ltmain.sh revision 48c85eb7
1d63fdb69Smrg
248c85eb7Smrg# libtool (GNU libtool) 2.4.2
3d63fdb69Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
4d63fdb69Smrg
555acc8fcSmrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
648c85eb7Smrg# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
7d63fdb69Smrg# This is free software; see the source for copying conditions.  There is NO
8d63fdb69Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9d63fdb69Smrg
10d63fdb69Smrg# GNU Libtool is free software; you can redistribute it and/or modify
113da084b3Smrg# it under the terms of the GNU General Public License as published by
123da084b3Smrg# the Free Software Foundation; either version 2 of the License, or
133da084b3Smrg# (at your option) any later version.
143da084b3Smrg#
15d63fdb69Smrg# As a special exception to the GNU General Public License,
16d63fdb69Smrg# if you distribute this file as part of a program or library that
17d63fdb69Smrg# is built using GNU Libtool, you may include this file under the
18d63fdb69Smrg# same distribution terms that you use for the rest of that program.
19d63fdb69Smrg#
20d63fdb69Smrg# GNU Libtool is distributed in the hope that it will be useful, but
213da084b3Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
223da084b3Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
233da084b3Smrg# General Public License for more details.
243da084b3Smrg#
253da084b3Smrg# You should have received a copy of the GNU General Public License
26d63fdb69Smrg# along with GNU Libtool; see the file COPYING.  If not, a copy
27d63fdb69Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html,
28d63fdb69Smrg# or obtained by writing to the Free Software Foundation, Inc.,
29d63fdb69Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30d63fdb69Smrg
31d63fdb69Smrg# Usage: $progname [OPTION]... [MODE-ARG]...
32d63fdb69Smrg#
33d63fdb69Smrg# Provide generalized library-building support services.
343da084b3Smrg#
3555acc8fcSmrg#       --config             show all configuration variables
3655acc8fcSmrg#       --debug              enable verbose shell tracing
3755acc8fcSmrg#   -n, --dry-run            display commands without modifying any files
3855acc8fcSmrg#       --features           display basic configuration information and exit
3955acc8fcSmrg#       --mode=MODE          use operation mode MODE
4055acc8fcSmrg#       --preserve-dup-deps  don't remove duplicate dependency libraries
4155acc8fcSmrg#       --quiet, --silent    don't print informational messages
4255acc8fcSmrg#       --no-quiet, --no-silent
4355acc8fcSmrg#                            print informational messages (default)
4448c85eb7Smrg#       --no-warn            don't display warning messages
4555acc8fcSmrg#       --tag=TAG            use configuration variables from tag TAG
4655acc8fcSmrg#   -v, --verbose            print more informational messages than default
4755acc8fcSmrg#       --no-verbose         don't print the extra informational messages
4855acc8fcSmrg#       --version            print version information
4955acc8fcSmrg#   -h, --help, --help-all   print short, long, or detailed help message
50d63fdb69Smrg#
51d63fdb69Smrg# MODE must be one of the following:
52d63fdb69Smrg#
5355acc8fcSmrg#         clean              remove files from the build directory
5455acc8fcSmrg#         compile            compile a source file into a libtool object
5555acc8fcSmrg#         execute            automatically set library path, then run a program
5655acc8fcSmrg#         finish             complete the installation of libtool libraries
5755acc8fcSmrg#         install            install libraries or executables
5855acc8fcSmrg#         link               create a library or an executable
5955acc8fcSmrg#         uninstall          remove libraries from an installed directory
60d63fdb69Smrg#
6155acc8fcSmrg# MODE-ARGS vary depending on the MODE.  When passed as first option,
6255acc8fcSmrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
63d63fdb69Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
64d63fdb69Smrg#
65d63fdb69Smrg# When reporting a bug, please describe a test case to reproduce it and
66d63fdb69Smrg# include the following information:
67d63fdb69Smrg#
6855acc8fcSmrg#         host-triplet:	$host
6955acc8fcSmrg#         shell:		$SHELL
7055acc8fcSmrg#         compiler:		$LTCC
7155acc8fcSmrg#         compiler flags:		$LTCFLAGS
7255acc8fcSmrg#         linker:		$LD (gnu? $with_gnu_ld)
7348c85eb7Smrg#         $progname:	(GNU libtool) 2.4.2
7455acc8fcSmrg#         automake:	$automake_version
7555acc8fcSmrg#         autoconf:	$autoconf_version
76d63fdb69Smrg#
77d63fdb69Smrg# Report bugs to <bug-libtool@gnu.org>.
7848c85eb7Smrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
7948c85eb7Smrg# General help using GNU software: <http://www.gnu.org/gethelp/>.
80d63fdb69Smrg
8155acc8fcSmrgPROGRAM=libtool
82d63fdb69SmrgPACKAGE=libtool
8348c85eb7SmrgVERSION=2.4.2
84d63fdb69SmrgTIMESTAMP=""
8548c85eb7Smrgpackage_revision=1.3337
86d63fdb69Smrg
87d63fdb69Smrg# Be Bourne compatible
88d63fdb69Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
89d63fdb69Smrg  emulate sh
90d63fdb69Smrg  NULLCMD=:
91d63fdb69Smrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
92d63fdb69Smrg  # is contrary to our usage.  Disable this feature.
93d63fdb69Smrg  alias -g '${1+"$@"}'='"$@"'
94d63fdb69Smrg  setopt NO_GLOB_SUBST
95d63fdb69Smrgelse
96d63fdb69Smrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
97d63fdb69Smrgfi
98d63fdb69SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
99d63fdb69SmrgDUALCASE=1; export DUALCASE # for MKS sh
100d63fdb69Smrg
10155acc8fcSmrg# A function that is used when there is no print builtin or printf.
10255acc8fcSmrgfunc_fallback_echo ()
10355acc8fcSmrg{
10455acc8fcSmrg  eval 'cat <<_LTECHO_EOF
10555acc8fcSmrg$1
10655acc8fcSmrg_LTECHO_EOF'
10755acc8fcSmrg}
10855acc8fcSmrg
109d63fdb69Smrg# NLS nuisances: We save the old values to restore during execute mode.
110d63fdb69Smrglt_user_locale=
111d63fdb69Smrglt_safe_locale=
112d63fdb69Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
113d63fdb69Smrgdo
114d63fdb69Smrg  eval "if test \"\${$lt_var+set}\" = set; then
115d63fdb69Smrg          save_$lt_var=\$$lt_var
116d63fdb69Smrg          $lt_var=C
117d63fdb69Smrg	  export $lt_var
118d63fdb69Smrg	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
119d63fdb69Smrg	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
120d63fdb69Smrg	fi"
121d63fdb69Smrgdone
12255acc8fcSmrgLC_ALL=C
12355acc8fcSmrgLANGUAGE=C
12455acc8fcSmrgexport LANGUAGE LC_ALL
125d63fdb69Smrg
126d63fdb69Smrg$lt_unset CDPATH
127d63fdb69Smrg
128d63fdb69Smrg
12955acc8fcSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
13055acc8fcSmrg# is ksh but when the shell is invoked as "sh" and the current value of
13155acc8fcSmrg# the _XPG environment variable is not equal to 1 (one), the special
13255acc8fcSmrg# positional parameter $0, within a function call, is the name of the
13355acc8fcSmrg# function.
13455acc8fcSmrgprogpath="$0"
135d63fdb69Smrg
136d63fdb69Smrg
137d63fdb69Smrg
138d63fdb69Smrg: ${CP="cp -f"}
13955acc8fcSmrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
140d63fdb69Smrg: ${MAKE="make"}
141d63fdb69Smrg: ${MKDIR="mkdir"}
142d63fdb69Smrg: ${MV="mv -f"}
143d63fdb69Smrg: ${RM="rm -f"}
144d63fdb69Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
145d63fdb69Smrg: ${Xsed="$SED -e 1s/^X//"}
1463da084b3Smrg
147d63fdb69Smrg# Global variables:
148d63fdb69SmrgEXIT_SUCCESS=0
149d63fdb69SmrgEXIT_FAILURE=1
150d63fdb69SmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
151d63fdb69SmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
152d63fdb69Smrg
153d63fdb69Smrgexit_status=$EXIT_SUCCESS
154d63fdb69Smrg
155d63fdb69Smrg# Make sure IFS has a sensible default
156d63fdb69Smrglt_nl='
157d63fdb69Smrg'
158d63fdb69SmrgIFS=" 	$lt_nl"
159d63fdb69Smrg
160d63fdb69Smrgdirname="s,/[^/]*$,,"
161d63fdb69Smrgbasename="s,^.*/,,"
162d63fdb69Smrg
16348c85eb7Smrg# func_dirname file append nondir_replacement
16448c85eb7Smrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
16548c85eb7Smrg# otherwise set result to NONDIR_REPLACEMENT.
16648c85eb7Smrgfunc_dirname ()
16748c85eb7Smrg{
16848c85eb7Smrg    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
16948c85eb7Smrg    if test "X$func_dirname_result" = "X${1}"; then
17048c85eb7Smrg      func_dirname_result="${3}"
17148c85eb7Smrg    else
17248c85eb7Smrg      func_dirname_result="$func_dirname_result${2}"
17348c85eb7Smrg    fi
17448c85eb7Smrg} # func_dirname may be replaced by extended shell implementation
17548c85eb7Smrg
17648c85eb7Smrg
17748c85eb7Smrg# func_basename file
17848c85eb7Smrgfunc_basename ()
17948c85eb7Smrg{
18048c85eb7Smrg    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
18148c85eb7Smrg} # func_basename may be replaced by extended shell implementation
18248c85eb7Smrg
18348c85eb7Smrg
184d63fdb69Smrg# func_dirname_and_basename file append nondir_replacement
185d63fdb69Smrg# perform func_basename and func_dirname in a single function
186d63fdb69Smrg# call:
187d63fdb69Smrg#   dirname:  Compute the dirname of FILE.  If nonempty,
188d63fdb69Smrg#             add APPEND to the result, otherwise set result
189d63fdb69Smrg#             to NONDIR_REPLACEMENT.
190d63fdb69Smrg#             value returned in "$func_dirname_result"
191d63fdb69Smrg#   basename: Compute filename of FILE.
192d63fdb69Smrg#             value retuned in "$func_basename_result"
193d63fdb69Smrg# Implementation must be kept synchronized with func_dirname
194d63fdb69Smrg# and func_basename. For efficiency, we do not delegate to
195d63fdb69Smrg# those functions but instead duplicate the functionality here.
196d63fdb69Smrgfunc_dirname_and_basename ()
197d63fdb69Smrg{
19848c85eb7Smrg    # Extract subdirectory from the argument.
19948c85eb7Smrg    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
20048c85eb7Smrg    if test "X$func_dirname_result" = "X${1}"; then
20148c85eb7Smrg      func_dirname_result="${3}"
20248c85eb7Smrg    else
20348c85eb7Smrg      func_dirname_result="$func_dirname_result${2}"
20448c85eb7Smrg    fi
20548c85eb7Smrg    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
20648c85eb7Smrg} # func_dirname_and_basename may be replaced by extended shell implementation
20748c85eb7Smrg
20848c85eb7Smrg
20948c85eb7Smrg# func_stripname prefix suffix name
21048c85eb7Smrg# strip PREFIX and SUFFIX off of NAME.
21148c85eb7Smrg# PREFIX and SUFFIX must not contain globbing or regex special
21248c85eb7Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading
21348c85eb7Smrg# dot (in which case that matches only a dot).
21448c85eb7Smrg# func_strip_suffix prefix name
21548c85eb7Smrgfunc_stripname ()
21648c85eb7Smrg{
21748c85eb7Smrg    case ${2} in
21848c85eb7Smrg      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
21948c85eb7Smrg      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
22048c85eb7Smrg    esac
22148c85eb7Smrg} # func_stripname may be replaced by extended shell implementation
222d63fdb69Smrg
2233da084b3Smrg
22455acc8fcSmrg# These SED scripts presuppose an absolute path with a trailing slash.
22555acc8fcSmrgpathcar='s,^/\([^/]*\).*$,\1,'
22655acc8fcSmrgpathcdr='s,^/[^/]*,,'
22755acc8fcSmrgremovedotparts=':dotsl
22855acc8fcSmrg		s@/\./@/@g
22955acc8fcSmrg		t dotsl
23055acc8fcSmrg		s,/\.$,/,'
23155acc8fcSmrgcollapseslashes='s@/\{1,\}@/@g'
23255acc8fcSmrgfinalslash='s,/*$,/,'
23355acc8fcSmrg
23455acc8fcSmrg# func_normal_abspath PATH
23555acc8fcSmrg# Remove doubled-up and trailing slashes, "." path components,
23655acc8fcSmrg# and cancel out any ".." path components in PATH after making
23755acc8fcSmrg# it an absolute path.
23855acc8fcSmrg#             value returned in "$func_normal_abspath_result"
23955acc8fcSmrgfunc_normal_abspath ()
24055acc8fcSmrg{
24155acc8fcSmrg  # Start from root dir and reassemble the path.
24255acc8fcSmrg  func_normal_abspath_result=
24355acc8fcSmrg  func_normal_abspath_tpath=$1
24455acc8fcSmrg  func_normal_abspath_altnamespace=
24555acc8fcSmrg  case $func_normal_abspath_tpath in
24655acc8fcSmrg    "")
24755acc8fcSmrg      # Empty path, that just means $cwd.
24855acc8fcSmrg      func_stripname '' '/' "`pwd`"
24955acc8fcSmrg      func_normal_abspath_result=$func_stripname_result
25055acc8fcSmrg      return
25155acc8fcSmrg    ;;
25255acc8fcSmrg    # The next three entries are used to spot a run of precisely
25355acc8fcSmrg    # two leading slashes without using negated character classes;
25455acc8fcSmrg    # we take advantage of case's first-match behaviour.
25555acc8fcSmrg    ///*)
25655acc8fcSmrg      # Unusual form of absolute path, do nothing.
25755acc8fcSmrg    ;;
25855acc8fcSmrg    //*)
25955acc8fcSmrg      # Not necessarily an ordinary path; POSIX reserves leading '//'
26055acc8fcSmrg      # and for example Cygwin uses it to access remote file shares
26155acc8fcSmrg      # over CIFS/SMB, so we conserve a leading double slash if found.
26255acc8fcSmrg      func_normal_abspath_altnamespace=/
26355acc8fcSmrg    ;;
26455acc8fcSmrg    /*)
26555acc8fcSmrg      # Absolute path, do nothing.
26655acc8fcSmrg    ;;
26755acc8fcSmrg    *)
26855acc8fcSmrg      # Relative path, prepend $cwd.
26955acc8fcSmrg      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
27055acc8fcSmrg    ;;
27155acc8fcSmrg  esac
27255acc8fcSmrg  # Cancel out all the simple stuff to save iterations.  We also want
27355acc8fcSmrg  # the path to end with a slash for ease of parsing, so make sure
27455acc8fcSmrg  # there is one (and only one) here.
27555acc8fcSmrg  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
27655acc8fcSmrg        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
27755acc8fcSmrg  while :; do
27855acc8fcSmrg    # Processed it all yet?
27955acc8fcSmrg    if test "$func_normal_abspath_tpath" = / ; then
28055acc8fcSmrg      # If we ascended to the root using ".." the result may be empty now.
28155acc8fcSmrg      if test -z "$func_normal_abspath_result" ; then
28255acc8fcSmrg        func_normal_abspath_result=/
28355acc8fcSmrg      fi
28455acc8fcSmrg      break
28555acc8fcSmrg    fi
28655acc8fcSmrg    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
28755acc8fcSmrg        -e "$pathcar"`
28855acc8fcSmrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
28955acc8fcSmrg        -e "$pathcdr"`
29055acc8fcSmrg    # Figure out what to do with it
29155acc8fcSmrg    case $func_normal_abspath_tcomponent in
29255acc8fcSmrg      "")
29355acc8fcSmrg        # Trailing empty path component, ignore it.
29455acc8fcSmrg      ;;
29555acc8fcSmrg      ..)
29655acc8fcSmrg        # Parent dir; strip last assembled component from result.
29755acc8fcSmrg        func_dirname "$func_normal_abspath_result"
29855acc8fcSmrg        func_normal_abspath_result=$func_dirname_result
29955acc8fcSmrg      ;;
30055acc8fcSmrg      *)
30155acc8fcSmrg        # Actual path component, append it.
30255acc8fcSmrg        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
30355acc8fcSmrg      ;;
30455acc8fcSmrg    esac
30555acc8fcSmrg  done
30655acc8fcSmrg  # Restore leading double-slash if one was found on entry.
30755acc8fcSmrg  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
30855acc8fcSmrg}
30955acc8fcSmrg
31055acc8fcSmrg# func_relative_path SRCDIR DSTDIR
31155acc8fcSmrg# generates a relative path from SRCDIR to DSTDIR, with a trailing
31255acc8fcSmrg# slash if non-empty, suitable for immediately appending a filename
31355acc8fcSmrg# without needing to append a separator.
31455acc8fcSmrg#             value returned in "$func_relative_path_result"
31555acc8fcSmrgfunc_relative_path ()
31655acc8fcSmrg{
31755acc8fcSmrg  func_relative_path_result=
31855acc8fcSmrg  func_normal_abspath "$1"
31955acc8fcSmrg  func_relative_path_tlibdir=$func_normal_abspath_result
32055acc8fcSmrg  func_normal_abspath "$2"
32155acc8fcSmrg  func_relative_path_tbindir=$func_normal_abspath_result
32255acc8fcSmrg
32355acc8fcSmrg  # Ascend the tree starting from libdir
32455acc8fcSmrg  while :; do
32555acc8fcSmrg    # check if we have found a prefix of bindir
32655acc8fcSmrg    case $func_relative_path_tbindir in
32755acc8fcSmrg      $func_relative_path_tlibdir)
32855acc8fcSmrg        # found an exact match
32955acc8fcSmrg        func_relative_path_tcancelled=
33055acc8fcSmrg        break
33155acc8fcSmrg        ;;
33255acc8fcSmrg      $func_relative_path_tlibdir*)
33355acc8fcSmrg        # found a matching prefix
33455acc8fcSmrg        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
33555acc8fcSmrg        func_relative_path_tcancelled=$func_stripname_result
33655acc8fcSmrg        if test -z "$func_relative_path_result"; then
33755acc8fcSmrg          func_relative_path_result=.
33855acc8fcSmrg        fi
33955acc8fcSmrg        break
34055acc8fcSmrg        ;;
34155acc8fcSmrg      *)
34255acc8fcSmrg        func_dirname $func_relative_path_tlibdir
34355acc8fcSmrg        func_relative_path_tlibdir=${func_dirname_result}
34455acc8fcSmrg        if test "x$func_relative_path_tlibdir" = x ; then
34555acc8fcSmrg          # Have to descend all the way to the root!
34655acc8fcSmrg          func_relative_path_result=../$func_relative_path_result
34755acc8fcSmrg          func_relative_path_tcancelled=$func_relative_path_tbindir
34855acc8fcSmrg          break
34955acc8fcSmrg        fi
35055acc8fcSmrg        func_relative_path_result=../$func_relative_path_result
35155acc8fcSmrg        ;;
35255acc8fcSmrg    esac
35355acc8fcSmrg  done
35455acc8fcSmrg
35555acc8fcSmrg  # Now calculate path; take care to avoid doubling-up slashes.
35655acc8fcSmrg  func_stripname '' '/' "$func_relative_path_result"
35755acc8fcSmrg  func_relative_path_result=$func_stripname_result
35855acc8fcSmrg  func_stripname '/' '/' "$func_relative_path_tcancelled"
35955acc8fcSmrg  if test "x$func_stripname_result" != x ; then
36055acc8fcSmrg    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
36155acc8fcSmrg  fi
36255acc8fcSmrg
36355acc8fcSmrg  # Normalisation. If bindir is libdir, return empty string,
36455acc8fcSmrg  # else relative path ending with a slash; either way, target
36555acc8fcSmrg  # file name can be directly appended.
36655acc8fcSmrg  if test ! -z "$func_relative_path_result"; then
36755acc8fcSmrg    func_stripname './' '' "$func_relative_path_result/"
36855acc8fcSmrg    func_relative_path_result=$func_stripname_result
36955acc8fcSmrg  fi
37055acc8fcSmrg}
3713da084b3Smrg
3723da084b3Smrg# The name of this program:
373d63fdb69Smrgfunc_dirname_and_basename "$progpath"
374d63fdb69Smrgprogname=$func_basename_result
3753da084b3Smrg
376d63fdb69Smrg# Make sure we have an absolute path for reexecution:
377d63fdb69Smrgcase $progpath in
378d63fdb69Smrg  [\\/]*|[A-Za-z]:\\*) ;;
379d63fdb69Smrg  *[\\/]*)
380d63fdb69Smrg     progdir=$func_dirname_result
381d63fdb69Smrg     progdir=`cd "$progdir" && pwd`
382d63fdb69Smrg     progpath="$progdir/$progname"
383d63fdb69Smrg     ;;
384d63fdb69Smrg  *)
385d63fdb69Smrg     save_IFS="$IFS"
38648c85eb7Smrg     IFS=${PATH_SEPARATOR-:}
387d63fdb69Smrg     for progdir in $PATH; do
388d63fdb69Smrg       IFS="$save_IFS"
389d63fdb69Smrg       test -x "$progdir/$progname" && break
390d63fdb69Smrg     done
391d63fdb69Smrg     IFS="$save_IFS"
392d63fdb69Smrg     test -n "$progdir" || progdir=`pwd`
393d63fdb69Smrg     progpath="$progdir/$progname"
394d63fdb69Smrg     ;;
395d63fdb69Smrgesac
3963da084b3Smrg
397d63fdb69Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
398d63fdb69Smrg# metacharacters that are still active within double-quoted strings.
399d63fdb69SmrgXsed="${SED}"' -e 1s/^X//'
400d63fdb69Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
401d63fdb69Smrg
402d63fdb69Smrg# Same as above, but do not quote variable references.
403d63fdb69Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
404d63fdb69Smrg
40548c85eb7Smrg# Sed substitution that turns a string into a regex matching for the
40648c85eb7Smrg# string literally.
40748c85eb7Smrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
40848c85eb7Smrg
40948c85eb7Smrg# Sed substitution that converts a w32 file name or path
41048c85eb7Smrg# which contains forward slashes, into one that contains
41148c85eb7Smrg# (escaped) backslashes.  A very naive implementation.
41248c85eb7Smrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
41348c85eb7Smrg
414d63fdb69Smrg# Re-`\' parameter expansions in output of double_quote_subst that were
415d63fdb69Smrg# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
416d63fdb69Smrg# in input to double_quote_subst, that '$' was protected from expansion.
417d63fdb69Smrg# Since each input `\' is now two `\'s, look for any number of runs of
418d63fdb69Smrg# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
419d63fdb69Smrgbs='\\'
420d63fdb69Smrgbs2='\\\\'
421d63fdb69Smrgbs4='\\\\\\\\'
422d63fdb69Smrgdollar='\$'
423d63fdb69Smrgsed_double_backslash="\
424d63fdb69Smrg  s/$bs4/&\\
425d63fdb69Smrg/g
426d63fdb69Smrg  s/^$bs2$dollar/$bs&/
427d63fdb69Smrg  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
428d63fdb69Smrg  s/\n//g"
429d63fdb69Smrg
430d63fdb69Smrg# Standard options:
431d63fdb69Smrgopt_dry_run=false
432d63fdb69Smrgopt_help=false
433d63fdb69Smrgopt_quiet=false
434d63fdb69Smrgopt_verbose=false
435d63fdb69Smrgopt_warning=:
436d63fdb69Smrg
437d63fdb69Smrg# func_echo arg...
438d63fdb69Smrg# Echo program name prefixed message, along with the current mode
439d63fdb69Smrg# name if it has been set yet.
440d63fdb69Smrgfunc_echo ()
441d63fdb69Smrg{
44248c85eb7Smrg    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
443d63fdb69Smrg}
4443da084b3Smrg
445d63fdb69Smrg# func_verbose arg...
446d63fdb69Smrg# Echo program name prefixed message in verbose mode only.
447d63fdb69Smrgfunc_verbose ()
448d63fdb69Smrg{
449d63fdb69Smrg    $opt_verbose && func_echo ${1+"$@"}
4503da084b3Smrg
451d63fdb69Smrg    # A bug in bash halts the script if the last line of a function
452d63fdb69Smrg    # fails when set -e is in force, so we need another command to
453d63fdb69Smrg    # work around that:
454d63fdb69Smrg    :
455d63fdb69Smrg}
4563da084b3Smrg
45755acc8fcSmrg# func_echo_all arg...
45855acc8fcSmrg# Invoke $ECHO with all args, space-separated.
45955acc8fcSmrgfunc_echo_all ()
46055acc8fcSmrg{
46155acc8fcSmrg    $ECHO "$*"
46255acc8fcSmrg}
46355acc8fcSmrg
464d63fdb69Smrg# func_error arg...
465d63fdb69Smrg# Echo program name prefixed message to standard error.
466d63fdb69Smrgfunc_error ()
467d63fdb69Smrg{
46848c85eb7Smrg    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
469d63fdb69Smrg}
4703da084b3Smrg
471d63fdb69Smrg# func_warning arg...
472d63fdb69Smrg# Echo program name prefixed warning message to standard error.
473d63fdb69Smrgfunc_warning ()
474d63fdb69Smrg{
47548c85eb7Smrg    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
4763da084b3Smrg
477d63fdb69Smrg    # bash bug again:
478d63fdb69Smrg    :
479d63fdb69Smrg}
4803da084b3Smrg
481d63fdb69Smrg# func_fatal_error arg...
482d63fdb69Smrg# Echo program name prefixed message to standard error, and exit.
483d63fdb69Smrgfunc_fatal_error ()
484d63fdb69Smrg{
485d63fdb69Smrg    func_error ${1+"$@"}
486d63fdb69Smrg    exit $EXIT_FAILURE
487d63fdb69Smrg}
4883da084b3Smrg
489d63fdb69Smrg# func_fatal_help arg...
490d63fdb69Smrg# Echo program name prefixed message to standard error, followed by
491d63fdb69Smrg# a help hint, and exit.
492d63fdb69Smrgfunc_fatal_help ()
493d63fdb69Smrg{
494d63fdb69Smrg    func_error ${1+"$@"}
495d63fdb69Smrg    func_fatal_error "$help"
496d63fdb69Smrg}
497d63fdb69Smrghelp="Try \`$progname --help' for more information."  ## default
4983da084b3Smrg
4993da084b3Smrg
500d63fdb69Smrg# func_grep expression filename
501d63fdb69Smrg# Check whether EXPRESSION matches any line of FILENAME, without output.
502d63fdb69Smrgfunc_grep ()
503d63fdb69Smrg{
504d63fdb69Smrg    $GREP "$1" "$2" >/dev/null 2>&1
505d63fdb69Smrg}
506d63fdb69Smrg
507d63fdb69Smrg
508d63fdb69Smrg# func_mkdir_p directory-path
509d63fdb69Smrg# Make sure the entire path to DIRECTORY-PATH is available.
510d63fdb69Smrgfunc_mkdir_p ()
511d63fdb69Smrg{
512d63fdb69Smrg    my_directory_path="$1"
513d63fdb69Smrg    my_dir_list=
514d63fdb69Smrg
515d63fdb69Smrg    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
516d63fdb69Smrg
517d63fdb69Smrg      # Protect directory names starting with `-'
518d63fdb69Smrg      case $my_directory_path in
519d63fdb69Smrg        -*) my_directory_path="./$my_directory_path" ;;
520d63fdb69Smrg      esac
521d63fdb69Smrg
522d63fdb69Smrg      # While some portion of DIR does not yet exist...
523d63fdb69Smrg      while test ! -d "$my_directory_path"; do
524d63fdb69Smrg        # ...make a list in topmost first order.  Use a colon delimited
525d63fdb69Smrg	# list incase some portion of path contains whitespace.
526d63fdb69Smrg        my_dir_list="$my_directory_path:$my_dir_list"
527d63fdb69Smrg
528d63fdb69Smrg        # If the last portion added has no slash in it, the list is done
529d63fdb69Smrg        case $my_directory_path in */*) ;; *) break ;; esac
530d63fdb69Smrg
531d63fdb69Smrg        # ...otherwise throw away the child directory and loop
53255acc8fcSmrg        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
533d63fdb69Smrg      done
53455acc8fcSmrg      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
535d63fdb69Smrg
536d63fdb69Smrg      save_mkdir_p_IFS="$IFS"; IFS=':'
537d63fdb69Smrg      for my_dir in $my_dir_list; do
538d63fdb69Smrg	IFS="$save_mkdir_p_IFS"
539d63fdb69Smrg        # mkdir can fail with a `File exist' error if two processes
540d63fdb69Smrg        # try to create one of the directories concurrently.  Don't
541d63fdb69Smrg        # stop in that case!
542d63fdb69Smrg        $MKDIR "$my_dir" 2>/dev/null || :
543d63fdb69Smrg      done
544d63fdb69Smrg      IFS="$save_mkdir_p_IFS"
545d63fdb69Smrg
546d63fdb69Smrg      # Bail out if we (or some other process) failed to create a directory.
547d63fdb69Smrg      test -d "$my_directory_path" || \
548d63fdb69Smrg        func_fatal_error "Failed to create \`$1'"
549d63fdb69Smrg    fi
550d63fdb69Smrg}
5513da084b3Smrg
5523da084b3Smrg
5533da084b3Smrg# func_mktempdir [string]
5543da084b3Smrg# Make a temporary directory that won't clash with other running
5553da084b3Smrg# libtool processes, and avoids race conditions if possible.  If
5563da084b3Smrg# given, STRING is the basename for that directory.
5573da084b3Smrgfunc_mktempdir ()
5583da084b3Smrg{
5593da084b3Smrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
5603da084b3Smrg
561d63fdb69Smrg    if test "$opt_dry_run" = ":"; then
5623da084b3Smrg      # Return a directory name, but don't create it in dry-run mode
5633da084b3Smrg      my_tmpdir="${my_template}-$$"
5643da084b3Smrg    else
5653da084b3Smrg
5663da084b3Smrg      # If mktemp works, use that first and foremost
5673da084b3Smrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
5683da084b3Smrg
5693da084b3Smrg      if test ! -d "$my_tmpdir"; then
570d63fdb69Smrg        # Failing that, at least try and use $RANDOM to avoid a race
571d63fdb69Smrg        my_tmpdir="${my_template}-${RANDOM-0}$$"
5723da084b3Smrg
573d63fdb69Smrg        save_mktempdir_umask=`umask`
574d63fdb69Smrg        umask 0077
575d63fdb69Smrg        $MKDIR "$my_tmpdir"
576d63fdb69Smrg        umask $save_mktempdir_umask
5773da084b3Smrg      fi
5783da084b3Smrg
5793da084b3Smrg      # If we're not in dry-run mode, bomb out on failure
580d63fdb69Smrg      test -d "$my_tmpdir" || \
581d63fdb69Smrg        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
5823da084b3Smrg    fi
5833da084b3Smrg
58455acc8fcSmrg    $ECHO "$my_tmpdir"
5853da084b3Smrg}
5863da084b3Smrg
5873da084b3Smrg
588d63fdb69Smrg# func_quote_for_eval arg
589d63fdb69Smrg# Aesthetically quote ARG to be evaled later.
590d63fdb69Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
591d63fdb69Smrg# is double-quoted, suitable for a subsequent eval, whereas
592d63fdb69Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
593d63fdb69Smrg# which are still active within double quotes backslashified.
594d63fdb69Smrgfunc_quote_for_eval ()
5953da084b3Smrg{
596d63fdb69Smrg    case $1 in
597d63fdb69Smrg      *[\\\`\"\$]*)
59855acc8fcSmrg	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
599d63fdb69Smrg      *)
600d63fdb69Smrg        func_quote_for_eval_unquoted_result="$1" ;;
601d63fdb69Smrg    esac
602d63fdb69Smrg
603d63fdb69Smrg    case $func_quote_for_eval_unquoted_result in
604d63fdb69Smrg      # Double-quote args containing shell metacharacters to delay
605d63fdb69Smrg      # word splitting, command substitution and and variable
606d63fdb69Smrg      # expansion for a subsequent eval.
607d63fdb69Smrg      # Many Bourne shells cannot handle close brackets correctly
608d63fdb69Smrg      # in scan sets, so we specify it separately.
609d63fdb69Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
610d63fdb69Smrg        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
611d63fdb69Smrg        ;;
612d63fdb69Smrg      *)
613d63fdb69Smrg        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
6143da084b3Smrg    esac
6153da084b3Smrg}
6163da084b3Smrg
6173da084b3Smrg
618d63fdb69Smrg# func_quote_for_expand arg
619d63fdb69Smrg# Aesthetically quote ARG to be evaled later; same as above,
620d63fdb69Smrg# but do not quote variable references.
621d63fdb69Smrgfunc_quote_for_expand ()
6223da084b3Smrg{
623d63fdb69Smrg    case $1 in
624d63fdb69Smrg      *[\\\`\"]*)
62555acc8fcSmrg	my_arg=`$ECHO "$1" | $SED \
626d63fdb69Smrg	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
6273da084b3Smrg      *)
628d63fdb69Smrg        my_arg="$1" ;;
629d63fdb69Smrg    esac
630d63fdb69Smrg
631d63fdb69Smrg    case $my_arg in
632d63fdb69Smrg      # Double-quote args containing shell metacharacters to delay
633d63fdb69Smrg      # word splitting and command substitution for a subsequent eval.
634d63fdb69Smrg      # Many Bourne shells cannot handle close brackets correctly
635d63fdb69Smrg      # in scan sets, so we specify it separately.
636d63fdb69Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
637d63fdb69Smrg        my_arg="\"$my_arg\""
638d63fdb69Smrg        ;;
639d63fdb69Smrg    esac
640d63fdb69Smrg
641d63fdb69Smrg    func_quote_for_expand_result="$my_arg"
6423da084b3Smrg}
6433da084b3Smrg
6443da084b3Smrg
645d63fdb69Smrg# func_show_eval cmd [fail_exp]
646d63fdb69Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
647d63fdb69Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
648d63fdb69Smrg# is given, then evaluate it.
649d63fdb69Smrgfunc_show_eval ()
6503da084b3Smrg{
651d63fdb69Smrg    my_cmd="$1"
652d63fdb69Smrg    my_fail_exp="${2-:}"
6533da084b3Smrg
654d63fdb69Smrg    ${opt_silent-false} || {
655d63fdb69Smrg      func_quote_for_expand "$my_cmd"
656d63fdb69Smrg      eval "func_echo $func_quote_for_expand_result"
657d63fdb69Smrg    }
658d63fdb69Smrg
659d63fdb69Smrg    if ${opt_dry_run-false}; then :; else
660d63fdb69Smrg      eval "$my_cmd"
661d63fdb69Smrg      my_status=$?
662d63fdb69Smrg      if test "$my_status" -eq 0; then :; else
663d63fdb69Smrg	eval "(exit $my_status); $my_fail_exp"
664d63fdb69Smrg      fi
6653da084b3Smrg    fi
6663da084b3Smrg}
6673da084b3Smrg
668d63fdb69Smrg
669d63fdb69Smrg# func_show_eval_locale cmd [fail_exp]
670d63fdb69Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
671d63fdb69Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
672d63fdb69Smrg# is given, then evaluate it.  Use the saved locale for evaluation.
673d63fdb69Smrgfunc_show_eval_locale ()
6743da084b3Smrg{
675d63fdb69Smrg    my_cmd="$1"
676d63fdb69Smrg    my_fail_exp="${2-:}"
6773da084b3Smrg
678d63fdb69Smrg    ${opt_silent-false} || {
679d63fdb69Smrg      func_quote_for_expand "$my_cmd"
680d63fdb69Smrg      eval "func_echo $func_quote_for_expand_result"
681d63fdb69Smrg    }
682d63fdb69Smrg
683d63fdb69Smrg    if ${opt_dry_run-false}; then :; else
684d63fdb69Smrg      eval "$lt_user_locale
685d63fdb69Smrg	    $my_cmd"
686d63fdb69Smrg      my_status=$?
687d63fdb69Smrg      eval "$lt_safe_locale"
688d63fdb69Smrg      if test "$my_status" -eq 0; then :; else
689d63fdb69Smrg	eval "(exit $my_status); $my_fail_exp"
6903da084b3Smrg      fi
691d63fdb69Smrg    fi
6923da084b3Smrg}
6933da084b3Smrg
69448c85eb7Smrg# func_tr_sh
69548c85eb7Smrg# Turn $1 into a string suitable for a shell variable name.
69648c85eb7Smrg# Result is stored in $func_tr_sh_result.  All characters
69748c85eb7Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
69848c85eb7Smrg# if $1 begins with a digit, a '_' is prepended as well.
69948c85eb7Smrgfunc_tr_sh ()
70048c85eb7Smrg{
70148c85eb7Smrg  case $1 in
70248c85eb7Smrg  [0-9]* | *[!a-zA-Z0-9_]*)
70348c85eb7Smrg    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
70448c85eb7Smrg    ;;
70548c85eb7Smrg  * )
70648c85eb7Smrg    func_tr_sh_result=$1
70748c85eb7Smrg    ;;
70848c85eb7Smrg  esac
70948c85eb7Smrg}
71048c85eb7Smrg
7113da084b3Smrg
712d63fdb69Smrg# func_version
713d63fdb69Smrg# Echo version message to standard output and exit.
714d63fdb69Smrgfunc_version ()
715d63fdb69Smrg{
71648c85eb7Smrg    $opt_debug
71748c85eb7Smrg
71855acc8fcSmrg    $SED -n '/(C)/!b go
71955acc8fcSmrg	:more
72055acc8fcSmrg	/\./!{
72155acc8fcSmrg	  N
72255acc8fcSmrg	  s/\n# / /
72355acc8fcSmrg	  b more
72455acc8fcSmrg	}
72555acc8fcSmrg	:go
72655acc8fcSmrg	/^# '$PROGRAM' (GNU /,/# warranty; / {
727d63fdb69Smrg        s/^# //
728d63fdb69Smrg	s/^# *$//
729d63fdb69Smrg        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
730d63fdb69Smrg        p
731d63fdb69Smrg     }' < "$progpath"
732d63fdb69Smrg     exit $?
733d63fdb69Smrg}
734d63fdb69Smrg
735d63fdb69Smrg# func_usage
736d63fdb69Smrg# Echo short help message to standard output and exit.
737d63fdb69Smrgfunc_usage ()
738d63fdb69Smrg{
73948c85eb7Smrg    $opt_debug
74048c85eb7Smrg
74155acc8fcSmrg    $SED -n '/^# Usage:/,/^#  *.*--help/ {
742d63fdb69Smrg        s/^# //
743d63fdb69Smrg	s/^# *$//
744d63fdb69Smrg	s/\$progname/'$progname'/
745d63fdb69Smrg	p
746d63fdb69Smrg    }' < "$progpath"
74755acc8fcSmrg    echo
748d63fdb69Smrg    $ECHO "run \`$progname --help | more' for full usage"
749d63fdb69Smrg    exit $?
750d63fdb69Smrg}
751d63fdb69Smrg
75255acc8fcSmrg# func_help [NOEXIT]
75355acc8fcSmrg# Echo long help message to standard output and exit,
75455acc8fcSmrg# unless 'noexit' is passed as argument.
755d63fdb69Smrgfunc_help ()
756d63fdb69Smrg{
75748c85eb7Smrg    $opt_debug
75848c85eb7Smrg
759d63fdb69Smrg    $SED -n '/^# Usage:/,/# Report bugs to/ {
76048c85eb7Smrg	:print
761d63fdb69Smrg        s/^# //
762d63fdb69Smrg	s/^# *$//
763d63fdb69Smrg	s*\$progname*'$progname'*
764d63fdb69Smrg	s*\$host*'"$host"'*
765d63fdb69Smrg	s*\$SHELL*'"$SHELL"'*
766d63fdb69Smrg	s*\$LTCC*'"$LTCC"'*
767d63fdb69Smrg	s*\$LTCFLAGS*'"$LTCFLAGS"'*
768d63fdb69Smrg	s*\$LD*'"$LD"'*
769d63fdb69Smrg	s/\$with_gnu_ld/'"$with_gnu_ld"'/
77048c85eb7Smrg	s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
77148c85eb7Smrg	s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
772d63fdb69Smrg	p
77348c85eb7Smrg	d
77448c85eb7Smrg     }
77548c85eb7Smrg     /^# .* home page:/b print
77648c85eb7Smrg     /^# General help using/b print
77748c85eb7Smrg     ' < "$progpath"
77855acc8fcSmrg    ret=$?
77955acc8fcSmrg    if test -z "$1"; then
78055acc8fcSmrg      exit $ret
78155acc8fcSmrg    fi
782d63fdb69Smrg}
783d63fdb69Smrg
784d63fdb69Smrg# func_missing_arg argname
785d63fdb69Smrg# Echo program name prefixed message to standard error and set global
786d63fdb69Smrg# exit_cmd.
787d63fdb69Smrgfunc_missing_arg ()
788d63fdb69Smrg{
78948c85eb7Smrg    $opt_debug
79048c85eb7Smrg
79155acc8fcSmrg    func_error "missing argument for $1."
792d63fdb69Smrg    exit_cmd=exit
793d63fdb69Smrg}
794d63fdb69Smrg
795d63fdb69Smrg
79648c85eb7Smrg# func_split_short_opt shortopt
79748c85eb7Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
79848c85eb7Smrg# variables after splitting SHORTOPT after the 2nd character.
79948c85eb7Smrgfunc_split_short_opt ()
80048c85eb7Smrg{
80148c85eb7Smrg    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
80248c85eb7Smrg    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
80348c85eb7Smrg
80448c85eb7Smrg    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
80548c85eb7Smrg    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
80648c85eb7Smrg} # func_split_short_opt may be replaced by extended shell implementation
80748c85eb7Smrg
80848c85eb7Smrg
80948c85eb7Smrg# func_split_long_opt longopt
81048c85eb7Smrg# Set func_split_long_opt_name and func_split_long_opt_arg shell
81148c85eb7Smrg# variables after splitting LONGOPT at the `=' sign.
81248c85eb7Smrgfunc_split_long_opt ()
81348c85eb7Smrg{
81448c85eb7Smrg    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
81548c85eb7Smrg    my_sed_long_arg='1s/^--[^=]*=//'
81648c85eb7Smrg
81748c85eb7Smrg    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
81848c85eb7Smrg    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
81948c85eb7Smrg} # func_split_long_opt may be replaced by extended shell implementation
82048c85eb7Smrg
82148c85eb7Smrgexit_cmd=:
822d63fdb69Smrg
823d63fdb69Smrg
824d63fdb69Smrg
825d63fdb69Smrg
8263da084b3Smrg
827d63fdb69Smrgmagic="%%%MAGIC variable%%%"
828d63fdb69Smrgmagic_exe="%%%MAGIC EXE variable%%%"
8293da084b3Smrg
830d63fdb69Smrg# Global variables.
831d63fdb69Smrgnonopt=
832d63fdb69Smrgpreserve_args=
833d63fdb69Smrglo2o="s/\\.lo\$/.${objext}/"
834d63fdb69Smrgo2lo="s/\\.${objext}\$/.lo/"
835d63fdb69Smrgextracted_archives=
836d63fdb69Smrgextracted_serial=0
8373da084b3Smrg
838d63fdb69Smrg# If this variable is set in any of the actions, the command in it
839d63fdb69Smrg# will be execed at the end.  This prevents here-documents from being
840d63fdb69Smrg# left over by shells.
841d63fdb69Smrgexec_cmd=
8423da084b3Smrg
84348c85eb7Smrg# func_append var value
84448c85eb7Smrg# Append VALUE to the end of shell variable VAR.
84548c85eb7Smrgfunc_append ()
84648c85eb7Smrg{
84748c85eb7Smrg    eval "${1}=\$${1}\${2}"
84848c85eb7Smrg} # func_append may be replaced by extended shell implementation
84948c85eb7Smrg
85048c85eb7Smrg# func_append_quoted var value
85148c85eb7Smrg# Quote VALUE and append to the end of shell variable VAR, separated
85248c85eb7Smrg# by a space.
85348c85eb7Smrgfunc_append_quoted ()
85448c85eb7Smrg{
85548c85eb7Smrg    func_quote_for_eval "${2}"
85648c85eb7Smrg    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
85748c85eb7Smrg} # func_append_quoted may be replaced by extended shell implementation
85848c85eb7Smrg
85948c85eb7Smrg
86048c85eb7Smrg# func_arith arithmetic-term...
86148c85eb7Smrgfunc_arith ()
86248c85eb7Smrg{
86348c85eb7Smrg    func_arith_result=`expr "${@}"`
86448c85eb7Smrg} # func_arith may be replaced by extended shell implementation
86548c85eb7Smrg
86648c85eb7Smrg
86748c85eb7Smrg# func_len string
86848c85eb7Smrg# STRING may not start with a hyphen.
86948c85eb7Smrgfunc_len ()
87048c85eb7Smrg{
87148c85eb7Smrg    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
87248c85eb7Smrg} # func_len may be replaced by extended shell implementation
87348c85eb7Smrg
87448c85eb7Smrg
87548c85eb7Smrg# func_lo2o object
87648c85eb7Smrgfunc_lo2o ()
87748c85eb7Smrg{
87848c85eb7Smrg    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
87948c85eb7Smrg} # func_lo2o may be replaced by extended shell implementation
88048c85eb7Smrg
88148c85eb7Smrg
88248c85eb7Smrg# func_xform libobj-or-source
88348c85eb7Smrgfunc_xform ()
88448c85eb7Smrg{
88548c85eb7Smrg    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
88648c85eb7Smrg} # func_xform may be replaced by extended shell implementation
88748c85eb7Smrg
88848c85eb7Smrg
889d63fdb69Smrg# func_fatal_configuration arg...
890d63fdb69Smrg# Echo program name prefixed message to standard error, followed by
891d63fdb69Smrg# a configuration failure hint, and exit.
892d63fdb69Smrgfunc_fatal_configuration ()
893d63fdb69Smrg{
894d63fdb69Smrg    func_error ${1+"$@"}
895d63fdb69Smrg    func_error "See the $PACKAGE documentation for more information."
896d63fdb69Smrg    func_fatal_error "Fatal configuration error."
897d63fdb69Smrg}
898d63fdb69Smrg
899d63fdb69Smrg
900d63fdb69Smrg# func_config
901d63fdb69Smrg# Display the configuration for all the tags in this script.
902d63fdb69Smrgfunc_config ()
903d63fdb69Smrg{
904d63fdb69Smrg    re_begincf='^# ### BEGIN LIBTOOL'
905d63fdb69Smrg    re_endcf='^# ### END LIBTOOL'
906d63fdb69Smrg
907d63fdb69Smrg    # Default configuration.
908d63fdb69Smrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
9093da084b3Smrg
9103da084b3Smrg    # Now print the configurations for the tags.
9113da084b3Smrg    for tagname in $taglist; do
912d63fdb69Smrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
9133da084b3Smrg    done
9143da084b3Smrg
915d63fdb69Smrg    exit $?
916d63fdb69Smrg}
9173da084b3Smrg
918d63fdb69Smrg# func_features
919d63fdb69Smrg# Display the features supported by this script.
920d63fdb69Smrgfunc_features ()
921d63fdb69Smrg{
92255acc8fcSmrg    echo "host: $host"
9233da084b3Smrg    if test "$build_libtool_libs" = yes; then
92455acc8fcSmrg      echo "enable shared libraries"
9253da084b3Smrg    else
92655acc8fcSmrg      echo "disable shared libraries"
9273da084b3Smrg    fi
9283da084b3Smrg    if test "$build_old_libs" = yes; then
92955acc8fcSmrg      echo "enable static libraries"
9303da084b3Smrg    else
93155acc8fcSmrg      echo "disable static libraries"
9323da084b3Smrg    fi
933d63fdb69Smrg
9343da084b3Smrg    exit $?
935d63fdb69Smrg}
936d63fdb69Smrg
937d63fdb69Smrg# func_enable_tag tagname
938d63fdb69Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or
939d63fdb69Smrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
940d63fdb69Smrg# variable here.
941d63fdb69Smrgfunc_enable_tag ()
942d63fdb69Smrg{
943d63fdb69Smrg  # Global variable:
944d63fdb69Smrg  tagname="$1"
9453da084b3Smrg
946d63fdb69Smrg  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
947d63fdb69Smrg  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
948d63fdb69Smrg  sed_extractcf="/$re_begincf/,/$re_endcf/p"
9493da084b3Smrg
950d63fdb69Smrg  # Validate tagname.
951d63fdb69Smrg  case $tagname in
952d63fdb69Smrg    *[!-_A-Za-z0-9,/]*)
953d63fdb69Smrg      func_fatal_error "invalid tag name: $tagname"
954d63fdb69Smrg      ;;
955d63fdb69Smrg  esac
9563da084b3Smrg
957d63fdb69Smrg  # Don't test for the "default" C tag, as we know it's
958d63fdb69Smrg  # there but not specially marked.
959d63fdb69Smrg  case $tagname in
960d63fdb69Smrg    CC) ;;
961d63fdb69Smrg    *)
962d63fdb69Smrg      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
963d63fdb69Smrg	taglist="$taglist $tagname"
964d63fdb69Smrg
965d63fdb69Smrg	# Evaluate the configuration.  Be careful to quote the path
966d63fdb69Smrg	# and the sed script, to avoid splitting on whitespace, but
967d63fdb69Smrg	# also don't use non-portable quotes within backquotes within
968d63fdb69Smrg	# quotes we have to do it in 2 steps:
969d63fdb69Smrg	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
970d63fdb69Smrg	eval "$extractedcf"
971d63fdb69Smrg      else
972d63fdb69Smrg	func_error "ignoring unknown tag $tagname"
973d63fdb69Smrg      fi
974d63fdb69Smrg      ;;
975d63fdb69Smrg  esac
976d63fdb69Smrg}
9773da084b3Smrg
97848c85eb7Smrg# func_check_version_match
97948c85eb7Smrg# Ensure that we are using m4 macros, and libtool script from the same
98048c85eb7Smrg# release of libtool.
98148c85eb7Smrgfunc_check_version_match ()
982d63fdb69Smrg{
98348c85eb7Smrg  if test "$package_revision" != "$macro_revision"; then
98448c85eb7Smrg    if test "$VERSION" != "$macro_version"; then
98548c85eb7Smrg      if test -z "$macro_version"; then
98648c85eb7Smrg        cat >&2 <<_LT_EOF
98748c85eb7Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
98848c85eb7Smrg$progname: definition of this LT_INIT comes from an older release.
98948c85eb7Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
99048c85eb7Smrg$progname: and run autoconf again.
99148c85eb7Smrg_LT_EOF
99248c85eb7Smrg      else
99348c85eb7Smrg        cat >&2 <<_LT_EOF
99448c85eb7Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
99548c85eb7Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
99648c85eb7Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
99748c85eb7Smrg$progname: and run autoconf again.
99848c85eb7Smrg_LT_EOF
99948c85eb7Smrg      fi
100048c85eb7Smrg    else
100148c85eb7Smrg      cat >&2 <<_LT_EOF
100248c85eb7Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
100348c85eb7Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
100448c85eb7Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
100548c85eb7Smrg$progname: of $PACKAGE $VERSION and run autoconf again.
100648c85eb7Smrg_LT_EOF
100748c85eb7Smrg    fi
100848c85eb7Smrg
100948c85eb7Smrg    exit $EXIT_MISMATCH
101048c85eb7Smrg  fi
101148c85eb7Smrg}
101248c85eb7Smrg
101348c85eb7Smrg
101448c85eb7Smrg# Shorthand for --mode=foo, only valid as the first argument
101548c85eb7Smrgcase $1 in
101648c85eb7Smrgclean|clea|cle|cl)
101748c85eb7Smrg  shift; set dummy --mode clean ${1+"$@"}; shift
101848c85eb7Smrg  ;;
101948c85eb7Smrgcompile|compil|compi|comp|com|co|c)
102048c85eb7Smrg  shift; set dummy --mode compile ${1+"$@"}; shift
102148c85eb7Smrg  ;;
102248c85eb7Smrgexecute|execut|execu|exec|exe|ex|e)
102348c85eb7Smrg  shift; set dummy --mode execute ${1+"$@"}; shift
102448c85eb7Smrg  ;;
102548c85eb7Smrgfinish|finis|fini|fin|fi|f)
102648c85eb7Smrg  shift; set dummy --mode finish ${1+"$@"}; shift
102748c85eb7Smrg  ;;
102848c85eb7Smrginstall|instal|insta|inst|ins|in|i)
102948c85eb7Smrg  shift; set dummy --mode install ${1+"$@"}; shift
103048c85eb7Smrg  ;;
103148c85eb7Smrglink|lin|li|l)
103248c85eb7Smrg  shift; set dummy --mode link ${1+"$@"}; shift
103348c85eb7Smrg  ;;
103448c85eb7Smrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
103548c85eb7Smrg  shift; set dummy --mode uninstall ${1+"$@"}; shift
103648c85eb7Smrg  ;;
103748c85eb7Smrgesac
103848c85eb7Smrg
103948c85eb7Smrg
104048c85eb7Smrg
104148c85eb7Smrg# Option defaults:
104248c85eb7Smrgopt_debug=:
104348c85eb7Smrgopt_dry_run=false
104448c85eb7Smrgopt_config=false
104548c85eb7Smrgopt_preserve_dup_deps=false
104648c85eb7Smrgopt_features=false
104748c85eb7Smrgopt_finish=false
104848c85eb7Smrgopt_help=false
104948c85eb7Smrgopt_help_all=false
105048c85eb7Smrgopt_silent=:
105148c85eb7Smrgopt_warning=:
105248c85eb7Smrgopt_verbose=:
105348c85eb7Smrgopt_silent=false
105448c85eb7Smrgopt_verbose=false
10553da084b3Smrg
10563da084b3Smrg
105748c85eb7Smrg# Parse options once, thoroughly.  This comes as soon as possible in the
105848c85eb7Smrg# script to make things like `--version' happen as quickly as we can.
105948c85eb7Smrg{
106048c85eb7Smrg  # this just eases exit handling
106148c85eb7Smrg  while test $# -gt 0; do
1062d63fdb69Smrg    opt="$1"
1063d63fdb69Smrg    shift
1064d63fdb69Smrg    case $opt in
106548c85eb7Smrg      --debug|-x)	opt_debug='set -x'
1066d63fdb69Smrg			func_echo "enabling shell trace mode"
1067d63fdb69Smrg			$opt_debug
1068d63fdb69Smrg			;;
106948c85eb7Smrg      --dry-run|--dryrun|-n)
107048c85eb7Smrg			opt_dry_run=:
1071d63fdb69Smrg			;;
107248c85eb7Smrg      --config)
107348c85eb7Smrg			opt_config=:
107448c85eb7Smrgfunc_config
107548c85eb7Smrg			;;
107648c85eb7Smrg      --dlopen|-dlopen)
107748c85eb7Smrg			optarg="$1"
107848c85eb7Smrg			opt_dlopen="${opt_dlopen+$opt_dlopen
107948c85eb7Smrg}$optarg"
1080d63fdb69Smrg			shift
1081d63fdb69Smrg			;;
1082d63fdb69Smrg      --preserve-dup-deps)
108348c85eb7Smrg			opt_preserve_dup_deps=:
108455acc8fcSmrg			;;
108548c85eb7Smrg      --features)
108648c85eb7Smrg			opt_features=:
108748c85eb7Smrgfunc_features
1088d63fdb69Smrg			;;
108948c85eb7Smrg      --finish)
109048c85eb7Smrg			opt_finish=:
109148c85eb7Smrgset dummy --mode finish ${1+"$@"}; shift
109248c85eb7Smrg			;;
109348c85eb7Smrg      --help)
109448c85eb7Smrg			opt_help=:
109548c85eb7Smrg			;;
109648c85eb7Smrg      --help-all)
109748c85eb7Smrg			opt_help_all=:
109848c85eb7Smrgopt_help=': help-all'
109948c85eb7Smrg			;;
110048c85eb7Smrg      --mode)
110148c85eb7Smrg			test $# = 0 && func_missing_arg $opt && break
110248c85eb7Smrg			optarg="$1"
110348c85eb7Smrg			opt_mode="$optarg"
110448c85eb7Smrgcase $optarg in
110548c85eb7Smrg  # Valid mode arguments:
110648c85eb7Smrg  clean|compile|execute|finish|install|link|relink|uninstall) ;;
110748c85eb7Smrg
110848c85eb7Smrg  # Catch anything else as an error
110948c85eb7Smrg  *) func_error "invalid argument for $opt"
111048c85eb7Smrg     exit_cmd=exit
111148c85eb7Smrg     break
111248c85eb7Smrg     ;;
111348c85eb7Smrgesac
111448c85eb7Smrg			shift
111548c85eb7Smrg			;;
111648c85eb7Smrg      --no-silent|--no-quiet)
1117d63fdb69Smrg			opt_silent=false
111848c85eb7Smrgfunc_append preserve_args " $opt"
111955acc8fcSmrg			;;
112048c85eb7Smrg      --no-warning|--no-warn)
112148c85eb7Smrg			opt_warning=false
112248c85eb7Smrgfunc_append preserve_args " $opt"
112348c85eb7Smrg			;;
112448c85eb7Smrg      --no-verbose)
112555acc8fcSmrg			opt_verbose=false
112648c85eb7Smrgfunc_append preserve_args " $opt"
1127d63fdb69Smrg			;;
112848c85eb7Smrg      --silent|--quiet)
112948c85eb7Smrg			opt_silent=:
113048c85eb7Smrgfunc_append preserve_args " $opt"
113148c85eb7Smrg        opt_verbose=false
113248c85eb7Smrg			;;
113348c85eb7Smrg      --verbose|-v)
113448c85eb7Smrg			opt_verbose=:
113548c85eb7Smrgfunc_append preserve_args " $opt"
113648c85eb7Smrgopt_silent=false
113748c85eb7Smrg			;;
113848c85eb7Smrg      --tag)
113948c85eb7Smrg			test $# = 0 && func_missing_arg $opt && break
114048c85eb7Smrg			optarg="$1"
114148c85eb7Smrg			opt_tag="$optarg"
114248c85eb7Smrgfunc_append preserve_args " $opt $optarg"
114348c85eb7Smrgfunc_enable_tag "$optarg"
1144d63fdb69Smrg			shift
1145d63fdb69Smrg			;;
1146d63fdb69Smrg
114748c85eb7Smrg      -\?|-h)		func_usage				;;
114848c85eb7Smrg      --help)		func_help				;;
114948c85eb7Smrg      --version)	func_version				;;
115048c85eb7Smrg
1151d63fdb69Smrg      # Separate optargs to long options:
115248c85eb7Smrg      --*=*)
115348c85eb7Smrg			func_split_long_opt "$opt"
115448c85eb7Smrg			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
1155d63fdb69Smrg			shift
1156d63fdb69Smrg			;;
1157d63fdb69Smrg
115848c85eb7Smrg      # Separate non-argument short options:
115948c85eb7Smrg      -\?*|-h*|-n*|-v*)
116048c85eb7Smrg			func_split_short_opt "$opt"
116148c85eb7Smrg			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
116248c85eb7Smrg			shift
1163d63fdb69Smrg			;;
116448c85eb7Smrg
116548c85eb7Smrg      --)		break					;;
116648c85eb7Smrg      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
116748c85eb7Smrg      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
1168d63fdb69Smrg    esac
1169d63fdb69Smrg  done
1170d63fdb69Smrg
117148c85eb7Smrg  # Validate options:
117248c85eb7Smrg
117348c85eb7Smrg  # save first non-option argument
117448c85eb7Smrg  if test "$#" -gt 0; then
117548c85eb7Smrg    nonopt="$opt"
117648c85eb7Smrg    shift
117748c85eb7Smrg  fi
117848c85eb7Smrg
117948c85eb7Smrg  # preserve --debug
118048c85eb7Smrg  test "$opt_debug" = : || func_append preserve_args " --debug"
1181d63fdb69Smrg
1182d63fdb69Smrg  case $host in
1183d63fdb69Smrg    *cygwin* | *mingw* | *pw32* | *cegcc*)
1184d63fdb69Smrg      # don't eliminate duplications in $postdeps and $predeps
1185d63fdb69Smrg      opt_duplicate_compiler_generated_deps=:
11863da084b3Smrg      ;;
11873da084b3Smrg    *)
118848c85eb7Smrg      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
1189d63fdb69Smrg      ;;
1190d63fdb69Smrg  esac
11913da084b3Smrg
119248c85eb7Smrg  $opt_help || {
119348c85eb7Smrg    # Sanity checks first:
119448c85eb7Smrg    func_check_version_match
1195d63fdb69Smrg
119648c85eb7Smrg    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
119748c85eb7Smrg      func_fatal_configuration "not configured to build any kind of library"
1198d63fdb69Smrg    fi
1199d63fdb69Smrg
120048c85eb7Smrg    # Darwin sucks
120148c85eb7Smrg    eval std_shrext=\"$shrext_cmds\"
1202d63fdb69Smrg
120348c85eb7Smrg    # Only execute mode is allowed to have -dlopen flags.
120448c85eb7Smrg    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
120548c85eb7Smrg      func_error "unrecognized option \`-dlopen'"
120648c85eb7Smrg      $ECHO "$help" 1>&2
120748c85eb7Smrg      exit $EXIT_FAILURE
120848c85eb7Smrg    fi
1209d63fdb69Smrg
121048c85eb7Smrg    # Change the help message to a mode-specific one.
121148c85eb7Smrg    generic_help="$help"
121248c85eb7Smrg    help="Try \`$progname --help --mode=$opt_mode' for more information."
121348c85eb7Smrg  }
1214d63fdb69Smrg
1215d63fdb69Smrg
121648c85eb7Smrg  # Bail if the options were screwed
121748c85eb7Smrg  $exit_cmd $EXIT_FAILURE
121848c85eb7Smrg}
1219d63fdb69Smrg
1220d63fdb69Smrg
12213da084b3Smrg
12223da084b3Smrg
122348c85eb7Smrg## ----------- ##
122448c85eb7Smrg##    Main.    ##
122548c85eb7Smrg## ----------- ##
12263da084b3Smrg
1227d63fdb69Smrg# func_lalib_p file
1228d63fdb69Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
1229d63fdb69Smrg# This function is only a basic sanity check; it will hardly flush out
1230d63fdb69Smrg# determined imposters.
1231d63fdb69Smrgfunc_lalib_p ()
1232d63fdb69Smrg{
1233d63fdb69Smrg    test -f "$1" &&
1234d63fdb69Smrg      $SED -e 4q "$1" 2>/dev/null \
1235d63fdb69Smrg        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
1236d63fdb69Smrg}
12373da084b3Smrg
1238d63fdb69Smrg# func_lalib_unsafe_p file
1239d63fdb69Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
1240d63fdb69Smrg# This function implements the same check as func_lalib_p without
1241d63fdb69Smrg# resorting to external programs.  To this end, it redirects stdin and
1242d63fdb69Smrg# closes it afterwards, without saving the original file descriptor.
1243d63fdb69Smrg# As a safety measure, use it only where a negative result would be
1244d63fdb69Smrg# fatal anyway.  Works if `file' does not exist.
1245d63fdb69Smrgfunc_lalib_unsafe_p ()
1246d63fdb69Smrg{
1247d63fdb69Smrg    lalib_p=no
1248d63fdb69Smrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
1249d63fdb69Smrg	for lalib_p_l in 1 2 3 4
1250d63fdb69Smrg	do
1251d63fdb69Smrg	    read lalib_p_line
1252d63fdb69Smrg	    case "$lalib_p_line" in
1253d63fdb69Smrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
1254d63fdb69Smrg	    esac
1255d63fdb69Smrg	done
1256d63fdb69Smrg	exec 0<&5 5<&-
1257d63fdb69Smrg    fi
1258d63fdb69Smrg    test "$lalib_p" = yes
1259d63fdb69Smrg}
12603da084b3Smrg
1261d63fdb69Smrg# func_ltwrapper_script_p file
1262d63fdb69Smrg# True iff FILE is a libtool wrapper script
1263d63fdb69Smrg# This function is only a basic sanity check; it will hardly flush out
1264d63fdb69Smrg# determined imposters.
1265d63fdb69Smrgfunc_ltwrapper_script_p ()
1266d63fdb69Smrg{
1267d63fdb69Smrg    func_lalib_p "$1"
1268d63fdb69Smrg}
12693da084b3Smrg
1270d63fdb69Smrg# func_ltwrapper_executable_p file
1271d63fdb69Smrg# True iff FILE is a libtool wrapper executable
1272d63fdb69Smrg# This function is only a basic sanity check; it will hardly flush out
1273d63fdb69Smrg# determined imposters.
1274d63fdb69Smrgfunc_ltwrapper_executable_p ()
1275d63fdb69Smrg{
1276d63fdb69Smrg    func_ltwrapper_exec_suffix=
1277d63fdb69Smrg    case $1 in
1278d63fdb69Smrg    *.exe) ;;
1279d63fdb69Smrg    *) func_ltwrapper_exec_suffix=.exe ;;
1280d63fdb69Smrg    esac
1281d63fdb69Smrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
1282d63fdb69Smrg}
12833da084b3Smrg
1284d63fdb69Smrg# func_ltwrapper_scriptname file
1285d63fdb69Smrg# Assumes file is an ltwrapper_executable
1286d63fdb69Smrg# uses $file to determine the appropriate filename for a
1287d63fdb69Smrg# temporary ltwrapper_script.
1288d63fdb69Smrgfunc_ltwrapper_scriptname ()
1289d63fdb69Smrg{
129048c85eb7Smrg    func_dirname_and_basename "$1" "" "."
129148c85eb7Smrg    func_stripname '' '.exe' "$func_basename_result"
129248c85eb7Smrg    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
1293d63fdb69Smrg}
12943da084b3Smrg
1295d63fdb69Smrg# func_ltwrapper_p file
1296d63fdb69Smrg# True iff FILE is a libtool wrapper script or wrapper executable
1297d63fdb69Smrg# This function is only a basic sanity check; it will hardly flush out
1298d63fdb69Smrg# determined imposters.
1299d63fdb69Smrgfunc_ltwrapper_p ()
1300d63fdb69Smrg{
1301d63fdb69Smrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
1302d63fdb69Smrg}
13033da084b3Smrg
13043da084b3Smrg
1305d63fdb69Smrg# func_execute_cmds commands fail_cmd
1306d63fdb69Smrg# Execute tilde-delimited COMMANDS.
1307d63fdb69Smrg# If FAIL_CMD is given, eval that upon failure.
1308d63fdb69Smrg# FAIL_CMD may read-access the current command in variable CMD!
1309d63fdb69Smrgfunc_execute_cmds ()
1310d63fdb69Smrg{
1311d63fdb69Smrg    $opt_debug
1312d63fdb69Smrg    save_ifs=$IFS; IFS='~'
1313d63fdb69Smrg    for cmd in $1; do
1314d63fdb69Smrg      IFS=$save_ifs
1315d63fdb69Smrg      eval cmd=\"$cmd\"
1316d63fdb69Smrg      func_show_eval "$cmd" "${2-:}"
1317d63fdb69Smrg    done
1318d63fdb69Smrg    IFS=$save_ifs
1319d63fdb69Smrg}
1320d63fdb69Smrg
1321d63fdb69Smrg
1322d63fdb69Smrg# func_source file
1323d63fdb69Smrg# Source FILE, adding directory component if necessary.
1324d63fdb69Smrg# Note that it is not necessary on cygwin/mingw to append a dot to
1325d63fdb69Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
1326d63fdb69Smrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
1327d63fdb69Smrg# `FILE.' does not work on cygwin managed mounts.
1328d63fdb69Smrgfunc_source ()
1329d63fdb69Smrg{
1330d63fdb69Smrg    $opt_debug
1331d63fdb69Smrg    case $1 in
1332d63fdb69Smrg    */* | *\\*)	. "$1" ;;
1333d63fdb69Smrg    *)		. "./$1" ;;
1334d63fdb69Smrg    esac
1335d63fdb69Smrg}
1336d63fdb69Smrg
1337d63fdb69Smrg
133848c85eb7Smrg# func_resolve_sysroot PATH
133948c85eb7Smrg# Replace a leading = in PATH with a sysroot.  Store the result into
134048c85eb7Smrg# func_resolve_sysroot_result
134148c85eb7Smrgfunc_resolve_sysroot ()
134248c85eb7Smrg{
134348c85eb7Smrg  func_resolve_sysroot_result=$1
134448c85eb7Smrg  case $func_resolve_sysroot_result in
134548c85eb7Smrg  =*)
134648c85eb7Smrg    func_stripname '=' '' "$func_resolve_sysroot_result"
134748c85eb7Smrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
134848c85eb7Smrg    ;;
134948c85eb7Smrg  esac
135048c85eb7Smrg}
135148c85eb7Smrg
135248c85eb7Smrg# func_replace_sysroot PATH
135348c85eb7Smrg# If PATH begins with the sysroot, replace it with = and
135448c85eb7Smrg# store the result into func_replace_sysroot_result.
135548c85eb7Smrgfunc_replace_sysroot ()
135648c85eb7Smrg{
135748c85eb7Smrg  case "$lt_sysroot:$1" in
135848c85eb7Smrg  ?*:"$lt_sysroot"*)
135948c85eb7Smrg    func_stripname "$lt_sysroot" '' "$1"
136048c85eb7Smrg    func_replace_sysroot_result="=$func_stripname_result"
136148c85eb7Smrg    ;;
136248c85eb7Smrg  *)
136348c85eb7Smrg    # Including no sysroot.
136448c85eb7Smrg    func_replace_sysroot_result=$1
136548c85eb7Smrg    ;;
136648c85eb7Smrg  esac
136748c85eb7Smrg}
136848c85eb7Smrg
1369d63fdb69Smrg# func_infer_tag arg
1370d63fdb69Smrg# Infer tagged configuration to use if any are available and
1371d63fdb69Smrg# if one wasn't chosen via the "--tag" command line option.
1372d63fdb69Smrg# Only attempt this if the compiler in the base compile
1373d63fdb69Smrg# command doesn't match the default compiler.
1374d63fdb69Smrg# arg is usually of the form 'gcc ...'
1375d63fdb69Smrgfunc_infer_tag ()
1376d63fdb69Smrg{
1377d63fdb69Smrg    $opt_debug
1378d63fdb69Smrg    if test -n "$available_tags" && test -z "$tagname"; then
1379d63fdb69Smrg      CC_quoted=
1380d63fdb69Smrg      for arg in $CC; do
138148c85eb7Smrg	func_append_quoted CC_quoted "$arg"
1382d63fdb69Smrg      done
138355acc8fcSmrg      CC_expanded=`func_echo_all $CC`
138455acc8fcSmrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
1385d63fdb69Smrg      case $@ in
1386d63fdb69Smrg      # Blanks in the command may have been stripped by the calling shell,
1387d63fdb69Smrg      # but not from the CC environment variable when configure was run.
138855acc8fcSmrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
138955acc8fcSmrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
1390d63fdb69Smrg      # Blanks at the start of $base_compile will cause this to fail
1391d63fdb69Smrg      # if we don't check for them as well.
1392d63fdb69Smrg      *)
1393d63fdb69Smrg	for z in $available_tags; do
1394d63fdb69Smrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1395d63fdb69Smrg	    # Evaluate the configuration.
1396d63fdb69Smrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1397d63fdb69Smrg	    CC_quoted=
1398d63fdb69Smrg	    for arg in $CC; do
1399d63fdb69Smrg	      # Double-quote args containing other shell metacharacters.
140048c85eb7Smrg	      func_append_quoted CC_quoted "$arg"
1401d63fdb69Smrg	    done
140255acc8fcSmrg	    CC_expanded=`func_echo_all $CC`
140355acc8fcSmrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
1404d63fdb69Smrg	    case "$@ " in
140555acc8fcSmrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
140655acc8fcSmrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
1407d63fdb69Smrg	      # The compiler in the base compile command matches
1408d63fdb69Smrg	      # the one in the tagged configuration.
1409d63fdb69Smrg	      # Assume this is the tagged configuration we want.
1410d63fdb69Smrg	      tagname=$z
1411d63fdb69Smrg	      break
1412d63fdb69Smrg	      ;;
14133da084b3Smrg	    esac
1414d63fdb69Smrg	  fi
1415d63fdb69Smrg	done
1416d63fdb69Smrg	# If $tagname still isn't set, then no tagged configuration
1417d63fdb69Smrg	# was found and let the user know that the "--tag" command
1418d63fdb69Smrg	# line option must be used.
1419d63fdb69Smrg	if test -z "$tagname"; then
1420d63fdb69Smrg	  func_echo "unable to infer tagged configuration"
1421d63fdb69Smrg	  func_fatal_error "specify a tag with \`--tag'"
1422d63fdb69Smrg#	else
1423d63fdb69Smrg#	  func_verbose "using $tagname tagged configuration"
1424d63fdb69Smrg	fi
1425d63fdb69Smrg	;;
1426d63fdb69Smrg      esac
1427d63fdb69Smrg    fi
1428d63fdb69Smrg}
1429d63fdb69Smrg
1430d63fdb69Smrg
143148c85eb7Smrg
143248c85eb7Smrg# func_write_libtool_object output_name pic_name nonpic_name
143348c85eb7Smrg# Create a libtool object file (analogous to a ".la" file),
143448c85eb7Smrg# but don't create it if we're doing a dry run.
143548c85eb7Smrgfunc_write_libtool_object ()
143648c85eb7Smrg{
143748c85eb7Smrg    write_libobj=${1}
143848c85eb7Smrg    if test "$build_libtool_libs" = yes; then
143948c85eb7Smrg      write_lobj=\'${2}\'
144048c85eb7Smrg    else
144148c85eb7Smrg      write_lobj=none
144248c85eb7Smrg    fi
144348c85eb7Smrg
144448c85eb7Smrg    if test "$build_old_libs" = yes; then
144548c85eb7Smrg      write_oldobj=\'${3}\'
144648c85eb7Smrg    else
144748c85eb7Smrg      write_oldobj=none
144848c85eb7Smrg    fi
144948c85eb7Smrg
145048c85eb7Smrg    $opt_dry_run || {
145148c85eb7Smrg      cat >${write_libobj}T <<EOF
145248c85eb7Smrg# $write_libobj - a libtool object file
145348c85eb7Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
145448c85eb7Smrg#
145548c85eb7Smrg# Please DO NOT delete this file!
145648c85eb7Smrg# It is necessary for linking the library.
145748c85eb7Smrg
145848c85eb7Smrg# Name of the PIC object.
145948c85eb7Smrgpic_object=$write_lobj
146048c85eb7Smrg
146148c85eb7Smrg# Name of the non-PIC object
146248c85eb7Smrgnon_pic_object=$write_oldobj
146348c85eb7Smrg
146448c85eb7SmrgEOF
146548c85eb7Smrg      $MV "${write_libobj}T" "${write_libobj}"
146648c85eb7Smrg    }
146748c85eb7Smrg}
146848c85eb7Smrg
146948c85eb7Smrg
147048c85eb7Smrg##################################################
147148c85eb7Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
147248c85eb7Smrg##################################################
147348c85eb7Smrg
147448c85eb7Smrg# func_convert_core_file_wine_to_w32 ARG
147548c85eb7Smrg# Helper function used by file name conversion functions when $build is *nix,
147648c85eb7Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
147748c85eb7Smrg# correctly configured wine environment available, with the winepath program
147848c85eb7Smrg# in $build's $PATH.
147948c85eb7Smrg#
148048c85eb7Smrg# ARG is the $build file name to be converted to w32 format.
148148c85eb7Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
148248c85eb7Smrg# be empty on error (or when ARG is empty)
148348c85eb7Smrgfunc_convert_core_file_wine_to_w32 ()
148448c85eb7Smrg{
148548c85eb7Smrg  $opt_debug
148648c85eb7Smrg  func_convert_core_file_wine_to_w32_result="$1"
148748c85eb7Smrg  if test -n "$1"; then
148848c85eb7Smrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
148948c85eb7Smrg    # are forced to check the contents of stdout. On the other hand, if the
149048c85eb7Smrg    # command is not found, the shell will set an exit code of 127 and print
149148c85eb7Smrg    # *an error message* to stdout. So we must check for both error code of
149248c85eb7Smrg    # zero AND non-empty stdout, which explains the odd construction:
149348c85eb7Smrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
149448c85eb7Smrg    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
149548c85eb7Smrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
149648c85eb7Smrg        $SED -e "$lt_sed_naive_backslashify"`
149748c85eb7Smrg    else
149848c85eb7Smrg      func_convert_core_file_wine_to_w32_result=
149948c85eb7Smrg    fi
150048c85eb7Smrg  fi
150148c85eb7Smrg}
150248c85eb7Smrg# end: func_convert_core_file_wine_to_w32
150348c85eb7Smrg
150448c85eb7Smrg
150548c85eb7Smrg# func_convert_core_path_wine_to_w32 ARG
150648c85eb7Smrg# Helper function used by path conversion functions when $build is *nix, and
150748c85eb7Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
150848c85eb7Smrg# configured wine environment available, with the winepath program in $build's
150948c85eb7Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
151048c85eb7Smrg#
151148c85eb7Smrg# ARG is path to be converted from $build format to win32.
151248c85eb7Smrg# Result is available in $func_convert_core_path_wine_to_w32_result.
151348c85eb7Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
151448c85eb7Smrg# are convertible, then the result may be empty.
151548c85eb7Smrgfunc_convert_core_path_wine_to_w32 ()
151648c85eb7Smrg{
151748c85eb7Smrg  $opt_debug
151848c85eb7Smrg  # unfortunately, winepath doesn't convert paths, only file names
151948c85eb7Smrg  func_convert_core_path_wine_to_w32_result=""
152048c85eb7Smrg  if test -n "$1"; then
152148c85eb7Smrg    oldIFS=$IFS
152248c85eb7Smrg    IFS=:
152348c85eb7Smrg    for func_convert_core_path_wine_to_w32_f in $1; do
152448c85eb7Smrg      IFS=$oldIFS
152548c85eb7Smrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
152648c85eb7Smrg      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
152748c85eb7Smrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
152848c85eb7Smrg          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
152948c85eb7Smrg        else
153048c85eb7Smrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
153148c85eb7Smrg        fi
153248c85eb7Smrg      fi
153348c85eb7Smrg    done
153448c85eb7Smrg    IFS=$oldIFS
153548c85eb7Smrg  fi
153648c85eb7Smrg}
153748c85eb7Smrg# end: func_convert_core_path_wine_to_w32
153848c85eb7Smrg
153948c85eb7Smrg
154048c85eb7Smrg# func_cygpath ARGS...
154148c85eb7Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
154248c85eb7Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
154348c85eb7Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
154448c85eb7Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
154548c85eb7Smrg# file name or path is assumed to be in w32 format, as previously converted
154648c85eb7Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
154748c85eb7Smrg# or path in func_cygpath_result (input file name or path is assumed to be in
154848c85eb7Smrg# Cygwin format). Returns an empty string on error.
154948c85eb7Smrg#
155048c85eb7Smrg# ARGS are passed to cygpath, with the last one being the file name or path to
155148c85eb7Smrg# be converted.
155248c85eb7Smrg#
155348c85eb7Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
155448c85eb7Smrg# environment variable; do not put it in $PATH.
155548c85eb7Smrgfunc_cygpath ()
155648c85eb7Smrg{
155748c85eb7Smrg  $opt_debug
155848c85eb7Smrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
155948c85eb7Smrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
156048c85eb7Smrg    if test "$?" -ne 0; then
156148c85eb7Smrg      # on failure, ensure result is empty
156248c85eb7Smrg      func_cygpath_result=
156348c85eb7Smrg    fi
156448c85eb7Smrg  else
156548c85eb7Smrg    func_cygpath_result=
156648c85eb7Smrg    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
156748c85eb7Smrg  fi
156848c85eb7Smrg}
156948c85eb7Smrg#end: func_cygpath
157048c85eb7Smrg
157148c85eb7Smrg
157248c85eb7Smrg# func_convert_core_msys_to_w32 ARG
157348c85eb7Smrg# Convert file name or path ARG from MSYS format to w32 format.  Return
157448c85eb7Smrg# result in func_convert_core_msys_to_w32_result.
157548c85eb7Smrgfunc_convert_core_msys_to_w32 ()
157648c85eb7Smrg{
157748c85eb7Smrg  $opt_debug
157848c85eb7Smrg  # awkward: cmd appends spaces to result
157948c85eb7Smrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
158048c85eb7Smrg    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
158148c85eb7Smrg}
158248c85eb7Smrg#end: func_convert_core_msys_to_w32
158348c85eb7Smrg
158448c85eb7Smrg
158548c85eb7Smrg# func_convert_file_check ARG1 ARG2
158648c85eb7Smrg# Verify that ARG1 (a file name in $build format) was converted to $host
158748c85eb7Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
158848c85eb7Smrg# func_to_host_file_result to ARG1).
158948c85eb7Smrgfunc_convert_file_check ()
159048c85eb7Smrg{
159148c85eb7Smrg  $opt_debug
159248c85eb7Smrg  if test -z "$2" && test -n "$1" ; then
159348c85eb7Smrg    func_error "Could not determine host file name corresponding to"
159448c85eb7Smrg    func_error "  \`$1'"
159548c85eb7Smrg    func_error "Continuing, but uninstalled executables may not work."
159648c85eb7Smrg    # Fallback:
159748c85eb7Smrg    func_to_host_file_result="$1"
159848c85eb7Smrg  fi
159948c85eb7Smrg}
160048c85eb7Smrg# end func_convert_file_check
160148c85eb7Smrg
160248c85eb7Smrg
160348c85eb7Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
160448c85eb7Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host
160548c85eb7Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
160648c85eb7Smrg# func_to_host_file_result to a simplistic fallback value (see below).
160748c85eb7Smrgfunc_convert_path_check ()
160848c85eb7Smrg{
160948c85eb7Smrg  $opt_debug
161048c85eb7Smrg  if test -z "$4" && test -n "$3"; then
161148c85eb7Smrg    func_error "Could not determine the host path corresponding to"
161248c85eb7Smrg    func_error "  \`$3'"
161348c85eb7Smrg    func_error "Continuing, but uninstalled executables may not work."
161448c85eb7Smrg    # Fallback.  This is a deliberately simplistic "conversion" and
161548c85eb7Smrg    # should not be "improved".  See libtool.info.
161648c85eb7Smrg    if test "x$1" != "x$2"; then
161748c85eb7Smrg      lt_replace_pathsep_chars="s|$1|$2|g"
161848c85eb7Smrg      func_to_host_path_result=`echo "$3" |
161948c85eb7Smrg        $SED -e "$lt_replace_pathsep_chars"`
162048c85eb7Smrg    else
162148c85eb7Smrg      func_to_host_path_result="$3"
162248c85eb7Smrg    fi
162348c85eb7Smrg  fi
162448c85eb7Smrg}
162548c85eb7Smrg# end func_convert_path_check
162648c85eb7Smrg
162748c85eb7Smrg
162848c85eb7Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
162948c85eb7Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
163048c85eb7Smrg# and appending REPL if ORIG matches BACKPAT.
163148c85eb7Smrgfunc_convert_path_front_back_pathsep ()
163248c85eb7Smrg{
163348c85eb7Smrg  $opt_debug
163448c85eb7Smrg  case $4 in
163548c85eb7Smrg  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
163648c85eb7Smrg    ;;
163748c85eb7Smrg  esac
163848c85eb7Smrg  case $4 in
163948c85eb7Smrg  $2 ) func_append func_to_host_path_result "$3"
164048c85eb7Smrg    ;;
164148c85eb7Smrg  esac
164248c85eb7Smrg}
164348c85eb7Smrg# end func_convert_path_front_back_pathsep
164448c85eb7Smrg
164548c85eb7Smrg
164648c85eb7Smrg##################################################
164748c85eb7Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
164848c85eb7Smrg##################################################
164948c85eb7Smrg# invoked via `$to_host_file_cmd ARG'
165048c85eb7Smrg#
165148c85eb7Smrg# In each case, ARG is the path to be converted from $build to $host format.
165248c85eb7Smrg# Result will be available in $func_to_host_file_result.
165348c85eb7Smrg
165448c85eb7Smrg
165548c85eb7Smrg# func_to_host_file ARG
165648c85eb7Smrg# Converts the file name ARG from $build format to $host format. Return result
165748c85eb7Smrg# in func_to_host_file_result.
165848c85eb7Smrgfunc_to_host_file ()
165948c85eb7Smrg{
166048c85eb7Smrg  $opt_debug
166148c85eb7Smrg  $to_host_file_cmd "$1"
166248c85eb7Smrg}
166348c85eb7Smrg# end func_to_host_file
166448c85eb7Smrg
166548c85eb7Smrg
166648c85eb7Smrg# func_to_tool_file ARG LAZY
166748c85eb7Smrg# converts the file name ARG from $build format to toolchain format. Return
166848c85eb7Smrg# result in func_to_tool_file_result.  If the conversion in use is listed
166948c85eb7Smrg# in (the comma separated) LAZY, no conversion takes place.
167048c85eb7Smrgfunc_to_tool_file ()
167148c85eb7Smrg{
167248c85eb7Smrg  $opt_debug
167348c85eb7Smrg  case ,$2, in
167448c85eb7Smrg    *,"$to_tool_file_cmd",*)
167548c85eb7Smrg      func_to_tool_file_result=$1
167648c85eb7Smrg      ;;
167748c85eb7Smrg    *)
167848c85eb7Smrg      $to_tool_file_cmd "$1"
167948c85eb7Smrg      func_to_tool_file_result=$func_to_host_file_result
168048c85eb7Smrg      ;;
168148c85eb7Smrg  esac
168248c85eb7Smrg}
168348c85eb7Smrg# end func_to_tool_file
168448c85eb7Smrg
168548c85eb7Smrg
168648c85eb7Smrg# func_convert_file_noop ARG
168748c85eb7Smrg# Copy ARG to func_to_host_file_result.
168848c85eb7Smrgfunc_convert_file_noop ()
168948c85eb7Smrg{
169048c85eb7Smrg  func_to_host_file_result="$1"
169148c85eb7Smrg}
169248c85eb7Smrg# end func_convert_file_noop
169348c85eb7Smrg
169448c85eb7Smrg
169548c85eb7Smrg# func_convert_file_msys_to_w32 ARG
169648c85eb7Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
169748c85eb7Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
169848c85eb7Smrg# func_to_host_file_result.
169948c85eb7Smrgfunc_convert_file_msys_to_w32 ()
170048c85eb7Smrg{
170148c85eb7Smrg  $opt_debug
170248c85eb7Smrg  func_to_host_file_result="$1"
170348c85eb7Smrg  if test -n "$1"; then
170448c85eb7Smrg    func_convert_core_msys_to_w32 "$1"
170548c85eb7Smrg    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
170648c85eb7Smrg  fi
170748c85eb7Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
170848c85eb7Smrg}
170948c85eb7Smrg# end func_convert_file_msys_to_w32
171048c85eb7Smrg
171148c85eb7Smrg
171248c85eb7Smrg# func_convert_file_cygwin_to_w32 ARG
171348c85eb7Smrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
171448c85eb7Smrg# func_to_host_file_result.
171548c85eb7Smrgfunc_convert_file_cygwin_to_w32 ()
171648c85eb7Smrg{
171748c85eb7Smrg  $opt_debug
171848c85eb7Smrg  func_to_host_file_result="$1"
171948c85eb7Smrg  if test -n "$1"; then
172048c85eb7Smrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
172148c85eb7Smrg    # LT_CYGPATH in this case.
172248c85eb7Smrg    func_to_host_file_result=`cygpath -m "$1"`
172348c85eb7Smrg  fi
172448c85eb7Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
172548c85eb7Smrg}
172648c85eb7Smrg# end func_convert_file_cygwin_to_w32
172748c85eb7Smrg
172848c85eb7Smrg
172948c85eb7Smrg# func_convert_file_nix_to_w32 ARG
173048c85eb7Smrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
173148c85eb7Smrg# and a working winepath. Returns result in func_to_host_file_result.
173248c85eb7Smrgfunc_convert_file_nix_to_w32 ()
173348c85eb7Smrg{
173448c85eb7Smrg  $opt_debug
173548c85eb7Smrg  func_to_host_file_result="$1"
173648c85eb7Smrg  if test -n "$1"; then
173748c85eb7Smrg    func_convert_core_file_wine_to_w32 "$1"
173848c85eb7Smrg    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
173948c85eb7Smrg  fi
174048c85eb7Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
174148c85eb7Smrg}
174248c85eb7Smrg# end func_convert_file_nix_to_w32
174348c85eb7Smrg
174448c85eb7Smrg
174548c85eb7Smrg# func_convert_file_msys_to_cygwin ARG
174648c85eb7Smrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
174748c85eb7Smrg# Returns result in func_to_host_file_result.
174848c85eb7Smrgfunc_convert_file_msys_to_cygwin ()
174948c85eb7Smrg{
175048c85eb7Smrg  $opt_debug
175148c85eb7Smrg  func_to_host_file_result="$1"
175248c85eb7Smrg  if test -n "$1"; then
175348c85eb7Smrg    func_convert_core_msys_to_w32 "$1"
175448c85eb7Smrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
175548c85eb7Smrg    func_to_host_file_result="$func_cygpath_result"
175648c85eb7Smrg  fi
175748c85eb7Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
175848c85eb7Smrg}
175948c85eb7Smrg# end func_convert_file_msys_to_cygwin
176048c85eb7Smrg
176148c85eb7Smrg
176248c85eb7Smrg# func_convert_file_nix_to_cygwin ARG
176348c85eb7Smrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
176448c85eb7Smrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
176548c85eb7Smrg# in func_to_host_file_result.
176648c85eb7Smrgfunc_convert_file_nix_to_cygwin ()
176748c85eb7Smrg{
176848c85eb7Smrg  $opt_debug
176948c85eb7Smrg  func_to_host_file_result="$1"
177048c85eb7Smrg  if test -n "$1"; then
177148c85eb7Smrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
177248c85eb7Smrg    func_convert_core_file_wine_to_w32 "$1"
177348c85eb7Smrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
177448c85eb7Smrg    func_to_host_file_result="$func_cygpath_result"
177548c85eb7Smrg  fi
177648c85eb7Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
177748c85eb7Smrg}
177848c85eb7Smrg# end func_convert_file_nix_to_cygwin
177948c85eb7Smrg
178048c85eb7Smrg
178148c85eb7Smrg#############################################
178248c85eb7Smrg# $build to $host PATH CONVERSION FUNCTIONS #
178348c85eb7Smrg#############################################
178448c85eb7Smrg# invoked via `$to_host_path_cmd ARG'
178548c85eb7Smrg#
178648c85eb7Smrg# In each case, ARG is the path to be converted from $build to $host format.
178748c85eb7Smrg# The result will be available in $func_to_host_path_result.
178848c85eb7Smrg#
178948c85eb7Smrg# Path separators are also converted from $build format to $host format.  If
179048c85eb7Smrg# ARG begins or ends with a path separator character, it is preserved (but
179148c85eb7Smrg# converted to $host format) on output.
179248c85eb7Smrg#
179348c85eb7Smrg# All path conversion functions are named using the following convention:
179448c85eb7Smrg#   file name conversion function    : func_convert_file_X_to_Y ()
179548c85eb7Smrg#   path conversion function         : func_convert_path_X_to_Y ()
179648c85eb7Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the
179748c85eb7Smrg# same.  If conversion functions are added for new $build/$host combinations,
179848c85eb7Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
179948c85eb7Smrg# will break.
180048c85eb7Smrg
180148c85eb7Smrg
180248c85eb7Smrg# func_init_to_host_path_cmd
180348c85eb7Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
180448c85eb7Smrg# appropriate value, based on the value of $to_host_file_cmd.
180548c85eb7Smrgto_host_path_cmd=
180648c85eb7Smrgfunc_init_to_host_path_cmd ()
180748c85eb7Smrg{
180848c85eb7Smrg  $opt_debug
180948c85eb7Smrg  if test -z "$to_host_path_cmd"; then
181048c85eb7Smrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
181148c85eb7Smrg    to_host_path_cmd="func_convert_path_${func_stripname_result}"
181248c85eb7Smrg  fi
181348c85eb7Smrg}
181448c85eb7Smrg
181548c85eb7Smrg
181648c85eb7Smrg# func_to_host_path ARG
181748c85eb7Smrg# Converts the path ARG from $build format to $host format. Return result
181848c85eb7Smrg# in func_to_host_path_result.
181948c85eb7Smrgfunc_to_host_path ()
182048c85eb7Smrg{
182148c85eb7Smrg  $opt_debug
182248c85eb7Smrg  func_init_to_host_path_cmd
182348c85eb7Smrg  $to_host_path_cmd "$1"
182448c85eb7Smrg}
182548c85eb7Smrg# end func_to_host_path
182648c85eb7Smrg
182748c85eb7Smrg
182848c85eb7Smrg# func_convert_path_noop ARG
182948c85eb7Smrg# Copy ARG to func_to_host_path_result.
183048c85eb7Smrgfunc_convert_path_noop ()
183148c85eb7Smrg{
183248c85eb7Smrg  func_to_host_path_result="$1"
183348c85eb7Smrg}
183448c85eb7Smrg# end func_convert_path_noop
183548c85eb7Smrg
183648c85eb7Smrg
183748c85eb7Smrg# func_convert_path_msys_to_w32 ARG
183848c85eb7Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
183948c85eb7Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
184048c85eb7Smrg# func_to_host_path_result.
184148c85eb7Smrgfunc_convert_path_msys_to_w32 ()
184248c85eb7Smrg{
184348c85eb7Smrg  $opt_debug
184448c85eb7Smrg  func_to_host_path_result="$1"
184548c85eb7Smrg  if test -n "$1"; then
184648c85eb7Smrg    # Remove leading and trailing path separator characters from ARG.  MSYS
184748c85eb7Smrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
184848c85eb7Smrg    # and winepath ignores them completely.
184948c85eb7Smrg    func_stripname : : "$1"
185048c85eb7Smrg    func_to_host_path_tmp1=$func_stripname_result
185148c85eb7Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
185248c85eb7Smrg    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
185348c85eb7Smrg    func_convert_path_check : ";" \
185448c85eb7Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
185548c85eb7Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
185648c85eb7Smrg  fi
185748c85eb7Smrg}
185848c85eb7Smrg# end func_convert_path_msys_to_w32
185948c85eb7Smrg
186048c85eb7Smrg
186148c85eb7Smrg# func_convert_path_cygwin_to_w32 ARG
186248c85eb7Smrg# Convert path ARG from Cygwin to w32 format.  Returns result in
186348c85eb7Smrg# func_to_host_file_result.
186448c85eb7Smrgfunc_convert_path_cygwin_to_w32 ()
186548c85eb7Smrg{
186648c85eb7Smrg  $opt_debug
186748c85eb7Smrg  func_to_host_path_result="$1"
186848c85eb7Smrg  if test -n "$1"; then
186948c85eb7Smrg    # See func_convert_path_msys_to_w32:
187048c85eb7Smrg    func_stripname : : "$1"
187148c85eb7Smrg    func_to_host_path_tmp1=$func_stripname_result
187248c85eb7Smrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
187348c85eb7Smrg    func_convert_path_check : ";" \
187448c85eb7Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
187548c85eb7Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
187648c85eb7Smrg  fi
187748c85eb7Smrg}
187848c85eb7Smrg# end func_convert_path_cygwin_to_w32
187948c85eb7Smrg
188048c85eb7Smrg
188148c85eb7Smrg# func_convert_path_nix_to_w32 ARG
188248c85eb7Smrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
188348c85eb7Smrg# a working winepath.  Returns result in func_to_host_file_result.
188448c85eb7Smrgfunc_convert_path_nix_to_w32 ()
1885d63fdb69Smrg{
188648c85eb7Smrg  $opt_debug
188748c85eb7Smrg  func_to_host_path_result="$1"
188848c85eb7Smrg  if test -n "$1"; then
188948c85eb7Smrg    # See func_convert_path_msys_to_w32:
189048c85eb7Smrg    func_stripname : : "$1"
189148c85eb7Smrg    func_to_host_path_tmp1=$func_stripname_result
189248c85eb7Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
189348c85eb7Smrg    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
189448c85eb7Smrg    func_convert_path_check : ";" \
189548c85eb7Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
189648c85eb7Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
189748c85eb7Smrg  fi
189848c85eb7Smrg}
189948c85eb7Smrg# end func_convert_path_nix_to_w32
1900d63fdb69Smrg
1901d63fdb69Smrg
190248c85eb7Smrg# func_convert_path_msys_to_cygwin ARG
190348c85eb7Smrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
190448c85eb7Smrg# Returns result in func_to_host_file_result.
190548c85eb7Smrgfunc_convert_path_msys_to_cygwin ()
190648c85eb7Smrg{
190748c85eb7Smrg  $opt_debug
190848c85eb7Smrg  func_to_host_path_result="$1"
190948c85eb7Smrg  if test -n "$1"; then
191048c85eb7Smrg    # See func_convert_path_msys_to_w32:
191148c85eb7Smrg    func_stripname : : "$1"
191248c85eb7Smrg    func_to_host_path_tmp1=$func_stripname_result
191348c85eb7Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
191448c85eb7Smrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
191548c85eb7Smrg    func_to_host_path_result="$func_cygpath_result"
191648c85eb7Smrg    func_convert_path_check : : \
191748c85eb7Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
191848c85eb7Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
191948c85eb7Smrg  fi
192048c85eb7Smrg}
192148c85eb7Smrg# end func_convert_path_msys_to_cygwin
1922d63fdb69Smrg
1923d63fdb69Smrg
192448c85eb7Smrg# func_convert_path_nix_to_cygwin ARG
192548c85eb7Smrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
192648c85eb7Smrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
192748c85eb7Smrg# func_to_host_file_result.
192848c85eb7Smrgfunc_convert_path_nix_to_cygwin ()
192948c85eb7Smrg{
193048c85eb7Smrg  $opt_debug
193148c85eb7Smrg  func_to_host_path_result="$1"
193248c85eb7Smrg  if test -n "$1"; then
193348c85eb7Smrg    # Remove leading and trailing path separator characters from
193448c85eb7Smrg    # ARG. msys behavior is inconsistent here, cygpath turns them
193548c85eb7Smrg    # into '.;' and ';.', and winepath ignores them completely.
193648c85eb7Smrg    func_stripname : : "$1"
193748c85eb7Smrg    func_to_host_path_tmp1=$func_stripname_result
193848c85eb7Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
193948c85eb7Smrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
194048c85eb7Smrg    func_to_host_path_result="$func_cygpath_result"
194148c85eb7Smrg    func_convert_path_check : : \
194248c85eb7Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
194348c85eb7Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
194448c85eb7Smrg  fi
1945d63fdb69Smrg}
194648c85eb7Smrg# end func_convert_path_nix_to_cygwin
194748c85eb7Smrg
1948d63fdb69Smrg
1949d63fdb69Smrg# func_mode_compile arg...
1950d63fdb69Smrgfunc_mode_compile ()
1951d63fdb69Smrg{
1952d63fdb69Smrg    $opt_debug
1953d63fdb69Smrg    # Get the compilation command and the source file.
1954d63fdb69Smrg    base_compile=
1955d63fdb69Smrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
1956d63fdb69Smrg    suppress_opt=yes
1957d63fdb69Smrg    suppress_output=
1958d63fdb69Smrg    arg_mode=normal
1959d63fdb69Smrg    libobj=
1960d63fdb69Smrg    later=
1961d63fdb69Smrg    pie_flag=
1962d63fdb69Smrg
1963d63fdb69Smrg    for arg
1964d63fdb69Smrg    do
1965d63fdb69Smrg      case $arg_mode in
1966d63fdb69Smrg      arg  )
1967d63fdb69Smrg	# do not "continue".  Instead, add this to base_compile
1968d63fdb69Smrg	lastarg="$arg"
1969d63fdb69Smrg	arg_mode=normal
1970d63fdb69Smrg	;;
1971d63fdb69Smrg
1972d63fdb69Smrg      target )
1973d63fdb69Smrg	libobj="$arg"
1974d63fdb69Smrg	arg_mode=normal
1975d63fdb69Smrg	continue
1976d63fdb69Smrg	;;
1977d63fdb69Smrg
1978d63fdb69Smrg      normal )
1979d63fdb69Smrg	# Accept any command-line options.
1980d63fdb69Smrg	case $arg in
1981d63fdb69Smrg	-o)
1982d63fdb69Smrg	  test -n "$libobj" && \
1983d63fdb69Smrg	    func_fatal_error "you cannot specify \`-o' more than once"
1984d63fdb69Smrg	  arg_mode=target
1985d63fdb69Smrg	  continue
1986d63fdb69Smrg	  ;;
1987d63fdb69Smrg
1988d63fdb69Smrg	-pie | -fpie | -fPIE)
198948c85eb7Smrg          func_append pie_flag " $arg"
1990d63fdb69Smrg	  continue
1991d63fdb69Smrg	  ;;
1992d63fdb69Smrg
1993d63fdb69Smrg	-shared | -static | -prefer-pic | -prefer-non-pic)
199448c85eb7Smrg	  func_append later " $arg"
1995d63fdb69Smrg	  continue
1996d63fdb69Smrg	  ;;
1997d63fdb69Smrg
1998d63fdb69Smrg	-no-suppress)
1999d63fdb69Smrg	  suppress_opt=no
2000d63fdb69Smrg	  continue
2001d63fdb69Smrg	  ;;
2002d63fdb69Smrg
2003d63fdb69Smrg	-Xcompiler)
2004d63fdb69Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
2005d63fdb69Smrg	  continue      #  The current "srcfile" will either be retained or
2006d63fdb69Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
2007d63fdb69Smrg
2008d63fdb69Smrg	-Wc,*)
2009d63fdb69Smrg	  func_stripname '-Wc,' '' "$arg"
2010d63fdb69Smrg	  args=$func_stripname_result
2011d63fdb69Smrg	  lastarg=
2012d63fdb69Smrg	  save_ifs="$IFS"; IFS=','
2013d63fdb69Smrg	  for arg in $args; do
2014d63fdb69Smrg	    IFS="$save_ifs"
201548c85eb7Smrg	    func_append_quoted lastarg "$arg"
20163da084b3Smrg	  done
20173da084b3Smrg	  IFS="$save_ifs"
2018d63fdb69Smrg	  func_stripname ' ' '' "$lastarg"
2019d63fdb69Smrg	  lastarg=$func_stripname_result
20203da084b3Smrg
20213da084b3Smrg	  # Add the arguments to base_compile.
202248c85eb7Smrg	  func_append base_compile " $lastarg"
20233da084b3Smrg	  continue
20243da084b3Smrg	  ;;
20253da084b3Smrg
2026d63fdb69Smrg	*)
20273da084b3Smrg	  # Accept the current argument as the source file.
20283da084b3Smrg	  # The previous "srcfile" becomes the current argument.
20293da084b3Smrg	  #
20303da084b3Smrg	  lastarg="$srcfile"
20313da084b3Smrg	  srcfile="$arg"
20323da084b3Smrg	  ;;
20333da084b3Smrg	esac  #  case $arg
20343da084b3Smrg	;;
20353da084b3Smrg      esac    #  case $arg_mode
20363da084b3Smrg
20373da084b3Smrg      # Aesthetically quote the previous argument.
203848c85eb7Smrg      func_append_quoted base_compile "$lastarg"
20393da084b3Smrg    done # for arg
20403da084b3Smrg
20413da084b3Smrg    case $arg_mode in
20423da084b3Smrg    arg)
2043d63fdb69Smrg      func_fatal_error "you must specify an argument for -Xcompile"
20443da084b3Smrg      ;;
20453da084b3Smrg    target)
2046d63fdb69Smrg      func_fatal_error "you must specify a target with \`-o'"
20473da084b3Smrg      ;;
20483da084b3Smrg    *)
20493da084b3Smrg      # Get the name of the library object.
2050d63fdb69Smrg      test -z "$libobj" && {
2051d63fdb69Smrg	func_basename "$srcfile"
2052d63fdb69Smrg	libobj="$func_basename_result"
2053d63fdb69Smrg      }
20543da084b3Smrg      ;;
20553da084b3Smrg    esac
20563da084b3Smrg
20573da084b3Smrg    # Recognize several different file suffixes.
20583da084b3Smrg    # If the user specifies -o file.o, it is replaced with file.lo
20593da084b3Smrg    case $libobj in
2060d63fdb69Smrg    *.[cCFSifmso] | \
2061d63fdb69Smrg    *.ada | *.adb | *.ads | *.asm | \
2062d63fdb69Smrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
206348c85eb7Smrg    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
2064d63fdb69Smrg      func_xform "$libobj"
2065d63fdb69Smrg      libobj=$func_xform_result
2066d63fdb69Smrg      ;;
20673da084b3Smrg    esac
20683da084b3Smrg
20693da084b3Smrg    case $libobj in
2070d63fdb69Smrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
20713da084b3Smrg    *)
2072d63fdb69Smrg      func_fatal_error "cannot determine name of library object from \`$libobj'"
20733da084b3Smrg      ;;
20743da084b3Smrg    esac
20753da084b3Smrg
20763da084b3Smrg    func_infer_tag $base_compile
20773da084b3Smrg
20783da084b3Smrg    for arg in $later; do
20793da084b3Smrg      case $arg in
2080d63fdb69Smrg      -shared)
2081d63fdb69Smrg	test "$build_libtool_libs" != yes && \
2082d63fdb69Smrg	  func_fatal_configuration "can not build a shared library"
2083d63fdb69Smrg	build_old_libs=no
2084d63fdb69Smrg	continue
2085d63fdb69Smrg	;;
2086d63fdb69Smrg
20873da084b3Smrg      -static)
2088d63fdb69Smrg	build_libtool_libs=no
20893da084b3Smrg	build_old_libs=yes
20903da084b3Smrg	continue
20913da084b3Smrg	;;
20923da084b3Smrg
20933da084b3Smrg      -prefer-pic)
20943da084b3Smrg	pic_mode=yes
20953da084b3Smrg	continue
20963da084b3Smrg	;;
20973da084b3Smrg
20983da084b3Smrg      -prefer-non-pic)
20993da084b3Smrg	pic_mode=no
21003da084b3Smrg	continue
21013da084b3Smrg	;;
21023da084b3Smrg      esac
21033da084b3Smrg    done
21043da084b3Smrg
2105d63fdb69Smrg    func_quote_for_eval "$libobj"
2106d63fdb69Smrg    test "X$libobj" != "X$func_quote_for_eval_result" \
2107d63fdb69Smrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
2108d63fdb69Smrg      && func_warning "libobj name \`$libobj' may not contain shell special characters."
2109d63fdb69Smrg    func_dirname_and_basename "$obj" "/" ""
2110d63fdb69Smrg    objname="$func_basename_result"
2111d63fdb69Smrg    xdir="$func_dirname_result"
21123da084b3Smrg    lobj=${xdir}$objdir/$objname
21133da084b3Smrg
2114d63fdb69Smrg    test -z "$base_compile" && \
2115d63fdb69Smrg      func_fatal_help "you must specify a compilation command"
21163da084b3Smrg
21173da084b3Smrg    # Delete any leftover library objects.
21183da084b3Smrg    if test "$build_old_libs" = yes; then
21193da084b3Smrg      removelist="$obj $lobj $libobj ${libobj}T"
21203da084b3Smrg    else
21213da084b3Smrg      removelist="$lobj $libobj ${libobj}T"
21223da084b3Smrg    fi
21233da084b3Smrg
21243da084b3Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
21253da084b3Smrg    case $host_os in
2126d63fdb69Smrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
21273da084b3Smrg      pic_mode=default
21283da084b3Smrg      ;;
21293da084b3Smrg    esac
21303da084b3Smrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
21313da084b3Smrg      # non-PIC code in shared libraries is not supported
21323da084b3Smrg      pic_mode=default
21333da084b3Smrg    fi
21343da084b3Smrg
21353da084b3Smrg    # Calculate the filename of the output object if compiler does
21363da084b3Smrg    # not support -o with -c
21373da084b3Smrg    if test "$compiler_c_o" = no; then
213855acc8fcSmrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
21393da084b3Smrg      lockfile="$output_obj.lock"
21403da084b3Smrg    else
21413da084b3Smrg      output_obj=
21423da084b3Smrg      need_locks=no
21433da084b3Smrg      lockfile=
21443da084b3Smrg    fi
21453da084b3Smrg
21463da084b3Smrg    # Lock this critical section if it is needed
21473da084b3Smrg    # We use this script file to make the link, it avoids creating a new file
21483da084b3Smrg    if test "$need_locks" = yes; then
2149d63fdb69Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
2150d63fdb69Smrg	func_echo "Waiting for $lockfile to be removed"
21513da084b3Smrg	sleep 2
21523da084b3Smrg      done
21533da084b3Smrg    elif test "$need_locks" = warn; then
21543da084b3Smrg      if test -f "$lockfile"; then
2155d63fdb69Smrg	$ECHO "\
21563da084b3Smrg*** ERROR, $lockfile exists and contains:
21573da084b3Smrg`cat $lockfile 2>/dev/null`
21583da084b3Smrg
21593da084b3SmrgThis indicates that another process is trying to use the same
21603da084b3Smrgtemporary object file, and libtool could not work around it because
21613da084b3Smrgyour compiler does not support \`-c' and \`-o' together.  If you
21623da084b3Smrgrepeat this compilation, it may succeed, by chance, but you had better
21633da084b3Smrgavoid parallel builds (make -j) in this platform, or get a better
21643da084b3Smrgcompiler."
21653da084b3Smrg
2166d63fdb69Smrg	$opt_dry_run || $RM $removelist
21673da084b3Smrg	exit $EXIT_FAILURE
21683da084b3Smrg      fi
216948c85eb7Smrg      func_append removelist " $output_obj"
2170d63fdb69Smrg      $ECHO "$srcfile" > "$lockfile"
21713da084b3Smrg    fi
21723da084b3Smrg
2173d63fdb69Smrg    $opt_dry_run || $RM $removelist
217448c85eb7Smrg    func_append removelist " $lockfile"
2175d63fdb69Smrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
2176d63fdb69Smrg
217748c85eb7Smrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
217848c85eb7Smrg    srcfile=$func_to_tool_file_result
2179d63fdb69Smrg    func_quote_for_eval "$srcfile"
2180d63fdb69Smrg    qsrcfile=$func_quote_for_eval_result
21813da084b3Smrg
21823da084b3Smrg    # Only build a PIC object if we are building libtool libraries.
21833da084b3Smrg    if test "$build_libtool_libs" = yes; then
21843da084b3Smrg      # Without this assignment, base_compile gets emptied.
21853da084b3Smrg      fbsd_hideous_sh_bug=$base_compile
21863da084b3Smrg
21873da084b3Smrg      if test "$pic_mode" != no; then
21883da084b3Smrg	command="$base_compile $qsrcfile $pic_flag"
21893da084b3Smrg      else
21903da084b3Smrg	# Don't build PIC code
21913da084b3Smrg	command="$base_compile $qsrcfile"
21923da084b3Smrg      fi
21933da084b3Smrg
2194d63fdb69Smrg      func_mkdir_p "$xdir$objdir"
21953da084b3Smrg
21963da084b3Smrg      if test -z "$output_obj"; then
21973da084b3Smrg	# Place PIC objects in $objdir
219848c85eb7Smrg	func_append command " -o $lobj"
21993da084b3Smrg      fi
22003da084b3Smrg
2201d63fdb69Smrg      func_show_eval_locale "$command"	\
2202d63fdb69Smrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
22033da084b3Smrg
22043da084b3Smrg      if test "$need_locks" = warn &&
22053da084b3Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2206d63fdb69Smrg	$ECHO "\
22073da084b3Smrg*** ERROR, $lockfile contains:
22083da084b3Smrg`cat $lockfile 2>/dev/null`
22093da084b3Smrg
22103da084b3Smrgbut it should contain:
22113da084b3Smrg$srcfile
22123da084b3Smrg
22133da084b3SmrgThis indicates that another process is trying to use the same
22143da084b3Smrgtemporary object file, and libtool could not work around it because
22153da084b3Smrgyour compiler does not support \`-c' and \`-o' together.  If you
22163da084b3Smrgrepeat this compilation, it may succeed, by chance, but you had better
22173da084b3Smrgavoid parallel builds (make -j) in this platform, or get a better
22183da084b3Smrgcompiler."
22193da084b3Smrg
2220d63fdb69Smrg	$opt_dry_run || $RM $removelist
22213da084b3Smrg	exit $EXIT_FAILURE
22223da084b3Smrg      fi
22233da084b3Smrg
22243da084b3Smrg      # Just move the object if needed, then go on to compile the next one
22253da084b3Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
2226d63fdb69Smrg	func_show_eval '$MV "$output_obj" "$lobj"' \
2227d63fdb69Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
22283da084b3Smrg      fi
22293da084b3Smrg
22303da084b3Smrg      # Allow error messages only from the first compilation.
22313da084b3Smrg      if test "$suppress_opt" = yes; then
2232d63fdb69Smrg	suppress_output=' >/dev/null 2>&1'
22333da084b3Smrg      fi
22343da084b3Smrg    fi
22353da084b3Smrg
22363da084b3Smrg    # Only build a position-dependent object if we build old libraries.
22373da084b3Smrg    if test "$build_old_libs" = yes; then
22383da084b3Smrg      if test "$pic_mode" != yes; then
22393da084b3Smrg	# Don't build PIC code
2240d63fdb69Smrg	command="$base_compile $qsrcfile$pie_flag"
22413da084b3Smrg      else
22423da084b3Smrg	command="$base_compile $qsrcfile $pic_flag"
22433da084b3Smrg      fi
22443da084b3Smrg      if test "$compiler_c_o" = yes; then
224548c85eb7Smrg	func_append command " -o $obj"
22463da084b3Smrg      fi
22473da084b3Smrg
22483da084b3Smrg      # Suppress compiler output if we already did a PIC compilation.
224948c85eb7Smrg      func_append command "$suppress_output"
2250d63fdb69Smrg      func_show_eval_locale "$command" \
2251d63fdb69Smrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
22523da084b3Smrg
22533da084b3Smrg      if test "$need_locks" = warn &&
22543da084b3Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2255d63fdb69Smrg	$ECHO "\
22563da084b3Smrg*** ERROR, $lockfile contains:
22573da084b3Smrg`cat $lockfile 2>/dev/null`
22583da084b3Smrg
22593da084b3Smrgbut it should contain:
22603da084b3Smrg$srcfile
22613da084b3Smrg
22623da084b3SmrgThis indicates that another process is trying to use the same
22633da084b3Smrgtemporary object file, and libtool could not work around it because
22643da084b3Smrgyour compiler does not support \`-c' and \`-o' together.  If you
22653da084b3Smrgrepeat this compilation, it may succeed, by chance, but you had better
22663da084b3Smrgavoid parallel builds (make -j) in this platform, or get a better
22673da084b3Smrgcompiler."
22683da084b3Smrg
2269d63fdb69Smrg	$opt_dry_run || $RM $removelist
22703da084b3Smrg	exit $EXIT_FAILURE
22713da084b3Smrg      fi
22723da084b3Smrg
22733da084b3Smrg      # Just move the object if needed
22743da084b3Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
2275d63fdb69Smrg	func_show_eval '$MV "$output_obj" "$obj"' \
2276d63fdb69Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
22773da084b3Smrg      fi
22783da084b3Smrg    fi
22793da084b3Smrg
2280d63fdb69Smrg    $opt_dry_run || {
2281d63fdb69Smrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
22823da084b3Smrg
2283d63fdb69Smrg      # Unlock the critical section if it was locked
2284d63fdb69Smrg      if test "$need_locks" != no; then
2285d63fdb69Smrg	removelist=$lockfile
2286d63fdb69Smrg        $RM "$lockfile"
2287d63fdb69Smrg      fi
2288d63fdb69Smrg    }
22893da084b3Smrg
22903da084b3Smrg    exit $EXIT_SUCCESS
2291d63fdb69Smrg}
22923da084b3Smrg
2293d63fdb69Smrg$opt_help || {
229448c85eb7Smrg  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
2295d63fdb69Smrg}
22963da084b3Smrg
2297d63fdb69Smrgfunc_mode_help ()
2298d63fdb69Smrg{
2299d63fdb69Smrg    # We need to display help for each of the modes.
230048c85eb7Smrg    case $opt_mode in
2301d63fdb69Smrg      "")
2302d63fdb69Smrg        # Generic help is extracted from the usage comments
2303d63fdb69Smrg        # at the start of this file.
2304d63fdb69Smrg        func_help
2305d63fdb69Smrg        ;;
23063da084b3Smrg
2307d63fdb69Smrg      clean)
2308d63fdb69Smrg        $ECHO \
2309d63fdb69Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
23103da084b3Smrg
2311d63fdb69SmrgRemove files from the build directory.
23123da084b3Smrg
2313d63fdb69SmrgRM is the name of the program to use to delete files associated with each FILE
2314d63fdb69Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2315d63fdb69Smrgto RM.
23163da084b3Smrg
2317d63fdb69SmrgIf FILE is a libtool library, object or program, all the files associated
2318d63fdb69Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
2319d63fdb69Smrg        ;;
23203da084b3Smrg
2321d63fdb69Smrg      compile)
2322d63fdb69Smrg      $ECHO \
2323d63fdb69Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
23243da084b3Smrg
2325d63fdb69SmrgCompile a source file into a libtool library object.
23263da084b3Smrg
2327d63fdb69SmrgThis mode accepts the following additional options:
23283da084b3Smrg
2329d63fdb69Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
2330d63fdb69Smrg  -no-suppress      do not suppress compiler output for multiple passes
233155acc8fcSmrg  -prefer-pic       try to build PIC objects only
233255acc8fcSmrg  -prefer-non-pic   try to build non-PIC objects only
2333d63fdb69Smrg  -shared           do not build a \`.o' file suitable for static linking
2334d63fdb69Smrg  -static           only build a \`.o' file suitable for static linking
233555acc8fcSmrg  -Wc,FLAG          pass FLAG directly to the compiler
23363da084b3Smrg
2337d63fdb69SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
2338d63fdb69Smrgfrom the given SOURCEFILE.
23393da084b3Smrg
2340d63fdb69SmrgThe output file name is determined by removing the directory component from
2341d63fdb69SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
2342d63fdb69Smrglibrary object suffix, \`.lo'."
2343d63fdb69Smrg        ;;
23443da084b3Smrg
2345d63fdb69Smrg      execute)
2346d63fdb69Smrg        $ECHO \
2347d63fdb69Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
23483da084b3Smrg
2349d63fdb69SmrgAutomatically set library path, then run a program.
23503da084b3Smrg
2351d63fdb69SmrgThis mode accepts the following additional options:
23523da084b3Smrg
2353d63fdb69Smrg  -dlopen FILE      add the directory containing FILE to the library path
23543da084b3Smrg
2355d63fdb69SmrgThis mode sets the library path environment variable according to \`-dlopen'
2356d63fdb69Smrgflags.
23573da084b3Smrg
2358d63fdb69SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
2359d63fdb69Smrginto their corresponding uninstalled binary, and any of their required library
2360d63fdb69Smrgdirectories are added to the library path.
23613da084b3Smrg
2362d63fdb69SmrgThen, COMMAND is executed, with ARGS as arguments."
2363d63fdb69Smrg        ;;
23643da084b3Smrg
2365d63fdb69Smrg      finish)
2366d63fdb69Smrg        $ECHO \
2367d63fdb69Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
23683da084b3Smrg
2369d63fdb69SmrgComplete the installation of libtool libraries.
23703da084b3Smrg
2371d63fdb69SmrgEach LIBDIR is a directory that contains libtool libraries.
23723da084b3Smrg
2373d63fdb69SmrgThe commands that this mode executes may require superuser privileges.  Use
2374d63fdb69Smrgthe \`--dry-run' option if you just want to see what would be executed."
2375d63fdb69Smrg        ;;
23763da084b3Smrg
2377d63fdb69Smrg      install)
2378d63fdb69Smrg        $ECHO \
2379d63fdb69Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
23803da084b3Smrg
2381d63fdb69SmrgInstall executables or libraries.
23823da084b3Smrg
2383d63fdb69SmrgINSTALL-COMMAND is the installation command.  The first component should be
2384d63fdb69Smrgeither the \`install' or \`cp' program.
23853da084b3Smrg
2386d63fdb69SmrgThe following components of INSTALL-COMMAND are treated specially:
23873da084b3Smrg
238855acc8fcSmrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
23893da084b3Smrg
2390d63fdb69SmrgThe rest of the components are interpreted as arguments to that command (only
2391d63fdb69SmrgBSD-compatible install options are recognized)."
2392d63fdb69Smrg        ;;
23933da084b3Smrg
2394d63fdb69Smrg      link)
2395d63fdb69Smrg        $ECHO \
2396d63fdb69Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
23973da084b3Smrg
2398d63fdb69SmrgLink object files or libraries together to form another library, or to
2399d63fdb69Smrgcreate an executable program.
24003da084b3Smrg
2401d63fdb69SmrgLINK-COMMAND is a command using the C compiler that you would use to create
2402d63fdb69Smrga program from several object files.
24033da084b3Smrg
2404d63fdb69SmrgThe following components of LINK-COMMAND are treated specially:
24053da084b3Smrg
2406d63fdb69Smrg  -all-static       do not do any dynamic linking at all
2407d63fdb69Smrg  -avoid-version    do not add a version suffix if possible
240855acc8fcSmrg  -bindir BINDIR    specify path to binaries directory (for systems where
240955acc8fcSmrg                    libraries must be found in the PATH setting at runtime)
2410d63fdb69Smrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
2411d63fdb69Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
2412d63fdb69Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
2413d63fdb69Smrg  -export-symbols SYMFILE
2414d63fdb69Smrg                    try to export only the symbols listed in SYMFILE
2415d63fdb69Smrg  -export-symbols-regex REGEX
2416d63fdb69Smrg                    try to export only the symbols matching REGEX
2417d63fdb69Smrg  -LLIBDIR          search LIBDIR for required installed libraries
2418d63fdb69Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
2419d63fdb69Smrg  -module           build a library that can dlopened
2420d63fdb69Smrg  -no-fast-install  disable the fast-install mode
2421d63fdb69Smrg  -no-install       link a not-installable executable
2422d63fdb69Smrg  -no-undefined     declare that a library does not refer to external symbols
2423d63fdb69Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
2424d63fdb69Smrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
2425d63fdb69Smrg  -precious-files-regex REGEX
2426d63fdb69Smrg                    don't remove output files matching REGEX
2427d63fdb69Smrg  -release RELEASE  specify package release information
2428d63fdb69Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
2429d63fdb69Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
2430d63fdb69Smrg  -shared           only do dynamic linking of libtool libraries
2431d63fdb69Smrg  -shrext SUFFIX    override the standard shared library file extension
2432d63fdb69Smrg  -static           do not do any dynamic linking of uninstalled libtool libraries
2433d63fdb69Smrg  -static-libtool-libs
2434d63fdb69Smrg                    do not do any dynamic linking of libtool libraries
2435d63fdb69Smrg  -version-info CURRENT[:REVISION[:AGE]]
2436d63fdb69Smrg                    specify library version info [each variable defaults to 0]
2437d63fdb69Smrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
243855acc8fcSmrg  -Wc,FLAG
243955acc8fcSmrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
244055acc8fcSmrg  -Wl,FLAG
244155acc8fcSmrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
244255acc8fcSmrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
24433da084b3Smrg
2444d63fdb69SmrgAll other options (arguments beginning with \`-') are ignored.
24453da084b3Smrg
2446d63fdb69SmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
2447d63fdb69Smrgtreated as uninstalled libtool libraries, other files are standard or library
2448d63fdb69Smrgobject files.
24493da084b3Smrg
2450d63fdb69SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
2451d63fdb69Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
2452d63fdb69Smrgrequired, except when creating a convenience library.
24533da084b3Smrg
2454d63fdb69SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
2455d63fdb69Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
24563da084b3Smrg
2457d63fdb69SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
2458d63fdb69Smrgis created, otherwise an executable program is created."
24593da084b3Smrg        ;;
24603da084b3Smrg
2461d63fdb69Smrg      uninstall)
2462d63fdb69Smrg        $ECHO \
2463d63fdb69Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
24643da084b3Smrg
2465d63fdb69SmrgRemove libraries from an installation directory.
24663da084b3Smrg
2467d63fdb69SmrgRM is the name of the program to use to delete files associated with each FILE
2468d63fdb69Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2469d63fdb69Smrgto RM.
24703da084b3Smrg
2471d63fdb69SmrgIf FILE is a libtool library, all the files associated with it are deleted.
2472d63fdb69SmrgOtherwise, only FILE itself is deleted using RM."
2473d63fdb69Smrg        ;;
24743da084b3Smrg
2475d63fdb69Smrg      *)
247648c85eb7Smrg        func_fatal_help "invalid operation mode \`$opt_mode'"
2477d63fdb69Smrg        ;;
2478d63fdb69Smrg    esac
24793da084b3Smrg
248055acc8fcSmrg    echo
2481d63fdb69Smrg    $ECHO "Try \`$progname --help' for more information about other modes."
2482d63fdb69Smrg}
24833da084b3Smrg
248455acc8fcSmrg# Now that we've collected a possible --mode arg, show help if necessary
248555acc8fcSmrgif $opt_help; then
248655acc8fcSmrg  if test "$opt_help" = :; then
248755acc8fcSmrg    func_mode_help
248855acc8fcSmrg  else
248955acc8fcSmrg    {
249055acc8fcSmrg      func_help noexit
249148c85eb7Smrg      for opt_mode in compile link execute install finish uninstall clean; do
249255acc8fcSmrg	func_mode_help
249355acc8fcSmrg      done
249455acc8fcSmrg    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
249555acc8fcSmrg    {
249655acc8fcSmrg      func_help noexit
249748c85eb7Smrg      for opt_mode in compile link execute install finish uninstall clean; do
249855acc8fcSmrg	echo
249955acc8fcSmrg	func_mode_help
250055acc8fcSmrg      done
250155acc8fcSmrg    } |
250255acc8fcSmrg    sed '1d
250355acc8fcSmrg      /^When reporting/,/^Report/{
250455acc8fcSmrg	H
250555acc8fcSmrg	d
250655acc8fcSmrg      }
250755acc8fcSmrg      $x
250855acc8fcSmrg      /information about other modes/d
250955acc8fcSmrg      /more detailed .*MODE/d
251055acc8fcSmrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
251155acc8fcSmrg  fi
251255acc8fcSmrg  exit $?
251355acc8fcSmrgfi
25143da084b3Smrg
25153da084b3Smrg
2516d63fdb69Smrg# func_mode_execute arg...
2517d63fdb69Smrgfunc_mode_execute ()
2518d63fdb69Smrg{
2519d63fdb69Smrg    $opt_debug
2520d63fdb69Smrg    # The first argument is the command name.
2521d63fdb69Smrg    cmd="$nonopt"
2522d63fdb69Smrg    test -z "$cmd" && \
2523d63fdb69Smrg      func_fatal_help "you must specify a COMMAND"
25243da084b3Smrg
2525d63fdb69Smrg    # Handle -dlopen flags immediately.
252648c85eb7Smrg    for file in $opt_dlopen; do
2527d63fdb69Smrg      test -f "$file" \
2528d63fdb69Smrg	|| func_fatal_help "\`$file' is not a file"
25293da084b3Smrg
2530d63fdb69Smrg      dir=
2531d63fdb69Smrg      case $file in
2532d63fdb69Smrg      *.la)
253348c85eb7Smrg	func_resolve_sysroot "$file"
253448c85eb7Smrg	file=$func_resolve_sysroot_result
253548c85eb7Smrg
2536d63fdb69Smrg	# Check to see that this really is a libtool archive.
2537d63fdb69Smrg	func_lalib_unsafe_p "$file" \
2538d63fdb69Smrg	  || func_fatal_help "\`$lib' is not a valid libtool archive"
25393da084b3Smrg
2540d63fdb69Smrg	# Read the libtool library.
2541d63fdb69Smrg	dlname=
2542d63fdb69Smrg	library_names=
2543d63fdb69Smrg	func_source "$file"
25443da084b3Smrg
2545d63fdb69Smrg	# Skip this library if it cannot be dlopened.
2546d63fdb69Smrg	if test -z "$dlname"; then
2547d63fdb69Smrg	  # Warn if it was a shared library.
2548d63fdb69Smrg	  test -n "$library_names" && \
2549d63fdb69Smrg	    func_warning "\`$file' was not linked with \`-export-dynamic'"
2550d63fdb69Smrg	  continue
2551d63fdb69Smrg	fi
25523da084b3Smrg
2553d63fdb69Smrg	func_dirname "$file" "" "."
2554d63fdb69Smrg	dir="$func_dirname_result"
25553da084b3Smrg
2556d63fdb69Smrg	if test -f "$dir/$objdir/$dlname"; then
255748c85eb7Smrg	  func_append dir "/$objdir"
2558d63fdb69Smrg	else
2559d63fdb69Smrg	  if test ! -f "$dir/$dlname"; then
2560d63fdb69Smrg	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
2561d63fdb69Smrg	  fi
2562d63fdb69Smrg	fi
25633da084b3Smrg	;;
25643da084b3Smrg
2565d63fdb69Smrg      *.lo)
2566d63fdb69Smrg	# Just add the directory containing the .lo file.
2567d63fdb69Smrg	func_dirname "$file" "" "."
2568d63fdb69Smrg	dir="$func_dirname_result"
25693da084b3Smrg	;;
25703da084b3Smrg
2571d63fdb69Smrg      *)
2572d63fdb69Smrg	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
25733da084b3Smrg	continue
25743da084b3Smrg	;;
2575d63fdb69Smrg      esac
25763da084b3Smrg
2577d63fdb69Smrg      # Get the absolute pathname.
2578d63fdb69Smrg      absdir=`cd "$dir" && pwd`
2579d63fdb69Smrg      test -n "$absdir" && dir="$absdir"
25803da084b3Smrg
2581d63fdb69Smrg      # Now add the directory to shlibpath_var.
2582d63fdb69Smrg      if eval "test -z \"\$$shlibpath_var\""; then
2583d63fdb69Smrg	eval "$shlibpath_var=\"\$dir\""
2584d63fdb69Smrg      else
2585d63fdb69Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
2586d63fdb69Smrg      fi
2587d63fdb69Smrg    done
25883da084b3Smrg
2589d63fdb69Smrg    # This variable tells wrapper scripts just to set shlibpath_var
2590d63fdb69Smrg    # rather than running their programs.
2591d63fdb69Smrg    libtool_execute_magic="$magic"
25923da084b3Smrg
2593d63fdb69Smrg    # Check if any of the arguments is a wrapper script.
2594d63fdb69Smrg    args=
2595d63fdb69Smrg    for file
2596d63fdb69Smrg    do
2597d63fdb69Smrg      case $file in
259855acc8fcSmrg      -* | *.la | *.lo ) ;;
2599d63fdb69Smrg      *)
2600d63fdb69Smrg	# Do a test to see if this is really a libtool program.
2601d63fdb69Smrg	if func_ltwrapper_script_p "$file"; then
2602d63fdb69Smrg	  func_source "$file"
2603d63fdb69Smrg	  # Transform arg to wrapped name.
2604d63fdb69Smrg	  file="$progdir/$program"
2605d63fdb69Smrg	elif func_ltwrapper_executable_p "$file"; then
2606d63fdb69Smrg	  func_ltwrapper_scriptname "$file"
2607d63fdb69Smrg	  func_source "$func_ltwrapper_scriptname_result"
2608d63fdb69Smrg	  # Transform arg to wrapped name.
2609d63fdb69Smrg	  file="$progdir/$program"
2610d63fdb69Smrg	fi
2611d63fdb69Smrg	;;
2612d63fdb69Smrg      esac
2613d63fdb69Smrg      # Quote arguments (to preserve shell metacharacters).
261448c85eb7Smrg      func_append_quoted args "$file"
2615d63fdb69Smrg    done
26163da084b3Smrg
2617d63fdb69Smrg    if test "X$opt_dry_run" = Xfalse; then
2618d63fdb69Smrg      if test -n "$shlibpath_var"; then
2619d63fdb69Smrg	# Export the shlibpath_var.
2620d63fdb69Smrg	eval "export $shlibpath_var"
2621d63fdb69Smrg      fi
26223da084b3Smrg
2623d63fdb69Smrg      # Restore saved environment variables
2624d63fdb69Smrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
2625d63fdb69Smrg      do
2626d63fdb69Smrg	eval "if test \"\${save_$lt_var+set}\" = set; then
2627d63fdb69Smrg                $lt_var=\$save_$lt_var; export $lt_var
2628d63fdb69Smrg	      else
2629d63fdb69Smrg		$lt_unset $lt_var
2630d63fdb69Smrg	      fi"
2631d63fdb69Smrg      done
26323da084b3Smrg
2633d63fdb69Smrg      # Now prepare to actually exec the command.
2634d63fdb69Smrg      exec_cmd="\$cmd$args"
2635d63fdb69Smrg    else
2636d63fdb69Smrg      # Display what would be done.
2637d63fdb69Smrg      if test -n "$shlibpath_var"; then
2638d63fdb69Smrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
263955acc8fcSmrg	echo "export $shlibpath_var"
2640d63fdb69Smrg      fi
2641d63fdb69Smrg      $ECHO "$cmd$args"
2642d63fdb69Smrg      exit $EXIT_SUCCESS
2643d63fdb69Smrg    fi
2644d63fdb69Smrg}
26453da084b3Smrg
264648c85eb7Smrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"}
26473da084b3Smrg
26483da084b3Smrg
2649d63fdb69Smrg# func_mode_finish arg...
2650d63fdb69Smrgfunc_mode_finish ()
2651d63fdb69Smrg{
2652d63fdb69Smrg    $opt_debug
265348c85eb7Smrg    libs=
265448c85eb7Smrg    libdirs=
2655d63fdb69Smrg    admincmds=
26563da084b3Smrg
265748c85eb7Smrg    for opt in "$nonopt" ${1+"$@"}
265848c85eb7Smrg    do
265948c85eb7Smrg      if test -d "$opt"; then
266048c85eb7Smrg	func_append libdirs " $opt"
266148c85eb7Smrg
266248c85eb7Smrg      elif test -f "$opt"; then
266348c85eb7Smrg	if func_lalib_unsafe_p "$opt"; then
266448c85eb7Smrg	  func_append libs " $opt"
266548c85eb7Smrg	else
266648c85eb7Smrg	  func_warning "\`$opt' is not a valid libtool archive"
266748c85eb7Smrg	fi
266848c85eb7Smrg
266948c85eb7Smrg      else
267048c85eb7Smrg	func_fatal_error "invalid argument \`$opt'"
267148c85eb7Smrg      fi
267248c85eb7Smrg    done
267348c85eb7Smrg
267448c85eb7Smrg    if test -n "$libs"; then
267548c85eb7Smrg      if test -n "$lt_sysroot"; then
267648c85eb7Smrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
267748c85eb7Smrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
267848c85eb7Smrg      else
267948c85eb7Smrg        sysroot_cmd=
268048c85eb7Smrg      fi
268148c85eb7Smrg
268248c85eb7Smrg      # Remove sysroot references
268348c85eb7Smrg      if $opt_dry_run; then
268448c85eb7Smrg        for lib in $libs; do
268548c85eb7Smrg          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
268648c85eb7Smrg        done
268748c85eb7Smrg      else
268848c85eb7Smrg        tmpdir=`func_mktempdir`
268948c85eb7Smrg        for lib in $libs; do
269048c85eb7Smrg	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
269148c85eb7Smrg	    > $tmpdir/tmp-la
269248c85eb7Smrg	  mv -f $tmpdir/tmp-la $lib
269348c85eb7Smrg	done
269448c85eb7Smrg        ${RM}r "$tmpdir"
269548c85eb7Smrg      fi
269648c85eb7Smrg    fi
26973da084b3Smrg
269848c85eb7Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2699d63fdb69Smrg      for libdir in $libdirs; do
2700d63fdb69Smrg	if test -n "$finish_cmds"; then
2701d63fdb69Smrg	  # Do each command in the finish commands.
2702d63fdb69Smrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
2703d63fdb69Smrg'"$cmd"'"'
2704d63fdb69Smrg	fi
2705d63fdb69Smrg	if test -n "$finish_eval"; then
2706d63fdb69Smrg	  # Do the single finish_eval.
2707d63fdb69Smrg	  eval cmds=\"$finish_eval\"
270848c85eb7Smrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
2709d63fdb69Smrg       $cmds"
2710d63fdb69Smrg	fi
2711d63fdb69Smrg      done
2712d63fdb69Smrg    fi
27133da084b3Smrg
2714d63fdb69Smrg    # Exit here if they wanted silent mode.
2715d63fdb69Smrg    $opt_silent && exit $EXIT_SUCCESS
27163da084b3Smrg
271748c85eb7Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
271848c85eb7Smrg      echo "----------------------------------------------------------------------"
271948c85eb7Smrg      echo "Libraries have been installed in:"
272048c85eb7Smrg      for libdir in $libdirs; do
272148c85eb7Smrg	$ECHO "   $libdir"
272248c85eb7Smrg      done
272348c85eb7Smrg      echo
272448c85eb7Smrg      echo "If you ever happen to want to link against installed libraries"
272548c85eb7Smrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
272648c85eb7Smrg      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
272748c85eb7Smrg      echo "flag during linking and do at least one of the following:"
272848c85eb7Smrg      if test -n "$shlibpath_var"; then
272948c85eb7Smrg	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
273048c85eb7Smrg	echo "     during execution"
273148c85eb7Smrg      fi
273248c85eb7Smrg      if test -n "$runpath_var"; then
273348c85eb7Smrg	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
273448c85eb7Smrg	echo "     during linking"
273548c85eb7Smrg      fi
273648c85eb7Smrg      if test -n "$hardcode_libdir_flag_spec"; then
273748c85eb7Smrg	libdir=LIBDIR
273848c85eb7Smrg	eval flag=\"$hardcode_libdir_flag_spec\"
27393da084b3Smrg
274048c85eb7Smrg	$ECHO "   - use the \`$flag' linker flag"
274148c85eb7Smrg      fi
274248c85eb7Smrg      if test -n "$admincmds"; then
274348c85eb7Smrg	$ECHO "   - have your system administrator run these commands:$admincmds"
274448c85eb7Smrg      fi
274548c85eb7Smrg      if test -f /etc/ld.so.conf; then
274648c85eb7Smrg	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
274748c85eb7Smrg      fi
274848c85eb7Smrg      echo
27493da084b3Smrg
275048c85eb7Smrg      echo "See any operating system documentation about shared libraries for"
275148c85eb7Smrg      case $host in
275248c85eb7Smrg	solaris2.[6789]|solaris2.1[0-9])
275348c85eb7Smrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
275448c85eb7Smrg	  echo "pages."
275548c85eb7Smrg	  ;;
275648c85eb7Smrg	*)
275748c85eb7Smrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
275848c85eb7Smrg	  ;;
275948c85eb7Smrg      esac
276048c85eb7Smrg      echo "----------------------------------------------------------------------"
276148c85eb7Smrg    fi
2762d63fdb69Smrg    exit $EXIT_SUCCESS
2763d63fdb69Smrg}
27643da084b3Smrg
276548c85eb7Smrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"}
27663da084b3Smrg
27673da084b3Smrg
2768d63fdb69Smrg# func_mode_install arg...
2769d63fdb69Smrgfunc_mode_install ()
2770d63fdb69Smrg{
2771d63fdb69Smrg    $opt_debug
2772d63fdb69Smrg    # There may be an optional sh(1) argument at the beginning of
2773d63fdb69Smrg    # install_prog (especially on Windows NT).
2774d63fdb69Smrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
2775d63fdb69Smrg       # Allow the use of GNU shtool's install command.
277655acc8fcSmrg       case $nonopt in *shtool*) :;; *) false;; esac; then
2777d63fdb69Smrg      # Aesthetically quote it.
2778d63fdb69Smrg      func_quote_for_eval "$nonopt"
2779d63fdb69Smrg      install_prog="$func_quote_for_eval_result "
2780d63fdb69Smrg      arg=$1
2781d63fdb69Smrg      shift
2782d63fdb69Smrg    else
2783d63fdb69Smrg      install_prog=
2784d63fdb69Smrg      arg=$nonopt
2785d63fdb69Smrg    fi
27863da084b3Smrg
2787d63fdb69Smrg    # The real first argument should be the name of the installation program.
2788d63fdb69Smrg    # Aesthetically quote it.
2789d63fdb69Smrg    func_quote_for_eval "$arg"
279048c85eb7Smrg    func_append install_prog "$func_quote_for_eval_result"
279155acc8fcSmrg    install_shared_prog=$install_prog
279255acc8fcSmrg    case " $install_prog " in
279355acc8fcSmrg      *[\\\ /]cp\ *) install_cp=: ;;
279455acc8fcSmrg      *) install_cp=false ;;
279555acc8fcSmrg    esac
2796d63fdb69Smrg
2797d63fdb69Smrg    # We need to accept at least all the BSD install flags.
2798d63fdb69Smrg    dest=
2799d63fdb69Smrg    files=
2800d63fdb69Smrg    opts=
2801d63fdb69Smrg    prev=
2802d63fdb69Smrg    install_type=
2803d63fdb69Smrg    isdir=no
2804d63fdb69Smrg    stripme=
280555acc8fcSmrg    no_mode=:
2806d63fdb69Smrg    for arg
2807d63fdb69Smrg    do
280855acc8fcSmrg      arg2=
2809d63fdb69Smrg      if test -n "$dest"; then
281048c85eb7Smrg	func_append files " $dest"
2811d63fdb69Smrg	dest=$arg
2812d63fdb69Smrg	continue
28133da084b3Smrg      fi
28143da084b3Smrg
2815d63fdb69Smrg      case $arg in
2816d63fdb69Smrg      -d) isdir=yes ;;
2817d63fdb69Smrg      -f)
281855acc8fcSmrg	if $install_cp; then :; else
281955acc8fcSmrg	  prev=$arg
282055acc8fcSmrg	fi
2821d63fdb69Smrg	;;
2822d63fdb69Smrg      -g | -m | -o)
2823d63fdb69Smrg	prev=$arg
2824d63fdb69Smrg	;;
2825d63fdb69Smrg      -s)
2826d63fdb69Smrg	stripme=" -s"
2827d63fdb69Smrg	continue
2828d63fdb69Smrg	;;
2829d63fdb69Smrg      -*)
2830d63fdb69Smrg	;;
2831d63fdb69Smrg      *)
2832d63fdb69Smrg	# If the previous option needed an argument, then skip it.
2833d63fdb69Smrg	if test -n "$prev"; then
283455acc8fcSmrg	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
283555acc8fcSmrg	    arg2=$install_override_mode
283655acc8fcSmrg	    no_mode=false
283755acc8fcSmrg	  fi
2838d63fdb69Smrg	  prev=
2839d63fdb69Smrg	else
2840d63fdb69Smrg	  dest=$arg
2841d63fdb69Smrg	  continue
2842d63fdb69Smrg	fi
2843d63fdb69Smrg	;;
2844d63fdb69Smrg      esac
28453da084b3Smrg
2846d63fdb69Smrg      # Aesthetically quote the argument.
2847d63fdb69Smrg      func_quote_for_eval "$arg"
284848c85eb7Smrg      func_append install_prog " $func_quote_for_eval_result"
284955acc8fcSmrg      if test -n "$arg2"; then
285055acc8fcSmrg	func_quote_for_eval "$arg2"
285155acc8fcSmrg      fi
285248c85eb7Smrg      func_append install_shared_prog " $func_quote_for_eval_result"
2853d63fdb69Smrg    done
28543da084b3Smrg
2855d63fdb69Smrg    test -z "$install_prog" && \
2856d63fdb69Smrg      func_fatal_help "you must specify an install program"
28573da084b3Smrg
2858d63fdb69Smrg    test -n "$prev" && \
2859d63fdb69Smrg      func_fatal_help "the \`$prev' option requires an argument"
28603da084b3Smrg
286155acc8fcSmrg    if test -n "$install_override_mode" && $no_mode; then
286255acc8fcSmrg      if $install_cp; then :; else
286355acc8fcSmrg	func_quote_for_eval "$install_override_mode"
286448c85eb7Smrg	func_append install_shared_prog " -m $func_quote_for_eval_result"
286555acc8fcSmrg      fi
286655acc8fcSmrg    fi
286755acc8fcSmrg
2868d63fdb69Smrg    if test -z "$files"; then
2869d63fdb69Smrg      if test -z "$dest"; then
2870d63fdb69Smrg	func_fatal_help "no file or destination specified"
2871d63fdb69Smrg      else
2872d63fdb69Smrg	func_fatal_help "you must specify a destination"
28733da084b3Smrg      fi
28743da084b3Smrg    fi
28753da084b3Smrg
2876d63fdb69Smrg    # Strip any trailing slash from the destination.
2877d63fdb69Smrg    func_stripname '' '/' "$dest"
2878d63fdb69Smrg    dest=$func_stripname_result
28793da084b3Smrg
2880d63fdb69Smrg    # Check to see that the destination is a directory.
2881d63fdb69Smrg    test -d "$dest" && isdir=yes
2882d63fdb69Smrg    if test "$isdir" = yes; then
2883d63fdb69Smrg      destdir="$dest"
2884d63fdb69Smrg      destname=
2885d63fdb69Smrg    else
2886d63fdb69Smrg      func_dirname_and_basename "$dest" "" "."
2887d63fdb69Smrg      destdir="$func_dirname_result"
2888d63fdb69Smrg      destname="$func_basename_result"
2889d63fdb69Smrg
2890d63fdb69Smrg      # Not a directory, so check to see that there is only one file specified.
2891d63fdb69Smrg      set dummy $files; shift
2892d63fdb69Smrg      test "$#" -gt 1 && \
2893d63fdb69Smrg	func_fatal_help "\`$dest' is not a directory"
2894d63fdb69Smrg    fi
2895d63fdb69Smrg    case $destdir in
2896d63fdb69Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
28973da084b3Smrg    *)
2898d63fdb69Smrg      for file in $files; do
2899d63fdb69Smrg	case $file in
2900d63fdb69Smrg	*.lo) ;;
2901d63fdb69Smrg	*)
2902d63fdb69Smrg	  func_fatal_help "\`$destdir' must be an absolute directory name"
2903d63fdb69Smrg	  ;;
2904d63fdb69Smrg	esac
2905d63fdb69Smrg      done
29063da084b3Smrg      ;;
29073da084b3Smrg    esac
29083da084b3Smrg
2909d63fdb69Smrg    # This variable tells wrapper scripts just to set variables rather
2910d63fdb69Smrg    # than running their programs.
2911d63fdb69Smrg    libtool_install_magic="$magic"
29123da084b3Smrg
2913d63fdb69Smrg    staticlibs=
2914d63fdb69Smrg    future_libdirs=
2915d63fdb69Smrg    current_libdirs=
2916d63fdb69Smrg    for file in $files; do
29173da084b3Smrg
2918d63fdb69Smrg      # Do each installation.
2919d63fdb69Smrg      case $file in
2920d63fdb69Smrg      *.$libext)
2921d63fdb69Smrg	# Do the static libraries later.
292248c85eb7Smrg	func_append staticlibs " $file"
2923d63fdb69Smrg	;;
2924d63fdb69Smrg
2925d63fdb69Smrg      *.la)
292648c85eb7Smrg	func_resolve_sysroot "$file"
292748c85eb7Smrg	file=$func_resolve_sysroot_result
292848c85eb7Smrg
2929d63fdb69Smrg	# Check to see that this really is a libtool archive.
2930d63fdb69Smrg	func_lalib_unsafe_p "$file" \
2931d63fdb69Smrg	  || func_fatal_help "\`$file' is not a valid libtool archive"
2932d63fdb69Smrg
2933d63fdb69Smrg	library_names=
2934d63fdb69Smrg	old_library=
2935d63fdb69Smrg	relink_command=
2936d63fdb69Smrg	func_source "$file"
2937d63fdb69Smrg
2938d63fdb69Smrg	# Add the libdir to current_libdirs if it is the destination.
2939d63fdb69Smrg	if test "X$destdir" = "X$libdir"; then
2940d63fdb69Smrg	  case "$current_libdirs " in
2941d63fdb69Smrg	  *" $libdir "*) ;;
294248c85eb7Smrg	  *) func_append current_libdirs " $libdir" ;;
29433da084b3Smrg	  esac
2944d63fdb69Smrg	else
2945d63fdb69Smrg	  # Note the libdir as a future libdir.
2946d63fdb69Smrg	  case "$future_libdirs " in
2947d63fdb69Smrg	  *" $libdir "*) ;;
294848c85eb7Smrg	  *) func_append future_libdirs " $libdir" ;;
2949d63fdb69Smrg	  esac
2950d63fdb69Smrg	fi
29513da084b3Smrg
2952d63fdb69Smrg	func_dirname "$file" "/" ""
2953d63fdb69Smrg	dir="$func_dirname_result"
295448c85eb7Smrg	func_append dir "$objdir"
2955d63fdb69Smrg
2956d63fdb69Smrg	if test -n "$relink_command"; then
2957d63fdb69Smrg	  # Determine the prefix the user has applied to our future dir.
295855acc8fcSmrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
2959d63fdb69Smrg
2960d63fdb69Smrg	  # Don't allow the user to place us outside of our expected
2961d63fdb69Smrg	  # location b/c this prevents finding dependent libraries that
2962d63fdb69Smrg	  # are installed to the same prefix.
2963d63fdb69Smrg	  # At present, this check doesn't affect windows .dll's that
2964d63fdb69Smrg	  # are installed into $libdir/../bin (currently, that works fine)
2965d63fdb69Smrg	  # but it's something to keep an eye on.
2966d63fdb69Smrg	  test "$inst_prefix_dir" = "$destdir" && \
2967d63fdb69Smrg	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2968d63fdb69Smrg
2969d63fdb69Smrg	  if test -n "$inst_prefix_dir"; then
2970d63fdb69Smrg	    # Stick the inst_prefix_dir data into the link command.
297155acc8fcSmrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2972d63fdb69Smrg	  else
297355acc8fcSmrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
2974d63fdb69Smrg	  fi
2975d63fdb69Smrg
2976d63fdb69Smrg	  func_warning "relinking \`$file'"
2977d63fdb69Smrg	  func_show_eval "$relink_command" \
2978d63fdb69Smrg	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2979d63fdb69Smrg	fi
2980d63fdb69Smrg
2981d63fdb69Smrg	# See the names of the shared library.
2982d63fdb69Smrg	set dummy $library_names; shift
2983d63fdb69Smrg	if test -n "$1"; then
2984d63fdb69Smrg	  realname="$1"
2985d63fdb69Smrg	  shift
2986d63fdb69Smrg
2987d63fdb69Smrg	  srcname="$realname"
2988d63fdb69Smrg	  test -n "$relink_command" && srcname="$realname"T
2989d63fdb69Smrg
2990d63fdb69Smrg	  # Install the shared library and build the symlinks.
299155acc8fcSmrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
2992d63fdb69Smrg	      'exit $?'
2993d63fdb69Smrg	  tstripme="$stripme"
2994d63fdb69Smrg	  case $host_os in
2995d63fdb69Smrg	  cygwin* | mingw* | pw32* | cegcc*)
2996d63fdb69Smrg	    case $realname in
2997d63fdb69Smrg	    *.dll.a)
2998d63fdb69Smrg	      tstripme=""
2999d63fdb69Smrg	      ;;
3000d63fdb69Smrg	    esac
30013da084b3Smrg	    ;;
30023da084b3Smrg	  esac
3003d63fdb69Smrg	  if test -n "$tstripme" && test -n "$striplib"; then
3004d63fdb69Smrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
30053da084b3Smrg	  fi
3006d63fdb69Smrg
3007d63fdb69Smrg	  if test "$#" -gt 0; then
3008d63fdb69Smrg	    # Delete the old symlinks, and create new ones.
3009d63fdb69Smrg	    # Try `ln -sf' first, because the `ln' binary might depend on
3010d63fdb69Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
3011d63fdb69Smrg	    # so we also need to try rm && ln -s.
3012d63fdb69Smrg	    for linkname
3013d63fdb69Smrg	    do
3014d63fdb69Smrg	      test "$linkname" != "$realname" \
3015d63fdb69Smrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
30163da084b3Smrg	    done
30173da084b3Smrg	  fi
30183da084b3Smrg
3019d63fdb69Smrg	  # Do each command in the postinstall commands.
3020d63fdb69Smrg	  lib="$destdir/$realname"
3021d63fdb69Smrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
30223da084b3Smrg	fi
30233da084b3Smrg
3024d63fdb69Smrg	# Install the pseudo-library for information purposes.
3025d63fdb69Smrg	func_basename "$file"
3026d63fdb69Smrg	name="$func_basename_result"
3027d63fdb69Smrg	instname="$dir/$name"i
3028d63fdb69Smrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
30293da084b3Smrg
3030d63fdb69Smrg	# Maybe install the static library, too.
303148c85eb7Smrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
3032d63fdb69Smrg	;;
30333da084b3Smrg
3034d63fdb69Smrg      *.lo)
3035d63fdb69Smrg	# Install (i.e. copy) a libtool object.
30363da084b3Smrg
3037d63fdb69Smrg	# Figure out destination file name, if it wasn't already specified.
3038d63fdb69Smrg	if test -n "$destname"; then
3039d63fdb69Smrg	  destfile="$destdir/$destname"
3040d63fdb69Smrg	else
3041d63fdb69Smrg	  func_basename "$file"
3042d63fdb69Smrg	  destfile="$func_basename_result"
3043d63fdb69Smrg	  destfile="$destdir/$destfile"
3044d63fdb69Smrg	fi
3045d63fdb69Smrg
3046d63fdb69Smrg	# Deduce the name of the destination old-style object file.
3047d63fdb69Smrg	case $destfile in
3048d63fdb69Smrg	*.lo)
3049d63fdb69Smrg	  func_lo2o "$destfile"
3050d63fdb69Smrg	  staticdest=$func_lo2o_result
3051d63fdb69Smrg	  ;;
3052d63fdb69Smrg	*.$objext)
3053d63fdb69Smrg	  staticdest="$destfile"
3054d63fdb69Smrg	  destfile=
3055d63fdb69Smrg	  ;;
3056d63fdb69Smrg	*)
3057d63fdb69Smrg	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
3058d63fdb69Smrg	  ;;
30593da084b3Smrg	esac
30603da084b3Smrg
3061d63fdb69Smrg	# Install the libtool object if requested.
3062d63fdb69Smrg	test -n "$destfile" && \
3063d63fdb69Smrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
3064d63fdb69Smrg
3065d63fdb69Smrg	# Install the old object if enabled.
3066d63fdb69Smrg	if test "$build_old_libs" = yes; then
3067d63fdb69Smrg	  # Deduce the name of the old-style object file.
3068d63fdb69Smrg	  func_lo2o "$file"
3069d63fdb69Smrg	  staticobj=$func_lo2o_result
3070d63fdb69Smrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
30713da084b3Smrg	fi
3072d63fdb69Smrg	exit $EXIT_SUCCESS
3073d63fdb69Smrg	;;
30743da084b3Smrg
3075d63fdb69Smrg      *)
3076d63fdb69Smrg	# Figure out destination file name, if it wasn't already specified.
3077d63fdb69Smrg	if test -n "$destname"; then
3078d63fdb69Smrg	  destfile="$destdir/$destname"
3079d63fdb69Smrg	else
3080d63fdb69Smrg	  func_basename "$file"
3081d63fdb69Smrg	  destfile="$func_basename_result"
3082d63fdb69Smrg	  destfile="$destdir/$destfile"
3083d63fdb69Smrg	fi
3084d63fdb69Smrg
3085d63fdb69Smrg	# If the file is missing, and there is a .exe on the end, strip it
3086d63fdb69Smrg	# because it is most likely a libtool script we actually want to
3087d63fdb69Smrg	# install
3088d63fdb69Smrg	stripped_ext=""
3089d63fdb69Smrg	case $file in
3090d63fdb69Smrg	  *.exe)
3091d63fdb69Smrg	    if test ! -f "$file"; then
3092d63fdb69Smrg	      func_stripname '' '.exe' "$file"
3093d63fdb69Smrg	      file=$func_stripname_result
3094d63fdb69Smrg	      stripped_ext=".exe"
30953da084b3Smrg	    fi
3096d63fdb69Smrg	    ;;
3097d63fdb69Smrg	esac
30983da084b3Smrg
3099d63fdb69Smrg	# Do a test to see if this is really a libtool program.
3100d63fdb69Smrg	case $host in
3101d63fdb69Smrg	*cygwin* | *mingw*)
3102d63fdb69Smrg	    if func_ltwrapper_executable_p "$file"; then
3103d63fdb69Smrg	      func_ltwrapper_scriptname "$file"
3104d63fdb69Smrg	      wrapper=$func_ltwrapper_scriptname_result
3105d63fdb69Smrg	    else
3106d63fdb69Smrg	      func_stripname '' '.exe' "$file"
3107d63fdb69Smrg	      wrapper=$func_stripname_result
3108d63fdb69Smrg	    fi
3109d63fdb69Smrg	    ;;
3110d63fdb69Smrg	*)
3111d63fdb69Smrg	    wrapper=$file
3112d63fdb69Smrg	    ;;
3113d63fdb69Smrg	esac
3114d63fdb69Smrg	if func_ltwrapper_script_p "$wrapper"; then
3115d63fdb69Smrg	  notinst_deplibs=
3116d63fdb69Smrg	  relink_command=
31173da084b3Smrg
3118d63fdb69Smrg	  func_source "$wrapper"
31193da084b3Smrg
3120d63fdb69Smrg	  # Check the variables that should have been set.
3121d63fdb69Smrg	  test -z "$generated_by_libtool_version" && \
3122d63fdb69Smrg	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
3123d63fdb69Smrg
3124d63fdb69Smrg	  finalize=yes
3125d63fdb69Smrg	  for lib in $notinst_deplibs; do
3126d63fdb69Smrg	    # Check to see that each library is installed.
3127d63fdb69Smrg	    libdir=
3128d63fdb69Smrg	    if test -f "$lib"; then
3129d63fdb69Smrg	      func_source "$lib"
3130d63fdb69Smrg	    fi
313155acc8fcSmrg	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
3132d63fdb69Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
3133d63fdb69Smrg	      func_warning "\`$lib' has not been installed in \`$libdir'"
3134d63fdb69Smrg	      finalize=no
3135d63fdb69Smrg	    fi
3136d63fdb69Smrg	  done
3137d63fdb69Smrg
3138d63fdb69Smrg	  relink_command=
3139d63fdb69Smrg	  func_source "$wrapper"
3140d63fdb69Smrg
3141d63fdb69Smrg	  outputname=
3142d63fdb69Smrg	  if test "$fast_install" = no && test -n "$relink_command"; then
3143d63fdb69Smrg	    $opt_dry_run || {
3144d63fdb69Smrg	      if test "$finalize" = yes; then
3145d63fdb69Smrg	        tmpdir=`func_mktempdir`
3146d63fdb69Smrg		func_basename "$file$stripped_ext"
3147d63fdb69Smrg		file="$func_basename_result"
3148d63fdb69Smrg	        outputname="$tmpdir/$file"
3149d63fdb69Smrg	        # Replace the output file specification.
315055acc8fcSmrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
3151d63fdb69Smrg
3152d63fdb69Smrg	        $opt_silent || {
3153d63fdb69Smrg	          func_quote_for_expand "$relink_command"
3154d63fdb69Smrg		  eval "func_echo $func_quote_for_expand_result"
3155d63fdb69Smrg	        }
3156d63fdb69Smrg	        if eval "$relink_command"; then :
3157d63fdb69Smrg	          else
3158d63fdb69Smrg		  func_error "error: relink \`$file' with the above command before installing it"
3159d63fdb69Smrg		  $opt_dry_run || ${RM}r "$tmpdir"
3160d63fdb69Smrg		  continue
3161d63fdb69Smrg	        fi
3162d63fdb69Smrg	        file="$outputname"
3163d63fdb69Smrg	      else
3164d63fdb69Smrg	        func_warning "cannot relink \`$file'"
3165d63fdb69Smrg	      fi
3166d63fdb69Smrg	    }
31673da084b3Smrg	  else
3168d63fdb69Smrg	    # Install the binary that we compiled earlier.
316955acc8fcSmrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
31703da084b3Smrg	  fi
3171d63fdb69Smrg	fi
31723da084b3Smrg
3173d63fdb69Smrg	# remove .exe since cygwin /usr/bin/install will append another
3174d63fdb69Smrg	# one anyway
3175d63fdb69Smrg	case $install_prog,$host in
3176d63fdb69Smrg	*/usr/bin/install*,*cygwin*)
3177d63fdb69Smrg	  case $file:$destfile in
3178d63fdb69Smrg	  *.exe:*.exe)
3179d63fdb69Smrg	    # this is ok
3180d63fdb69Smrg	    ;;
3181d63fdb69Smrg	  *.exe:*)
3182d63fdb69Smrg	    destfile=$destfile.exe
3183d63fdb69Smrg	    ;;
3184d63fdb69Smrg	  *:*.exe)
3185d63fdb69Smrg	    func_stripname '' '.exe' "$destfile"
3186d63fdb69Smrg	    destfile=$func_stripname_result
3187d63fdb69Smrg	    ;;
3188d63fdb69Smrg	  esac
31893da084b3Smrg	  ;;
31903da084b3Smrg	esac
3191d63fdb69Smrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
3192d63fdb69Smrg	$opt_dry_run || if test -n "$outputname"; then
3193d63fdb69Smrg	  ${RM}r "$tmpdir"
3194d63fdb69Smrg	fi
3195d63fdb69Smrg	;;
3196d63fdb69Smrg      esac
3197d63fdb69Smrg    done
31983da084b3Smrg
3199d63fdb69Smrg    for file in $staticlibs; do
3200d63fdb69Smrg      func_basename "$file"
3201d63fdb69Smrg      name="$func_basename_result"
32023da084b3Smrg
3203d63fdb69Smrg      # Set up the ranlib parameters.
3204d63fdb69Smrg      oldlib="$destdir/$name"
320548c85eb7Smrg      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
320648c85eb7Smrg      tool_oldlib=$func_to_tool_file_result
32073da084b3Smrg
3208d63fdb69Smrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
32093da084b3Smrg
3210d63fdb69Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
321148c85eb7Smrg	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
3212d63fdb69Smrg      fi
32133da084b3Smrg
3214d63fdb69Smrg      # Do each command in the postinstall commands.
3215d63fdb69Smrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
3216d63fdb69Smrg    done
32173da084b3Smrg
3218d63fdb69Smrg    test -n "$future_libdirs" && \
3219d63fdb69Smrg      func_warning "remember to run \`$progname --finish$future_libdirs'"
32203da084b3Smrg
3221d63fdb69Smrg    if test -n "$current_libdirs"; then
3222d63fdb69Smrg      # Maybe just do a dry run.
3223d63fdb69Smrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
3224d63fdb69Smrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
3225d63fdb69Smrg    else
3226d63fdb69Smrg      exit $EXIT_SUCCESS
3227d63fdb69Smrg    fi
3228d63fdb69Smrg}
32293da084b3Smrg
323048c85eb7Smrgtest "$opt_mode" = install && func_mode_install ${1+"$@"}
32313da084b3Smrg
32323da084b3Smrg
3233d63fdb69Smrg# func_generate_dlsyms outputname originator pic_p
3234d63fdb69Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with
3235d63fdb69Smrg# a dlpreopen symbol table.
3236d63fdb69Smrgfunc_generate_dlsyms ()
3237d63fdb69Smrg{
3238d63fdb69Smrg    $opt_debug
3239d63fdb69Smrg    my_outputname="$1"
3240d63fdb69Smrg    my_originator="$2"
3241d63fdb69Smrg    my_pic_p="${3-no}"
3242d63fdb69Smrg    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
3243d63fdb69Smrg    my_dlsyms=
3244d63fdb69Smrg
3245d63fdb69Smrg    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
3246d63fdb69Smrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
3247d63fdb69Smrg	my_dlsyms="${my_outputname}S.c"
3248d63fdb69Smrg      else
3249d63fdb69Smrg	func_error "not configured to extract global symbols from dlpreopened files"
3250d63fdb69Smrg      fi
3251d63fdb69Smrg    fi
32523da084b3Smrg
3253d63fdb69Smrg    if test -n "$my_dlsyms"; then
3254d63fdb69Smrg      case $my_dlsyms in
3255d63fdb69Smrg      "") ;;
3256d63fdb69Smrg      *.c)
3257d63fdb69Smrg	# Discover the nlist of each of the dlfiles.
3258d63fdb69Smrg	nlist="$output_objdir/${my_outputname}.nm"
3259d63fdb69Smrg
3260d63fdb69Smrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
3261d63fdb69Smrg
3262d63fdb69Smrg	# Parse the name list into a source file.
3263d63fdb69Smrg	func_verbose "creating $output_objdir/$my_dlsyms"
3264d63fdb69Smrg
3265d63fdb69Smrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
3266d63fdb69Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
3267d63fdb69Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
3268d63fdb69Smrg
3269d63fdb69Smrg#ifdef __cplusplus
3270d63fdb69Smrgextern \"C\" {
3271d63fdb69Smrg#endif
3272d63fdb69Smrg
327355acc8fcSmrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
327455acc8fcSmrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
327555acc8fcSmrg#endif
327655acc8fcSmrg
327748c85eb7Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
327848c85eb7Smrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
327948c85eb7Smrg/* DATA imports from DLLs on WIN32 con't be const, because runtime
328048c85eb7Smrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
328148c85eb7Smrg# define LT_DLSYM_CONST
328248c85eb7Smrg#elif defined(__osf__)
328348c85eb7Smrg/* This system does not cope well with relocations in const data.  */
328448c85eb7Smrg# define LT_DLSYM_CONST
328548c85eb7Smrg#else
328648c85eb7Smrg# define LT_DLSYM_CONST const
328748c85eb7Smrg#endif
328848c85eb7Smrg
3289d63fdb69Smrg/* External symbol declarations for the compiler. */\
3290d63fdb69Smrg"
3291d63fdb69Smrg
3292d63fdb69Smrg	if test "$dlself" = yes; then
3293d63fdb69Smrg	  func_verbose "generating symbol list for \`$output'"
3294d63fdb69Smrg
3295d63fdb69Smrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
3296d63fdb69Smrg
3297d63fdb69Smrg	  # Add our own program objects to the symbol list.
329855acc8fcSmrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
3299d63fdb69Smrg	  for progfile in $progfiles; do
330048c85eb7Smrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
330148c85eb7Smrg	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
330248c85eb7Smrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
3303d63fdb69Smrg	  done
3304d63fdb69Smrg
3305d63fdb69Smrg	  if test -n "$exclude_expsyms"; then
3306d63fdb69Smrg	    $opt_dry_run || {
3307d63fdb69Smrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
3308d63fdb69Smrg	      eval '$MV "$nlist"T "$nlist"'
3309d63fdb69Smrg	    }
33103da084b3Smrg	  fi
33113da084b3Smrg
3312d63fdb69Smrg	  if test -n "$export_symbols_regex"; then
3313d63fdb69Smrg	    $opt_dry_run || {
3314d63fdb69Smrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
3315d63fdb69Smrg	      eval '$MV "$nlist"T "$nlist"'
3316d63fdb69Smrg	    }
33173da084b3Smrg	  fi
3318d63fdb69Smrg
3319d63fdb69Smrg	  # Prepare the list of exported symbols
3320d63fdb69Smrg	  if test -z "$export_symbols"; then
3321d63fdb69Smrg	    export_symbols="$output_objdir/$outputname.exp"
3322d63fdb69Smrg	    $opt_dry_run || {
3323d63fdb69Smrg	      $RM $export_symbols
3324d63fdb69Smrg	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
3325d63fdb69Smrg	      case $host in
3326d63fdb69Smrg	      *cygwin* | *mingw* | *cegcc* )
3327d63fdb69Smrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3328d63fdb69Smrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
3329d63fdb69Smrg	        ;;
33303da084b3Smrg	      esac
3331d63fdb69Smrg	    }
3332d63fdb69Smrg	  else
3333d63fdb69Smrg	    $opt_dry_run || {
3334d63fdb69Smrg	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
3335d63fdb69Smrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
3336d63fdb69Smrg	      eval '$MV "$nlist"T "$nlist"'
3337d63fdb69Smrg	      case $host in
333855acc8fcSmrg	        *cygwin* | *mingw* | *cegcc* )
3339d63fdb69Smrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3340d63fdb69Smrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
3341d63fdb69Smrg	          ;;
33423da084b3Smrg	      esac
3343d63fdb69Smrg	    }
33443da084b3Smrg	  fi
3345d63fdb69Smrg	fi
33463da084b3Smrg
3347d63fdb69Smrg	for dlprefile in $dlprefiles; do
3348d63fdb69Smrg	  func_verbose "extracting global C symbols from \`$dlprefile'"
3349d63fdb69Smrg	  func_basename "$dlprefile"
3350d63fdb69Smrg	  name="$func_basename_result"
335148c85eb7Smrg          case $host in
335248c85eb7Smrg	    *cygwin* | *mingw* | *cegcc* )
335348c85eb7Smrg	      # if an import library, we need to obtain dlname
335448c85eb7Smrg	      if func_win32_import_lib_p "$dlprefile"; then
335548c85eb7Smrg	        func_tr_sh "$dlprefile"
335648c85eb7Smrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
335748c85eb7Smrg	        dlprefile_dlbasename=""
335848c85eb7Smrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
335948c85eb7Smrg	          # Use subshell, to avoid clobbering current variable values
336048c85eb7Smrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
336148c85eb7Smrg	          if test -n "$dlprefile_dlname" ; then
336248c85eb7Smrg	            func_basename "$dlprefile_dlname"
336348c85eb7Smrg	            dlprefile_dlbasename="$func_basename_result"
336448c85eb7Smrg	          else
336548c85eb7Smrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
336648c85eb7Smrg	            $sharedlib_from_linklib_cmd "$dlprefile"
336748c85eb7Smrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
336848c85eb7Smrg	          fi
336948c85eb7Smrg	        fi
337048c85eb7Smrg	        $opt_dry_run || {
337148c85eb7Smrg	          if test -n "$dlprefile_dlbasename" ; then
337248c85eb7Smrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
337348c85eb7Smrg	          else
337448c85eb7Smrg	            func_warning "Could not compute DLL name from $name"
337548c85eb7Smrg	            eval '$ECHO ": $name " >> "$nlist"'
337648c85eb7Smrg	          fi
337748c85eb7Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
337848c85eb7Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
337948c85eb7Smrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
338048c85eb7Smrg	        }
338148c85eb7Smrg	      else # not an import lib
338248c85eb7Smrg	        $opt_dry_run || {
338348c85eb7Smrg	          eval '$ECHO ": $name " >> "$nlist"'
338448c85eb7Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
338548c85eb7Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
338648c85eb7Smrg	        }
338748c85eb7Smrg	      fi
338848c85eb7Smrg	    ;;
338948c85eb7Smrg	    *)
339048c85eb7Smrg	      $opt_dry_run || {
339148c85eb7Smrg	        eval '$ECHO ": $name " >> "$nlist"'
339248c85eb7Smrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
339348c85eb7Smrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
339448c85eb7Smrg	      }
339548c85eb7Smrg	    ;;
339648c85eb7Smrg          esac
3397d63fdb69Smrg	done
33983da084b3Smrg
3399d63fdb69Smrg	$opt_dry_run || {
3400d63fdb69Smrg	  # Make sure we have at least an empty file.
3401d63fdb69Smrg	  test -f "$nlist" || : > "$nlist"
34023da084b3Smrg
3403d63fdb69Smrg	  if test -n "$exclude_expsyms"; then
3404d63fdb69Smrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
3405d63fdb69Smrg	    $MV "$nlist"T "$nlist"
34063da084b3Smrg	  fi
34073da084b3Smrg
3408d63fdb69Smrg	  # Try sorting and uniquifying the output.
3409d63fdb69Smrg	  if $GREP -v "^: " < "$nlist" |
3410d63fdb69Smrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
3411d63fdb69Smrg		sort -k 3
34123da084b3Smrg	      else
3413d63fdb69Smrg		sort +2
3414d63fdb69Smrg	      fi |
3415d63fdb69Smrg	      uniq > "$nlist"S; then
3416d63fdb69Smrg	    :
34173da084b3Smrg	  else
3418d63fdb69Smrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
34193da084b3Smrg	  fi
34203da084b3Smrg
3421d63fdb69Smrg	  if test -f "$nlist"S; then
3422d63fdb69Smrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
34233da084b3Smrg	  else
342455acc8fcSmrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
34253da084b3Smrg	  fi
34263da084b3Smrg
342755acc8fcSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
34283da084b3Smrg
3429d63fdb69Smrg/* The mapping between symbol names and symbols.  */
3430d63fdb69Smrgtypedef struct {
3431d63fdb69Smrg  const char *name;
3432d63fdb69Smrg  void *address;
3433d63fdb69Smrg} lt_dlsymlist;
343448c85eb7Smrgextern LT_DLSYM_CONST lt_dlsymlist
3435d63fdb69Smrglt_${my_prefix}_LTX_preloaded_symbols[];
343648c85eb7SmrgLT_DLSYM_CONST lt_dlsymlist
3437d63fdb69Smrglt_${my_prefix}_LTX_preloaded_symbols[] =
3438d63fdb69Smrg{\
3439d63fdb69Smrg  { \"$my_originator\", (void *) 0 },"
3440d63fdb69Smrg
3441d63fdb69Smrg	  case $need_lib_prefix in
3442d63fdb69Smrg	  no)
3443d63fdb69Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
3444d63fdb69Smrg	    ;;
3445d63fdb69Smrg	  *)
3446d63fdb69Smrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
3447d63fdb69Smrg	    ;;
3448d63fdb69Smrg	  esac
344955acc8fcSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
3450d63fdb69Smrg  {0, (void *) 0}
3451d63fdb69Smrg};
3452d63fdb69Smrg
3453d63fdb69Smrg/* This works around a problem in FreeBSD linker */
3454d63fdb69Smrg#ifdef FREEBSD_WORKAROUND
3455d63fdb69Smrgstatic const void *lt_preloaded_setup() {
3456d63fdb69Smrg  return lt_${my_prefix}_LTX_preloaded_symbols;
3457d63fdb69Smrg}
3458d63fdb69Smrg#endif
3459d63fdb69Smrg
3460d63fdb69Smrg#ifdef __cplusplus
3461d63fdb69Smrg}
3462d63fdb69Smrg#endif\
3463d63fdb69Smrg"
3464d63fdb69Smrg	} # !$opt_dry_run
3465d63fdb69Smrg
3466d63fdb69Smrg	pic_flag_for_symtable=
3467d63fdb69Smrg	case "$compile_command " in
3468d63fdb69Smrg	*" -static "*) ;;
3469d63fdb69Smrg	*)
3470d63fdb69Smrg	  case $host in
3471d63fdb69Smrg	  # compiling the symbol table file with pic_flag works around
3472d63fdb69Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
3473d63fdb69Smrg	  # linked before any other PIC object.  But we must not use
3474d63fdb69Smrg	  # pic_flag when linking with -static.  The problem exists in
3475d63fdb69Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
347648c85eb7Smrg	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
3477d63fdb69Smrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
3478d63fdb69Smrg	  *-*-hpux*)
3479d63fdb69Smrg	    pic_flag_for_symtable=" $pic_flag"  ;;
3480d63fdb69Smrg	  *)
3481d63fdb69Smrg	    if test "X$my_pic_p" != Xno; then
3482d63fdb69Smrg	      pic_flag_for_symtable=" $pic_flag"
34833da084b3Smrg	    fi
3484d63fdb69Smrg	    ;;
3485d63fdb69Smrg	  esac
3486d63fdb69Smrg	  ;;
3487d63fdb69Smrg	esac
3488d63fdb69Smrg	symtab_cflags=
3489d63fdb69Smrg	for arg in $LTCFLAGS; do
3490d63fdb69Smrg	  case $arg in
3491d63fdb69Smrg	  -pie | -fpie | -fPIE) ;;
349248c85eb7Smrg	  *) func_append symtab_cflags " $arg" ;;
3493d63fdb69Smrg	  esac
3494d63fdb69Smrg	done
34953da084b3Smrg
3496d63fdb69Smrg	# Now compile the dynamic symbol file.
3497d63fdb69Smrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
34983da084b3Smrg
3499d63fdb69Smrg	# Clean up the generated files.
3500d63fdb69Smrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
3501d63fdb69Smrg
3502d63fdb69Smrg	# Transform the symbol file into the correct name.
3503d63fdb69Smrg	symfileobj="$output_objdir/${my_outputname}S.$objext"
3504d63fdb69Smrg	case $host in
3505d63fdb69Smrg	*cygwin* | *mingw* | *cegcc* )
3506d63fdb69Smrg	  if test -f "$output_objdir/$my_outputname.def"; then
350755acc8fcSmrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
350855acc8fcSmrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3509d63fdb69Smrg	  else
351055acc8fcSmrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
351155acc8fcSmrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3512d63fdb69Smrg	  fi
3513d63fdb69Smrg	  ;;
3514d63fdb69Smrg	*)
351555acc8fcSmrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
351655acc8fcSmrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
35173da084b3Smrg	  ;;
35183da084b3Smrg	esac
3519d63fdb69Smrg	;;
3520d63fdb69Smrg      *)
3521d63fdb69Smrg	func_fatal_error "unknown suffix for \`$my_dlsyms'"
3522d63fdb69Smrg	;;
3523d63fdb69Smrg      esac
3524d63fdb69Smrg    else
3525d63fdb69Smrg      # We keep going just in case the user didn't refer to
3526d63fdb69Smrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
3527d63fdb69Smrg      # really was required.
3528d63fdb69Smrg
3529d63fdb69Smrg      # Nullify the symbol file.
353055acc8fcSmrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
353155acc8fcSmrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
35323da084b3Smrg    fi
3533d63fdb69Smrg}
35343da084b3Smrg
3535d63fdb69Smrg# func_win32_libid arg
3536d63fdb69Smrg# return the library type of file 'arg'
3537d63fdb69Smrg#
3538d63fdb69Smrg# Need a lot of goo to handle *both* DLLs and import libs
3539d63fdb69Smrg# Has to be a shell function in order to 'eat' the argument
3540d63fdb69Smrg# that is supplied when $file_magic_command is called.
354155acc8fcSmrg# Despite the name, also deal with 64 bit binaries.
3542d63fdb69Smrgfunc_win32_libid ()
3543d63fdb69Smrg{
3544d63fdb69Smrg  $opt_debug
3545d63fdb69Smrg  win32_libid_type="unknown"
3546d63fdb69Smrg  win32_fileres=`file -L $1 2>/dev/null`
3547d63fdb69Smrg  case $win32_fileres in
3548d63fdb69Smrg  *ar\ archive\ import\ library*) # definitely import
3549d63fdb69Smrg    win32_libid_type="x86 archive import"
3550d63fdb69Smrg    ;;
3551d63fdb69Smrg  *ar\ archive*) # could be an import, or static
355255acc8fcSmrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
3553d63fdb69Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
355455acc8fcSmrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
355548c85eb7Smrg      func_to_tool_file "$1" func_convert_file_msys_to_w32
355648c85eb7Smrg      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
3557d63fdb69Smrg	$SED -n -e '
3558d63fdb69Smrg	    1,100{
3559d63fdb69Smrg		/ I /{
3560d63fdb69Smrg		    s,.*,import,
3561d63fdb69Smrg		    p
3562d63fdb69Smrg		    q
3563d63fdb69Smrg		}
3564d63fdb69Smrg	    }'`
3565d63fdb69Smrg      case $win32_nmres in
3566d63fdb69Smrg      import*)  win32_libid_type="x86 archive import";;
3567d63fdb69Smrg      *)        win32_libid_type="x86 archive static";;
3568d63fdb69Smrg      esac
3569d63fdb69Smrg    fi
3570d63fdb69Smrg    ;;
3571d63fdb69Smrg  *DLL*)
3572d63fdb69Smrg    win32_libid_type="x86 DLL"
3573d63fdb69Smrg    ;;
3574d63fdb69Smrg  *executable*) # but shell scripts are "executable" too...
3575d63fdb69Smrg    case $win32_fileres in
3576d63fdb69Smrg    *MS\ Windows\ PE\ Intel*)
3577d63fdb69Smrg      win32_libid_type="x86 DLL"
3578d63fdb69Smrg      ;;
3579d63fdb69Smrg    esac
3580d63fdb69Smrg    ;;
3581d63fdb69Smrg  esac
3582d63fdb69Smrg  $ECHO "$win32_libid_type"
3583d63fdb69Smrg}
35843da084b3Smrg
358548c85eb7Smrg# func_cygming_dll_for_implib ARG
358648c85eb7Smrg#
358748c85eb7Smrg# Platform-specific function to extract the
358848c85eb7Smrg# name of the DLL associated with the specified
358948c85eb7Smrg# import library ARG.
359048c85eb7Smrg# Invoked by eval'ing the libtool variable
359148c85eb7Smrg#    $sharedlib_from_linklib_cmd
359248c85eb7Smrg# Result is available in the variable
359348c85eb7Smrg#    $sharedlib_from_linklib_result
359448c85eb7Smrgfunc_cygming_dll_for_implib ()
359548c85eb7Smrg{
359648c85eb7Smrg  $opt_debug
359748c85eb7Smrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
359848c85eb7Smrg}
359948c85eb7Smrg
360048c85eb7Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
360148c85eb7Smrg#
360248c85eb7Smrg# The is the core of a fallback implementation of a
360348c85eb7Smrg# platform-specific function to extract the name of the
360448c85eb7Smrg# DLL associated with the specified import library LIBNAME.
360548c85eb7Smrg#
360648c85eb7Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending
360748c85eb7Smrg# on the platform and compiler that created the implib.
360848c85eb7Smrg#
360948c85eb7Smrg# Echos the name of the DLL associated with the
361048c85eb7Smrg# specified import library.
361148c85eb7Smrgfunc_cygming_dll_for_implib_fallback_core ()
361248c85eb7Smrg{
361348c85eb7Smrg  $opt_debug
361448c85eb7Smrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
361548c85eb7Smrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
361648c85eb7Smrg    $SED '/^Contents of section '"$match_literal"':/{
361748c85eb7Smrg      # Place marker at beginning of archive member dllname section
361848c85eb7Smrg      s/.*/====MARK====/
361948c85eb7Smrg      p
362048c85eb7Smrg      d
362148c85eb7Smrg    }
362248c85eb7Smrg    # These lines can sometimes be longer than 43 characters, but
362348c85eb7Smrg    # are always uninteresting
362448c85eb7Smrg    /:[	 ]*file format pe[i]\{,1\}-/d
362548c85eb7Smrg    /^In archive [^:]*:/d
362648c85eb7Smrg    # Ensure marker is printed
362748c85eb7Smrg    /^====MARK====/p
362848c85eb7Smrg    # Remove all lines with less than 43 characters
362948c85eb7Smrg    /^.\{43\}/!d
363048c85eb7Smrg    # From remaining lines, remove first 43 characters
363148c85eb7Smrg    s/^.\{43\}//' |
363248c85eb7Smrg    $SED -n '
363348c85eb7Smrg      # Join marker and all lines until next marker into a single line
363448c85eb7Smrg      /^====MARK====/ b para
363548c85eb7Smrg      H
363648c85eb7Smrg      $ b para
363748c85eb7Smrg      b
363848c85eb7Smrg      :para
363948c85eb7Smrg      x
364048c85eb7Smrg      s/\n//g
364148c85eb7Smrg      # Remove the marker
364248c85eb7Smrg      s/^====MARK====//
364348c85eb7Smrg      # Remove trailing dots and whitespace
364448c85eb7Smrg      s/[\. \t]*$//
364548c85eb7Smrg      # Print
364648c85eb7Smrg      /./p' |
364748c85eb7Smrg    # we now have a list, one entry per line, of the stringified
364848c85eb7Smrg    # contents of the appropriate section of all members of the
364948c85eb7Smrg    # archive which possess that section. Heuristic: eliminate
365048c85eb7Smrg    # all those which have a first or second character that is
365148c85eb7Smrg    # a '.' (that is, objdump's representation of an unprintable
365248c85eb7Smrg    # character.) This should work for all archives with less than
365348c85eb7Smrg    # 0x302f exports -- but will fail for DLLs whose name actually
365448c85eb7Smrg    # begins with a literal '.' or a single character followed by
365548c85eb7Smrg    # a '.'.
365648c85eb7Smrg    #
365748c85eb7Smrg    # Of those that remain, print the first one.
365848c85eb7Smrg    $SED -e '/^\./d;/^.\./d;q'
365948c85eb7Smrg}
366048c85eb7Smrg
366148c85eb7Smrg# func_cygming_gnu_implib_p ARG
366248c85eb7Smrg# This predicate returns with zero status (TRUE) if
366348c85eb7Smrg# ARG is a GNU/binutils-style import library. Returns
366448c85eb7Smrg# with nonzero status (FALSE) otherwise.
366548c85eb7Smrgfunc_cygming_gnu_implib_p ()
366648c85eb7Smrg{
366748c85eb7Smrg  $opt_debug
366848c85eb7Smrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
366948c85eb7Smrg  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)$'`
367048c85eb7Smrg  test -n "$func_cygming_gnu_implib_tmp"
367148c85eb7Smrg}
367248c85eb7Smrg
367348c85eb7Smrg# func_cygming_ms_implib_p ARG
367448c85eb7Smrg# This predicate returns with zero status (TRUE) if
367548c85eb7Smrg# ARG is an MS-style import library. Returns
367648c85eb7Smrg# with nonzero status (FALSE) otherwise.
367748c85eb7Smrgfunc_cygming_ms_implib_p ()
367848c85eb7Smrg{
367948c85eb7Smrg  $opt_debug
368048c85eb7Smrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
368148c85eb7Smrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
368248c85eb7Smrg  test -n "$func_cygming_ms_implib_tmp"
368348c85eb7Smrg}
368448c85eb7Smrg
368548c85eb7Smrg# func_cygming_dll_for_implib_fallback ARG
368648c85eb7Smrg# Platform-specific function to extract the
368748c85eb7Smrg# name of the DLL associated with the specified
368848c85eb7Smrg# import library ARG.
368948c85eb7Smrg#
369048c85eb7Smrg# This fallback implementation is for use when $DLLTOOL
369148c85eb7Smrg# does not support the --identify-strict option.
369248c85eb7Smrg# Invoked by eval'ing the libtool variable
369348c85eb7Smrg#    $sharedlib_from_linklib_cmd
369448c85eb7Smrg# Result is available in the variable
369548c85eb7Smrg#    $sharedlib_from_linklib_result
369648c85eb7Smrgfunc_cygming_dll_for_implib_fallback ()
369748c85eb7Smrg{
369848c85eb7Smrg  $opt_debug
369948c85eb7Smrg  if func_cygming_gnu_implib_p "$1" ; then
370048c85eb7Smrg    # binutils import library
370148c85eb7Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
370248c85eb7Smrg  elif func_cygming_ms_implib_p "$1" ; then
370348c85eb7Smrg    # ms-generated import library
370448c85eb7Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
370548c85eb7Smrg  else
370648c85eb7Smrg    # unknown
370748c85eb7Smrg    sharedlib_from_linklib_result=""
370848c85eb7Smrg  fi
370948c85eb7Smrg}
37103da084b3Smrg
37113da084b3Smrg
3712d63fdb69Smrg# func_extract_an_archive dir oldlib
3713d63fdb69Smrgfunc_extract_an_archive ()
3714d63fdb69Smrg{
3715d63fdb69Smrg    $opt_debug
3716d63fdb69Smrg    f_ex_an_ar_dir="$1"; shift
3717d63fdb69Smrg    f_ex_an_ar_oldlib="$1"
371855acc8fcSmrg    if test "$lock_old_archive_extraction" = yes; then
371955acc8fcSmrg      lockfile=$f_ex_an_ar_oldlib.lock
372055acc8fcSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
372155acc8fcSmrg	func_echo "Waiting for $lockfile to be removed"
372255acc8fcSmrg	sleep 2
372355acc8fcSmrg      done
372455acc8fcSmrg    fi
372555acc8fcSmrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
372655acc8fcSmrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
372755acc8fcSmrg    if test "$lock_old_archive_extraction" = yes; then
372855acc8fcSmrg      $opt_dry_run || rm -f "$lockfile"
372955acc8fcSmrg    fi
3730d63fdb69Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
3731d63fdb69Smrg     :
3732d63fdb69Smrg    else
3733d63fdb69Smrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
3734d63fdb69Smrg    fi
3735d63fdb69Smrg}
37363da084b3Smrg
37373da084b3Smrg
3738d63fdb69Smrg# func_extract_archives gentop oldlib ...
3739d63fdb69Smrgfunc_extract_archives ()
3740d63fdb69Smrg{
3741d63fdb69Smrg    $opt_debug
3742d63fdb69Smrg    my_gentop="$1"; shift
3743d63fdb69Smrg    my_oldlibs=${1+"$@"}
3744d63fdb69Smrg    my_oldobjs=""
3745d63fdb69Smrg    my_xlib=""
3746d63fdb69Smrg    my_xabs=""
3747d63fdb69Smrg    my_xdir=""
37483da084b3Smrg
3749d63fdb69Smrg    for my_xlib in $my_oldlibs; do
3750d63fdb69Smrg      # Extract the objects.
3751d63fdb69Smrg      case $my_xlib in
3752d63fdb69Smrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
3753d63fdb69Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
3754d63fdb69Smrg      esac
3755d63fdb69Smrg      func_basename "$my_xlib"
3756d63fdb69Smrg      my_xlib="$func_basename_result"
3757d63fdb69Smrg      my_xlib_u=$my_xlib
3758d63fdb69Smrg      while :; do
3759d63fdb69Smrg        case " $extracted_archives " in
3760d63fdb69Smrg	*" $my_xlib_u "*)
3761d63fdb69Smrg	  func_arith $extracted_serial + 1
3762d63fdb69Smrg	  extracted_serial=$func_arith_result
3763d63fdb69Smrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
3764d63fdb69Smrg	*) break ;;
3765d63fdb69Smrg	esac
3766d63fdb69Smrg      done
3767d63fdb69Smrg      extracted_archives="$extracted_archives $my_xlib_u"
3768d63fdb69Smrg      my_xdir="$my_gentop/$my_xlib_u"
37693da084b3Smrg
3770d63fdb69Smrg      func_mkdir_p "$my_xdir"
37713da084b3Smrg
3772d63fdb69Smrg      case $host in
3773d63fdb69Smrg      *-darwin*)
3774d63fdb69Smrg	func_verbose "Extracting $my_xabs"
3775d63fdb69Smrg	# Do not bother doing anything if just a dry run
3776d63fdb69Smrg	$opt_dry_run || {
3777d63fdb69Smrg	  darwin_orig_dir=`pwd`
3778d63fdb69Smrg	  cd $my_xdir || exit $?
3779d63fdb69Smrg	  darwin_archive=$my_xabs
3780d63fdb69Smrg	  darwin_curdir=`pwd`
3781d63fdb69Smrg	  darwin_base_archive=`basename "$darwin_archive"`
3782d63fdb69Smrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
3783d63fdb69Smrg	  if test -n "$darwin_arches"; then
3784d63fdb69Smrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
3785d63fdb69Smrg	    darwin_arch=
3786d63fdb69Smrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
3787d63fdb69Smrg	    for darwin_arch in  $darwin_arches ; do
3788d63fdb69Smrg	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3789d63fdb69Smrg	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
3790d63fdb69Smrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3791d63fdb69Smrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
3792d63fdb69Smrg	      cd "$darwin_curdir"
3793d63fdb69Smrg	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
3794d63fdb69Smrg	    done # $darwin_arches
3795d63fdb69Smrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
3796d63fdb69Smrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
3797d63fdb69Smrg	    darwin_file=
3798d63fdb69Smrg	    darwin_files=
3799d63fdb69Smrg	    for darwin_file in $darwin_filelist; do
380055acc8fcSmrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
3801d63fdb69Smrg	      $LIPO -create -output "$darwin_file" $darwin_files
3802d63fdb69Smrg	    done # $darwin_filelist
3803d63fdb69Smrg	    $RM -rf unfat-$$
3804d63fdb69Smrg	    cd "$darwin_orig_dir"
3805d63fdb69Smrg	  else
3806d63fdb69Smrg	    cd $darwin_orig_dir
3807d63fdb69Smrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
3808d63fdb69Smrg	  fi # $darwin_arches
3809d63fdb69Smrg	} # !$opt_dry_run
3810d63fdb69Smrg	;;
3811d63fdb69Smrg      *)
3812d63fdb69Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
3813d63fdb69Smrg	;;
38143da084b3Smrg      esac
381555acc8fcSmrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
3816d63fdb69Smrg    done
38173da084b3Smrg
3818d63fdb69Smrg    func_extract_archives_result="$my_oldobjs"
3819d63fdb69Smrg}
38203da084b3Smrg
38213da084b3Smrg
382255acc8fcSmrg# func_emit_wrapper [arg=no]
382355acc8fcSmrg#
382455acc8fcSmrg# Emit a libtool wrapper script on stdout.
382555acc8fcSmrg# Don't directly open a file because we may want to
382655acc8fcSmrg# incorporate the script contents within a cygwin/mingw
382755acc8fcSmrg# wrapper executable.  Must ONLY be called from within
382855acc8fcSmrg# func_mode_link because it depends on a number of variables
382955acc8fcSmrg# set therein.
3830d63fdb69Smrg#
383155acc8fcSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
383255acc8fcSmrg# variable will take.  If 'yes', then the emitted script
383355acc8fcSmrg# will assume that the directory in which it is stored is
383455acc8fcSmrg# the $objdir directory.  This is a cygwin/mingw-specific
383555acc8fcSmrg# behavior.
383655acc8fcSmrgfunc_emit_wrapper ()
3837d63fdb69Smrg{
383855acc8fcSmrg	func_emit_wrapper_arg1=${1-no}
38393da084b3Smrg
3840d63fdb69Smrg	$ECHO "\
3841d63fdb69Smrg#! $SHELL
38423da084b3Smrg
3843d63fdb69Smrg# $output - temporary wrapper script for $objdir/$outputname
3844d63fdb69Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
3845d63fdb69Smrg#
3846d63fdb69Smrg# The $output program cannot be directly executed until all the libtool
3847d63fdb69Smrg# libraries that it depends on are installed.
3848d63fdb69Smrg#
3849d63fdb69Smrg# This wrapper script should never be moved out of the build directory.
3850d63fdb69Smrg# If it is, it will not operate correctly.
38513da084b3Smrg
3852d63fdb69Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
3853d63fdb69Smrg# metacharacters that are still active within double-quoted strings.
3854d63fdb69Smrgsed_quote_subst='$sed_quote_subst'
38553da084b3Smrg
3856d63fdb69Smrg# Be Bourne compatible
3857d63fdb69Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
3858d63fdb69Smrg  emulate sh
3859d63fdb69Smrg  NULLCMD=:
3860d63fdb69Smrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
3861d63fdb69Smrg  # is contrary to our usage.  Disable this feature.
3862d63fdb69Smrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
3863d63fdb69Smrg  setopt NO_GLOB_SUBST
3864d63fdb69Smrgelse
3865d63fdb69Smrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
3866d63fdb69Smrgfi
3867d63fdb69SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
3868d63fdb69SmrgDUALCASE=1; export DUALCASE # for MKS sh
38693da084b3Smrg
3870d63fdb69Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
3871d63fdb69Smrg# if CDPATH is set.
3872d63fdb69Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
38733da084b3Smrg
3874d63fdb69Smrgrelink_command=\"$relink_command\"
38753da084b3Smrg
3876d63fdb69Smrg# This environment variable determines our operation mode.
3877d63fdb69Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
3878d63fdb69Smrg  # install mode needs the following variables:
3879d63fdb69Smrg  generated_by_libtool_version='$macro_version'
3880d63fdb69Smrg  notinst_deplibs='$notinst_deplibs'
3881d63fdb69Smrgelse
3882d63fdb69Smrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
3883d63fdb69Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
388455acc8fcSmrg    file=\"\$0\""
388555acc8fcSmrg
388655acc8fcSmrg    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
388755acc8fcSmrg    $ECHO "\
388855acc8fcSmrg
388955acc8fcSmrg# A function that is used when there is no print builtin or printf.
389055acc8fcSmrgfunc_fallback_echo ()
389155acc8fcSmrg{
389255acc8fcSmrg  eval 'cat <<_LTECHO_EOF
389355acc8fcSmrg\$1
389455acc8fcSmrg_LTECHO_EOF'
389555acc8fcSmrg}
389655acc8fcSmrg    ECHO=\"$qECHO\"
389755acc8fcSmrg  fi
389855acc8fcSmrg
389955acc8fcSmrg# Very basic option parsing. These options are (a) specific to
390055acc8fcSmrg# the libtool wrapper, (b) are identical between the wrapper
390155acc8fcSmrg# /script/ and the wrapper /executable/ which is used only on
390255acc8fcSmrg# windows platforms, and (c) all begin with the string "--lt-"
390355acc8fcSmrg# (application programs are unlikely to have options which match
390455acc8fcSmrg# this pattern).
390555acc8fcSmrg#
390655acc8fcSmrg# There are only two supported options: --lt-debug and
390755acc8fcSmrg# --lt-dump-script. There is, deliberately, no --lt-help.
390855acc8fcSmrg#
390955acc8fcSmrg# The first argument to this parsing function should be the
391055acc8fcSmrg# script's $0 value, followed by "$@".
391155acc8fcSmrglt_option_debug=
391255acc8fcSmrgfunc_parse_lt_options ()
391355acc8fcSmrg{
391455acc8fcSmrg  lt_script_arg0=\$0
391555acc8fcSmrg  shift
391655acc8fcSmrg  for lt_opt
391755acc8fcSmrg  do
391855acc8fcSmrg    case \"\$lt_opt\" in
391955acc8fcSmrg    --lt-debug) lt_option_debug=1 ;;
392055acc8fcSmrg    --lt-dump-script)
392155acc8fcSmrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
392255acc8fcSmrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
392355acc8fcSmrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
392455acc8fcSmrg        cat \"\$lt_dump_D/\$lt_dump_F\"
392555acc8fcSmrg        exit 0
392655acc8fcSmrg      ;;
392755acc8fcSmrg    --lt-*)
392855acc8fcSmrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
392955acc8fcSmrg        exit 1
393055acc8fcSmrg      ;;
393155acc8fcSmrg    esac
393255acc8fcSmrg  done
393355acc8fcSmrg
393455acc8fcSmrg  # Print the debug banner immediately:
393555acc8fcSmrg  if test -n \"\$lt_option_debug\"; then
393655acc8fcSmrg    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
393755acc8fcSmrg  fi
393855acc8fcSmrg}
393955acc8fcSmrg
394055acc8fcSmrg# Used when --lt-debug. Prints its arguments to stdout
394155acc8fcSmrg# (redirection is the responsibility of the caller)
394255acc8fcSmrgfunc_lt_dump_args ()
394355acc8fcSmrg{
394455acc8fcSmrg  lt_dump_args_N=1;
394555acc8fcSmrg  for lt_arg
394655acc8fcSmrg  do
394755acc8fcSmrg    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
394855acc8fcSmrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
394955acc8fcSmrg  done
395055acc8fcSmrg}
395155acc8fcSmrg
395255acc8fcSmrg# Core function for launching the target application
395355acc8fcSmrgfunc_exec_program_core ()
395455acc8fcSmrg{
3955d63fdb69Smrg"
395655acc8fcSmrg  case $host in
395755acc8fcSmrg  # Backslashes separate directories on plain windows
395855acc8fcSmrg  *-*-mingw | *-*-os2* | *-cegcc*)
395955acc8fcSmrg    $ECHO "\
396055acc8fcSmrg      if test -n \"\$lt_option_debug\"; then
396155acc8fcSmrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
396255acc8fcSmrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
396355acc8fcSmrg      fi
396455acc8fcSmrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
396555acc8fcSmrg"
396655acc8fcSmrg    ;;
396755acc8fcSmrg
396855acc8fcSmrg  *)
396955acc8fcSmrg    $ECHO "\
397055acc8fcSmrg      if test -n \"\$lt_option_debug\"; then
397155acc8fcSmrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
397255acc8fcSmrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
397355acc8fcSmrg      fi
397455acc8fcSmrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
397555acc8fcSmrg"
397655acc8fcSmrg    ;;
397755acc8fcSmrg  esac
397855acc8fcSmrg  $ECHO "\
397955acc8fcSmrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
398055acc8fcSmrg      exit 1
398155acc8fcSmrg}
398255acc8fcSmrg
398355acc8fcSmrg# A function to encapsulate launching the target application
398455acc8fcSmrg# Strips options in the --lt-* namespace from \$@ and
398555acc8fcSmrg# launches target application with the remaining arguments.
398655acc8fcSmrgfunc_exec_program ()
398755acc8fcSmrg{
398848c85eb7Smrg  case \" \$* \" in
398948c85eb7Smrg  *\\ --lt-*)
399048c85eb7Smrg    for lt_wr_arg
399148c85eb7Smrg    do
399248c85eb7Smrg      case \$lt_wr_arg in
399348c85eb7Smrg      --lt-*) ;;
399448c85eb7Smrg      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
399548c85eb7Smrg      esac
399648c85eb7Smrg      shift
399748c85eb7Smrg    done ;;
399848c85eb7Smrg  esac
399955acc8fcSmrg  func_exec_program_core \${1+\"\$@\"}
400055acc8fcSmrg}
400155acc8fcSmrg
400255acc8fcSmrg  # Parse options
400355acc8fcSmrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
40043da084b3Smrg
4005d63fdb69Smrg  # Find the directory that this script lives in.
400655acc8fcSmrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
4007d63fdb69Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
40083da084b3Smrg
4009d63fdb69Smrg  # Follow symbolic links until we get to the real thisdir.
401055acc8fcSmrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
4011d63fdb69Smrg  while test -n \"\$file\"; do
401255acc8fcSmrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
40133da084b3Smrg
4014d63fdb69Smrg    # If there was a directory component, then change thisdir.
4015d63fdb69Smrg    if test \"x\$destdir\" != \"x\$file\"; then
4016d63fdb69Smrg      case \"\$destdir\" in
4017d63fdb69Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
4018d63fdb69Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
4019d63fdb69Smrg      esac
4020d63fdb69Smrg    fi
40213da084b3Smrg
402255acc8fcSmrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
402355acc8fcSmrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
4024d63fdb69Smrg  done
40253da084b3Smrg
4026d63fdb69Smrg  # Usually 'no', except on cygwin/mingw when embedded into
4027d63fdb69Smrg  # the cwrapper.
402855acc8fcSmrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
4029d63fdb69Smrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
4030d63fdb69Smrg    # special case for '.'
4031d63fdb69Smrg    if test \"\$thisdir\" = \".\"; then
4032d63fdb69Smrg      thisdir=\`pwd\`
4033d63fdb69Smrg    fi
4034d63fdb69Smrg    # remove .libs from thisdir
4035d63fdb69Smrg    case \"\$thisdir\" in
403655acc8fcSmrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
4037d63fdb69Smrg    $objdir )   thisdir=. ;;
4038d63fdb69Smrg    esac
4039d63fdb69Smrg  fi
40403da084b3Smrg
4041d63fdb69Smrg  # Try to get the absolute directory name.
4042d63fdb69Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
4043d63fdb69Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
4044d63fdb69Smrg"
40453da084b3Smrg
4046d63fdb69Smrg	if test "$fast_install" = yes; then
4047d63fdb69Smrg	  $ECHO "\
4048d63fdb69Smrg  program=lt-'$outputname'$exeext
4049d63fdb69Smrg  progdir=\"\$thisdir/$objdir\"
40503da084b3Smrg
4051d63fdb69Smrg  if test ! -f \"\$progdir/\$program\" ||
4052d63fdb69Smrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
4053d63fdb69Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
40543da084b3Smrg
4055d63fdb69Smrg    file=\"\$\$-\$program\"
40563da084b3Smrg
4057d63fdb69Smrg    if test ! -d \"\$progdir\"; then
4058d63fdb69Smrg      $MKDIR \"\$progdir\"
4059d63fdb69Smrg    else
4060d63fdb69Smrg      $RM \"\$progdir/\$file\"
4061d63fdb69Smrg    fi"
40623da084b3Smrg
4063d63fdb69Smrg	  $ECHO "\
40643da084b3Smrg
4065d63fdb69Smrg    # relink executable if necessary
4066d63fdb69Smrg    if test -n \"\$relink_command\"; then
4067d63fdb69Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
4068d63fdb69Smrg      else
4069d63fdb69Smrg	$ECHO \"\$relink_command_output\" >&2
4070d63fdb69Smrg	$RM \"\$progdir/\$file\"
4071d63fdb69Smrg	exit 1
4072d63fdb69Smrg      fi
4073d63fdb69Smrg    fi
40743da084b3Smrg
4075d63fdb69Smrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
4076d63fdb69Smrg    { $RM \"\$progdir/\$program\";
4077d63fdb69Smrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
4078d63fdb69Smrg    $RM \"\$progdir/\$file\"
4079d63fdb69Smrg  fi"
4080d63fdb69Smrg	else
4081d63fdb69Smrg	  $ECHO "\
4082d63fdb69Smrg  program='$outputname'
4083d63fdb69Smrg  progdir=\"\$thisdir/$objdir\"
4084d63fdb69Smrg"
4085d63fdb69Smrg	fi
40863da084b3Smrg
4087d63fdb69Smrg	$ECHO "\
40883da084b3Smrg
4089d63fdb69Smrg  if test -f \"\$progdir/\$program\"; then"
40903da084b3Smrg
409148c85eb7Smrg	# fixup the dll searchpath if we need to.
409248c85eb7Smrg	#
409348c85eb7Smrg	# Fix the DLL searchpath if we need to.  Do this before prepending
409448c85eb7Smrg	# to shlibpath, because on Windows, both are PATH and uninstalled
409548c85eb7Smrg	# libraries must come first.
409648c85eb7Smrg	if test -n "$dllsearchpath"; then
409748c85eb7Smrg	  $ECHO "\
409848c85eb7Smrg    # Add the dll search path components to the executable PATH
409948c85eb7Smrg    PATH=$dllsearchpath:\$PATH
410048c85eb7Smrg"
410148c85eb7Smrg	fi
410248c85eb7Smrg
4103d63fdb69Smrg	# Export our shlibpath_var if we have one.
4104d63fdb69Smrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4105d63fdb69Smrg	  $ECHO "\
4106d63fdb69Smrg    # Add our own library path to $shlibpath_var
4107d63fdb69Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
41083da084b3Smrg
4109d63fdb69Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
4110d63fdb69Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
411155acc8fcSmrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
41123da084b3Smrg
4113d63fdb69Smrg    export $shlibpath_var
4114d63fdb69Smrg"
41153da084b3Smrg	fi
41163da084b3Smrg
4117d63fdb69Smrg	$ECHO "\
4118d63fdb69Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
4119d63fdb69Smrg      # Run the actual program with our arguments.
412055acc8fcSmrg      func_exec_program \${1+\"\$@\"}
4121d63fdb69Smrg    fi
4122d63fdb69Smrg  else
4123d63fdb69Smrg    # The program doesn't exist.
4124d63fdb69Smrg    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
4125d63fdb69Smrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
412655acc8fcSmrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
4127d63fdb69Smrg    exit 1
4128d63fdb69Smrg  fi
4129d63fdb69Smrgfi\
4130d63fdb69Smrg"
4131d63fdb69Smrg}
41323da084b3Smrg
41333da084b3Smrg
4134d63fdb69Smrg# func_emit_cwrapperexe_src
4135d63fdb69Smrg# emit the source code for a wrapper executable on stdout
4136d63fdb69Smrg# Must ONLY be called from within func_mode_link because
4137d63fdb69Smrg# it depends on a number of variable set therein.
4138d63fdb69Smrgfunc_emit_cwrapperexe_src ()
4139d63fdb69Smrg{
4140d63fdb69Smrg	cat <<EOF
41413da084b3Smrg
4142d63fdb69Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
4143d63fdb69Smrg   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
41443da084b3Smrg
4145d63fdb69Smrg   The $output program cannot be directly executed until all the libtool
4146d63fdb69Smrg   libraries that it depends on are installed.
41473da084b3Smrg
4148d63fdb69Smrg   This wrapper executable should never be moved out of the build directory.
4149d63fdb69Smrg   If it is, it will not operate correctly.
4150d63fdb69Smrg*/
4151d63fdb69SmrgEOF
4152d63fdb69Smrg	    cat <<"EOF"
415355acc8fcSmrg#ifdef _MSC_VER
415455acc8fcSmrg# define _CRT_SECURE_NO_DEPRECATE 1
415555acc8fcSmrg#endif
4156d63fdb69Smrg#include <stdio.h>
4157d63fdb69Smrg#include <stdlib.h>
4158d63fdb69Smrg#ifdef _MSC_VER
4159d63fdb69Smrg# include <direct.h>
4160d63fdb69Smrg# include <process.h>
4161d63fdb69Smrg# include <io.h>
4162d63fdb69Smrg#else
4163d63fdb69Smrg# include <unistd.h>
4164d63fdb69Smrg# include <stdint.h>
4165d63fdb69Smrg# ifdef __CYGWIN__
4166d63fdb69Smrg#  include <io.h>
4167d63fdb69Smrg# endif
4168d63fdb69Smrg#endif
4169d63fdb69Smrg#include <malloc.h>
4170d63fdb69Smrg#include <stdarg.h>
4171d63fdb69Smrg#include <assert.h>
4172d63fdb69Smrg#include <string.h>
4173d63fdb69Smrg#include <ctype.h>
4174d63fdb69Smrg#include <errno.h>
4175d63fdb69Smrg#include <fcntl.h>
4176d63fdb69Smrg#include <sys/stat.h>
4177d63fdb69Smrg
417855acc8fcSmrg/* declarations of non-ANSI functions */
417955acc8fcSmrg#if defined(__MINGW32__)
418055acc8fcSmrg# ifdef __STRICT_ANSI__
418155acc8fcSmrgint _putenv (const char *);
418255acc8fcSmrg# endif
418355acc8fcSmrg#elif defined(__CYGWIN__)
418455acc8fcSmrg# ifdef __STRICT_ANSI__
418555acc8fcSmrgchar *realpath (const char *, char *);
418655acc8fcSmrgint putenv (char *);
418755acc8fcSmrgint setenv (const char *, const char *, int);
418855acc8fcSmrg# endif
418955acc8fcSmrg/* #elif defined (other platforms) ... */
419055acc8fcSmrg#endif
419155acc8fcSmrg
419255acc8fcSmrg/* portability defines, excluding path handling macros */
419355acc8fcSmrg#if defined(_MSC_VER)
419455acc8fcSmrg# define setmode _setmode
419555acc8fcSmrg# define stat    _stat
419655acc8fcSmrg# define chmod   _chmod
419755acc8fcSmrg# define getcwd  _getcwd
419855acc8fcSmrg# define putenv  _putenv
419955acc8fcSmrg# define S_IXUSR _S_IEXEC
420055acc8fcSmrg# ifndef _INTPTR_T_DEFINED
420155acc8fcSmrg#  define _INTPTR_T_DEFINED
420255acc8fcSmrg#  define intptr_t int
420355acc8fcSmrg# endif
420455acc8fcSmrg#elif defined(__MINGW32__)
420555acc8fcSmrg# define setmode _setmode
420655acc8fcSmrg# define stat    _stat
420755acc8fcSmrg# define chmod   _chmod
420855acc8fcSmrg# define getcwd  _getcwd
420955acc8fcSmrg# define putenv  _putenv
421055acc8fcSmrg#elif defined(__CYGWIN__)
421155acc8fcSmrg# define HAVE_SETENV
421255acc8fcSmrg# define FOPEN_WB "wb"
421355acc8fcSmrg/* #elif defined (other platforms) ... */
421455acc8fcSmrg#endif
421555acc8fcSmrg
4216d63fdb69Smrg#if defined(PATH_MAX)
4217d63fdb69Smrg# define LT_PATHMAX PATH_MAX
4218d63fdb69Smrg#elif defined(MAXPATHLEN)
4219d63fdb69Smrg# define LT_PATHMAX MAXPATHLEN
4220d63fdb69Smrg#else
4221d63fdb69Smrg# define LT_PATHMAX 1024
4222d63fdb69Smrg#endif
4223d63fdb69Smrg
4224d63fdb69Smrg#ifndef S_IXOTH
4225d63fdb69Smrg# define S_IXOTH 0
4226d63fdb69Smrg#endif
4227d63fdb69Smrg#ifndef S_IXGRP
4228d63fdb69Smrg# define S_IXGRP 0
4229d63fdb69Smrg#endif
4230d63fdb69Smrg
423155acc8fcSmrg/* path handling portability macros */
4232d63fdb69Smrg#ifndef DIR_SEPARATOR
4233d63fdb69Smrg# define DIR_SEPARATOR '/'
4234d63fdb69Smrg# define PATH_SEPARATOR ':'
4235d63fdb69Smrg#endif
4236d63fdb69Smrg
4237d63fdb69Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
4238d63fdb69Smrg  defined (__OS2__)
4239d63fdb69Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
4240d63fdb69Smrg# define FOPEN_WB "wb"
4241d63fdb69Smrg# ifndef DIR_SEPARATOR_2
4242d63fdb69Smrg#  define DIR_SEPARATOR_2 '\\'
4243d63fdb69Smrg# endif
4244d63fdb69Smrg# ifndef PATH_SEPARATOR_2
4245d63fdb69Smrg#  define PATH_SEPARATOR_2 ';'
4246d63fdb69Smrg# endif
4247d63fdb69Smrg#endif
4248d63fdb69Smrg
4249d63fdb69Smrg#ifndef DIR_SEPARATOR_2
4250d63fdb69Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
4251d63fdb69Smrg#else /* DIR_SEPARATOR_2 */
4252d63fdb69Smrg# define IS_DIR_SEPARATOR(ch) \
4253d63fdb69Smrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4254d63fdb69Smrg#endif /* DIR_SEPARATOR_2 */
4255d63fdb69Smrg
4256d63fdb69Smrg#ifndef PATH_SEPARATOR_2
4257d63fdb69Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
4258d63fdb69Smrg#else /* PATH_SEPARATOR_2 */
4259d63fdb69Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
4260d63fdb69Smrg#endif /* PATH_SEPARATOR_2 */
4261d63fdb69Smrg
4262d63fdb69Smrg#ifndef FOPEN_WB
4263d63fdb69Smrg# define FOPEN_WB "w"
4264d63fdb69Smrg#endif
4265d63fdb69Smrg#ifndef _O_BINARY
4266d63fdb69Smrg# define _O_BINARY 0
4267d63fdb69Smrg#endif
4268d63fdb69Smrg
4269d63fdb69Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
4270d63fdb69Smrg#define XFREE(stale) do { \
4271d63fdb69Smrg  if (stale) { free ((void *) stale); stale = 0; } \
4272d63fdb69Smrg} while (0)
4273d63fdb69Smrg
427455acc8fcSmrg#if defined(LT_DEBUGWRAPPER)
427555acc8fcSmrgstatic int lt_debug = 1;
4276d63fdb69Smrg#else
427755acc8fcSmrgstatic int lt_debug = 0;
4278d63fdb69Smrg#endif
4279d63fdb69Smrg
428055acc8fcSmrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
4281d63fdb69Smrg
4282d63fdb69Smrgvoid *xmalloc (size_t num);
4283d63fdb69Smrgchar *xstrdup (const char *string);
4284d63fdb69Smrgconst char *base_name (const char *name);
4285d63fdb69Smrgchar *find_executable (const char *wrapper);
4286d63fdb69Smrgchar *chase_symlinks (const char *pathspec);
4287d63fdb69Smrgint make_executable (const char *path);
4288d63fdb69Smrgint check_executable (const char *path);
4289d63fdb69Smrgchar *strendzap (char *str, const char *pat);
429055acc8fcSmrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
429155acc8fcSmrgvoid lt_fatal (const char *file, int line, const char *message, ...);
429255acc8fcSmrgstatic const char *nonnull (const char *s);
429355acc8fcSmrgstatic const char *nonempty (const char *s);
4294d63fdb69Smrgvoid lt_setenv (const char *name, const char *value);
4295d63fdb69Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
4296d63fdb69Smrgvoid lt_update_exe_path (const char *name, const char *value);
4297d63fdb69Smrgvoid lt_update_lib_path (const char *name, const char *value);
429855acc8fcSmrgchar **prepare_spawn (char **argv);
429955acc8fcSmrgvoid lt_dump_script (FILE *f);
4300d63fdb69SmrgEOF
4301d63fdb69Smrg
4302d63fdb69Smrg	    cat <<EOF
430348c85eb7Smrgvolatile const char * MAGIC_EXE = "$magic_exe";
4304d63fdb69Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
4305d63fdb69SmrgEOF
4306d63fdb69Smrg
4307d63fdb69Smrg	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
430848c85eb7Smrg              func_to_host_path "$temp_rpath"
4309d63fdb69Smrg	      cat <<EOF
431048c85eb7Smrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
43113da084b3SmrgEOF
43123da084b3Smrg	    else
4313d63fdb69Smrg	      cat <<"EOF"
4314d63fdb69Smrgconst char * LIB_PATH_VALUE   = "";
4315d63fdb69SmrgEOF
43163da084b3Smrg	    fi
4317d63fdb69Smrg
4318d63fdb69Smrg	    if test -n "$dllsearchpath"; then
431948c85eb7Smrg              func_to_host_path "$dllsearchpath:"
4320d63fdb69Smrg	      cat <<EOF
4321d63fdb69Smrgconst char * EXE_PATH_VARNAME = "PATH";
432248c85eb7Smrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
4323d63fdb69SmrgEOF
43243da084b3Smrg	    else
4325d63fdb69Smrg	      cat <<"EOF"
4326d63fdb69Smrgconst char * EXE_PATH_VARNAME = "";
4327d63fdb69Smrgconst char * EXE_PATH_VALUE   = "";
4328d63fdb69SmrgEOF
43293da084b3Smrg	    fi
4330d63fdb69Smrg
4331d63fdb69Smrg	    if test "$fast_install" = yes; then
4332d63fdb69Smrg	      cat <<EOF
4333d63fdb69Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
4334d63fdb69SmrgEOF
43353da084b3Smrg	    else
4336d63fdb69Smrg	      cat <<EOF
4337d63fdb69Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
4338d63fdb69SmrgEOF
43393da084b3Smrg	    fi
43403da084b3Smrg
43413da084b3Smrg
4342d63fdb69Smrg	    cat <<"EOF"
43433da084b3Smrg
4344d63fdb69Smrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
43453da084b3Smrg
4346d63fdb69Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
4347d63fdb69Smrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
434855acc8fcSmrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
43493da084b3Smrg
4350d63fdb69Smrgint
4351d63fdb69Smrgmain (int argc, char *argv[])
4352d63fdb69Smrg{
4353d63fdb69Smrg  char **newargz;
4354d63fdb69Smrg  int  newargc;
4355d63fdb69Smrg  char *tmp_pathspec;
4356d63fdb69Smrg  char *actual_cwrapper_path;
4357d63fdb69Smrg  char *actual_cwrapper_name;
4358d63fdb69Smrg  char *target_name;
4359d63fdb69Smrg  char *lt_argv_zero;
4360d63fdb69Smrg  intptr_t rval = 127;
43613da084b3Smrg
4362d63fdb69Smrg  int i;
43633da084b3Smrg
4364d63fdb69Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
436555acc8fcSmrg  newargz = XMALLOC (char *, argc + 1);
43663da084b3Smrg
436755acc8fcSmrg  /* very simple arg parsing; don't want to rely on getopt
436855acc8fcSmrg   * also, copy all non cwrapper options to newargz, except
436955acc8fcSmrg   * argz[0], which is handled differently
437055acc8fcSmrg   */
437155acc8fcSmrg  newargc=0;
4372d63fdb69Smrg  for (i = 1; i < argc; i++)
4373d63fdb69Smrg    {
4374d63fdb69Smrg      if (strcmp (argv[i], dumpscript_opt) == 0)
4375d63fdb69Smrg	{
4376d63fdb69SmrgEOF
4377d63fdb69Smrg	    case "$host" in
4378d63fdb69Smrg	      *mingw* | *cygwin* )
4379d63fdb69Smrg		# make stdout use "unix" line endings
4380d63fdb69Smrg		echo "          setmode(1,_O_BINARY);"
4381d63fdb69Smrg		;;
4382d63fdb69Smrg	      esac
43833da084b3Smrg
4384d63fdb69Smrg	    cat <<"EOF"
438555acc8fcSmrg	  lt_dump_script (stdout);
4386d63fdb69Smrg	  return 0;
4387d63fdb69Smrg	}
438855acc8fcSmrg      if (strcmp (argv[i], debug_opt) == 0)
438955acc8fcSmrg	{
439055acc8fcSmrg          lt_debug = 1;
439155acc8fcSmrg          continue;
439255acc8fcSmrg	}
439355acc8fcSmrg      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
439455acc8fcSmrg        {
439555acc8fcSmrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
439655acc8fcSmrg             namespace, but it is not one of the ones we know about and
439755acc8fcSmrg             have already dealt with, above (inluding dump-script), then
439855acc8fcSmrg             report an error. Otherwise, targets might begin to believe
439955acc8fcSmrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
440055acc8fcSmrg             namespace. The first time any user complains about this, we'll
440155acc8fcSmrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
440255acc8fcSmrg             or a configure.ac-settable value.
440355acc8fcSmrg           */
440455acc8fcSmrg          lt_fatal (__FILE__, __LINE__,
440555acc8fcSmrg		    "unrecognized %s option: '%s'",
440655acc8fcSmrg                    ltwrapper_option_prefix, argv[i]);
440755acc8fcSmrg        }
440855acc8fcSmrg      /* otherwise ... */
440955acc8fcSmrg      newargz[++newargc] = xstrdup (argv[i]);
4410d63fdb69Smrg    }
441155acc8fcSmrg  newargz[++newargc] = NULL;
441255acc8fcSmrg
441355acc8fcSmrgEOF
441455acc8fcSmrg	    cat <<EOF
441555acc8fcSmrg  /* The GNU banner must be the first non-error debug message */
441655acc8fcSmrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
441755acc8fcSmrgEOF
441855acc8fcSmrg	    cat <<"EOF"
441955acc8fcSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
442055acc8fcSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
44213da084b3Smrg
4422d63fdb69Smrg  tmp_pathspec = find_executable (argv[0]);
4423d63fdb69Smrg  if (tmp_pathspec == NULL)
442455acc8fcSmrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
442555acc8fcSmrg  lt_debugprintf (__FILE__, __LINE__,
442655acc8fcSmrg                  "(main) found exe (before symlink chase) at: %s\n",
442755acc8fcSmrg		  tmp_pathspec);
4428d63fdb69Smrg
4429d63fdb69Smrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
443055acc8fcSmrg  lt_debugprintf (__FILE__, __LINE__,
443155acc8fcSmrg                  "(main) found exe (after symlink chase) at: %s\n",
443255acc8fcSmrg		  actual_cwrapper_path);
4433d63fdb69Smrg  XFREE (tmp_pathspec);
4434d63fdb69Smrg
443555acc8fcSmrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
4436d63fdb69Smrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
4437d63fdb69Smrg
4438d63fdb69Smrg  /* wrapper name transforms */
4439d63fdb69Smrg  strendzap (actual_cwrapper_name, ".exe");
4440d63fdb69Smrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
4441d63fdb69Smrg  XFREE (actual_cwrapper_name);
4442d63fdb69Smrg  actual_cwrapper_name = tmp_pathspec;
4443d63fdb69Smrg  tmp_pathspec = 0;
4444d63fdb69Smrg
4445d63fdb69Smrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
4446d63fdb69Smrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
4447d63fdb69Smrg  strendzap (target_name, ".exe");
4448d63fdb69Smrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
4449d63fdb69Smrg  XFREE (target_name);
4450d63fdb69Smrg  target_name = tmp_pathspec;
4451d63fdb69Smrg  tmp_pathspec = 0;
4452d63fdb69Smrg
445355acc8fcSmrg  lt_debugprintf (__FILE__, __LINE__,
445455acc8fcSmrg		  "(main) libtool target name: %s\n",
445555acc8fcSmrg		  target_name);
4456d63fdb69SmrgEOF
44573da084b3Smrg
4458d63fdb69Smrg	    cat <<EOF
4459d63fdb69Smrg  newargz[0] =
4460d63fdb69Smrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
4461d63fdb69Smrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
4462d63fdb69Smrg  strcpy (newargz[0], actual_cwrapper_path);
4463d63fdb69Smrg  strcat (newargz[0], "$objdir");
4464d63fdb69Smrg  strcat (newargz[0], "/");
4465d63fdb69SmrgEOF
44663da084b3Smrg
4467d63fdb69Smrg	    cat <<"EOF"
4468d63fdb69Smrg  /* stop here, and copy so we don't have to do this twice */
4469d63fdb69Smrg  tmp_pathspec = xstrdup (newargz[0]);
44703da084b3Smrg
4471d63fdb69Smrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
4472d63fdb69Smrg  strcat (newargz[0], actual_cwrapper_name);
44733da084b3Smrg
4474d63fdb69Smrg  /* DO want the lt- prefix here if it exists, so use target_name */
4475d63fdb69Smrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
4476d63fdb69Smrg  XFREE (tmp_pathspec);
4477d63fdb69Smrg  tmp_pathspec = NULL;
4478d63fdb69SmrgEOF
44793da084b3Smrg
4480d63fdb69Smrg	    case $host_os in
4481d63fdb69Smrg	      mingw*)
4482d63fdb69Smrg	    cat <<"EOF"
4483d63fdb69Smrg  {
4484d63fdb69Smrg    char* p;
4485d63fdb69Smrg    while ((p = strchr (newargz[0], '\\')) != NULL)
4486d63fdb69Smrg      {
4487d63fdb69Smrg	*p = '/';
4488d63fdb69Smrg      }
4489d63fdb69Smrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
4490d63fdb69Smrg      {
4491d63fdb69Smrg	*p = '/';
4492d63fdb69Smrg      }
4493d63fdb69Smrg  }
4494d63fdb69SmrgEOF
4495d63fdb69Smrg	    ;;
4496d63fdb69Smrg	    esac
44973da084b3Smrg
4498d63fdb69Smrg	    cat <<"EOF"
4499d63fdb69Smrg  XFREE (target_name);
4500d63fdb69Smrg  XFREE (actual_cwrapper_path);
4501d63fdb69Smrg  XFREE (actual_cwrapper_name);
45023da084b3Smrg
4503d63fdb69Smrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
4504d63fdb69Smrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
450548c85eb7Smrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
450648c85eb7Smrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
450748c85eb7Smrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
450848c85eb7Smrg     libraries must come first. */
4509d63fdb69Smrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
451048c85eb7Smrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
45113da084b3Smrg
451255acc8fcSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
451355acc8fcSmrg		  nonnull (lt_argv_zero));
4514d63fdb69Smrg  for (i = 0; i < newargc; i++)
4515d63fdb69Smrg    {
451655acc8fcSmrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
451755acc8fcSmrg		      i, nonnull (newargz[i]));
4518d63fdb69Smrg    }
45193da084b3Smrg
4520d63fdb69SmrgEOF
45213da084b3Smrg
4522d63fdb69Smrg	    case $host_os in
4523d63fdb69Smrg	      mingw*)
4524d63fdb69Smrg		cat <<"EOF"
4525d63fdb69Smrg  /* execv doesn't actually work on mingw as expected on unix */
452655acc8fcSmrg  newargz = prepare_spawn (newargz);
4527d63fdb69Smrg  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
4528d63fdb69Smrg  if (rval == -1)
4529d63fdb69Smrg    {
4530d63fdb69Smrg      /* failed to start process */
453155acc8fcSmrg      lt_debugprintf (__FILE__, __LINE__,
453255acc8fcSmrg		      "(main) failed to launch target \"%s\": %s\n",
453355acc8fcSmrg		      lt_argv_zero, nonnull (strerror (errno)));
4534d63fdb69Smrg      return 127;
4535d63fdb69Smrg    }
4536d63fdb69Smrg  return rval;
4537d63fdb69SmrgEOF
4538d63fdb69Smrg		;;
4539d63fdb69Smrg	      *)
4540d63fdb69Smrg		cat <<"EOF"
4541d63fdb69Smrg  execv (lt_argv_zero, newargz);
4542d63fdb69Smrg  return rval; /* =127, but avoids unused variable warning */
4543d63fdb69SmrgEOF
4544d63fdb69Smrg		;;
4545d63fdb69Smrg	    esac
45463da084b3Smrg
4547d63fdb69Smrg	    cat <<"EOF"
4548d63fdb69Smrg}
45493da084b3Smrg
4550d63fdb69Smrgvoid *
4551d63fdb69Smrgxmalloc (size_t num)
4552d63fdb69Smrg{
4553d63fdb69Smrg  void *p = (void *) malloc (num);
4554d63fdb69Smrg  if (!p)
455555acc8fcSmrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
45563da084b3Smrg
4557d63fdb69Smrg  return p;
4558d63fdb69Smrg}
45593da084b3Smrg
4560d63fdb69Smrgchar *
4561d63fdb69Smrgxstrdup (const char *string)
4562d63fdb69Smrg{
4563d63fdb69Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
4564d63fdb69Smrg			  string) : NULL;
4565d63fdb69Smrg}
45663da084b3Smrg
4567d63fdb69Smrgconst char *
4568d63fdb69Smrgbase_name (const char *name)
4569d63fdb69Smrg{
4570d63fdb69Smrg  const char *base;
45713da084b3Smrg
4572d63fdb69Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4573d63fdb69Smrg  /* Skip over the disk name in MSDOS pathnames. */
4574d63fdb69Smrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
4575d63fdb69Smrg    name += 2;
4576d63fdb69Smrg#endif
45773da084b3Smrg
4578d63fdb69Smrg  for (base = name; *name; name++)
4579d63fdb69Smrg    if (IS_DIR_SEPARATOR (*name))
4580d63fdb69Smrg      base = name + 1;
4581d63fdb69Smrg  return base;
4582d63fdb69Smrg}
45833da084b3Smrg
4584d63fdb69Smrgint
4585d63fdb69Smrgcheck_executable (const char *path)
4586d63fdb69Smrg{
4587d63fdb69Smrg  struct stat st;
45883da084b3Smrg
458955acc8fcSmrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
459055acc8fcSmrg                  nonempty (path));
4591d63fdb69Smrg  if ((!path) || (!*path))
4592d63fdb69Smrg    return 0;
45933da084b3Smrg
4594d63fdb69Smrg  if ((stat (path, &st) >= 0)
4595d63fdb69Smrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
4596d63fdb69Smrg    return 1;
4597d63fdb69Smrg  else
4598d63fdb69Smrg    return 0;
4599d63fdb69Smrg}
46003da084b3Smrg
4601d63fdb69Smrgint
4602d63fdb69Smrgmake_executable (const char *path)
4603d63fdb69Smrg{
4604d63fdb69Smrg  int rval = 0;
4605d63fdb69Smrg  struct stat st;
46063da084b3Smrg
460755acc8fcSmrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
460855acc8fcSmrg                  nonempty (path));
4609d63fdb69Smrg  if ((!path) || (!*path))
4610d63fdb69Smrg    return 0;
46113da084b3Smrg
4612d63fdb69Smrg  if (stat (path, &st) >= 0)
4613d63fdb69Smrg    {
4614d63fdb69Smrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
4615d63fdb69Smrg    }
4616d63fdb69Smrg  return rval;
4617d63fdb69Smrg}
46183da084b3Smrg
4619d63fdb69Smrg/* Searches for the full path of the wrapper.  Returns
4620d63fdb69Smrg   newly allocated full path name if found, NULL otherwise
4621d63fdb69Smrg   Does not chase symlinks, even on platforms that support them.
4622d63fdb69Smrg*/
4623d63fdb69Smrgchar *
4624d63fdb69Smrgfind_executable (const char *wrapper)
4625d63fdb69Smrg{
4626d63fdb69Smrg  int has_slash = 0;
4627d63fdb69Smrg  const char *p;
4628d63fdb69Smrg  const char *p_next;
4629d63fdb69Smrg  /* static buffer for getcwd */
4630d63fdb69Smrg  char tmp[LT_PATHMAX + 1];
4631d63fdb69Smrg  int tmp_len;
4632d63fdb69Smrg  char *concat_name;
46333da084b3Smrg
463455acc8fcSmrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
463555acc8fcSmrg                  nonempty (wrapper));
46363da084b3Smrg
4637d63fdb69Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
4638d63fdb69Smrg    return NULL;
46393da084b3Smrg
4640d63fdb69Smrg  /* Absolute path? */
4641d63fdb69Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4642d63fdb69Smrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
4643d63fdb69Smrg    {
4644d63fdb69Smrg      concat_name = xstrdup (wrapper);
4645d63fdb69Smrg      if (check_executable (concat_name))
4646d63fdb69Smrg	return concat_name;
4647d63fdb69Smrg      XFREE (concat_name);
4648d63fdb69Smrg    }
4649d63fdb69Smrg  else
4650d63fdb69Smrg    {
4651d63fdb69Smrg#endif
4652d63fdb69Smrg      if (IS_DIR_SEPARATOR (wrapper[0]))
4653d63fdb69Smrg	{
4654d63fdb69Smrg	  concat_name = xstrdup (wrapper);
4655d63fdb69Smrg	  if (check_executable (concat_name))
4656d63fdb69Smrg	    return concat_name;
4657d63fdb69Smrg	  XFREE (concat_name);
4658d63fdb69Smrg	}
4659d63fdb69Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4660d63fdb69Smrg    }
4661d63fdb69Smrg#endif
46623da084b3Smrg
4663d63fdb69Smrg  for (p = wrapper; *p; p++)
4664d63fdb69Smrg    if (*p == '/')
4665d63fdb69Smrg      {
4666d63fdb69Smrg	has_slash = 1;
4667d63fdb69Smrg	break;
4668d63fdb69Smrg      }
4669d63fdb69Smrg  if (!has_slash)
4670d63fdb69Smrg    {
4671d63fdb69Smrg      /* no slashes; search PATH */
4672d63fdb69Smrg      const char *path = getenv ("PATH");
4673d63fdb69Smrg      if (path != NULL)
4674d63fdb69Smrg	{
4675d63fdb69Smrg	  for (p = path; *p; p = p_next)
4676d63fdb69Smrg	    {
4677d63fdb69Smrg	      const char *q;
4678d63fdb69Smrg	      size_t p_len;
4679d63fdb69Smrg	      for (q = p; *q; q++)
4680d63fdb69Smrg		if (IS_PATH_SEPARATOR (*q))
4681d63fdb69Smrg		  break;
4682d63fdb69Smrg	      p_len = q - p;
4683d63fdb69Smrg	      p_next = (*q == '\0' ? q : q + 1);
4684d63fdb69Smrg	      if (p_len == 0)
4685d63fdb69Smrg		{
4686d63fdb69Smrg		  /* empty path: current directory */
4687d63fdb69Smrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
468855acc8fcSmrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
468955acc8fcSmrg                              nonnull (strerror (errno)));
4690d63fdb69Smrg		  tmp_len = strlen (tmp);
4691d63fdb69Smrg		  concat_name =
4692d63fdb69Smrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4693d63fdb69Smrg		  memcpy (concat_name, tmp, tmp_len);
4694d63fdb69Smrg		  concat_name[tmp_len] = '/';
4695d63fdb69Smrg		  strcpy (concat_name + tmp_len + 1, wrapper);
4696d63fdb69Smrg		}
4697d63fdb69Smrg	      else
4698d63fdb69Smrg		{
4699d63fdb69Smrg		  concat_name =
4700d63fdb69Smrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
4701d63fdb69Smrg		  memcpy (concat_name, p, p_len);
4702d63fdb69Smrg		  concat_name[p_len] = '/';
4703d63fdb69Smrg		  strcpy (concat_name + p_len + 1, wrapper);
4704d63fdb69Smrg		}
4705d63fdb69Smrg	      if (check_executable (concat_name))
4706d63fdb69Smrg		return concat_name;
4707d63fdb69Smrg	      XFREE (concat_name);
4708d63fdb69Smrg	    }
4709d63fdb69Smrg	}
4710d63fdb69Smrg      /* not found in PATH; assume curdir */
4711d63fdb69Smrg    }
4712d63fdb69Smrg  /* Relative path | not found in path: prepend cwd */
4713d63fdb69Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
471455acc8fcSmrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
471555acc8fcSmrg              nonnull (strerror (errno)));
4716d63fdb69Smrg  tmp_len = strlen (tmp);
4717d63fdb69Smrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4718d63fdb69Smrg  memcpy (concat_name, tmp, tmp_len);
4719d63fdb69Smrg  concat_name[tmp_len] = '/';
4720d63fdb69Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
47213da084b3Smrg
4722d63fdb69Smrg  if (check_executable (concat_name))
4723d63fdb69Smrg    return concat_name;
4724d63fdb69Smrg  XFREE (concat_name);
4725d63fdb69Smrg  return NULL;
4726d63fdb69Smrg}
47273da084b3Smrg
4728d63fdb69Smrgchar *
4729d63fdb69Smrgchase_symlinks (const char *pathspec)
4730d63fdb69Smrg{
4731d63fdb69Smrg#ifndef S_ISLNK
4732d63fdb69Smrg  return xstrdup (pathspec);
4733d63fdb69Smrg#else
4734d63fdb69Smrg  char buf[LT_PATHMAX];
4735d63fdb69Smrg  struct stat s;
4736d63fdb69Smrg  char *tmp_pathspec = xstrdup (pathspec);
4737d63fdb69Smrg  char *p;
4738d63fdb69Smrg  int has_symlinks = 0;
4739d63fdb69Smrg  while (strlen (tmp_pathspec) && !has_symlinks)
4740d63fdb69Smrg    {
474155acc8fcSmrg      lt_debugprintf (__FILE__, __LINE__,
474255acc8fcSmrg		      "checking path component for symlinks: %s\n",
474355acc8fcSmrg		      tmp_pathspec);
4744d63fdb69Smrg      if (lstat (tmp_pathspec, &s) == 0)
4745d63fdb69Smrg	{
4746d63fdb69Smrg	  if (S_ISLNK (s.st_mode) != 0)
4747d63fdb69Smrg	    {
4748d63fdb69Smrg	      has_symlinks = 1;
4749d63fdb69Smrg	      break;
4750d63fdb69Smrg	    }
47513da084b3Smrg
4752d63fdb69Smrg	  /* search backwards for last DIR_SEPARATOR */
4753d63fdb69Smrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
4754d63fdb69Smrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4755d63fdb69Smrg	    p--;
4756d63fdb69Smrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4757d63fdb69Smrg	    {
4758d63fdb69Smrg	      /* no more DIR_SEPARATORS left */
4759d63fdb69Smrg	      break;
4760d63fdb69Smrg	    }
4761d63fdb69Smrg	  *p = '\0';
4762d63fdb69Smrg	}
4763d63fdb69Smrg      else
4764d63fdb69Smrg	{
476555acc8fcSmrg	  lt_fatal (__FILE__, __LINE__,
476655acc8fcSmrg		    "error accessing file \"%s\": %s",
476755acc8fcSmrg		    tmp_pathspec, nonnull (strerror (errno)));
4768d63fdb69Smrg	}
4769d63fdb69Smrg    }
4770d63fdb69Smrg  XFREE (tmp_pathspec);
47713da084b3Smrg
4772d63fdb69Smrg  if (!has_symlinks)
4773d63fdb69Smrg    {
4774d63fdb69Smrg      return xstrdup (pathspec);
4775d63fdb69Smrg    }
47763da084b3Smrg
4777d63fdb69Smrg  tmp_pathspec = realpath (pathspec, buf);
4778d63fdb69Smrg  if (tmp_pathspec == 0)
4779d63fdb69Smrg    {
478055acc8fcSmrg      lt_fatal (__FILE__, __LINE__,
478155acc8fcSmrg		"could not follow symlinks for %s", pathspec);
4782d63fdb69Smrg    }
4783d63fdb69Smrg  return xstrdup (tmp_pathspec);
4784d63fdb69Smrg#endif
4785d63fdb69Smrg}
47863da084b3Smrg
4787d63fdb69Smrgchar *
4788d63fdb69Smrgstrendzap (char *str, const char *pat)
4789d63fdb69Smrg{
4790d63fdb69Smrg  size_t len, patlen;
47913da084b3Smrg
4792d63fdb69Smrg  assert (str != NULL);
4793d63fdb69Smrg  assert (pat != NULL);
47943da084b3Smrg
4795d63fdb69Smrg  len = strlen (str);
4796d63fdb69Smrg  patlen = strlen (pat);
47973da084b3Smrg
4798d63fdb69Smrg  if (patlen <= len)
4799d63fdb69Smrg    {
4800d63fdb69Smrg      str += len - patlen;
4801d63fdb69Smrg      if (strcmp (str, pat) == 0)
4802d63fdb69Smrg	*str = '\0';
4803d63fdb69Smrg    }
4804d63fdb69Smrg  return str;
4805d63fdb69Smrg}
48063da084b3Smrg
480755acc8fcSmrgvoid
480855acc8fcSmrglt_debugprintf (const char *file, int line, const char *fmt, ...)
480955acc8fcSmrg{
481055acc8fcSmrg  va_list args;
481155acc8fcSmrg  if (lt_debug)
481255acc8fcSmrg    {
481355acc8fcSmrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
481455acc8fcSmrg      va_start (args, fmt);
481555acc8fcSmrg      (void) vfprintf (stderr, fmt, args);
481655acc8fcSmrg      va_end (args);
481755acc8fcSmrg    }
481855acc8fcSmrg}
481955acc8fcSmrg
4820d63fdb69Smrgstatic void
482155acc8fcSmrglt_error_core (int exit_status, const char *file,
482255acc8fcSmrg	       int line, const char *mode,
4823d63fdb69Smrg	       const char *message, va_list ap)
4824d63fdb69Smrg{
482555acc8fcSmrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
4826d63fdb69Smrg  vfprintf (stderr, message, ap);
4827d63fdb69Smrg  fprintf (stderr, ".\n");
48283da084b3Smrg
4829d63fdb69Smrg  if (exit_status >= 0)
4830d63fdb69Smrg    exit (exit_status);
4831d63fdb69Smrg}
48323da084b3Smrg
4833d63fdb69Smrgvoid
483455acc8fcSmrglt_fatal (const char *file, int line, const char *message, ...)
4835d63fdb69Smrg{
4836d63fdb69Smrg  va_list ap;
4837d63fdb69Smrg  va_start (ap, message);
483855acc8fcSmrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
4839d63fdb69Smrg  va_end (ap);
4840d63fdb69Smrg}
48413da084b3Smrg
484255acc8fcSmrgstatic const char *
484355acc8fcSmrgnonnull (const char *s)
484455acc8fcSmrg{
484555acc8fcSmrg  return s ? s : "(null)";
484655acc8fcSmrg}
484755acc8fcSmrg
484855acc8fcSmrgstatic const char *
484955acc8fcSmrgnonempty (const char *s)
485055acc8fcSmrg{
485155acc8fcSmrg  return (s && !*s) ? "(empty)" : nonnull (s);
485255acc8fcSmrg}
485355acc8fcSmrg
4854d63fdb69Smrgvoid
4855d63fdb69Smrglt_setenv (const char *name, const char *value)
4856d63fdb69Smrg{
485755acc8fcSmrg  lt_debugprintf (__FILE__, __LINE__,
485855acc8fcSmrg		  "(lt_setenv) setting '%s' to '%s'\n",
485955acc8fcSmrg                  nonnull (name), nonnull (value));
4860d63fdb69Smrg  {
4861d63fdb69Smrg#ifdef HAVE_SETENV
4862d63fdb69Smrg    /* always make a copy, for consistency with !HAVE_SETENV */
4863d63fdb69Smrg    char *str = xstrdup (value);
4864d63fdb69Smrg    setenv (name, str, 1);
4865d63fdb69Smrg#else
4866d63fdb69Smrg    int len = strlen (name) + 1 + strlen (value) + 1;
4867d63fdb69Smrg    char *str = XMALLOC (char, len);
4868d63fdb69Smrg    sprintf (str, "%s=%s", name, value);
4869d63fdb69Smrg    if (putenv (str) != EXIT_SUCCESS)
4870d63fdb69Smrg      {
4871d63fdb69Smrg        XFREE (str);
4872d63fdb69Smrg      }
4873d63fdb69Smrg#endif
4874d63fdb69Smrg  }
4875d63fdb69Smrg}
48763da084b3Smrg
4877d63fdb69Smrgchar *
4878d63fdb69Smrglt_extend_str (const char *orig_value, const char *add, int to_end)
4879d63fdb69Smrg{
4880d63fdb69Smrg  char *new_value;
4881d63fdb69Smrg  if (orig_value && *orig_value)
4882d63fdb69Smrg    {
4883d63fdb69Smrg      int orig_value_len = strlen (orig_value);
4884d63fdb69Smrg      int add_len = strlen (add);
4885d63fdb69Smrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
4886d63fdb69Smrg      if (to_end)
4887d63fdb69Smrg        {
4888d63fdb69Smrg          strcpy (new_value, orig_value);
4889d63fdb69Smrg          strcpy (new_value + orig_value_len, add);
4890d63fdb69Smrg        }
4891d63fdb69Smrg      else
4892d63fdb69Smrg        {
4893d63fdb69Smrg          strcpy (new_value, add);
4894d63fdb69Smrg          strcpy (new_value + add_len, orig_value);
4895d63fdb69Smrg        }
4896d63fdb69Smrg    }
4897d63fdb69Smrg  else
4898d63fdb69Smrg    {
4899d63fdb69Smrg      new_value = xstrdup (add);
4900d63fdb69Smrg    }
4901d63fdb69Smrg  return new_value;
4902d63fdb69Smrg}
49033da084b3Smrg
4904d63fdb69Smrgvoid
4905d63fdb69Smrglt_update_exe_path (const char *name, const char *value)
4906d63fdb69Smrg{
490755acc8fcSmrg  lt_debugprintf (__FILE__, __LINE__,
490855acc8fcSmrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
490955acc8fcSmrg                  nonnull (name), nonnull (value));
49103da084b3Smrg
4911d63fdb69Smrg  if (name && *name && value && *value)
4912d63fdb69Smrg    {
4913d63fdb69Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
4914d63fdb69Smrg      /* some systems can't cope with a ':'-terminated path #' */
4915d63fdb69Smrg      int len = strlen (new_value);
4916d63fdb69Smrg      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
4917d63fdb69Smrg        {
4918d63fdb69Smrg          new_value[len-1] = '\0';
4919d63fdb69Smrg        }
4920d63fdb69Smrg      lt_setenv (name, new_value);
4921d63fdb69Smrg      XFREE (new_value);
4922d63fdb69Smrg    }
4923d63fdb69Smrg}
49243da084b3Smrg
4925d63fdb69Smrgvoid
4926d63fdb69Smrglt_update_lib_path (const char *name, const char *value)
4927d63fdb69Smrg{
492855acc8fcSmrg  lt_debugprintf (__FILE__, __LINE__,
492955acc8fcSmrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
493055acc8fcSmrg                  nonnull (name), nonnull (value));
49313da084b3Smrg
4932d63fdb69Smrg  if (name && *name && value && *value)
4933d63fdb69Smrg    {
4934d63fdb69Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
4935d63fdb69Smrg      lt_setenv (name, new_value);
4936d63fdb69Smrg      XFREE (new_value);
4937d63fdb69Smrg    }
4938d63fdb69Smrg}
49393da084b3Smrg
494055acc8fcSmrgEOF
494155acc8fcSmrg	    case $host_os in
494255acc8fcSmrg	      mingw*)
494355acc8fcSmrg		cat <<"EOF"
494455acc8fcSmrg
494555acc8fcSmrg/* Prepares an argument vector before calling spawn().
494655acc8fcSmrg   Note that spawn() does not by itself call the command interpreter
494755acc8fcSmrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
494855acc8fcSmrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
494955acc8fcSmrg         GetVersionEx(&v);
495055acc8fcSmrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
495155acc8fcSmrg      }) ? "cmd.exe" : "command.com").
495255acc8fcSmrg   Instead it simply concatenates the arguments, separated by ' ', and calls
495355acc8fcSmrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
495455acc8fcSmrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
495555acc8fcSmrg   special way:
495655acc8fcSmrg   - Space and tab are interpreted as delimiters. They are not treated as
495755acc8fcSmrg     delimiters if they are surrounded by double quotes: "...".
495855acc8fcSmrg   - Unescaped double quotes are removed from the input. Their only effect is
495955acc8fcSmrg     that within double quotes, space and tab are treated like normal
496055acc8fcSmrg     characters.
496155acc8fcSmrg   - Backslashes not followed by double quotes are not special.
496255acc8fcSmrg   - But 2*n+1 backslashes followed by a double quote become
496355acc8fcSmrg     n backslashes followed by a double quote (n >= 0):
496455acc8fcSmrg       \" -> "
496555acc8fcSmrg       \\\" -> \"
496655acc8fcSmrg       \\\\\" -> \\"
496755acc8fcSmrg */
496855acc8fcSmrg#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"
496955acc8fcSmrg#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"
497055acc8fcSmrgchar **
497155acc8fcSmrgprepare_spawn (char **argv)
497255acc8fcSmrg{
497355acc8fcSmrg  size_t argc;
497455acc8fcSmrg  char **new_argv;
497555acc8fcSmrg  size_t i;
497655acc8fcSmrg
497755acc8fcSmrg  /* Count number of arguments.  */
497855acc8fcSmrg  for (argc = 0; argv[argc] != NULL; argc++)
497955acc8fcSmrg    ;
498055acc8fcSmrg
498155acc8fcSmrg  /* Allocate new argument vector.  */
498255acc8fcSmrg  new_argv = XMALLOC (char *, argc + 1);
498355acc8fcSmrg
498455acc8fcSmrg  /* Put quoted arguments into the new argument vector.  */
498555acc8fcSmrg  for (i = 0; i < argc; i++)
498655acc8fcSmrg    {
498755acc8fcSmrg      const char *string = argv[i];
498855acc8fcSmrg
498955acc8fcSmrg      if (string[0] == '\0')
499055acc8fcSmrg	new_argv[i] = xstrdup ("\"\"");
499155acc8fcSmrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
499255acc8fcSmrg	{
499355acc8fcSmrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
499455acc8fcSmrg	  size_t length;
499555acc8fcSmrg	  unsigned int backslashes;
499655acc8fcSmrg	  const char *s;
499755acc8fcSmrg	  char *quoted_string;
499855acc8fcSmrg	  char *p;
499955acc8fcSmrg
500055acc8fcSmrg	  length = 0;
500155acc8fcSmrg	  backslashes = 0;
500255acc8fcSmrg	  if (quote_around)
500355acc8fcSmrg	    length++;
500455acc8fcSmrg	  for (s = string; *s != '\0'; s++)
500555acc8fcSmrg	    {
500655acc8fcSmrg	      char c = *s;
500755acc8fcSmrg	      if (c == '"')
500855acc8fcSmrg		length += backslashes + 1;
500955acc8fcSmrg	      length++;
501055acc8fcSmrg	      if (c == '\\')
501155acc8fcSmrg		backslashes++;
501255acc8fcSmrg	      else
501355acc8fcSmrg		backslashes = 0;
501455acc8fcSmrg	    }
501555acc8fcSmrg	  if (quote_around)
501655acc8fcSmrg	    length += backslashes + 1;
501755acc8fcSmrg
501855acc8fcSmrg	  quoted_string = XMALLOC (char, length + 1);
501955acc8fcSmrg
502055acc8fcSmrg	  p = quoted_string;
502155acc8fcSmrg	  backslashes = 0;
502255acc8fcSmrg	  if (quote_around)
502355acc8fcSmrg	    *p++ = '"';
502455acc8fcSmrg	  for (s = string; *s != '\0'; s++)
502555acc8fcSmrg	    {
502655acc8fcSmrg	      char c = *s;
502755acc8fcSmrg	      if (c == '"')
502855acc8fcSmrg		{
502955acc8fcSmrg		  unsigned int j;
503055acc8fcSmrg		  for (j = backslashes + 1; j > 0; j--)
503155acc8fcSmrg		    *p++ = '\\';
503255acc8fcSmrg		}
503355acc8fcSmrg	      *p++ = c;
503455acc8fcSmrg	      if (c == '\\')
503555acc8fcSmrg		backslashes++;
503655acc8fcSmrg	      else
503755acc8fcSmrg		backslashes = 0;
503855acc8fcSmrg	    }
503955acc8fcSmrg	  if (quote_around)
504055acc8fcSmrg	    {
504155acc8fcSmrg	      unsigned int j;
504255acc8fcSmrg	      for (j = backslashes; j > 0; j--)
504355acc8fcSmrg		*p++ = '\\';
504455acc8fcSmrg	      *p++ = '"';
504555acc8fcSmrg	    }
504655acc8fcSmrg	  *p = '\0';
504755acc8fcSmrg
504855acc8fcSmrg	  new_argv[i] = quoted_string;
504955acc8fcSmrg	}
505055acc8fcSmrg      else
505155acc8fcSmrg	new_argv[i] = (char *) string;
505255acc8fcSmrg    }
505355acc8fcSmrg  new_argv[argc] = NULL;
505455acc8fcSmrg
505555acc8fcSmrg  return new_argv;
505655acc8fcSmrg}
505755acc8fcSmrgEOF
505855acc8fcSmrg		;;
505955acc8fcSmrg	    esac
506055acc8fcSmrg
506155acc8fcSmrg            cat <<"EOF"
506255acc8fcSmrgvoid lt_dump_script (FILE* f)
506355acc8fcSmrg{
506455acc8fcSmrgEOF
506555acc8fcSmrg	    func_emit_wrapper yes |
506648c85eb7Smrg	      $SED -n -e '
506748c85eb7Smrgs/^\(.\{79\}\)\(..*\)/\1\
506848c85eb7Smrg\2/
506948c85eb7Smrgh
507048c85eb7Smrgs/\([\\"]\)/\\\1/g
507148c85eb7Smrgs/$/\\n/
507248c85eb7Smrgs/\([^\n]*\).*/  fputs ("\1", f);/p
507348c85eb7Smrgg
507448c85eb7SmrgD'
507555acc8fcSmrg            cat <<"EOF"
507655acc8fcSmrg}
5077d63fdb69SmrgEOF
5078d63fdb69Smrg}
5079d63fdb69Smrg# end: func_emit_cwrapperexe_src
50803da084b3Smrg
508155acc8fcSmrg# func_win32_import_lib_p ARG
508255acc8fcSmrg# True if ARG is an import lib, as indicated by $file_magic_cmd
508355acc8fcSmrgfunc_win32_import_lib_p ()
508455acc8fcSmrg{
508555acc8fcSmrg    $opt_debug
508655acc8fcSmrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
508755acc8fcSmrg    *import*) : ;;
508855acc8fcSmrg    *) false ;;
508955acc8fcSmrg    esac
509055acc8fcSmrg}
509155acc8fcSmrg
5092d63fdb69Smrg# func_mode_link arg...
5093d63fdb69Smrgfunc_mode_link ()
5094d63fdb69Smrg{
5095d63fdb69Smrg    $opt_debug
5096d63fdb69Smrg    case $host in
5097d63fdb69Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5098d63fdb69Smrg      # It is impossible to link a dll without this setting, and
5099d63fdb69Smrg      # we shouldn't force the makefile maintainer to figure out
5100d63fdb69Smrg      # which system we are compiling for in order to pass an extra
5101d63fdb69Smrg      # flag for every libtool invocation.
5102d63fdb69Smrg      # allow_undefined=no
51033da084b3Smrg
5104d63fdb69Smrg      # FIXME: Unfortunately, there are problems with the above when trying
5105d63fdb69Smrg      # to make a dll which has undefined symbols, in which case not
5106d63fdb69Smrg      # even a static library is built.  For now, we need to specify
5107d63fdb69Smrg      # -no-undefined on the libtool link line when we can be certain
5108d63fdb69Smrg      # that all symbols are satisfied, otherwise we get a static library.
5109d63fdb69Smrg      allow_undefined=yes
5110d63fdb69Smrg      ;;
5111d63fdb69Smrg    *)
5112d63fdb69Smrg      allow_undefined=yes
5113d63fdb69Smrg      ;;
5114d63fdb69Smrg    esac
5115d63fdb69Smrg    libtool_args=$nonopt
5116d63fdb69Smrg    base_compile="$nonopt $@"
5117d63fdb69Smrg    compile_command=$nonopt
5118d63fdb69Smrg    finalize_command=$nonopt
51193da084b3Smrg
5120d63fdb69Smrg    compile_rpath=
5121d63fdb69Smrg    finalize_rpath=
5122d63fdb69Smrg    compile_shlibpath=
5123d63fdb69Smrg    finalize_shlibpath=
5124d63fdb69Smrg    convenience=
5125d63fdb69Smrg    old_convenience=
5126d63fdb69Smrg    deplibs=
5127d63fdb69Smrg    old_deplibs=
5128d63fdb69Smrg    compiler_flags=
5129d63fdb69Smrg    linker_flags=
5130d63fdb69Smrg    dllsearchpath=
5131d63fdb69Smrg    lib_search_path=`pwd`
5132d63fdb69Smrg    inst_prefix_dir=
5133d63fdb69Smrg    new_inherited_linker_flags=
51343da084b3Smrg
5135d63fdb69Smrg    avoid_version=no
513655acc8fcSmrg    bindir=
5137d63fdb69Smrg    dlfiles=
5138d63fdb69Smrg    dlprefiles=
5139d63fdb69Smrg    dlself=no
5140d63fdb69Smrg    export_dynamic=no
5141d63fdb69Smrg    export_symbols=
5142d63fdb69Smrg    export_symbols_regex=
5143d63fdb69Smrg    generated=
5144d63fdb69Smrg    libobjs=
5145d63fdb69Smrg    ltlibs=
5146d63fdb69Smrg    module=no
5147d63fdb69Smrg    no_install=no
5148d63fdb69Smrg    objs=
5149d63fdb69Smrg    non_pic_objects=
5150d63fdb69Smrg    precious_files_regex=
5151d63fdb69Smrg    prefer_static_libs=no
5152d63fdb69Smrg    preload=no
5153d63fdb69Smrg    prev=
5154d63fdb69Smrg    prevarg=
5155d63fdb69Smrg    release=
5156d63fdb69Smrg    rpath=
5157d63fdb69Smrg    xrpath=
5158d63fdb69Smrg    perm_rpath=
5159d63fdb69Smrg    temp_rpath=
5160d63fdb69Smrg    thread_safe=no
5161d63fdb69Smrg    vinfo=
5162d63fdb69Smrg    vinfo_number=no
5163d63fdb69Smrg    weak_libs=
5164d63fdb69Smrg    single_module="${wl}-single_module"
5165d63fdb69Smrg    func_infer_tag $base_compile
51663da084b3Smrg
5167d63fdb69Smrg    # We need to know -static, to get the right output filenames.
5168d63fdb69Smrg    for arg
5169d63fdb69Smrg    do
5170d63fdb69Smrg      case $arg in
5171d63fdb69Smrg      -shared)
5172d63fdb69Smrg	test "$build_libtool_libs" != yes && \
5173d63fdb69Smrg	  func_fatal_configuration "can not build a shared library"
5174d63fdb69Smrg	build_old_libs=no
5175d63fdb69Smrg	break
5176d63fdb69Smrg	;;
5177d63fdb69Smrg      -all-static | -static | -static-libtool-libs)
5178d63fdb69Smrg	case $arg in
5179d63fdb69Smrg	-all-static)
5180d63fdb69Smrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
5181d63fdb69Smrg	    func_warning "complete static linking is impossible in this configuration"
51823da084b3Smrg	  fi
5183d63fdb69Smrg	  if test -n "$link_static_flag"; then
5184d63fdb69Smrg	    dlopen_self=$dlopen_self_static
51853da084b3Smrg	  fi
5186d63fdb69Smrg	  prefer_static_libs=yes
51873da084b3Smrg	  ;;
5188d63fdb69Smrg	-static)
5189d63fdb69Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5190d63fdb69Smrg	    dlopen_self=$dlopen_self_static
5191d63fdb69Smrg	  fi
5192d63fdb69Smrg	  prefer_static_libs=built
5193d63fdb69Smrg	  ;;
5194d63fdb69Smrg	-static-libtool-libs)
5195d63fdb69Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5196d63fdb69Smrg	    dlopen_self=$dlopen_self_static
5197d63fdb69Smrg	  fi
5198d63fdb69Smrg	  prefer_static_libs=yes
51993da084b3Smrg	  ;;
52003da084b3Smrg	esac
5201d63fdb69Smrg	build_libtool_libs=no
5202d63fdb69Smrg	build_old_libs=yes
5203d63fdb69Smrg	break
5204d63fdb69Smrg	;;
5205d63fdb69Smrg      esac
5206d63fdb69Smrg    done
52073da084b3Smrg
5208d63fdb69Smrg    # See if our shared archives depend on static archives.
5209d63fdb69Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
52103da084b3Smrg
5211d63fdb69Smrg    # Go through the arguments, transforming them on the way.
5212d63fdb69Smrg    while test "$#" -gt 0; do
5213d63fdb69Smrg      arg="$1"
5214d63fdb69Smrg      shift
5215d63fdb69Smrg      func_quote_for_eval "$arg"
5216d63fdb69Smrg      qarg=$func_quote_for_eval_unquoted_result
5217d63fdb69Smrg      func_append libtool_args " $func_quote_for_eval_result"
52183da084b3Smrg
5219d63fdb69Smrg      # If the previous option needs an argument, assign it.
5220d63fdb69Smrg      if test -n "$prev"; then
5221d63fdb69Smrg	case $prev in
5222d63fdb69Smrg	output)
5223d63fdb69Smrg	  func_append compile_command " @OUTPUT@"
5224d63fdb69Smrg	  func_append finalize_command " @OUTPUT@"
5225d63fdb69Smrg	  ;;
5226d63fdb69Smrg	esac
52273da084b3Smrg
5228d63fdb69Smrg	case $prev in
522955acc8fcSmrg	bindir)
523055acc8fcSmrg	  bindir="$arg"
523155acc8fcSmrg	  prev=
523255acc8fcSmrg	  continue
523355acc8fcSmrg	  ;;
5234d63fdb69Smrg	dlfiles|dlprefiles)
5235d63fdb69Smrg	  if test "$preload" = no; then
5236d63fdb69Smrg	    # Add the symbol object into the linking commands.
5237d63fdb69Smrg	    func_append compile_command " @SYMFILE@"
5238d63fdb69Smrg	    func_append finalize_command " @SYMFILE@"
5239d63fdb69Smrg	    preload=yes
5240d63fdb69Smrg	  fi
5241d63fdb69Smrg	  case $arg in
5242d63fdb69Smrg	  *.la | *.lo) ;;  # We handle these cases below.
5243d63fdb69Smrg	  force)
5244d63fdb69Smrg	    if test "$dlself" = no; then
5245d63fdb69Smrg	      dlself=needless
5246d63fdb69Smrg	      export_dynamic=yes
5247d63fdb69Smrg	    fi
5248d63fdb69Smrg	    prev=
5249d63fdb69Smrg	    continue
5250d63fdb69Smrg	    ;;
5251d63fdb69Smrg	  self)
5252d63fdb69Smrg	    if test "$prev" = dlprefiles; then
5253d63fdb69Smrg	      dlself=yes
5254d63fdb69Smrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
5255d63fdb69Smrg	      dlself=yes
5256d63fdb69Smrg	    else
5257d63fdb69Smrg	      dlself=needless
5258d63fdb69Smrg	      export_dynamic=yes
5259d63fdb69Smrg	    fi
5260d63fdb69Smrg	    prev=
5261d63fdb69Smrg	    continue
52623da084b3Smrg	    ;;
52633da084b3Smrg	  *)
5264d63fdb69Smrg	    if test "$prev" = dlfiles; then
526548c85eb7Smrg	      func_append dlfiles " $arg"
5266d63fdb69Smrg	    else
526748c85eb7Smrg	      func_append dlprefiles " $arg"
5268d63fdb69Smrg	    fi
5269d63fdb69Smrg	    prev=
5270d63fdb69Smrg	    continue
52713da084b3Smrg	    ;;
52723da084b3Smrg	  esac
5273d63fdb69Smrg	  ;;
5274d63fdb69Smrg	expsyms)
5275d63fdb69Smrg	  export_symbols="$arg"
5276d63fdb69Smrg	  test -f "$arg" \
5277d63fdb69Smrg	    || func_fatal_error "symbol file \`$arg' does not exist"
5278d63fdb69Smrg	  prev=
5279d63fdb69Smrg	  continue
5280d63fdb69Smrg	  ;;
5281d63fdb69Smrg	expsyms_regex)
5282d63fdb69Smrg	  export_symbols_regex="$arg"
5283d63fdb69Smrg	  prev=
5284d63fdb69Smrg	  continue
5285d63fdb69Smrg	  ;;
5286d63fdb69Smrg	framework)
5287d63fdb69Smrg	  case $host in
5288d63fdb69Smrg	    *-*-darwin*)
5289d63fdb69Smrg	      case "$deplibs " in
5290d63fdb69Smrg		*" $qarg.ltframework "*) ;;
529148c85eb7Smrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
5292d63fdb69Smrg		   ;;
5293d63fdb69Smrg	      esac
5294d63fdb69Smrg	      ;;
5295d63fdb69Smrg	  esac
5296d63fdb69Smrg	  prev=
5297d63fdb69Smrg	  continue
5298d63fdb69Smrg	  ;;
5299d63fdb69Smrg	inst_prefix)
5300d63fdb69Smrg	  inst_prefix_dir="$arg"
5301d63fdb69Smrg	  prev=
5302d63fdb69Smrg	  continue
5303d63fdb69Smrg	  ;;
5304d63fdb69Smrg	objectlist)
5305d63fdb69Smrg	  if test -f "$arg"; then
5306d63fdb69Smrg	    save_arg=$arg
5307d63fdb69Smrg	    moreargs=
5308d63fdb69Smrg	    for fil in `cat "$save_arg"`
5309d63fdb69Smrg	    do
531048c85eb7Smrg#	      func_append moreargs " $fil"
5311d63fdb69Smrg	      arg=$fil
5312d63fdb69Smrg	      # A libtool-controlled object.
53133da084b3Smrg
5314d63fdb69Smrg	      # Check to see that this really is a libtool object.
5315d63fdb69Smrg	      if func_lalib_unsafe_p "$arg"; then
5316d63fdb69Smrg		pic_object=
5317d63fdb69Smrg		non_pic_object=
53183da084b3Smrg
5319d63fdb69Smrg		# Read the .lo file
5320d63fdb69Smrg		func_source "$arg"
53213da084b3Smrg
5322d63fdb69Smrg		if test -z "$pic_object" ||
5323d63fdb69Smrg		   test -z "$non_pic_object" ||
5324d63fdb69Smrg		   test "$pic_object" = none &&
5325d63fdb69Smrg		   test "$non_pic_object" = none; then
5326d63fdb69Smrg		  func_fatal_error "cannot find name of object for \`$arg'"
5327d63fdb69Smrg		fi
53283da084b3Smrg
5329d63fdb69Smrg		# Extract subdirectory from the argument.
5330d63fdb69Smrg		func_dirname "$arg" "/" ""
5331d63fdb69Smrg		xdir="$func_dirname_result"
53323da084b3Smrg
5333d63fdb69Smrg		if test "$pic_object" != none; then
5334d63fdb69Smrg		  # Prepend the subdirectory the object is found in.
5335d63fdb69Smrg		  pic_object="$xdir$pic_object"
53363da084b3Smrg
5337d63fdb69Smrg		  if test "$prev" = dlfiles; then
5338d63fdb69Smrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
533948c85eb7Smrg		      func_append dlfiles " $pic_object"
5340d63fdb69Smrg		      prev=
5341d63fdb69Smrg		      continue
5342d63fdb69Smrg		    else
5343d63fdb69Smrg		      # If libtool objects are unsupported, then we need to preload.
5344d63fdb69Smrg		      prev=dlprefiles
5345d63fdb69Smrg		    fi
5346d63fdb69Smrg		  fi
53473da084b3Smrg
5348d63fdb69Smrg		  # CHECK ME:  I think I busted this.  -Ossama
5349d63fdb69Smrg		  if test "$prev" = dlprefiles; then
5350d63fdb69Smrg		    # Preload the old-style object.
535148c85eb7Smrg		    func_append dlprefiles " $pic_object"
5352d63fdb69Smrg		    prev=
5353d63fdb69Smrg		  fi
53543da084b3Smrg
5355d63fdb69Smrg		  # A PIC object.
5356d63fdb69Smrg		  func_append libobjs " $pic_object"
5357d63fdb69Smrg		  arg="$pic_object"
5358d63fdb69Smrg		fi
53593da084b3Smrg
5360d63fdb69Smrg		# Non-PIC object.
5361d63fdb69Smrg		if test "$non_pic_object" != none; then
5362d63fdb69Smrg		  # Prepend the subdirectory the object is found in.
5363d63fdb69Smrg		  non_pic_object="$xdir$non_pic_object"
53643da084b3Smrg
5365d63fdb69Smrg		  # A standard non-PIC object
5366d63fdb69Smrg		  func_append non_pic_objects " $non_pic_object"
5367d63fdb69Smrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
5368d63fdb69Smrg		    arg="$non_pic_object"
5369d63fdb69Smrg		  fi
5370d63fdb69Smrg		else
5371d63fdb69Smrg		  # If the PIC object exists, use it instead.
5372d63fdb69Smrg		  # $xdir was prepended to $pic_object above.
5373d63fdb69Smrg		  non_pic_object="$pic_object"
5374d63fdb69Smrg		  func_append non_pic_objects " $non_pic_object"
5375d63fdb69Smrg		fi
5376d63fdb69Smrg	      else
5377d63fdb69Smrg		# Only an error if not doing a dry-run.
5378d63fdb69Smrg		if $opt_dry_run; then
5379d63fdb69Smrg		  # Extract subdirectory from the argument.
5380d63fdb69Smrg		  func_dirname "$arg" "/" ""
5381d63fdb69Smrg		  xdir="$func_dirname_result"
5382d63fdb69Smrg
5383d63fdb69Smrg		  func_lo2o "$arg"
5384d63fdb69Smrg		  pic_object=$xdir$objdir/$func_lo2o_result
5385d63fdb69Smrg		  non_pic_object=$xdir$func_lo2o_result
5386d63fdb69Smrg		  func_append libobjs " $pic_object"
5387d63fdb69Smrg		  func_append non_pic_objects " $non_pic_object"
5388d63fdb69Smrg	        else
5389d63fdb69Smrg		  func_fatal_error "\`$arg' is not a valid libtool object"
5390d63fdb69Smrg		fi
5391d63fdb69Smrg	      fi
5392d63fdb69Smrg	    done
5393d63fdb69Smrg	  else
5394d63fdb69Smrg	    func_fatal_error "link input file \`$arg' does not exist"
5395d63fdb69Smrg	  fi
5396d63fdb69Smrg	  arg=$save_arg
5397d63fdb69Smrg	  prev=
5398d63fdb69Smrg	  continue
5399d63fdb69Smrg	  ;;
5400d63fdb69Smrg	precious_regex)
5401d63fdb69Smrg	  precious_files_regex="$arg"
5402d63fdb69Smrg	  prev=
5403d63fdb69Smrg	  continue
5404d63fdb69Smrg	  ;;
5405d63fdb69Smrg	release)
5406d63fdb69Smrg	  release="-$arg"
5407d63fdb69Smrg	  prev=
5408d63fdb69Smrg	  continue
5409d63fdb69Smrg	  ;;
5410d63fdb69Smrg	rpath | xrpath)
5411d63fdb69Smrg	  # We need an absolute path.
5412d63fdb69Smrg	  case $arg in
5413d63fdb69Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
5414d63fdb69Smrg	  *)
5415d63fdb69Smrg	    func_fatal_error "only absolute run-paths are allowed"
5416d63fdb69Smrg	    ;;
5417d63fdb69Smrg	  esac
5418d63fdb69Smrg	  if test "$prev" = rpath; then
5419d63fdb69Smrg	    case "$rpath " in
5420d63fdb69Smrg	    *" $arg "*) ;;
542148c85eb7Smrg	    *) func_append rpath " $arg" ;;
5422d63fdb69Smrg	    esac
5423d63fdb69Smrg	  else
5424d63fdb69Smrg	    case "$xrpath " in
5425d63fdb69Smrg	    *" $arg "*) ;;
542648c85eb7Smrg	    *) func_append xrpath " $arg" ;;
5427d63fdb69Smrg	    esac
5428d63fdb69Smrg	  fi
5429d63fdb69Smrg	  prev=
5430d63fdb69Smrg	  continue
5431d63fdb69Smrg	  ;;
5432d63fdb69Smrg	shrext)
5433d63fdb69Smrg	  shrext_cmds="$arg"
5434d63fdb69Smrg	  prev=
5435d63fdb69Smrg	  continue
5436d63fdb69Smrg	  ;;
5437d63fdb69Smrg	weak)
543848c85eb7Smrg	  func_append weak_libs " $arg"
5439d63fdb69Smrg	  prev=
5440d63fdb69Smrg	  continue
5441d63fdb69Smrg	  ;;
5442d63fdb69Smrg	xcclinker)
544348c85eb7Smrg	  func_append linker_flags " $qarg"
544448c85eb7Smrg	  func_append compiler_flags " $qarg"
5445d63fdb69Smrg	  prev=
5446d63fdb69Smrg	  func_append compile_command " $qarg"
5447d63fdb69Smrg	  func_append finalize_command " $qarg"
5448d63fdb69Smrg	  continue
5449d63fdb69Smrg	  ;;
5450d63fdb69Smrg	xcompiler)
545148c85eb7Smrg	  func_append compiler_flags " $qarg"
5452d63fdb69Smrg	  prev=
5453d63fdb69Smrg	  func_append compile_command " $qarg"
5454d63fdb69Smrg	  func_append finalize_command " $qarg"
5455d63fdb69Smrg	  continue
5456d63fdb69Smrg	  ;;
5457d63fdb69Smrg	xlinker)
545848c85eb7Smrg	  func_append linker_flags " $qarg"
545948c85eb7Smrg	  func_append compiler_flags " $wl$qarg"
5460d63fdb69Smrg	  prev=
5461d63fdb69Smrg	  func_append compile_command " $wl$qarg"
5462d63fdb69Smrg	  func_append finalize_command " $wl$qarg"
5463d63fdb69Smrg	  continue
5464d63fdb69Smrg	  ;;
5465d63fdb69Smrg	*)
5466d63fdb69Smrg	  eval "$prev=\"\$arg\""
5467d63fdb69Smrg	  prev=
5468d63fdb69Smrg	  continue
5469d63fdb69Smrg	  ;;
54703da084b3Smrg	esac
5471d63fdb69Smrg      fi # test -n "$prev"
54723da084b3Smrg
5473d63fdb69Smrg      prevarg="$arg"
54743da084b3Smrg
5475d63fdb69Smrg      case $arg in
5476d63fdb69Smrg      -all-static)
5477d63fdb69Smrg	if test -n "$link_static_flag"; then
5478d63fdb69Smrg	  # See comment for -static flag below, for more details.
5479d63fdb69Smrg	  func_append compile_command " $link_static_flag"
5480d63fdb69Smrg	  func_append finalize_command " $link_static_flag"
5481d63fdb69Smrg	fi
5482d63fdb69Smrg	continue
5483d63fdb69Smrg	;;
54843da084b3Smrg
5485d63fdb69Smrg      -allow-undefined)
5486d63fdb69Smrg	# FIXME: remove this flag sometime in the future.
5487d63fdb69Smrg	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
5488d63fdb69Smrg	;;
54893da084b3Smrg
5490d63fdb69Smrg      -avoid-version)
5491d63fdb69Smrg	avoid_version=yes
5492d63fdb69Smrg	continue
5493d63fdb69Smrg	;;
54943da084b3Smrg
549555acc8fcSmrg      -bindir)
549655acc8fcSmrg	prev=bindir
549755acc8fcSmrg	continue
549855acc8fcSmrg	;;
549955acc8fcSmrg
5500d63fdb69Smrg      -dlopen)
5501d63fdb69Smrg	prev=dlfiles
5502d63fdb69Smrg	continue
5503d63fdb69Smrg	;;
55043da084b3Smrg
5505d63fdb69Smrg      -dlpreopen)
5506d63fdb69Smrg	prev=dlprefiles
5507d63fdb69Smrg	continue
5508d63fdb69Smrg	;;
55093da084b3Smrg
5510d63fdb69Smrg      -export-dynamic)
5511d63fdb69Smrg	export_dynamic=yes
5512d63fdb69Smrg	continue
5513d63fdb69Smrg	;;
55143da084b3Smrg
5515d63fdb69Smrg      -export-symbols | -export-symbols-regex)
5516d63fdb69Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
5517d63fdb69Smrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
5518d63fdb69Smrg	fi
5519d63fdb69Smrg	if test "X$arg" = "X-export-symbols"; then
5520d63fdb69Smrg	  prev=expsyms
5521d63fdb69Smrg	else
5522d63fdb69Smrg	  prev=expsyms_regex
5523d63fdb69Smrg	fi
5524d63fdb69Smrg	continue
5525d63fdb69Smrg	;;
55263da084b3Smrg
5527d63fdb69Smrg      -framework)
5528d63fdb69Smrg	prev=framework
5529d63fdb69Smrg	continue
5530d63fdb69Smrg	;;
55313da084b3Smrg
5532d63fdb69Smrg      -inst-prefix-dir)
5533d63fdb69Smrg	prev=inst_prefix
5534d63fdb69Smrg	continue
5535d63fdb69Smrg	;;
55363da084b3Smrg
5537d63fdb69Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
5538d63fdb69Smrg      # so, if we see these flags be careful not to treat them like -L
5539d63fdb69Smrg      -L[A-Z][A-Z]*:*)
5540d63fdb69Smrg	case $with_gcc/$host in
5541d63fdb69Smrg	no/*-*-irix* | /*-*-irix*)
5542d63fdb69Smrg	  func_append compile_command " $arg"
5543d63fdb69Smrg	  func_append finalize_command " $arg"
5544d63fdb69Smrg	  ;;
5545d63fdb69Smrg	esac
5546d63fdb69Smrg	continue
5547d63fdb69Smrg	;;
55483da084b3Smrg
5549d63fdb69Smrg      -L*)
555048c85eb7Smrg	func_stripname "-L" '' "$arg"
555148c85eb7Smrg	if test -z "$func_stripname_result"; then
5552d63fdb69Smrg	  if test "$#" -gt 0; then
5553d63fdb69Smrg	    func_fatal_error "require no space between \`-L' and \`$1'"
5554d63fdb69Smrg	  else
5555d63fdb69Smrg	    func_fatal_error "need path for \`-L' option"
5556d63fdb69Smrg	  fi
5557d63fdb69Smrg	fi
555848c85eb7Smrg	func_resolve_sysroot "$func_stripname_result"
555948c85eb7Smrg	dir=$func_resolve_sysroot_result
5560d63fdb69Smrg	# We need an absolute path.
5561d63fdb69Smrg	case $dir in
5562d63fdb69Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
5563d63fdb69Smrg	*)
5564d63fdb69Smrg	  absdir=`cd "$dir" && pwd`
5565d63fdb69Smrg	  test -z "$absdir" && \
5566d63fdb69Smrg	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
5567d63fdb69Smrg	  dir="$absdir"
5568d63fdb69Smrg	  ;;
5569d63fdb69Smrg	esac
5570d63fdb69Smrg	case "$deplibs " in
557148c85eb7Smrg	*" -L$dir "* | *" $arg "*)
557248c85eb7Smrg	  # Will only happen for absolute or sysroot arguments
557348c85eb7Smrg	  ;;
5574d63fdb69Smrg	*)
557548c85eb7Smrg	  # Preserve sysroot, but never include relative directories
557648c85eb7Smrg	  case $dir in
557748c85eb7Smrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
557848c85eb7Smrg	    *) func_append deplibs " -L$dir" ;;
557948c85eb7Smrg	  esac
558048c85eb7Smrg	  func_append lib_search_path " $dir"
5581d63fdb69Smrg	  ;;
5582d63fdb69Smrg	esac
5583d63fdb69Smrg	case $host in
5584d63fdb69Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
558555acc8fcSmrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
5586d63fdb69Smrg	  case :$dllsearchpath: in
5587d63fdb69Smrg	  *":$dir:"*) ;;
5588d63fdb69Smrg	  ::) dllsearchpath=$dir;;
558948c85eb7Smrg	  *) func_append dllsearchpath ":$dir";;
5590d63fdb69Smrg	  esac
5591d63fdb69Smrg	  case :$dllsearchpath: in
5592d63fdb69Smrg	  *":$testbindir:"*) ;;
5593d63fdb69Smrg	  ::) dllsearchpath=$testbindir;;
559448c85eb7Smrg	  *) func_append dllsearchpath ":$testbindir";;
5595d63fdb69Smrg	  esac
5596d63fdb69Smrg	  ;;
5597d63fdb69Smrg	esac
5598d63fdb69Smrg	continue
5599d63fdb69Smrg	;;
56003da084b3Smrg
5601d63fdb69Smrg      -l*)
5602d63fdb69Smrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
5603d63fdb69Smrg	  case $host in
560455acc8fcSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
5605d63fdb69Smrg	    # These systems don't actually have a C or math library (as such)
5606d63fdb69Smrg	    continue
5607d63fdb69Smrg	    ;;
5608d63fdb69Smrg	  *-*-os2*)
5609d63fdb69Smrg	    # These systems don't actually have a C library (as such)
5610d63fdb69Smrg	    test "X$arg" = "X-lc" && continue
5611d63fdb69Smrg	    ;;
5612d63fdb69Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5613d63fdb69Smrg	    # Do not include libc due to us having libc/libc_r.
5614d63fdb69Smrg	    test "X$arg" = "X-lc" && continue
5615d63fdb69Smrg	    ;;
5616d63fdb69Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
5617d63fdb69Smrg	    # Rhapsody C and math libraries are in the System framework
561848c85eb7Smrg	    func_append deplibs " System.ltframework"
5619d63fdb69Smrg	    continue
5620d63fdb69Smrg	    ;;
5621d63fdb69Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
5622d63fdb69Smrg	    # Causes problems with __ctype
5623d63fdb69Smrg	    test "X$arg" = "X-lc" && continue
5624d63fdb69Smrg	    ;;
5625d63fdb69Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
5626d63fdb69Smrg	    # Compiler inserts libc in the correct place for threads to work
5627d63fdb69Smrg	    test "X$arg" = "X-lc" && continue
5628d63fdb69Smrg	    ;;
5629d63fdb69Smrg	  esac
5630d63fdb69Smrg	elif test "X$arg" = "X-lc_r"; then
5631d63fdb69Smrg	 case $host in
5632d63fdb69Smrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5633d63fdb69Smrg	   # Do not include libc_r directly, use -pthread flag.
5634d63fdb69Smrg	   continue
5635d63fdb69Smrg	   ;;
5636d63fdb69Smrg	 esac
5637d63fdb69Smrg	fi
563848c85eb7Smrg	func_append deplibs " $arg"
5639d63fdb69Smrg	continue
5640d63fdb69Smrg	;;
56413da084b3Smrg
5642d63fdb69Smrg      -module)
5643d63fdb69Smrg	module=yes
5644d63fdb69Smrg	continue
5645d63fdb69Smrg	;;
56463da084b3Smrg
5647d63fdb69Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
5648d63fdb69Smrg      # classes, name mangling, and exception handling.
5649d63fdb69Smrg      # Darwin uses the -arch flag to determine output architecture.
565048c85eb7Smrg      -model|-arch|-isysroot|--sysroot)
565148c85eb7Smrg	func_append compiler_flags " $arg"
5652d63fdb69Smrg	func_append compile_command " $arg"
5653d63fdb69Smrg	func_append finalize_command " $arg"
5654d63fdb69Smrg	prev=xcompiler
5655d63fdb69Smrg	continue
5656d63fdb69Smrg	;;
56573da084b3Smrg
565848c85eb7Smrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
565948c85eb7Smrg      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
566048c85eb7Smrg	func_append compiler_flags " $arg"
5661d63fdb69Smrg	func_append compile_command " $arg"
5662d63fdb69Smrg	func_append finalize_command " $arg"
5663d63fdb69Smrg	case "$new_inherited_linker_flags " in
5664d63fdb69Smrg	    *" $arg "*) ;;
566548c85eb7Smrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
5666d63fdb69Smrg	esac
5667d63fdb69Smrg	continue
5668d63fdb69Smrg	;;
56693da084b3Smrg
5670d63fdb69Smrg      -multi_module)
5671d63fdb69Smrg	single_module="${wl}-multi_module"
5672d63fdb69Smrg	continue
5673d63fdb69Smrg	;;
56743da084b3Smrg
5675d63fdb69Smrg      -no-fast-install)
5676d63fdb69Smrg	fast_install=no
5677d63fdb69Smrg	continue
5678d63fdb69Smrg	;;
56793da084b3Smrg
5680d63fdb69Smrg      -no-install)
5681d63fdb69Smrg	case $host in
5682d63fdb69Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
5683d63fdb69Smrg	  # The PATH hackery in wrapper scripts is required on Windows
5684d63fdb69Smrg	  # and Darwin in order for the loader to find any dlls it needs.
5685d63fdb69Smrg	  func_warning "\`-no-install' is ignored for $host"
5686d63fdb69Smrg	  func_warning "assuming \`-no-fast-install' instead"
5687d63fdb69Smrg	  fast_install=no
5688d63fdb69Smrg	  ;;
5689d63fdb69Smrg	*) no_install=yes ;;
5690d63fdb69Smrg	esac
5691d63fdb69Smrg	continue
5692d63fdb69Smrg	;;
56933da084b3Smrg
5694d63fdb69Smrg      -no-undefined)
5695d63fdb69Smrg	allow_undefined=no
5696d63fdb69Smrg	continue
5697d63fdb69Smrg	;;
56983da084b3Smrg
5699d63fdb69Smrg      -objectlist)
5700d63fdb69Smrg	prev=objectlist
5701d63fdb69Smrg	continue
5702d63fdb69Smrg	;;
57033da084b3Smrg
5704d63fdb69Smrg      -o) prev=output ;;
57053da084b3Smrg
5706d63fdb69Smrg      -precious-files-regex)
5707d63fdb69Smrg	prev=precious_regex
5708d63fdb69Smrg	continue
5709d63fdb69Smrg	;;
57103da084b3Smrg
5711d63fdb69Smrg      -release)
5712d63fdb69Smrg	prev=release
5713d63fdb69Smrg	continue
5714d63fdb69Smrg	;;
57153da084b3Smrg
5716d63fdb69Smrg      -rpath)
5717d63fdb69Smrg	prev=rpath
5718d63fdb69Smrg	continue
5719d63fdb69Smrg	;;
57203da084b3Smrg
5721d63fdb69Smrg      -R)
5722d63fdb69Smrg	prev=xrpath
5723d63fdb69Smrg	continue
5724d63fdb69Smrg	;;
57253da084b3Smrg
5726d63fdb69Smrg      -R*)
5727d63fdb69Smrg	func_stripname '-R' '' "$arg"
5728d63fdb69Smrg	dir=$func_stripname_result
5729d63fdb69Smrg	# We need an absolute path.
5730d63fdb69Smrg	case $dir in
5731d63fdb69Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
573248c85eb7Smrg	=*)
573348c85eb7Smrg	  func_stripname '=' '' "$dir"
573448c85eb7Smrg	  dir=$lt_sysroot$func_stripname_result
573548c85eb7Smrg	  ;;
5736d63fdb69Smrg	*)
5737d63fdb69Smrg	  func_fatal_error "only absolute run-paths are allowed"
5738d63fdb69Smrg	  ;;
5739d63fdb69Smrg	esac
5740d63fdb69Smrg	case "$xrpath " in
5741d63fdb69Smrg	*" $dir "*) ;;
574248c85eb7Smrg	*) func_append xrpath " $dir" ;;
5743d63fdb69Smrg	esac
5744d63fdb69Smrg	continue
5745d63fdb69Smrg	;;
57463da084b3Smrg
5747d63fdb69Smrg      -shared)
5748d63fdb69Smrg	# The effects of -shared are defined in a previous loop.
5749d63fdb69Smrg	continue
5750d63fdb69Smrg	;;
57513da084b3Smrg
5752d63fdb69Smrg      -shrext)
5753d63fdb69Smrg	prev=shrext
5754d63fdb69Smrg	continue
5755d63fdb69Smrg	;;
57563da084b3Smrg
5757d63fdb69Smrg      -static | -static-libtool-libs)
5758d63fdb69Smrg	# The effects of -static are defined in a previous loop.
5759d63fdb69Smrg	# We used to do the same as -all-static on platforms that
5760d63fdb69Smrg	# didn't have a PIC flag, but the assumption that the effects
5761d63fdb69Smrg	# would be equivalent was wrong.  It would break on at least
5762d63fdb69Smrg	# Digital Unix and AIX.
5763d63fdb69Smrg	continue
5764d63fdb69Smrg	;;
57653da084b3Smrg
5766d63fdb69Smrg      -thread-safe)
5767d63fdb69Smrg	thread_safe=yes
5768d63fdb69Smrg	continue
5769d63fdb69Smrg	;;
57703da084b3Smrg
5771d63fdb69Smrg      -version-info)
5772d63fdb69Smrg	prev=vinfo
5773d63fdb69Smrg	continue
5774d63fdb69Smrg	;;
57753da084b3Smrg
5776d63fdb69Smrg      -version-number)
5777d63fdb69Smrg	prev=vinfo
5778d63fdb69Smrg	vinfo_number=yes
5779d63fdb69Smrg	continue
5780d63fdb69Smrg	;;
57813da084b3Smrg
5782d63fdb69Smrg      -weak)
5783d63fdb69Smrg        prev=weak
5784d63fdb69Smrg	continue
5785d63fdb69Smrg	;;
57863da084b3Smrg
5787d63fdb69Smrg      -Wc,*)
5788d63fdb69Smrg	func_stripname '-Wc,' '' "$arg"
5789d63fdb69Smrg	args=$func_stripname_result
5790d63fdb69Smrg	arg=
5791d63fdb69Smrg	save_ifs="$IFS"; IFS=','
5792d63fdb69Smrg	for flag in $args; do
5793d63fdb69Smrg	  IFS="$save_ifs"
5794d63fdb69Smrg          func_quote_for_eval "$flag"
579548c85eb7Smrg	  func_append arg " $func_quote_for_eval_result"
579648c85eb7Smrg	  func_append compiler_flags " $func_quote_for_eval_result"
5797d63fdb69Smrg	done
5798d63fdb69Smrg	IFS="$save_ifs"
5799d63fdb69Smrg	func_stripname ' ' '' "$arg"
5800d63fdb69Smrg	arg=$func_stripname_result
5801d63fdb69Smrg	;;
58023da084b3Smrg
5803d63fdb69Smrg      -Wl,*)
5804d63fdb69Smrg	func_stripname '-Wl,' '' "$arg"
5805d63fdb69Smrg	args=$func_stripname_result
5806d63fdb69Smrg	arg=
5807d63fdb69Smrg	save_ifs="$IFS"; IFS=','
5808d63fdb69Smrg	for flag in $args; do
5809d63fdb69Smrg	  IFS="$save_ifs"
5810d63fdb69Smrg          func_quote_for_eval "$flag"
581148c85eb7Smrg	  func_append arg " $wl$func_quote_for_eval_result"
581248c85eb7Smrg	  func_append compiler_flags " $wl$func_quote_for_eval_result"
581348c85eb7Smrg	  func_append linker_flags " $func_quote_for_eval_result"
5814d63fdb69Smrg	done
5815d63fdb69Smrg	IFS="$save_ifs"
5816d63fdb69Smrg	func_stripname ' ' '' "$arg"
5817d63fdb69Smrg	arg=$func_stripname_result
5818d63fdb69Smrg	;;
58193da084b3Smrg
5820d63fdb69Smrg      -Xcompiler)
5821d63fdb69Smrg	prev=xcompiler
5822d63fdb69Smrg	continue
5823d63fdb69Smrg	;;
58243da084b3Smrg
5825d63fdb69Smrg      -Xlinker)
5826d63fdb69Smrg	prev=xlinker
5827d63fdb69Smrg	continue
5828d63fdb69Smrg	;;
58293da084b3Smrg
5830d63fdb69Smrg      -XCClinker)
5831d63fdb69Smrg	prev=xcclinker
5832d63fdb69Smrg	continue
5833d63fdb69Smrg	;;
58343da084b3Smrg
5835d63fdb69Smrg      # -msg_* for osf cc
5836d63fdb69Smrg      -msg_*)
5837d63fdb69Smrg	func_quote_for_eval "$arg"
5838d63fdb69Smrg	arg="$func_quote_for_eval_result"
5839d63fdb69Smrg	;;
58403da084b3Smrg
584155acc8fcSmrg      # Flags to be passed through unchanged, with rationale:
584255acc8fcSmrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
584355acc8fcSmrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
584455acc8fcSmrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
584555acc8fcSmrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
584655acc8fcSmrg      # -q*                  compiler args for the IBM compiler
584755acc8fcSmrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
584855acc8fcSmrg      # -F/path              path to uninstalled frameworks, gcc on darwin
584955acc8fcSmrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
585055acc8fcSmrg      # @file                GCC response files
585155acc8fcSmrg      # -tp=*                Portland pgcc target processor selection
585248c85eb7Smrg      # --sysroot=*          for sysroot support
585348c85eb7Smrg      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
5854d63fdb69Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
585548c85eb7Smrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
585648c85eb7Smrg      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
5857d63fdb69Smrg        func_quote_for_eval "$arg"
5858d63fdb69Smrg	arg="$func_quote_for_eval_result"
5859d63fdb69Smrg        func_append compile_command " $arg"
5860d63fdb69Smrg        func_append finalize_command " $arg"
586148c85eb7Smrg        func_append compiler_flags " $arg"
5862d63fdb69Smrg        continue
5863d63fdb69Smrg        ;;
58643da084b3Smrg
5865d63fdb69Smrg      # Some other compiler flag.
5866d63fdb69Smrg      -* | +*)
5867d63fdb69Smrg        func_quote_for_eval "$arg"
5868d63fdb69Smrg	arg="$func_quote_for_eval_result"
5869d63fdb69Smrg	;;
58703da084b3Smrg
5871d63fdb69Smrg      *.$objext)
5872d63fdb69Smrg	# A standard object.
587348c85eb7Smrg	func_append objs " $arg"
5874d63fdb69Smrg	;;
58753da084b3Smrg
5876d63fdb69Smrg      *.lo)
5877d63fdb69Smrg	# A libtool-controlled object.
58783da084b3Smrg
5879d63fdb69Smrg	# Check to see that this really is a libtool object.
5880d63fdb69Smrg	if func_lalib_unsafe_p "$arg"; then
5881d63fdb69Smrg	  pic_object=
5882d63fdb69Smrg	  non_pic_object=
5883d63fdb69Smrg
5884d63fdb69Smrg	  # Read the .lo file
5885d63fdb69Smrg	  func_source "$arg"
5886d63fdb69Smrg
5887d63fdb69Smrg	  if test -z "$pic_object" ||
5888d63fdb69Smrg	     test -z "$non_pic_object" ||
5889d63fdb69Smrg	     test "$pic_object" = none &&
5890d63fdb69Smrg	     test "$non_pic_object" = none; then
5891d63fdb69Smrg	    func_fatal_error "cannot find name of object for \`$arg'"
5892d63fdb69Smrg	  fi
5893d63fdb69Smrg
5894d63fdb69Smrg	  # Extract subdirectory from the argument.
5895d63fdb69Smrg	  func_dirname "$arg" "/" ""
5896d63fdb69Smrg	  xdir="$func_dirname_result"
5897d63fdb69Smrg
5898d63fdb69Smrg	  if test "$pic_object" != none; then
5899d63fdb69Smrg	    # Prepend the subdirectory the object is found in.
5900d63fdb69Smrg	    pic_object="$xdir$pic_object"
5901d63fdb69Smrg
5902d63fdb69Smrg	    if test "$prev" = dlfiles; then
5903d63fdb69Smrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
590448c85eb7Smrg		func_append dlfiles " $pic_object"
5905d63fdb69Smrg		prev=
5906d63fdb69Smrg		continue
5907d63fdb69Smrg	      else
5908d63fdb69Smrg		# If libtool objects are unsupported, then we need to preload.
5909d63fdb69Smrg		prev=dlprefiles
5910d63fdb69Smrg	      fi
5911d63fdb69Smrg	    fi
5912d63fdb69Smrg
5913d63fdb69Smrg	    # CHECK ME:  I think I busted this.  -Ossama
5914d63fdb69Smrg	    if test "$prev" = dlprefiles; then
5915d63fdb69Smrg	      # Preload the old-style object.
591648c85eb7Smrg	      func_append dlprefiles " $pic_object"
5917d63fdb69Smrg	      prev=
5918d63fdb69Smrg	    fi
5919d63fdb69Smrg
5920d63fdb69Smrg	    # A PIC object.
5921d63fdb69Smrg	    func_append libobjs " $pic_object"
5922d63fdb69Smrg	    arg="$pic_object"
5923d63fdb69Smrg	  fi
5924d63fdb69Smrg
5925d63fdb69Smrg	  # Non-PIC object.
5926d63fdb69Smrg	  if test "$non_pic_object" != none; then
5927d63fdb69Smrg	    # Prepend the subdirectory the object is found in.
5928d63fdb69Smrg	    non_pic_object="$xdir$non_pic_object"
5929d63fdb69Smrg
5930d63fdb69Smrg	    # A standard non-PIC object
5931d63fdb69Smrg	    func_append non_pic_objects " $non_pic_object"
5932d63fdb69Smrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
5933d63fdb69Smrg	      arg="$non_pic_object"
5934d63fdb69Smrg	    fi
5935d63fdb69Smrg	  else
5936d63fdb69Smrg	    # If the PIC object exists, use it instead.
5937d63fdb69Smrg	    # $xdir was prepended to $pic_object above.
5938d63fdb69Smrg	    non_pic_object="$pic_object"
5939d63fdb69Smrg	    func_append non_pic_objects " $non_pic_object"
5940d63fdb69Smrg	  fi
5941d63fdb69Smrg	else
5942d63fdb69Smrg	  # Only an error if not doing a dry-run.
5943d63fdb69Smrg	  if $opt_dry_run; then
5944d63fdb69Smrg	    # Extract subdirectory from the argument.
5945d63fdb69Smrg	    func_dirname "$arg" "/" ""
5946d63fdb69Smrg	    xdir="$func_dirname_result"
5947d63fdb69Smrg
5948d63fdb69Smrg	    func_lo2o "$arg"
5949d63fdb69Smrg	    pic_object=$xdir$objdir/$func_lo2o_result
5950d63fdb69Smrg	    non_pic_object=$xdir$func_lo2o_result
5951d63fdb69Smrg	    func_append libobjs " $pic_object"
5952d63fdb69Smrg	    func_append non_pic_objects " $non_pic_object"
5953d63fdb69Smrg	  else
5954d63fdb69Smrg	    func_fatal_error "\`$arg' is not a valid libtool object"
5955d63fdb69Smrg	  fi
5956d63fdb69Smrg	fi
5957d63fdb69Smrg	;;
5958d63fdb69Smrg
5959d63fdb69Smrg      *.$libext)
5960d63fdb69Smrg	# An archive.
596148c85eb7Smrg	func_append deplibs " $arg"
596248c85eb7Smrg	func_append old_deplibs " $arg"
5963d63fdb69Smrg	continue
5964d63fdb69Smrg	;;
5965d63fdb69Smrg
5966d63fdb69Smrg      *.la)
5967d63fdb69Smrg	# A libtool-controlled library.
5968d63fdb69Smrg
596948c85eb7Smrg	func_resolve_sysroot "$arg"
5970d63fdb69Smrg	if test "$prev" = dlfiles; then
5971d63fdb69Smrg	  # This library was specified with -dlopen.
597248c85eb7Smrg	  func_append dlfiles " $func_resolve_sysroot_result"
5973d63fdb69Smrg	  prev=
5974d63fdb69Smrg	elif test "$prev" = dlprefiles; then
5975d63fdb69Smrg	  # The library was specified with -dlpreopen.
597648c85eb7Smrg	  func_append dlprefiles " $func_resolve_sysroot_result"
5977d63fdb69Smrg	  prev=
5978d63fdb69Smrg	else
597948c85eb7Smrg	  func_append deplibs " $func_resolve_sysroot_result"
5980d63fdb69Smrg	fi
5981d63fdb69Smrg	continue
5982d63fdb69Smrg	;;
5983d63fdb69Smrg
5984d63fdb69Smrg      # Some other compiler argument.
5985d63fdb69Smrg      *)
5986d63fdb69Smrg	# Unknown arguments in both finalize_command and compile_command need
5987d63fdb69Smrg	# to be aesthetically quoted because they are evaled later.
5988d63fdb69Smrg	func_quote_for_eval "$arg"
5989d63fdb69Smrg	arg="$func_quote_for_eval_result"
5990d63fdb69Smrg	;;
5991d63fdb69Smrg      esac # arg
5992d63fdb69Smrg
5993d63fdb69Smrg      # Now actually substitute the argument into the commands.
5994d63fdb69Smrg      if test -n "$arg"; then
5995d63fdb69Smrg	func_append compile_command " $arg"
5996d63fdb69Smrg	func_append finalize_command " $arg"
5997d63fdb69Smrg      fi
5998d63fdb69Smrg    done # argument parsing loop
5999d63fdb69Smrg
6000d63fdb69Smrg    test -n "$prev" && \
6001d63fdb69Smrg      func_fatal_help "the \`$prevarg' option requires an argument"
6002d63fdb69Smrg
6003d63fdb69Smrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
6004d63fdb69Smrg      eval arg=\"$export_dynamic_flag_spec\"
6005d63fdb69Smrg      func_append compile_command " $arg"
6006d63fdb69Smrg      func_append finalize_command " $arg"
6007d63fdb69Smrg    fi
6008d63fdb69Smrg
6009d63fdb69Smrg    oldlibs=
6010d63fdb69Smrg    # calculate the name of the file, without its directory
6011d63fdb69Smrg    func_basename "$output"
6012d63fdb69Smrg    outputname="$func_basename_result"
6013d63fdb69Smrg    libobjs_save="$libobjs"
6014d63fdb69Smrg
6015d63fdb69Smrg    if test -n "$shlibpath_var"; then
6016d63fdb69Smrg      # get the directories listed in $shlibpath_var
601755acc8fcSmrg      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
60183da084b3Smrg    else
6019d63fdb69Smrg      shlib_search_path=
60203da084b3Smrg    fi
6021d63fdb69Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
6022d63fdb69Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
60233da084b3Smrg
6024d63fdb69Smrg    func_dirname "$output" "/" ""
6025d63fdb69Smrg    output_objdir="$func_dirname_result$objdir"
602648c85eb7Smrg    func_to_tool_file "$output_objdir/"
602748c85eb7Smrg    tool_output_objdir=$func_to_tool_file_result
6028d63fdb69Smrg    # Create the object directory.
6029d63fdb69Smrg    func_mkdir_p "$output_objdir"
60303da084b3Smrg
6031d63fdb69Smrg    # Determine the type of output
6032d63fdb69Smrg    case $output in
6033d63fdb69Smrg    "")
6034d63fdb69Smrg      func_fatal_help "you must specify an output file"
6035d63fdb69Smrg      ;;
6036d63fdb69Smrg    *.$libext) linkmode=oldlib ;;
6037d63fdb69Smrg    *.lo | *.$objext) linkmode=obj ;;
6038d63fdb69Smrg    *.la) linkmode=lib ;;
6039d63fdb69Smrg    *) linkmode=prog ;; # Anything else should be a program.
6040d63fdb69Smrg    esac
6041d63fdb69Smrg
6042d63fdb69Smrg    specialdeplibs=
6043d63fdb69Smrg
6044d63fdb69Smrg    libs=
6045d63fdb69Smrg    # Find all interdependent deplibs by searching for libraries
6046d63fdb69Smrg    # that are linked more than once (e.g. -la -lb -la)
6047d63fdb69Smrg    for deplib in $deplibs; do
604848c85eb7Smrg      if $opt_preserve_dup_deps ; then
6049d63fdb69Smrg	case "$libs " in
605048c85eb7Smrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
6051d63fdb69Smrg	esac
6052d63fdb69Smrg      fi
605348c85eb7Smrg      func_append libs " $deplib"
6054d63fdb69Smrg    done
6055d63fdb69Smrg
6056d63fdb69Smrg    if test "$linkmode" = lib; then
6057d63fdb69Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
6058d63fdb69Smrg
6059d63fdb69Smrg      # Compute libraries that are listed more than once in $predeps
6060d63fdb69Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
6061d63fdb69Smrg      # not to be eliminated).
6062d63fdb69Smrg      pre_post_deps=
6063d63fdb69Smrg      if $opt_duplicate_compiler_generated_deps; then
6064d63fdb69Smrg	for pre_post_dep in $predeps $postdeps; do
6065d63fdb69Smrg	  case "$pre_post_deps " in
606648c85eb7Smrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
6067d63fdb69Smrg	  esac
606848c85eb7Smrg	  func_append pre_post_deps " $pre_post_dep"
6069d63fdb69Smrg	done
6070d63fdb69Smrg      fi
6071d63fdb69Smrg      pre_post_deps=
6072d63fdb69Smrg    fi
6073d63fdb69Smrg
6074d63fdb69Smrg    deplibs=
6075d63fdb69Smrg    newdependency_libs=
6076d63fdb69Smrg    newlib_search_path=
6077d63fdb69Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
6078d63fdb69Smrg    notinst_deplibs= # not-installed libtool libraries
6079d63fdb69Smrg    notinst_path= # paths that contain not-installed libtool libraries
6080d63fdb69Smrg
6081d63fdb69Smrg    case $linkmode in
6082d63fdb69Smrg    lib)
6083d63fdb69Smrg	passes="conv dlpreopen link"
6084d63fdb69Smrg	for file in $dlfiles $dlprefiles; do
6085d63fdb69Smrg	  case $file in
6086d63fdb69Smrg	  *.la) ;;
6087d63fdb69Smrg	  *)
6088d63fdb69Smrg	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
6089d63fdb69Smrg	    ;;
6090d63fdb69Smrg	  esac
6091d63fdb69Smrg	done
6092d63fdb69Smrg	;;
6093d63fdb69Smrg    prog)
6094d63fdb69Smrg	compile_deplibs=
6095d63fdb69Smrg	finalize_deplibs=
6096d63fdb69Smrg	alldeplibs=no
6097d63fdb69Smrg	newdlfiles=
6098d63fdb69Smrg	newdlprefiles=
6099d63fdb69Smrg	passes="conv scan dlopen dlpreopen link"
6100d63fdb69Smrg	;;
6101d63fdb69Smrg    *)  passes="conv"
6102d63fdb69Smrg	;;
6103d63fdb69Smrg    esac
6104d63fdb69Smrg
6105d63fdb69Smrg    for pass in $passes; do
6106d63fdb69Smrg      # The preopen pass in lib mode reverses $deplibs; put it back here
6107d63fdb69Smrg      # so that -L comes before libs that need it for instance...
6108d63fdb69Smrg      if test "$linkmode,$pass" = "lib,link"; then
6109d63fdb69Smrg	## FIXME: Find the place where the list is rebuilt in the wrong
6110d63fdb69Smrg	##        order, and fix it there properly
6111d63fdb69Smrg        tmp_deplibs=
6112d63fdb69Smrg	for deplib in $deplibs; do
6113d63fdb69Smrg	  tmp_deplibs="$deplib $tmp_deplibs"
6114d63fdb69Smrg	done
6115d63fdb69Smrg	deplibs="$tmp_deplibs"
6116d63fdb69Smrg      fi
6117d63fdb69Smrg
6118d63fdb69Smrg      if test "$linkmode,$pass" = "lib,link" ||
6119d63fdb69Smrg	 test "$linkmode,$pass" = "prog,scan"; then
6120d63fdb69Smrg	libs="$deplibs"
6121d63fdb69Smrg	deplibs=
6122d63fdb69Smrg      fi
6123d63fdb69Smrg      if test "$linkmode" = prog; then
6124d63fdb69Smrg	case $pass in
6125d63fdb69Smrg	dlopen) libs="$dlfiles" ;;
6126d63fdb69Smrg	dlpreopen) libs="$dlprefiles" ;;
6127d63fdb69Smrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
6128d63fdb69Smrg	esac
6129d63fdb69Smrg      fi
6130d63fdb69Smrg      if test "$linkmode,$pass" = "lib,dlpreopen"; then
6131d63fdb69Smrg	# Collect and forward deplibs of preopened libtool libs
6132d63fdb69Smrg	for lib in $dlprefiles; do
6133d63fdb69Smrg	  # Ignore non-libtool-libs
6134d63fdb69Smrg	  dependency_libs=
613548c85eb7Smrg	  func_resolve_sysroot "$lib"
6136d63fdb69Smrg	  case $lib in
613748c85eb7Smrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
6138d63fdb69Smrg	  esac
6139d63fdb69Smrg
6140d63fdb69Smrg	  # Collect preopened libtool deplibs, except any this library
6141d63fdb69Smrg	  # has declared as weak libs
6142d63fdb69Smrg	  for deplib in $dependency_libs; do
614355acc8fcSmrg	    func_basename "$deplib"
614455acc8fcSmrg            deplib_base=$func_basename_result
6145d63fdb69Smrg	    case " $weak_libs " in
6146d63fdb69Smrg	    *" $deplib_base "*) ;;
614748c85eb7Smrg	    *) func_append deplibs " $deplib" ;;
6148d63fdb69Smrg	    esac
6149d63fdb69Smrg	  done
6150d63fdb69Smrg	done
6151d63fdb69Smrg	libs="$dlprefiles"
6152d63fdb69Smrg      fi
6153d63fdb69Smrg      if test "$pass" = dlopen; then
6154d63fdb69Smrg	# Collect dlpreopened libraries
6155d63fdb69Smrg	save_deplibs="$deplibs"
6156d63fdb69Smrg	deplibs=
6157d63fdb69Smrg      fi
6158d63fdb69Smrg
6159d63fdb69Smrg      for deplib in $libs; do
6160d63fdb69Smrg	lib=
6161d63fdb69Smrg	found=no
6162d63fdb69Smrg	case $deplib in
616348c85eb7Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
616448c85eb7Smrg        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
6165d63fdb69Smrg	  if test "$linkmode,$pass" = "prog,link"; then
6166d63fdb69Smrg	    compile_deplibs="$deplib $compile_deplibs"
6167d63fdb69Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
6168d63fdb69Smrg	  else
616948c85eb7Smrg	    func_append compiler_flags " $deplib"
6170d63fdb69Smrg	    if test "$linkmode" = lib ; then
6171d63fdb69Smrg		case "$new_inherited_linker_flags " in
6172d63fdb69Smrg		    *" $deplib "*) ;;
617348c85eb7Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6174d63fdb69Smrg		esac
6175d63fdb69Smrg	    fi
6176d63fdb69Smrg	  fi
6177d63fdb69Smrg	  continue
6178d63fdb69Smrg	  ;;
6179d63fdb69Smrg	-l*)
6180d63fdb69Smrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
6181d63fdb69Smrg	    func_warning "\`-l' is ignored for archives/objects"
6182d63fdb69Smrg	    continue
6183d63fdb69Smrg	  fi
6184d63fdb69Smrg	  func_stripname '-l' '' "$deplib"
6185d63fdb69Smrg	  name=$func_stripname_result
6186d63fdb69Smrg	  if test "$linkmode" = lib; then
6187d63fdb69Smrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
6188d63fdb69Smrg	  else
6189d63fdb69Smrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
6190d63fdb69Smrg	  fi
6191d63fdb69Smrg	  for searchdir in $searchdirs; do
6192d63fdb69Smrg	    for search_ext in .la $std_shrext .so .a; do
6193d63fdb69Smrg	      # Search the libtool library
6194d63fdb69Smrg	      lib="$searchdir/lib${name}${search_ext}"
6195d63fdb69Smrg	      if test -f "$lib"; then
6196d63fdb69Smrg		if test "$search_ext" = ".la"; then
6197d63fdb69Smrg		  found=yes
6198d63fdb69Smrg		else
6199d63fdb69Smrg		  found=no
6200d63fdb69Smrg		fi
6201d63fdb69Smrg		break 2
6202d63fdb69Smrg	      fi
6203d63fdb69Smrg	    done
6204d63fdb69Smrg	  done
6205d63fdb69Smrg	  if test "$found" != yes; then
6206d63fdb69Smrg	    # deplib doesn't seem to be a libtool library
6207d63fdb69Smrg	    if test "$linkmode,$pass" = "prog,link"; then
6208d63fdb69Smrg	      compile_deplibs="$deplib $compile_deplibs"
6209d63fdb69Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
6210d63fdb69Smrg	    else
6211d63fdb69Smrg	      deplibs="$deplib $deplibs"
6212d63fdb69Smrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6213d63fdb69Smrg	    fi
6214d63fdb69Smrg	    continue
6215d63fdb69Smrg	  else # deplib is a libtool library
6216d63fdb69Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
6217d63fdb69Smrg	    # We need to do some special things here, and not later.
6218d63fdb69Smrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6219d63fdb69Smrg	      case " $predeps $postdeps " in
6220d63fdb69Smrg	      *" $deplib "*)
6221d63fdb69Smrg		if func_lalib_p "$lib"; then
6222d63fdb69Smrg		  library_names=
6223d63fdb69Smrg		  old_library=
6224d63fdb69Smrg		  func_source "$lib"
6225d63fdb69Smrg		  for l in $old_library $library_names; do
6226d63fdb69Smrg		    ll="$l"
6227d63fdb69Smrg		  done
6228d63fdb69Smrg		  if test "X$ll" = "X$old_library" ; then # only static version available
6229d63fdb69Smrg		    found=no
6230d63fdb69Smrg		    func_dirname "$lib" "" "."
6231d63fdb69Smrg		    ladir="$func_dirname_result"
6232d63fdb69Smrg		    lib=$ladir/$old_library
6233d63fdb69Smrg		    if test "$linkmode,$pass" = "prog,link"; then
6234d63fdb69Smrg		      compile_deplibs="$deplib $compile_deplibs"
6235d63fdb69Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
6236d63fdb69Smrg		    else
6237d63fdb69Smrg		      deplibs="$deplib $deplibs"
6238d63fdb69Smrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6239d63fdb69Smrg		    fi
6240d63fdb69Smrg		    continue
6241d63fdb69Smrg		  fi
6242d63fdb69Smrg		fi
6243d63fdb69Smrg		;;
6244d63fdb69Smrg	      *) ;;
6245d63fdb69Smrg	      esac
6246d63fdb69Smrg	    fi
6247d63fdb69Smrg	  fi
6248d63fdb69Smrg	  ;; # -l
6249d63fdb69Smrg	*.ltframework)
6250d63fdb69Smrg	  if test "$linkmode,$pass" = "prog,link"; then
6251d63fdb69Smrg	    compile_deplibs="$deplib $compile_deplibs"
6252d63fdb69Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
6253d63fdb69Smrg	  else
6254d63fdb69Smrg	    deplibs="$deplib $deplibs"
6255d63fdb69Smrg	    if test "$linkmode" = lib ; then
6256d63fdb69Smrg		case "$new_inherited_linker_flags " in
6257d63fdb69Smrg		    *" $deplib "*) ;;
625848c85eb7Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6259d63fdb69Smrg		esac
6260d63fdb69Smrg	    fi
6261d63fdb69Smrg	  fi
6262d63fdb69Smrg	  continue
6263d63fdb69Smrg	  ;;
6264d63fdb69Smrg	-L*)
6265d63fdb69Smrg	  case $linkmode in
6266d63fdb69Smrg	  lib)
6267d63fdb69Smrg	    deplibs="$deplib $deplibs"
6268d63fdb69Smrg	    test "$pass" = conv && continue
6269d63fdb69Smrg	    newdependency_libs="$deplib $newdependency_libs"
6270d63fdb69Smrg	    func_stripname '-L' '' "$deplib"
627148c85eb7Smrg	    func_resolve_sysroot "$func_stripname_result"
627248c85eb7Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
6273d63fdb69Smrg	    ;;
6274d63fdb69Smrg	  prog)
6275d63fdb69Smrg	    if test "$pass" = conv; then
6276d63fdb69Smrg	      deplibs="$deplib $deplibs"
6277d63fdb69Smrg	      continue
6278d63fdb69Smrg	    fi
6279d63fdb69Smrg	    if test "$pass" = scan; then
6280d63fdb69Smrg	      deplibs="$deplib $deplibs"
6281d63fdb69Smrg	    else
6282d63fdb69Smrg	      compile_deplibs="$deplib $compile_deplibs"
6283d63fdb69Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
6284d63fdb69Smrg	    fi
6285d63fdb69Smrg	    func_stripname '-L' '' "$deplib"
628648c85eb7Smrg	    func_resolve_sysroot "$func_stripname_result"
628748c85eb7Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
6288d63fdb69Smrg	    ;;
6289d63fdb69Smrg	  *)
6290d63fdb69Smrg	    func_warning "\`-L' is ignored for archives/objects"
6291d63fdb69Smrg	    ;;
6292d63fdb69Smrg	  esac # linkmode
6293d63fdb69Smrg	  continue
6294d63fdb69Smrg	  ;; # -L
6295d63fdb69Smrg	-R*)
6296d63fdb69Smrg	  if test "$pass" = link; then
6297d63fdb69Smrg	    func_stripname '-R' '' "$deplib"
629848c85eb7Smrg	    func_resolve_sysroot "$func_stripname_result"
629948c85eb7Smrg	    dir=$func_resolve_sysroot_result
6300d63fdb69Smrg	    # Make sure the xrpath contains only unique directories.
6301d63fdb69Smrg	    case "$xrpath " in
6302d63fdb69Smrg	    *" $dir "*) ;;
630348c85eb7Smrg	    *) func_append xrpath " $dir" ;;
6304d63fdb69Smrg	    esac
6305d63fdb69Smrg	  fi
6306d63fdb69Smrg	  deplibs="$deplib $deplibs"
6307d63fdb69Smrg	  continue
6308d63fdb69Smrg	  ;;
630948c85eb7Smrg	*.la)
631048c85eb7Smrg	  func_resolve_sysroot "$deplib"
631148c85eb7Smrg	  lib=$func_resolve_sysroot_result
631248c85eb7Smrg	  ;;
6313d63fdb69Smrg	*.$libext)
6314d63fdb69Smrg	  if test "$pass" = conv; then
6315d63fdb69Smrg	    deplibs="$deplib $deplibs"
6316d63fdb69Smrg	    continue
6317d63fdb69Smrg	  fi
6318d63fdb69Smrg	  case $linkmode in
6319d63fdb69Smrg	  lib)
6320d63fdb69Smrg	    # Linking convenience modules into shared libraries is allowed,
6321d63fdb69Smrg	    # but linking other static libraries is non-portable.
6322d63fdb69Smrg	    case " $dlpreconveniencelibs " in
6323d63fdb69Smrg	    *" $deplib "*) ;;
6324d63fdb69Smrg	    *)
6325d63fdb69Smrg	      valid_a_lib=no
6326d63fdb69Smrg	      case $deplibs_check_method in
6327d63fdb69Smrg		match_pattern*)
6328d63fdb69Smrg		  set dummy $deplibs_check_method; shift
6329d63fdb69Smrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
633055acc8fcSmrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
6331d63fdb69Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
6332d63fdb69Smrg		    valid_a_lib=yes
6333d63fdb69Smrg		  fi
6334d63fdb69Smrg		;;
6335d63fdb69Smrg		pass_all)
6336d63fdb69Smrg		  valid_a_lib=yes
6337d63fdb69Smrg		;;
6338d63fdb69Smrg	      esac
6339d63fdb69Smrg	      if test "$valid_a_lib" != yes; then
634055acc8fcSmrg		echo
6341d63fdb69Smrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
634255acc8fcSmrg		echo "*** I have the capability to make that library automatically link in when"
634355acc8fcSmrg		echo "*** you link to this library.  But I can only do this if you have a"
634455acc8fcSmrg		echo "*** shared version of the library, which you do not appear to have"
634555acc8fcSmrg		echo "*** because the file extensions .$libext of this argument makes me believe"
634655acc8fcSmrg		echo "*** that it is just a static archive that I should not use here."
6347d63fdb69Smrg	      else
634855acc8fcSmrg		echo
6349d63fdb69Smrg		$ECHO "*** Warning: Linking the shared library $output against the"
6350d63fdb69Smrg		$ECHO "*** static library $deplib is not portable!"
6351d63fdb69Smrg		deplibs="$deplib $deplibs"
6352d63fdb69Smrg	      fi
6353d63fdb69Smrg	      ;;
6354d63fdb69Smrg	    esac
6355d63fdb69Smrg	    continue
6356d63fdb69Smrg	    ;;
6357d63fdb69Smrg	  prog)
6358d63fdb69Smrg	    if test "$pass" != link; then
6359d63fdb69Smrg	      deplibs="$deplib $deplibs"
6360d63fdb69Smrg	    else
6361d63fdb69Smrg	      compile_deplibs="$deplib $compile_deplibs"
6362d63fdb69Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
6363d63fdb69Smrg	    fi
6364d63fdb69Smrg	    continue
6365d63fdb69Smrg	    ;;
6366d63fdb69Smrg	  esac # linkmode
6367d63fdb69Smrg	  ;; # *.$libext
6368d63fdb69Smrg	*.lo | *.$objext)
6369d63fdb69Smrg	  if test "$pass" = conv; then
6370d63fdb69Smrg	    deplibs="$deplib $deplibs"
6371d63fdb69Smrg	  elif test "$linkmode" = prog; then
6372d63fdb69Smrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
6373d63fdb69Smrg	      # If there is no dlopen support or we're linking statically,
6374d63fdb69Smrg	      # we need to preload.
637548c85eb7Smrg	      func_append newdlprefiles " $deplib"
6376d63fdb69Smrg	      compile_deplibs="$deplib $compile_deplibs"
6377d63fdb69Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
6378d63fdb69Smrg	    else
637948c85eb7Smrg	      func_append newdlfiles " $deplib"
6380d63fdb69Smrg	    fi
6381d63fdb69Smrg	  fi
6382d63fdb69Smrg	  continue
6383d63fdb69Smrg	  ;;
6384d63fdb69Smrg	%DEPLIBS%)
6385d63fdb69Smrg	  alldeplibs=yes
6386d63fdb69Smrg	  continue
6387d63fdb69Smrg	  ;;
6388d63fdb69Smrg	esac # case $deplib
6389d63fdb69Smrg
6390d63fdb69Smrg	if test "$found" = yes || test -f "$lib"; then :
6391d63fdb69Smrg	else
6392d63fdb69Smrg	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
6393d63fdb69Smrg	fi
6394d63fdb69Smrg
6395d63fdb69Smrg	# Check to see that this really is a libtool archive.
6396d63fdb69Smrg	func_lalib_unsafe_p "$lib" \
6397d63fdb69Smrg	  || func_fatal_error "\`$lib' is not a valid libtool archive"
6398d63fdb69Smrg
6399d63fdb69Smrg	func_dirname "$lib" "" "."
6400d63fdb69Smrg	ladir="$func_dirname_result"
6401d63fdb69Smrg
6402d63fdb69Smrg	dlname=
6403d63fdb69Smrg	dlopen=
6404d63fdb69Smrg	dlpreopen=
6405d63fdb69Smrg	libdir=
6406d63fdb69Smrg	library_names=
6407d63fdb69Smrg	old_library=
6408d63fdb69Smrg	inherited_linker_flags=
6409d63fdb69Smrg	# If the library was installed with an old release of libtool,
6410d63fdb69Smrg	# it will not redefine variables installed, or shouldnotlink
6411d63fdb69Smrg	installed=yes
6412d63fdb69Smrg	shouldnotlink=no
6413d63fdb69Smrg	avoidtemprpath=
6414d63fdb69Smrg
6415d63fdb69Smrg
6416d63fdb69Smrg	# Read the .la file
6417d63fdb69Smrg	func_source "$lib"
6418d63fdb69Smrg
6419d63fdb69Smrg	# Convert "-framework foo" to "foo.ltframework"
6420d63fdb69Smrg	if test -n "$inherited_linker_flags"; then
642155acc8fcSmrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
6422d63fdb69Smrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
6423d63fdb69Smrg	    case " $new_inherited_linker_flags " in
6424d63fdb69Smrg	      *" $tmp_inherited_linker_flag "*) ;;
642548c85eb7Smrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
6426d63fdb69Smrg	    esac
6427d63fdb69Smrg	  done
6428d63fdb69Smrg	fi
642955acc8fcSmrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
6430d63fdb69Smrg	if test "$linkmode,$pass" = "lib,link" ||
6431d63fdb69Smrg	   test "$linkmode,$pass" = "prog,scan" ||
6432d63fdb69Smrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
643348c85eb7Smrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
643448c85eb7Smrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
6435d63fdb69Smrg	fi
6436d63fdb69Smrg
6437d63fdb69Smrg	if test "$pass" = conv; then
6438d63fdb69Smrg	  # Only check for convenience libraries
6439d63fdb69Smrg	  deplibs="$lib $deplibs"
6440d63fdb69Smrg	  if test -z "$libdir"; then
6441d63fdb69Smrg	    if test -z "$old_library"; then
6442d63fdb69Smrg	      func_fatal_error "cannot find name of link library for \`$lib'"
6443d63fdb69Smrg	    fi
6444d63fdb69Smrg	    # It is a libtool convenience library, so add in its objects.
644548c85eb7Smrg	    func_append convenience " $ladir/$objdir/$old_library"
644648c85eb7Smrg	    func_append old_convenience " $ladir/$objdir/$old_library"
6447d63fdb69Smrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
6448d63fdb69Smrg	    func_fatal_error "\`$lib' is not a convenience library"
6449d63fdb69Smrg	  fi
6450d63fdb69Smrg	  tmp_libs=
6451d63fdb69Smrg	  for deplib in $dependency_libs; do
6452d63fdb69Smrg	    deplibs="$deplib $deplibs"
645348c85eb7Smrg	    if $opt_preserve_dup_deps ; then
6454d63fdb69Smrg	      case "$tmp_libs " in
645548c85eb7Smrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6456d63fdb69Smrg	      esac
6457d63fdb69Smrg	    fi
645848c85eb7Smrg	    func_append tmp_libs " $deplib"
6459d63fdb69Smrg	  done
6460d63fdb69Smrg	  continue
6461d63fdb69Smrg	fi # $pass = conv
6462d63fdb69Smrg
6463d63fdb69Smrg
6464d63fdb69Smrg	# Get the name of the library we link against.
6465d63fdb69Smrg	linklib=
646648c85eb7Smrg	if test -n "$old_library" &&
646748c85eb7Smrg	   { test "$prefer_static_libs" = yes ||
646848c85eb7Smrg	     test "$prefer_static_libs,$installed" = "built,no"; }; then
646948c85eb7Smrg	  linklib=$old_library
647048c85eb7Smrg	else
647148c85eb7Smrg	  for l in $old_library $library_names; do
647248c85eb7Smrg	    linklib="$l"
647348c85eb7Smrg	  done
647448c85eb7Smrg	fi
6475d63fdb69Smrg	if test -z "$linklib"; then
6476d63fdb69Smrg	  func_fatal_error "cannot find name of link library for \`$lib'"
6477d63fdb69Smrg	fi
6478d63fdb69Smrg
6479d63fdb69Smrg	# This library was specified with -dlopen.
6480d63fdb69Smrg	if test "$pass" = dlopen; then
6481d63fdb69Smrg	  if test -z "$libdir"; then
6482d63fdb69Smrg	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
6483d63fdb69Smrg	  fi
6484d63fdb69Smrg	  if test -z "$dlname" ||
6485d63fdb69Smrg	     test "$dlopen_support" != yes ||
6486d63fdb69Smrg	     test "$build_libtool_libs" = no; then
6487d63fdb69Smrg	    # If there is no dlname, no dlopen support or we're linking
6488d63fdb69Smrg	    # statically, we need to preload.  We also need to preload any
6489d63fdb69Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
6490d63fdb69Smrg	    # bomb out in the load deplibs phase.
649148c85eb7Smrg	    func_append dlprefiles " $lib $dependency_libs"
6492d63fdb69Smrg	  else
649348c85eb7Smrg	    func_append newdlfiles " $lib"
6494d63fdb69Smrg	  fi
6495d63fdb69Smrg	  continue
6496d63fdb69Smrg	fi # $pass = dlopen
6497d63fdb69Smrg
6498d63fdb69Smrg	# We need an absolute path.
6499d63fdb69Smrg	case $ladir in
6500d63fdb69Smrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
6501d63fdb69Smrg	*)
6502d63fdb69Smrg	  abs_ladir=`cd "$ladir" && pwd`
6503d63fdb69Smrg	  if test -z "$abs_ladir"; then
6504d63fdb69Smrg	    func_warning "cannot determine absolute directory name of \`$ladir'"
6505d63fdb69Smrg	    func_warning "passing it literally to the linker, although it might fail"
6506d63fdb69Smrg	    abs_ladir="$ladir"
6507d63fdb69Smrg	  fi
6508d63fdb69Smrg	  ;;
6509d63fdb69Smrg	esac
6510d63fdb69Smrg	func_basename "$lib"
6511d63fdb69Smrg	laname="$func_basename_result"
6512d63fdb69Smrg
6513d63fdb69Smrg	# Find the relevant object directory and library name.
6514d63fdb69Smrg	if test "X$installed" = Xyes; then
651548c85eb7Smrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6516d63fdb69Smrg	    func_warning "library \`$lib' was moved."
6517d63fdb69Smrg	    dir="$ladir"
6518d63fdb69Smrg	    absdir="$abs_ladir"
6519d63fdb69Smrg	    libdir="$abs_ladir"
6520d63fdb69Smrg	  else
652148c85eb7Smrg	    dir="$lt_sysroot$libdir"
652248c85eb7Smrg	    absdir="$lt_sysroot$libdir"
6523d63fdb69Smrg	  fi
6524d63fdb69Smrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
6525d63fdb69Smrg	else
6526d63fdb69Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6527d63fdb69Smrg	    dir="$ladir"
6528d63fdb69Smrg	    absdir="$abs_ladir"
6529d63fdb69Smrg	    # Remove this search path later
653048c85eb7Smrg	    func_append notinst_path " $abs_ladir"
6531d63fdb69Smrg	  else
6532d63fdb69Smrg	    dir="$ladir/$objdir"
6533d63fdb69Smrg	    absdir="$abs_ladir/$objdir"
6534d63fdb69Smrg	    # Remove this search path later
653548c85eb7Smrg	    func_append notinst_path " $abs_ladir"
6536d63fdb69Smrg	  fi
6537d63fdb69Smrg	fi # $installed = yes
6538d63fdb69Smrg	func_stripname 'lib' '.la' "$laname"
6539d63fdb69Smrg	name=$func_stripname_result
6540d63fdb69Smrg
6541d63fdb69Smrg	# This library was specified with -dlpreopen.
6542d63fdb69Smrg	if test "$pass" = dlpreopen; then
6543d63fdb69Smrg	  if test -z "$libdir" && test "$linkmode" = prog; then
6544d63fdb69Smrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
6545d63fdb69Smrg	  fi
654648c85eb7Smrg	  case "$host" in
654748c85eb7Smrg	    # special handling for platforms with PE-DLLs.
654848c85eb7Smrg	    *cygwin* | *mingw* | *cegcc* )
654948c85eb7Smrg	      # Linker will automatically link against shared library if both
655048c85eb7Smrg	      # static and shared are present.  Therefore, ensure we extract
655148c85eb7Smrg	      # symbols from the import library if a shared library is present
655248c85eb7Smrg	      # (otherwise, the dlopen module name will be incorrect).  We do
655348c85eb7Smrg	      # this by putting the import library name into $newdlprefiles.
655448c85eb7Smrg	      # We recover the dlopen module name by 'saving' the la file
655548c85eb7Smrg	      # name in a special purpose variable, and (later) extracting the
655648c85eb7Smrg	      # dlname from the la file.
655748c85eb7Smrg	      if test -n "$dlname"; then
655848c85eb7Smrg	        func_tr_sh "$dir/$linklib"
655948c85eb7Smrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
656048c85eb7Smrg	        func_append newdlprefiles " $dir/$linklib"
656148c85eb7Smrg	      else
656248c85eb7Smrg	        func_append newdlprefiles " $dir/$old_library"
656348c85eb7Smrg	        # Keep a list of preopened convenience libraries to check
656448c85eb7Smrg	        # that they are being used correctly in the link pass.
656548c85eb7Smrg	        test -z "$libdir" && \
656648c85eb7Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
656748c85eb7Smrg	      fi
656848c85eb7Smrg	    ;;
656948c85eb7Smrg	    * )
657048c85eb7Smrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
657148c85eb7Smrg	      # are required to link).
657248c85eb7Smrg	      if test -n "$old_library"; then
657348c85eb7Smrg	        func_append newdlprefiles " $dir/$old_library"
657448c85eb7Smrg	        # Keep a list of preopened convenience libraries to check
657548c85eb7Smrg	        # that they are being used correctly in the link pass.
657648c85eb7Smrg	        test -z "$libdir" && \
657748c85eb7Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
657848c85eb7Smrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
657948c85eb7Smrg	      elif test -n "$dlname"; then
658048c85eb7Smrg	        func_append newdlprefiles " $dir/$dlname"
658148c85eb7Smrg	      else
658248c85eb7Smrg	        func_append newdlprefiles " $dir/$linklib"
658348c85eb7Smrg	      fi
658448c85eb7Smrg	    ;;
658548c85eb7Smrg	  esac
6586d63fdb69Smrg	fi # $pass = dlpreopen
6587d63fdb69Smrg
6588d63fdb69Smrg	if test -z "$libdir"; then
6589d63fdb69Smrg	  # Link the convenience library
6590d63fdb69Smrg	  if test "$linkmode" = lib; then
6591d63fdb69Smrg	    deplibs="$dir/$old_library $deplibs"
6592d63fdb69Smrg	  elif test "$linkmode,$pass" = "prog,link"; then
6593d63fdb69Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
6594d63fdb69Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
6595d63fdb69Smrg	  else
6596d63fdb69Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
6597d63fdb69Smrg	  fi
6598d63fdb69Smrg	  continue
6599d63fdb69Smrg	fi
6600d63fdb69Smrg
6601d63fdb69Smrg
6602d63fdb69Smrg	if test "$linkmode" = prog && test "$pass" != link; then
660348c85eb7Smrg	  func_append newlib_search_path " $ladir"
6604d63fdb69Smrg	  deplibs="$lib $deplibs"
6605d63fdb69Smrg
6606d63fdb69Smrg	  linkalldeplibs=no
6607d63fdb69Smrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
6608d63fdb69Smrg	     test "$build_libtool_libs" = no; then
6609d63fdb69Smrg	    linkalldeplibs=yes
6610d63fdb69Smrg	  fi
6611d63fdb69Smrg
6612d63fdb69Smrg	  tmp_libs=
6613d63fdb69Smrg	  for deplib in $dependency_libs; do
6614d63fdb69Smrg	    case $deplib in
6615d63fdb69Smrg	    -L*) func_stripname '-L' '' "$deplib"
661648c85eb7Smrg	         func_resolve_sysroot "$func_stripname_result"
661748c85eb7Smrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
6618d63fdb69Smrg		 ;;
6619d63fdb69Smrg	    esac
6620d63fdb69Smrg	    # Need to link against all dependency_libs?
6621d63fdb69Smrg	    if test "$linkalldeplibs" = yes; then
6622d63fdb69Smrg	      deplibs="$deplib $deplibs"
6623d63fdb69Smrg	    else
6624d63fdb69Smrg	      # Need to hardcode shared library paths
6625d63fdb69Smrg	      # or/and link against static libraries
6626d63fdb69Smrg	      newdependency_libs="$deplib $newdependency_libs"
6627d63fdb69Smrg	    fi
662848c85eb7Smrg	    if $opt_preserve_dup_deps ; then
6629d63fdb69Smrg	      case "$tmp_libs " in
663048c85eb7Smrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6631d63fdb69Smrg	      esac
6632d63fdb69Smrg	    fi
663348c85eb7Smrg	    func_append tmp_libs " $deplib"
6634d63fdb69Smrg	  done # for deplib
6635d63fdb69Smrg	  continue
6636d63fdb69Smrg	fi # $linkmode = prog...
6637d63fdb69Smrg
6638d63fdb69Smrg	if test "$linkmode,$pass" = "prog,link"; then
6639d63fdb69Smrg	  if test -n "$library_names" &&
6640d63fdb69Smrg	     { { test "$prefer_static_libs" = no ||
6641d63fdb69Smrg	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
6642d63fdb69Smrg	       test -z "$old_library"; }; then
6643d63fdb69Smrg	    # We need to hardcode the library path
6644d63fdb69Smrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
6645d63fdb69Smrg	      # Make sure the rpath contains only unique directories.
6646d63fdb69Smrg	      case "$temp_rpath:" in
6647d63fdb69Smrg	      *"$absdir:"*) ;;
664848c85eb7Smrg	      *) func_append temp_rpath "$absdir:" ;;
6649d63fdb69Smrg	      esac
6650d63fdb69Smrg	    fi
6651d63fdb69Smrg
6652d63fdb69Smrg	    # Hardcode the library path.
6653d63fdb69Smrg	    # Skip directories that are in the system default run-time
6654d63fdb69Smrg	    # search path.
6655d63fdb69Smrg	    case " $sys_lib_dlsearch_path " in
6656d63fdb69Smrg	    *" $absdir "*) ;;
6657d63fdb69Smrg	    *)
6658d63fdb69Smrg	      case "$compile_rpath " in
6659d63fdb69Smrg	      *" $absdir "*) ;;
666048c85eb7Smrg	      *) func_append compile_rpath " $absdir" ;;
6661d63fdb69Smrg	      esac
6662d63fdb69Smrg	      ;;
6663d63fdb69Smrg	    esac
6664d63fdb69Smrg	    case " $sys_lib_dlsearch_path " in
6665d63fdb69Smrg	    *" $libdir "*) ;;
6666d63fdb69Smrg	    *)
6667d63fdb69Smrg	      case "$finalize_rpath " in
6668d63fdb69Smrg	      *" $libdir "*) ;;
666948c85eb7Smrg	      *) func_append finalize_rpath " $libdir" ;;
6670d63fdb69Smrg	      esac
6671d63fdb69Smrg	      ;;
6672d63fdb69Smrg	    esac
6673d63fdb69Smrg	  fi # $linkmode,$pass = prog,link...
6674d63fdb69Smrg
6675d63fdb69Smrg	  if test "$alldeplibs" = yes &&
6676d63fdb69Smrg	     { test "$deplibs_check_method" = pass_all ||
6677d63fdb69Smrg	       { test "$build_libtool_libs" = yes &&
6678d63fdb69Smrg		 test -n "$library_names"; }; }; then
6679d63fdb69Smrg	    # We only need to search for static libraries
6680d63fdb69Smrg	    continue
6681d63fdb69Smrg	  fi
6682d63fdb69Smrg	fi
6683d63fdb69Smrg
6684d63fdb69Smrg	link_static=no # Whether the deplib will be linked statically
6685d63fdb69Smrg	use_static_libs=$prefer_static_libs
6686d63fdb69Smrg	if test "$use_static_libs" = built && test "$installed" = yes; then
6687d63fdb69Smrg	  use_static_libs=no
6688d63fdb69Smrg	fi
6689d63fdb69Smrg	if test -n "$library_names" &&
6690d63fdb69Smrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
6691d63fdb69Smrg	  case $host in
6692d63fdb69Smrg	  *cygwin* | *mingw* | *cegcc*)
6693d63fdb69Smrg	      # No point in relinking DLLs because paths are not encoded
669448c85eb7Smrg	      func_append notinst_deplibs " $lib"
6695d63fdb69Smrg	      need_relink=no
6696d63fdb69Smrg	    ;;
6697d63fdb69Smrg	  *)
6698d63fdb69Smrg	    if test "$installed" = no; then
669948c85eb7Smrg	      func_append notinst_deplibs " $lib"
6700d63fdb69Smrg	      need_relink=yes
6701d63fdb69Smrg	    fi
6702d63fdb69Smrg	    ;;
6703d63fdb69Smrg	  esac
6704d63fdb69Smrg	  # This is a shared library
6705d63fdb69Smrg
6706d63fdb69Smrg	  # Warn about portability, can't link against -module's on some
6707d63fdb69Smrg	  # systems (darwin).  Don't bleat about dlopened modules though!
6708d63fdb69Smrg	  dlopenmodule=""
6709d63fdb69Smrg	  for dlpremoduletest in $dlprefiles; do
6710d63fdb69Smrg	    if test "X$dlpremoduletest" = "X$lib"; then
6711d63fdb69Smrg	      dlopenmodule="$dlpremoduletest"
6712d63fdb69Smrg	      break
6713d63fdb69Smrg	    fi
6714d63fdb69Smrg	  done
6715d63fdb69Smrg	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
671655acc8fcSmrg	    echo
6717d63fdb69Smrg	    if test "$linkmode" = prog; then
6718d63fdb69Smrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
6719d63fdb69Smrg	    else
6720d63fdb69Smrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
6721d63fdb69Smrg	    fi
6722d63fdb69Smrg	    $ECHO "*** $linklib is not portable!"
6723d63fdb69Smrg	  fi
6724d63fdb69Smrg	  if test "$linkmode" = lib &&
6725d63fdb69Smrg	     test "$hardcode_into_libs" = yes; then
6726d63fdb69Smrg	    # Hardcode the library path.
6727d63fdb69Smrg	    # Skip directories that are in the system default run-time
6728d63fdb69Smrg	    # search path.
6729d63fdb69Smrg	    case " $sys_lib_dlsearch_path " in
6730d63fdb69Smrg	    *" $absdir "*) ;;
6731d63fdb69Smrg	    *)
6732d63fdb69Smrg	      case "$compile_rpath " in
6733d63fdb69Smrg	      *" $absdir "*) ;;
673448c85eb7Smrg	      *) func_append compile_rpath " $absdir" ;;
6735d63fdb69Smrg	      esac
6736d63fdb69Smrg	      ;;
6737d63fdb69Smrg	    esac
6738d63fdb69Smrg	    case " $sys_lib_dlsearch_path " in
6739d63fdb69Smrg	    *" $libdir "*) ;;
6740d63fdb69Smrg	    *)
6741d63fdb69Smrg	      case "$finalize_rpath " in
6742d63fdb69Smrg	      *" $libdir "*) ;;
674348c85eb7Smrg	      *) func_append finalize_rpath " $libdir" ;;
6744d63fdb69Smrg	      esac
6745d63fdb69Smrg	      ;;
6746d63fdb69Smrg	    esac
6747d63fdb69Smrg	  fi
6748d63fdb69Smrg
6749d63fdb69Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
6750d63fdb69Smrg	    # figure out the soname
6751d63fdb69Smrg	    set dummy $library_names
6752d63fdb69Smrg	    shift
6753d63fdb69Smrg	    realname="$1"
6754d63fdb69Smrg	    shift
6755d63fdb69Smrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
6756d63fdb69Smrg	    # use dlname if we got it. it's perfectly good, no?
6757d63fdb69Smrg	    if test -n "$dlname"; then
6758d63fdb69Smrg	      soname="$dlname"
6759d63fdb69Smrg	    elif test -n "$soname_spec"; then
6760d63fdb69Smrg	      # bleh windows
6761d63fdb69Smrg	      case $host in
6762d63fdb69Smrg	      *cygwin* | mingw* | *cegcc*)
6763d63fdb69Smrg	        func_arith $current - $age
6764d63fdb69Smrg		major=$func_arith_result
6765d63fdb69Smrg		versuffix="-$major"
6766d63fdb69Smrg		;;
6767d63fdb69Smrg	      esac
6768d63fdb69Smrg	      eval soname=\"$soname_spec\"
6769d63fdb69Smrg	    else
6770d63fdb69Smrg	      soname="$realname"
6771d63fdb69Smrg	    fi
6772d63fdb69Smrg
6773d63fdb69Smrg	    # Make a new name for the extract_expsyms_cmds to use
6774d63fdb69Smrg	    soroot="$soname"
6775d63fdb69Smrg	    func_basename "$soroot"
6776d63fdb69Smrg	    soname="$func_basename_result"
6777d63fdb69Smrg	    func_stripname 'lib' '.dll' "$soname"
6778d63fdb69Smrg	    newlib=libimp-$func_stripname_result.a
6779d63fdb69Smrg
6780d63fdb69Smrg	    # If the library has no export list, then create one now
6781d63fdb69Smrg	    if test -f "$output_objdir/$soname-def"; then :
6782d63fdb69Smrg	    else
6783d63fdb69Smrg	      func_verbose "extracting exported symbol list from \`$soname'"
6784d63fdb69Smrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
6785d63fdb69Smrg	    fi
6786d63fdb69Smrg
6787d63fdb69Smrg	    # Create $newlib
6788d63fdb69Smrg	    if test -f "$output_objdir/$newlib"; then :; else
6789d63fdb69Smrg	      func_verbose "generating import library for \`$soname'"
6790d63fdb69Smrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
6791d63fdb69Smrg	    fi
6792d63fdb69Smrg	    # make sure the library variables are pointing to the new library
6793d63fdb69Smrg	    dir=$output_objdir
6794d63fdb69Smrg	    linklib=$newlib
6795d63fdb69Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
6796d63fdb69Smrg
679748c85eb7Smrg	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
6798d63fdb69Smrg	    add_shlibpath=
6799d63fdb69Smrg	    add_dir=
6800d63fdb69Smrg	    add=
6801d63fdb69Smrg	    lib_linked=yes
6802d63fdb69Smrg	    case $hardcode_action in
6803d63fdb69Smrg	    immediate | unsupported)
6804d63fdb69Smrg	      if test "$hardcode_direct" = no; then
6805d63fdb69Smrg		add="$dir/$linklib"
6806d63fdb69Smrg		case $host in
6807d63fdb69Smrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
6808d63fdb69Smrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
6809d63fdb69Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
6810d63fdb69Smrg		    *-*-unixware7*) add_dir="-L$dir" ;;
6811d63fdb69Smrg		  *-*-darwin* )
6812d63fdb69Smrg		    # if the lib is a (non-dlopened) module then we can not
6813d63fdb69Smrg		    # link against it, someone is ignoring the earlier warnings
6814d63fdb69Smrg		    if /usr/bin/file -L $add 2> /dev/null |
6815d63fdb69Smrg			 $GREP ": [^:]* bundle" >/dev/null ; then
6816d63fdb69Smrg		      if test "X$dlopenmodule" != "X$lib"; then
6817d63fdb69Smrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
6818d63fdb69Smrg			if test -z "$old_library" ; then
681955acc8fcSmrg			  echo
682055acc8fcSmrg			  echo "*** And there doesn't seem to be a static archive available"
682155acc8fcSmrg			  echo "*** The link will probably fail, sorry"
6822d63fdb69Smrg			else
6823d63fdb69Smrg			  add="$dir/$old_library"
6824d63fdb69Smrg			fi
6825d63fdb69Smrg		      elif test -n "$old_library"; then
6826d63fdb69Smrg			add="$dir/$old_library"
6827d63fdb69Smrg		      fi
6828d63fdb69Smrg		    fi
6829d63fdb69Smrg		esac
6830d63fdb69Smrg	      elif test "$hardcode_minus_L" = no; then
6831d63fdb69Smrg		case $host in
6832d63fdb69Smrg		*-*-sunos*) add_shlibpath="$dir" ;;
6833d63fdb69Smrg		esac
6834d63fdb69Smrg		add_dir="-L$dir"
6835d63fdb69Smrg		add="-l$name"
6836d63fdb69Smrg	      elif test "$hardcode_shlibpath_var" = no; then
6837d63fdb69Smrg		add_shlibpath="$dir"
6838d63fdb69Smrg		add="-l$name"
6839d63fdb69Smrg	      else
6840d63fdb69Smrg		lib_linked=no
6841d63fdb69Smrg	      fi
6842d63fdb69Smrg	      ;;
6843d63fdb69Smrg	    relink)
6844d63fdb69Smrg	      if test "$hardcode_direct" = yes &&
6845d63fdb69Smrg	         test "$hardcode_direct_absolute" = no; then
6846d63fdb69Smrg		add="$dir/$linklib"
6847d63fdb69Smrg	      elif test "$hardcode_minus_L" = yes; then
684848c85eb7Smrg		add_dir="-L$absdir"
6849d63fdb69Smrg		# Try looking first in the location we're being installed to.
6850d63fdb69Smrg		if test -n "$inst_prefix_dir"; then
6851d63fdb69Smrg		  case $libdir in
6852d63fdb69Smrg		    [\\/]*)
685348c85eb7Smrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
6854d63fdb69Smrg		      ;;
6855d63fdb69Smrg		  esac
6856d63fdb69Smrg		fi
6857d63fdb69Smrg		add="-l$name"
6858d63fdb69Smrg	      elif test "$hardcode_shlibpath_var" = yes; then
6859d63fdb69Smrg		add_shlibpath="$dir"
6860d63fdb69Smrg		add="-l$name"
6861d63fdb69Smrg	      else
6862d63fdb69Smrg		lib_linked=no
6863d63fdb69Smrg	      fi
6864d63fdb69Smrg	      ;;
6865d63fdb69Smrg	    *) lib_linked=no ;;
6866d63fdb69Smrg	    esac
6867d63fdb69Smrg
6868d63fdb69Smrg	    if test "$lib_linked" != yes; then
6869d63fdb69Smrg	      func_fatal_configuration "unsupported hardcode properties"
6870d63fdb69Smrg	    fi
6871d63fdb69Smrg
6872d63fdb69Smrg	    if test -n "$add_shlibpath"; then
6873d63fdb69Smrg	      case :$compile_shlibpath: in
6874d63fdb69Smrg	      *":$add_shlibpath:"*) ;;
687548c85eb7Smrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
6876d63fdb69Smrg	      esac
6877d63fdb69Smrg	    fi
6878d63fdb69Smrg	    if test "$linkmode" = prog; then
6879d63fdb69Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
6880d63fdb69Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
6881d63fdb69Smrg	    else
6882d63fdb69Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6883d63fdb69Smrg	      test -n "$add" && deplibs="$add $deplibs"
6884d63fdb69Smrg	      if test "$hardcode_direct" != yes &&
6885d63fdb69Smrg		 test "$hardcode_minus_L" != yes &&
6886d63fdb69Smrg		 test "$hardcode_shlibpath_var" = yes; then
6887d63fdb69Smrg		case :$finalize_shlibpath: in
6888d63fdb69Smrg		*":$libdir:"*) ;;
688948c85eb7Smrg		*) func_append finalize_shlibpath "$libdir:" ;;
6890d63fdb69Smrg		esac
6891d63fdb69Smrg	      fi
6892d63fdb69Smrg	    fi
6893d63fdb69Smrg	  fi
6894d63fdb69Smrg
689548c85eb7Smrg	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
6896d63fdb69Smrg	    add_shlibpath=
6897d63fdb69Smrg	    add_dir=
6898d63fdb69Smrg	    add=
6899d63fdb69Smrg	    # Finalize command for both is simple: just hardcode it.
6900d63fdb69Smrg	    if test "$hardcode_direct" = yes &&
6901d63fdb69Smrg	       test "$hardcode_direct_absolute" = no; then
6902d63fdb69Smrg	      add="$libdir/$linklib"
6903d63fdb69Smrg	    elif test "$hardcode_minus_L" = yes; then
6904d63fdb69Smrg	      add_dir="-L$libdir"
6905d63fdb69Smrg	      add="-l$name"
6906d63fdb69Smrg	    elif test "$hardcode_shlibpath_var" = yes; then
6907d63fdb69Smrg	      case :$finalize_shlibpath: in
6908d63fdb69Smrg	      *":$libdir:"*) ;;
690948c85eb7Smrg	      *) func_append finalize_shlibpath "$libdir:" ;;
6910d63fdb69Smrg	      esac
6911d63fdb69Smrg	      add="-l$name"
6912d63fdb69Smrg	    elif test "$hardcode_automatic" = yes; then
6913d63fdb69Smrg	      if test -n "$inst_prefix_dir" &&
6914d63fdb69Smrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
6915d63fdb69Smrg		add="$inst_prefix_dir$libdir/$linklib"
6916d63fdb69Smrg	      else
6917d63fdb69Smrg		add="$libdir/$linklib"
6918d63fdb69Smrg	      fi
6919d63fdb69Smrg	    else
6920d63fdb69Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
6921d63fdb69Smrg	      add_dir="-L$libdir"
6922d63fdb69Smrg	      # Try looking first in the location we're being installed to.
6923d63fdb69Smrg	      if test -n "$inst_prefix_dir"; then
6924d63fdb69Smrg		case $libdir in
6925d63fdb69Smrg		  [\\/]*)
692648c85eb7Smrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
6927d63fdb69Smrg		    ;;
6928d63fdb69Smrg		esac
6929d63fdb69Smrg	      fi
6930d63fdb69Smrg	      add="-l$name"
6931d63fdb69Smrg	    fi
6932d63fdb69Smrg
6933d63fdb69Smrg	    if test "$linkmode" = prog; then
6934d63fdb69Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
6935d63fdb69Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
6936d63fdb69Smrg	    else
6937d63fdb69Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6938d63fdb69Smrg	      test -n "$add" && deplibs="$add $deplibs"
6939d63fdb69Smrg	    fi
6940d63fdb69Smrg	  fi
6941d63fdb69Smrg	elif test "$linkmode" = prog; then
6942d63fdb69Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
6943d63fdb69Smrg	  # is not unsupported.  This is valid on all known static and
6944d63fdb69Smrg	  # shared platforms.
6945d63fdb69Smrg	  if test "$hardcode_direct" != unsupported; then
6946d63fdb69Smrg	    test -n "$old_library" && linklib="$old_library"
6947d63fdb69Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
6948d63fdb69Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
6949d63fdb69Smrg	  else
6950d63fdb69Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
6951d63fdb69Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
6952d63fdb69Smrg	  fi
6953d63fdb69Smrg	elif test "$build_libtool_libs" = yes; then
6954d63fdb69Smrg	  # Not a shared library
6955d63fdb69Smrg	  if test "$deplibs_check_method" != pass_all; then
6956d63fdb69Smrg	    # We're trying link a shared library against a static one
6957d63fdb69Smrg	    # but the system doesn't support it.
6958d63fdb69Smrg
6959d63fdb69Smrg	    # Just print a warning and add the library to dependency_libs so
6960d63fdb69Smrg	    # that the program can be linked against the static library.
696155acc8fcSmrg	    echo
6962d63fdb69Smrg	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
696355acc8fcSmrg	    echo "*** I have the capability to make that library automatically link in when"
696455acc8fcSmrg	    echo "*** you link to this library.  But I can only do this if you have a"
696555acc8fcSmrg	    echo "*** shared version of the library, which you do not appear to have."
6966d63fdb69Smrg	    if test "$module" = yes; then
696755acc8fcSmrg	      echo "*** But as you try to build a module library, libtool will still create "
696855acc8fcSmrg	      echo "*** a static module, that should work as long as the dlopening application"
696955acc8fcSmrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
6970d63fdb69Smrg	      if test -z "$global_symbol_pipe"; then
697155acc8fcSmrg		echo
697255acc8fcSmrg		echo "*** However, this would only work if libtool was able to extract symbol"
697355acc8fcSmrg		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
697455acc8fcSmrg		echo "*** not find such a program.  So, this module is probably useless."
697555acc8fcSmrg		echo "*** \`nm' from GNU binutils and a full rebuild may help."
6976d63fdb69Smrg	      fi
6977d63fdb69Smrg	      if test "$build_old_libs" = no; then
6978d63fdb69Smrg		build_libtool_libs=module
6979d63fdb69Smrg		build_old_libs=yes
6980d63fdb69Smrg	      else
6981d63fdb69Smrg		build_libtool_libs=no
6982d63fdb69Smrg	      fi
6983d63fdb69Smrg	    fi
6984d63fdb69Smrg	  else
6985d63fdb69Smrg	    deplibs="$dir/$old_library $deplibs"
6986d63fdb69Smrg	    link_static=yes
6987d63fdb69Smrg	  fi
6988d63fdb69Smrg	fi # link shared/static library?
6989d63fdb69Smrg
6990d63fdb69Smrg	if test "$linkmode" = lib; then
6991d63fdb69Smrg	  if test -n "$dependency_libs" &&
6992d63fdb69Smrg	     { test "$hardcode_into_libs" != yes ||
6993d63fdb69Smrg	       test "$build_old_libs" = yes ||
6994d63fdb69Smrg	       test "$link_static" = yes; }; then
6995d63fdb69Smrg	    # Extract -R from dependency_libs
6996d63fdb69Smrg	    temp_deplibs=
6997d63fdb69Smrg	    for libdir in $dependency_libs; do
6998d63fdb69Smrg	      case $libdir in
6999d63fdb69Smrg	      -R*) func_stripname '-R' '' "$libdir"
7000d63fdb69Smrg	           temp_xrpath=$func_stripname_result
7001d63fdb69Smrg		   case " $xrpath " in
7002d63fdb69Smrg		   *" $temp_xrpath "*) ;;
700348c85eb7Smrg		   *) func_append xrpath " $temp_xrpath";;
7004d63fdb69Smrg		   esac;;
700548c85eb7Smrg	      *) func_append temp_deplibs " $libdir";;
7006d63fdb69Smrg	      esac
7007d63fdb69Smrg	    done
7008d63fdb69Smrg	    dependency_libs="$temp_deplibs"
7009d63fdb69Smrg	  fi
7010d63fdb69Smrg
701148c85eb7Smrg	  func_append newlib_search_path " $absdir"
7012d63fdb69Smrg	  # Link against this library
7013d63fdb69Smrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
7014d63fdb69Smrg	  # ... and its dependency_libs
7015d63fdb69Smrg	  tmp_libs=
7016d63fdb69Smrg	  for deplib in $dependency_libs; do
7017d63fdb69Smrg	    newdependency_libs="$deplib $newdependency_libs"
701848c85eb7Smrg	    case $deplib in
701948c85eb7Smrg              -L*) func_stripname '-L' '' "$deplib"
702048c85eb7Smrg                   func_resolve_sysroot "$func_stripname_result";;
702148c85eb7Smrg              *) func_resolve_sysroot "$deplib" ;;
702248c85eb7Smrg            esac
702348c85eb7Smrg	    if $opt_preserve_dup_deps ; then
7024d63fdb69Smrg	      case "$tmp_libs " in
702548c85eb7Smrg	      *" $func_resolve_sysroot_result "*)
702648c85eb7Smrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
7027d63fdb69Smrg	      esac
7028d63fdb69Smrg	    fi
702948c85eb7Smrg	    func_append tmp_libs " $func_resolve_sysroot_result"
7030d63fdb69Smrg	  done
7031d63fdb69Smrg
7032d63fdb69Smrg	  if test "$link_all_deplibs" != no; then
7033d63fdb69Smrg	    # Add the search paths of all dependency libraries
7034d63fdb69Smrg	    for deplib in $dependency_libs; do
703555acc8fcSmrg	      path=
7036d63fdb69Smrg	      case $deplib in
7037d63fdb69Smrg	      -L*) path="$deplib" ;;
7038d63fdb69Smrg	      *.la)
703948c85eb7Smrg	        func_resolve_sysroot "$deplib"
704048c85eb7Smrg	        deplib=$func_resolve_sysroot_result
7041d63fdb69Smrg	        func_dirname "$deplib" "" "."
704248c85eb7Smrg		dir=$func_dirname_result
7043d63fdb69Smrg		# We need an absolute path.
7044d63fdb69Smrg		case $dir in
7045d63fdb69Smrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
7046d63fdb69Smrg		*)
7047d63fdb69Smrg		  absdir=`cd "$dir" && pwd`
7048d63fdb69Smrg		  if test -z "$absdir"; then
7049d63fdb69Smrg		    func_warning "cannot determine absolute directory name of \`$dir'"
7050d63fdb69Smrg		    absdir="$dir"
7051d63fdb69Smrg		  fi
7052d63fdb69Smrg		  ;;
7053d63fdb69Smrg		esac
7054d63fdb69Smrg		if $GREP "^installed=no" $deplib > /dev/null; then
7055d63fdb69Smrg		case $host in
7056d63fdb69Smrg		*-*-darwin*)
7057d63fdb69Smrg		  depdepl=
7058d63fdb69Smrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
7059d63fdb69Smrg		  if test -n "$deplibrary_names" ; then
7060d63fdb69Smrg		    for tmp in $deplibrary_names ; do
7061d63fdb69Smrg		      depdepl=$tmp
7062d63fdb69Smrg		    done
7063d63fdb69Smrg		    if test -f "$absdir/$objdir/$depdepl" ; then
7064d63fdb69Smrg		      depdepl="$absdir/$objdir/$depdepl"
7065d63fdb69Smrg		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
7066d63fdb69Smrg                      if test -z "$darwin_install_name"; then
7067d63fdb69Smrg                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
7068d63fdb69Smrg                      fi
706948c85eb7Smrg		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
707048c85eb7Smrg		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
7071d63fdb69Smrg		      path=
7072d63fdb69Smrg		    fi
7073d63fdb69Smrg		  fi
7074d63fdb69Smrg		  ;;
7075d63fdb69Smrg		*)
7076d63fdb69Smrg		  path="-L$absdir/$objdir"
7077d63fdb69Smrg		  ;;
7078d63fdb69Smrg		esac
7079d63fdb69Smrg		else
7080d63fdb69Smrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
7081d63fdb69Smrg		  test -z "$libdir" && \
7082d63fdb69Smrg		    func_fatal_error "\`$deplib' is not a valid libtool archive"
7083d63fdb69Smrg		  test "$absdir" != "$libdir" && \
7084d63fdb69Smrg		    func_warning "\`$deplib' seems to be moved"
7085d63fdb69Smrg
7086d63fdb69Smrg		  path="-L$absdir"
7087d63fdb69Smrg		fi
7088d63fdb69Smrg		;;
7089d63fdb69Smrg	      esac
7090d63fdb69Smrg	      case " $deplibs " in
7091d63fdb69Smrg	      *" $path "*) ;;
7092d63fdb69Smrg	      *) deplibs="$path $deplibs" ;;
7093d63fdb69Smrg	      esac
7094d63fdb69Smrg	    done
7095d63fdb69Smrg	  fi # link_all_deplibs != no
7096d63fdb69Smrg	fi # linkmode = lib
7097d63fdb69Smrg      done # for deplib in $libs
7098d63fdb69Smrg      if test "$pass" = link; then
7099d63fdb69Smrg	if test "$linkmode" = "prog"; then
7100d63fdb69Smrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
7101d63fdb69Smrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
7102d63fdb69Smrg	else
710355acc8fcSmrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7104d63fdb69Smrg	fi
7105d63fdb69Smrg      fi
7106d63fdb69Smrg      dependency_libs="$newdependency_libs"
7107d63fdb69Smrg      if test "$pass" = dlpreopen; then
7108d63fdb69Smrg	# Link the dlpreopened libraries before other libraries
7109d63fdb69Smrg	for deplib in $save_deplibs; do
7110d63fdb69Smrg	  deplibs="$deplib $deplibs"
7111d63fdb69Smrg	done
7112d63fdb69Smrg      fi
7113d63fdb69Smrg      if test "$pass" != dlopen; then
7114d63fdb69Smrg	if test "$pass" != conv; then
7115d63fdb69Smrg	  # Make sure lib_search_path contains only unique directories.
7116d63fdb69Smrg	  lib_search_path=
7117d63fdb69Smrg	  for dir in $newlib_search_path; do
7118d63fdb69Smrg	    case "$lib_search_path " in
7119d63fdb69Smrg	    *" $dir "*) ;;
712048c85eb7Smrg	    *) func_append lib_search_path " $dir" ;;
7121d63fdb69Smrg	    esac
7122d63fdb69Smrg	  done
7123d63fdb69Smrg	  newlib_search_path=
7124d63fdb69Smrg	fi
7125d63fdb69Smrg
7126d63fdb69Smrg	if test "$linkmode,$pass" != "prog,link"; then
7127d63fdb69Smrg	  vars="deplibs"
7128d63fdb69Smrg	else
7129d63fdb69Smrg	  vars="compile_deplibs finalize_deplibs"
7130d63fdb69Smrg	fi
7131d63fdb69Smrg	for var in $vars dependency_libs; do
7132d63fdb69Smrg	  # Add libraries to $var in reverse order
7133d63fdb69Smrg	  eval tmp_libs=\"\$$var\"
7134d63fdb69Smrg	  new_libs=
7135d63fdb69Smrg	  for deplib in $tmp_libs; do
7136d63fdb69Smrg	    # FIXME: Pedantically, this is the right thing to do, so
7137d63fdb69Smrg	    #        that some nasty dependency loop isn't accidentally
7138d63fdb69Smrg	    #        broken:
7139d63fdb69Smrg	    #new_libs="$deplib $new_libs"
7140d63fdb69Smrg	    # Pragmatically, this seems to cause very few problems in
7141d63fdb69Smrg	    # practice:
7142d63fdb69Smrg	    case $deplib in
7143d63fdb69Smrg	    -L*) new_libs="$deplib $new_libs" ;;
7144d63fdb69Smrg	    -R*) ;;
7145d63fdb69Smrg	    *)
7146d63fdb69Smrg	      # And here is the reason: when a library appears more
7147d63fdb69Smrg	      # than once as an explicit dependence of a library, or
7148d63fdb69Smrg	      # is implicitly linked in more than once by the
7149d63fdb69Smrg	      # compiler, it is considered special, and multiple
7150d63fdb69Smrg	      # occurrences thereof are not removed.  Compare this
7151d63fdb69Smrg	      # with having the same library being listed as a
7152d63fdb69Smrg	      # dependency of multiple other libraries: in this case,
7153d63fdb69Smrg	      # we know (pedantically, we assume) the library does not
7154d63fdb69Smrg	      # need to be listed more than once, so we keep only the
7155d63fdb69Smrg	      # last copy.  This is not always right, but it is rare
7156d63fdb69Smrg	      # enough that we require users that really mean to play
7157d63fdb69Smrg	      # such unportable linking tricks to link the library
7158d63fdb69Smrg	      # using -Wl,-lname, so that libtool does not consider it
7159d63fdb69Smrg	      # for duplicate removal.
7160d63fdb69Smrg	      case " $specialdeplibs " in
7161d63fdb69Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
7162d63fdb69Smrg	      *)
7163d63fdb69Smrg		case " $new_libs " in
7164d63fdb69Smrg		*" $deplib "*) ;;
7165d63fdb69Smrg		*) new_libs="$deplib $new_libs" ;;
7166d63fdb69Smrg		esac
7167d63fdb69Smrg		;;
7168d63fdb69Smrg	      esac
7169d63fdb69Smrg	      ;;
7170d63fdb69Smrg	    esac
7171d63fdb69Smrg	  done
7172d63fdb69Smrg	  tmp_libs=
7173d63fdb69Smrg	  for deplib in $new_libs; do
7174d63fdb69Smrg	    case $deplib in
7175d63fdb69Smrg	    -L*)
7176d63fdb69Smrg	      case " $tmp_libs " in
7177d63fdb69Smrg	      *" $deplib "*) ;;
717848c85eb7Smrg	      *) func_append tmp_libs " $deplib" ;;
7179d63fdb69Smrg	      esac
7180d63fdb69Smrg	      ;;
718148c85eb7Smrg	    *) func_append tmp_libs " $deplib" ;;
7182d63fdb69Smrg	    esac
7183d63fdb69Smrg	  done
7184d63fdb69Smrg	  eval $var=\"$tmp_libs\"
7185d63fdb69Smrg	done # for var
7186d63fdb69Smrg      fi
7187d63fdb69Smrg      # Last step: remove runtime libs from dependency_libs
7188d63fdb69Smrg      # (they stay in deplibs)
7189d63fdb69Smrg      tmp_libs=
7190d63fdb69Smrg      for i in $dependency_libs ; do
7191d63fdb69Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
7192d63fdb69Smrg	*" $i "*)
7193d63fdb69Smrg	  i=""
7194d63fdb69Smrg	  ;;
7195d63fdb69Smrg	esac
7196d63fdb69Smrg	if test -n "$i" ; then
719748c85eb7Smrg	  func_append tmp_libs " $i"
7198d63fdb69Smrg	fi
7199d63fdb69Smrg      done
7200d63fdb69Smrg      dependency_libs=$tmp_libs
7201d63fdb69Smrg    done # for pass
7202d63fdb69Smrg    if test "$linkmode" = prog; then
7203d63fdb69Smrg      dlfiles="$newdlfiles"
7204d63fdb69Smrg    fi
7205d63fdb69Smrg    if test "$linkmode" = prog || test "$linkmode" = lib; then
7206d63fdb69Smrg      dlprefiles="$newdlprefiles"
7207d63fdb69Smrg    fi
7208d63fdb69Smrg
7209d63fdb69Smrg    case $linkmode in
7210d63fdb69Smrg    oldlib)
7211d63fdb69Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
7212d63fdb69Smrg	func_warning "\`-dlopen' is ignored for archives"
7213d63fdb69Smrg      fi
7214d63fdb69Smrg
7215d63fdb69Smrg      case " $deplibs" in
7216d63fdb69Smrg      *\ -l* | *\ -L*)
7217d63fdb69Smrg	func_warning "\`-l' and \`-L' are ignored for archives" ;;
7218d63fdb69Smrg      esac
7219d63fdb69Smrg
7220d63fdb69Smrg      test -n "$rpath" && \
7221d63fdb69Smrg	func_warning "\`-rpath' is ignored for archives"
7222d63fdb69Smrg
7223d63fdb69Smrg      test -n "$xrpath" && \
7224d63fdb69Smrg	func_warning "\`-R' is ignored for archives"
7225d63fdb69Smrg
7226d63fdb69Smrg      test -n "$vinfo" && \
7227d63fdb69Smrg	func_warning "\`-version-info/-version-number' is ignored for archives"
7228d63fdb69Smrg
7229d63fdb69Smrg      test -n "$release" && \
7230d63fdb69Smrg	func_warning "\`-release' is ignored for archives"
7231d63fdb69Smrg
7232d63fdb69Smrg      test -n "$export_symbols$export_symbols_regex" && \
7233d63fdb69Smrg	func_warning "\`-export-symbols' is ignored for archives"
7234d63fdb69Smrg
7235d63fdb69Smrg      # Now set the variables for building old libraries.
7236d63fdb69Smrg      build_libtool_libs=no
7237d63fdb69Smrg      oldlibs="$output"
723848c85eb7Smrg      func_append objs "$old_deplibs"
7239d63fdb69Smrg      ;;
7240d63fdb69Smrg
7241d63fdb69Smrg    lib)
7242d63fdb69Smrg      # Make sure we only generate libraries of the form `libNAME.la'.
7243d63fdb69Smrg      case $outputname in
7244d63fdb69Smrg      lib*)
7245d63fdb69Smrg	func_stripname 'lib' '.la' "$outputname"
7246d63fdb69Smrg	name=$func_stripname_result
7247d63fdb69Smrg	eval shared_ext=\"$shrext_cmds\"
7248d63fdb69Smrg	eval libname=\"$libname_spec\"
7249d63fdb69Smrg	;;
7250d63fdb69Smrg      *)
7251d63fdb69Smrg	test "$module" = no && \
7252d63fdb69Smrg	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
7253d63fdb69Smrg
7254d63fdb69Smrg	if test "$need_lib_prefix" != no; then
7255d63fdb69Smrg	  # Add the "lib" prefix for modules if required
7256d63fdb69Smrg	  func_stripname '' '.la' "$outputname"
7257d63fdb69Smrg	  name=$func_stripname_result
7258d63fdb69Smrg	  eval shared_ext=\"$shrext_cmds\"
7259d63fdb69Smrg	  eval libname=\"$libname_spec\"
7260d63fdb69Smrg	else
7261d63fdb69Smrg	  func_stripname '' '.la' "$outputname"
7262d63fdb69Smrg	  libname=$func_stripname_result
7263d63fdb69Smrg	fi
7264d63fdb69Smrg	;;
7265d63fdb69Smrg      esac
7266d63fdb69Smrg
7267d63fdb69Smrg      if test -n "$objs"; then
7268d63fdb69Smrg	if test "$deplibs_check_method" != pass_all; then
7269d63fdb69Smrg	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
7270d63fdb69Smrg	else
727155acc8fcSmrg	  echo
7272d63fdb69Smrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
7273d63fdb69Smrg	  $ECHO "*** objects $objs is not portable!"
727448c85eb7Smrg	  func_append libobjs " $objs"
7275d63fdb69Smrg	fi
7276d63fdb69Smrg      fi
7277d63fdb69Smrg
7278d63fdb69Smrg      test "$dlself" != no && \
7279d63fdb69Smrg	func_warning "\`-dlopen self' is ignored for libtool libraries"
7280d63fdb69Smrg
7281d63fdb69Smrg      set dummy $rpath
7282d63fdb69Smrg      shift
7283d63fdb69Smrg      test "$#" -gt 1 && \
7284d63fdb69Smrg	func_warning "ignoring multiple \`-rpath's for a libtool library"
7285d63fdb69Smrg
7286d63fdb69Smrg      install_libdir="$1"
7287d63fdb69Smrg
7288d63fdb69Smrg      oldlibs=
7289d63fdb69Smrg      if test -z "$rpath"; then
7290d63fdb69Smrg	if test "$build_libtool_libs" = yes; then
7291d63fdb69Smrg	  # Building a libtool convenience library.
7292d63fdb69Smrg	  # Some compilers have problems with a `.al' extension so
7293d63fdb69Smrg	  # convenience libraries should have the same extension an
7294d63fdb69Smrg	  # archive normally would.
7295d63fdb69Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
7296d63fdb69Smrg	  build_libtool_libs=convenience
7297d63fdb69Smrg	  build_old_libs=yes
7298d63fdb69Smrg	fi
7299d63fdb69Smrg
7300d63fdb69Smrg	test -n "$vinfo" && \
7301d63fdb69Smrg	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
7302d63fdb69Smrg
7303d63fdb69Smrg	test -n "$release" && \
7304d63fdb69Smrg	  func_warning "\`-release' is ignored for convenience libraries"
7305d63fdb69Smrg      else
7306d63fdb69Smrg
7307d63fdb69Smrg	# Parse the version information argument.
7308d63fdb69Smrg	save_ifs="$IFS"; IFS=':'
7309d63fdb69Smrg	set dummy $vinfo 0 0 0
7310d63fdb69Smrg	shift
7311d63fdb69Smrg	IFS="$save_ifs"
7312d63fdb69Smrg
7313d63fdb69Smrg	test -n "$7" && \
7314d63fdb69Smrg	  func_fatal_help "too many parameters to \`-version-info'"
7315d63fdb69Smrg
7316d63fdb69Smrg	# convert absolute version numbers to libtool ages
7317d63fdb69Smrg	# this retains compatibility with .la files and attempts
7318d63fdb69Smrg	# to make the code below a bit more comprehensible
7319d63fdb69Smrg
7320d63fdb69Smrg	case $vinfo_number in
7321d63fdb69Smrg	yes)
7322d63fdb69Smrg	  number_major="$1"
7323d63fdb69Smrg	  number_minor="$2"
7324d63fdb69Smrg	  number_revision="$3"
7325d63fdb69Smrg	  #
7326d63fdb69Smrg	  # There are really only two kinds -- those that
7327d63fdb69Smrg	  # use the current revision as the major version
7328d63fdb69Smrg	  # and those that subtract age and use age as
7329d63fdb69Smrg	  # a minor version.  But, then there is irix
7330d63fdb69Smrg	  # which has an extra 1 added just for fun
7331d63fdb69Smrg	  #
7332d63fdb69Smrg	  case $version_type in
733348c85eb7Smrg	  # correct linux to gnu/linux during the next big refactor
7334d63fdb69Smrg	  darwin|linux|osf|windows|none)
7335d63fdb69Smrg	    func_arith $number_major + $number_minor
7336d63fdb69Smrg	    current=$func_arith_result
7337d63fdb69Smrg	    age="$number_minor"
7338d63fdb69Smrg	    revision="$number_revision"
7339d63fdb69Smrg	    ;;
734055acc8fcSmrg	  freebsd-aout|freebsd-elf|qnx|sunos)
7341d63fdb69Smrg	    current="$number_major"
7342d63fdb69Smrg	    revision="$number_minor"
7343d63fdb69Smrg	    age="0"
7344d63fdb69Smrg	    ;;
7345d63fdb69Smrg	  irix|nonstopux)
7346d63fdb69Smrg	    func_arith $number_major + $number_minor
7347d63fdb69Smrg	    current=$func_arith_result
7348d63fdb69Smrg	    age="$number_minor"
7349d63fdb69Smrg	    revision="$number_minor"
7350d63fdb69Smrg	    lt_irix_increment=no
7351d63fdb69Smrg	    ;;
7352d63fdb69Smrg	  esac
7353d63fdb69Smrg	  ;;
7354d63fdb69Smrg	no)
7355d63fdb69Smrg	  current="$1"
7356d63fdb69Smrg	  revision="$2"
7357d63fdb69Smrg	  age="$3"
7358d63fdb69Smrg	  ;;
7359d63fdb69Smrg	esac
7360d63fdb69Smrg
7361d63fdb69Smrg	# Check that each of the things are valid numbers.
7362d63fdb69Smrg	case $current in
7363d63fdb69Smrg	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]) ;;
7364d63fdb69Smrg	*)
7365d63fdb69Smrg	  func_error "CURRENT \`$current' must be a nonnegative integer"
7366d63fdb69Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
7367d63fdb69Smrg	  ;;
7368d63fdb69Smrg	esac
7369d63fdb69Smrg
7370d63fdb69Smrg	case $revision in
7371d63fdb69Smrg	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]) ;;
7372d63fdb69Smrg	*)
7373d63fdb69Smrg	  func_error "REVISION \`$revision' must be a nonnegative integer"
7374d63fdb69Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
7375d63fdb69Smrg	  ;;
7376d63fdb69Smrg	esac
7377d63fdb69Smrg
7378d63fdb69Smrg	case $age in
7379d63fdb69Smrg	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]) ;;
7380d63fdb69Smrg	*)
7381d63fdb69Smrg	  func_error "AGE \`$age' must be a nonnegative integer"
7382d63fdb69Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
7383d63fdb69Smrg	  ;;
7384d63fdb69Smrg	esac
7385d63fdb69Smrg
7386d63fdb69Smrg	if test "$age" -gt "$current"; then
7387d63fdb69Smrg	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
7388d63fdb69Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
7389d63fdb69Smrg	fi
7390d63fdb69Smrg
7391d63fdb69Smrg	# Calculate the version variables.
7392d63fdb69Smrg	major=
7393d63fdb69Smrg	versuffix=
7394d63fdb69Smrg	verstring=
7395d63fdb69Smrg	case $version_type in
7396d63fdb69Smrg	none) ;;
7397d63fdb69Smrg
7398d63fdb69Smrg	darwin)
7399d63fdb69Smrg	  # Like Linux, but with the current version available in
7400d63fdb69Smrg	  # verstring for coding it into the library header
7401d63fdb69Smrg	  func_arith $current - $age
7402d63fdb69Smrg	  major=.$func_arith_result
7403d63fdb69Smrg	  versuffix="$major.$age.$revision"
7404d63fdb69Smrg	  # Darwin ld doesn't like 0 for these options...
7405d63fdb69Smrg	  func_arith $current + 1
7406d63fdb69Smrg	  minor_current=$func_arith_result
7407d63fdb69Smrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
7408d63fdb69Smrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
7409d63fdb69Smrg	  ;;
7410d63fdb69Smrg
7411d63fdb69Smrg	freebsd-aout)
7412d63fdb69Smrg	  major=".$current"
7413d63fdb69Smrg	  versuffix=".$current.$revision";
7414d63fdb69Smrg	  ;;
7415d63fdb69Smrg
7416d63fdb69Smrg	freebsd-elf)
7417d63fdb69Smrg	  major=".$current"
7418d63fdb69Smrg	  versuffix=".$current"
7419d63fdb69Smrg	  ;;
7420d63fdb69Smrg
7421d63fdb69Smrg	irix | nonstopux)
7422d63fdb69Smrg	  if test "X$lt_irix_increment" = "Xno"; then
7423d63fdb69Smrg	    func_arith $current - $age
7424d63fdb69Smrg	  else
7425d63fdb69Smrg	    func_arith $current - $age + 1
7426d63fdb69Smrg	  fi
7427d63fdb69Smrg	  major=$func_arith_result
7428d63fdb69Smrg
7429d63fdb69Smrg	  case $version_type in
7430d63fdb69Smrg	    nonstopux) verstring_prefix=nonstopux ;;
7431d63fdb69Smrg	    *)         verstring_prefix=sgi ;;
7432d63fdb69Smrg	  esac
7433d63fdb69Smrg	  verstring="$verstring_prefix$major.$revision"
7434d63fdb69Smrg
7435d63fdb69Smrg	  # Add in all the interfaces that we are compatible with.
7436d63fdb69Smrg	  loop=$revision
7437d63fdb69Smrg	  while test "$loop" -ne 0; do
7438d63fdb69Smrg	    func_arith $revision - $loop
7439d63fdb69Smrg	    iface=$func_arith_result
7440d63fdb69Smrg	    func_arith $loop - 1
7441d63fdb69Smrg	    loop=$func_arith_result
7442d63fdb69Smrg	    verstring="$verstring_prefix$major.$iface:$verstring"
7443d63fdb69Smrg	  done
7444d63fdb69Smrg
7445d63fdb69Smrg	  # Before this point, $major must not contain `.'.
7446d63fdb69Smrg	  major=.$major
7447d63fdb69Smrg	  versuffix="$major.$revision"
7448d63fdb69Smrg	  ;;
7449d63fdb69Smrg
745048c85eb7Smrg	linux) # correct to gnu/linux during the next big refactor
7451d63fdb69Smrg	  func_arith $current - $age
7452d63fdb69Smrg	  major=.$func_arith_result
7453d63fdb69Smrg	  versuffix="$major.$age.$revision"
7454d63fdb69Smrg	  ;;
7455d63fdb69Smrg
7456d63fdb69Smrg	osf)
7457d63fdb69Smrg	  func_arith $current - $age
7458d63fdb69Smrg	  major=.$func_arith_result
7459d63fdb69Smrg	  versuffix=".$current.$age.$revision"
7460d63fdb69Smrg	  verstring="$current.$age.$revision"
7461d63fdb69Smrg
7462d63fdb69Smrg	  # Add in all the interfaces that we are compatible with.
7463d63fdb69Smrg	  loop=$age
7464d63fdb69Smrg	  while test "$loop" -ne 0; do
7465d63fdb69Smrg	    func_arith $current - $loop
7466d63fdb69Smrg	    iface=$func_arith_result
7467d63fdb69Smrg	    func_arith $loop - 1
7468d63fdb69Smrg	    loop=$func_arith_result
7469d63fdb69Smrg	    verstring="$verstring:${iface}.0"
7470d63fdb69Smrg	  done
7471d63fdb69Smrg
7472d63fdb69Smrg	  # Make executables depend on our current version.
747348c85eb7Smrg	  func_append verstring ":${current}.0"
7474d63fdb69Smrg	  ;;
7475d63fdb69Smrg
7476d63fdb69Smrg	qnx)
7477d63fdb69Smrg	  major=".$current"
7478d63fdb69Smrg	  versuffix=".$current"
7479d63fdb69Smrg	  ;;
7480d63fdb69Smrg
7481d63fdb69Smrg	sunos)
7482d63fdb69Smrg	  major=".$current"
7483d63fdb69Smrg	  versuffix=".$current.$revision"
7484d63fdb69Smrg	  ;;
7485d63fdb69Smrg
7486d63fdb69Smrg	windows)
7487d63fdb69Smrg	  # Use '-' rather than '.', since we only want one
7488d63fdb69Smrg	  # extension on DOS 8.3 filesystems.
7489d63fdb69Smrg	  func_arith $current - $age
7490d63fdb69Smrg	  major=$func_arith_result
7491d63fdb69Smrg	  versuffix="-$major"
7492d63fdb69Smrg	  ;;
7493d63fdb69Smrg
7494d63fdb69Smrg	*)
7495d63fdb69Smrg	  func_fatal_configuration "unknown library version type \`$version_type'"
7496d63fdb69Smrg	  ;;
7497d63fdb69Smrg	esac
7498d63fdb69Smrg
7499d63fdb69Smrg	# Clear the version info if we defaulted, and they specified a release.
7500d63fdb69Smrg	if test -z "$vinfo" && test -n "$release"; then
7501d63fdb69Smrg	  major=
7502d63fdb69Smrg	  case $version_type in
7503d63fdb69Smrg	  darwin)
7504d63fdb69Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
7505d63fdb69Smrg	    # problems, so we reset it completely
7506d63fdb69Smrg	    verstring=
7507d63fdb69Smrg	    ;;
7508d63fdb69Smrg	  *)
7509d63fdb69Smrg	    verstring="0.0"
7510d63fdb69Smrg	    ;;
7511d63fdb69Smrg	  esac
7512d63fdb69Smrg	  if test "$need_version" = no; then
7513d63fdb69Smrg	    versuffix=
7514d63fdb69Smrg	  else
7515d63fdb69Smrg	    versuffix=".0.0"
7516d63fdb69Smrg	  fi
7517d63fdb69Smrg	fi
7518d63fdb69Smrg
7519d63fdb69Smrg	# Remove version info from name if versioning should be avoided
7520d63fdb69Smrg	if test "$avoid_version" = yes && test "$need_version" = no; then
7521d63fdb69Smrg	  major=
7522d63fdb69Smrg	  versuffix=
7523d63fdb69Smrg	  verstring=""
7524d63fdb69Smrg	fi
7525d63fdb69Smrg
7526d63fdb69Smrg	# Check to see if the archive will have undefined symbols.
7527d63fdb69Smrg	if test "$allow_undefined" = yes; then
7528d63fdb69Smrg	  if test "$allow_undefined_flag" = unsupported; then
7529d63fdb69Smrg	    func_warning "undefined symbols not allowed in $host shared libraries"
7530d63fdb69Smrg	    build_libtool_libs=no
7531d63fdb69Smrg	    build_old_libs=yes
7532d63fdb69Smrg	  fi
7533d63fdb69Smrg	else
7534d63fdb69Smrg	  # Don't allow undefined symbols.
7535d63fdb69Smrg	  allow_undefined_flag="$no_undefined_flag"
7536d63fdb69Smrg	fi
7537d63fdb69Smrg
7538d63fdb69Smrg      fi
7539d63fdb69Smrg
7540d63fdb69Smrg      func_generate_dlsyms "$libname" "$libname" "yes"
754148c85eb7Smrg      func_append libobjs " $symfileobj"
7542d63fdb69Smrg      test "X$libobjs" = "X " && libobjs=
7543d63fdb69Smrg
754448c85eb7Smrg      if test "$opt_mode" != relink; then
7545d63fdb69Smrg	# Remove our outputs, but don't remove object files since they
7546d63fdb69Smrg	# may have been created when compiling PIC objects.
7547d63fdb69Smrg	removelist=
7548d63fdb69Smrg	tempremovelist=`$ECHO "$output_objdir/*"`
7549d63fdb69Smrg	for p in $tempremovelist; do
7550d63fdb69Smrg	  case $p in
7551d63fdb69Smrg	    *.$objext | *.gcno)
7552d63fdb69Smrg	       ;;
7553d63fdb69Smrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
7554d63fdb69Smrg	       if test "X$precious_files_regex" != "X"; then
7555d63fdb69Smrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
7556d63fdb69Smrg		 then
7557d63fdb69Smrg		   continue
7558d63fdb69Smrg		 fi
7559d63fdb69Smrg	       fi
756048c85eb7Smrg	       func_append removelist " $p"
7561d63fdb69Smrg	       ;;
7562d63fdb69Smrg	    *) ;;
7563d63fdb69Smrg	  esac
7564d63fdb69Smrg	done
7565d63fdb69Smrg	test -n "$removelist" && \
7566d63fdb69Smrg	  func_show_eval "${RM}r \$removelist"
7567d63fdb69Smrg      fi
7568d63fdb69Smrg
7569d63fdb69Smrg      # Now set the variables for building old libraries.
7570d63fdb69Smrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
757148c85eb7Smrg	func_append oldlibs " $output_objdir/$libname.$libext"
7572d63fdb69Smrg
7573d63fdb69Smrg	# Transform .lo files to .o files.
757455acc8fcSmrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
7575d63fdb69Smrg      fi
7576d63fdb69Smrg
7577d63fdb69Smrg      # Eliminate all temporary directories.
7578d63fdb69Smrg      #for path in $notinst_path; do
757955acc8fcSmrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
758055acc8fcSmrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
758155acc8fcSmrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
7582d63fdb69Smrg      #done
7583d63fdb69Smrg
7584d63fdb69Smrg      if test -n "$xrpath"; then
7585d63fdb69Smrg	# If the user specified any rpath flags, then add them.
7586d63fdb69Smrg	temp_xrpath=
7587d63fdb69Smrg	for libdir in $xrpath; do
758848c85eb7Smrg	  func_replace_sysroot "$libdir"
758948c85eb7Smrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
7590d63fdb69Smrg	  case "$finalize_rpath " in
7591d63fdb69Smrg	  *" $libdir "*) ;;
759248c85eb7Smrg	  *) func_append finalize_rpath " $libdir" ;;
7593d63fdb69Smrg	  esac
7594d63fdb69Smrg	done
7595d63fdb69Smrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
7596d63fdb69Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
7597d63fdb69Smrg	fi
7598d63fdb69Smrg      fi
7599d63fdb69Smrg
7600d63fdb69Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
7601d63fdb69Smrg      old_dlfiles="$dlfiles"
7602d63fdb69Smrg      dlfiles=
7603d63fdb69Smrg      for lib in $old_dlfiles; do
7604d63fdb69Smrg	case " $dlprefiles $dlfiles " in
7605d63fdb69Smrg	*" $lib "*) ;;
760648c85eb7Smrg	*) func_append dlfiles " $lib" ;;
7607d63fdb69Smrg	esac
7608d63fdb69Smrg      done
7609d63fdb69Smrg
7610d63fdb69Smrg      # Make sure dlprefiles contains only unique files
7611d63fdb69Smrg      old_dlprefiles="$dlprefiles"
7612d63fdb69Smrg      dlprefiles=
7613d63fdb69Smrg      for lib in $old_dlprefiles; do
7614d63fdb69Smrg	case "$dlprefiles " in
7615d63fdb69Smrg	*" $lib "*) ;;
761648c85eb7Smrg	*) func_append dlprefiles " $lib" ;;
7617d63fdb69Smrg	esac
7618d63fdb69Smrg      done
7619d63fdb69Smrg
7620d63fdb69Smrg      if test "$build_libtool_libs" = yes; then
7621d63fdb69Smrg	if test -n "$rpath"; then
7622d63fdb69Smrg	  case $host in
762355acc8fcSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
7624d63fdb69Smrg	    # these systems don't actually have a c library (as such)!
7625d63fdb69Smrg	    ;;
7626d63fdb69Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
7627d63fdb69Smrg	    # Rhapsody C library is in the System framework
762848c85eb7Smrg	    func_append deplibs " System.ltframework"
7629d63fdb69Smrg	    ;;
7630d63fdb69Smrg	  *-*-netbsd*)
7631d63fdb69Smrg	    # Don't link with libc until the a.out ld.so is fixed.
7632d63fdb69Smrg	    ;;
7633d63fdb69Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
7634d63fdb69Smrg	    # Do not include libc due to us having libc/libc_r.
7635d63fdb69Smrg	    ;;
7636d63fdb69Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
7637d63fdb69Smrg	    # Causes problems with __ctype
7638d63fdb69Smrg	    ;;
7639d63fdb69Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
7640d63fdb69Smrg	    # Compiler inserts libc in the correct place for threads to work
7641d63fdb69Smrg	    ;;
7642d63fdb69Smrg	  *)
7643d63fdb69Smrg	    # Add libc to deplibs on all other systems if necessary.
7644d63fdb69Smrg	    if test "$build_libtool_need_lc" = "yes"; then
764548c85eb7Smrg	      func_append deplibs " -lc"
7646d63fdb69Smrg	    fi
7647d63fdb69Smrg	    ;;
7648d63fdb69Smrg	  esac
7649d63fdb69Smrg	fi
7650d63fdb69Smrg
7651d63fdb69Smrg	# Transform deplibs into only deplibs that can be linked in shared.
7652d63fdb69Smrg	name_save=$name
7653d63fdb69Smrg	libname_save=$libname
7654d63fdb69Smrg	release_save=$release
7655d63fdb69Smrg	versuffix_save=$versuffix
7656d63fdb69Smrg	major_save=$major
7657d63fdb69Smrg	# I'm not sure if I'm treating the release correctly.  I think
7658d63fdb69Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
7659d63fdb69Smrg	# add it in twice.  Is that correct?
7660d63fdb69Smrg	release=""
7661d63fdb69Smrg	versuffix=""
7662d63fdb69Smrg	major=""
7663d63fdb69Smrg	newdeplibs=
7664d63fdb69Smrg	droppeddeps=no
7665d63fdb69Smrg	case $deplibs_check_method in
7666d63fdb69Smrg	pass_all)
7667d63fdb69Smrg	  # Don't check for shared/static.  Everything works.
7668d63fdb69Smrg	  # This might be a little naive.  We might want to check
7669d63fdb69Smrg	  # whether the library exists or not.  But this is on
7670d63fdb69Smrg	  # osf3 & osf4 and I'm not really sure... Just
7671d63fdb69Smrg	  # implementing what was already the behavior.
7672d63fdb69Smrg	  newdeplibs=$deplibs
7673d63fdb69Smrg	  ;;
7674d63fdb69Smrg	test_compile)
7675d63fdb69Smrg	  # This code stresses the "libraries are programs" paradigm to its
7676d63fdb69Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
7677d63fdb69Smrg	  # against the deplibs as a proxy for the library.  Then we can check
7678d63fdb69Smrg	  # whether they linked in statically or dynamically with ldd.
7679d63fdb69Smrg	  $opt_dry_run || $RM conftest.c
7680d63fdb69Smrg	  cat > conftest.c <<EOF
7681d63fdb69Smrg	  int main() { return 0; }
7682d63fdb69SmrgEOF
7683d63fdb69Smrg	  $opt_dry_run || $RM conftest
7684d63fdb69Smrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
7685d63fdb69Smrg	    ldd_output=`ldd conftest`
7686d63fdb69Smrg	    for i in $deplibs; do
7687d63fdb69Smrg	      case $i in
7688d63fdb69Smrg	      -l*)
7689d63fdb69Smrg		func_stripname -l '' "$i"
7690d63fdb69Smrg		name=$func_stripname_result
7691d63fdb69Smrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7692d63fdb69Smrg		  case " $predeps $postdeps " in
7693d63fdb69Smrg		  *" $i "*)
769448c85eb7Smrg		    func_append newdeplibs " $i"
7695d63fdb69Smrg		    i=""
7696d63fdb69Smrg		    ;;
7697d63fdb69Smrg		  esac
7698d63fdb69Smrg		fi
7699d63fdb69Smrg		if test -n "$i" ; then
7700d63fdb69Smrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
7701d63fdb69Smrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7702d63fdb69Smrg		  set dummy $deplib_matches; shift
7703d63fdb69Smrg		  deplib_match=$1
7704d63fdb69Smrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
770548c85eb7Smrg		    func_append newdeplibs " $i"
7706d63fdb69Smrg		  else
7707d63fdb69Smrg		    droppeddeps=yes
770855acc8fcSmrg		    echo
7709d63fdb69Smrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
771055acc8fcSmrg		    echo "*** I have the capability to make that library automatically link in when"
771155acc8fcSmrg		    echo "*** you link to this library.  But I can only do this if you have a"
771255acc8fcSmrg		    echo "*** shared version of the library, which I believe you do not have"
771355acc8fcSmrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
771455acc8fcSmrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
7715d63fdb69Smrg		  fi
7716d63fdb69Smrg		fi
7717d63fdb69Smrg		;;
7718d63fdb69Smrg	      *)
771948c85eb7Smrg		func_append newdeplibs " $i"
7720d63fdb69Smrg		;;
7721d63fdb69Smrg	      esac
7722d63fdb69Smrg	    done
7723d63fdb69Smrg	  else
7724d63fdb69Smrg	    # Error occurred in the first compile.  Let's try to salvage
7725d63fdb69Smrg	    # the situation: Compile a separate program for each library.
7726d63fdb69Smrg	    for i in $deplibs; do
7727d63fdb69Smrg	      case $i in
7728d63fdb69Smrg	      -l*)
7729d63fdb69Smrg		func_stripname -l '' "$i"
7730d63fdb69Smrg		name=$func_stripname_result
7731d63fdb69Smrg		$opt_dry_run || $RM conftest
7732d63fdb69Smrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
7733d63fdb69Smrg		  ldd_output=`ldd conftest`
7734d63fdb69Smrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7735d63fdb69Smrg		    case " $predeps $postdeps " in
7736d63fdb69Smrg		    *" $i "*)
773748c85eb7Smrg		      func_append newdeplibs " $i"
7738d63fdb69Smrg		      i=""
7739d63fdb69Smrg		      ;;
7740d63fdb69Smrg		    esac
7741d63fdb69Smrg		  fi
7742d63fdb69Smrg		  if test -n "$i" ; then
7743d63fdb69Smrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
7744d63fdb69Smrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7745d63fdb69Smrg		    set dummy $deplib_matches; shift
7746d63fdb69Smrg		    deplib_match=$1
7747d63fdb69Smrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
774848c85eb7Smrg		      func_append newdeplibs " $i"
7749d63fdb69Smrg		    else
7750d63fdb69Smrg		      droppeddeps=yes
775155acc8fcSmrg		      echo
7752d63fdb69Smrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
775355acc8fcSmrg		      echo "*** I have the capability to make that library automatically link in when"
775455acc8fcSmrg		      echo "*** you link to this library.  But I can only do this if you have a"
775555acc8fcSmrg		      echo "*** shared version of the library, which you do not appear to have"
775655acc8fcSmrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
775755acc8fcSmrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
7758d63fdb69Smrg		    fi
7759d63fdb69Smrg		  fi
7760d63fdb69Smrg		else
7761d63fdb69Smrg		  droppeddeps=yes
776255acc8fcSmrg		  echo
7763d63fdb69Smrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
776455acc8fcSmrg		  echo "*** make it link in!  You will probably need to install it or some"
776555acc8fcSmrg		  echo "*** library that it depends on before this library will be fully"
776655acc8fcSmrg		  echo "*** functional.  Installing it before continuing would be even better."
7767d63fdb69Smrg		fi
7768d63fdb69Smrg		;;
7769d63fdb69Smrg	      *)
777048c85eb7Smrg		func_append newdeplibs " $i"
7771d63fdb69Smrg		;;
7772d63fdb69Smrg	      esac
7773d63fdb69Smrg	    done
7774d63fdb69Smrg	  fi
7775d63fdb69Smrg	  ;;
7776d63fdb69Smrg	file_magic*)
7777d63fdb69Smrg	  set dummy $deplibs_check_method; shift
7778d63fdb69Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7779d63fdb69Smrg	  for a_deplib in $deplibs; do
7780d63fdb69Smrg	    case $a_deplib in
7781d63fdb69Smrg	    -l*)
7782d63fdb69Smrg	      func_stripname -l '' "$a_deplib"
7783d63fdb69Smrg	      name=$func_stripname_result
7784d63fdb69Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7785d63fdb69Smrg		case " $predeps $postdeps " in
7786d63fdb69Smrg		*" $a_deplib "*)
778748c85eb7Smrg		  func_append newdeplibs " $a_deplib"
7788d63fdb69Smrg		  a_deplib=""
7789d63fdb69Smrg		  ;;
7790d63fdb69Smrg		esac
7791d63fdb69Smrg	      fi
7792d63fdb69Smrg	      if test -n "$a_deplib" ; then
7793d63fdb69Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
779448c85eb7Smrg		if test -n "$file_magic_glob"; then
779548c85eb7Smrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
779648c85eb7Smrg		else
779748c85eb7Smrg		  libnameglob=$libname
779848c85eb7Smrg		fi
779948c85eb7Smrg		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
7800d63fdb69Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
780148c85eb7Smrg		  if test "$want_nocaseglob" = yes; then
780248c85eb7Smrg		    shopt -s nocaseglob
780348c85eb7Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
780448c85eb7Smrg		    $nocaseglob
780548c85eb7Smrg		  else
780648c85eb7Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
780748c85eb7Smrg		  fi
7808d63fdb69Smrg		  for potent_lib in $potential_libs; do
7809d63fdb69Smrg		      # Follow soft links.
7810d63fdb69Smrg		      if ls -lLd "$potent_lib" 2>/dev/null |
7811d63fdb69Smrg			 $GREP " -> " >/dev/null; then
7812d63fdb69Smrg			continue
7813d63fdb69Smrg		      fi
7814d63fdb69Smrg		      # The statement above tries to avoid entering an
7815d63fdb69Smrg		      # endless loop below, in case of cyclic links.
7816d63fdb69Smrg		      # We might still enter an endless loop, since a link
7817d63fdb69Smrg		      # loop can be closed while we follow links,
7818d63fdb69Smrg		      # but so what?
7819d63fdb69Smrg		      potlib="$potent_lib"
7820d63fdb69Smrg		      while test -h "$potlib" 2>/dev/null; do
7821d63fdb69Smrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
7822d63fdb69Smrg			case $potliblink in
7823d63fdb69Smrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
782455acc8fcSmrg			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
7825d63fdb69Smrg			esac
7826d63fdb69Smrg		      done
7827d63fdb69Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
7828d63fdb69Smrg			 $SED -e 10q |
7829d63fdb69Smrg			 $EGREP "$file_magic_regex" > /dev/null; then
783048c85eb7Smrg			func_append newdeplibs " $a_deplib"
7831d63fdb69Smrg			a_deplib=""
7832d63fdb69Smrg			break 2
7833d63fdb69Smrg		      fi
7834d63fdb69Smrg		  done
7835d63fdb69Smrg		done
7836d63fdb69Smrg	      fi
7837d63fdb69Smrg	      if test -n "$a_deplib" ; then
7838d63fdb69Smrg		droppeddeps=yes
783955acc8fcSmrg		echo
7840d63fdb69Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
784155acc8fcSmrg		echo "*** I have the capability to make that library automatically link in when"
784255acc8fcSmrg		echo "*** you link to this library.  But I can only do this if you have a"
784355acc8fcSmrg		echo "*** shared version of the library, which you do not appear to have"
784455acc8fcSmrg		echo "*** because I did check the linker path looking for a file starting"
7845d63fdb69Smrg		if test -z "$potlib" ; then
7846d63fdb69Smrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
7847d63fdb69Smrg		else
7848d63fdb69Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7849d63fdb69Smrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
7850d63fdb69Smrg		fi
7851d63fdb69Smrg	      fi
7852d63fdb69Smrg	      ;;
7853d63fdb69Smrg	    *)
7854d63fdb69Smrg	      # Add a -L argument.
785548c85eb7Smrg	      func_append newdeplibs " $a_deplib"
7856d63fdb69Smrg	      ;;
7857d63fdb69Smrg	    esac
7858d63fdb69Smrg	  done # Gone through all deplibs.
7859d63fdb69Smrg	  ;;
7860d63fdb69Smrg	match_pattern*)
7861d63fdb69Smrg	  set dummy $deplibs_check_method; shift
7862d63fdb69Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7863d63fdb69Smrg	  for a_deplib in $deplibs; do
7864d63fdb69Smrg	    case $a_deplib in
7865d63fdb69Smrg	    -l*)
7866d63fdb69Smrg	      func_stripname -l '' "$a_deplib"
7867d63fdb69Smrg	      name=$func_stripname_result
7868d63fdb69Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7869d63fdb69Smrg		case " $predeps $postdeps " in
7870d63fdb69Smrg		*" $a_deplib "*)
787148c85eb7Smrg		  func_append newdeplibs " $a_deplib"
7872d63fdb69Smrg		  a_deplib=""
7873d63fdb69Smrg		  ;;
7874d63fdb69Smrg		esac
7875d63fdb69Smrg	      fi
7876d63fdb69Smrg	      if test -n "$a_deplib" ; then
7877d63fdb69Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
7878d63fdb69Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7879d63fdb69Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
7880d63fdb69Smrg		  for potent_lib in $potential_libs; do
7881d63fdb69Smrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
788255acc8fcSmrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
7883d63fdb69Smrg		       $EGREP "$match_pattern_regex" > /dev/null; then
788448c85eb7Smrg		      func_append newdeplibs " $a_deplib"
7885d63fdb69Smrg		      a_deplib=""
7886d63fdb69Smrg		      break 2
7887d63fdb69Smrg		    fi
7888d63fdb69Smrg		  done
7889d63fdb69Smrg		done
7890d63fdb69Smrg	      fi
7891d63fdb69Smrg	      if test -n "$a_deplib" ; then
7892d63fdb69Smrg		droppeddeps=yes
789355acc8fcSmrg		echo
7894d63fdb69Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
789555acc8fcSmrg		echo "*** I have the capability to make that library automatically link in when"
789655acc8fcSmrg		echo "*** you link to this library.  But I can only do this if you have a"
789755acc8fcSmrg		echo "*** shared version of the library, which you do not appear to have"
789855acc8fcSmrg		echo "*** because I did check the linker path looking for a file starting"
7899d63fdb69Smrg		if test -z "$potlib" ; then
7900d63fdb69Smrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
7901d63fdb69Smrg		else
7902d63fdb69Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7903d63fdb69Smrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
7904d63fdb69Smrg		fi
7905d63fdb69Smrg	      fi
7906d63fdb69Smrg	      ;;
7907d63fdb69Smrg	    *)
7908d63fdb69Smrg	      # Add a -L argument.
790948c85eb7Smrg	      func_append newdeplibs " $a_deplib"
7910d63fdb69Smrg	      ;;
7911d63fdb69Smrg	    esac
7912d63fdb69Smrg	  done # Gone through all deplibs.
7913d63fdb69Smrg	  ;;
7914d63fdb69Smrg	none | unknown | *)
7915d63fdb69Smrg	  newdeplibs=""
791655acc8fcSmrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
7917d63fdb69Smrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7918d63fdb69Smrg	    for i in $predeps $postdeps ; do
7919d63fdb69Smrg	      # can't use Xsed below, because $i might contain '/'
792055acc8fcSmrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
7921d63fdb69Smrg	    done
7922d63fdb69Smrg	  fi
792355acc8fcSmrg	  case $tmp_deplibs in
792455acc8fcSmrg	  *[!\	\ ]*)
792555acc8fcSmrg	    echo
7926d63fdb69Smrg	    if test "X$deplibs_check_method" = "Xnone"; then
792755acc8fcSmrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
7928d63fdb69Smrg	    else
792955acc8fcSmrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
7930d63fdb69Smrg	    fi
793155acc8fcSmrg	    echo "*** All declared inter-library dependencies are being dropped."
7932d63fdb69Smrg	    droppeddeps=yes
793355acc8fcSmrg	    ;;
793455acc8fcSmrg	  esac
7935d63fdb69Smrg	  ;;
7936d63fdb69Smrg	esac
7937d63fdb69Smrg	versuffix=$versuffix_save
7938d63fdb69Smrg	major=$major_save
7939d63fdb69Smrg	release=$release_save
7940d63fdb69Smrg	libname=$libname_save
7941d63fdb69Smrg	name=$name_save
7942d63fdb69Smrg
7943d63fdb69Smrg	case $host in
7944d63fdb69Smrg	*-*-rhapsody* | *-*-darwin1.[012])
7945d63fdb69Smrg	  # On Rhapsody replace the C library with the System framework
794655acc8fcSmrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
7947d63fdb69Smrg	  ;;
7948d63fdb69Smrg	esac
7949d63fdb69Smrg
7950d63fdb69Smrg	if test "$droppeddeps" = yes; then
7951d63fdb69Smrg	  if test "$module" = yes; then
795255acc8fcSmrg	    echo
795355acc8fcSmrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
7954d63fdb69Smrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
795555acc8fcSmrg	    echo "*** a static module, that should work as long as the dlopening"
795655acc8fcSmrg	    echo "*** application is linked with the -dlopen flag."
7957d63fdb69Smrg	    if test -z "$global_symbol_pipe"; then
795855acc8fcSmrg	      echo
795955acc8fcSmrg	      echo "*** However, this would only work if libtool was able to extract symbol"
796055acc8fcSmrg	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
796155acc8fcSmrg	      echo "*** not find such a program.  So, this module is probably useless."
796255acc8fcSmrg	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
7963d63fdb69Smrg	    fi
7964d63fdb69Smrg	    if test "$build_old_libs" = no; then
7965d63fdb69Smrg	      oldlibs="$output_objdir/$libname.$libext"
7966d63fdb69Smrg	      build_libtool_libs=module
7967d63fdb69Smrg	      build_old_libs=yes
7968d63fdb69Smrg	    else
7969d63fdb69Smrg	      build_libtool_libs=no
7970d63fdb69Smrg	    fi
7971d63fdb69Smrg	  else
797255acc8fcSmrg	    echo "*** The inter-library dependencies that have been dropped here will be"
797355acc8fcSmrg	    echo "*** automatically added whenever a program is linked with this library"
797455acc8fcSmrg	    echo "*** or is declared to -dlopen it."
7975d63fdb69Smrg
7976d63fdb69Smrg	    if test "$allow_undefined" = no; then
797755acc8fcSmrg	      echo
797855acc8fcSmrg	      echo "*** Since this library must not contain undefined symbols,"
797955acc8fcSmrg	      echo "*** because either the platform does not support them or"
798055acc8fcSmrg	      echo "*** it was explicitly requested with -no-undefined,"
798155acc8fcSmrg	      echo "*** libtool will only create a static version of it."
7982d63fdb69Smrg	      if test "$build_old_libs" = no; then
7983d63fdb69Smrg		oldlibs="$output_objdir/$libname.$libext"
7984d63fdb69Smrg		build_libtool_libs=module
7985d63fdb69Smrg		build_old_libs=yes
7986d63fdb69Smrg	      else
7987d63fdb69Smrg		build_libtool_libs=no
7988d63fdb69Smrg	      fi
7989d63fdb69Smrg	    fi
7990d63fdb69Smrg	  fi
7991d63fdb69Smrg	fi
7992d63fdb69Smrg	# Done checking deplibs!
7993d63fdb69Smrg	deplibs=$newdeplibs
7994d63fdb69Smrg      fi
7995d63fdb69Smrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
7996d63fdb69Smrg      case $host in
7997d63fdb69Smrg	*-*-darwin*)
799855acc8fcSmrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
799955acc8fcSmrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
800055acc8fcSmrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8001d63fdb69Smrg	  ;;
8002d63fdb69Smrg      esac
8003d63fdb69Smrg
8004d63fdb69Smrg      # move library search paths that coincide with paths to not yet
8005d63fdb69Smrg      # installed libraries to the beginning of the library search list
8006d63fdb69Smrg      new_libs=
8007d63fdb69Smrg      for path in $notinst_path; do
8008d63fdb69Smrg	case " $new_libs " in
8009d63fdb69Smrg	*" -L$path/$objdir "*) ;;
8010d63fdb69Smrg	*)
8011d63fdb69Smrg	  case " $deplibs " in
8012d63fdb69Smrg	  *" -L$path/$objdir "*)
801348c85eb7Smrg	    func_append new_libs " -L$path/$objdir" ;;
8014d63fdb69Smrg	  esac
8015d63fdb69Smrg	  ;;
8016d63fdb69Smrg	esac
8017d63fdb69Smrg      done
8018d63fdb69Smrg      for deplib in $deplibs; do
8019d63fdb69Smrg	case $deplib in
8020d63fdb69Smrg	-L*)
8021d63fdb69Smrg	  case " $new_libs " in
8022d63fdb69Smrg	  *" $deplib "*) ;;
802348c85eb7Smrg	  *) func_append new_libs " $deplib" ;;
8024d63fdb69Smrg	  esac
8025d63fdb69Smrg	  ;;
802648c85eb7Smrg	*) func_append new_libs " $deplib" ;;
8027d63fdb69Smrg	esac
8028d63fdb69Smrg      done
8029d63fdb69Smrg      deplibs="$new_libs"
8030d63fdb69Smrg
8031d63fdb69Smrg      # All the library-specific variables (install_libdir is set above).
8032d63fdb69Smrg      library_names=
8033d63fdb69Smrg      old_library=
8034d63fdb69Smrg      dlname=
8035d63fdb69Smrg
8036d63fdb69Smrg      # Test again, we may have decided not to build it any more
8037d63fdb69Smrg      if test "$build_libtool_libs" = yes; then
803848c85eb7Smrg	# Remove ${wl} instances when linking with ld.
803948c85eb7Smrg	# FIXME: should test the right _cmds variable.
804048c85eb7Smrg	case $archive_cmds in
804148c85eb7Smrg	  *\$LD\ *) wl= ;;
804248c85eb7Smrg        esac
8043d63fdb69Smrg	if test "$hardcode_into_libs" = yes; then
8044d63fdb69Smrg	  # Hardcode the library paths
8045d63fdb69Smrg	  hardcode_libdirs=
8046d63fdb69Smrg	  dep_rpath=
8047d63fdb69Smrg	  rpath="$finalize_rpath"
804848c85eb7Smrg	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
8049d63fdb69Smrg	  for libdir in $rpath; do
8050d63fdb69Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
8051d63fdb69Smrg	      if test -n "$hardcode_libdir_separator"; then
805248c85eb7Smrg		func_replace_sysroot "$libdir"
805348c85eb7Smrg		libdir=$func_replace_sysroot_result
8054d63fdb69Smrg		if test -z "$hardcode_libdirs"; then
8055d63fdb69Smrg		  hardcode_libdirs="$libdir"
8056d63fdb69Smrg		else
8057d63fdb69Smrg		  # Just accumulate the unique libdirs.
8058d63fdb69Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8059d63fdb69Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8060d63fdb69Smrg		    ;;
8061d63fdb69Smrg		  *)
806248c85eb7Smrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8063d63fdb69Smrg		    ;;
8064d63fdb69Smrg		  esac
8065d63fdb69Smrg		fi
8066d63fdb69Smrg	      else
8067d63fdb69Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
806848c85eb7Smrg		func_append dep_rpath " $flag"
8069d63fdb69Smrg	      fi
8070d63fdb69Smrg	    elif test -n "$runpath_var"; then
8071d63fdb69Smrg	      case "$perm_rpath " in
8072d63fdb69Smrg	      *" $libdir "*) ;;
807348c85eb7Smrg	      *) func_append perm_rpath " $libdir" ;;
8074d63fdb69Smrg	      esac
8075d63fdb69Smrg	    fi
8076d63fdb69Smrg	  done
8077d63fdb69Smrg	  # Substitute the hardcoded libdirs into the rpath.
8078d63fdb69Smrg	  if test -n "$hardcode_libdir_separator" &&
8079d63fdb69Smrg	     test -n "$hardcode_libdirs"; then
8080d63fdb69Smrg	    libdir="$hardcode_libdirs"
808148c85eb7Smrg	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
8082d63fdb69Smrg	  fi
8083d63fdb69Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
8084d63fdb69Smrg	    # We should set the runpath_var.
8085d63fdb69Smrg	    rpath=
8086d63fdb69Smrg	    for dir in $perm_rpath; do
808748c85eb7Smrg	      func_append rpath "$dir:"
8088d63fdb69Smrg	    done
8089d63fdb69Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
8090d63fdb69Smrg	  fi
8091d63fdb69Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
8092d63fdb69Smrg	fi
80933da084b3Smrg
8094d63fdb69Smrg	shlibpath="$finalize_shlibpath"
809548c85eb7Smrg	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
8096d63fdb69Smrg	if test -n "$shlibpath"; then
8097d63fdb69Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
8098d63fdb69Smrg	fi
80993da084b3Smrg
8100d63fdb69Smrg	# Get the real and link names of the library.
8101d63fdb69Smrg	eval shared_ext=\"$shrext_cmds\"
8102d63fdb69Smrg	eval library_names=\"$library_names_spec\"
8103d63fdb69Smrg	set dummy $library_names
8104d63fdb69Smrg	shift
8105d63fdb69Smrg	realname="$1"
8106d63fdb69Smrg	shift
81073da084b3Smrg
8108d63fdb69Smrg	if test -n "$soname_spec"; then
8109d63fdb69Smrg	  eval soname=\"$soname_spec\"
8110d63fdb69Smrg	else
8111d63fdb69Smrg	  soname="$realname"
8112d63fdb69Smrg	fi
8113d63fdb69Smrg	if test -z "$dlname"; then
8114d63fdb69Smrg	  dlname=$soname
8115d63fdb69Smrg	fi
81163da084b3Smrg
8117d63fdb69Smrg	lib="$output_objdir/$realname"
8118d63fdb69Smrg	linknames=
8119d63fdb69Smrg	for link
8120d63fdb69Smrg	do
812148c85eb7Smrg	  func_append linknames " $link"
8122d63fdb69Smrg	done
81233da084b3Smrg
8124d63fdb69Smrg	# Use standard objects if they are pic
812555acc8fcSmrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
8126d63fdb69Smrg	test "X$libobjs" = "X " && libobjs=
81273da084b3Smrg
8128d63fdb69Smrg	delfiles=
8129d63fdb69Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8130d63fdb69Smrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
8131d63fdb69Smrg	  export_symbols="$output_objdir/$libname.uexp"
813248c85eb7Smrg	  func_append delfiles " $export_symbols"
8133d63fdb69Smrg	fi
81343da084b3Smrg
8135d63fdb69Smrg	orig_export_symbols=
8136d63fdb69Smrg	case $host_os in
8137d63fdb69Smrg	cygwin* | mingw* | cegcc*)
8138d63fdb69Smrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
8139d63fdb69Smrg	    # exporting using user supplied symfile
8140d63fdb69Smrg	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
8141d63fdb69Smrg	      # and it's NOT already a .def file. Must figure out
8142d63fdb69Smrg	      # which of the given symbols are data symbols and tag
8143d63fdb69Smrg	      # them as such. So, trigger use of export_symbols_cmds.
8144d63fdb69Smrg	      # export_symbols gets reassigned inside the "prepare
8145d63fdb69Smrg	      # the list of exported symbols" if statement, so the
8146d63fdb69Smrg	      # include_expsyms logic still works.
8147d63fdb69Smrg	      orig_export_symbols="$export_symbols"
8148d63fdb69Smrg	      export_symbols=
8149d63fdb69Smrg	      always_export_symbols=yes
8150d63fdb69Smrg	    fi
8151d63fdb69Smrg	  fi
8152d63fdb69Smrg	  ;;
8153d63fdb69Smrg	esac
81543da084b3Smrg
8155d63fdb69Smrg	# Prepare the list of exported symbols
8156d63fdb69Smrg	if test -z "$export_symbols"; then
8157d63fdb69Smrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
8158d63fdb69Smrg	    func_verbose "generating symbol list for \`$libname.la'"
8159d63fdb69Smrg	    export_symbols="$output_objdir/$libname.exp"
8160d63fdb69Smrg	    $opt_dry_run || $RM $export_symbols
8161d63fdb69Smrg	    cmds=$export_symbols_cmds
8162d63fdb69Smrg	    save_ifs="$IFS"; IFS='~'
816348c85eb7Smrg	    for cmd1 in $cmds; do
8164d63fdb69Smrg	      IFS="$save_ifs"
816548c85eb7Smrg	      # Take the normal branch if the nm_file_list_spec branch
816648c85eb7Smrg	      # doesn't work or if tool conversion is not needed.
816748c85eb7Smrg	      case $nm_file_list_spec~$to_tool_file_cmd in
816848c85eb7Smrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
816948c85eb7Smrg		  try_normal_branch=yes
817048c85eb7Smrg		  eval cmd=\"$cmd1\"
817148c85eb7Smrg		  func_len " $cmd"
817248c85eb7Smrg		  len=$func_len_result
817348c85eb7Smrg		  ;;
817448c85eb7Smrg		*)
817548c85eb7Smrg		  try_normal_branch=no
817648c85eb7Smrg		  ;;
817748c85eb7Smrg	      esac
817848c85eb7Smrg	      if test "$try_normal_branch" = yes \
817948c85eb7Smrg		 && { test "$len" -lt "$max_cmd_len" \
818048c85eb7Smrg		      || test "$max_cmd_len" -le -1; }
818148c85eb7Smrg	      then
818248c85eb7Smrg		func_show_eval "$cmd" 'exit $?'
818348c85eb7Smrg		skipped_export=false
818448c85eb7Smrg	      elif test -n "$nm_file_list_spec"; then
818548c85eb7Smrg		func_basename "$output"
818648c85eb7Smrg		output_la=$func_basename_result
818748c85eb7Smrg		save_libobjs=$libobjs
818848c85eb7Smrg		save_output=$output
818948c85eb7Smrg		output=${output_objdir}/${output_la}.nm
819048c85eb7Smrg		func_to_tool_file "$output"
819148c85eb7Smrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
819248c85eb7Smrg		func_append delfiles " $output"
819348c85eb7Smrg		func_verbose "creating $NM input file list: $output"
819448c85eb7Smrg		for obj in $save_libobjs; do
819548c85eb7Smrg		  func_to_tool_file "$obj"
819648c85eb7Smrg		  $ECHO "$func_to_tool_file_result"
819748c85eb7Smrg		done > "$output"
819848c85eb7Smrg		eval cmd=\"$cmd1\"
8199d63fdb69Smrg		func_show_eval "$cmd" 'exit $?'
820048c85eb7Smrg		output=$save_output
820148c85eb7Smrg		libobjs=$save_libobjs
8202d63fdb69Smrg		skipped_export=false
8203d63fdb69Smrg	      else
8204d63fdb69Smrg		# The command line is too long to execute in one step.
8205d63fdb69Smrg		func_verbose "using reloadable object file for export list..."
8206d63fdb69Smrg		skipped_export=:
8207d63fdb69Smrg		# Break out early, otherwise skipped_export may be
8208d63fdb69Smrg		# set to false by a later but shorter cmd.
8209d63fdb69Smrg		break
8210d63fdb69Smrg	      fi
8211d63fdb69Smrg	    done
8212d63fdb69Smrg	    IFS="$save_ifs"
8213d63fdb69Smrg	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
8214d63fdb69Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8215d63fdb69Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8216d63fdb69Smrg	    fi
8217d63fdb69Smrg	  fi
8218d63fdb69Smrg	fi
82193da084b3Smrg
8220d63fdb69Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8221d63fdb69Smrg	  tmp_export_symbols="$export_symbols"
8222d63fdb69Smrg	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
822355acc8fcSmrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8224d63fdb69Smrg	fi
82253da084b3Smrg
8226d63fdb69Smrg	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
8227d63fdb69Smrg	  # The given exports_symbols file has to be filtered, so filter it.
8228d63fdb69Smrg	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8229d63fdb69Smrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
8230d63fdb69Smrg	  # 's' commands which not all seds can handle. GNU sed should be fine
8231d63fdb69Smrg	  # though. Also, the filter scales superlinearly with the number of
8232d63fdb69Smrg	  # global variables. join(1) would be nice here, but unfortunately
8233d63fdb69Smrg	  # isn't a blessed tool.
8234d63fdb69Smrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
823548c85eb7Smrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8236d63fdb69Smrg	  export_symbols=$output_objdir/$libname.def
8237d63fdb69Smrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
82383da084b3Smrg	fi
82393da084b3Smrg
8240d63fdb69Smrg	tmp_deplibs=
8241d63fdb69Smrg	for test_deplib in $deplibs; do
8242d63fdb69Smrg	  case " $convenience " in
8243d63fdb69Smrg	  *" $test_deplib "*) ;;
8244d63fdb69Smrg	  *)
824548c85eb7Smrg	    func_append tmp_deplibs " $test_deplib"
8246d63fdb69Smrg	    ;;
8247d63fdb69Smrg	  esac
8248d63fdb69Smrg	done
8249d63fdb69Smrg	deplibs="$tmp_deplibs"
82503da084b3Smrg
8251d63fdb69Smrg	if test -n "$convenience"; then
8252d63fdb69Smrg	  if test -n "$whole_archive_flag_spec" &&
8253d63fdb69Smrg	    test "$compiler_needs_object" = yes &&
8254d63fdb69Smrg	    test -z "$libobjs"; then
8255d63fdb69Smrg	    # extract the archives, so we have objects to list.
8256d63fdb69Smrg	    # TODO: could optimize this to just extract one archive.
8257d63fdb69Smrg	    whole_archive_flag_spec=
8258d63fdb69Smrg	  fi
8259d63fdb69Smrg	  if test -n "$whole_archive_flag_spec"; then
8260d63fdb69Smrg	    save_libobjs=$libobjs
8261d63fdb69Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8262d63fdb69Smrg	    test "X$libobjs" = "X " && libobjs=
8263d63fdb69Smrg	  else
8264d63fdb69Smrg	    gentop="$output_objdir/${outputname}x"
826548c85eb7Smrg	    func_append generated " $gentop"
82663da084b3Smrg
8267d63fdb69Smrg	    func_extract_archives $gentop $convenience
826848c85eb7Smrg	    func_append libobjs " $func_extract_archives_result"
8269d63fdb69Smrg	    test "X$libobjs" = "X " && libobjs=
8270d63fdb69Smrg	  fi
8271d63fdb69Smrg	fi
82723da084b3Smrg
8273d63fdb69Smrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
8274d63fdb69Smrg	  eval flag=\"$thread_safe_flag_spec\"
827548c85eb7Smrg	  func_append linker_flags " $flag"
8276d63fdb69Smrg	fi
82773da084b3Smrg
8278d63fdb69Smrg	# Make a backup of the uninstalled library when relinking
827948c85eb7Smrg	if test "$opt_mode" = relink; then
8280d63fdb69Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
82813da084b3Smrg	fi
82823da084b3Smrg
8283d63fdb69Smrg	# Do each of the archive commands.
8284d63fdb69Smrg	if test "$module" = yes && test -n "$module_cmds" ; then
8285d63fdb69Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8286d63fdb69Smrg	    eval test_cmds=\"$module_expsym_cmds\"
8287d63fdb69Smrg	    cmds=$module_expsym_cmds
8288d63fdb69Smrg	  else
8289d63fdb69Smrg	    eval test_cmds=\"$module_cmds\"
8290d63fdb69Smrg	    cmds=$module_cmds
8291d63fdb69Smrg	  fi
8292d63fdb69Smrg	else
8293d63fdb69Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8294d63fdb69Smrg	    eval test_cmds=\"$archive_expsym_cmds\"
8295d63fdb69Smrg	    cmds=$archive_expsym_cmds
8296d63fdb69Smrg	  else
8297d63fdb69Smrg	    eval test_cmds=\"$archive_cmds\"
8298d63fdb69Smrg	    cmds=$archive_cmds
8299d63fdb69Smrg	  fi
83003da084b3Smrg	fi
83013da084b3Smrg
8302d63fdb69Smrg	if test "X$skipped_export" != "X:" &&
8303d63fdb69Smrg	   func_len " $test_cmds" &&
8304d63fdb69Smrg	   len=$func_len_result &&
8305d63fdb69Smrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
8306d63fdb69Smrg	  :
8307d63fdb69Smrg	else
8308d63fdb69Smrg	  # The command line is too long to link in one step, link piecewise
8309d63fdb69Smrg	  # or, if using GNU ld and skipped_export is not :, use a linker
8310d63fdb69Smrg	  # script.
83113da084b3Smrg
8312d63fdb69Smrg	  # Save the value of $output and $libobjs because we want to
8313d63fdb69Smrg	  # use them later.  If we have whole_archive_flag_spec, we
8314d63fdb69Smrg	  # want to use save_libobjs as it was before
8315d63fdb69Smrg	  # whole_archive_flag_spec was expanded, because we can't
8316d63fdb69Smrg	  # assume the linker understands whole_archive_flag_spec.
8317d63fdb69Smrg	  # This may have to be revisited, in case too many
8318d63fdb69Smrg	  # convenience libraries get linked in and end up exceeding
8319d63fdb69Smrg	  # the spec.
8320d63fdb69Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
8321d63fdb69Smrg	    save_libobjs=$libobjs
8322d63fdb69Smrg	  fi
8323d63fdb69Smrg	  save_output=$output
832455acc8fcSmrg	  func_basename "$output"
832555acc8fcSmrg	  output_la=$func_basename_result
83263da084b3Smrg
8327d63fdb69Smrg	  # Clear the reloadable object creation command queue and
8328d63fdb69Smrg	  # initialize k to one.
8329d63fdb69Smrg	  test_cmds=
8330d63fdb69Smrg	  concat_cmds=
8331d63fdb69Smrg	  objlist=
8332d63fdb69Smrg	  last_robj=
8333d63fdb69Smrg	  k=1
83343da084b3Smrg
8335d63fdb69Smrg	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
8336d63fdb69Smrg	    output=${output_objdir}/${output_la}.lnkscript
8337d63fdb69Smrg	    func_verbose "creating GNU ld script: $output"
833855acc8fcSmrg	    echo 'INPUT (' > $output
8339d63fdb69Smrg	    for obj in $save_libobjs
8340d63fdb69Smrg	    do
834148c85eb7Smrg	      func_to_tool_file "$obj"
834248c85eb7Smrg	      $ECHO "$func_to_tool_file_result" >> $output
8343d63fdb69Smrg	    done
834455acc8fcSmrg	    echo ')' >> $output
834548c85eb7Smrg	    func_append delfiles " $output"
834648c85eb7Smrg	    func_to_tool_file "$output"
834748c85eb7Smrg	    output=$func_to_tool_file_result
8348d63fdb69Smrg	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
8349d63fdb69Smrg	    output=${output_objdir}/${output_la}.lnk
8350d63fdb69Smrg	    func_verbose "creating linker input file list: $output"
8351d63fdb69Smrg	    : > $output
8352d63fdb69Smrg	    set x $save_libobjs
8353d63fdb69Smrg	    shift
8354d63fdb69Smrg	    firstobj=
8355d63fdb69Smrg	    if test "$compiler_needs_object" = yes; then
8356d63fdb69Smrg	      firstobj="$1 "
8357d63fdb69Smrg	      shift
8358d63fdb69Smrg	    fi
8359d63fdb69Smrg	    for obj
8360d63fdb69Smrg	    do
836148c85eb7Smrg	      func_to_tool_file "$obj"
836248c85eb7Smrg	      $ECHO "$func_to_tool_file_result" >> $output
8363d63fdb69Smrg	    done
836448c85eb7Smrg	    func_append delfiles " $output"
836548c85eb7Smrg	    func_to_tool_file "$output"
836648c85eb7Smrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
8367d63fdb69Smrg	  else
8368d63fdb69Smrg	    if test -n "$save_libobjs"; then
8369d63fdb69Smrg	      func_verbose "creating reloadable object files..."
8370d63fdb69Smrg	      output=$output_objdir/$output_la-${k}.$objext
8371d63fdb69Smrg	      eval test_cmds=\"$reload_cmds\"
8372d63fdb69Smrg	      func_len " $test_cmds"
8373d63fdb69Smrg	      len0=$func_len_result
8374d63fdb69Smrg	      len=$len0
8375d63fdb69Smrg
8376d63fdb69Smrg	      # Loop over the list of objects to be linked.
8377d63fdb69Smrg	      for obj in $save_libobjs
8378d63fdb69Smrg	      do
8379d63fdb69Smrg		func_len " $obj"
8380d63fdb69Smrg		func_arith $len + $func_len_result
8381d63fdb69Smrg		len=$func_arith_result
8382d63fdb69Smrg		if test "X$objlist" = X ||
8383d63fdb69Smrg		   test "$len" -lt "$max_cmd_len"; then
8384d63fdb69Smrg		  func_append objlist " $obj"
8385d63fdb69Smrg		else
8386d63fdb69Smrg		  # The command $test_cmds is almost too long, add a
8387d63fdb69Smrg		  # command to the queue.
8388d63fdb69Smrg		  if test "$k" -eq 1 ; then
8389d63fdb69Smrg		    # The first file doesn't have a previous command to add.
839055acc8fcSmrg		    reload_objs=$objlist
839155acc8fcSmrg		    eval concat_cmds=\"$reload_cmds\"
8392d63fdb69Smrg		  else
8393d63fdb69Smrg		    # All subsequent reloadable object files will link in
8394d63fdb69Smrg		    # the last one created.
839555acc8fcSmrg		    reload_objs="$objlist $last_robj"
839655acc8fcSmrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
8397d63fdb69Smrg		  fi
8398d63fdb69Smrg		  last_robj=$output_objdir/$output_la-${k}.$objext
8399d63fdb69Smrg		  func_arith $k + 1
8400d63fdb69Smrg		  k=$func_arith_result
8401d63fdb69Smrg		  output=$output_objdir/$output_la-${k}.$objext
840255acc8fcSmrg		  objlist=" $obj"
8403d63fdb69Smrg		  func_len " $last_robj"
8404d63fdb69Smrg		  func_arith $len0 + $func_len_result
8405d63fdb69Smrg		  len=$func_arith_result
8406d63fdb69Smrg		fi
8407d63fdb69Smrg	      done
8408d63fdb69Smrg	      # Handle the remaining objects by creating one last
8409d63fdb69Smrg	      # reloadable object file.  All subsequent reloadable object
8410d63fdb69Smrg	      # files will link in the last one created.
8411d63fdb69Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
841255acc8fcSmrg	      reload_objs="$objlist $last_robj"
841355acc8fcSmrg	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
8414d63fdb69Smrg	      if test -n "$last_robj"; then
8415d63fdb69Smrg	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
8416d63fdb69Smrg	      fi
841748c85eb7Smrg	      func_append delfiles " $output"
84183da084b3Smrg
8419d63fdb69Smrg	    else
8420d63fdb69Smrg	      output=
8421d63fdb69Smrg	    fi
84223da084b3Smrg
8423d63fdb69Smrg	    if ${skipped_export-false}; then
8424d63fdb69Smrg	      func_verbose "generating symbol list for \`$libname.la'"
8425d63fdb69Smrg	      export_symbols="$output_objdir/$libname.exp"
8426d63fdb69Smrg	      $opt_dry_run || $RM $export_symbols
8427d63fdb69Smrg	      libobjs=$output
8428d63fdb69Smrg	      # Append the command to create the export file.
8429d63fdb69Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8430d63fdb69Smrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
8431d63fdb69Smrg	      if test -n "$last_robj"; then
8432d63fdb69Smrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
8433d63fdb69Smrg	      fi
8434d63fdb69Smrg	    fi
84353da084b3Smrg
8436d63fdb69Smrg	    test -n "$save_libobjs" &&
8437d63fdb69Smrg	      func_verbose "creating a temporary reloadable object file: $output"
84383da084b3Smrg
8439d63fdb69Smrg	    # Loop through the commands generated above and execute them.
8440d63fdb69Smrg	    save_ifs="$IFS"; IFS='~'
8441d63fdb69Smrg	    for cmd in $concat_cmds; do
8442d63fdb69Smrg	      IFS="$save_ifs"
8443d63fdb69Smrg	      $opt_silent || {
8444d63fdb69Smrg		  func_quote_for_expand "$cmd"
8445d63fdb69Smrg		  eval "func_echo $func_quote_for_expand_result"
8446d63fdb69Smrg	      }
8447d63fdb69Smrg	      $opt_dry_run || eval "$cmd" || {
8448d63fdb69Smrg		lt_exit=$?
8449d63fdb69Smrg
8450d63fdb69Smrg		# Restore the uninstalled library and exit
845148c85eb7Smrg		if test "$opt_mode" = relink; then
8452d63fdb69Smrg		  ( cd "$output_objdir" && \
8453d63fdb69Smrg		    $RM "${realname}T" && \
8454d63fdb69Smrg		    $MV "${realname}U" "$realname" )
8455d63fdb69Smrg		fi
84563da084b3Smrg
8457d63fdb69Smrg		exit $lt_exit
8458d63fdb69Smrg	      }
8459d63fdb69Smrg	    done
8460d63fdb69Smrg	    IFS="$save_ifs"
8461d63fdb69Smrg
8462d63fdb69Smrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
8463d63fdb69Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8464d63fdb69Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
84653da084b3Smrg	    fi
84663da084b3Smrg	  fi
84673da084b3Smrg
8468d63fdb69Smrg          if ${skipped_export-false}; then
8469d63fdb69Smrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
8470d63fdb69Smrg	      tmp_export_symbols="$export_symbols"
8471d63fdb69Smrg	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
847255acc8fcSmrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8473d63fdb69Smrg	    fi
84743da084b3Smrg
8475d63fdb69Smrg	    if test -n "$orig_export_symbols"; then
8476d63fdb69Smrg	      # The given exports_symbols file has to be filtered, so filter it.
8477d63fdb69Smrg	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8478d63fdb69Smrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
8479d63fdb69Smrg	      # 's' commands which not all seds can handle. GNU sed should be fine
8480d63fdb69Smrg	      # though. Also, the filter scales superlinearly with the number of
8481d63fdb69Smrg	      # global variables. join(1) would be nice here, but unfortunately
8482d63fdb69Smrg	      # isn't a blessed tool.
8483d63fdb69Smrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
848448c85eb7Smrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8485d63fdb69Smrg	      export_symbols=$output_objdir/$libname.def
8486d63fdb69Smrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8487d63fdb69Smrg	    fi
8488d63fdb69Smrg	  fi
84893da084b3Smrg
8490d63fdb69Smrg	  libobjs=$output
8491d63fdb69Smrg	  # Restore the value of output.
8492d63fdb69Smrg	  output=$save_output
84933da084b3Smrg
8494d63fdb69Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
8495d63fdb69Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8496d63fdb69Smrg	    test "X$libobjs" = "X " && libobjs=
8497d63fdb69Smrg	  fi
8498d63fdb69Smrg	  # Expand the library linking commands again to reset the
8499d63fdb69Smrg	  # value of $libobjs for piecewise linking.
8500d63fdb69Smrg
8501d63fdb69Smrg	  # Do each of the archive commands.
8502d63fdb69Smrg	  if test "$module" = yes && test -n "$module_cmds" ; then
8503d63fdb69Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8504d63fdb69Smrg	      cmds=$module_expsym_cmds
85053da084b3Smrg	    else
8506d63fdb69Smrg	      cmds=$module_cmds
85073da084b3Smrg	    fi
85083da084b3Smrg	  else
8509d63fdb69Smrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8510d63fdb69Smrg	      cmds=$archive_expsym_cmds
8511d63fdb69Smrg	    else
8512d63fdb69Smrg	      cmds=$archive_cmds
8513d63fdb69Smrg	    fi
85143da084b3Smrg	  fi
85153da084b3Smrg	fi
85163da084b3Smrg
8517d63fdb69Smrg	if test -n "$delfiles"; then
8518d63fdb69Smrg	  # Append the command to remove temporary files to $cmds.
8519d63fdb69Smrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
8520d63fdb69Smrg	fi
85213da084b3Smrg
8522d63fdb69Smrg	# Add any objects from preloaded convenience libraries
8523d63fdb69Smrg	if test -n "$dlprefiles"; then
8524d63fdb69Smrg	  gentop="$output_objdir/${outputname}x"
852548c85eb7Smrg	  func_append generated " $gentop"
85263da084b3Smrg
8527d63fdb69Smrg	  func_extract_archives $gentop $dlprefiles
852848c85eb7Smrg	  func_append libobjs " $func_extract_archives_result"
8529d63fdb69Smrg	  test "X$libobjs" = "X " && libobjs=
85303da084b3Smrg	fi
85313da084b3Smrg
8532d63fdb69Smrg	save_ifs="$IFS"; IFS='~'
8533d63fdb69Smrg	for cmd in $cmds; do
8534d63fdb69Smrg	  IFS="$save_ifs"
8535d63fdb69Smrg	  eval cmd=\"$cmd\"
8536d63fdb69Smrg	  $opt_silent || {
8537d63fdb69Smrg	    func_quote_for_expand "$cmd"
8538d63fdb69Smrg	    eval "func_echo $func_quote_for_expand_result"
8539d63fdb69Smrg	  }
8540d63fdb69Smrg	  $opt_dry_run || eval "$cmd" || {
8541d63fdb69Smrg	    lt_exit=$?
85423da084b3Smrg
8543d63fdb69Smrg	    # Restore the uninstalled library and exit
854448c85eb7Smrg	    if test "$opt_mode" = relink; then
8545d63fdb69Smrg	      ( cd "$output_objdir" && \
8546d63fdb69Smrg	        $RM "${realname}T" && \
8547d63fdb69Smrg		$MV "${realname}U" "$realname" )
8548d63fdb69Smrg	    fi
8549d63fdb69Smrg
8550d63fdb69Smrg	    exit $lt_exit
8551d63fdb69Smrg	  }
8552d63fdb69Smrg	done
8553d63fdb69Smrg	IFS="$save_ifs"
8554d63fdb69Smrg
8555d63fdb69Smrg	# Restore the uninstalled library and exit
855648c85eb7Smrg	if test "$opt_mode" = relink; then
8557d63fdb69Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
8558d63fdb69Smrg
8559d63fdb69Smrg	  if test -n "$convenience"; then
8560d63fdb69Smrg	    if test -z "$whole_archive_flag_spec"; then
8561d63fdb69Smrg	      func_show_eval '${RM}r "$gentop"'
85623da084b3Smrg	    fi
85633da084b3Smrg	  fi
85643da084b3Smrg
8565d63fdb69Smrg	  exit $EXIT_SUCCESS
8566d63fdb69Smrg	fi
85673da084b3Smrg
8568d63fdb69Smrg	# Create links to the real library.
8569d63fdb69Smrg	for linkname in $linknames; do
8570d63fdb69Smrg	  if test "$realname" != "$linkname"; then
8571d63fdb69Smrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
8572d63fdb69Smrg	  fi
8573d63fdb69Smrg	done
8574d63fdb69Smrg
8575d63fdb69Smrg	# If -module or -export-dynamic was specified, set the dlname.
8576d63fdb69Smrg	if test "$module" = yes || test "$export_dynamic" = yes; then
8577d63fdb69Smrg	  # On all known operating systems, these are identical.
8578d63fdb69Smrg	  dlname="$soname"
8579d63fdb69Smrg	fi
8580d63fdb69Smrg      fi
8581d63fdb69Smrg      ;;
8582d63fdb69Smrg
8583d63fdb69Smrg    obj)
8584d63fdb69Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
8585d63fdb69Smrg	func_warning "\`-dlopen' is ignored for objects"
8586d63fdb69Smrg      fi
8587d63fdb69Smrg
8588d63fdb69Smrg      case " $deplibs" in
8589d63fdb69Smrg      *\ -l* | *\ -L*)
8590d63fdb69Smrg	func_warning "\`-l' and \`-L' are ignored for objects" ;;
8591d63fdb69Smrg      esac
8592d63fdb69Smrg
8593d63fdb69Smrg      test -n "$rpath" && \
8594d63fdb69Smrg	func_warning "\`-rpath' is ignored for objects"
8595d63fdb69Smrg
8596d63fdb69Smrg      test -n "$xrpath" && \
8597d63fdb69Smrg	func_warning "\`-R' is ignored for objects"
8598d63fdb69Smrg
8599d63fdb69Smrg      test -n "$vinfo" && \
8600d63fdb69Smrg	func_warning "\`-version-info' is ignored for objects"
8601d63fdb69Smrg
8602d63fdb69Smrg      test -n "$release" && \
8603d63fdb69Smrg	func_warning "\`-release' is ignored for objects"
8604d63fdb69Smrg
8605d63fdb69Smrg      case $output in
8606d63fdb69Smrg      *.lo)
8607d63fdb69Smrg	test -n "$objs$old_deplibs" && \
8608d63fdb69Smrg	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
8609d63fdb69Smrg
8610d63fdb69Smrg	libobj=$output
8611d63fdb69Smrg	func_lo2o "$libobj"
8612d63fdb69Smrg	obj=$func_lo2o_result
8613d63fdb69Smrg	;;
8614d63fdb69Smrg      *)
8615d63fdb69Smrg	libobj=
8616d63fdb69Smrg	obj="$output"
8617d63fdb69Smrg	;;
8618d63fdb69Smrg      esac
8619d63fdb69Smrg
8620d63fdb69Smrg      # Delete the old objects.
8621d63fdb69Smrg      $opt_dry_run || $RM $obj $libobj
8622d63fdb69Smrg
8623d63fdb69Smrg      # Objects from convenience libraries.  This assumes
8624d63fdb69Smrg      # single-version convenience libraries.  Whenever we create
8625d63fdb69Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
8626d63fdb69Smrg      # the extraction.
8627d63fdb69Smrg      reload_conv_objs=
8628d63fdb69Smrg      gentop=
8629d63fdb69Smrg      # reload_cmds runs $LD directly, so let us get rid of
8630d63fdb69Smrg      # -Wl from whole_archive_flag_spec and hope we can get by with
8631d63fdb69Smrg      # turning comma into space..
8632d63fdb69Smrg      wl=
8633d63fdb69Smrg
8634d63fdb69Smrg      if test -n "$convenience"; then
8635d63fdb69Smrg	if test -n "$whole_archive_flag_spec"; then
8636d63fdb69Smrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
863755acc8fcSmrg	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
8638d63fdb69Smrg	else
8639d63fdb69Smrg	  gentop="$output_objdir/${obj}x"
864048c85eb7Smrg	  func_append generated " $gentop"
8641d63fdb69Smrg
8642d63fdb69Smrg	  func_extract_archives $gentop $convenience
8643d63fdb69Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
8644d63fdb69Smrg	fi
8645d63fdb69Smrg      fi
86463da084b3Smrg
864748c85eb7Smrg      # If we're not building shared, we need to use non_pic_objs
864848c85eb7Smrg      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
864948c85eb7Smrg
8650d63fdb69Smrg      # Create the old-style object.
865155acc8fcSmrg      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
86523da084b3Smrg
8653d63fdb69Smrg      output="$obj"
8654d63fdb69Smrg      func_execute_cmds "$reload_cmds" 'exit $?'
86553da084b3Smrg
8656d63fdb69Smrg      # Exit if we aren't doing a library object file.
8657d63fdb69Smrg      if test -z "$libobj"; then
8658d63fdb69Smrg	if test -n "$gentop"; then
8659d63fdb69Smrg	  func_show_eval '${RM}r "$gentop"'
8660d63fdb69Smrg	fi
86613da084b3Smrg
8662d63fdb69Smrg	exit $EXIT_SUCCESS
8663d63fdb69Smrg      fi
86643da084b3Smrg
8665d63fdb69Smrg      if test "$build_libtool_libs" != yes; then
8666d63fdb69Smrg	if test -n "$gentop"; then
8667d63fdb69Smrg	  func_show_eval '${RM}r "$gentop"'
8668d63fdb69Smrg	fi
86693da084b3Smrg
8670d63fdb69Smrg	# Create an invalid libtool object if no PIC, so that we don't
8671d63fdb69Smrg	# accidentally link it into a program.
8672d63fdb69Smrg	# $show "echo timestamp > $libobj"
8673d63fdb69Smrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
8674d63fdb69Smrg	exit $EXIT_SUCCESS
8675d63fdb69Smrg      fi
86763da084b3Smrg
8677d63fdb69Smrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
8678d63fdb69Smrg	# Only do commands if we really have different PIC objects.
8679d63fdb69Smrg	reload_objs="$libobjs $reload_conv_objs"
8680d63fdb69Smrg	output="$libobj"
8681d63fdb69Smrg	func_execute_cmds "$reload_cmds" 'exit $?'
86823da084b3Smrg      fi
86833da084b3Smrg
8684d63fdb69Smrg      if test -n "$gentop"; then
8685d63fdb69Smrg	func_show_eval '${RM}r "$gentop"'
8686d63fdb69Smrg      fi
86873da084b3Smrg
8688d63fdb69Smrg      exit $EXIT_SUCCESS
8689d63fdb69Smrg      ;;
86903da084b3Smrg
8691d63fdb69Smrg    prog)
8692d63fdb69Smrg      case $host in
8693d63fdb69Smrg	*cygwin*) func_stripname '' '.exe' "$output"
8694d63fdb69Smrg	          output=$func_stripname_result.exe;;
86953da084b3Smrg      esac
8696d63fdb69Smrg      test -n "$vinfo" && \
8697d63fdb69Smrg	func_warning "\`-version-info' is ignored for programs"
86983da084b3Smrg
8699d63fdb69Smrg      test -n "$release" && \
8700d63fdb69Smrg	func_warning "\`-release' is ignored for programs"
87013da084b3Smrg
8702d63fdb69Smrg      test "$preload" = yes \
8703d63fdb69Smrg        && test "$dlopen_support" = unknown \
8704d63fdb69Smrg	&& test "$dlopen_self" = unknown \
8705d63fdb69Smrg	&& test "$dlopen_self_static" = unknown && \
8706d63fdb69Smrg	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
87073da084b3Smrg
8708d63fdb69Smrg      case $host in
8709d63fdb69Smrg      *-*-rhapsody* | *-*-darwin1.[012])
8710d63fdb69Smrg	# On Rhapsody replace the C library is the System framework
871155acc8fcSmrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
871255acc8fcSmrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
87133da084b3Smrg	;;
87143da084b3Smrg      esac
87153da084b3Smrg
8716d63fdb69Smrg      case $host in
8717d63fdb69Smrg      *-*-darwin*)
8718d63fdb69Smrg	# Don't allow lazy linking, it breaks C++ global constructors
8719d63fdb69Smrg	# But is supposedly fixed on 10.4 or later (yay!).
8720d63fdb69Smrg	if test "$tagname" = CXX ; then
8721d63fdb69Smrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
8722d63fdb69Smrg	    10.[0123])
872348c85eb7Smrg	      func_append compile_command " ${wl}-bind_at_load"
872448c85eb7Smrg	      func_append finalize_command " ${wl}-bind_at_load"
8725d63fdb69Smrg	    ;;
8726d63fdb69Smrg	  esac
8727d63fdb69Smrg	fi
8728d63fdb69Smrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
872955acc8fcSmrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
873055acc8fcSmrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
87313da084b3Smrg	;;
87323da084b3Smrg      esac
87333da084b3Smrg
87343da084b3Smrg
8735d63fdb69Smrg      # move library search paths that coincide with paths to not yet
8736d63fdb69Smrg      # installed libraries to the beginning of the library search list
8737d63fdb69Smrg      new_libs=
8738d63fdb69Smrg      for path in $notinst_path; do
8739d63fdb69Smrg	case " $new_libs " in
8740d63fdb69Smrg	*" -L$path/$objdir "*) ;;
87413da084b3Smrg	*)
8742d63fdb69Smrg	  case " $compile_deplibs " in
8743d63fdb69Smrg	  *" -L$path/$objdir "*)
874448c85eb7Smrg	    func_append new_libs " -L$path/$objdir" ;;
8745d63fdb69Smrg	  esac
87463da084b3Smrg	  ;;
87473da084b3Smrg	esac
87483da084b3Smrg      done
8749d63fdb69Smrg      for deplib in $compile_deplibs; do
8750d63fdb69Smrg	case $deplib in
8751d63fdb69Smrg	-L*)
8752d63fdb69Smrg	  case " $new_libs " in
8753d63fdb69Smrg	  *" $deplib "*) ;;
875448c85eb7Smrg	  *) func_append new_libs " $deplib" ;;
8755d63fdb69Smrg	  esac
8756d63fdb69Smrg	  ;;
875748c85eb7Smrg	*) func_append new_libs " $deplib" ;;
8758d63fdb69Smrg	esac
8759d63fdb69Smrg      done
8760d63fdb69Smrg      compile_deplibs="$new_libs"
87613da084b3Smrg
87623da084b3Smrg
876348c85eb7Smrg      func_append compile_command " $compile_deplibs"
876448c85eb7Smrg      func_append finalize_command " $finalize_deplibs"
87653da084b3Smrg
8766d63fdb69Smrg      if test -n "$rpath$xrpath"; then
8767d63fdb69Smrg	# If the user specified any rpath flags, then add them.
8768d63fdb69Smrg	for libdir in $rpath $xrpath; do
8769d63fdb69Smrg	  # This is the magic to use -rpath.
8770d63fdb69Smrg	  case "$finalize_rpath " in
8771d63fdb69Smrg	  *" $libdir "*) ;;
877248c85eb7Smrg	  *) func_append finalize_rpath " $libdir" ;;
8773d63fdb69Smrg	  esac
8774d63fdb69Smrg	done
8775d63fdb69Smrg      fi
87763da084b3Smrg
8777d63fdb69Smrg      # Now hardcode the library paths
8778d63fdb69Smrg      rpath=
8779d63fdb69Smrg      hardcode_libdirs=
8780d63fdb69Smrg      for libdir in $compile_rpath $finalize_rpath; do
8781d63fdb69Smrg	if test -n "$hardcode_libdir_flag_spec"; then
8782d63fdb69Smrg	  if test -n "$hardcode_libdir_separator"; then
8783d63fdb69Smrg	    if test -z "$hardcode_libdirs"; then
8784d63fdb69Smrg	      hardcode_libdirs="$libdir"
8785d63fdb69Smrg	    else
8786d63fdb69Smrg	      # Just accumulate the unique libdirs.
8787d63fdb69Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8788d63fdb69Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8789d63fdb69Smrg		;;
8790d63fdb69Smrg	      *)
879148c85eb7Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8792d63fdb69Smrg		;;
8793d63fdb69Smrg	      esac
8794d63fdb69Smrg	    fi
8795d63fdb69Smrg	  else
8796d63fdb69Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
879748c85eb7Smrg	    func_append rpath " $flag"
8798d63fdb69Smrg	  fi
8799d63fdb69Smrg	elif test -n "$runpath_var"; then
8800d63fdb69Smrg	  case "$perm_rpath " in
88013da084b3Smrg	  *" $libdir "*) ;;
880248c85eb7Smrg	  *) func_append perm_rpath " $libdir" ;;
88033da084b3Smrg	  esac
8804d63fdb69Smrg	fi
8805d63fdb69Smrg	case $host in
8806d63fdb69Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
8807d63fdb69Smrg	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
8808d63fdb69Smrg	  case :$dllsearchpath: in
8809d63fdb69Smrg	  *":$libdir:"*) ;;
8810d63fdb69Smrg	  ::) dllsearchpath=$libdir;;
881148c85eb7Smrg	  *) func_append dllsearchpath ":$libdir";;
8812d63fdb69Smrg	  esac
8813d63fdb69Smrg	  case :$dllsearchpath: in
8814d63fdb69Smrg	  *":$testbindir:"*) ;;
8815d63fdb69Smrg	  ::) dllsearchpath=$testbindir;;
881648c85eb7Smrg	  *) func_append dllsearchpath ":$testbindir";;
8817d63fdb69Smrg	  esac
8818d63fdb69Smrg	  ;;
8819d63fdb69Smrg	esac
8820d63fdb69Smrg      done
8821d63fdb69Smrg      # Substitute the hardcoded libdirs into the rpath.
8822d63fdb69Smrg      if test -n "$hardcode_libdir_separator" &&
8823d63fdb69Smrg	 test -n "$hardcode_libdirs"; then
8824d63fdb69Smrg	libdir="$hardcode_libdirs"
8825d63fdb69Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
8826d63fdb69Smrg      fi
8827d63fdb69Smrg      compile_rpath="$rpath"
8828d63fdb69Smrg
8829d63fdb69Smrg      rpath=
8830d63fdb69Smrg      hardcode_libdirs=
8831d63fdb69Smrg      for libdir in $finalize_rpath; do
8832d63fdb69Smrg	if test -n "$hardcode_libdir_flag_spec"; then
8833d63fdb69Smrg	  if test -n "$hardcode_libdir_separator"; then
8834d63fdb69Smrg	    if test -z "$hardcode_libdirs"; then
8835d63fdb69Smrg	      hardcode_libdirs="$libdir"
8836d63fdb69Smrg	    else
8837d63fdb69Smrg	      # Just accumulate the unique libdirs.
8838d63fdb69Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8839d63fdb69Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8840d63fdb69Smrg		;;
8841d63fdb69Smrg	      *)
884248c85eb7Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8843d63fdb69Smrg		;;
8844d63fdb69Smrg	      esac
8845d63fdb69Smrg	    fi
8846d63fdb69Smrg	  else
8847d63fdb69Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
884848c85eb7Smrg	    func_append rpath " $flag"
8849d63fdb69Smrg	  fi
8850d63fdb69Smrg	elif test -n "$runpath_var"; then
8851d63fdb69Smrg	  case "$finalize_perm_rpath " in
88523da084b3Smrg	  *" $libdir "*) ;;
885348c85eb7Smrg	  *) func_append finalize_perm_rpath " $libdir" ;;
88543da084b3Smrg	  esac
88553da084b3Smrg	fi
8856d63fdb69Smrg      done
8857d63fdb69Smrg      # Substitute the hardcoded libdirs into the rpath.
8858d63fdb69Smrg      if test -n "$hardcode_libdir_separator" &&
8859d63fdb69Smrg	 test -n "$hardcode_libdirs"; then
8860d63fdb69Smrg	libdir="$hardcode_libdirs"
8861d63fdb69Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
8862d63fdb69Smrg      fi
8863d63fdb69Smrg      finalize_rpath="$rpath"
88643da084b3Smrg
8865d63fdb69Smrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
8866d63fdb69Smrg	# Transform all the library objects into standard objects.
886755acc8fcSmrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
886855acc8fcSmrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8869d63fdb69Smrg      fi
88703da084b3Smrg
8871d63fdb69Smrg      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
88723da084b3Smrg
8873d63fdb69Smrg      # template prelinking step
8874d63fdb69Smrg      if test -n "$prelink_cmds"; then
8875d63fdb69Smrg	func_execute_cmds "$prelink_cmds" 'exit $?'
8876d63fdb69Smrg      fi
88773da084b3Smrg
8878d63fdb69Smrg      wrappers_required=yes
8879d63fdb69Smrg      case $host in
888055acc8fcSmrg      *cegcc* | *mingw32ce*)
888155acc8fcSmrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
888255acc8fcSmrg        wrappers_required=no
888355acc8fcSmrg        ;;
8884d63fdb69Smrg      *cygwin* | *mingw* )
8885d63fdb69Smrg        if test "$build_libtool_libs" != yes; then
8886d63fdb69Smrg          wrappers_required=no
8887d63fdb69Smrg        fi
8888d63fdb69Smrg        ;;
8889d63fdb69Smrg      *)
8890d63fdb69Smrg        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
8891d63fdb69Smrg          wrappers_required=no
8892d63fdb69Smrg        fi
8893d63fdb69Smrg        ;;
8894d63fdb69Smrg      esac
8895d63fdb69Smrg      if test "$wrappers_required" = no; then
8896d63fdb69Smrg	# Replace the output file specification.
889755acc8fcSmrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8898d63fdb69Smrg	link_command="$compile_command$compile_rpath"
88993da084b3Smrg
8900d63fdb69Smrg	# We have no uninstalled library dependencies, so finalize right now.
8901d63fdb69Smrg	exit_status=0
8902d63fdb69Smrg	func_show_eval "$link_command" 'exit_status=$?'
89033da084b3Smrg
890448c85eb7Smrg	if test -n "$postlink_cmds"; then
890548c85eb7Smrg	  func_to_tool_file "$output"
890648c85eb7Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
890748c85eb7Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
890848c85eb7Smrg	fi
890948c85eb7Smrg
8910d63fdb69Smrg	# Delete the generated files.
8911d63fdb69Smrg	if test -f "$output_objdir/${outputname}S.${objext}"; then
8912d63fdb69Smrg	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
8913d63fdb69Smrg	fi
89143da084b3Smrg
8915d63fdb69Smrg	exit $exit_status
8916d63fdb69Smrg      fi
89173da084b3Smrg
8918d63fdb69Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
8919d63fdb69Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
8920d63fdb69Smrg      fi
8921d63fdb69Smrg      if test -n "$finalize_shlibpath"; then
8922d63fdb69Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
8923d63fdb69Smrg      fi
89243da084b3Smrg
8925d63fdb69Smrg      compile_var=
8926d63fdb69Smrg      finalize_var=
8927d63fdb69Smrg      if test -n "$runpath_var"; then
8928d63fdb69Smrg	if test -n "$perm_rpath"; then
8929d63fdb69Smrg	  # We should set the runpath_var.
8930d63fdb69Smrg	  rpath=
8931d63fdb69Smrg	  for dir in $perm_rpath; do
893248c85eb7Smrg	    func_append rpath "$dir:"
89333da084b3Smrg	  done
8934d63fdb69Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
89353da084b3Smrg	fi
8936d63fdb69Smrg	if test -n "$finalize_perm_rpath"; then
8937d63fdb69Smrg	  # We should set the runpath_var.
8938d63fdb69Smrg	  rpath=
8939d63fdb69Smrg	  for dir in $finalize_perm_rpath; do
894048c85eb7Smrg	    func_append rpath "$dir:"
8941d63fdb69Smrg	  done
8942d63fdb69Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
8943d63fdb69Smrg	fi
8944d63fdb69Smrg      fi
89453da084b3Smrg
8946d63fdb69Smrg      if test "$no_install" = yes; then
8947d63fdb69Smrg	# We don't need to create a wrapper script.
8948d63fdb69Smrg	link_command="$compile_var$compile_command$compile_rpath"
8949d63fdb69Smrg	# Replace the output file specification.
895055acc8fcSmrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8951d63fdb69Smrg	# Delete the old output file.
8952d63fdb69Smrg	$opt_dry_run || $RM $output
8953d63fdb69Smrg	# Link the executable and exit
8954d63fdb69Smrg	func_show_eval "$link_command" 'exit $?'
895548c85eb7Smrg
895648c85eb7Smrg	if test -n "$postlink_cmds"; then
895748c85eb7Smrg	  func_to_tool_file "$output"
895848c85eb7Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
895948c85eb7Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
896048c85eb7Smrg	fi
896148c85eb7Smrg
8962d63fdb69Smrg	exit $EXIT_SUCCESS
8963d63fdb69Smrg      fi
89643da084b3Smrg
8965d63fdb69Smrg      if test "$hardcode_action" = relink; then
8966d63fdb69Smrg	# Fast installation is not supported
8967d63fdb69Smrg	link_command="$compile_var$compile_command$compile_rpath"
8968d63fdb69Smrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
89693da084b3Smrg
8970d63fdb69Smrg	func_warning "this platform does not like uninstalled shared libraries"
8971d63fdb69Smrg	func_warning "\`$output' will be relinked during installation"
8972d63fdb69Smrg      else
8973d63fdb69Smrg	if test "$fast_install" != no; then
8974d63fdb69Smrg	  link_command="$finalize_var$compile_command$finalize_rpath"
8975d63fdb69Smrg	  if test "$fast_install" = yes; then
897655acc8fcSmrg	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
8977d63fdb69Smrg	  else
8978d63fdb69Smrg	    # fast_install is set to needless
8979d63fdb69Smrg	    relink_command=
8980d63fdb69Smrg	  fi
89813da084b3Smrg	else
8982d63fdb69Smrg	  link_command="$compile_var$compile_command$compile_rpath"
8983d63fdb69Smrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
89843da084b3Smrg	fi
8985d63fdb69Smrg      fi
89863da084b3Smrg
8987d63fdb69Smrg      # Replace the output file specification.
898855acc8fcSmrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
89893da084b3Smrg
8990d63fdb69Smrg      # Delete the old output files.
8991d63fdb69Smrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
89923da084b3Smrg
8993d63fdb69Smrg      func_show_eval "$link_command" 'exit $?'
89943da084b3Smrg
899548c85eb7Smrg      if test -n "$postlink_cmds"; then
899648c85eb7Smrg	func_to_tool_file "$output_objdir/$outputname"
899748c85eb7Smrg	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'`
899848c85eb7Smrg	func_execute_cmds "$postlink_cmds" 'exit $?'
899948c85eb7Smrg      fi
900048c85eb7Smrg
9001d63fdb69Smrg      # Now create the wrapper script.
9002d63fdb69Smrg      func_verbose "creating $output"
90033da084b3Smrg
9004d63fdb69Smrg      # Quote the relink command for shipping.
9005d63fdb69Smrg      if test -n "$relink_command"; then
9006d63fdb69Smrg	# Preserve any variables that may affect compiler behavior
9007d63fdb69Smrg	for var in $variables_saved_for_relink; do
9008d63fdb69Smrg	  if eval test -z \"\${$var+set}\"; then
9009d63fdb69Smrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9010d63fdb69Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
9011d63fdb69Smrg	    relink_command="$var=; export $var; $relink_command"
9012d63fdb69Smrg	  else
9013d63fdb69Smrg	    func_quote_for_eval "$var_value"
9014d63fdb69Smrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9015d63fdb69Smrg	  fi
9016d63fdb69Smrg	done
9017d63fdb69Smrg	relink_command="(cd `pwd`; $relink_command)"
901855acc8fcSmrg	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9019d63fdb69Smrg      fi
90203da084b3Smrg
9021d63fdb69Smrg      # Only actually do things if not in dry run mode.
9022d63fdb69Smrg      $opt_dry_run || {
9023d63fdb69Smrg	# win32 will think the script is a binary if it has
9024d63fdb69Smrg	# a .exe suffix, so we strip it off here.
9025d63fdb69Smrg	case $output in
9026d63fdb69Smrg	  *.exe) func_stripname '' '.exe' "$output"
9027d63fdb69Smrg	         output=$func_stripname_result ;;
9028d63fdb69Smrg	esac
9029d63fdb69Smrg	# test for cygwin because mv fails w/o .exe extensions
90303da084b3Smrg	case $host in
9031d63fdb69Smrg	  *cygwin*)
9032d63fdb69Smrg	    exeext=.exe
9033d63fdb69Smrg	    func_stripname '' '.exe' "$outputname"
9034d63fdb69Smrg	    outputname=$func_stripname_result ;;
9035d63fdb69Smrg	  *) exeext= ;;
90363da084b3Smrg	esac
9037d63fdb69Smrg	case $host in
9038d63fdb69Smrg	  *cygwin* | *mingw* )
9039d63fdb69Smrg	    func_dirname_and_basename "$output" "" "."
9040d63fdb69Smrg	    output_name=$func_basename_result
9041d63fdb69Smrg	    output_path=$func_dirname_result
9042d63fdb69Smrg	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
9043d63fdb69Smrg	    cwrapper="$output_path/$output_name.exe"
9044d63fdb69Smrg	    $RM $cwrappersource $cwrapper
9045d63fdb69Smrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
9046d63fdb69Smrg
9047d63fdb69Smrg	    func_emit_cwrapperexe_src > $cwrappersource
9048d63fdb69Smrg
9049d63fdb69Smrg	    # The wrapper executable is built using the $host compiler,
9050d63fdb69Smrg	    # because it contains $host paths and files. If cross-
9051d63fdb69Smrg	    # compiling, it, like the target executable, must be
9052d63fdb69Smrg	    # executed on the $host or under an emulation environment.
9053d63fdb69Smrg	    $opt_dry_run || {
9054d63fdb69Smrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
9055d63fdb69Smrg	      $STRIP $cwrapper
9056d63fdb69Smrg	    }
90573da084b3Smrg
9058d63fdb69Smrg	    # Now, create the wrapper script for func_source use:
9059d63fdb69Smrg	    func_ltwrapper_scriptname $cwrapper
9060d63fdb69Smrg	    $RM $func_ltwrapper_scriptname_result
9061d63fdb69Smrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
9062d63fdb69Smrg	    $opt_dry_run || {
9063d63fdb69Smrg	      # note: this script will not be executed, so do not chmod.
9064d63fdb69Smrg	      if test "x$build" = "x$host" ; then
9065d63fdb69Smrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
90663da084b3Smrg	      else
9067d63fdb69Smrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
90683da084b3Smrg	      fi
9069d63fdb69Smrg	    }
9070d63fdb69Smrg	  ;;
9071d63fdb69Smrg	  * )
9072d63fdb69Smrg	    $RM $output
9073d63fdb69Smrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
90743da084b3Smrg
9075d63fdb69Smrg	    func_emit_wrapper no > $output
9076d63fdb69Smrg	    chmod +x $output
90773da084b3Smrg	  ;;
90783da084b3Smrg	esac
9079d63fdb69Smrg      }
9080d63fdb69Smrg      exit $EXIT_SUCCESS
9081d63fdb69Smrg      ;;
9082d63fdb69Smrg    esac
90833da084b3Smrg
9084d63fdb69Smrg    # See if we need to build an old-fashioned archive.
9085d63fdb69Smrg    for oldlib in $oldlibs; do
90863da084b3Smrg
9087d63fdb69Smrg      if test "$build_libtool_libs" = convenience; then
9088d63fdb69Smrg	oldobjs="$libobjs_save $symfileobj"
9089d63fdb69Smrg	addlibs="$convenience"
9090d63fdb69Smrg	build_libtool_libs=no
9091d63fdb69Smrg      else
9092d63fdb69Smrg	if test "$build_libtool_libs" = module; then
9093d63fdb69Smrg	  oldobjs="$libobjs_save"
9094d63fdb69Smrg	  build_libtool_libs=no
9095d63fdb69Smrg	else
9096d63fdb69Smrg	  oldobjs="$old_deplibs $non_pic_objects"
9097d63fdb69Smrg	  if test "$preload" = yes && test -f "$symfileobj"; then
909848c85eb7Smrg	    func_append oldobjs " $symfileobj"
9099d63fdb69Smrg	  fi
9100d63fdb69Smrg	fi
9101d63fdb69Smrg	addlibs="$old_convenience"
91023da084b3Smrg      fi
91033da084b3Smrg
9104d63fdb69Smrg      if test -n "$addlibs"; then
9105d63fdb69Smrg	gentop="$output_objdir/${outputname}x"
910648c85eb7Smrg	func_append generated " $gentop"
91073da084b3Smrg
9108d63fdb69Smrg	func_extract_archives $gentop $addlibs
910948c85eb7Smrg	func_append oldobjs " $func_extract_archives_result"
9110d63fdb69Smrg      fi
91113da084b3Smrg
9112d63fdb69Smrg      # Do each command in the archive commands.
9113d63fdb69Smrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
9114d63fdb69Smrg	cmds=$old_archive_from_new_cmds
9115d63fdb69Smrg      else
91163da084b3Smrg
9117d63fdb69Smrg	# Add any objects from preloaded convenience libraries
9118d63fdb69Smrg	if test -n "$dlprefiles"; then
9119d63fdb69Smrg	  gentop="$output_objdir/${outputname}x"
912048c85eb7Smrg	  func_append generated " $gentop"
91213da084b3Smrg
9122d63fdb69Smrg	  func_extract_archives $gentop $dlprefiles
912348c85eb7Smrg	  func_append oldobjs " $func_extract_archives_result"
9124d63fdb69Smrg	fi
91253da084b3Smrg
9126d63fdb69Smrg	# POSIX demands no paths to be encoded in archives.  We have
9127d63fdb69Smrg	# to avoid creating archives with duplicate basenames if we
9128d63fdb69Smrg	# might have to extract them afterwards, e.g., when creating a
9129d63fdb69Smrg	# static archive out of a convenience library, or when linking
9130d63fdb69Smrg	# the entirety of a libtool archive into another (currently
9131d63fdb69Smrg	# not supported by libtool).
9132d63fdb69Smrg	if (for obj in $oldobjs
9133d63fdb69Smrg	    do
9134d63fdb69Smrg	      func_basename "$obj"
9135d63fdb69Smrg	      $ECHO "$func_basename_result"
9136d63fdb69Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
9137d63fdb69Smrg	  :
9138d63fdb69Smrg	else
913955acc8fcSmrg	  echo "copying selected object files to avoid basename conflicts..."
9140d63fdb69Smrg	  gentop="$output_objdir/${outputname}x"
914148c85eb7Smrg	  func_append generated " $gentop"
9142d63fdb69Smrg	  func_mkdir_p "$gentop"
9143d63fdb69Smrg	  save_oldobjs=$oldobjs
9144d63fdb69Smrg	  oldobjs=
9145d63fdb69Smrg	  counter=1
9146d63fdb69Smrg	  for obj in $save_oldobjs
9147d63fdb69Smrg	  do
9148d63fdb69Smrg	    func_basename "$obj"
9149d63fdb69Smrg	    objbase="$func_basename_result"
9150d63fdb69Smrg	    case " $oldobjs " in
9151d63fdb69Smrg	    " ") oldobjs=$obj ;;
9152d63fdb69Smrg	    *[\ /]"$objbase "*)
9153d63fdb69Smrg	      while :; do
9154d63fdb69Smrg		# Make sure we don't pick an alternate name that also
9155d63fdb69Smrg		# overlaps.
9156d63fdb69Smrg		newobj=lt$counter-$objbase
9157d63fdb69Smrg		func_arith $counter + 1
9158d63fdb69Smrg		counter=$func_arith_result
9159d63fdb69Smrg		case " $oldobjs " in
9160d63fdb69Smrg		*[\ /]"$newobj "*) ;;
9161d63fdb69Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
9162d63fdb69Smrg		esac
9163d63fdb69Smrg	      done
9164d63fdb69Smrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
916548c85eb7Smrg	      func_append oldobjs " $gentop/$newobj"
9166d63fdb69Smrg	      ;;
916748c85eb7Smrg	    *) func_append oldobjs " $obj" ;;
9168d63fdb69Smrg	    esac
91693da084b3Smrg	  done
91703da084b3Smrg	fi
917148c85eb7Smrg	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
917248c85eb7Smrg	tool_oldlib=$func_to_tool_file_result
9173d63fdb69Smrg	eval cmds=\"$old_archive_cmds\"
91743da084b3Smrg
9175d63fdb69Smrg	func_len " $cmds"
9176d63fdb69Smrg	len=$func_len_result
9177d63fdb69Smrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
9178d63fdb69Smrg	  cmds=$old_archive_cmds
917948c85eb7Smrg	elif test -n "$archiver_list_spec"; then
918048c85eb7Smrg	  func_verbose "using command file archive linking..."
918148c85eb7Smrg	  for obj in $oldobjs
918248c85eb7Smrg	  do
918348c85eb7Smrg	    func_to_tool_file "$obj"
918448c85eb7Smrg	    $ECHO "$func_to_tool_file_result"
918548c85eb7Smrg	  done > $output_objdir/$libname.libcmd
918648c85eb7Smrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
918748c85eb7Smrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
918848c85eb7Smrg	  cmds=$old_archive_cmds
9189d63fdb69Smrg	else
9190d63fdb69Smrg	  # the command line is too long to link in one step, link in parts
9191d63fdb69Smrg	  func_verbose "using piecewise archive linking..."
9192d63fdb69Smrg	  save_RANLIB=$RANLIB
9193d63fdb69Smrg	  RANLIB=:
9194d63fdb69Smrg	  objlist=
9195d63fdb69Smrg	  concat_cmds=
9196d63fdb69Smrg	  save_oldobjs=$oldobjs
9197d63fdb69Smrg	  oldobjs=
9198d63fdb69Smrg	  # Is there a better way of finding the last object in the list?
9199d63fdb69Smrg	  for obj in $save_oldobjs
9200d63fdb69Smrg	  do
9201d63fdb69Smrg	    last_oldobj=$obj
9202d63fdb69Smrg	  done
9203d63fdb69Smrg	  eval test_cmds=\"$old_archive_cmds\"
9204d63fdb69Smrg	  func_len " $test_cmds"
9205d63fdb69Smrg	  len0=$func_len_result
9206d63fdb69Smrg	  len=$len0
9207d63fdb69Smrg	  for obj in $save_oldobjs
9208d63fdb69Smrg	  do
9209d63fdb69Smrg	    func_len " $obj"
9210d63fdb69Smrg	    func_arith $len + $func_len_result
9211d63fdb69Smrg	    len=$func_arith_result
9212d63fdb69Smrg	    func_append objlist " $obj"
9213d63fdb69Smrg	    if test "$len" -lt "$max_cmd_len"; then
9214d63fdb69Smrg	      :
9215d63fdb69Smrg	    else
9216d63fdb69Smrg	      # the above command should be used before it gets too long
9217d63fdb69Smrg	      oldobjs=$objlist
9218d63fdb69Smrg	      if test "$obj" = "$last_oldobj" ; then
9219d63fdb69Smrg		RANLIB=$save_RANLIB
9220d63fdb69Smrg	      fi
9221d63fdb69Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9222d63fdb69Smrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
9223d63fdb69Smrg	      objlist=
9224d63fdb69Smrg	      len=$len0
9225d63fdb69Smrg	    fi
9226d63fdb69Smrg	  done
9227d63fdb69Smrg	  RANLIB=$save_RANLIB
9228d63fdb69Smrg	  oldobjs=$objlist
9229d63fdb69Smrg	  if test "X$oldobjs" = "X" ; then
9230d63fdb69Smrg	    eval cmds=\"\$concat_cmds\"
9231d63fdb69Smrg	  else
9232d63fdb69Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
9233d63fdb69Smrg	  fi
9234d63fdb69Smrg	fi
9235d63fdb69Smrg      fi
9236d63fdb69Smrg      func_execute_cmds "$cmds" 'exit $?'
92373da084b3Smrg    done
92383da084b3Smrg
9239d63fdb69Smrg    test -n "$generated" && \
9240d63fdb69Smrg      func_show_eval "${RM}r$generated"
92413da084b3Smrg
9242d63fdb69Smrg    # Now create the libtool archive.
9243d63fdb69Smrg    case $output in
9244d63fdb69Smrg    *.la)
9245d63fdb69Smrg      old_library=
9246d63fdb69Smrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
9247d63fdb69Smrg      func_verbose "creating $output"
92483da084b3Smrg
9249d63fdb69Smrg      # Preserve any variables that may affect compiler behavior
9250d63fdb69Smrg      for var in $variables_saved_for_relink; do
9251d63fdb69Smrg	if eval test -z \"\${$var+set}\"; then
9252d63fdb69Smrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9253d63fdb69Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
9254d63fdb69Smrg	  relink_command="$var=; export $var; $relink_command"
92553da084b3Smrg	else
9256d63fdb69Smrg	  func_quote_for_eval "$var_value"
9257d63fdb69Smrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
92583da084b3Smrg	fi
9259d63fdb69Smrg      done
9260d63fdb69Smrg      # Quote the link command for shipping.
9261d63fdb69Smrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
926255acc8fcSmrg      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9263d63fdb69Smrg      if test "$hardcode_automatic" = yes ; then
9264d63fdb69Smrg	relink_command=
9265d63fdb69Smrg      fi
92663da084b3Smrg
9267d63fdb69Smrg      # Only create the output if not a dry run.
9268d63fdb69Smrg      $opt_dry_run || {
9269d63fdb69Smrg	for installed in no yes; do
9270d63fdb69Smrg	  if test "$installed" = yes; then
9271d63fdb69Smrg	    if test -z "$install_libdir"; then
9272d63fdb69Smrg	      break
9273d63fdb69Smrg	    fi
9274d63fdb69Smrg	    output="$output_objdir/$outputname"i
9275d63fdb69Smrg	    # Replace all uninstalled libtool libraries with the installed ones
9276d63fdb69Smrg	    newdependency_libs=
9277d63fdb69Smrg	    for deplib in $dependency_libs; do
9278d63fdb69Smrg	      case $deplib in
9279d63fdb69Smrg	      *.la)
9280d63fdb69Smrg		func_basename "$deplib"
9281d63fdb69Smrg		name="$func_basename_result"
928248c85eb7Smrg		func_resolve_sysroot "$deplib"
928348c85eb7Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
9284d63fdb69Smrg		test -z "$libdir" && \
9285d63fdb69Smrg		  func_fatal_error "\`$deplib' is not a valid libtool archive"
928648c85eb7Smrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
928748c85eb7Smrg		;;
928848c85eb7Smrg	      -L*)
928948c85eb7Smrg		func_stripname -L '' "$deplib"
929048c85eb7Smrg		func_replace_sysroot "$func_stripname_result"
929148c85eb7Smrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
929248c85eb7Smrg		;;
929348c85eb7Smrg	      -R*)
929448c85eb7Smrg		func_stripname -R '' "$deplib"
929548c85eb7Smrg		func_replace_sysroot "$func_stripname_result"
929648c85eb7Smrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
9297d63fdb69Smrg		;;
929848c85eb7Smrg	      *) func_append newdependency_libs " $deplib" ;;
9299d63fdb69Smrg	      esac
9300d63fdb69Smrg	    done
9301d63fdb69Smrg	    dependency_libs="$newdependency_libs"
9302d63fdb69Smrg	    newdlfiles=
9303d63fdb69Smrg
9304d63fdb69Smrg	    for lib in $dlfiles; do
9305d63fdb69Smrg	      case $lib in
9306d63fdb69Smrg	      *.la)
9307d63fdb69Smrg	        func_basename "$lib"
9308d63fdb69Smrg		name="$func_basename_result"
9309d63fdb69Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9310d63fdb69Smrg		test -z "$libdir" && \
9311d63fdb69Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
931248c85eb7Smrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
9313d63fdb69Smrg		;;
931448c85eb7Smrg	      *) func_append newdlfiles " $lib" ;;
9315d63fdb69Smrg	      esac
9316d63fdb69Smrg	    done
9317d63fdb69Smrg	    dlfiles="$newdlfiles"
9318d63fdb69Smrg	    newdlprefiles=
9319d63fdb69Smrg	    for lib in $dlprefiles; do
9320d63fdb69Smrg	      case $lib in
9321d63fdb69Smrg	      *.la)
9322d63fdb69Smrg		# Only pass preopened files to the pseudo-archive (for
9323d63fdb69Smrg		# eventual linking with the app. that links it) if we
9324d63fdb69Smrg		# didn't already link the preopened objects directly into
9325d63fdb69Smrg		# the library:
9326d63fdb69Smrg		func_basename "$lib"
9327d63fdb69Smrg		name="$func_basename_result"
9328d63fdb69Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9329d63fdb69Smrg		test -z "$libdir" && \
9330d63fdb69Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
933148c85eb7Smrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
9332d63fdb69Smrg		;;
9333d63fdb69Smrg	      esac
9334d63fdb69Smrg	    done
9335d63fdb69Smrg	    dlprefiles="$newdlprefiles"
9336d63fdb69Smrg	  else
9337d63fdb69Smrg	    newdlfiles=
9338d63fdb69Smrg	    for lib in $dlfiles; do
9339d63fdb69Smrg	      case $lib in
9340d63fdb69Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9341d63fdb69Smrg		*) abs=`pwd`"/$lib" ;;
9342d63fdb69Smrg	      esac
934348c85eb7Smrg	      func_append newdlfiles " $abs"
9344d63fdb69Smrg	    done
9345d63fdb69Smrg	    dlfiles="$newdlfiles"
9346d63fdb69Smrg	    newdlprefiles=
9347d63fdb69Smrg	    for lib in $dlprefiles; do
9348d63fdb69Smrg	      case $lib in
9349d63fdb69Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9350d63fdb69Smrg		*) abs=`pwd`"/$lib" ;;
9351d63fdb69Smrg	      esac
935248c85eb7Smrg	      func_append newdlprefiles " $abs"
9353d63fdb69Smrg	    done
9354d63fdb69Smrg	    dlprefiles="$newdlprefiles"
9355d63fdb69Smrg	  fi
9356d63fdb69Smrg	  $RM $output
9357d63fdb69Smrg	  # place dlname in correct position for cygwin
935855acc8fcSmrg	  # In fact, it would be nice if we could use this code for all target
935955acc8fcSmrg	  # systems that can't hard-code library paths into their executables
936055acc8fcSmrg	  # and that have no shared library path variable independent of PATH,
936155acc8fcSmrg	  # but it turns out we can't easily determine that from inspecting
936255acc8fcSmrg	  # libtool variables, so we have to hard-code the OSs to which it
936355acc8fcSmrg	  # applies here; at the moment, that means platforms that use the PE
936455acc8fcSmrg	  # object format with DLL files.  See the long comment at the top of
936555acc8fcSmrg	  # tests/bindir.at for full details.
9366d63fdb69Smrg	  tdlname=$dlname
9367d63fdb69Smrg	  case $host,$output,$installed,$module,$dlname in
936855acc8fcSmrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
936955acc8fcSmrg	      # If a -bindir argument was supplied, place the dll there.
937055acc8fcSmrg	      if test "x$bindir" != x ;
937155acc8fcSmrg	      then
937255acc8fcSmrg		func_relative_path "$install_libdir" "$bindir"
937355acc8fcSmrg		tdlname=$func_relative_path_result$dlname
937455acc8fcSmrg	      else
937555acc8fcSmrg		# Otherwise fall back on heuristic.
937655acc8fcSmrg		tdlname=../bin/$dlname
937755acc8fcSmrg	      fi
937855acc8fcSmrg	      ;;
9379d63fdb69Smrg	  esac
9380d63fdb69Smrg	  $ECHO > $output "\
9381d63fdb69Smrg# $outputname - a libtool library file
9382d63fdb69Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
9383d63fdb69Smrg#
9384d63fdb69Smrg# Please DO NOT delete this file!
9385d63fdb69Smrg# It is necessary for linking the library.
93863da084b3Smrg
9387d63fdb69Smrg# The name that we can dlopen(3).
9388d63fdb69Smrgdlname='$tdlname'
93893da084b3Smrg
9390d63fdb69Smrg# Names of this library.
9391d63fdb69Smrglibrary_names='$library_names'
93923da084b3Smrg
9393d63fdb69Smrg# The name of the static archive.
9394d63fdb69Smrgold_library='$old_library'
93953da084b3Smrg
9396d63fdb69Smrg# Linker flags that can not go in dependency_libs.
9397d63fdb69Smrginherited_linker_flags='$new_inherited_linker_flags'
93983da084b3Smrg
9399d63fdb69Smrg# Libraries that this one depends upon.
9400d63fdb69Smrgdependency_libs='$dependency_libs'
94013da084b3Smrg
9402d63fdb69Smrg# Names of additional weak libraries provided by this library
9403d63fdb69Smrgweak_library_names='$weak_libs'
94043da084b3Smrg
9405d63fdb69Smrg# Version information for $libname.
9406d63fdb69Smrgcurrent=$current
9407d63fdb69Smrgage=$age
9408d63fdb69Smrgrevision=$revision
94093da084b3Smrg
9410d63fdb69Smrg# Is this an already installed library?
9411d63fdb69Smrginstalled=$installed
94123da084b3Smrg
9413d63fdb69Smrg# Should we warn about portability when linking against -modules?
9414d63fdb69Smrgshouldnotlink=$module
94153da084b3Smrg
9416d63fdb69Smrg# Files to dlopen/dlpreopen
9417d63fdb69Smrgdlopen='$dlfiles'
9418d63fdb69Smrgdlpreopen='$dlprefiles'
94193da084b3Smrg
9420d63fdb69Smrg# Directory that this library needs to be installed in:
9421d63fdb69Smrglibdir='$install_libdir'"
9422d63fdb69Smrg	  if test "$installed" = no && test "$need_relink" = yes; then
9423d63fdb69Smrg	    $ECHO >> $output "\
9424d63fdb69Smrgrelink_command=\"$relink_command\""
9425d63fdb69Smrg	  fi
9426d63fdb69Smrg	done
9427d63fdb69Smrg      }
94283da084b3Smrg
9429d63fdb69Smrg      # Do a symbolic link so that the libtool archive can be found in
9430d63fdb69Smrg      # LD_LIBRARY_PATH before the program is installed.
9431d63fdb69Smrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
9432d63fdb69Smrg      ;;
9433d63fdb69Smrg    esac
9434d63fdb69Smrg    exit $EXIT_SUCCESS
9435d63fdb69Smrg}
94363da084b3Smrg
943748c85eb7Smrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
9438d63fdb69Smrg    func_mode_link ${1+"$@"}
94393da084b3Smrg
94403da084b3Smrg
9441d63fdb69Smrg# func_mode_uninstall arg...
9442d63fdb69Smrgfunc_mode_uninstall ()
9443d63fdb69Smrg{
9444d63fdb69Smrg    $opt_debug
9445d63fdb69Smrg    RM="$nonopt"
94463da084b3Smrg    files=
94473da084b3Smrg    rmforce=
94483da084b3Smrg    exit_status=0
94493da084b3Smrg
94503da084b3Smrg    # This variable tells wrapper scripts just to set variables rather
94513da084b3Smrg    # than running their programs.
94523da084b3Smrg    libtool_install_magic="$magic"
94533da084b3Smrg
94543da084b3Smrg    for arg
94553da084b3Smrg    do
94563da084b3Smrg      case $arg in
945748c85eb7Smrg      -f) func_append RM " $arg"; rmforce=yes ;;
945848c85eb7Smrg      -*) func_append RM " $arg" ;;
945948c85eb7Smrg      *) func_append files " $arg" ;;
94603da084b3Smrg      esac
94613da084b3Smrg    done
94623da084b3Smrg
9463d63fdb69Smrg    test -z "$RM" && \
9464d63fdb69Smrg      func_fatal_help "you must specify an RM program"
94653da084b3Smrg
94663da084b3Smrg    rmdirs=
94673da084b3Smrg
94683da084b3Smrg    for file in $files; do
9469d63fdb69Smrg      func_dirname "$file" "" "."
9470d63fdb69Smrg      dir="$func_dirname_result"
9471d63fdb69Smrg      if test "X$dir" = X.; then
947248c85eb7Smrg	odir="$objdir"
94733da084b3Smrg      else
947448c85eb7Smrg	odir="$dir/$objdir"
94753da084b3Smrg      fi
9476d63fdb69Smrg      func_basename "$file"
9477d63fdb69Smrg      name="$func_basename_result"
947848c85eb7Smrg      test "$opt_mode" = uninstall && odir="$dir"
94793da084b3Smrg
948048c85eb7Smrg      # Remember odir for removal later, being careful to avoid duplicates
948148c85eb7Smrg      if test "$opt_mode" = clean; then
94823da084b3Smrg	case " $rmdirs " in
948348c85eb7Smrg	  *" $odir "*) ;;
948448c85eb7Smrg	  *) func_append rmdirs " $odir" ;;
94853da084b3Smrg	esac
94863da084b3Smrg      fi
94873da084b3Smrg
94883da084b3Smrg      # Don't error if the file doesn't exist and rm -f was used.
9489d63fdb69Smrg      if { test -L "$file"; } >/dev/null 2>&1 ||
9490d63fdb69Smrg	 { test -h "$file"; } >/dev/null 2>&1 ||
9491d63fdb69Smrg	 test -f "$file"; then
94923da084b3Smrg	:
94933da084b3Smrg      elif test -d "$file"; then
94943da084b3Smrg	exit_status=1
94953da084b3Smrg	continue
94963da084b3Smrg      elif test "$rmforce" = yes; then
94973da084b3Smrg	continue
94983da084b3Smrg      fi
94993da084b3Smrg
95003da084b3Smrg      rmfiles="$file"
95013da084b3Smrg
95023da084b3Smrg      case $name in
95033da084b3Smrg      *.la)
95043da084b3Smrg	# Possibly a libtool archive, so verify it.
9505d63fdb69Smrg	if func_lalib_p "$file"; then
9506d63fdb69Smrg	  func_source $dir/$name
95073da084b3Smrg
95083da084b3Smrg	  # Delete the libtool libraries and symlinks.
95093da084b3Smrg	  for n in $library_names; do
951048c85eb7Smrg	    func_append rmfiles " $odir/$n"
95113da084b3Smrg	  done
951248c85eb7Smrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
95133da084b3Smrg
951448c85eb7Smrg	  case "$opt_mode" in
95153da084b3Smrg	  clean)
951648c85eb7Smrg	    case " $library_names " in
95173da084b3Smrg	    *" $dlname "*) ;;
951848c85eb7Smrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
95193da084b3Smrg	    esac
952048c85eb7Smrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
95213da084b3Smrg	    ;;
95223da084b3Smrg	  uninstall)
95233da084b3Smrg	    if test -n "$library_names"; then
95243da084b3Smrg	      # Do each command in the postuninstall commands.
9525d63fdb69Smrg	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
95263da084b3Smrg	    fi
95273da084b3Smrg
95283da084b3Smrg	    if test -n "$old_library"; then
95293da084b3Smrg	      # Do each command in the old_postuninstall commands.
9530d63fdb69Smrg	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
95313da084b3Smrg	    fi
95323da084b3Smrg	    # FIXME: should reinstall the best remaining shared library.
95333da084b3Smrg	    ;;
95343da084b3Smrg	  esac
95353da084b3Smrg	fi
95363da084b3Smrg	;;
95373da084b3Smrg
95383da084b3Smrg      *.lo)
95393da084b3Smrg	# Possibly a libtool object, so verify it.
9540d63fdb69Smrg	if func_lalib_p "$file"; then
95413da084b3Smrg
95423da084b3Smrg	  # Read the .lo file
9543d63fdb69Smrg	  func_source $dir/$name
95443da084b3Smrg
95453da084b3Smrg	  # Add PIC object to the list of files to remove.
9546d63fdb69Smrg	  if test -n "$pic_object" &&
9547d63fdb69Smrg	     test "$pic_object" != none; then
954848c85eb7Smrg	    func_append rmfiles " $dir/$pic_object"
95493da084b3Smrg	  fi
95503da084b3Smrg
95513da084b3Smrg	  # Add non-PIC object to the list of files to remove.
9552d63fdb69Smrg	  if test -n "$non_pic_object" &&
9553d63fdb69Smrg	     test "$non_pic_object" != none; then
955448c85eb7Smrg	    func_append rmfiles " $dir/$non_pic_object"
95553da084b3Smrg	  fi
95563da084b3Smrg	fi
95573da084b3Smrg	;;
95583da084b3Smrg
95593da084b3Smrg      *)
956048c85eb7Smrg	if test "$opt_mode" = clean ; then
95613da084b3Smrg	  noexename=$name
95623da084b3Smrg	  case $file in
95633da084b3Smrg	  *.exe)
9564d63fdb69Smrg	    func_stripname '' '.exe' "$file"
9565d63fdb69Smrg	    file=$func_stripname_result
9566d63fdb69Smrg	    func_stripname '' '.exe' "$name"
9567d63fdb69Smrg	    noexename=$func_stripname_result
95683da084b3Smrg	    # $file with .exe has already been added to rmfiles,
95693da084b3Smrg	    # add $file without .exe
957048c85eb7Smrg	    func_append rmfiles " $file"
95713da084b3Smrg	    ;;
95723da084b3Smrg	  esac
95733da084b3Smrg	  # Do a test to see if this is a libtool program.
9574d63fdb69Smrg	  if func_ltwrapper_p "$file"; then
9575d63fdb69Smrg	    if func_ltwrapper_executable_p "$file"; then
9576d63fdb69Smrg	      func_ltwrapper_scriptname "$file"
9577d63fdb69Smrg	      relink_command=
9578d63fdb69Smrg	      func_source $func_ltwrapper_scriptname_result
957948c85eb7Smrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
9580d63fdb69Smrg	    else
9581d63fdb69Smrg	      relink_command=
9582d63fdb69Smrg	      func_source $dir/$noexename
9583d63fdb69Smrg	    fi
95843da084b3Smrg
95853da084b3Smrg	    # note $name still contains .exe if it was in $file originally
95863da084b3Smrg	    # as does the version of $file that was added into $rmfiles
958748c85eb7Smrg	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
95883da084b3Smrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
958948c85eb7Smrg	      func_append rmfiles " $odir/lt-$name"
95903da084b3Smrg	    fi
95913da084b3Smrg	    if test "X$noexename" != "X$name" ; then
959248c85eb7Smrg	      func_append rmfiles " $odir/lt-${noexename}.c"
95933da084b3Smrg	    fi
95943da084b3Smrg	  fi
95953da084b3Smrg	fi
95963da084b3Smrg	;;
95973da084b3Smrg      esac
9598d63fdb69Smrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
95993da084b3Smrg    done
96003da084b3Smrg
96013da084b3Smrg    # Try to remove the ${objdir}s in the directories where we deleted files
96023da084b3Smrg    for dir in $rmdirs; do
96033da084b3Smrg      if test -d "$dir"; then
9604d63fdb69Smrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
96053da084b3Smrg      fi
96063da084b3Smrg    done
96073da084b3Smrg
96083da084b3Smrg    exit $exit_status
9609d63fdb69Smrg}
96103da084b3Smrg
961148c85eb7Smrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
9612d63fdb69Smrg    func_mode_uninstall ${1+"$@"}
96133da084b3Smrg
961448c85eb7Smrgtest -z "$opt_mode" && {
9615d63fdb69Smrg  help="$generic_help"
9616d63fdb69Smrg  func_fatal_help "you must specify a MODE"
9617d63fdb69Smrg}
9618d63fdb69Smrg
9619d63fdb69Smrgtest -z "$exec_cmd" && \
962048c85eb7Smrg  func_fatal_help "invalid operation mode \`$opt_mode'"
96213da084b3Smrg
96223da084b3Smrgif test -n "$exec_cmd"; then
9623d63fdb69Smrg  eval exec "$exec_cmd"
96243da084b3Smrg  exit $EXIT_FAILURE
96253da084b3Smrgfi
96263da084b3Smrg
9627d63fdb69Smrgexit $exit_status
96283da084b3Smrg
96293da084b3Smrg
96303da084b3Smrg# The TAGs below are defined such that we never get into a situation
96313da084b3Smrg# in which we disable both kinds of libraries.  Given conflicting
96323da084b3Smrg# choices, we go for a static library, that is the most portable,
96333da084b3Smrg# since we can't tell whether shared libraries were disabled because
96343da084b3Smrg# the user asked for that or because the platform doesn't support
96353da084b3Smrg# them.  This is particularly important on AIX, because we don't
96363da084b3Smrg# support having both static and shared libraries enabled at the same
96373da084b3Smrg# time on that platform, so we default to a shared-only configuration.
96383da084b3Smrg# If a disable-shared tag is given, we'll fallback to a static-only
96393da084b3Smrg# configuration.  But we'll never go from static-only to shared-only.
96403da084b3Smrg
96413da084b3Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
9642d63fdb69Smrgbuild_libtool_libs=no
9643d63fdb69Smrgbuild_old_libs=yes
96443da084b3Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
96453da084b3Smrg
96463da084b3Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
9647d63fdb69Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
96483da084b3Smrg# ### END LIBTOOL TAG CONFIG: disable-static
96493da084b3Smrg
96503da084b3Smrg# Local Variables:
96513da084b3Smrg# mode:shell-script
96523da084b3Smrg# sh-indentation:2
96533da084b3Smrg# End:
9654d63fdb69Smrg# vi:sw=2
9655d63fdb69Smrg
9656