ltmain.sh revision 9ef0b394
1698f425bSmrg
29ef0b394Smrg# libtool (GNU libtool) 2.4
3698f425bSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
4698f425bSmrg
59ef0b394Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
69ef0b394Smrg# 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
7698f425bSmrg# This is free software; see the source for copying conditions.  There is NO
8698f425bSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9698f425bSmrg
10698f425bSmrg# GNU Libtool is free software; you can redistribute it and/or modify
11266e564dSmrg# it under the terms of the GNU General Public License as published by
12266e564dSmrg# the Free Software Foundation; either version 2 of the License, or
13266e564dSmrg# (at your option) any later version.
14266e564dSmrg#
15698f425bSmrg# As a special exception to the GNU General Public License,
16698f425bSmrg# if you distribute this file as part of a program or library that
17698f425bSmrg# is built using GNU Libtool, you may include this file under the
18698f425bSmrg# same distribution terms that you use for the rest of that program.
19698f425bSmrg#
20698f425bSmrg# GNU Libtool is distributed in the hope that it will be useful, but
21266e564dSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
22266e564dSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23266e564dSmrg# General Public License for more details.
24266e564dSmrg#
25266e564dSmrg# You should have received a copy of the GNU General Public License
26698f425bSmrg# along with GNU Libtool; see the file COPYING.  If not, a copy
27698f425bSmrg# can be downloaded from http://www.gnu.org/licenses/gpl.html,
28698f425bSmrg# or obtained by writing to the Free Software Foundation, Inc.,
29698f425bSmrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30c5629e66Smrg
31698f425bSmrg# Usage: $progname [OPTION]... [MODE-ARG]...
32698f425bSmrg#
33698f425bSmrg# Provide generalized library-building support services.
34698f425bSmrg#
359ef0b394Smrg#       --config             show all configuration variables
369ef0b394Smrg#       --debug              enable verbose shell tracing
379ef0b394Smrg#   -n, --dry-run            display commands without modifying any files
389ef0b394Smrg#       --features           display basic configuration information and exit
399ef0b394Smrg#       --mode=MODE          use operation mode MODE
409ef0b394Smrg#       --preserve-dup-deps  don't remove duplicate dependency libraries
419ef0b394Smrg#       --quiet, --silent    don't print informational messages
429ef0b394Smrg#       --no-quiet, --no-silent
439ef0b394Smrg#                            print informational messages (default)
449ef0b394Smrg#       --tag=TAG            use configuration variables from tag TAG
459ef0b394Smrg#   -v, --verbose            print more informational messages than default
469ef0b394Smrg#       --no-verbose         don't print the extra informational messages
479ef0b394Smrg#       --version            print version information
489ef0b394Smrg#   -h, --help, --help-all   print short, long, or detailed help message
49698f425bSmrg#
50698f425bSmrg# MODE must be one of the following:
51698f425bSmrg#
529ef0b394Smrg#         clean              remove files from the build directory
539ef0b394Smrg#         compile            compile a source file into a libtool object
549ef0b394Smrg#         execute            automatically set library path, then run a program
559ef0b394Smrg#         finish             complete the installation of libtool libraries
569ef0b394Smrg#         install            install libraries or executables
579ef0b394Smrg#         link               create a library or an executable
589ef0b394Smrg#         uninstall          remove libraries from an installed directory
59698f425bSmrg#
609ef0b394Smrg# MODE-ARGS vary depending on the MODE.  When passed as first option,
619ef0b394Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
62698f425bSmrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
63698f425bSmrg#
64698f425bSmrg# When reporting a bug, please describe a test case to reproduce it and
65698f425bSmrg# include the following information:
66698f425bSmrg#
679ef0b394Smrg#         host-triplet:	$host
689ef0b394Smrg#         shell:		$SHELL
699ef0b394Smrg#         compiler:		$LTCC
709ef0b394Smrg#         compiler flags:		$LTCFLAGS
719ef0b394Smrg#         linker:		$LD (gnu? $with_gnu_ld)
729ef0b394Smrg#         $progname:	(GNU libtool) 2.4
739ef0b394Smrg#         automake:	$automake_version
749ef0b394Smrg#         autoconf:	$autoconf_version
75698f425bSmrg#
76698f425bSmrg# Report bugs to <bug-libtool@gnu.org>.
779ef0b394Smrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
789ef0b394Smrg# General help using GNU software: <http://www.gnu.org/gethelp/>.
79266e564dSmrg
809ef0b394SmrgPROGRAM=libtool
81266e564dSmrgPACKAGE=libtool
829ef0b394SmrgVERSION=2.4
83698f425bSmrgTIMESTAMP=""
849ef0b394Smrgpackage_revision=1.3293
85c5629e66Smrg
86698f425bSmrg# Be Bourne compatible
87c5629e66Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
88c5629e66Smrg  emulate sh
89c5629e66Smrg  NULLCMD=:
90c5629e66Smrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
91c5629e66Smrg  # is contrary to our usage.  Disable this feature.
92c5629e66Smrg  alias -g '${1+"$@"}'='"$@"'
93266e564dSmrg  setopt NO_GLOB_SUBST
94c5629e66Smrgelse
95c5629e66Smrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
96266e564dSmrgfi
97c5629e66SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
98c5629e66SmrgDUALCASE=1; export DUALCASE # for MKS sh
99266e564dSmrg
1009ef0b394Smrg# A function that is used when there is no print builtin or printf.
1019ef0b394Smrgfunc_fallback_echo ()
1029ef0b394Smrg{
1039ef0b394Smrg  eval 'cat <<_LTECHO_EOF
1049ef0b394Smrg$1
1059ef0b394Smrg_LTECHO_EOF'
1069ef0b394Smrg}
1079ef0b394Smrg
108698f425bSmrg# NLS nuisances: We save the old values to restore during execute mode.
109698f425bSmrglt_user_locale=
110698f425bSmrglt_safe_locale=
111c5629e66Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
112c5629e66Smrgdo
113c5629e66Smrg  eval "if test \"\${$lt_var+set}\" = set; then
114698f425bSmrg          save_$lt_var=\$$lt_var
115698f425bSmrg          $lt_var=C
116c5629e66Smrg	  export $lt_var
117698f425bSmrg	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
118698f425bSmrg	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
119c5629e66Smrg	fi"
120c5629e66Smrgdone
1219ef0b394SmrgLC_ALL=C
1229ef0b394SmrgLANGUAGE=C
1239ef0b394Smrgexport LANGUAGE LC_ALL
124c5629e66Smrg
125698f425bSmrg$lt_unset CDPATH
126698f425bSmrg
127698f425bSmrg
1289ef0b394Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
1299ef0b394Smrg# is ksh but when the shell is invoked as "sh" and the current value of
1309ef0b394Smrg# the _XPG environment variable is not equal to 1 (one), the special
1319ef0b394Smrg# positional parameter $0, within a function call, is the name of the
1329ef0b394Smrg# function.
1339ef0b394Smrgprogpath="$0"
134698f425bSmrg
135698f425bSmrg
136698f425bSmrg
137698f425bSmrg: ${CP="cp -f"}
1389ef0b394Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
1399ef0b394Smrg: ${EGREP="grep -E"}
1409ef0b394Smrg: ${FGREP="grep -F"}
1419ef0b394Smrg: ${GREP="grep"}
142698f425bSmrg: ${LN_S="ln -s"}
143698f425bSmrg: ${MAKE="make"}
144698f425bSmrg: ${MKDIR="mkdir"}
145698f425bSmrg: ${MV="mv -f"}
146698f425bSmrg: ${RM="rm -f"}
1479ef0b394Smrg: ${SED="sed"}
148698f425bSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
149698f425bSmrg: ${Xsed="$SED -e 1s/^X//"}
150698f425bSmrg
151698f425bSmrg# Global variables:
152698f425bSmrgEXIT_SUCCESS=0
153698f425bSmrgEXIT_FAILURE=1
154698f425bSmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
155698f425bSmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
156698f425bSmrg
157698f425bSmrgexit_status=$EXIT_SUCCESS
158266e564dSmrg
159266e564dSmrg# Make sure IFS has a sensible default
160266e564dSmrglt_nl='
161266e564dSmrg'
162266e564dSmrgIFS=" 	$lt_nl"
163266e564dSmrg
164698f425bSmrgdirname="s,/[^/]*$,,"
165698f425bSmrgbasename="s,^.*/,,"
166698f425bSmrg
1679ef0b394Smrg# func_dirname file append nondir_replacement
1689ef0b394Smrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
1699ef0b394Smrg# otherwise set result to NONDIR_REPLACEMENT.
1709ef0b394Smrgfunc_dirname ()
1719ef0b394Smrg{
1729ef0b394Smrg    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
1739ef0b394Smrg    if test "X$func_dirname_result" = "X${1}"; then
1749ef0b394Smrg      func_dirname_result="${3}"
1759ef0b394Smrg    else
1769ef0b394Smrg      func_dirname_result="$func_dirname_result${2}"
1779ef0b394Smrg    fi
1789ef0b394Smrg} # func_dirname may be replaced by extended shell implementation
1799ef0b394Smrg
1809ef0b394Smrg
1819ef0b394Smrg# func_basename file
1829ef0b394Smrgfunc_basename ()
1839ef0b394Smrg{
1849ef0b394Smrg    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
1859ef0b394Smrg} # func_basename may be replaced by extended shell implementation
1869ef0b394Smrg
1879ef0b394Smrg
188698f425bSmrg# func_dirname_and_basename file append nondir_replacement
189698f425bSmrg# perform func_basename and func_dirname in a single function
190698f425bSmrg# call:
191698f425bSmrg#   dirname:  Compute the dirname of FILE.  If nonempty,
192698f425bSmrg#             add APPEND to the result, otherwise set result
193698f425bSmrg#             to NONDIR_REPLACEMENT.
194698f425bSmrg#             value returned in "$func_dirname_result"
195698f425bSmrg#   basename: Compute filename of FILE.
196698f425bSmrg#             value retuned in "$func_basename_result"
197698f425bSmrg# Implementation must be kept synchronized with func_dirname
198698f425bSmrg# and func_basename. For efficiency, we do not delegate to
199698f425bSmrg# those functions but instead duplicate the functionality here.
200698f425bSmrgfunc_dirname_and_basename ()
201698f425bSmrg{
2029ef0b394Smrg    # Extract subdirectory from the argument.
2039ef0b394Smrg    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
2049ef0b394Smrg    if test "X$func_dirname_result" = "X${1}"; then
2059ef0b394Smrg      func_dirname_result="${3}"
2069ef0b394Smrg    else
2079ef0b394Smrg      func_dirname_result="$func_dirname_result${2}"
2089ef0b394Smrg    fi
2099ef0b394Smrg    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
2109ef0b394Smrg} # func_dirname_and_basename may be replaced by extended shell implementation
2119ef0b394Smrg
2129ef0b394Smrg
2139ef0b394Smrg# func_stripname prefix suffix name
2149ef0b394Smrg# strip PREFIX and SUFFIX off of NAME.
2159ef0b394Smrg# PREFIX and SUFFIX must not contain globbing or regex special
2169ef0b394Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading
2179ef0b394Smrg# dot (in which case that matches only a dot).
2189ef0b394Smrg# func_strip_suffix prefix name
2199ef0b394Smrgfunc_stripname ()
2209ef0b394Smrg{
2219ef0b394Smrg    case ${2} in
2229ef0b394Smrg      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
2239ef0b394Smrg      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
2249ef0b394Smrg    esac
2259ef0b394Smrg} # func_stripname may be replaced by extended shell implementation
2269ef0b394Smrg
2279ef0b394Smrg
2289ef0b394Smrg# These SED scripts presuppose an absolute path with a trailing slash.
2299ef0b394Smrgpathcar='s,^/\([^/]*\).*$,\1,'
2309ef0b394Smrgpathcdr='s,^/[^/]*,,'
2319ef0b394Smrgremovedotparts=':dotsl
2329ef0b394Smrg		s@/\./@/@g
2339ef0b394Smrg		t dotsl
2349ef0b394Smrg		s,/\.$,/,'
2359ef0b394Smrgcollapseslashes='s@/\{1,\}@/@g'
2369ef0b394Smrgfinalslash='s,/*$,/,'
2379ef0b394Smrg
2389ef0b394Smrg# func_normal_abspath PATH
2399ef0b394Smrg# Remove doubled-up and trailing slashes, "." path components,
2409ef0b394Smrg# and cancel out any ".." path components in PATH after making
2419ef0b394Smrg# it an absolute path.
2429ef0b394Smrg#             value returned in "$func_normal_abspath_result"
2439ef0b394Smrgfunc_normal_abspath ()
2449ef0b394Smrg{
2459ef0b394Smrg  # Start from root dir and reassemble the path.
2469ef0b394Smrg  func_normal_abspath_result=
2479ef0b394Smrg  func_normal_abspath_tpath=$1
2489ef0b394Smrg  func_normal_abspath_altnamespace=
2499ef0b394Smrg  case $func_normal_abspath_tpath in
2509ef0b394Smrg    "")
2519ef0b394Smrg      # Empty path, that just means $cwd.
2529ef0b394Smrg      func_stripname '' '/' "`pwd`"
2539ef0b394Smrg      func_normal_abspath_result=$func_stripname_result
2549ef0b394Smrg      return
2559ef0b394Smrg    ;;
2569ef0b394Smrg    # The next three entries are used to spot a run of precisely
2579ef0b394Smrg    # two leading slashes without using negated character classes;
2589ef0b394Smrg    # we take advantage of case's first-match behaviour.
2599ef0b394Smrg    ///*)
2609ef0b394Smrg      # Unusual form of absolute path, do nothing.
2619ef0b394Smrg    ;;
2629ef0b394Smrg    //*)
2639ef0b394Smrg      # Not necessarily an ordinary path; POSIX reserves leading '//'
2649ef0b394Smrg      # and for example Cygwin uses it to access remote file shares
2659ef0b394Smrg      # over CIFS/SMB, so we conserve a leading double slash if found.
2669ef0b394Smrg      func_normal_abspath_altnamespace=/
2679ef0b394Smrg    ;;
2689ef0b394Smrg    /*)
2699ef0b394Smrg      # Absolute path, do nothing.
2709ef0b394Smrg    ;;
2719ef0b394Smrg    *)
2729ef0b394Smrg      # Relative path, prepend $cwd.
2739ef0b394Smrg      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
2749ef0b394Smrg    ;;
2759ef0b394Smrg  esac
2769ef0b394Smrg  # Cancel out all the simple stuff to save iterations.  We also want
2779ef0b394Smrg  # the path to end with a slash for ease of parsing, so make sure
2789ef0b394Smrg  # there is one (and only one) here.
2799ef0b394Smrg  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
2809ef0b394Smrg        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
2819ef0b394Smrg  while :; do
2829ef0b394Smrg    # Processed it all yet?
2839ef0b394Smrg    if test "$func_normal_abspath_tpath" = / ; then
2849ef0b394Smrg      # If we ascended to the root using ".." the result may be empty now.
2859ef0b394Smrg      if test -z "$func_normal_abspath_result" ; then
2869ef0b394Smrg        func_normal_abspath_result=/
2879ef0b394Smrg      fi
2889ef0b394Smrg      break
2899ef0b394Smrg    fi
2909ef0b394Smrg    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
2919ef0b394Smrg        -e "$pathcar"`
2929ef0b394Smrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
2939ef0b394Smrg        -e "$pathcdr"`
2949ef0b394Smrg    # Figure out what to do with it
2959ef0b394Smrg    case $func_normal_abspath_tcomponent in
2969ef0b394Smrg      "")
2979ef0b394Smrg        # Trailing empty path component, ignore it.
2989ef0b394Smrg      ;;
2999ef0b394Smrg      ..)
3009ef0b394Smrg        # Parent dir; strip last assembled component from result.
3019ef0b394Smrg        func_dirname "$func_normal_abspath_result"
3029ef0b394Smrg        func_normal_abspath_result=$func_dirname_result
3039ef0b394Smrg      ;;
3049ef0b394Smrg      *)
3059ef0b394Smrg        # Actual path component, append it.
3069ef0b394Smrg        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
3079ef0b394Smrg      ;;
3089ef0b394Smrg    esac
3099ef0b394Smrg  done
3109ef0b394Smrg  # Restore leading double-slash if one was found on entry.
3119ef0b394Smrg  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
312698f425bSmrg}
313266e564dSmrg
3149ef0b394Smrg# func_relative_path SRCDIR DSTDIR
3159ef0b394Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing
3169ef0b394Smrg# slash if non-empty, suitable for immediately appending a filename
3179ef0b394Smrg# without needing to append a separator.
3189ef0b394Smrg#             value returned in "$func_relative_path_result"
3199ef0b394Smrgfunc_relative_path ()
3209ef0b394Smrg{
3219ef0b394Smrg  func_relative_path_result=
3229ef0b394Smrg  func_normal_abspath "$1"
3239ef0b394Smrg  func_relative_path_tlibdir=$func_normal_abspath_result
3249ef0b394Smrg  func_normal_abspath "$2"
3259ef0b394Smrg  func_relative_path_tbindir=$func_normal_abspath_result
3269ef0b394Smrg
3279ef0b394Smrg  # Ascend the tree starting from libdir
3289ef0b394Smrg  while :; do
3299ef0b394Smrg    # check if we have found a prefix of bindir
3309ef0b394Smrg    case $func_relative_path_tbindir in
3319ef0b394Smrg      $func_relative_path_tlibdir)
3329ef0b394Smrg        # found an exact match
3339ef0b394Smrg        func_relative_path_tcancelled=
3349ef0b394Smrg        break
3359ef0b394Smrg        ;;
3369ef0b394Smrg      $func_relative_path_tlibdir*)
3379ef0b394Smrg        # found a matching prefix
3389ef0b394Smrg        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
3399ef0b394Smrg        func_relative_path_tcancelled=$func_stripname_result
3409ef0b394Smrg        if test -z "$func_relative_path_result"; then
3419ef0b394Smrg          func_relative_path_result=.
3429ef0b394Smrg        fi
3439ef0b394Smrg        break
3449ef0b394Smrg        ;;
3459ef0b394Smrg      *)
3469ef0b394Smrg        func_dirname $func_relative_path_tlibdir
3479ef0b394Smrg        func_relative_path_tlibdir=${func_dirname_result}
3489ef0b394Smrg        if test "x$func_relative_path_tlibdir" = x ; then
3499ef0b394Smrg          # Have to descend all the way to the root!
3509ef0b394Smrg          func_relative_path_result=../$func_relative_path_result
3519ef0b394Smrg          func_relative_path_tcancelled=$func_relative_path_tbindir
3529ef0b394Smrg          break
3539ef0b394Smrg        fi
3549ef0b394Smrg        func_relative_path_result=../$func_relative_path_result
3559ef0b394Smrg        ;;
3569ef0b394Smrg    esac
3579ef0b394Smrg  done
358698f425bSmrg
3599ef0b394Smrg  # Now calculate path; take care to avoid doubling-up slashes.
3609ef0b394Smrg  func_stripname '' '/' "$func_relative_path_result"
3619ef0b394Smrg  func_relative_path_result=$func_stripname_result
3629ef0b394Smrg  func_stripname '/' '/' "$func_relative_path_tcancelled"
3639ef0b394Smrg  if test "x$func_stripname_result" != x ; then
3649ef0b394Smrg    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
3659ef0b394Smrg  fi
3669ef0b394Smrg
3679ef0b394Smrg  # Normalisation. If bindir is libdir, return empty string,
3689ef0b394Smrg  # else relative path ending with a slash; either way, target
3699ef0b394Smrg  # file name can be directly appended.
3709ef0b394Smrg  if test ! -z "$func_relative_path_result"; then
3719ef0b394Smrg    func_stripname './' '' "$func_relative_path_result/"
3729ef0b394Smrg    func_relative_path_result=$func_stripname_result
3739ef0b394Smrg  fi
3749ef0b394Smrg}
375698f425bSmrg
376698f425bSmrg# The name of this program:
377698f425bSmrgfunc_dirname_and_basename "$progpath"
378698f425bSmrgprogname=$func_basename_result
379698f425bSmrg
380698f425bSmrg# Make sure we have an absolute path for reexecution:
381698f425bSmrgcase $progpath in
382698f425bSmrg  [\\/]*|[A-Za-z]:\\*) ;;
383698f425bSmrg  *[\\/]*)
384698f425bSmrg     progdir=$func_dirname_result
385698f425bSmrg     progdir=`cd "$progdir" && pwd`
386698f425bSmrg     progpath="$progdir/$progname"
387698f425bSmrg     ;;
388698f425bSmrg  *)
389698f425bSmrg     save_IFS="$IFS"
390698f425bSmrg     IFS=:
391698f425bSmrg     for progdir in $PATH; do
392698f425bSmrg       IFS="$save_IFS"
393698f425bSmrg       test -x "$progdir/$progname" && break
394698f425bSmrg     done
395698f425bSmrg     IFS="$save_IFS"
396698f425bSmrg     test -n "$progdir" || progdir=`pwd`
397698f425bSmrg     progpath="$progdir/$progname"
398698f425bSmrg     ;;
399698f425bSmrgesac
400698f425bSmrg
401698f425bSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
402698f425bSmrg# metacharacters that are still active within double-quoted strings.
403698f425bSmrgXsed="${SED}"' -e 1s/^X//'
404698f425bSmrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
405698f425bSmrg
406698f425bSmrg# Same as above, but do not quote variable references.
407698f425bSmrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
408698f425bSmrg
4099ef0b394Smrg# Sed substitution that turns a string into a regex matching for the
4109ef0b394Smrg# string literally.
4119ef0b394Smrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
4129ef0b394Smrg
4139ef0b394Smrg# Sed substitution that converts a w32 file name or path
4149ef0b394Smrg# which contains forward slashes, into one that contains
4159ef0b394Smrg# (escaped) backslashes.  A very naive implementation.
4169ef0b394Smrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
4179ef0b394Smrg
418698f425bSmrg# Re-`\' parameter expansions in output of double_quote_subst that were
419698f425bSmrg# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
420698f425bSmrg# in input to double_quote_subst, that '$' was protected from expansion.
421698f425bSmrg# Since each input `\' is now two `\'s, look for any number of runs of
422698f425bSmrg# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
423698f425bSmrgbs='\\'
424698f425bSmrgbs2='\\\\'
425698f425bSmrgbs4='\\\\\\\\'
426698f425bSmrgdollar='\$'
427698f425bSmrgsed_double_backslash="\
428698f425bSmrg  s/$bs4/&\\
429698f425bSmrg/g
430698f425bSmrg  s/^$bs2$dollar/$bs&/
431698f425bSmrg  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
432698f425bSmrg  s/\n//g"
433698f425bSmrg
434698f425bSmrg# Standard options:
435698f425bSmrgopt_dry_run=false
436698f425bSmrgopt_help=false
437698f425bSmrgopt_quiet=false
438698f425bSmrgopt_verbose=false
439698f425bSmrgopt_warning=:
440698f425bSmrg
441698f425bSmrg# func_echo arg...
442698f425bSmrg# Echo program name prefixed message, along with the current mode
443698f425bSmrg# name if it has been set yet.
444698f425bSmrgfunc_echo ()
445698f425bSmrg{
4469ef0b394Smrg    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
447698f425bSmrg}
448698f425bSmrg
449698f425bSmrg# func_verbose arg...
450698f425bSmrg# Echo program name prefixed message in verbose mode only.
451698f425bSmrgfunc_verbose ()
452698f425bSmrg{
453698f425bSmrg    $opt_verbose && func_echo ${1+"$@"}
454698f425bSmrg
455698f425bSmrg    # A bug in bash halts the script if the last line of a function
456698f425bSmrg    # fails when set -e is in force, so we need another command to
457698f425bSmrg    # work around that:
458698f425bSmrg    :
459698f425bSmrg}
460698f425bSmrg
4619ef0b394Smrg# func_echo_all arg...
4629ef0b394Smrg# Invoke $ECHO with all args, space-separated.
4639ef0b394Smrgfunc_echo_all ()
4649ef0b394Smrg{
4659ef0b394Smrg    $ECHO "$*"
4669ef0b394Smrg}
4679ef0b394Smrg
468698f425bSmrg# func_error arg...
469698f425bSmrg# Echo program name prefixed message to standard error.
470698f425bSmrgfunc_error ()
471698f425bSmrg{
4729ef0b394Smrg    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
473698f425bSmrg}
474698f425bSmrg
475698f425bSmrg# func_warning arg...
476698f425bSmrg# Echo program name prefixed warning message to standard error.
477698f425bSmrgfunc_warning ()
478698f425bSmrg{
4799ef0b394Smrg    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
480698f425bSmrg
481698f425bSmrg    # bash bug again:
482698f425bSmrg    :
483698f425bSmrg}
484698f425bSmrg
485698f425bSmrg# func_fatal_error arg...
486698f425bSmrg# Echo program name prefixed message to standard error, and exit.
487698f425bSmrgfunc_fatal_error ()
488698f425bSmrg{
489698f425bSmrg    func_error ${1+"$@"}
490698f425bSmrg    exit $EXIT_FAILURE
491698f425bSmrg}
492698f425bSmrg
493698f425bSmrg# func_fatal_help arg...
494698f425bSmrg# Echo program name prefixed message to standard error, followed by
495698f425bSmrg# a help hint, and exit.
496698f425bSmrgfunc_fatal_help ()
497698f425bSmrg{
498698f425bSmrg    func_error ${1+"$@"}
499698f425bSmrg    func_fatal_error "$help"
500698f425bSmrg}
501698f425bSmrghelp="Try \`$progname --help' for more information."  ## default
502698f425bSmrg
503698f425bSmrg
504698f425bSmrg# func_grep expression filename
505698f425bSmrg# Check whether EXPRESSION matches any line of FILENAME, without output.
506698f425bSmrgfunc_grep ()
507698f425bSmrg{
508698f425bSmrg    $GREP "$1" "$2" >/dev/null 2>&1
509698f425bSmrg}
510698f425bSmrg
511698f425bSmrg
512698f425bSmrg# func_mkdir_p directory-path
513698f425bSmrg# Make sure the entire path to DIRECTORY-PATH is available.
514698f425bSmrgfunc_mkdir_p ()
515698f425bSmrg{
516698f425bSmrg    my_directory_path="$1"
517698f425bSmrg    my_dir_list=
518698f425bSmrg
519698f425bSmrg    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
520698f425bSmrg
521698f425bSmrg      # Protect directory names starting with `-'
522698f425bSmrg      case $my_directory_path in
523698f425bSmrg        -*) my_directory_path="./$my_directory_path" ;;
524698f425bSmrg      esac
525698f425bSmrg
526698f425bSmrg      # While some portion of DIR does not yet exist...
527698f425bSmrg      while test ! -d "$my_directory_path"; do
528698f425bSmrg        # ...make a list in topmost first order.  Use a colon delimited
529698f425bSmrg	# list incase some portion of path contains whitespace.
530698f425bSmrg        my_dir_list="$my_directory_path:$my_dir_list"
531698f425bSmrg
532698f425bSmrg        # If the last portion added has no slash in it, the list is done
533698f425bSmrg        case $my_directory_path in */*) ;; *) break ;; esac
534698f425bSmrg
535698f425bSmrg        # ...otherwise throw away the child directory and loop
5369ef0b394Smrg        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
537698f425bSmrg      done
5389ef0b394Smrg      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
539698f425bSmrg
540698f425bSmrg      save_mkdir_p_IFS="$IFS"; IFS=':'
541698f425bSmrg      for my_dir in $my_dir_list; do
542698f425bSmrg	IFS="$save_mkdir_p_IFS"
543698f425bSmrg        # mkdir can fail with a `File exist' error if two processes
544698f425bSmrg        # try to create one of the directories concurrently.  Don't
545698f425bSmrg        # stop in that case!
546698f425bSmrg        $MKDIR "$my_dir" 2>/dev/null || :
547698f425bSmrg      done
548698f425bSmrg      IFS="$save_mkdir_p_IFS"
549698f425bSmrg
550698f425bSmrg      # Bail out if we (or some other process) failed to create a directory.
551698f425bSmrg      test -d "$my_directory_path" || \
552698f425bSmrg        func_fatal_error "Failed to create \`$1'"
553698f425bSmrg    fi
554698f425bSmrg}
555266e564dSmrg
556266e564dSmrg
557266e564dSmrg# func_mktempdir [string]
558266e564dSmrg# Make a temporary directory that won't clash with other running
559266e564dSmrg# libtool processes, and avoids race conditions if possible.  If
560266e564dSmrg# given, STRING is the basename for that directory.
561266e564dSmrgfunc_mktempdir ()
562266e564dSmrg{
563266e564dSmrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
564266e564dSmrg
565698f425bSmrg    if test "$opt_dry_run" = ":"; then
566266e564dSmrg      # Return a directory name, but don't create it in dry-run mode
567266e564dSmrg      my_tmpdir="${my_template}-$$"
568266e564dSmrg    else
569266e564dSmrg
570266e564dSmrg      # If mktemp works, use that first and foremost
571266e564dSmrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
572266e564dSmrg
573266e564dSmrg      if test ! -d "$my_tmpdir"; then
574698f425bSmrg        # Failing that, at least try and use $RANDOM to avoid a race
575698f425bSmrg        my_tmpdir="${my_template}-${RANDOM-0}$$"
576266e564dSmrg
577698f425bSmrg        save_mktempdir_umask=`umask`
578698f425bSmrg        umask 0077
579698f425bSmrg        $MKDIR "$my_tmpdir"
580698f425bSmrg        umask $save_mktempdir_umask
581266e564dSmrg      fi
582266e564dSmrg
583266e564dSmrg      # If we're not in dry-run mode, bomb out on failure
584698f425bSmrg      test -d "$my_tmpdir" || \
585698f425bSmrg        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
586266e564dSmrg    fi
587266e564dSmrg
5889ef0b394Smrg    $ECHO "$my_tmpdir"
589266e564dSmrg}
590266e564dSmrg
591266e564dSmrg
592698f425bSmrg# func_quote_for_eval arg
593698f425bSmrg# Aesthetically quote ARG to be evaled later.
594698f425bSmrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
595698f425bSmrg# is double-quoted, suitable for a subsequent eval, whereas
596698f425bSmrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
597698f425bSmrg# which are still active within double quotes backslashified.
598698f425bSmrgfunc_quote_for_eval ()
599266e564dSmrg{
600698f425bSmrg    case $1 in
601698f425bSmrg      *[\\\`\"\$]*)
6029ef0b394Smrg	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
603698f425bSmrg      *)
604698f425bSmrg        func_quote_for_eval_unquoted_result="$1" ;;
605698f425bSmrg    esac
606698f425bSmrg
607698f425bSmrg    case $func_quote_for_eval_unquoted_result in
608698f425bSmrg      # Double-quote args containing shell metacharacters to delay
609698f425bSmrg      # word splitting, command substitution and and variable
610698f425bSmrg      # expansion for a subsequent eval.
611698f425bSmrg      # Many Bourne shells cannot handle close brackets correctly
612698f425bSmrg      # in scan sets, so we specify it separately.
613698f425bSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
614698f425bSmrg        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
615698f425bSmrg        ;;
616698f425bSmrg      *)
617698f425bSmrg        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
618266e564dSmrg    esac
619266e564dSmrg}
620266e564dSmrg
621266e564dSmrg
622698f425bSmrg# func_quote_for_expand arg
623698f425bSmrg# Aesthetically quote ARG to be evaled later; same as above,
624698f425bSmrg# but do not quote variable references.
625698f425bSmrgfunc_quote_for_expand ()
626266e564dSmrg{
627698f425bSmrg    case $1 in
628698f425bSmrg      *[\\\`\"]*)
6299ef0b394Smrg	my_arg=`$ECHO "$1" | $SED \
630698f425bSmrg	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
631266e564dSmrg      *)
632698f425bSmrg        my_arg="$1" ;;
633698f425bSmrg    esac
634698f425bSmrg
635698f425bSmrg    case $my_arg in
636698f425bSmrg      # Double-quote args containing shell metacharacters to delay
637698f425bSmrg      # word splitting and command substitution for a subsequent eval.
638698f425bSmrg      # Many Bourne shells cannot handle close brackets correctly
639698f425bSmrg      # in scan sets, so we specify it separately.
640698f425bSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
641698f425bSmrg        my_arg="\"$my_arg\""
642698f425bSmrg        ;;
643698f425bSmrg    esac
644698f425bSmrg
645698f425bSmrg    func_quote_for_expand_result="$my_arg"
646266e564dSmrg}
647266e564dSmrg
648266e564dSmrg
649698f425bSmrg# func_show_eval cmd [fail_exp]
650698f425bSmrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
651698f425bSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
652698f425bSmrg# is given, then evaluate it.
653698f425bSmrgfunc_show_eval ()
654266e564dSmrg{
655698f425bSmrg    my_cmd="$1"
656698f425bSmrg    my_fail_exp="${2-:}"
657266e564dSmrg
658698f425bSmrg    ${opt_silent-false} || {
659698f425bSmrg      func_quote_for_expand "$my_cmd"
660698f425bSmrg      eval "func_echo $func_quote_for_expand_result"
661698f425bSmrg    }
662698f425bSmrg
663698f425bSmrg    if ${opt_dry_run-false}; then :; else
664698f425bSmrg      eval "$my_cmd"
665698f425bSmrg      my_status=$?
666698f425bSmrg      if test "$my_status" -eq 0; then :; else
667698f425bSmrg	eval "(exit $my_status); $my_fail_exp"
668698f425bSmrg      fi
669266e564dSmrg    fi
670266e564dSmrg}
671266e564dSmrg
672698f425bSmrg
673698f425bSmrg# func_show_eval_locale cmd [fail_exp]
674698f425bSmrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
675698f425bSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
676698f425bSmrg# is given, then evaluate it.  Use the saved locale for evaluation.
677698f425bSmrgfunc_show_eval_locale ()
678266e564dSmrg{
679698f425bSmrg    my_cmd="$1"
680698f425bSmrg    my_fail_exp="${2-:}"
681698f425bSmrg
682698f425bSmrg    ${opt_silent-false} || {
683698f425bSmrg      func_quote_for_expand "$my_cmd"
684698f425bSmrg      eval "func_echo $func_quote_for_expand_result"
685698f425bSmrg    }
686698f425bSmrg
687698f425bSmrg    if ${opt_dry_run-false}; then :; else
688698f425bSmrg      eval "$lt_user_locale
689698f425bSmrg	    $my_cmd"
690698f425bSmrg      my_status=$?
691698f425bSmrg      eval "$lt_safe_locale"
692698f425bSmrg      if test "$my_status" -eq 0; then :; else
693698f425bSmrg	eval "(exit $my_status); $my_fail_exp"
694698f425bSmrg      fi
695266e564dSmrg    fi
696698f425bSmrg}
697266e564dSmrg
6989ef0b394Smrg# func_tr_sh
6999ef0b394Smrg# Turn $1 into a string suitable for a shell variable name.
7009ef0b394Smrg# Result is stored in $func_tr_sh_result.  All characters
7019ef0b394Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
7029ef0b394Smrg# if $1 begins with a digit, a '_' is prepended as well.
7039ef0b394Smrgfunc_tr_sh ()
7049ef0b394Smrg{
7059ef0b394Smrg  case $1 in
7069ef0b394Smrg  [0-9]* | *[!a-zA-Z0-9_]*)
7079ef0b394Smrg    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
7089ef0b394Smrg    ;;
7099ef0b394Smrg  * )
7109ef0b394Smrg    func_tr_sh_result=$1
7119ef0b394Smrg    ;;
7129ef0b394Smrg  esac
7139ef0b394Smrg}
714698f425bSmrg
715698f425bSmrg
716698f425bSmrg# func_version
717698f425bSmrg# Echo version message to standard output and exit.
718698f425bSmrgfunc_version ()
719698f425bSmrg{
7209ef0b394Smrg    $opt_debug
7219ef0b394Smrg
7229ef0b394Smrg    $SED -n '/(C)/!b go
7239ef0b394Smrg	:more
7249ef0b394Smrg	/\./!{
7259ef0b394Smrg	  N
7269ef0b394Smrg	  s/\n# / /
7279ef0b394Smrg	  b more
7289ef0b394Smrg	}
7299ef0b394Smrg	:go
7309ef0b394Smrg	/^# '$PROGRAM' (GNU /,/# warranty; / {
731698f425bSmrg        s/^# //
732698f425bSmrg	s/^# *$//
733698f425bSmrg        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
734698f425bSmrg        p
735698f425bSmrg     }' < "$progpath"
736698f425bSmrg     exit $?
737266e564dSmrg}
738266e564dSmrg
739698f425bSmrg# func_usage
740698f425bSmrg# Echo short help message to standard output and exit.
741698f425bSmrgfunc_usage ()
742698f425bSmrg{
7439ef0b394Smrg    $opt_debug
7449ef0b394Smrg
7459ef0b394Smrg    $SED -n '/^# Usage:/,/^#  *.*--help/ {
746698f425bSmrg        s/^# //
747698f425bSmrg	s/^# *$//
748698f425bSmrg	s/\$progname/'$progname'/
749698f425bSmrg	p
750698f425bSmrg    }' < "$progpath"
7519ef0b394Smrg    echo
752698f425bSmrg    $ECHO "run \`$progname --help | more' for full usage"
753698f425bSmrg    exit $?
754698f425bSmrg}
755266e564dSmrg
7569ef0b394Smrg# func_help [NOEXIT]
7579ef0b394Smrg# Echo long help message to standard output and exit,
7589ef0b394Smrg# unless 'noexit' is passed as argument.
759698f425bSmrgfunc_help ()
760698f425bSmrg{
7619ef0b394Smrg    $opt_debug
7629ef0b394Smrg
763698f425bSmrg    $SED -n '/^# Usage:/,/# Report bugs to/ {
7649ef0b394Smrg	:print
765698f425bSmrg        s/^# //
766698f425bSmrg	s/^# *$//
767698f425bSmrg	s*\$progname*'$progname'*
768698f425bSmrg	s*\$host*'"$host"'*
769698f425bSmrg	s*\$SHELL*'"$SHELL"'*
770698f425bSmrg	s*\$LTCC*'"$LTCC"'*
771698f425bSmrg	s*\$LTCFLAGS*'"$LTCFLAGS"'*
772698f425bSmrg	s*\$LD*'"$LD"'*
773698f425bSmrg	s/\$with_gnu_ld/'"$with_gnu_ld"'/
774698f425bSmrg	s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
775698f425bSmrg	s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
776698f425bSmrg	p
7779ef0b394Smrg	d
7789ef0b394Smrg     }
7799ef0b394Smrg     /^# .* home page:/b print
7809ef0b394Smrg     /^# General help using/b print
7819ef0b394Smrg     ' < "$progpath"
7829ef0b394Smrg    ret=$?
7839ef0b394Smrg    if test -z "$1"; then
7849ef0b394Smrg      exit $ret
7859ef0b394Smrg    fi
786698f425bSmrg}
787266e564dSmrg
788698f425bSmrg# func_missing_arg argname
789698f425bSmrg# Echo program name prefixed message to standard error and set global
790698f425bSmrg# exit_cmd.
791698f425bSmrgfunc_missing_arg ()
792698f425bSmrg{
7939ef0b394Smrg    $opt_debug
7949ef0b394Smrg
7959ef0b394Smrg    func_error "missing argument for $1."
796698f425bSmrg    exit_cmd=exit
797698f425bSmrg}
798698f425bSmrg
799698f425bSmrg
8009ef0b394Smrg# func_split_short_opt shortopt
8019ef0b394Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
8029ef0b394Smrg# variables after splitting SHORTOPT after the 2nd character.
8039ef0b394Smrgfunc_split_short_opt ()
8049ef0b394Smrg{
8059ef0b394Smrg    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
8069ef0b394Smrg    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
807698f425bSmrg
8089ef0b394Smrg    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
8099ef0b394Smrg    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
8109ef0b394Smrg} # func_split_short_opt may be replaced by extended shell implementation
8119ef0b394Smrg
8129ef0b394Smrg
8139ef0b394Smrg# func_split_long_opt longopt
8149ef0b394Smrg# Set func_split_long_opt_name and func_split_long_opt_arg shell
8159ef0b394Smrg# variables after splitting LONGOPT at the `=' sign.
8169ef0b394Smrgfunc_split_long_opt ()
8179ef0b394Smrg{
8189ef0b394Smrg    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
8199ef0b394Smrg    my_sed_long_arg='1s/^--[^=]*=//'
8209ef0b394Smrg
8219ef0b394Smrg    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
8229ef0b394Smrg    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
8239ef0b394Smrg} # func_split_long_opt may be replaced by extended shell implementation
8249ef0b394Smrg
8259ef0b394Smrgexit_cmd=:
826698f425bSmrg
827698f425bSmrg
828698f425bSmrg
829266e564dSmrg
830266e564dSmrg
831698f425bSmrgmagic="%%%MAGIC variable%%%"
832698f425bSmrgmagic_exe="%%%MAGIC EXE variable%%%"
833266e564dSmrg
834698f425bSmrg# Global variables.
835698f425bSmrgnonopt=
836698f425bSmrgpreserve_args=
837698f425bSmrglo2o="s/\\.lo\$/.${objext}/"
838698f425bSmrgo2lo="s/\\.${objext}\$/.lo/"
839698f425bSmrgextracted_archives=
840698f425bSmrgextracted_serial=0
841266e564dSmrg
842698f425bSmrg# If this variable is set in any of the actions, the command in it
843698f425bSmrg# will be execed at the end.  This prevents here-documents from being
844698f425bSmrg# left over by shells.
845698f425bSmrgexec_cmd=
846698f425bSmrg
8479ef0b394Smrg# func_append var value
8489ef0b394Smrg# Append VALUE to the end of shell variable VAR.
8499ef0b394Smrgfunc_append ()
8509ef0b394Smrg{
8519ef0b394Smrg    eval "${1}=\$${1}\${2}"
8529ef0b394Smrg} # func_append may be replaced by extended shell implementation
8539ef0b394Smrg
8549ef0b394Smrg# func_append_quoted var value
8559ef0b394Smrg# Quote VALUE and append to the end of shell variable VAR, separated
8569ef0b394Smrg# by a space.
8579ef0b394Smrgfunc_append_quoted ()
8589ef0b394Smrg{
8599ef0b394Smrg    func_quote_for_eval "${2}"
8609ef0b394Smrg    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
8619ef0b394Smrg} # func_append_quoted may be replaced by extended shell implementation
8629ef0b394Smrg
8639ef0b394Smrg
8649ef0b394Smrg# func_arith arithmetic-term...
8659ef0b394Smrgfunc_arith ()
8669ef0b394Smrg{
8679ef0b394Smrg    func_arith_result=`expr "${@}"`
8689ef0b394Smrg} # func_arith may be replaced by extended shell implementation
8699ef0b394Smrg
8709ef0b394Smrg
8719ef0b394Smrg# func_len string
8729ef0b394Smrg# STRING may not start with a hyphen.
8739ef0b394Smrgfunc_len ()
8749ef0b394Smrg{
8759ef0b394Smrg    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
8769ef0b394Smrg} # func_len may be replaced by extended shell implementation
8779ef0b394Smrg
8789ef0b394Smrg
8799ef0b394Smrg# func_lo2o object
8809ef0b394Smrgfunc_lo2o ()
8819ef0b394Smrg{
8829ef0b394Smrg    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
8839ef0b394Smrg} # func_lo2o may be replaced by extended shell implementation
8849ef0b394Smrg
8859ef0b394Smrg
8869ef0b394Smrg# func_xform libobj-or-source
8879ef0b394Smrgfunc_xform ()
8889ef0b394Smrg{
8899ef0b394Smrg    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
8909ef0b394Smrg} # func_xform may be replaced by extended shell implementation
8919ef0b394Smrg
8929ef0b394Smrg
893698f425bSmrg# func_fatal_configuration arg...
894698f425bSmrg# Echo program name prefixed message to standard error, followed by
895698f425bSmrg# a configuration failure hint, and exit.
896698f425bSmrgfunc_fatal_configuration ()
897698f425bSmrg{
898698f425bSmrg    func_error ${1+"$@"}
899698f425bSmrg    func_error "See the $PACKAGE documentation for more information."
900698f425bSmrg    func_fatal_error "Fatal configuration error."
901698f425bSmrg}
902266e564dSmrg
903c5629e66Smrg
904698f425bSmrg# func_config
905698f425bSmrg# Display the configuration for all the tags in this script.
906698f425bSmrgfunc_config ()
907698f425bSmrg{
908698f425bSmrg    re_begincf='^# ### BEGIN LIBTOOL'
909698f425bSmrg    re_endcf='^# ### END LIBTOOL'
910698f425bSmrg
911698f425bSmrg    # Default configuration.
912698f425bSmrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
913266e564dSmrg
914266e564dSmrg    # Now print the configurations for the tags.
915266e564dSmrg    for tagname in $taglist; do
916698f425bSmrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
917266e564dSmrg    done
918266e564dSmrg
919698f425bSmrg    exit $?
920698f425bSmrg}
921266e564dSmrg
922698f425bSmrg# func_features
923698f425bSmrg# Display the features supported by this script.
924698f425bSmrgfunc_features ()
925698f425bSmrg{
9269ef0b394Smrg    echo "host: $host"
927266e564dSmrg    if test "$build_libtool_libs" = yes; then
9289ef0b394Smrg      echo "enable shared libraries"
929266e564dSmrg    else
9309ef0b394Smrg      echo "disable shared libraries"
931266e564dSmrg    fi
932266e564dSmrg    if test "$build_old_libs" = yes; then
9339ef0b394Smrg      echo "enable static libraries"
934266e564dSmrg    else
9359ef0b394Smrg      echo "disable static libraries"
936266e564dSmrg    fi
937698f425bSmrg
938266e564dSmrg    exit $?
939698f425bSmrg}
940266e564dSmrg
941698f425bSmrg# func_enable_tag tagname
942698f425bSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or
943698f425bSmrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
944698f425bSmrg# variable here.
945698f425bSmrgfunc_enable_tag ()
946698f425bSmrg{
947698f425bSmrg  # Global variable:
948698f425bSmrg  tagname="$1"
949266e564dSmrg
950698f425bSmrg  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
951698f425bSmrg  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
952698f425bSmrg  sed_extractcf="/$re_begincf/,/$re_endcf/p"
953266e564dSmrg
954698f425bSmrg  # Validate tagname.
955698f425bSmrg  case $tagname in
956698f425bSmrg    *[!-_A-Za-z0-9,/]*)
957698f425bSmrg      func_fatal_error "invalid tag name: $tagname"
958698f425bSmrg      ;;
959698f425bSmrg  esac
960266e564dSmrg
961698f425bSmrg  # Don't test for the "default" C tag, as we know it's
962698f425bSmrg  # there but not specially marked.
963698f425bSmrg  case $tagname in
964698f425bSmrg    CC) ;;
965698f425bSmrg    *)
966698f425bSmrg      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
967698f425bSmrg	taglist="$taglist $tagname"
968698f425bSmrg
969698f425bSmrg	# Evaluate the configuration.  Be careful to quote the path
970698f425bSmrg	# and the sed script, to avoid splitting on whitespace, but
971698f425bSmrg	# also don't use non-portable quotes within backquotes within
972698f425bSmrg	# quotes we have to do it in 2 steps:
973698f425bSmrg	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
974698f425bSmrg	eval "$extractedcf"
975698f425bSmrg      else
976698f425bSmrg	func_error "ignoring unknown tag $tagname"
977698f425bSmrg      fi
978698f425bSmrg      ;;
979698f425bSmrg  esac
980698f425bSmrg}
981698f425bSmrg
9829ef0b394Smrg# func_check_version_match
9839ef0b394Smrg# Ensure that we are using m4 macros, and libtool script from the same
9849ef0b394Smrg# release of libtool.
9859ef0b394Smrgfunc_check_version_match ()
986698f425bSmrg{
9879ef0b394Smrg  if test "$package_revision" != "$macro_revision"; then
9889ef0b394Smrg    if test "$VERSION" != "$macro_version"; then
9899ef0b394Smrg      if test -z "$macro_version"; then
9909ef0b394Smrg        cat >&2 <<_LT_EOF
9919ef0b394Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
9929ef0b394Smrg$progname: definition of this LT_INIT comes from an older release.
9939ef0b394Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
9949ef0b394Smrg$progname: and run autoconf again.
9959ef0b394Smrg_LT_EOF
9969ef0b394Smrg      else
9979ef0b394Smrg        cat >&2 <<_LT_EOF
9989ef0b394Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
9999ef0b394Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
10009ef0b394Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
10019ef0b394Smrg$progname: and run autoconf again.
10029ef0b394Smrg_LT_EOF
10039ef0b394Smrg      fi
10049ef0b394Smrg    else
10059ef0b394Smrg      cat >&2 <<_LT_EOF
10069ef0b394Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
10079ef0b394Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
10089ef0b394Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
10099ef0b394Smrg$progname: of $PACKAGE $VERSION and run autoconf again.
10109ef0b394Smrg_LT_EOF
10119ef0b394Smrg    fi
1012266e564dSmrg
10139ef0b394Smrg    exit $EXIT_MISMATCH
10149ef0b394Smrg  fi
10159ef0b394Smrg}
10169ef0b394Smrg
10179ef0b394Smrg
10189ef0b394Smrg# Shorthand for --mode=foo, only valid as the first argument
10199ef0b394Smrgcase $1 in
10209ef0b394Smrgclean|clea|cle|cl)
10219ef0b394Smrg  shift; set dummy --mode clean ${1+"$@"}; shift
10229ef0b394Smrg  ;;
10239ef0b394Smrgcompile|compil|compi|comp|com|co|c)
10249ef0b394Smrg  shift; set dummy --mode compile ${1+"$@"}; shift
10259ef0b394Smrg  ;;
10269ef0b394Smrgexecute|execut|execu|exec|exe|ex|e)
10279ef0b394Smrg  shift; set dummy --mode execute ${1+"$@"}; shift
10289ef0b394Smrg  ;;
10299ef0b394Smrgfinish|finis|fini|fin|fi|f)
10309ef0b394Smrg  shift; set dummy --mode finish ${1+"$@"}; shift
10319ef0b394Smrg  ;;
10329ef0b394Smrginstall|instal|insta|inst|ins|in|i)
10339ef0b394Smrg  shift; set dummy --mode install ${1+"$@"}; shift
10349ef0b394Smrg  ;;
10359ef0b394Smrglink|lin|li|l)
10369ef0b394Smrg  shift; set dummy --mode link ${1+"$@"}; shift
10379ef0b394Smrg  ;;
10389ef0b394Smrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
10399ef0b394Smrg  shift; set dummy --mode uninstall ${1+"$@"}; shift
10409ef0b394Smrg  ;;
10419ef0b394Smrgesac
10429ef0b394Smrg
10439ef0b394Smrg
10449ef0b394Smrg
10459ef0b394Smrg# Option defaults:
10469ef0b394Smrgopt_debug=:
10479ef0b394Smrgopt_dry_run=false
10489ef0b394Smrgopt_config=false
10499ef0b394Smrgopt_preserve_dup_deps=false
10509ef0b394Smrgopt_features=false
10519ef0b394Smrgopt_finish=false
10529ef0b394Smrgopt_help=false
10539ef0b394Smrgopt_help_all=false
10549ef0b394Smrgopt_silent=:
10559ef0b394Smrgopt_verbose=:
10569ef0b394Smrgopt_silent=false
10579ef0b394Smrgopt_verbose=false
1058266e564dSmrg
10599ef0b394Smrg
10609ef0b394Smrg# Parse options once, thoroughly.  This comes as soon as possible in the
10619ef0b394Smrg# script to make things like `--version' happen as quickly as we can.
10629ef0b394Smrg{
10639ef0b394Smrg  # this just eases exit handling
10649ef0b394Smrg  while test $# -gt 0; do
1065698f425bSmrg    opt="$1"
1066698f425bSmrg    shift
1067698f425bSmrg    case $opt in
10689ef0b394Smrg      --debug|-x)	opt_debug='set -x'
1069698f425bSmrg			func_echo "enabling shell trace mode"
1070698f425bSmrg			$opt_debug
1071698f425bSmrg			;;
10729ef0b394Smrg      --dry-run|--dryrun|-n)
10739ef0b394Smrg			opt_dry_run=:
1074698f425bSmrg			;;
10759ef0b394Smrg      --config)
10769ef0b394Smrg			opt_config=:
10779ef0b394Smrgfunc_config
10789ef0b394Smrg			;;
10799ef0b394Smrg      --dlopen|-dlopen)
10809ef0b394Smrg			optarg="$1"
10819ef0b394Smrg			opt_dlopen="${opt_dlopen+$opt_dlopen
10829ef0b394Smrg}$optarg"
1083698f425bSmrg			shift
1084698f425bSmrg			;;
1085698f425bSmrg      --preserve-dup-deps)
10869ef0b394Smrg			opt_preserve_dup_deps=:
1087698f425bSmrg			;;
10889ef0b394Smrg      --features)
10899ef0b394Smrg			opt_features=:
10909ef0b394Smrgfunc_features
10919ef0b394Smrg			;;
10929ef0b394Smrg      --finish)
10939ef0b394Smrg			opt_finish=:
10949ef0b394Smrgset dummy --mode finish ${1+"$@"}; shift
10959ef0b394Smrg			;;
10969ef0b394Smrg      --help)
10979ef0b394Smrg			opt_help=:
10989ef0b394Smrg			;;
10999ef0b394Smrg      --help-all)
11009ef0b394Smrg			opt_help_all=:
11019ef0b394Smrgopt_help=': help-all'
11029ef0b394Smrg			;;
11039ef0b394Smrg      --mode)
11049ef0b394Smrg			test $# = 0 && func_missing_arg $opt && break
11059ef0b394Smrg			optarg="$1"
11069ef0b394Smrg			opt_mode="$optarg"
11079ef0b394Smrgcase $optarg in
11089ef0b394Smrg  # Valid mode arguments:
11099ef0b394Smrg  clean|compile|execute|finish|install|link|relink|uninstall) ;;
11109ef0b394Smrg
11119ef0b394Smrg  # Catch anything else as an error
11129ef0b394Smrg  *) func_error "invalid argument for $opt"
11139ef0b394Smrg     exit_cmd=exit
11149ef0b394Smrg     break
11159ef0b394Smrg     ;;
11169ef0b394Smrgesac
11179ef0b394Smrg			shift
11189ef0b394Smrg			;;
11199ef0b394Smrg      --no-silent|--no-quiet)
1120698f425bSmrg			opt_silent=false
11219ef0b394Smrgfunc_append preserve_args " $opt"
1122698f425bSmrg			;;
11239ef0b394Smrg      --no-verbose)
11249ef0b394Smrg			opt_verbose=false
11259ef0b394Smrgfunc_append preserve_args " $opt"
11269ef0b394Smrg			;;
11279ef0b394Smrg      --silent|--quiet)
11289ef0b394Smrg			opt_silent=:
11299ef0b394Smrgfunc_append preserve_args " $opt"
11309ef0b394Smrg        opt_verbose=false
11319ef0b394Smrg			;;
11329ef0b394Smrg      --verbose|-v)
11339ef0b394Smrg			opt_verbose=:
11349ef0b394Smrgfunc_append preserve_args " $opt"
11359ef0b394Smrgopt_silent=false
11369ef0b394Smrg			;;
11379ef0b394Smrg      --tag)
11389ef0b394Smrg			test $# = 0 && func_missing_arg $opt && break
11399ef0b394Smrg			optarg="$1"
11409ef0b394Smrg			opt_tag="$optarg"
11419ef0b394Smrgfunc_append preserve_args " $opt $optarg"
11429ef0b394Smrgfunc_enable_tag "$optarg"
1143698f425bSmrg			shift
1144698f425bSmrg			;;
1145698f425bSmrg
11469ef0b394Smrg      -\?|-h)		func_usage				;;
11479ef0b394Smrg      --help)		func_help				;;
11489ef0b394Smrg      --version)	func_version				;;
11499ef0b394Smrg
1150698f425bSmrg      # Separate optargs to long options:
11519ef0b394Smrg      --*=*)
11529ef0b394Smrg			func_split_long_opt "$opt"
11539ef0b394Smrg			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
1154698f425bSmrg			shift
1155698f425bSmrg			;;
1156698f425bSmrg
11579ef0b394Smrg      # Separate non-argument short options:
11589ef0b394Smrg      -\?*|-h*|-n*|-v*)
11599ef0b394Smrg			func_split_short_opt "$opt"
11609ef0b394Smrg			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
11619ef0b394Smrg			shift
1162698f425bSmrg			;;
11639ef0b394Smrg
11649ef0b394Smrg      --)		break					;;
11659ef0b394Smrg      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
11669ef0b394Smrg      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
1167698f425bSmrg    esac
1168698f425bSmrg  done
1169698f425bSmrg
11709ef0b394Smrg  # Validate options:
11719ef0b394Smrg
11729ef0b394Smrg  # save first non-option argument
11739ef0b394Smrg  if test "$#" -gt 0; then
11749ef0b394Smrg    nonopt="$opt"
11759ef0b394Smrg    shift
11769ef0b394Smrg  fi
11779ef0b394Smrg
11789ef0b394Smrg  # preserve --debug
11799ef0b394Smrg  test "$opt_debug" = : || func_append preserve_args " --debug"
1180698f425bSmrg
1181698f425bSmrg  case $host in
1182698f425bSmrg    *cygwin* | *mingw* | *pw32* | *cegcc*)
1183698f425bSmrg      # don't eliminate duplications in $postdeps and $predeps
1184698f425bSmrg      opt_duplicate_compiler_generated_deps=:
1185266e564dSmrg      ;;
1186266e564dSmrg    *)
11879ef0b394Smrg      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
1188698f425bSmrg      ;;
1189698f425bSmrg  esac
1190266e564dSmrg
11919ef0b394Smrg  $opt_help || {
11929ef0b394Smrg    # Sanity checks first:
11939ef0b394Smrg    func_check_version_match
1194698f425bSmrg
11959ef0b394Smrg    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
11969ef0b394Smrg      func_fatal_configuration "not configured to build any kind of library"
1197698f425bSmrg    fi
1198698f425bSmrg
11999ef0b394Smrg    # Darwin sucks
12009ef0b394Smrg    eval std_shrext=\"$shrext_cmds\"
1201698f425bSmrg
12029ef0b394Smrg    # Only execute mode is allowed to have -dlopen flags.
12039ef0b394Smrg    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
12049ef0b394Smrg      func_error "unrecognized option \`-dlopen'"
12059ef0b394Smrg      $ECHO "$help" 1>&2
12069ef0b394Smrg      exit $EXIT_FAILURE
12079ef0b394Smrg    fi
1208698f425bSmrg
12099ef0b394Smrg    # Change the help message to a mode-specific one.
12109ef0b394Smrg    generic_help="$help"
12119ef0b394Smrg    help="Try \`$progname --help --mode=$opt_mode' for more information."
12129ef0b394Smrg  }
1213698f425bSmrg
1214698f425bSmrg
12159ef0b394Smrg  # Bail if the options were screwed
12169ef0b394Smrg  $exit_cmd $EXIT_FAILURE
12179ef0b394Smrg}
1218698f425bSmrg
1219266e564dSmrg
1220266e564dSmrg
1221266e564dSmrg
12229ef0b394Smrg## ----------- ##
12239ef0b394Smrg##    Main.    ##
12249ef0b394Smrg## ----------- ##
1225266e564dSmrg
1226698f425bSmrg# func_lalib_p file
1227698f425bSmrg# True iff FILE is a libtool `.la' library or `.lo' object file.
1228698f425bSmrg# This function is only a basic sanity check; it will hardly flush out
1229698f425bSmrg# determined imposters.
1230698f425bSmrgfunc_lalib_p ()
1231698f425bSmrg{
1232698f425bSmrg    test -f "$1" &&
1233698f425bSmrg      $SED -e 4q "$1" 2>/dev/null \
1234698f425bSmrg        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
1235698f425bSmrg}
1236266e564dSmrg
1237698f425bSmrg# func_lalib_unsafe_p file
1238698f425bSmrg# True iff FILE is a libtool `.la' library or `.lo' object file.
1239698f425bSmrg# This function implements the same check as func_lalib_p without
1240698f425bSmrg# resorting to external programs.  To this end, it redirects stdin and
1241698f425bSmrg# closes it afterwards, without saving the original file descriptor.
1242698f425bSmrg# As a safety measure, use it only where a negative result would be
1243698f425bSmrg# fatal anyway.  Works if `file' does not exist.
1244698f425bSmrgfunc_lalib_unsafe_p ()
1245698f425bSmrg{
1246698f425bSmrg    lalib_p=no
1247698f425bSmrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
1248698f425bSmrg	for lalib_p_l in 1 2 3 4
1249698f425bSmrg	do
1250698f425bSmrg	    read lalib_p_line
1251698f425bSmrg	    case "$lalib_p_line" in
1252698f425bSmrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
1253698f425bSmrg	    esac
1254698f425bSmrg	done
1255698f425bSmrg	exec 0<&5 5<&-
1256698f425bSmrg    fi
1257698f425bSmrg    test "$lalib_p" = yes
1258698f425bSmrg}
1259266e564dSmrg
1260698f425bSmrg# func_ltwrapper_script_p file
1261698f425bSmrg# True iff FILE is a libtool wrapper script
1262698f425bSmrg# This function is only a basic sanity check; it will hardly flush out
1263698f425bSmrg# determined imposters.
1264698f425bSmrgfunc_ltwrapper_script_p ()
1265698f425bSmrg{
1266698f425bSmrg    func_lalib_p "$1"
1267698f425bSmrg}
1268266e564dSmrg
1269698f425bSmrg# func_ltwrapper_executable_p file
1270698f425bSmrg# True iff FILE is a libtool wrapper executable
1271698f425bSmrg# This function is only a basic sanity check; it will hardly flush out
1272698f425bSmrg# determined imposters.
1273698f425bSmrgfunc_ltwrapper_executable_p ()
1274698f425bSmrg{
1275698f425bSmrg    func_ltwrapper_exec_suffix=
1276698f425bSmrg    case $1 in
1277698f425bSmrg    *.exe) ;;
1278698f425bSmrg    *) func_ltwrapper_exec_suffix=.exe ;;
1279698f425bSmrg    esac
1280698f425bSmrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
1281698f425bSmrg}
1282698f425bSmrg
1283698f425bSmrg# func_ltwrapper_scriptname file
1284698f425bSmrg# Assumes file is an ltwrapper_executable
1285698f425bSmrg# uses $file to determine the appropriate filename for a
1286698f425bSmrg# temporary ltwrapper_script.
1287698f425bSmrgfunc_ltwrapper_scriptname ()
1288698f425bSmrg{
12899ef0b394Smrg    func_dirname_and_basename "$1" "" "."
12909ef0b394Smrg    func_stripname '' '.exe' "$func_basename_result"
12919ef0b394Smrg    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
1292698f425bSmrg}
1293698f425bSmrg
1294698f425bSmrg# func_ltwrapper_p file
1295698f425bSmrg# True iff FILE is a libtool wrapper script or wrapper executable
1296698f425bSmrg# This function is only a basic sanity check; it will hardly flush out
1297698f425bSmrg# determined imposters.
1298698f425bSmrgfunc_ltwrapper_p ()
1299698f425bSmrg{
1300698f425bSmrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
1301698f425bSmrg}
1302698f425bSmrg
1303698f425bSmrg
1304698f425bSmrg# func_execute_cmds commands fail_cmd
1305698f425bSmrg# Execute tilde-delimited COMMANDS.
1306698f425bSmrg# If FAIL_CMD is given, eval that upon failure.
1307698f425bSmrg# FAIL_CMD may read-access the current command in variable CMD!
1308698f425bSmrgfunc_execute_cmds ()
1309698f425bSmrg{
1310698f425bSmrg    $opt_debug
1311698f425bSmrg    save_ifs=$IFS; IFS='~'
1312698f425bSmrg    for cmd in $1; do
1313698f425bSmrg      IFS=$save_ifs
1314698f425bSmrg      eval cmd=\"$cmd\"
1315698f425bSmrg      func_show_eval "$cmd" "${2-:}"
1316698f425bSmrg    done
1317698f425bSmrg    IFS=$save_ifs
1318698f425bSmrg}
1319698f425bSmrg
1320698f425bSmrg
1321698f425bSmrg# func_source file
1322698f425bSmrg# Source FILE, adding directory component if necessary.
1323698f425bSmrg# Note that it is not necessary on cygwin/mingw to append a dot to
1324698f425bSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
1325698f425bSmrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
1326698f425bSmrg# `FILE.' does not work on cygwin managed mounts.
1327698f425bSmrgfunc_source ()
1328698f425bSmrg{
1329698f425bSmrg    $opt_debug
1330698f425bSmrg    case $1 in
1331698f425bSmrg    */* | *\\*)	. "$1" ;;
1332698f425bSmrg    *)		. "./$1" ;;
1333698f425bSmrg    esac
1334698f425bSmrg}
1335698f425bSmrg
1336698f425bSmrg
13379ef0b394Smrg# func_resolve_sysroot PATH
13389ef0b394Smrg# Replace a leading = in PATH with a sysroot.  Store the result into
13399ef0b394Smrg# func_resolve_sysroot_result
13409ef0b394Smrgfunc_resolve_sysroot ()
13419ef0b394Smrg{
13429ef0b394Smrg  func_resolve_sysroot_result=$1
13439ef0b394Smrg  case $func_resolve_sysroot_result in
13449ef0b394Smrg  =*)
13459ef0b394Smrg    func_stripname '=' '' "$func_resolve_sysroot_result"
13469ef0b394Smrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
13479ef0b394Smrg    ;;
13489ef0b394Smrg  esac
13499ef0b394Smrg}
13509ef0b394Smrg
13519ef0b394Smrg# func_replace_sysroot PATH
13529ef0b394Smrg# If PATH begins with the sysroot, replace it with = and
13539ef0b394Smrg# store the result into func_replace_sysroot_result.
13549ef0b394Smrgfunc_replace_sysroot ()
13559ef0b394Smrg{
13569ef0b394Smrg  case "$lt_sysroot:$1" in
13579ef0b394Smrg  ?*:"$lt_sysroot"*)
13589ef0b394Smrg    func_stripname "$lt_sysroot" '' "$1"
13599ef0b394Smrg    func_replace_sysroot_result="=$func_stripname_result"
13609ef0b394Smrg    ;;
13619ef0b394Smrg  *)
13629ef0b394Smrg    # Including no sysroot.
13639ef0b394Smrg    func_replace_sysroot_result=$1
13649ef0b394Smrg    ;;
13659ef0b394Smrg  esac
13669ef0b394Smrg}
13679ef0b394Smrg
1368698f425bSmrg# func_infer_tag arg
1369698f425bSmrg# Infer tagged configuration to use if any are available and
1370698f425bSmrg# if one wasn't chosen via the "--tag" command line option.
1371698f425bSmrg# Only attempt this if the compiler in the base compile
1372698f425bSmrg# command doesn't match the default compiler.
1373698f425bSmrg# arg is usually of the form 'gcc ...'
1374698f425bSmrgfunc_infer_tag ()
1375698f425bSmrg{
1376698f425bSmrg    $opt_debug
1377698f425bSmrg    if test -n "$available_tags" && test -z "$tagname"; then
1378698f425bSmrg      CC_quoted=
1379698f425bSmrg      for arg in $CC; do
13809ef0b394Smrg	func_append_quoted CC_quoted "$arg"
1381698f425bSmrg      done
13829ef0b394Smrg      CC_expanded=`func_echo_all $CC`
13839ef0b394Smrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
1384698f425bSmrg      case $@ in
1385698f425bSmrg      # Blanks in the command may have been stripped by the calling shell,
1386698f425bSmrg      # but not from the CC environment variable when configure was run.
13879ef0b394Smrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
13889ef0b394Smrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
1389698f425bSmrg      # Blanks at the start of $base_compile will cause this to fail
1390698f425bSmrg      # if we don't check for them as well.
1391698f425bSmrg      *)
1392698f425bSmrg	for z in $available_tags; do
1393698f425bSmrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1394698f425bSmrg	    # Evaluate the configuration.
1395698f425bSmrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1396698f425bSmrg	    CC_quoted=
1397698f425bSmrg	    for arg in $CC; do
1398698f425bSmrg	      # Double-quote args containing other shell metacharacters.
13999ef0b394Smrg	      func_append_quoted CC_quoted "$arg"
1400698f425bSmrg	    done
14019ef0b394Smrg	    CC_expanded=`func_echo_all $CC`
14029ef0b394Smrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
1403698f425bSmrg	    case "$@ " in
14049ef0b394Smrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
14059ef0b394Smrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
1406698f425bSmrg	      # The compiler in the base compile command matches
1407698f425bSmrg	      # the one in the tagged configuration.
1408698f425bSmrg	      # Assume this is the tagged configuration we want.
1409698f425bSmrg	      tagname=$z
1410698f425bSmrg	      break
1411698f425bSmrg	      ;;
1412698f425bSmrg	    esac
1413698f425bSmrg	  fi
1414698f425bSmrg	done
1415698f425bSmrg	# If $tagname still isn't set, then no tagged configuration
1416698f425bSmrg	# was found and let the user know that the "--tag" command
1417698f425bSmrg	# line option must be used.
1418698f425bSmrg	if test -z "$tagname"; then
1419698f425bSmrg	  func_echo "unable to infer tagged configuration"
1420698f425bSmrg	  func_fatal_error "specify a tag with \`--tag'"
1421698f425bSmrg#	else
1422698f425bSmrg#	  func_verbose "using $tagname tagged configuration"
1423698f425bSmrg	fi
1424698f425bSmrg	;;
1425698f425bSmrg      esac
1426698f425bSmrg    fi
1427698f425bSmrg}
1428698f425bSmrg
1429698f425bSmrg
1430698f425bSmrg
1431698f425bSmrg# func_write_libtool_object output_name pic_name nonpic_name
1432698f425bSmrg# Create a libtool object file (analogous to a ".la" file),
1433698f425bSmrg# but don't create it if we're doing a dry run.
1434698f425bSmrgfunc_write_libtool_object ()
1435698f425bSmrg{
1436698f425bSmrg    write_libobj=${1}
1437698f425bSmrg    if test "$build_libtool_libs" = yes; then
1438698f425bSmrg      write_lobj=\'${2}\'
1439698f425bSmrg    else
1440698f425bSmrg      write_lobj=none
1441698f425bSmrg    fi
1442698f425bSmrg
1443698f425bSmrg    if test "$build_old_libs" = yes; then
1444698f425bSmrg      write_oldobj=\'${3}\'
1445698f425bSmrg    else
1446698f425bSmrg      write_oldobj=none
1447698f425bSmrg    fi
1448698f425bSmrg
1449698f425bSmrg    $opt_dry_run || {
1450698f425bSmrg      cat >${write_libobj}T <<EOF
1451698f425bSmrg# $write_libobj - a libtool object file
1452698f425bSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1453698f425bSmrg#
1454698f425bSmrg# Please DO NOT delete this file!
1455698f425bSmrg# It is necessary for linking the library.
1456698f425bSmrg
1457698f425bSmrg# Name of the PIC object.
1458698f425bSmrgpic_object=$write_lobj
1459698f425bSmrg
1460698f425bSmrg# Name of the non-PIC object
1461698f425bSmrgnon_pic_object=$write_oldobj
1462698f425bSmrg
1463698f425bSmrgEOF
1464698f425bSmrg      $MV "${write_libobj}T" "${write_libobj}"
1465698f425bSmrg    }
1466698f425bSmrg}
1467698f425bSmrg
14689ef0b394Smrg
14699ef0b394Smrg##################################################
14709ef0b394Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
14719ef0b394Smrg##################################################
14729ef0b394Smrg
14739ef0b394Smrg# func_convert_core_file_wine_to_w32 ARG
14749ef0b394Smrg# Helper function used by file name conversion functions when $build is *nix,
14759ef0b394Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
14769ef0b394Smrg# correctly configured wine environment available, with the winepath program
14779ef0b394Smrg# in $build's $PATH.
14789ef0b394Smrg#
14799ef0b394Smrg# ARG is the $build file name to be converted to w32 format.
14809ef0b394Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
14819ef0b394Smrg# be empty on error (or when ARG is empty)
14829ef0b394Smrgfunc_convert_core_file_wine_to_w32 ()
14839ef0b394Smrg{
14849ef0b394Smrg  $opt_debug
14859ef0b394Smrg  func_convert_core_file_wine_to_w32_result="$1"
14869ef0b394Smrg  if test -n "$1"; then
14879ef0b394Smrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
14889ef0b394Smrg    # are forced to check the contents of stdout. On the other hand, if the
14899ef0b394Smrg    # command is not found, the shell will set an exit code of 127 and print
14909ef0b394Smrg    # *an error message* to stdout. So we must check for both error code of
14919ef0b394Smrg    # zero AND non-empty stdout, which explains the odd construction:
14929ef0b394Smrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
14939ef0b394Smrg    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
14949ef0b394Smrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
14959ef0b394Smrg        $SED -e "$lt_sed_naive_backslashify"`
14969ef0b394Smrg    else
14979ef0b394Smrg      func_convert_core_file_wine_to_w32_result=
14989ef0b394Smrg    fi
14999ef0b394Smrg  fi
15009ef0b394Smrg}
15019ef0b394Smrg# end: func_convert_core_file_wine_to_w32
15029ef0b394Smrg
15039ef0b394Smrg
15049ef0b394Smrg# func_convert_core_path_wine_to_w32 ARG
15059ef0b394Smrg# Helper function used by path conversion functions when $build is *nix, and
15069ef0b394Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
15079ef0b394Smrg# configured wine environment available, with the winepath program in $build's
15089ef0b394Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
15099ef0b394Smrg#
15109ef0b394Smrg# ARG is path to be converted from $build format to win32.
15119ef0b394Smrg# Result is available in $func_convert_core_path_wine_to_w32_result.
15129ef0b394Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
15139ef0b394Smrg# are convertible, then the result may be empty.
15149ef0b394Smrgfunc_convert_core_path_wine_to_w32 ()
15159ef0b394Smrg{
15169ef0b394Smrg  $opt_debug
15179ef0b394Smrg  # unfortunately, winepath doesn't convert paths, only file names
15189ef0b394Smrg  func_convert_core_path_wine_to_w32_result=""
15199ef0b394Smrg  if test -n "$1"; then
15209ef0b394Smrg    oldIFS=$IFS
15219ef0b394Smrg    IFS=:
15229ef0b394Smrg    for func_convert_core_path_wine_to_w32_f in $1; do
15239ef0b394Smrg      IFS=$oldIFS
15249ef0b394Smrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
15259ef0b394Smrg      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
15269ef0b394Smrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
15279ef0b394Smrg          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
15289ef0b394Smrg        else
15299ef0b394Smrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
15309ef0b394Smrg        fi
15319ef0b394Smrg      fi
15329ef0b394Smrg    done
15339ef0b394Smrg    IFS=$oldIFS
15349ef0b394Smrg  fi
15359ef0b394Smrg}
15369ef0b394Smrg# end: func_convert_core_path_wine_to_w32
15379ef0b394Smrg
15389ef0b394Smrg
15399ef0b394Smrg# func_cygpath ARGS...
15409ef0b394Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
15419ef0b394Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
15429ef0b394Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
15439ef0b394Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
15449ef0b394Smrg# file name or path is assumed to be in w32 format, as previously converted
15459ef0b394Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
15469ef0b394Smrg# or path in func_cygpath_result (input file name or path is assumed to be in
15479ef0b394Smrg# Cygwin format). Returns an empty string on error.
15489ef0b394Smrg#
15499ef0b394Smrg# ARGS are passed to cygpath, with the last one being the file name or path to
15509ef0b394Smrg# be converted.
15519ef0b394Smrg#
15529ef0b394Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
15539ef0b394Smrg# environment variable; do not put it in $PATH.
15549ef0b394Smrgfunc_cygpath ()
15559ef0b394Smrg{
15569ef0b394Smrg  $opt_debug
15579ef0b394Smrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
15589ef0b394Smrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
15599ef0b394Smrg    if test "$?" -ne 0; then
15609ef0b394Smrg      # on failure, ensure result is empty
15619ef0b394Smrg      func_cygpath_result=
15629ef0b394Smrg    fi
15639ef0b394Smrg  else
15649ef0b394Smrg    func_cygpath_result=
15659ef0b394Smrg    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
15669ef0b394Smrg  fi
15679ef0b394Smrg}
15689ef0b394Smrg#end: func_cygpath
15699ef0b394Smrg
15709ef0b394Smrg
15719ef0b394Smrg# func_convert_core_msys_to_w32 ARG
15729ef0b394Smrg# Convert file name or path ARG from MSYS format to w32 format.  Return
15739ef0b394Smrg# result in func_convert_core_msys_to_w32_result.
15749ef0b394Smrgfunc_convert_core_msys_to_w32 ()
15759ef0b394Smrg{
15769ef0b394Smrg  $opt_debug
15779ef0b394Smrg  # awkward: cmd appends spaces to result
15789ef0b394Smrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
15799ef0b394Smrg    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
15809ef0b394Smrg}
15819ef0b394Smrg#end: func_convert_core_msys_to_w32
15829ef0b394Smrg
15839ef0b394Smrg
15849ef0b394Smrg# func_convert_file_check ARG1 ARG2
15859ef0b394Smrg# Verify that ARG1 (a file name in $build format) was converted to $host
15869ef0b394Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
15879ef0b394Smrg# func_to_host_file_result to ARG1).
15889ef0b394Smrgfunc_convert_file_check ()
15899ef0b394Smrg{
15909ef0b394Smrg  $opt_debug
15919ef0b394Smrg  if test -z "$2" && test -n "$1" ; then
15929ef0b394Smrg    func_error "Could not determine host file name corresponding to"
15939ef0b394Smrg    func_error "  \`$1'"
15949ef0b394Smrg    func_error "Continuing, but uninstalled executables may not work."
15959ef0b394Smrg    # Fallback:
15969ef0b394Smrg    func_to_host_file_result="$1"
15979ef0b394Smrg  fi
15989ef0b394Smrg}
15999ef0b394Smrg# end func_convert_file_check
16009ef0b394Smrg
16019ef0b394Smrg
16029ef0b394Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
16039ef0b394Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host
16049ef0b394Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
16059ef0b394Smrg# func_to_host_file_result to a simplistic fallback value (see below).
16069ef0b394Smrgfunc_convert_path_check ()
16079ef0b394Smrg{
16089ef0b394Smrg  $opt_debug
16099ef0b394Smrg  if test -z "$4" && test -n "$3"; then
16109ef0b394Smrg    func_error "Could not determine the host path corresponding to"
16119ef0b394Smrg    func_error "  \`$3'"
16129ef0b394Smrg    func_error "Continuing, but uninstalled executables may not work."
16139ef0b394Smrg    # Fallback.  This is a deliberately simplistic "conversion" and
16149ef0b394Smrg    # should not be "improved".  See libtool.info.
16159ef0b394Smrg    if test "x$1" != "x$2"; then
16169ef0b394Smrg      lt_replace_pathsep_chars="s|$1|$2|g"
16179ef0b394Smrg      func_to_host_path_result=`echo "$3" |
16189ef0b394Smrg        $SED -e "$lt_replace_pathsep_chars"`
16199ef0b394Smrg    else
16209ef0b394Smrg      func_to_host_path_result="$3"
16219ef0b394Smrg    fi
16229ef0b394Smrg  fi
16239ef0b394Smrg}
16249ef0b394Smrg# end func_convert_path_check
16259ef0b394Smrg
16269ef0b394Smrg
16279ef0b394Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
16289ef0b394Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
16299ef0b394Smrg# and appending REPL if ORIG matches BACKPAT.
16309ef0b394Smrgfunc_convert_path_front_back_pathsep ()
16319ef0b394Smrg{
16329ef0b394Smrg  $opt_debug
16339ef0b394Smrg  case $4 in
16349ef0b394Smrg  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
16359ef0b394Smrg    ;;
16369ef0b394Smrg  esac
16379ef0b394Smrg  case $4 in
16389ef0b394Smrg  $2 ) func_append func_to_host_path_result "$3"
16399ef0b394Smrg    ;;
16409ef0b394Smrg  esac
16419ef0b394Smrg}
16429ef0b394Smrg# end func_convert_path_front_back_pathsep
16439ef0b394Smrg
16449ef0b394Smrg
16459ef0b394Smrg##################################################
16469ef0b394Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
16479ef0b394Smrg##################################################
16489ef0b394Smrg# invoked via `$to_host_file_cmd ARG'
16499ef0b394Smrg#
16509ef0b394Smrg# In each case, ARG is the path to be converted from $build to $host format.
16519ef0b394Smrg# Result will be available in $func_to_host_file_result.
16529ef0b394Smrg
16539ef0b394Smrg
16549ef0b394Smrg# func_to_host_file ARG
16559ef0b394Smrg# Converts the file name ARG from $build format to $host format. Return result
16569ef0b394Smrg# in func_to_host_file_result.
16579ef0b394Smrgfunc_to_host_file ()
16589ef0b394Smrg{
16599ef0b394Smrg  $opt_debug
16609ef0b394Smrg  $to_host_file_cmd "$1"
16619ef0b394Smrg}
16629ef0b394Smrg# end func_to_host_file
16639ef0b394Smrg
16649ef0b394Smrg
16659ef0b394Smrg# func_to_tool_file ARG LAZY
16669ef0b394Smrg# converts the file name ARG from $build format to toolchain format. Return
16679ef0b394Smrg# result in func_to_tool_file_result.  If the conversion in use is listed
16689ef0b394Smrg# in (the comma separated) LAZY, no conversion takes place.
16699ef0b394Smrgfunc_to_tool_file ()
16709ef0b394Smrg{
16719ef0b394Smrg  $opt_debug
16729ef0b394Smrg  case ,$2, in
16739ef0b394Smrg    *,"$to_tool_file_cmd",*)
16749ef0b394Smrg      func_to_tool_file_result=$1
16759ef0b394Smrg      ;;
16769ef0b394Smrg    *)
16779ef0b394Smrg      $to_tool_file_cmd "$1"
16789ef0b394Smrg      func_to_tool_file_result=$func_to_host_file_result
16799ef0b394Smrg      ;;
16809ef0b394Smrg  esac
16819ef0b394Smrg}
16829ef0b394Smrg# end func_to_tool_file
16839ef0b394Smrg
16849ef0b394Smrg
16859ef0b394Smrg# func_convert_file_noop ARG
16869ef0b394Smrg# Copy ARG to func_to_host_file_result.
16879ef0b394Smrgfunc_convert_file_noop ()
16889ef0b394Smrg{
16899ef0b394Smrg  func_to_host_file_result="$1"
16909ef0b394Smrg}
16919ef0b394Smrg# end func_convert_file_noop
16929ef0b394Smrg
16939ef0b394Smrg
16949ef0b394Smrg# func_convert_file_msys_to_w32 ARG
16959ef0b394Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
16969ef0b394Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
16979ef0b394Smrg# func_to_host_file_result.
16989ef0b394Smrgfunc_convert_file_msys_to_w32 ()
16999ef0b394Smrg{
17009ef0b394Smrg  $opt_debug
17019ef0b394Smrg  func_to_host_file_result="$1"
17029ef0b394Smrg  if test -n "$1"; then
17039ef0b394Smrg    func_convert_core_msys_to_w32 "$1"
17049ef0b394Smrg    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
17059ef0b394Smrg  fi
17069ef0b394Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
17079ef0b394Smrg}
17089ef0b394Smrg# end func_convert_file_msys_to_w32
17099ef0b394Smrg
17109ef0b394Smrg
17119ef0b394Smrg# func_convert_file_cygwin_to_w32 ARG
17129ef0b394Smrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
17139ef0b394Smrg# func_to_host_file_result.
17149ef0b394Smrgfunc_convert_file_cygwin_to_w32 ()
17159ef0b394Smrg{
17169ef0b394Smrg  $opt_debug
17179ef0b394Smrg  func_to_host_file_result="$1"
17189ef0b394Smrg  if test -n "$1"; then
17199ef0b394Smrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
17209ef0b394Smrg    # LT_CYGPATH in this case.
17219ef0b394Smrg    func_to_host_file_result=`cygpath -m "$1"`
17229ef0b394Smrg  fi
17239ef0b394Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
17249ef0b394Smrg}
17259ef0b394Smrg# end func_convert_file_cygwin_to_w32
17269ef0b394Smrg
17279ef0b394Smrg
17289ef0b394Smrg# func_convert_file_nix_to_w32 ARG
17299ef0b394Smrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
17309ef0b394Smrg# and a working winepath. Returns result in func_to_host_file_result.
17319ef0b394Smrgfunc_convert_file_nix_to_w32 ()
17329ef0b394Smrg{
17339ef0b394Smrg  $opt_debug
17349ef0b394Smrg  func_to_host_file_result="$1"
17359ef0b394Smrg  if test -n "$1"; then
17369ef0b394Smrg    func_convert_core_file_wine_to_w32 "$1"
17379ef0b394Smrg    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
17389ef0b394Smrg  fi
17399ef0b394Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
17409ef0b394Smrg}
17419ef0b394Smrg# end func_convert_file_nix_to_w32
17429ef0b394Smrg
17439ef0b394Smrg
17449ef0b394Smrg# func_convert_file_msys_to_cygwin ARG
17459ef0b394Smrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
17469ef0b394Smrg# Returns result in func_to_host_file_result.
17479ef0b394Smrgfunc_convert_file_msys_to_cygwin ()
17489ef0b394Smrg{
17499ef0b394Smrg  $opt_debug
17509ef0b394Smrg  func_to_host_file_result="$1"
17519ef0b394Smrg  if test -n "$1"; then
17529ef0b394Smrg    func_convert_core_msys_to_w32 "$1"
17539ef0b394Smrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
17549ef0b394Smrg    func_to_host_file_result="$func_cygpath_result"
17559ef0b394Smrg  fi
17569ef0b394Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
17579ef0b394Smrg}
17589ef0b394Smrg# end func_convert_file_msys_to_cygwin
17599ef0b394Smrg
17609ef0b394Smrg
17619ef0b394Smrg# func_convert_file_nix_to_cygwin ARG
17629ef0b394Smrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
17639ef0b394Smrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
17649ef0b394Smrg# in func_to_host_file_result.
17659ef0b394Smrgfunc_convert_file_nix_to_cygwin ()
17669ef0b394Smrg{
17679ef0b394Smrg  $opt_debug
17689ef0b394Smrg  func_to_host_file_result="$1"
17699ef0b394Smrg  if test -n "$1"; then
17709ef0b394Smrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
17719ef0b394Smrg    func_convert_core_file_wine_to_w32 "$1"
17729ef0b394Smrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
17739ef0b394Smrg    func_to_host_file_result="$func_cygpath_result"
17749ef0b394Smrg  fi
17759ef0b394Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
17769ef0b394Smrg}
17779ef0b394Smrg# end func_convert_file_nix_to_cygwin
17789ef0b394Smrg
17799ef0b394Smrg
17809ef0b394Smrg#############################################
17819ef0b394Smrg# $build to $host PATH CONVERSION FUNCTIONS #
17829ef0b394Smrg#############################################
17839ef0b394Smrg# invoked via `$to_host_path_cmd ARG'
17849ef0b394Smrg#
17859ef0b394Smrg# In each case, ARG is the path to be converted from $build to $host format.
17869ef0b394Smrg# The result will be available in $func_to_host_path_result.
17879ef0b394Smrg#
17889ef0b394Smrg# Path separators are also converted from $build format to $host format.  If
17899ef0b394Smrg# ARG begins or ends with a path separator character, it is preserved (but
17909ef0b394Smrg# converted to $host format) on output.
17919ef0b394Smrg#
17929ef0b394Smrg# All path conversion functions are named using the following convention:
17939ef0b394Smrg#   file name conversion function    : func_convert_file_X_to_Y ()
17949ef0b394Smrg#   path conversion function         : func_convert_path_X_to_Y ()
17959ef0b394Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the
17969ef0b394Smrg# same.  If conversion functions are added for new $build/$host combinations,
17979ef0b394Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
17989ef0b394Smrg# will break.
17999ef0b394Smrg
18009ef0b394Smrg
18019ef0b394Smrg# func_init_to_host_path_cmd
18029ef0b394Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
18039ef0b394Smrg# appropriate value, based on the value of $to_host_file_cmd.
18049ef0b394Smrgto_host_path_cmd=
18059ef0b394Smrgfunc_init_to_host_path_cmd ()
18069ef0b394Smrg{
18079ef0b394Smrg  $opt_debug
18089ef0b394Smrg  if test -z "$to_host_path_cmd"; then
18099ef0b394Smrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
18109ef0b394Smrg    to_host_path_cmd="func_convert_path_${func_stripname_result}"
18119ef0b394Smrg  fi
18129ef0b394Smrg}
18139ef0b394Smrg
18149ef0b394Smrg
18159ef0b394Smrg# func_to_host_path ARG
18169ef0b394Smrg# Converts the path ARG from $build format to $host format. Return result
18179ef0b394Smrg# in func_to_host_path_result.
18189ef0b394Smrgfunc_to_host_path ()
18199ef0b394Smrg{
18209ef0b394Smrg  $opt_debug
18219ef0b394Smrg  func_init_to_host_path_cmd
18229ef0b394Smrg  $to_host_path_cmd "$1"
18239ef0b394Smrg}
18249ef0b394Smrg# end func_to_host_path
18259ef0b394Smrg
18269ef0b394Smrg
18279ef0b394Smrg# func_convert_path_noop ARG
18289ef0b394Smrg# Copy ARG to func_to_host_path_result.
18299ef0b394Smrgfunc_convert_path_noop ()
18309ef0b394Smrg{
18319ef0b394Smrg  func_to_host_path_result="$1"
18329ef0b394Smrg}
18339ef0b394Smrg# end func_convert_path_noop
18349ef0b394Smrg
18359ef0b394Smrg
18369ef0b394Smrg# func_convert_path_msys_to_w32 ARG
18379ef0b394Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
18389ef0b394Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
18399ef0b394Smrg# func_to_host_path_result.
18409ef0b394Smrgfunc_convert_path_msys_to_w32 ()
18419ef0b394Smrg{
18429ef0b394Smrg  $opt_debug
18439ef0b394Smrg  func_to_host_path_result="$1"
18449ef0b394Smrg  if test -n "$1"; then
18459ef0b394Smrg    # Remove leading and trailing path separator characters from ARG.  MSYS
18469ef0b394Smrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
18479ef0b394Smrg    # and winepath ignores them completely.
18489ef0b394Smrg    func_stripname : : "$1"
18499ef0b394Smrg    func_to_host_path_tmp1=$func_stripname_result
18509ef0b394Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
18519ef0b394Smrg    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
18529ef0b394Smrg    func_convert_path_check : ";" \
18539ef0b394Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
18549ef0b394Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
18559ef0b394Smrg  fi
18569ef0b394Smrg}
18579ef0b394Smrg# end func_convert_path_msys_to_w32
18589ef0b394Smrg
18599ef0b394Smrg
18609ef0b394Smrg# func_convert_path_cygwin_to_w32 ARG
18619ef0b394Smrg# Convert path ARG from Cygwin to w32 format.  Returns result in
18629ef0b394Smrg# func_to_host_file_result.
18639ef0b394Smrgfunc_convert_path_cygwin_to_w32 ()
18649ef0b394Smrg{
18659ef0b394Smrg  $opt_debug
18669ef0b394Smrg  func_to_host_path_result="$1"
18679ef0b394Smrg  if test -n "$1"; then
18689ef0b394Smrg    # See func_convert_path_msys_to_w32:
18699ef0b394Smrg    func_stripname : : "$1"
18709ef0b394Smrg    func_to_host_path_tmp1=$func_stripname_result
18719ef0b394Smrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
18729ef0b394Smrg    func_convert_path_check : ";" \
18739ef0b394Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
18749ef0b394Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
18759ef0b394Smrg  fi
18769ef0b394Smrg}
18779ef0b394Smrg# end func_convert_path_cygwin_to_w32
18789ef0b394Smrg
18799ef0b394Smrg
18809ef0b394Smrg# func_convert_path_nix_to_w32 ARG
18819ef0b394Smrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
18829ef0b394Smrg# a working winepath.  Returns result in func_to_host_file_result.
18839ef0b394Smrgfunc_convert_path_nix_to_w32 ()
18849ef0b394Smrg{
18859ef0b394Smrg  $opt_debug
18869ef0b394Smrg  func_to_host_path_result="$1"
18879ef0b394Smrg  if test -n "$1"; then
18889ef0b394Smrg    # See func_convert_path_msys_to_w32:
18899ef0b394Smrg    func_stripname : : "$1"
18909ef0b394Smrg    func_to_host_path_tmp1=$func_stripname_result
18919ef0b394Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
18929ef0b394Smrg    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
18939ef0b394Smrg    func_convert_path_check : ";" \
18949ef0b394Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
18959ef0b394Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
18969ef0b394Smrg  fi
18979ef0b394Smrg}
18989ef0b394Smrg# end func_convert_path_nix_to_w32
18999ef0b394Smrg
19009ef0b394Smrg
19019ef0b394Smrg# func_convert_path_msys_to_cygwin ARG
19029ef0b394Smrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
19039ef0b394Smrg# Returns result in func_to_host_file_result.
19049ef0b394Smrgfunc_convert_path_msys_to_cygwin ()
19059ef0b394Smrg{
19069ef0b394Smrg  $opt_debug
19079ef0b394Smrg  func_to_host_path_result="$1"
19089ef0b394Smrg  if test -n "$1"; then
19099ef0b394Smrg    # See func_convert_path_msys_to_w32:
19109ef0b394Smrg    func_stripname : : "$1"
19119ef0b394Smrg    func_to_host_path_tmp1=$func_stripname_result
19129ef0b394Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
19139ef0b394Smrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
19149ef0b394Smrg    func_to_host_path_result="$func_cygpath_result"
19159ef0b394Smrg    func_convert_path_check : : \
19169ef0b394Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
19179ef0b394Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
19189ef0b394Smrg  fi
19199ef0b394Smrg}
19209ef0b394Smrg# end func_convert_path_msys_to_cygwin
19219ef0b394Smrg
19229ef0b394Smrg
19239ef0b394Smrg# func_convert_path_nix_to_cygwin ARG
19249ef0b394Smrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
19259ef0b394Smrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
19269ef0b394Smrg# func_to_host_file_result.
19279ef0b394Smrgfunc_convert_path_nix_to_cygwin ()
19289ef0b394Smrg{
19299ef0b394Smrg  $opt_debug
19309ef0b394Smrg  func_to_host_path_result="$1"
19319ef0b394Smrg  if test -n "$1"; then
19329ef0b394Smrg    # Remove leading and trailing path separator characters from
19339ef0b394Smrg    # ARG. msys behavior is inconsistent here, cygpath turns them
19349ef0b394Smrg    # into '.;' and ';.', and winepath ignores them completely.
19359ef0b394Smrg    func_stripname : : "$1"
19369ef0b394Smrg    func_to_host_path_tmp1=$func_stripname_result
19379ef0b394Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
19389ef0b394Smrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
19399ef0b394Smrg    func_to_host_path_result="$func_cygpath_result"
19409ef0b394Smrg    func_convert_path_check : : \
19419ef0b394Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
19429ef0b394Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
19439ef0b394Smrg  fi
19449ef0b394Smrg}
19459ef0b394Smrg# end func_convert_path_nix_to_cygwin
19469ef0b394Smrg
19479ef0b394Smrg
1948698f425bSmrg# func_mode_compile arg...
1949698f425bSmrgfunc_mode_compile ()
1950698f425bSmrg{
1951698f425bSmrg    $opt_debug
1952698f425bSmrg    # Get the compilation command and the source file.
1953698f425bSmrg    base_compile=
1954698f425bSmrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
1955698f425bSmrg    suppress_opt=yes
1956698f425bSmrg    suppress_output=
1957698f425bSmrg    arg_mode=normal
1958698f425bSmrg    libobj=
1959698f425bSmrg    later=
1960698f425bSmrg    pie_flag=
1961698f425bSmrg
1962698f425bSmrg    for arg
1963698f425bSmrg    do
1964698f425bSmrg      case $arg_mode in
1965698f425bSmrg      arg  )
1966698f425bSmrg	# do not "continue".  Instead, add this to base_compile
1967698f425bSmrg	lastarg="$arg"
1968698f425bSmrg	arg_mode=normal
1969698f425bSmrg	;;
1970698f425bSmrg
1971698f425bSmrg      target )
1972698f425bSmrg	libobj="$arg"
1973698f425bSmrg	arg_mode=normal
1974698f425bSmrg	continue
1975698f425bSmrg	;;
1976698f425bSmrg
1977698f425bSmrg      normal )
1978698f425bSmrg	# Accept any command-line options.
1979698f425bSmrg	case $arg in
1980698f425bSmrg	-o)
1981698f425bSmrg	  test -n "$libobj" && \
1982698f425bSmrg	    func_fatal_error "you cannot specify \`-o' more than once"
1983698f425bSmrg	  arg_mode=target
1984698f425bSmrg	  continue
1985698f425bSmrg	  ;;
1986698f425bSmrg
1987698f425bSmrg	-pie | -fpie | -fPIE)
19889ef0b394Smrg          func_append pie_flag " $arg"
1989698f425bSmrg	  continue
1990698f425bSmrg	  ;;
1991698f425bSmrg
1992698f425bSmrg	-shared | -static | -prefer-pic | -prefer-non-pic)
19939ef0b394Smrg	  func_append later " $arg"
1994698f425bSmrg	  continue
1995698f425bSmrg	  ;;
1996266e564dSmrg
1997266e564dSmrg	-no-suppress)
1998266e564dSmrg	  suppress_opt=no
1999266e564dSmrg	  continue
2000266e564dSmrg	  ;;
2001266e564dSmrg
2002266e564dSmrg	-Xcompiler)
2003266e564dSmrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
2004266e564dSmrg	  continue      #  The current "srcfile" will either be retained or
2005266e564dSmrg	  ;;            #  replaced later.  I would guess that would be a bug.
2006266e564dSmrg
2007266e564dSmrg	-Wc,*)
2008698f425bSmrg	  func_stripname '-Wc,' '' "$arg"
2009698f425bSmrg	  args=$func_stripname_result
2010266e564dSmrg	  lastarg=
2011266e564dSmrg	  save_ifs="$IFS"; IFS=','
2012698f425bSmrg	  for arg in $args; do
2013266e564dSmrg	    IFS="$save_ifs"
20149ef0b394Smrg	    func_append_quoted lastarg "$arg"
2015266e564dSmrg	  done
2016266e564dSmrg	  IFS="$save_ifs"
2017698f425bSmrg	  func_stripname ' ' '' "$lastarg"
2018698f425bSmrg	  lastarg=$func_stripname_result
2019266e564dSmrg
2020266e564dSmrg	  # Add the arguments to base_compile.
20219ef0b394Smrg	  func_append base_compile " $lastarg"
2022266e564dSmrg	  continue
2023266e564dSmrg	  ;;
2024266e564dSmrg
2025698f425bSmrg	*)
2026266e564dSmrg	  # Accept the current argument as the source file.
2027266e564dSmrg	  # The previous "srcfile" becomes the current argument.
2028266e564dSmrg	  #
2029266e564dSmrg	  lastarg="$srcfile"
2030266e564dSmrg	  srcfile="$arg"
2031266e564dSmrg	  ;;
2032266e564dSmrg	esac  #  case $arg
2033266e564dSmrg	;;
2034266e564dSmrg      esac    #  case $arg_mode
2035266e564dSmrg
2036266e564dSmrg      # Aesthetically quote the previous argument.
20379ef0b394Smrg      func_append_quoted base_compile "$lastarg"
2038266e564dSmrg    done # for arg
2039266e564dSmrg
2040266e564dSmrg    case $arg_mode in
2041266e564dSmrg    arg)
2042698f425bSmrg      func_fatal_error "you must specify an argument for -Xcompile"
2043266e564dSmrg      ;;
2044266e564dSmrg    target)
2045698f425bSmrg      func_fatal_error "you must specify a target with \`-o'"
2046266e564dSmrg      ;;
2047266e564dSmrg    *)
2048266e564dSmrg      # Get the name of the library object.
2049698f425bSmrg      test -z "$libobj" && {
2050698f425bSmrg	func_basename "$srcfile"
2051698f425bSmrg	libobj="$func_basename_result"
2052698f425bSmrg      }
2053266e564dSmrg      ;;
2054266e564dSmrg    esac
2055266e564dSmrg
2056266e564dSmrg    # Recognize several different file suffixes.
2057266e564dSmrg    # If the user specifies -o file.o, it is replaced with file.lo
2058266e564dSmrg    case $libobj in
2059698f425bSmrg    *.[cCFSifmso] | \
2060698f425bSmrg    *.ada | *.adb | *.ads | *.asm | \
2061698f425bSmrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
20629ef0b394Smrg    *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup)
2063698f425bSmrg      func_xform "$libobj"
2064698f425bSmrg      libobj=$func_xform_result
2065698f425bSmrg      ;;
2066266e564dSmrg    esac
2067266e564dSmrg
2068266e564dSmrg    case $libobj in
2069698f425bSmrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
2070266e564dSmrg    *)
2071698f425bSmrg      func_fatal_error "cannot determine name of library object from \`$libobj'"
2072266e564dSmrg      ;;
2073266e564dSmrg    esac
2074266e564dSmrg
2075266e564dSmrg    func_infer_tag $base_compile
2076266e564dSmrg
2077266e564dSmrg    for arg in $later; do
2078266e564dSmrg      case $arg in
2079698f425bSmrg      -shared)
2080698f425bSmrg	test "$build_libtool_libs" != yes && \
2081698f425bSmrg	  func_fatal_configuration "can not build a shared library"
2082698f425bSmrg	build_old_libs=no
2083698f425bSmrg	continue
2084698f425bSmrg	;;
2085698f425bSmrg
2086266e564dSmrg      -static)
2087698f425bSmrg	build_libtool_libs=no
2088266e564dSmrg	build_old_libs=yes
2089266e564dSmrg	continue
2090266e564dSmrg	;;
2091266e564dSmrg
2092266e564dSmrg      -prefer-pic)
2093266e564dSmrg	pic_mode=yes
2094266e564dSmrg	continue
2095266e564dSmrg	;;
2096266e564dSmrg
2097266e564dSmrg      -prefer-non-pic)
2098266e564dSmrg	pic_mode=no
2099266e564dSmrg	continue
2100266e564dSmrg	;;
2101266e564dSmrg      esac
2102266e564dSmrg    done
2103266e564dSmrg
2104698f425bSmrg    func_quote_for_eval "$libobj"
2105698f425bSmrg    test "X$libobj" != "X$func_quote_for_eval_result" \
2106698f425bSmrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
2107698f425bSmrg      && func_warning "libobj name \`$libobj' may not contain shell special characters."
2108698f425bSmrg    func_dirname_and_basename "$obj" "/" ""
2109698f425bSmrg    objname="$func_basename_result"
2110698f425bSmrg    xdir="$func_dirname_result"
2111266e564dSmrg    lobj=${xdir}$objdir/$objname
2112266e564dSmrg
2113698f425bSmrg    test -z "$base_compile" && \
2114698f425bSmrg      func_fatal_help "you must specify a compilation command"
2115266e564dSmrg
2116266e564dSmrg    # Delete any leftover library objects.
2117266e564dSmrg    if test "$build_old_libs" = yes; then
2118266e564dSmrg      removelist="$obj $lobj $libobj ${libobj}T"
2119266e564dSmrg    else
2120266e564dSmrg      removelist="$lobj $libobj ${libobj}T"
2121266e564dSmrg    fi
2122266e564dSmrg
2123266e564dSmrg    # On Cygwin there's no "real" PIC flag so we must build both object types
2124266e564dSmrg    case $host_os in
2125698f425bSmrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
2126266e564dSmrg      pic_mode=default
2127266e564dSmrg      ;;
2128266e564dSmrg    esac
2129266e564dSmrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
2130266e564dSmrg      # non-PIC code in shared libraries is not supported
2131266e564dSmrg      pic_mode=default
2132266e564dSmrg    fi
2133266e564dSmrg
2134266e564dSmrg    # Calculate the filename of the output object if compiler does
2135266e564dSmrg    # not support -o with -c
2136266e564dSmrg    if test "$compiler_c_o" = no; then
21379ef0b394Smrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
2138266e564dSmrg      lockfile="$output_obj.lock"
2139266e564dSmrg    else
2140266e564dSmrg      output_obj=
2141266e564dSmrg      need_locks=no
2142266e564dSmrg      lockfile=
2143266e564dSmrg    fi
2144266e564dSmrg
2145266e564dSmrg    # Lock this critical section if it is needed
2146266e564dSmrg    # We use this script file to make the link, it avoids creating a new file
2147266e564dSmrg    if test "$need_locks" = yes; then
2148698f425bSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
2149698f425bSmrg	func_echo "Waiting for $lockfile to be removed"
2150266e564dSmrg	sleep 2
2151266e564dSmrg      done
2152266e564dSmrg    elif test "$need_locks" = warn; then
2153266e564dSmrg      if test -f "$lockfile"; then
2154698f425bSmrg	$ECHO "\
2155266e564dSmrg*** ERROR, $lockfile exists and contains:
2156266e564dSmrg`cat $lockfile 2>/dev/null`
2157266e564dSmrg
2158266e564dSmrgThis indicates that another process is trying to use the same
2159266e564dSmrgtemporary object file, and libtool could not work around it because
2160266e564dSmrgyour compiler does not support \`-c' and \`-o' together.  If you
2161266e564dSmrgrepeat this compilation, it may succeed, by chance, but you had better
2162266e564dSmrgavoid parallel builds (make -j) in this platform, or get a better
2163266e564dSmrgcompiler."
2164266e564dSmrg
2165698f425bSmrg	$opt_dry_run || $RM $removelist
2166266e564dSmrg	exit $EXIT_FAILURE
2167266e564dSmrg      fi
21689ef0b394Smrg      func_append removelist " $output_obj"
2169698f425bSmrg      $ECHO "$srcfile" > "$lockfile"
2170266e564dSmrg    fi
2171266e564dSmrg
2172698f425bSmrg    $opt_dry_run || $RM $removelist
21739ef0b394Smrg    func_append removelist " $lockfile"
2174698f425bSmrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
2175698f425bSmrg
21769ef0b394Smrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
21779ef0b394Smrg    srcfile=$func_to_tool_file_result
2178698f425bSmrg    func_quote_for_eval "$srcfile"
2179698f425bSmrg    qsrcfile=$func_quote_for_eval_result
2180266e564dSmrg
2181266e564dSmrg    # Only build a PIC object if we are building libtool libraries.
2182266e564dSmrg    if test "$build_libtool_libs" = yes; then
2183266e564dSmrg      # Without this assignment, base_compile gets emptied.
2184266e564dSmrg      fbsd_hideous_sh_bug=$base_compile
2185266e564dSmrg
2186266e564dSmrg      if test "$pic_mode" != no; then
2187266e564dSmrg	command="$base_compile $qsrcfile $pic_flag"
2188266e564dSmrg      else
2189266e564dSmrg	# Don't build PIC code
2190266e564dSmrg	command="$base_compile $qsrcfile"
2191266e564dSmrg      fi
2192266e564dSmrg
2193698f425bSmrg      func_mkdir_p "$xdir$objdir"
2194266e564dSmrg
2195266e564dSmrg      if test -z "$output_obj"; then
2196266e564dSmrg	# Place PIC objects in $objdir
21979ef0b394Smrg	func_append command " -o $lobj"
2198266e564dSmrg      fi
2199266e564dSmrg
2200698f425bSmrg      func_show_eval_locale "$command"	\
2201698f425bSmrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
2202266e564dSmrg
2203266e564dSmrg      if test "$need_locks" = warn &&
2204266e564dSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2205698f425bSmrg	$ECHO "\
2206266e564dSmrg*** ERROR, $lockfile contains:
2207266e564dSmrg`cat $lockfile 2>/dev/null`
2208266e564dSmrg
2209266e564dSmrgbut it should contain:
2210266e564dSmrg$srcfile
2211266e564dSmrg
2212266e564dSmrgThis indicates that another process is trying to use the same
2213266e564dSmrgtemporary object file, and libtool could not work around it because
2214266e564dSmrgyour compiler does not support \`-c' and \`-o' together.  If you
2215266e564dSmrgrepeat this compilation, it may succeed, by chance, but you had better
2216266e564dSmrgavoid parallel builds (make -j) in this platform, or get a better
2217266e564dSmrgcompiler."
2218266e564dSmrg
2219698f425bSmrg	$opt_dry_run || $RM $removelist
2220266e564dSmrg	exit $EXIT_FAILURE
2221266e564dSmrg      fi
2222266e564dSmrg
2223266e564dSmrg      # Just move the object if needed, then go on to compile the next one
2224266e564dSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
2225698f425bSmrg	func_show_eval '$MV "$output_obj" "$lobj"' \
2226698f425bSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2227266e564dSmrg      fi
2228266e564dSmrg
2229266e564dSmrg      # Allow error messages only from the first compilation.
2230266e564dSmrg      if test "$suppress_opt" = yes; then
2231698f425bSmrg	suppress_output=' >/dev/null 2>&1'
2232266e564dSmrg      fi
2233266e564dSmrg    fi
2234266e564dSmrg
2235266e564dSmrg    # Only build a position-dependent object if we build old libraries.
2236266e564dSmrg    if test "$build_old_libs" = yes; then
2237266e564dSmrg      if test "$pic_mode" != yes; then
2238266e564dSmrg	# Don't build PIC code
2239698f425bSmrg	command="$base_compile $qsrcfile$pie_flag"
2240266e564dSmrg      else
2241266e564dSmrg	command="$base_compile $qsrcfile $pic_flag"
2242266e564dSmrg      fi
2243266e564dSmrg      if test "$compiler_c_o" = yes; then
22449ef0b394Smrg	func_append command " -o $obj"
2245266e564dSmrg      fi
2246266e564dSmrg
2247266e564dSmrg      # Suppress compiler output if we already did a PIC compilation.
22489ef0b394Smrg      func_append command "$suppress_output"
2249698f425bSmrg      func_show_eval_locale "$command" \
2250698f425bSmrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
2251266e564dSmrg
2252266e564dSmrg      if test "$need_locks" = warn &&
2253266e564dSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2254698f425bSmrg	$ECHO "\
2255266e564dSmrg*** ERROR, $lockfile contains:
2256266e564dSmrg`cat $lockfile 2>/dev/null`
2257266e564dSmrg
2258266e564dSmrgbut it should contain:
2259266e564dSmrg$srcfile
2260266e564dSmrg
2261266e564dSmrgThis indicates that another process is trying to use the same
2262266e564dSmrgtemporary object file, and libtool could not work around it because
2263266e564dSmrgyour compiler does not support \`-c' and \`-o' together.  If you
2264266e564dSmrgrepeat this compilation, it may succeed, by chance, but you had better
2265266e564dSmrgavoid parallel builds (make -j) in this platform, or get a better
2266266e564dSmrgcompiler."
2267266e564dSmrg
2268698f425bSmrg	$opt_dry_run || $RM $removelist
2269266e564dSmrg	exit $EXIT_FAILURE
2270266e564dSmrg      fi
2271266e564dSmrg
2272266e564dSmrg      # Just move the object if needed
2273266e564dSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
2274698f425bSmrg	func_show_eval '$MV "$output_obj" "$obj"' \
2275698f425bSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2276266e564dSmrg      fi
2277266e564dSmrg    fi
2278266e564dSmrg
2279698f425bSmrg    $opt_dry_run || {
2280698f425bSmrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
2281266e564dSmrg
2282698f425bSmrg      # Unlock the critical section if it was locked
2283698f425bSmrg      if test "$need_locks" != no; then
2284698f425bSmrg	removelist=$lockfile
2285698f425bSmrg        $RM "$lockfile"
2286698f425bSmrg      fi
2287698f425bSmrg    }
2288266e564dSmrg
2289266e564dSmrg    exit $EXIT_SUCCESS
2290698f425bSmrg}
2291266e564dSmrg
2292698f425bSmrg$opt_help || {
22939ef0b394Smrg  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
2294698f425bSmrg}
2295266e564dSmrg
2296698f425bSmrgfunc_mode_help ()
2297698f425bSmrg{
2298698f425bSmrg    # We need to display help for each of the modes.
22999ef0b394Smrg    case $opt_mode in
2300698f425bSmrg      "")
2301698f425bSmrg        # Generic help is extracted from the usage comments
2302698f425bSmrg        # at the start of this file.
2303698f425bSmrg        func_help
2304698f425bSmrg        ;;
2305266e564dSmrg
2306698f425bSmrg      clean)
2307698f425bSmrg        $ECHO \
2308698f425bSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
2309266e564dSmrg
2310698f425bSmrgRemove files from the build directory.
2311266e564dSmrg
2312698f425bSmrgRM is the name of the program to use to delete files associated with each FILE
2313698f425bSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2314698f425bSmrgto RM.
2315266e564dSmrg
2316698f425bSmrgIf FILE is a libtool library, object or program, all the files associated
2317698f425bSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
2318698f425bSmrg        ;;
2319266e564dSmrg
2320698f425bSmrg      compile)
2321698f425bSmrg      $ECHO \
2322698f425bSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
2323266e564dSmrg
2324698f425bSmrgCompile a source file into a libtool library object.
2325266e564dSmrg
2326698f425bSmrgThis mode accepts the following additional options:
2327266e564dSmrg
2328698f425bSmrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
2329698f425bSmrg  -no-suppress      do not suppress compiler output for multiple passes
23309ef0b394Smrg  -prefer-pic       try to build PIC objects only
23319ef0b394Smrg  -prefer-non-pic   try to build non-PIC objects only
2332698f425bSmrg  -shared           do not build a \`.o' file suitable for static linking
2333698f425bSmrg  -static           only build a \`.o' file suitable for static linking
23349ef0b394Smrg  -Wc,FLAG          pass FLAG directly to the compiler
2335266e564dSmrg
2336698f425bSmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
2337698f425bSmrgfrom the given SOURCEFILE.
2338266e564dSmrg
2339698f425bSmrgThe output file name is determined by removing the directory component from
2340698f425bSmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
2341698f425bSmrglibrary object suffix, \`.lo'."
2342698f425bSmrg        ;;
2343266e564dSmrg
2344698f425bSmrg      execute)
2345698f425bSmrg        $ECHO \
2346698f425bSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
2347266e564dSmrg
2348698f425bSmrgAutomatically set library path, then run a program.
2349266e564dSmrg
2350698f425bSmrgThis mode accepts the following additional options:
2351266e564dSmrg
2352698f425bSmrg  -dlopen FILE      add the directory containing FILE to the library path
2353266e564dSmrg
2354698f425bSmrgThis mode sets the library path environment variable according to \`-dlopen'
2355698f425bSmrgflags.
2356266e564dSmrg
2357698f425bSmrgIf any of the ARGS are libtool executable wrappers, then they are translated
2358698f425bSmrginto their corresponding uninstalled binary, and any of their required library
2359698f425bSmrgdirectories are added to the library path.
2360266e564dSmrg
2361698f425bSmrgThen, COMMAND is executed, with ARGS as arguments."
2362698f425bSmrg        ;;
2363266e564dSmrg
2364698f425bSmrg      finish)
2365698f425bSmrg        $ECHO \
2366698f425bSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
2367266e564dSmrg
2368698f425bSmrgComplete the installation of libtool libraries.
2369266e564dSmrg
2370698f425bSmrgEach LIBDIR is a directory that contains libtool libraries.
2371266e564dSmrg
2372698f425bSmrgThe commands that this mode executes may require superuser privileges.  Use
2373698f425bSmrgthe \`--dry-run' option if you just want to see what would be executed."
2374698f425bSmrg        ;;
2375266e564dSmrg
2376698f425bSmrg      install)
2377698f425bSmrg        $ECHO \
2378698f425bSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
2379266e564dSmrg
2380698f425bSmrgInstall executables or libraries.
2381266e564dSmrg
2382698f425bSmrgINSTALL-COMMAND is the installation command.  The first component should be
2383698f425bSmrgeither the \`install' or \`cp' program.
2384266e564dSmrg
2385698f425bSmrgThe following components of INSTALL-COMMAND are treated specially:
2386266e564dSmrg
23879ef0b394Smrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
2388266e564dSmrg
2389698f425bSmrgThe rest of the components are interpreted as arguments to that command (only
2390698f425bSmrgBSD-compatible install options are recognized)."
2391698f425bSmrg        ;;
2392266e564dSmrg
2393698f425bSmrg      link)
2394698f425bSmrg        $ECHO \
2395698f425bSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
2396266e564dSmrg
2397698f425bSmrgLink object files or libraries together to form another library, or to
2398698f425bSmrgcreate an executable program.
2399266e564dSmrg
2400698f425bSmrgLINK-COMMAND is a command using the C compiler that you would use to create
2401698f425bSmrga program from several object files.
2402266e564dSmrg
2403698f425bSmrgThe following components of LINK-COMMAND are treated specially:
2404266e564dSmrg
2405698f425bSmrg  -all-static       do not do any dynamic linking at all
2406698f425bSmrg  -avoid-version    do not add a version suffix if possible
24079ef0b394Smrg  -bindir BINDIR    specify path to binaries directory (for systems where
24089ef0b394Smrg                    libraries must be found in the PATH setting at runtime)
2409698f425bSmrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
2410698f425bSmrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
2411698f425bSmrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
2412698f425bSmrg  -export-symbols SYMFILE
2413698f425bSmrg                    try to export only the symbols listed in SYMFILE
2414698f425bSmrg  -export-symbols-regex REGEX
2415698f425bSmrg                    try to export only the symbols matching REGEX
2416698f425bSmrg  -LLIBDIR          search LIBDIR for required installed libraries
2417698f425bSmrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
2418698f425bSmrg  -module           build a library that can dlopened
2419698f425bSmrg  -no-fast-install  disable the fast-install mode
2420698f425bSmrg  -no-install       link a not-installable executable
2421698f425bSmrg  -no-undefined     declare that a library does not refer to external symbols
2422698f425bSmrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
2423698f425bSmrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
2424698f425bSmrg  -precious-files-regex REGEX
2425698f425bSmrg                    don't remove output files matching REGEX
2426698f425bSmrg  -release RELEASE  specify package release information
2427698f425bSmrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
2428698f425bSmrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
2429698f425bSmrg  -shared           only do dynamic linking of libtool libraries
2430698f425bSmrg  -shrext SUFFIX    override the standard shared library file extension
2431698f425bSmrg  -static           do not do any dynamic linking of uninstalled libtool libraries
2432698f425bSmrg  -static-libtool-libs
2433698f425bSmrg                    do not do any dynamic linking of libtool libraries
2434698f425bSmrg  -version-info CURRENT[:REVISION[:AGE]]
2435698f425bSmrg                    specify library version info [each variable defaults to 0]
2436698f425bSmrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
24379ef0b394Smrg  -Wc,FLAG
24389ef0b394Smrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
24399ef0b394Smrg  -Wl,FLAG
24409ef0b394Smrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
24419ef0b394Smrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
2442266e564dSmrg
2443698f425bSmrgAll other options (arguments beginning with \`-') are ignored.
2444266e564dSmrg
2445698f425bSmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
2446698f425bSmrgtreated as uninstalled libtool libraries, other files are standard or library
2447698f425bSmrgobject files.
2448c5629e66Smrg
2449698f425bSmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
2450698f425bSmrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
2451698f425bSmrgrequired, except when creating a convenience library.
2452266e564dSmrg
2453698f425bSmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
2454698f425bSmrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
2455266e564dSmrg
2456698f425bSmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
2457698f425bSmrgis created, otherwise an executable program is created."
2458266e564dSmrg        ;;
2459266e564dSmrg
2460698f425bSmrg      uninstall)
2461698f425bSmrg        $ECHO \
2462698f425bSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
2463266e564dSmrg
2464698f425bSmrgRemove libraries from an installation directory.
2465266e564dSmrg
2466698f425bSmrgRM is the name of the program to use to delete files associated with each FILE
2467698f425bSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2468698f425bSmrgto RM.
2469266e564dSmrg
2470698f425bSmrgIf FILE is a libtool library, all the files associated with it are deleted.
2471698f425bSmrgOtherwise, only FILE itself is deleted using RM."
2472698f425bSmrg        ;;
2473266e564dSmrg
2474698f425bSmrg      *)
24759ef0b394Smrg        func_fatal_help "invalid operation mode \`$opt_mode'"
2476698f425bSmrg        ;;
2477698f425bSmrg    esac
2478266e564dSmrg
24799ef0b394Smrg    echo
2480698f425bSmrg    $ECHO "Try \`$progname --help' for more information about other modes."
2481698f425bSmrg}
2482266e564dSmrg
24839ef0b394Smrg# Now that we've collected a possible --mode arg, show help if necessary
24849ef0b394Smrgif $opt_help; then
24859ef0b394Smrg  if test "$opt_help" = :; then
24869ef0b394Smrg    func_mode_help
24879ef0b394Smrg  else
24889ef0b394Smrg    {
24899ef0b394Smrg      func_help noexit
24909ef0b394Smrg      for opt_mode in compile link execute install finish uninstall clean; do
24919ef0b394Smrg	func_mode_help
24929ef0b394Smrg      done
24939ef0b394Smrg    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
24949ef0b394Smrg    {
24959ef0b394Smrg      func_help noexit
24969ef0b394Smrg      for opt_mode in compile link execute install finish uninstall clean; do
24979ef0b394Smrg	echo
24989ef0b394Smrg	func_mode_help
24999ef0b394Smrg      done
25009ef0b394Smrg    } |
25019ef0b394Smrg    sed '1d
25029ef0b394Smrg      /^When reporting/,/^Report/{
25039ef0b394Smrg	H
25049ef0b394Smrg	d
25059ef0b394Smrg      }
25069ef0b394Smrg      $x
25079ef0b394Smrg      /information about other modes/d
25089ef0b394Smrg      /more detailed .*MODE/d
25099ef0b394Smrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
25109ef0b394Smrg  fi
25119ef0b394Smrg  exit $?
25129ef0b394Smrgfi
2513266e564dSmrg
2514266e564dSmrg
2515698f425bSmrg# func_mode_execute arg...
2516698f425bSmrgfunc_mode_execute ()
2517698f425bSmrg{
2518698f425bSmrg    $opt_debug
2519698f425bSmrg    # The first argument is the command name.
2520698f425bSmrg    cmd="$nonopt"
2521698f425bSmrg    test -z "$cmd" && \
2522698f425bSmrg      func_fatal_help "you must specify a COMMAND"
2523266e564dSmrg
2524698f425bSmrg    # Handle -dlopen flags immediately.
25259ef0b394Smrg    for file in $opt_dlopen; do
2526698f425bSmrg      test -f "$file" \
2527698f425bSmrg	|| func_fatal_help "\`$file' is not a file"
2528266e564dSmrg
2529698f425bSmrg      dir=
2530698f425bSmrg      case $file in
2531698f425bSmrg      *.la)
25329ef0b394Smrg	func_resolve_sysroot "$file"
25339ef0b394Smrg	file=$func_resolve_sysroot_result
25349ef0b394Smrg
2535698f425bSmrg	# Check to see that this really is a libtool archive.
2536698f425bSmrg	func_lalib_unsafe_p "$file" \
2537698f425bSmrg	  || func_fatal_help "\`$lib' is not a valid libtool archive"
2538266e564dSmrg
2539698f425bSmrg	# Read the libtool library.
2540698f425bSmrg	dlname=
2541698f425bSmrg	library_names=
2542698f425bSmrg	func_source "$file"
2543266e564dSmrg
2544698f425bSmrg	# Skip this library if it cannot be dlopened.
2545698f425bSmrg	if test -z "$dlname"; then
2546698f425bSmrg	  # Warn if it was a shared library.
2547698f425bSmrg	  test -n "$library_names" && \
2548698f425bSmrg	    func_warning "\`$file' was not linked with \`-export-dynamic'"
2549698f425bSmrg	  continue
2550698f425bSmrg	fi
2551266e564dSmrg
2552698f425bSmrg	func_dirname "$file" "" "."
2553698f425bSmrg	dir="$func_dirname_result"
2554266e564dSmrg
2555698f425bSmrg	if test -f "$dir/$objdir/$dlname"; then
25569ef0b394Smrg	  func_append dir "/$objdir"
2557698f425bSmrg	else
2558698f425bSmrg	  if test ! -f "$dir/$dlname"; then
2559698f425bSmrg	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
2560698f425bSmrg	  fi
2561698f425bSmrg	fi
2562266e564dSmrg	;;
2563266e564dSmrg
2564698f425bSmrg      *.lo)
2565698f425bSmrg	# Just add the directory containing the .lo file.
2566698f425bSmrg	func_dirname "$file" "" "."
2567698f425bSmrg	dir="$func_dirname_result"
2568266e564dSmrg	;;
2569266e564dSmrg
2570698f425bSmrg      *)
2571698f425bSmrg	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
2572266e564dSmrg	continue
2573266e564dSmrg	;;
2574698f425bSmrg      esac
2575266e564dSmrg
2576698f425bSmrg      # Get the absolute pathname.
2577698f425bSmrg      absdir=`cd "$dir" && pwd`
2578698f425bSmrg      test -n "$absdir" && dir="$absdir"
2579266e564dSmrg
2580698f425bSmrg      # Now add the directory to shlibpath_var.
2581698f425bSmrg      if eval "test -z \"\$$shlibpath_var\""; then
2582698f425bSmrg	eval "$shlibpath_var=\"\$dir\""
2583698f425bSmrg      else
2584698f425bSmrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
2585698f425bSmrg      fi
2586698f425bSmrg    done
2587266e564dSmrg
2588698f425bSmrg    # This variable tells wrapper scripts just to set shlibpath_var
2589698f425bSmrg    # rather than running their programs.
2590698f425bSmrg    libtool_execute_magic="$magic"
2591266e564dSmrg
2592698f425bSmrg    # Check if any of the arguments is a wrapper script.
2593698f425bSmrg    args=
2594698f425bSmrg    for file
2595698f425bSmrg    do
2596698f425bSmrg      case $file in
25979ef0b394Smrg      -* | *.la | *.lo ) ;;
2598698f425bSmrg      *)
2599698f425bSmrg	# Do a test to see if this is really a libtool program.
2600698f425bSmrg	if func_ltwrapper_script_p "$file"; then
2601698f425bSmrg	  func_source "$file"
2602698f425bSmrg	  # Transform arg to wrapped name.
2603698f425bSmrg	  file="$progdir/$program"
2604698f425bSmrg	elif func_ltwrapper_executable_p "$file"; then
2605698f425bSmrg	  func_ltwrapper_scriptname "$file"
2606698f425bSmrg	  func_source "$func_ltwrapper_scriptname_result"
2607698f425bSmrg	  # Transform arg to wrapped name.
2608698f425bSmrg	  file="$progdir/$program"
2609698f425bSmrg	fi
2610698f425bSmrg	;;
2611698f425bSmrg      esac
2612698f425bSmrg      # Quote arguments (to preserve shell metacharacters).
26139ef0b394Smrg      func_append_quoted args "$file"
2614698f425bSmrg    done
2615266e564dSmrg
2616698f425bSmrg    if test "X$opt_dry_run" = Xfalse; then
2617698f425bSmrg      if test -n "$shlibpath_var"; then
2618698f425bSmrg	# Export the shlibpath_var.
2619698f425bSmrg	eval "export $shlibpath_var"
2620698f425bSmrg      fi
2621266e564dSmrg
2622698f425bSmrg      # Restore saved environment variables
2623698f425bSmrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
2624698f425bSmrg      do
2625698f425bSmrg	eval "if test \"\${save_$lt_var+set}\" = set; then
2626698f425bSmrg                $lt_var=\$save_$lt_var; export $lt_var
2627266e564dSmrg	      else
2628698f425bSmrg		$lt_unset $lt_var
2629698f425bSmrg	      fi"
2630698f425bSmrg      done
2631266e564dSmrg
2632698f425bSmrg      # Now prepare to actually exec the command.
2633698f425bSmrg      exec_cmd="\$cmd$args"
2634698f425bSmrg    else
2635698f425bSmrg      # Display what would be done.
2636698f425bSmrg      if test -n "$shlibpath_var"; then
2637698f425bSmrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
26389ef0b394Smrg	echo "export $shlibpath_var"
2639698f425bSmrg      fi
2640698f425bSmrg      $ECHO "$cmd$args"
2641698f425bSmrg      exit $EXIT_SUCCESS
2642698f425bSmrg    fi
2643698f425bSmrg}
2644266e564dSmrg
26459ef0b394Smrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"}
26469ef0b394Smrg
26479ef0b394Smrg
26489ef0b394Smrg# func_mode_finish arg...
26499ef0b394Smrgfunc_mode_finish ()
26509ef0b394Smrg{
26519ef0b394Smrg    $opt_debug
26529ef0b394Smrg    libs=
26539ef0b394Smrg    libdirs=
26549ef0b394Smrg    admincmds=
26559ef0b394Smrg
26569ef0b394Smrg    for opt in "$nonopt" ${1+"$@"}
26579ef0b394Smrg    do
26589ef0b394Smrg      if test -d "$opt"; then
26599ef0b394Smrg	func_append libdirs " $opt"
26609ef0b394Smrg
26619ef0b394Smrg      elif test -f "$opt"; then
26629ef0b394Smrg	if func_lalib_unsafe_p "$opt"; then
26639ef0b394Smrg	  func_append libs " $opt"
26649ef0b394Smrg	else
26659ef0b394Smrg	  func_warning "\`$opt' is not a valid libtool archive"
26669ef0b394Smrg	fi
26679ef0b394Smrg
26689ef0b394Smrg      else
26699ef0b394Smrg	func_fatal_error "invalid argument \`$opt'"
26709ef0b394Smrg      fi
26719ef0b394Smrg    done
2672266e564dSmrg
26739ef0b394Smrg    if test -n "$libs"; then
26749ef0b394Smrg      if test -n "$lt_sysroot"; then
26759ef0b394Smrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
26769ef0b394Smrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
26779ef0b394Smrg      else
26789ef0b394Smrg        sysroot_cmd=
26799ef0b394Smrg      fi
2680266e564dSmrg
26819ef0b394Smrg      # Remove sysroot references
26829ef0b394Smrg      if $opt_dry_run; then
26839ef0b394Smrg        for lib in $libs; do
26849ef0b394Smrg          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
26859ef0b394Smrg        done
26869ef0b394Smrg      else
26879ef0b394Smrg        tmpdir=`func_mktempdir`
26889ef0b394Smrg        for lib in $libs; do
26899ef0b394Smrg	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
26909ef0b394Smrg	    > $tmpdir/tmp-la
26919ef0b394Smrg	  mv -f $tmpdir/tmp-la $lib
26929ef0b394Smrg	done
26939ef0b394Smrg        ${RM}r "$tmpdir"
26949ef0b394Smrg      fi
26959ef0b394Smrg    fi
2696266e564dSmrg
2697698f425bSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2698698f425bSmrg      for libdir in $libdirs; do
2699698f425bSmrg	if test -n "$finish_cmds"; then
2700698f425bSmrg	  # Do each command in the finish commands.
2701698f425bSmrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
2702698f425bSmrg'"$cmd"'"'
2703266e564dSmrg	fi
2704698f425bSmrg	if test -n "$finish_eval"; then
2705698f425bSmrg	  # Do the single finish_eval.
2706698f425bSmrg	  eval cmds=\"$finish_eval\"
27079ef0b394Smrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
2708698f425bSmrg       $cmds"
2709698f425bSmrg	fi
2710698f425bSmrg      done
2711698f425bSmrg    fi
2712266e564dSmrg
2713698f425bSmrg    # Exit here if they wanted silent mode.
2714698f425bSmrg    $opt_silent && exit $EXIT_SUCCESS
2715266e564dSmrg
27169ef0b394Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
27179ef0b394Smrg      echo "----------------------------------------------------------------------"
27189ef0b394Smrg      echo "Libraries have been installed in:"
27199ef0b394Smrg      for libdir in $libdirs; do
27209ef0b394Smrg	$ECHO "   $libdir"
27219ef0b394Smrg      done
27229ef0b394Smrg      echo
27239ef0b394Smrg      echo "If you ever happen to want to link against installed libraries"
27249ef0b394Smrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
27259ef0b394Smrg      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
27269ef0b394Smrg      echo "flag during linking and do at least one of the following:"
27279ef0b394Smrg      if test -n "$shlibpath_var"; then
27289ef0b394Smrg	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
27299ef0b394Smrg	echo "     during execution"
27309ef0b394Smrg      fi
27319ef0b394Smrg      if test -n "$runpath_var"; then
27329ef0b394Smrg	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
27339ef0b394Smrg	echo "     during linking"
27349ef0b394Smrg      fi
27359ef0b394Smrg      if test -n "$hardcode_libdir_flag_spec"; then
27369ef0b394Smrg	libdir=LIBDIR
27379ef0b394Smrg	eval flag=\"$hardcode_libdir_flag_spec\"
2738266e564dSmrg
27399ef0b394Smrg	$ECHO "   - use the \`$flag' linker flag"
27409ef0b394Smrg      fi
27419ef0b394Smrg      if test -n "$admincmds"; then
27429ef0b394Smrg	$ECHO "   - have your system administrator run these commands:$admincmds"
27439ef0b394Smrg      fi
27449ef0b394Smrg      if test -f /etc/ld.so.conf; then
27459ef0b394Smrg	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
27469ef0b394Smrg      fi
27479ef0b394Smrg      echo
2748698f425bSmrg
27499ef0b394Smrg      echo "See any operating system documentation about shared libraries for"
27509ef0b394Smrg      case $host in
27519ef0b394Smrg	solaris2.[6789]|solaris2.1[0-9])
27529ef0b394Smrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
27539ef0b394Smrg	  echo "pages."
27549ef0b394Smrg	  ;;
27559ef0b394Smrg	*)
27569ef0b394Smrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
27579ef0b394Smrg	  ;;
27589ef0b394Smrg      esac
27599ef0b394Smrg      echo "----------------------------------------------------------------------"
27609ef0b394Smrg    fi
2761698f425bSmrg    exit $EXIT_SUCCESS
2762698f425bSmrg}
2763266e564dSmrg
27649ef0b394Smrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"}
2765266e564dSmrg
2766c5629e66Smrg
2767698f425bSmrg# func_mode_install arg...
2768698f425bSmrgfunc_mode_install ()
2769698f425bSmrg{
2770698f425bSmrg    $opt_debug
2771698f425bSmrg    # There may be an optional sh(1) argument at the beginning of
2772698f425bSmrg    # install_prog (especially on Windows NT).
2773698f425bSmrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
2774698f425bSmrg       # Allow the use of GNU shtool's install command.
27759ef0b394Smrg       case $nonopt in *shtool*) :;; *) false;; esac; then
2776698f425bSmrg      # Aesthetically quote it.
2777698f425bSmrg      func_quote_for_eval "$nonopt"
2778698f425bSmrg      install_prog="$func_quote_for_eval_result "
2779698f425bSmrg      arg=$1
2780698f425bSmrg      shift
2781698f425bSmrg    else
2782698f425bSmrg      install_prog=
2783698f425bSmrg      arg=$nonopt
2784266e564dSmrg    fi
2785266e564dSmrg
2786698f425bSmrg    # The real first argument should be the name of the installation program.
2787698f425bSmrg    # Aesthetically quote it.
2788698f425bSmrg    func_quote_for_eval "$arg"
27899ef0b394Smrg    func_append install_prog "$func_quote_for_eval_result"
27909ef0b394Smrg    install_shared_prog=$install_prog
27919ef0b394Smrg    case " $install_prog " in
27929ef0b394Smrg      *[\\\ /]cp\ *) install_cp=: ;;
27939ef0b394Smrg      *) install_cp=false ;;
27949ef0b394Smrg    esac
2795266e564dSmrg
2796698f425bSmrg    # We need to accept at least all the BSD install flags.
2797698f425bSmrg    dest=
2798698f425bSmrg    files=
2799698f425bSmrg    opts=
2800698f425bSmrg    prev=
2801698f425bSmrg    install_type=
2802698f425bSmrg    isdir=no
2803698f425bSmrg    stripme=
28049ef0b394Smrg    no_mode=:
2805698f425bSmrg    for arg
2806698f425bSmrg    do
28079ef0b394Smrg      arg2=
2808698f425bSmrg      if test -n "$dest"; then
28099ef0b394Smrg	func_append files " $dest"
2810698f425bSmrg	dest=$arg
2811698f425bSmrg	continue
2812698f425bSmrg      fi
2813266e564dSmrg
2814698f425bSmrg      case $arg in
2815698f425bSmrg      -d) isdir=yes ;;
2816698f425bSmrg      -f)
28179ef0b394Smrg	if $install_cp; then :; else
28189ef0b394Smrg	  prev=$arg
28199ef0b394Smrg	fi
2820698f425bSmrg	;;
2821698f425bSmrg      -g | -m | -o)
2822698f425bSmrg	prev=$arg
2823698f425bSmrg	;;
2824698f425bSmrg      -s)
2825698f425bSmrg	stripme=" -s"
2826698f425bSmrg	continue
2827698f425bSmrg	;;
2828698f425bSmrg      -*)
2829698f425bSmrg	;;
2830698f425bSmrg      *)
2831698f425bSmrg	# If the previous option needed an argument, then skip it.
2832698f425bSmrg	if test -n "$prev"; then
28339ef0b394Smrg	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
28349ef0b394Smrg	    arg2=$install_override_mode
28359ef0b394Smrg	    no_mode=false
28369ef0b394Smrg	  fi
2837698f425bSmrg	  prev=
2838698f425bSmrg	else
2839698f425bSmrg	  dest=$arg
2840698f425bSmrg	  continue
2841698f425bSmrg	fi
2842698f425bSmrg	;;
2843698f425bSmrg      esac
2844266e564dSmrg
2845698f425bSmrg      # Aesthetically quote the argument.
2846698f425bSmrg      func_quote_for_eval "$arg"
28479ef0b394Smrg      func_append install_prog " $func_quote_for_eval_result"
28489ef0b394Smrg      if test -n "$arg2"; then
28499ef0b394Smrg	func_quote_for_eval "$arg2"
28509ef0b394Smrg      fi
28519ef0b394Smrg      func_append install_shared_prog " $func_quote_for_eval_result"
2852698f425bSmrg    done
2853698f425bSmrg
2854698f425bSmrg    test -z "$install_prog" && \
2855698f425bSmrg      func_fatal_help "you must specify an install program"
2856698f425bSmrg
2857698f425bSmrg    test -n "$prev" && \
2858698f425bSmrg      func_fatal_help "the \`$prev' option requires an argument"
2859698f425bSmrg
28609ef0b394Smrg    if test -n "$install_override_mode" && $no_mode; then
28619ef0b394Smrg      if $install_cp; then :; else
28629ef0b394Smrg	func_quote_for_eval "$install_override_mode"
28639ef0b394Smrg	func_append install_shared_prog " -m $func_quote_for_eval_result"
28649ef0b394Smrg      fi
28659ef0b394Smrg    fi
28669ef0b394Smrg
2867698f425bSmrg    if test -z "$files"; then
2868698f425bSmrg      if test -z "$dest"; then
2869698f425bSmrg	func_fatal_help "no file or destination specified"
2870698f425bSmrg      else
2871698f425bSmrg	func_fatal_help "you must specify a destination"
2872266e564dSmrg      fi
2873266e564dSmrg    fi
2874266e564dSmrg
2875698f425bSmrg    # Strip any trailing slash from the destination.
2876698f425bSmrg    func_stripname '' '/' "$dest"
2877698f425bSmrg    dest=$func_stripname_result
2878266e564dSmrg
2879698f425bSmrg    # Check to see that the destination is a directory.
2880698f425bSmrg    test -d "$dest" && isdir=yes
2881698f425bSmrg    if test "$isdir" = yes; then
2882698f425bSmrg      destdir="$dest"
2883698f425bSmrg      destname=
2884698f425bSmrg    else
2885698f425bSmrg      func_dirname_and_basename "$dest" "" "."
2886698f425bSmrg      destdir="$func_dirname_result"
2887698f425bSmrg      destname="$func_basename_result"
2888698f425bSmrg
2889698f425bSmrg      # Not a directory, so check to see that there is only one file specified.
2890698f425bSmrg      set dummy $files; shift
2891698f425bSmrg      test "$#" -gt 1 && \
2892698f425bSmrg	func_fatal_help "\`$dest' is not a directory"
2893698f425bSmrg    fi
2894698f425bSmrg    case $destdir in
2895698f425bSmrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
2896266e564dSmrg    *)
2897698f425bSmrg      for file in $files; do
2898698f425bSmrg	case $file in
2899698f425bSmrg	*.lo) ;;
2900698f425bSmrg	*)
2901698f425bSmrg	  func_fatal_help "\`$destdir' must be an absolute directory name"
2902698f425bSmrg	  ;;
2903698f425bSmrg	esac
2904698f425bSmrg      done
2905266e564dSmrg      ;;
2906266e564dSmrg    esac
2907266e564dSmrg
2908698f425bSmrg    # This variable tells wrapper scripts just to set variables rather
2909698f425bSmrg    # than running their programs.
2910698f425bSmrg    libtool_install_magic="$magic"
2911266e564dSmrg
2912698f425bSmrg    staticlibs=
2913698f425bSmrg    future_libdirs=
2914698f425bSmrg    current_libdirs=
2915698f425bSmrg    for file in $files; do
2916266e564dSmrg
2917698f425bSmrg      # Do each installation.
2918698f425bSmrg      case $file in
2919698f425bSmrg      *.$libext)
2920698f425bSmrg	# Do the static libraries later.
29219ef0b394Smrg	func_append staticlibs " $file"
2922698f425bSmrg	;;
2923698f425bSmrg
2924698f425bSmrg      *.la)
29259ef0b394Smrg	func_resolve_sysroot "$file"
29269ef0b394Smrg	file=$func_resolve_sysroot_result
29279ef0b394Smrg
2928698f425bSmrg	# Check to see that this really is a libtool archive.
2929698f425bSmrg	func_lalib_unsafe_p "$file" \
2930698f425bSmrg	  || func_fatal_help "\`$file' is not a valid libtool archive"
2931698f425bSmrg
2932698f425bSmrg	library_names=
2933698f425bSmrg	old_library=
2934698f425bSmrg	relink_command=
2935698f425bSmrg	func_source "$file"
2936698f425bSmrg
2937698f425bSmrg	# Add the libdir to current_libdirs if it is the destination.
2938698f425bSmrg	if test "X$destdir" = "X$libdir"; then
2939698f425bSmrg	  case "$current_libdirs " in
2940698f425bSmrg	  *" $libdir "*) ;;
29419ef0b394Smrg	  *) func_append current_libdirs " $libdir" ;;
2942266e564dSmrg	  esac
2943698f425bSmrg	else
2944698f425bSmrg	  # Note the libdir as a future libdir.
2945698f425bSmrg	  case "$future_libdirs " in
2946698f425bSmrg	  *" $libdir "*) ;;
29479ef0b394Smrg	  *) func_append future_libdirs " $libdir" ;;
2948698f425bSmrg	  esac
2949698f425bSmrg	fi
2950266e564dSmrg
2951698f425bSmrg	func_dirname "$file" "/" ""
2952698f425bSmrg	dir="$func_dirname_result"
29539ef0b394Smrg	func_append dir "$objdir"
2954698f425bSmrg
2955698f425bSmrg	if test -n "$relink_command"; then
2956698f425bSmrg	  # Determine the prefix the user has applied to our future dir.
29579ef0b394Smrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
2958698f425bSmrg
2959698f425bSmrg	  # Don't allow the user to place us outside of our expected
2960698f425bSmrg	  # location b/c this prevents finding dependent libraries that
2961698f425bSmrg	  # are installed to the same prefix.
2962698f425bSmrg	  # At present, this check doesn't affect windows .dll's that
2963698f425bSmrg	  # are installed into $libdir/../bin (currently, that works fine)
2964698f425bSmrg	  # but it's something to keep an eye on.
2965698f425bSmrg	  test "$inst_prefix_dir" = "$destdir" && \
2966698f425bSmrg	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2967698f425bSmrg
2968698f425bSmrg	  if test -n "$inst_prefix_dir"; then
2969698f425bSmrg	    # Stick the inst_prefix_dir data into the link command.
29709ef0b394Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2971698f425bSmrg	  else
29729ef0b394Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
2973698f425bSmrg	  fi
2974698f425bSmrg
2975698f425bSmrg	  func_warning "relinking \`$file'"
2976698f425bSmrg	  func_show_eval "$relink_command" \
2977698f425bSmrg	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2978698f425bSmrg	fi
2979698f425bSmrg
2980698f425bSmrg	# See the names of the shared library.
2981698f425bSmrg	set dummy $library_names; shift
2982698f425bSmrg	if test -n "$1"; then
2983698f425bSmrg	  realname="$1"
2984698f425bSmrg	  shift
2985698f425bSmrg
2986698f425bSmrg	  srcname="$realname"
2987698f425bSmrg	  test -n "$relink_command" && srcname="$realname"T
2988698f425bSmrg
2989698f425bSmrg	  # Install the shared library and build the symlinks.
29909ef0b394Smrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
2991698f425bSmrg	      'exit $?'
2992698f425bSmrg	  tstripme="$stripme"
2993698f425bSmrg	  case $host_os in
2994698f425bSmrg	  cygwin* | mingw* | pw32* | cegcc*)
2995698f425bSmrg	    case $realname in
2996698f425bSmrg	    *.dll.a)
2997698f425bSmrg	      tstripme=""
2998698f425bSmrg	      ;;
2999698f425bSmrg	    esac
3000266e564dSmrg	    ;;
3001266e564dSmrg	  esac
3002698f425bSmrg	  if test -n "$tstripme" && test -n "$striplib"; then
3003698f425bSmrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
3004c5629e66Smrg	  fi
3005698f425bSmrg
3006698f425bSmrg	  if test "$#" -gt 0; then
3007698f425bSmrg	    # Delete the old symlinks, and create new ones.
3008698f425bSmrg	    # Try `ln -sf' first, because the `ln' binary might depend on
3009698f425bSmrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
3010698f425bSmrg	    # so we also need to try rm && ln -s.
3011698f425bSmrg	    for linkname
3012698f425bSmrg	    do
3013698f425bSmrg	      test "$linkname" != "$realname" \
3014698f425bSmrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
3015266e564dSmrg	    done
3016266e564dSmrg	  fi
3017266e564dSmrg
3018698f425bSmrg	  # Do each command in the postinstall commands.
3019698f425bSmrg	  lib="$destdir/$realname"
3020698f425bSmrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
3021266e564dSmrg	fi
3022266e564dSmrg
3023698f425bSmrg	# Install the pseudo-library for information purposes.
3024698f425bSmrg	func_basename "$file"
3025698f425bSmrg	name="$func_basename_result"
3026698f425bSmrg	instname="$dir/$name"i
3027698f425bSmrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
3028266e564dSmrg
3029698f425bSmrg	# Maybe install the static library, too.
30309ef0b394Smrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
3031698f425bSmrg	;;
3032266e564dSmrg
3033698f425bSmrg      *.lo)
3034698f425bSmrg	# Install (i.e. copy) a libtool object.
3035266e564dSmrg
3036698f425bSmrg	# Figure out destination file name, if it wasn't already specified.
3037698f425bSmrg	if test -n "$destname"; then
3038698f425bSmrg	  destfile="$destdir/$destname"
3039698f425bSmrg	else
3040698f425bSmrg	  func_basename "$file"
3041698f425bSmrg	  destfile="$func_basename_result"
3042698f425bSmrg	  destfile="$destdir/$destfile"
3043698f425bSmrg	fi
3044698f425bSmrg
3045698f425bSmrg	# Deduce the name of the destination old-style object file.
3046698f425bSmrg	case $destfile in
3047698f425bSmrg	*.lo)
3048698f425bSmrg	  func_lo2o "$destfile"
3049698f425bSmrg	  staticdest=$func_lo2o_result
3050698f425bSmrg	  ;;
3051698f425bSmrg	*.$objext)
3052698f425bSmrg	  staticdest="$destfile"
3053698f425bSmrg	  destfile=
3054698f425bSmrg	  ;;
3055698f425bSmrg	*)
3056698f425bSmrg	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
3057698f425bSmrg	  ;;
3058266e564dSmrg	esac
3059266e564dSmrg
3060698f425bSmrg	# Install the libtool object if requested.
3061698f425bSmrg	test -n "$destfile" && \
3062698f425bSmrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
3063698f425bSmrg
3064698f425bSmrg	# Install the old object if enabled.
3065698f425bSmrg	if test "$build_old_libs" = yes; then
3066698f425bSmrg	  # Deduce the name of the old-style object file.
3067698f425bSmrg	  func_lo2o "$file"
3068698f425bSmrg	  staticobj=$func_lo2o_result
3069698f425bSmrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
3070266e564dSmrg	fi
3071698f425bSmrg	exit $EXIT_SUCCESS
3072698f425bSmrg	;;
3073266e564dSmrg
3074698f425bSmrg      *)
3075698f425bSmrg	# Figure out destination file name, if it wasn't already specified.
3076698f425bSmrg	if test -n "$destname"; then
3077698f425bSmrg	  destfile="$destdir/$destname"
3078698f425bSmrg	else
3079698f425bSmrg	  func_basename "$file"
3080698f425bSmrg	  destfile="$func_basename_result"
3081698f425bSmrg	  destfile="$destdir/$destfile"
3082698f425bSmrg	fi
3083266e564dSmrg
3084698f425bSmrg	# If the file is missing, and there is a .exe on the end, strip it
3085698f425bSmrg	# because it is most likely a libtool script we actually want to
3086698f425bSmrg	# install
3087698f425bSmrg	stripped_ext=""
3088698f425bSmrg	case $file in
3089698f425bSmrg	  *.exe)
3090698f425bSmrg	    if test ! -f "$file"; then
3091698f425bSmrg	      func_stripname '' '.exe' "$file"
3092698f425bSmrg	      file=$func_stripname_result
3093698f425bSmrg	      stripped_ext=".exe"
3094698f425bSmrg	    fi
3095698f425bSmrg	    ;;
3096698f425bSmrg	esac
3097266e564dSmrg
3098698f425bSmrg	# Do a test to see if this is really a libtool program.
3099698f425bSmrg	case $host in
3100698f425bSmrg	*cygwin* | *mingw*)
3101698f425bSmrg	    if func_ltwrapper_executable_p "$file"; then
3102698f425bSmrg	      func_ltwrapper_scriptname "$file"
3103698f425bSmrg	      wrapper=$func_ltwrapper_scriptname_result
3104698f425bSmrg	    else
3105698f425bSmrg	      func_stripname '' '.exe' "$file"
3106698f425bSmrg	      wrapper=$func_stripname_result
3107698f425bSmrg	    fi
3108698f425bSmrg	    ;;
3109698f425bSmrg	*)
3110698f425bSmrg	    wrapper=$file
3111698f425bSmrg	    ;;
3112698f425bSmrg	esac
3113698f425bSmrg	if func_ltwrapper_script_p "$wrapper"; then
3114698f425bSmrg	  notinst_deplibs=
3115698f425bSmrg	  relink_command=
3116266e564dSmrg
3117698f425bSmrg	  func_source "$wrapper"
3118698f425bSmrg
3119698f425bSmrg	  # Check the variables that should have been set.
3120698f425bSmrg	  test -z "$generated_by_libtool_version" && \
3121698f425bSmrg	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
3122698f425bSmrg
3123698f425bSmrg	  finalize=yes
3124698f425bSmrg	  for lib in $notinst_deplibs; do
3125698f425bSmrg	    # Check to see that each library is installed.
3126698f425bSmrg	    libdir=
3127698f425bSmrg	    if test -f "$lib"; then
3128698f425bSmrg	      func_source "$lib"
3129698f425bSmrg	    fi
31309ef0b394Smrg	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
3131698f425bSmrg	    if test -n "$libdir" && test ! -f "$libfile"; then
3132698f425bSmrg	      func_warning "\`$lib' has not been installed in \`$libdir'"
3133698f425bSmrg	      finalize=no
3134698f425bSmrg	    fi
3135698f425bSmrg	  done
3136698f425bSmrg
3137698f425bSmrg	  relink_command=
3138698f425bSmrg	  func_source "$wrapper"
3139698f425bSmrg
3140698f425bSmrg	  outputname=
3141698f425bSmrg	  if test "$fast_install" = no && test -n "$relink_command"; then
3142698f425bSmrg	    $opt_dry_run || {
3143698f425bSmrg	      if test "$finalize" = yes; then
3144698f425bSmrg	        tmpdir=`func_mktempdir`
3145698f425bSmrg		func_basename "$file$stripped_ext"
3146698f425bSmrg		file="$func_basename_result"
3147698f425bSmrg	        outputname="$tmpdir/$file"
3148698f425bSmrg	        # Replace the output file specification.
31499ef0b394Smrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
3150698f425bSmrg
3151698f425bSmrg	        $opt_silent || {
3152698f425bSmrg	          func_quote_for_expand "$relink_command"
3153698f425bSmrg		  eval "func_echo $func_quote_for_expand_result"
3154698f425bSmrg	        }
3155698f425bSmrg	        if eval "$relink_command"; then :
3156698f425bSmrg	          else
3157698f425bSmrg		  func_error "error: relink \`$file' with the above command before installing it"
3158698f425bSmrg		  $opt_dry_run || ${RM}r "$tmpdir"
3159698f425bSmrg		  continue
3160698f425bSmrg	        fi
3161698f425bSmrg	        file="$outputname"
3162698f425bSmrg	      else
3163698f425bSmrg	        func_warning "cannot relink \`$file'"
3164698f425bSmrg	      fi
3165698f425bSmrg	    }
3166266e564dSmrg	  else
3167698f425bSmrg	    # Install the binary that we compiled earlier.
31689ef0b394Smrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
3169266e564dSmrg	  fi
3170698f425bSmrg	fi
3171266e564dSmrg
3172698f425bSmrg	# remove .exe since cygwin /usr/bin/install will append another
3173698f425bSmrg	# one anyway
3174698f425bSmrg	case $install_prog,$host in
3175698f425bSmrg	*/usr/bin/install*,*cygwin*)
3176698f425bSmrg	  case $file:$destfile in
3177698f425bSmrg	  *.exe:*.exe)
3178698f425bSmrg	    # this is ok
3179698f425bSmrg	    ;;
3180698f425bSmrg	  *.exe:*)
3181698f425bSmrg	    destfile=$destfile.exe
3182698f425bSmrg	    ;;
3183698f425bSmrg	  *:*.exe)
3184698f425bSmrg	    func_stripname '' '.exe' "$destfile"
3185698f425bSmrg	    destfile=$func_stripname_result
3186698f425bSmrg	    ;;
3187698f425bSmrg	  esac
3188266e564dSmrg	  ;;
3189266e564dSmrg	esac
3190698f425bSmrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
3191698f425bSmrg	$opt_dry_run || if test -n "$outputname"; then
3192698f425bSmrg	  ${RM}r "$tmpdir"
3193698f425bSmrg	fi
3194698f425bSmrg	;;
3195698f425bSmrg      esac
3196698f425bSmrg    done
3197266e564dSmrg
3198698f425bSmrg    for file in $staticlibs; do
3199698f425bSmrg      func_basename "$file"
3200698f425bSmrg      name="$func_basename_result"
3201698f425bSmrg
3202698f425bSmrg      # Set up the ranlib parameters.
3203698f425bSmrg      oldlib="$destdir/$name"
3204698f425bSmrg
3205698f425bSmrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
3206698f425bSmrg
3207698f425bSmrg      if test -n "$stripme" && test -n "$old_striplib"; then
3208698f425bSmrg	func_show_eval "$old_striplib $oldlib" 'exit $?'
3209698f425bSmrg      fi
3210698f425bSmrg
3211698f425bSmrg      # Do each command in the postinstall commands.
3212698f425bSmrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
3213698f425bSmrg    done
3214698f425bSmrg
3215698f425bSmrg    test -n "$future_libdirs" && \
3216698f425bSmrg      func_warning "remember to run \`$progname --finish$future_libdirs'"
3217698f425bSmrg
3218698f425bSmrg    if test -n "$current_libdirs"; then
3219698f425bSmrg      # Maybe just do a dry run.
3220698f425bSmrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
3221698f425bSmrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
3222698f425bSmrg    else
3223698f425bSmrg      exit $EXIT_SUCCESS
3224698f425bSmrg    fi
3225698f425bSmrg}
3226698f425bSmrg
32279ef0b394Smrgtest "$opt_mode" = install && func_mode_install ${1+"$@"}
3228698f425bSmrg
3229698f425bSmrg
3230698f425bSmrg# func_generate_dlsyms outputname originator pic_p
3231698f425bSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with
3232698f425bSmrg# a dlpreopen symbol table.
3233698f425bSmrgfunc_generate_dlsyms ()
3234698f425bSmrg{
3235698f425bSmrg    $opt_debug
3236698f425bSmrg    my_outputname="$1"
3237698f425bSmrg    my_originator="$2"
3238698f425bSmrg    my_pic_p="${3-no}"
3239698f425bSmrg    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
3240698f425bSmrg    my_dlsyms=
3241698f425bSmrg
3242698f425bSmrg    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
3243698f425bSmrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
3244698f425bSmrg	my_dlsyms="${my_outputname}S.c"
3245698f425bSmrg      else
3246698f425bSmrg	func_error "not configured to extract global symbols from dlpreopened files"
3247698f425bSmrg      fi
3248698f425bSmrg    fi
3249698f425bSmrg
3250698f425bSmrg    if test -n "$my_dlsyms"; then
3251698f425bSmrg      case $my_dlsyms in
3252698f425bSmrg      "") ;;
3253698f425bSmrg      *.c)
3254698f425bSmrg	# Discover the nlist of each of the dlfiles.
3255698f425bSmrg	nlist="$output_objdir/${my_outputname}.nm"
3256698f425bSmrg
3257698f425bSmrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
3258698f425bSmrg
3259698f425bSmrg	# Parse the name list into a source file.
3260698f425bSmrg	func_verbose "creating $output_objdir/$my_dlsyms"
3261698f425bSmrg
3262698f425bSmrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
3263698f425bSmrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
3264698f425bSmrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
3265698f425bSmrg
3266698f425bSmrg#ifdef __cplusplus
3267698f425bSmrgextern \"C\" {
3268698f425bSmrg#endif
3269698f425bSmrg
32709ef0b394Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
32719ef0b394Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
32729ef0b394Smrg#endif
32739ef0b394Smrg
32749ef0b394Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
32759ef0b394Smrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
32769ef0b394Smrg/* DATA imports from DLLs on WIN32 con't be const, because runtime
32779ef0b394Smrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
32789ef0b394Smrg# define LT_DLSYM_CONST
32799ef0b394Smrg#elif defined(__osf__)
32809ef0b394Smrg/* This system does not cope well with relocations in const data.  */
32819ef0b394Smrg# define LT_DLSYM_CONST
32829ef0b394Smrg#else
32839ef0b394Smrg# define LT_DLSYM_CONST const
32849ef0b394Smrg#endif
32859ef0b394Smrg
3286698f425bSmrg/* External symbol declarations for the compiler. */\
3287698f425bSmrg"
3288698f425bSmrg
3289698f425bSmrg	if test "$dlself" = yes; then
3290698f425bSmrg	  func_verbose "generating symbol list for \`$output'"
3291698f425bSmrg
3292698f425bSmrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
3293698f425bSmrg
3294698f425bSmrg	  # Add our own program objects to the symbol list.
32959ef0b394Smrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
3296698f425bSmrg	  for progfile in $progfiles; do
32979ef0b394Smrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
32989ef0b394Smrg	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
32999ef0b394Smrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
3300698f425bSmrg	  done
3301698f425bSmrg
3302698f425bSmrg	  if test -n "$exclude_expsyms"; then
3303698f425bSmrg	    $opt_dry_run || {
3304698f425bSmrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
3305698f425bSmrg	      eval '$MV "$nlist"T "$nlist"'
3306698f425bSmrg	    }
3307266e564dSmrg	  fi
3308698f425bSmrg
3309698f425bSmrg	  if test -n "$export_symbols_regex"; then
3310698f425bSmrg	    $opt_dry_run || {
3311698f425bSmrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
3312698f425bSmrg	      eval '$MV "$nlist"T "$nlist"'
3313698f425bSmrg	    }
3314698f425bSmrg	  fi
3315698f425bSmrg
3316698f425bSmrg	  # Prepare the list of exported symbols
3317698f425bSmrg	  if test -z "$export_symbols"; then
3318698f425bSmrg	    export_symbols="$output_objdir/$outputname.exp"
3319698f425bSmrg	    $opt_dry_run || {
3320698f425bSmrg	      $RM $export_symbols
3321698f425bSmrg	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
3322698f425bSmrg	      case $host in
3323698f425bSmrg	      *cygwin* | *mingw* | *cegcc* )
3324698f425bSmrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3325698f425bSmrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
3326698f425bSmrg	        ;;
3327698f425bSmrg	      esac
3328698f425bSmrg	    }
3329266e564dSmrg	  else
3330698f425bSmrg	    $opt_dry_run || {
3331698f425bSmrg	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
3332698f425bSmrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
3333698f425bSmrg	      eval '$MV "$nlist"T "$nlist"'
3334698f425bSmrg	      case $host in
33359ef0b394Smrg	        *cygwin* | *mingw* | *cegcc* )
3336698f425bSmrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3337698f425bSmrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
3338698f425bSmrg	          ;;
3339698f425bSmrg	      esac
3340698f425bSmrg	    }
3341266e564dSmrg	  fi
3342698f425bSmrg	fi
3343266e564dSmrg
3344698f425bSmrg	for dlprefile in $dlprefiles; do
3345698f425bSmrg	  func_verbose "extracting global C symbols from \`$dlprefile'"
3346698f425bSmrg	  func_basename "$dlprefile"
3347698f425bSmrg	  name="$func_basename_result"
33489ef0b394Smrg          case $host in
33499ef0b394Smrg	    *cygwin* | *mingw* | *cegcc* )
33509ef0b394Smrg	      # if an import library, we need to obtain dlname
33519ef0b394Smrg	      if func_win32_import_lib_p "$dlprefile"; then
33529ef0b394Smrg	        func_tr_sh "$dlprefile"
33539ef0b394Smrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
33549ef0b394Smrg	        dlprefile_dlbasename=""
33559ef0b394Smrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
33569ef0b394Smrg	          # Use subshell, to avoid clobbering current variable values
33579ef0b394Smrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
33589ef0b394Smrg	          if test -n "$dlprefile_dlname" ; then
33599ef0b394Smrg	            func_basename "$dlprefile_dlname"
33609ef0b394Smrg	            dlprefile_dlbasename="$func_basename_result"
33619ef0b394Smrg	          else
33629ef0b394Smrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
33639ef0b394Smrg	            $sharedlib_from_linklib_cmd "$dlprefile"
33649ef0b394Smrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
33659ef0b394Smrg	          fi
33669ef0b394Smrg	        fi
33679ef0b394Smrg	        $opt_dry_run || {
33689ef0b394Smrg	          if test -n "$dlprefile_dlbasename" ; then
33699ef0b394Smrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
33709ef0b394Smrg	          else
33719ef0b394Smrg	            func_warning "Could not compute DLL name from $name"
33729ef0b394Smrg	            eval '$ECHO ": $name " >> "$nlist"'
33739ef0b394Smrg	          fi
33749ef0b394Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
33759ef0b394Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
33769ef0b394Smrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
33779ef0b394Smrg	        }
33789ef0b394Smrg	      else # not an import lib
33799ef0b394Smrg	        $opt_dry_run || {
33809ef0b394Smrg	          eval '$ECHO ": $name " >> "$nlist"'
33819ef0b394Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
33829ef0b394Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
33839ef0b394Smrg	        }
33849ef0b394Smrg	      fi
33859ef0b394Smrg	    ;;
33869ef0b394Smrg	    *)
33879ef0b394Smrg	      $opt_dry_run || {
33889ef0b394Smrg	        eval '$ECHO ": $name " >> "$nlist"'
33899ef0b394Smrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
33909ef0b394Smrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
33919ef0b394Smrg	      }
33929ef0b394Smrg	    ;;
33939ef0b394Smrg          esac
3394698f425bSmrg	done
3395698f425bSmrg
3396698f425bSmrg	$opt_dry_run || {
3397698f425bSmrg	  # Make sure we have at least an empty file.
3398698f425bSmrg	  test -f "$nlist" || : > "$nlist"
3399698f425bSmrg
3400698f425bSmrg	  if test -n "$exclude_expsyms"; then
3401698f425bSmrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
3402698f425bSmrg	    $MV "$nlist"T "$nlist"
3403266e564dSmrg	  fi
3404698f425bSmrg
3405698f425bSmrg	  # Try sorting and uniquifying the output.
3406698f425bSmrg	  if $GREP -v "^: " < "$nlist" |
3407698f425bSmrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
3408698f425bSmrg		sort -k 3
3409698f425bSmrg	      else
3410698f425bSmrg		sort +2
3411698f425bSmrg	      fi |
3412698f425bSmrg	      uniq > "$nlist"S; then
3413698f425bSmrg	    :
3414266e564dSmrg	  else
3415698f425bSmrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
3416266e564dSmrg	  fi
3417266e564dSmrg
3418698f425bSmrg	  if test -f "$nlist"S; then
3419698f425bSmrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
3420266e564dSmrg	  else
34219ef0b394Smrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
3422266e564dSmrg	  fi
3423266e564dSmrg
34249ef0b394Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
3425266e564dSmrg
3426698f425bSmrg/* The mapping between symbol names and symbols.  */
3427698f425bSmrgtypedef struct {
3428698f425bSmrg  const char *name;
3429698f425bSmrg  void *address;
3430698f425bSmrg} lt_dlsymlist;
34319ef0b394Smrgextern LT_DLSYM_CONST lt_dlsymlist
3432698f425bSmrglt_${my_prefix}_LTX_preloaded_symbols[];
34339ef0b394SmrgLT_DLSYM_CONST lt_dlsymlist
3434698f425bSmrglt_${my_prefix}_LTX_preloaded_symbols[] =
3435698f425bSmrg{\
3436698f425bSmrg  { \"$my_originator\", (void *) 0 },"
3437266e564dSmrg
3438698f425bSmrg	  case $need_lib_prefix in
3439698f425bSmrg	  no)
3440698f425bSmrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
3441698f425bSmrg	    ;;
3442698f425bSmrg	  *)
3443698f425bSmrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
3444698f425bSmrg	    ;;
3445698f425bSmrg	  esac
34469ef0b394Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
3447698f425bSmrg  {0, (void *) 0}
3448698f425bSmrg};
3449266e564dSmrg
3450698f425bSmrg/* This works around a problem in FreeBSD linker */
3451698f425bSmrg#ifdef FREEBSD_WORKAROUND
3452698f425bSmrgstatic const void *lt_preloaded_setup() {
3453698f425bSmrg  return lt_${my_prefix}_LTX_preloaded_symbols;
3454698f425bSmrg}
3455698f425bSmrg#endif
3456698f425bSmrg
3457698f425bSmrg#ifdef __cplusplus
3458698f425bSmrg}
3459698f425bSmrg#endif\
3460698f425bSmrg"
3461698f425bSmrg	} # !$opt_dry_run
3462698f425bSmrg
3463698f425bSmrg	pic_flag_for_symtable=
3464698f425bSmrg	case "$compile_command " in
3465698f425bSmrg	*" -static "*) ;;
3466698f425bSmrg	*)
3467698f425bSmrg	  case $host in
3468698f425bSmrg	  # compiling the symbol table file with pic_flag works around
3469698f425bSmrg	  # a FreeBSD bug that causes programs to crash when -lm is
3470698f425bSmrg	  # linked before any other PIC object.  But we must not use
3471698f425bSmrg	  # pic_flag when linking with -static.  The problem exists in
3472698f425bSmrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
3473698f425bSmrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
3474698f425bSmrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
3475698f425bSmrg	  *-*-hpux*)
3476698f425bSmrg	    pic_flag_for_symtable=" $pic_flag"  ;;
3477698f425bSmrg	  *)
3478698f425bSmrg	    if test "X$my_pic_p" != Xno; then
3479698f425bSmrg	      pic_flag_for_symtable=" $pic_flag"
3480266e564dSmrg	    fi
3481698f425bSmrg	    ;;
3482698f425bSmrg	  esac
3483698f425bSmrg	  ;;
3484698f425bSmrg	esac
3485698f425bSmrg	symtab_cflags=
3486698f425bSmrg	for arg in $LTCFLAGS; do
3487698f425bSmrg	  case $arg in
3488698f425bSmrg	  -pie | -fpie | -fPIE) ;;
34899ef0b394Smrg	  *) func_append symtab_cflags " $arg" ;;
3490698f425bSmrg	  esac
3491698f425bSmrg	done
3492266e564dSmrg
3493698f425bSmrg	# Now compile the dynamic symbol file.
3494698f425bSmrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
3495266e564dSmrg
3496698f425bSmrg	# Clean up the generated files.
3497698f425bSmrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
3498266e564dSmrg
3499698f425bSmrg	# Transform the symbol file into the correct name.
3500698f425bSmrg	symfileobj="$output_objdir/${my_outputname}S.$objext"
3501698f425bSmrg	case $host in
3502698f425bSmrg	*cygwin* | *mingw* | *cegcc* )
3503698f425bSmrg	  if test -f "$output_objdir/$my_outputname.def"; then
35049ef0b394Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
35059ef0b394Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3506698f425bSmrg	  else
35079ef0b394Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
35089ef0b394Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3509266e564dSmrg	  fi
3510698f425bSmrg	  ;;
3511698f425bSmrg	*)
35129ef0b394Smrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
35139ef0b394Smrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3514698f425bSmrg	  ;;
3515698f425bSmrg	esac
3516698f425bSmrg	;;
3517698f425bSmrg      *)
3518698f425bSmrg	func_fatal_error "unknown suffix for \`$my_dlsyms'"
3519698f425bSmrg	;;
3520698f425bSmrg      esac
3521698f425bSmrg    else
3522698f425bSmrg      # We keep going just in case the user didn't refer to
3523698f425bSmrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
3524698f425bSmrg      # really was required.
3525266e564dSmrg
3526698f425bSmrg      # Nullify the symbol file.
35279ef0b394Smrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
35289ef0b394Smrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
3529698f425bSmrg    fi
3530698f425bSmrg}
3531266e564dSmrg
3532698f425bSmrg# func_win32_libid arg
3533698f425bSmrg# return the library type of file 'arg'
3534698f425bSmrg#
3535698f425bSmrg# Need a lot of goo to handle *both* DLLs and import libs
3536698f425bSmrg# Has to be a shell function in order to 'eat' the argument
3537698f425bSmrg# that is supplied when $file_magic_command is called.
35389ef0b394Smrg# Despite the name, also deal with 64 bit binaries.
3539698f425bSmrgfunc_win32_libid ()
3540698f425bSmrg{
3541698f425bSmrg  $opt_debug
3542698f425bSmrg  win32_libid_type="unknown"
3543698f425bSmrg  win32_fileres=`file -L $1 2>/dev/null`
3544698f425bSmrg  case $win32_fileres in
3545698f425bSmrg  *ar\ archive\ import\ library*) # definitely import
3546698f425bSmrg    win32_libid_type="x86 archive import"
3547698f425bSmrg    ;;
3548698f425bSmrg  *ar\ archive*) # could be an import, or static
35499ef0b394Smrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
3550698f425bSmrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
35519ef0b394Smrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
35529ef0b394Smrg      func_to_tool_file "$1" func_convert_file_msys_to_w32
35539ef0b394Smrg      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
3554698f425bSmrg	$SED -n -e '
3555698f425bSmrg	    1,100{
3556698f425bSmrg		/ I /{
3557698f425bSmrg		    s,.*,import,
3558698f425bSmrg		    p
3559698f425bSmrg		    q
3560698f425bSmrg		}
3561698f425bSmrg	    }'`
3562698f425bSmrg      case $win32_nmres in
3563698f425bSmrg      import*)  win32_libid_type="x86 archive import";;
3564698f425bSmrg      *)        win32_libid_type="x86 archive static";;
3565698f425bSmrg      esac
3566698f425bSmrg    fi
3567698f425bSmrg    ;;
3568698f425bSmrg  *DLL*)
3569698f425bSmrg    win32_libid_type="x86 DLL"
3570698f425bSmrg    ;;
3571698f425bSmrg  *executable*) # but shell scripts are "executable" too...
3572698f425bSmrg    case $win32_fileres in
3573698f425bSmrg    *MS\ Windows\ PE\ Intel*)
3574698f425bSmrg      win32_libid_type="x86 DLL"
3575698f425bSmrg      ;;
3576698f425bSmrg    esac
3577698f425bSmrg    ;;
3578698f425bSmrg  esac
3579698f425bSmrg  $ECHO "$win32_libid_type"
3580698f425bSmrg}
3581266e564dSmrg
35829ef0b394Smrg# func_cygming_dll_for_implib ARG
35839ef0b394Smrg#
35849ef0b394Smrg# Platform-specific function to extract the
35859ef0b394Smrg# name of the DLL associated with the specified
35869ef0b394Smrg# import library ARG.
35879ef0b394Smrg# Invoked by eval'ing the libtool variable
35889ef0b394Smrg#    $sharedlib_from_linklib_cmd
35899ef0b394Smrg# Result is available in the variable
35909ef0b394Smrg#    $sharedlib_from_linklib_result
35919ef0b394Smrgfunc_cygming_dll_for_implib ()
35929ef0b394Smrg{
35939ef0b394Smrg  $opt_debug
35949ef0b394Smrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
35959ef0b394Smrg}
35969ef0b394Smrg
35979ef0b394Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
35989ef0b394Smrg#
35999ef0b394Smrg# The is the core of a fallback implementation of a
36009ef0b394Smrg# platform-specific function to extract the name of the
36019ef0b394Smrg# DLL associated with the specified import library LIBNAME.
36029ef0b394Smrg#
36039ef0b394Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending
36049ef0b394Smrg# on the platform and compiler that created the implib.
36059ef0b394Smrg#
36069ef0b394Smrg# Echos the name of the DLL associated with the
36079ef0b394Smrg# specified import library.
36089ef0b394Smrgfunc_cygming_dll_for_implib_fallback_core ()
36099ef0b394Smrg{
36109ef0b394Smrg  $opt_debug
36119ef0b394Smrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
36129ef0b394Smrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
36139ef0b394Smrg    $SED '/^Contents of section '"$match_literal"':/{
36149ef0b394Smrg      # Place marker at beginning of archive member dllname section
36159ef0b394Smrg      s/.*/====MARK====/
36169ef0b394Smrg      p
36179ef0b394Smrg      d
36189ef0b394Smrg    }
36199ef0b394Smrg    # These lines can sometimes be longer than 43 characters, but
36209ef0b394Smrg    # are always uninteresting
36219ef0b394Smrg    /:[	 ]*file format pe[i]\{,1\}-/d
36229ef0b394Smrg    /^In archive [^:]*:/d
36239ef0b394Smrg    # Ensure marker is printed
36249ef0b394Smrg    /^====MARK====/p
36259ef0b394Smrg    # Remove all lines with less than 43 characters
36269ef0b394Smrg    /^.\{43\}/!d
36279ef0b394Smrg    # From remaining lines, remove first 43 characters
36289ef0b394Smrg    s/^.\{43\}//' |
36299ef0b394Smrg    $SED -n '
36309ef0b394Smrg      # Join marker and all lines until next marker into a single line
36319ef0b394Smrg      /^====MARK====/ b para
36329ef0b394Smrg      H
36339ef0b394Smrg      $ b para
36349ef0b394Smrg      b
36359ef0b394Smrg      :para
36369ef0b394Smrg      x
36379ef0b394Smrg      s/\n//g
36389ef0b394Smrg      # Remove the marker
36399ef0b394Smrg      s/^====MARK====//
36409ef0b394Smrg      # Remove trailing dots and whitespace
36419ef0b394Smrg      s/[\. \t]*$//
36429ef0b394Smrg      # Print
36439ef0b394Smrg      /./p' |
36449ef0b394Smrg    # we now have a list, one entry per line, of the stringified
36459ef0b394Smrg    # contents of the appropriate section of all members of the
36469ef0b394Smrg    # archive which possess that section. Heuristic: eliminate
36479ef0b394Smrg    # all those which have a first or second character that is
36489ef0b394Smrg    # a '.' (that is, objdump's representation of an unprintable
36499ef0b394Smrg    # character.) This should work for all archives with less than
36509ef0b394Smrg    # 0x302f exports -- but will fail for DLLs whose name actually
36519ef0b394Smrg    # begins with a literal '.' or a single character followed by
36529ef0b394Smrg    # a '.'.
36539ef0b394Smrg    #
36549ef0b394Smrg    # Of those that remain, print the first one.
36559ef0b394Smrg    $SED -e '/^\./d;/^.\./d;q'
36569ef0b394Smrg}
36579ef0b394Smrg
36589ef0b394Smrg# func_cygming_gnu_implib_p ARG
36599ef0b394Smrg# This predicate returns with zero status (TRUE) if
36609ef0b394Smrg# ARG is a GNU/binutils-style import library. Returns
36619ef0b394Smrg# with nonzero status (FALSE) otherwise.
36629ef0b394Smrgfunc_cygming_gnu_implib_p ()
36639ef0b394Smrg{
36649ef0b394Smrg  $opt_debug
36659ef0b394Smrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
36669ef0b394Smrg  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)$'`
36679ef0b394Smrg  test -n "$func_cygming_gnu_implib_tmp"
36689ef0b394Smrg}
36699ef0b394Smrg
36709ef0b394Smrg# func_cygming_ms_implib_p ARG
36719ef0b394Smrg# This predicate returns with zero status (TRUE) if
36729ef0b394Smrg# ARG is an MS-style import library. Returns
36739ef0b394Smrg# with nonzero status (FALSE) otherwise.
36749ef0b394Smrgfunc_cygming_ms_implib_p ()
36759ef0b394Smrg{
36769ef0b394Smrg  $opt_debug
36779ef0b394Smrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
36789ef0b394Smrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
36799ef0b394Smrg  test -n "$func_cygming_ms_implib_tmp"
36809ef0b394Smrg}
36819ef0b394Smrg
36829ef0b394Smrg# func_cygming_dll_for_implib_fallback ARG
36839ef0b394Smrg# Platform-specific function to extract the
36849ef0b394Smrg# name of the DLL associated with the specified
36859ef0b394Smrg# import library ARG.
36869ef0b394Smrg#
36879ef0b394Smrg# This fallback implementation is for use when $DLLTOOL
36889ef0b394Smrg# does not support the --identify-strict option.
36899ef0b394Smrg# Invoked by eval'ing the libtool variable
36909ef0b394Smrg#    $sharedlib_from_linklib_cmd
36919ef0b394Smrg# Result is available in the variable
36929ef0b394Smrg#    $sharedlib_from_linklib_result
36939ef0b394Smrgfunc_cygming_dll_for_implib_fallback ()
36949ef0b394Smrg{
36959ef0b394Smrg  $opt_debug
36969ef0b394Smrg  if func_cygming_gnu_implib_p "$1" ; then
36979ef0b394Smrg    # binutils import library
36989ef0b394Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
36999ef0b394Smrg  elif func_cygming_ms_implib_p "$1" ; then
37009ef0b394Smrg    # ms-generated import library
37019ef0b394Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
37029ef0b394Smrg  else
37039ef0b394Smrg    # unknown
37049ef0b394Smrg    sharedlib_from_linklib_result=""
37059ef0b394Smrg  fi
37069ef0b394Smrg}
3707266e564dSmrg
3708266e564dSmrg
3709698f425bSmrg# func_extract_an_archive dir oldlib
3710698f425bSmrgfunc_extract_an_archive ()
3711698f425bSmrg{
3712698f425bSmrg    $opt_debug
3713698f425bSmrg    f_ex_an_ar_dir="$1"; shift
3714698f425bSmrg    f_ex_an_ar_oldlib="$1"
37159ef0b394Smrg    if test "$lock_old_archive_extraction" = yes; then
37169ef0b394Smrg      lockfile=$f_ex_an_ar_oldlib.lock
37179ef0b394Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
37189ef0b394Smrg	func_echo "Waiting for $lockfile to be removed"
37199ef0b394Smrg	sleep 2
37209ef0b394Smrg      done
37219ef0b394Smrg    fi
37229ef0b394Smrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
37239ef0b394Smrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
37249ef0b394Smrg    if test "$lock_old_archive_extraction" = yes; then
37259ef0b394Smrg      $opt_dry_run || rm -f "$lockfile"
37269ef0b394Smrg    fi
3727698f425bSmrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
3728698f425bSmrg     :
3729698f425bSmrg    else
3730698f425bSmrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
3731698f425bSmrg    fi
3732698f425bSmrg}
3733266e564dSmrg
3734266e564dSmrg
3735698f425bSmrg# func_extract_archives gentop oldlib ...
3736698f425bSmrgfunc_extract_archives ()
3737698f425bSmrg{
3738698f425bSmrg    $opt_debug
3739698f425bSmrg    my_gentop="$1"; shift
3740698f425bSmrg    my_oldlibs=${1+"$@"}
3741698f425bSmrg    my_oldobjs=""
3742698f425bSmrg    my_xlib=""
3743698f425bSmrg    my_xabs=""
3744698f425bSmrg    my_xdir=""
3745266e564dSmrg
3746698f425bSmrg    for my_xlib in $my_oldlibs; do
3747698f425bSmrg      # Extract the objects.
3748698f425bSmrg      case $my_xlib in
3749698f425bSmrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
3750698f425bSmrg	*) my_xabs=`pwd`"/$my_xlib" ;;
3751698f425bSmrg      esac
3752698f425bSmrg      func_basename "$my_xlib"
3753698f425bSmrg      my_xlib="$func_basename_result"
3754698f425bSmrg      my_xlib_u=$my_xlib
3755698f425bSmrg      while :; do
3756698f425bSmrg        case " $extracted_archives " in
3757698f425bSmrg	*" $my_xlib_u "*)
3758698f425bSmrg	  func_arith $extracted_serial + 1
3759698f425bSmrg	  extracted_serial=$func_arith_result
3760698f425bSmrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
3761698f425bSmrg	*) break ;;
3762698f425bSmrg	esac
3763698f425bSmrg      done
3764698f425bSmrg      extracted_archives="$extracted_archives $my_xlib_u"
3765698f425bSmrg      my_xdir="$my_gentop/$my_xlib_u"
3766266e564dSmrg
3767698f425bSmrg      func_mkdir_p "$my_xdir"
3768266e564dSmrg
3769698f425bSmrg      case $host in
3770698f425bSmrg      *-darwin*)
3771698f425bSmrg	func_verbose "Extracting $my_xabs"
3772698f425bSmrg	# Do not bother doing anything if just a dry run
3773698f425bSmrg	$opt_dry_run || {
3774698f425bSmrg	  darwin_orig_dir=`pwd`
3775698f425bSmrg	  cd $my_xdir || exit $?
3776698f425bSmrg	  darwin_archive=$my_xabs
3777698f425bSmrg	  darwin_curdir=`pwd`
3778698f425bSmrg	  darwin_base_archive=`basename "$darwin_archive"`
3779698f425bSmrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
3780698f425bSmrg	  if test -n "$darwin_arches"; then
3781698f425bSmrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
3782698f425bSmrg	    darwin_arch=
3783698f425bSmrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
3784698f425bSmrg	    for darwin_arch in  $darwin_arches ; do
3785698f425bSmrg	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3786698f425bSmrg	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
3787698f425bSmrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3788698f425bSmrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
3789698f425bSmrg	      cd "$darwin_curdir"
3790698f425bSmrg	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
3791698f425bSmrg	    done # $darwin_arches
3792698f425bSmrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
3793698f425bSmrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
3794698f425bSmrg	    darwin_file=
3795698f425bSmrg	    darwin_files=
3796698f425bSmrg	    for darwin_file in $darwin_filelist; do
37979ef0b394Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
3798698f425bSmrg	      $LIPO -create -output "$darwin_file" $darwin_files
3799698f425bSmrg	    done # $darwin_filelist
3800698f425bSmrg	    $RM -rf unfat-$$
3801698f425bSmrg	    cd "$darwin_orig_dir"
3802266e564dSmrg	  else
3803698f425bSmrg	    cd $darwin_orig_dir
3804698f425bSmrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
3805698f425bSmrg	  fi # $darwin_arches
3806698f425bSmrg	} # !$opt_dry_run
3807698f425bSmrg	;;
3808698f425bSmrg      *)
3809698f425bSmrg        func_extract_an_archive "$my_xdir" "$my_xabs"
3810698f425bSmrg	;;
3811698f425bSmrg      esac
38129ef0b394Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
3813698f425bSmrg    done
3814266e564dSmrg
3815698f425bSmrg    func_extract_archives_result="$my_oldobjs"
3816698f425bSmrg}
3817266e564dSmrg
3818266e564dSmrg
38199ef0b394Smrg# func_emit_wrapper [arg=no]
38209ef0b394Smrg#
38219ef0b394Smrg# Emit a libtool wrapper script on stdout.
38229ef0b394Smrg# Don't directly open a file because we may want to
38239ef0b394Smrg# incorporate the script contents within a cygwin/mingw
38249ef0b394Smrg# wrapper executable.  Must ONLY be called from within
38259ef0b394Smrg# func_mode_link because it depends on a number of variables
38269ef0b394Smrg# set therein.
3827698f425bSmrg#
38289ef0b394Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
38299ef0b394Smrg# variable will take.  If 'yes', then the emitted script
38309ef0b394Smrg# will assume that the directory in which it is stored is
38319ef0b394Smrg# the $objdir directory.  This is a cygwin/mingw-specific
38329ef0b394Smrg# behavior.
38339ef0b394Smrgfunc_emit_wrapper ()
3834698f425bSmrg{
38359ef0b394Smrg	func_emit_wrapper_arg1=${1-no}
3836266e564dSmrg
3837698f425bSmrg	$ECHO "\
3838698f425bSmrg#! $SHELL
3839266e564dSmrg
3840698f425bSmrg# $output - temporary wrapper script for $objdir/$outputname
3841698f425bSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
3842698f425bSmrg#
3843698f425bSmrg# The $output program cannot be directly executed until all the libtool
3844698f425bSmrg# libraries that it depends on are installed.
3845698f425bSmrg#
3846698f425bSmrg# This wrapper script should never be moved out of the build directory.
3847698f425bSmrg# If it is, it will not operate correctly.
3848266e564dSmrg
3849698f425bSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
3850698f425bSmrg# metacharacters that are still active within double-quoted strings.
3851698f425bSmrgsed_quote_subst='$sed_quote_subst'
3852266e564dSmrg
3853698f425bSmrg# Be Bourne compatible
3854698f425bSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
3855698f425bSmrg  emulate sh
3856698f425bSmrg  NULLCMD=:
3857698f425bSmrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
3858698f425bSmrg  # is contrary to our usage.  Disable this feature.
3859698f425bSmrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
3860698f425bSmrg  setopt NO_GLOB_SUBST
3861698f425bSmrgelse
3862698f425bSmrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
3863698f425bSmrgfi
3864698f425bSmrgBIN_SH=xpg4; export BIN_SH # for Tru64
3865698f425bSmrgDUALCASE=1; export DUALCASE # for MKS sh
3866266e564dSmrg
3867698f425bSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout
3868698f425bSmrg# if CDPATH is set.
3869698f425bSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
3870266e564dSmrg
3871698f425bSmrgrelink_command=\"$relink_command\"
3872266e564dSmrg
3873698f425bSmrg# This environment variable determines our operation mode.
3874698f425bSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then
3875698f425bSmrg  # install mode needs the following variables:
3876698f425bSmrg  generated_by_libtool_version='$macro_version'
3877698f425bSmrg  notinst_deplibs='$notinst_deplibs'
3878698f425bSmrgelse
3879698f425bSmrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
3880698f425bSmrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
38819ef0b394Smrg    file=\"\$0\""
38829ef0b394Smrg
38839ef0b394Smrg    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
38849ef0b394Smrg    $ECHO "\
38859ef0b394Smrg
38869ef0b394Smrg# A function that is used when there is no print builtin or printf.
38879ef0b394Smrgfunc_fallback_echo ()
38889ef0b394Smrg{
38899ef0b394Smrg  eval 'cat <<_LTECHO_EOF
38909ef0b394Smrg\$1
38919ef0b394Smrg_LTECHO_EOF'
38929ef0b394Smrg}
38939ef0b394Smrg    ECHO=\"$qECHO\"
38949ef0b394Smrg  fi
38959ef0b394Smrg
38969ef0b394Smrg# Very basic option parsing. These options are (a) specific to
38979ef0b394Smrg# the libtool wrapper, (b) are identical between the wrapper
38989ef0b394Smrg# /script/ and the wrapper /executable/ which is used only on
38999ef0b394Smrg# windows platforms, and (c) all begin with the string "--lt-"
39009ef0b394Smrg# (application programs are unlikely to have options which match
39019ef0b394Smrg# this pattern).
39029ef0b394Smrg#
39039ef0b394Smrg# There are only two supported options: --lt-debug and
39049ef0b394Smrg# --lt-dump-script. There is, deliberately, no --lt-help.
39059ef0b394Smrg#
39069ef0b394Smrg# The first argument to this parsing function should be the
39079ef0b394Smrg# script's $0 value, followed by "$@".
39089ef0b394Smrglt_option_debug=
39099ef0b394Smrgfunc_parse_lt_options ()
39109ef0b394Smrg{
39119ef0b394Smrg  lt_script_arg0=\$0
39129ef0b394Smrg  shift
39139ef0b394Smrg  for lt_opt
39149ef0b394Smrg  do
39159ef0b394Smrg    case \"\$lt_opt\" in
39169ef0b394Smrg    --lt-debug) lt_option_debug=1 ;;
39179ef0b394Smrg    --lt-dump-script)
39189ef0b394Smrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
39199ef0b394Smrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
39209ef0b394Smrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
39219ef0b394Smrg        cat \"\$lt_dump_D/\$lt_dump_F\"
39229ef0b394Smrg        exit 0
39239ef0b394Smrg      ;;
39249ef0b394Smrg    --lt-*)
39259ef0b394Smrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
39269ef0b394Smrg        exit 1
39279ef0b394Smrg      ;;
39289ef0b394Smrg    esac
39299ef0b394Smrg  done
39309ef0b394Smrg
39319ef0b394Smrg  # Print the debug banner immediately:
39329ef0b394Smrg  if test -n \"\$lt_option_debug\"; then
39339ef0b394Smrg    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
39349ef0b394Smrg  fi
39359ef0b394Smrg}
39369ef0b394Smrg
39379ef0b394Smrg# Used when --lt-debug. Prints its arguments to stdout
39389ef0b394Smrg# (redirection is the responsibility of the caller)
39399ef0b394Smrgfunc_lt_dump_args ()
39409ef0b394Smrg{
39419ef0b394Smrg  lt_dump_args_N=1;
39429ef0b394Smrg  for lt_arg
39439ef0b394Smrg  do
39449ef0b394Smrg    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
39459ef0b394Smrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
39469ef0b394Smrg  done
39479ef0b394Smrg}
39489ef0b394Smrg
39499ef0b394Smrg# Core function for launching the target application
39509ef0b394Smrgfunc_exec_program_core ()
39519ef0b394Smrg{
3952698f425bSmrg"
39539ef0b394Smrg  case $host in
39549ef0b394Smrg  # Backslashes separate directories on plain windows
39559ef0b394Smrg  *-*-mingw | *-*-os2* | *-cegcc*)
39569ef0b394Smrg    $ECHO "\
39579ef0b394Smrg      if test -n \"\$lt_option_debug\"; then
39589ef0b394Smrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
39599ef0b394Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
39609ef0b394Smrg      fi
39619ef0b394Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
39629ef0b394Smrg"
39639ef0b394Smrg    ;;
39649ef0b394Smrg
39659ef0b394Smrg  *)
39669ef0b394Smrg    $ECHO "\
39679ef0b394Smrg      if test -n \"\$lt_option_debug\"; then
39689ef0b394Smrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
39699ef0b394Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
39709ef0b394Smrg      fi
39719ef0b394Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
39729ef0b394Smrg"
39739ef0b394Smrg    ;;
39749ef0b394Smrg  esac
39759ef0b394Smrg  $ECHO "\
39769ef0b394Smrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
39779ef0b394Smrg      exit 1
39789ef0b394Smrg}
39799ef0b394Smrg
39809ef0b394Smrg# A function to encapsulate launching the target application
39819ef0b394Smrg# Strips options in the --lt-* namespace from \$@ and
39829ef0b394Smrg# launches target application with the remaining arguments.
39839ef0b394Smrgfunc_exec_program ()
39849ef0b394Smrg{
39859ef0b394Smrg  for lt_wr_arg
39869ef0b394Smrg  do
39879ef0b394Smrg    case \$lt_wr_arg in
39889ef0b394Smrg    --lt-*) ;;
39899ef0b394Smrg    *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
39909ef0b394Smrg    esac
39919ef0b394Smrg    shift
39929ef0b394Smrg  done
39939ef0b394Smrg  func_exec_program_core \${1+\"\$@\"}
39949ef0b394Smrg}
39959ef0b394Smrg
39969ef0b394Smrg  # Parse options
39979ef0b394Smrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
3998266e564dSmrg
3999698f425bSmrg  # Find the directory that this script lives in.
40009ef0b394Smrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
4001698f425bSmrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
4002266e564dSmrg
4003698f425bSmrg  # Follow symbolic links until we get to the real thisdir.
40049ef0b394Smrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
4005698f425bSmrg  while test -n \"\$file\"; do
40069ef0b394Smrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
4007266e564dSmrg
4008698f425bSmrg    # If there was a directory component, then change thisdir.
4009698f425bSmrg    if test \"x\$destdir\" != \"x\$file\"; then
4010698f425bSmrg      case \"\$destdir\" in
4011698f425bSmrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
4012698f425bSmrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
4013266e564dSmrg      esac
4014698f425bSmrg    fi
4015266e564dSmrg
40169ef0b394Smrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
40179ef0b394Smrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
4018698f425bSmrg  done
4019266e564dSmrg
4020698f425bSmrg  # Usually 'no', except on cygwin/mingw when embedded into
4021698f425bSmrg  # the cwrapper.
40229ef0b394Smrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
4023698f425bSmrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
4024698f425bSmrg    # special case for '.'
4025698f425bSmrg    if test \"\$thisdir\" = \".\"; then
4026698f425bSmrg      thisdir=\`pwd\`
4027698f425bSmrg    fi
4028698f425bSmrg    # remove .libs from thisdir
4029698f425bSmrg    case \"\$thisdir\" in
40309ef0b394Smrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
4031698f425bSmrg    $objdir )   thisdir=. ;;
4032698f425bSmrg    esac
4033698f425bSmrg  fi
4034698f425bSmrg
4035698f425bSmrg  # Try to get the absolute directory name.
4036698f425bSmrg  absdir=\`cd \"\$thisdir\" && pwd\`
4037698f425bSmrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
4038698f425bSmrg"
4039698f425bSmrg
4040698f425bSmrg	if test "$fast_install" = yes; then
4041698f425bSmrg	  $ECHO "\
4042698f425bSmrg  program=lt-'$outputname'$exeext
4043698f425bSmrg  progdir=\"\$thisdir/$objdir\"
4044698f425bSmrg
4045698f425bSmrg  if test ! -f \"\$progdir/\$program\" ||
4046698f425bSmrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
4047698f425bSmrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
4048698f425bSmrg
4049698f425bSmrg    file=\"\$\$-\$program\"
4050698f425bSmrg
4051698f425bSmrg    if test ! -d \"\$progdir\"; then
4052698f425bSmrg      $MKDIR \"\$progdir\"
4053698f425bSmrg    else
4054698f425bSmrg      $RM \"\$progdir/\$file\"
4055698f425bSmrg    fi"
4056698f425bSmrg
4057698f425bSmrg	  $ECHO "\
4058698f425bSmrg
4059698f425bSmrg    # relink executable if necessary
4060698f425bSmrg    if test -n \"\$relink_command\"; then
4061698f425bSmrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
4062698f425bSmrg      else
4063698f425bSmrg	$ECHO \"\$relink_command_output\" >&2
4064698f425bSmrg	$RM \"\$progdir/\$file\"
4065698f425bSmrg	exit 1
4066266e564dSmrg      fi
4067698f425bSmrg    fi
4068266e564dSmrg
4069698f425bSmrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
4070698f425bSmrg    { $RM \"\$progdir/\$program\";
4071698f425bSmrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
4072698f425bSmrg    $RM \"\$progdir/\$file\"
4073698f425bSmrg  fi"
4074698f425bSmrg	else
4075698f425bSmrg	  $ECHO "\
4076698f425bSmrg  program='$outputname'
4077698f425bSmrg  progdir=\"\$thisdir/$objdir\"
4078698f425bSmrg"
4079266e564dSmrg	fi
4080266e564dSmrg
4081698f425bSmrg	$ECHO "\
4082266e564dSmrg
4083698f425bSmrg  if test -f \"\$progdir/\$program\"; then"
4084266e564dSmrg
40859ef0b394Smrg	# fixup the dll searchpath if we need to.
40869ef0b394Smrg	#
40879ef0b394Smrg	# Fix the DLL searchpath if we need to.  Do this before prepending
40889ef0b394Smrg	# to shlibpath, because on Windows, both are PATH and uninstalled
40899ef0b394Smrg	# libraries must come first.
40909ef0b394Smrg	if test -n "$dllsearchpath"; then
40919ef0b394Smrg	  $ECHO "\
40929ef0b394Smrg    # Add the dll search path components to the executable PATH
40939ef0b394Smrg    PATH=$dllsearchpath:\$PATH
40949ef0b394Smrg"
40959ef0b394Smrg	fi
40969ef0b394Smrg
4097698f425bSmrg	# Export our shlibpath_var if we have one.
4098698f425bSmrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4099698f425bSmrg	  $ECHO "\
4100698f425bSmrg    # Add our own library path to $shlibpath_var
4101698f425bSmrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
4102266e564dSmrg
4103698f425bSmrg    # Some systems cannot cope with colon-terminated $shlibpath_var
4104698f425bSmrg    # The second colon is a workaround for a bug in BeOS R4 sed
41059ef0b394Smrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
4106698f425bSmrg
4107698f425bSmrg    export $shlibpath_var
4108698f425bSmrg"
4109266e564dSmrg	fi
4110266e564dSmrg
4111698f425bSmrg	$ECHO "\
4112698f425bSmrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
4113698f425bSmrg      # Run the actual program with our arguments.
41149ef0b394Smrg      func_exec_program \${1+\"\$@\"}
4115698f425bSmrg    fi
4116698f425bSmrg  else
4117698f425bSmrg    # The program doesn't exist.
4118698f425bSmrg    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
4119698f425bSmrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
41209ef0b394Smrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
4121698f425bSmrg    exit 1
4122698f425bSmrg  fi
4123698f425bSmrgfi\
4124698f425bSmrg"
4125698f425bSmrg}
4126266e564dSmrg
4127266e564dSmrg
4128698f425bSmrg# func_emit_cwrapperexe_src
4129698f425bSmrg# emit the source code for a wrapper executable on stdout
4130698f425bSmrg# Must ONLY be called from within func_mode_link because
4131698f425bSmrg# it depends on a number of variable set therein.
4132698f425bSmrgfunc_emit_cwrapperexe_src ()
4133698f425bSmrg{
4134698f425bSmrg	cat <<EOF
4135266e564dSmrg
4136698f425bSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
4137698f425bSmrg   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
4138266e564dSmrg
4139698f425bSmrg   The $output program cannot be directly executed until all the libtool
4140698f425bSmrg   libraries that it depends on are installed.
4141266e564dSmrg
4142698f425bSmrg   This wrapper executable should never be moved out of the build directory.
4143698f425bSmrg   If it is, it will not operate correctly.
4144698f425bSmrg*/
4145698f425bSmrgEOF
4146698f425bSmrg	    cat <<"EOF"
41479ef0b394Smrg#ifdef _MSC_VER
41489ef0b394Smrg# define _CRT_SECURE_NO_DEPRECATE 1
41499ef0b394Smrg#endif
4150698f425bSmrg#include <stdio.h>
4151698f425bSmrg#include <stdlib.h>
4152698f425bSmrg#ifdef _MSC_VER
4153698f425bSmrg# include <direct.h>
4154698f425bSmrg# include <process.h>
4155698f425bSmrg# include <io.h>
4156698f425bSmrg#else
4157698f425bSmrg# include <unistd.h>
4158698f425bSmrg# include <stdint.h>
4159698f425bSmrg# ifdef __CYGWIN__
4160698f425bSmrg#  include <io.h>
4161698f425bSmrg# endif
4162698f425bSmrg#endif
4163698f425bSmrg#include <malloc.h>
4164698f425bSmrg#include <stdarg.h>
4165698f425bSmrg#include <assert.h>
4166698f425bSmrg#include <string.h>
4167698f425bSmrg#include <ctype.h>
4168698f425bSmrg#include <errno.h>
4169698f425bSmrg#include <fcntl.h>
4170698f425bSmrg#include <sys/stat.h>
4171266e564dSmrg
41729ef0b394Smrg/* declarations of non-ANSI functions */
41739ef0b394Smrg#if defined(__MINGW32__)
41749ef0b394Smrg# ifdef __STRICT_ANSI__
41759ef0b394Smrgint _putenv (const char *);
41769ef0b394Smrg# endif
41779ef0b394Smrg#elif defined(__CYGWIN__)
41789ef0b394Smrg# ifdef __STRICT_ANSI__
41799ef0b394Smrgchar *realpath (const char *, char *);
41809ef0b394Smrgint putenv (char *);
41819ef0b394Smrgint setenv (const char *, const char *, int);
41829ef0b394Smrg# endif
41839ef0b394Smrg/* #elif defined (other platforms) ... */
41849ef0b394Smrg#endif
41859ef0b394Smrg
41869ef0b394Smrg/* portability defines, excluding path handling macros */
41879ef0b394Smrg#if defined(_MSC_VER)
41889ef0b394Smrg# define setmode _setmode
41899ef0b394Smrg# define stat    _stat
41909ef0b394Smrg# define chmod   _chmod
41919ef0b394Smrg# define getcwd  _getcwd
41929ef0b394Smrg# define putenv  _putenv
41939ef0b394Smrg# define S_IXUSR _S_IEXEC
41949ef0b394Smrg# ifndef _INTPTR_T_DEFINED
41959ef0b394Smrg#  define _INTPTR_T_DEFINED
41969ef0b394Smrg#  define intptr_t int
41979ef0b394Smrg# endif
41989ef0b394Smrg#elif defined(__MINGW32__)
41999ef0b394Smrg# define setmode _setmode
42009ef0b394Smrg# define stat    _stat
42019ef0b394Smrg# define chmod   _chmod
42029ef0b394Smrg# define getcwd  _getcwd
42039ef0b394Smrg# define putenv  _putenv
42049ef0b394Smrg#elif defined(__CYGWIN__)
42059ef0b394Smrg# define HAVE_SETENV
42069ef0b394Smrg# define FOPEN_WB "wb"
42079ef0b394Smrg/* #elif defined (other platforms) ... */
42089ef0b394Smrg#endif
42099ef0b394Smrg
4210698f425bSmrg#if defined(PATH_MAX)
4211698f425bSmrg# define LT_PATHMAX PATH_MAX
4212698f425bSmrg#elif defined(MAXPATHLEN)
4213698f425bSmrg# define LT_PATHMAX MAXPATHLEN
4214698f425bSmrg#else
4215698f425bSmrg# define LT_PATHMAX 1024
4216698f425bSmrg#endif
4217266e564dSmrg
4218698f425bSmrg#ifndef S_IXOTH
4219698f425bSmrg# define S_IXOTH 0
4220698f425bSmrg#endif
4221698f425bSmrg#ifndef S_IXGRP
4222698f425bSmrg# define S_IXGRP 0
4223698f425bSmrg#endif
4224266e564dSmrg
42259ef0b394Smrg/* path handling portability macros */
4226698f425bSmrg#ifndef DIR_SEPARATOR
4227698f425bSmrg# define DIR_SEPARATOR '/'
4228698f425bSmrg# define PATH_SEPARATOR ':'
4229698f425bSmrg#endif
4230266e564dSmrg
4231698f425bSmrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
4232698f425bSmrg  defined (__OS2__)
4233698f425bSmrg# define HAVE_DOS_BASED_FILE_SYSTEM
4234698f425bSmrg# define FOPEN_WB "wb"
4235698f425bSmrg# ifndef DIR_SEPARATOR_2
4236698f425bSmrg#  define DIR_SEPARATOR_2 '\\'
4237698f425bSmrg# endif
4238698f425bSmrg# ifndef PATH_SEPARATOR_2
4239698f425bSmrg#  define PATH_SEPARATOR_2 ';'
4240698f425bSmrg# endif
4241698f425bSmrg#endif
4242266e564dSmrg
4243698f425bSmrg#ifndef DIR_SEPARATOR_2
4244698f425bSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
4245698f425bSmrg#else /* DIR_SEPARATOR_2 */
4246698f425bSmrg# define IS_DIR_SEPARATOR(ch) \
4247698f425bSmrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4248698f425bSmrg#endif /* DIR_SEPARATOR_2 */
4249266e564dSmrg
4250698f425bSmrg#ifndef PATH_SEPARATOR_2
4251698f425bSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
4252698f425bSmrg#else /* PATH_SEPARATOR_2 */
4253698f425bSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
4254698f425bSmrg#endif /* PATH_SEPARATOR_2 */
4255266e564dSmrg
4256698f425bSmrg#ifndef FOPEN_WB
4257698f425bSmrg# define FOPEN_WB "w"
4258698f425bSmrg#endif
4259698f425bSmrg#ifndef _O_BINARY
4260698f425bSmrg# define _O_BINARY 0
4261698f425bSmrg#endif
4262266e564dSmrg
4263698f425bSmrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
4264698f425bSmrg#define XFREE(stale) do { \
4265698f425bSmrg  if (stale) { free ((void *) stale); stale = 0; } \
4266698f425bSmrg} while (0)
4267266e564dSmrg
42689ef0b394Smrg#if defined(LT_DEBUGWRAPPER)
42699ef0b394Smrgstatic int lt_debug = 1;
4270698f425bSmrg#else
42719ef0b394Smrgstatic int lt_debug = 0;
4272698f425bSmrg#endif
4273266e564dSmrg
42749ef0b394Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
4275266e564dSmrg
4276698f425bSmrgvoid *xmalloc (size_t num);
4277698f425bSmrgchar *xstrdup (const char *string);
4278698f425bSmrgconst char *base_name (const char *name);
4279698f425bSmrgchar *find_executable (const char *wrapper);
4280698f425bSmrgchar *chase_symlinks (const char *pathspec);
4281698f425bSmrgint make_executable (const char *path);
4282698f425bSmrgint check_executable (const char *path);
4283698f425bSmrgchar *strendzap (char *str, const char *pat);
42849ef0b394Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
42859ef0b394Smrgvoid lt_fatal (const char *file, int line, const char *message, ...);
42869ef0b394Smrgstatic const char *nonnull (const char *s);
42879ef0b394Smrgstatic const char *nonempty (const char *s);
4288698f425bSmrgvoid lt_setenv (const char *name, const char *value);
4289698f425bSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
4290698f425bSmrgvoid lt_update_exe_path (const char *name, const char *value);
4291698f425bSmrgvoid lt_update_lib_path (const char *name, const char *value);
42929ef0b394Smrgchar **prepare_spawn (char **argv);
42939ef0b394Smrgvoid lt_dump_script (FILE *f);
4294698f425bSmrgEOF
4295698f425bSmrg
4296698f425bSmrg	    cat <<EOF
42979ef0b394Smrgvolatile const char * MAGIC_EXE = "$magic_exe";
4298698f425bSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
4299698f425bSmrgEOF
4300266e564dSmrg
4301698f425bSmrg	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
43029ef0b394Smrg              func_to_host_path "$temp_rpath"
4303698f425bSmrg	      cat <<EOF
43049ef0b394Smrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
4305698f425bSmrgEOF
4306698f425bSmrg	    else
4307698f425bSmrg	      cat <<"EOF"
4308698f425bSmrgconst char * LIB_PATH_VALUE   = "";
4309698f425bSmrgEOF
4310266e564dSmrg	    fi
4311266e564dSmrg
4312698f425bSmrg	    if test -n "$dllsearchpath"; then
43139ef0b394Smrg              func_to_host_path "$dllsearchpath:"
4314698f425bSmrg	      cat <<EOF
4315698f425bSmrgconst char * EXE_PATH_VARNAME = "PATH";
43169ef0b394Smrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
4317266e564dSmrgEOF
4318266e564dSmrg	    else
4319698f425bSmrg	      cat <<"EOF"
4320698f425bSmrgconst char * EXE_PATH_VARNAME = "";
4321698f425bSmrgconst char * EXE_PATH_VALUE   = "";
4322698f425bSmrgEOF
4323266e564dSmrg	    fi
4324698f425bSmrg
4325698f425bSmrg	    if test "$fast_install" = yes; then
4326698f425bSmrg	      cat <<EOF
4327698f425bSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
4328698f425bSmrgEOF
4329266e564dSmrg	    else
4330698f425bSmrg	      cat <<EOF
4331698f425bSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
4332698f425bSmrgEOF
4333266e564dSmrg	    fi
4334266e564dSmrg
4335266e564dSmrg
4336698f425bSmrg	    cat <<"EOF"
4337266e564dSmrg
4338698f425bSmrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
4339266e564dSmrg
4340698f425bSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
4341698f425bSmrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
43429ef0b394Smrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
4343266e564dSmrg
4344698f425bSmrgint
4345698f425bSmrgmain (int argc, char *argv[])
4346698f425bSmrg{
4347698f425bSmrg  char **newargz;
4348698f425bSmrg  int  newargc;
4349698f425bSmrg  char *tmp_pathspec;
4350698f425bSmrg  char *actual_cwrapper_path;
4351698f425bSmrg  char *actual_cwrapper_name;
4352698f425bSmrg  char *target_name;
4353698f425bSmrg  char *lt_argv_zero;
4354698f425bSmrg  intptr_t rval = 127;
4355266e564dSmrg
4356698f425bSmrg  int i;
4357266e564dSmrg
4358698f425bSmrg  program_name = (char *) xstrdup (base_name (argv[0]));
43599ef0b394Smrg  newargz = XMALLOC (char *, argc + 1);
4360266e564dSmrg
43619ef0b394Smrg  /* very simple arg parsing; don't want to rely on getopt
43629ef0b394Smrg   * also, copy all non cwrapper options to newargz, except
43639ef0b394Smrg   * argz[0], which is handled differently
43649ef0b394Smrg   */
43659ef0b394Smrg  newargc=0;
4366698f425bSmrg  for (i = 1; i < argc; i++)
4367698f425bSmrg    {
4368698f425bSmrg      if (strcmp (argv[i], dumpscript_opt) == 0)
4369698f425bSmrg	{
4370698f425bSmrgEOF
4371698f425bSmrg	    case "$host" in
4372698f425bSmrg	      *mingw* | *cygwin* )
4373698f425bSmrg		# make stdout use "unix" line endings
4374698f425bSmrg		echo "          setmode(1,_O_BINARY);"
4375698f425bSmrg		;;
4376698f425bSmrg	      esac
4377266e564dSmrg
4378698f425bSmrg	    cat <<"EOF"
43799ef0b394Smrg	  lt_dump_script (stdout);
4380698f425bSmrg	  return 0;
4381698f425bSmrg	}
43829ef0b394Smrg      if (strcmp (argv[i], debug_opt) == 0)
43839ef0b394Smrg	{
43849ef0b394Smrg          lt_debug = 1;
43859ef0b394Smrg          continue;
43869ef0b394Smrg	}
43879ef0b394Smrg      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
43889ef0b394Smrg        {
43899ef0b394Smrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
43909ef0b394Smrg             namespace, but it is not one of the ones we know about and
43919ef0b394Smrg             have already dealt with, above (inluding dump-script), then
43929ef0b394Smrg             report an error. Otherwise, targets might begin to believe
43939ef0b394Smrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
43949ef0b394Smrg             namespace. The first time any user complains about this, we'll
43959ef0b394Smrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
43969ef0b394Smrg             or a configure.ac-settable value.
43979ef0b394Smrg           */
43989ef0b394Smrg          lt_fatal (__FILE__, __LINE__,
43999ef0b394Smrg		    "unrecognized %s option: '%s'",
44009ef0b394Smrg                    ltwrapper_option_prefix, argv[i]);
44019ef0b394Smrg        }
44029ef0b394Smrg      /* otherwise ... */
44039ef0b394Smrg      newargz[++newargc] = xstrdup (argv[i]);
4404698f425bSmrg    }
44059ef0b394Smrg  newargz[++newargc] = NULL;
44069ef0b394Smrg
44079ef0b394SmrgEOF
44089ef0b394Smrg	    cat <<EOF
44099ef0b394Smrg  /* The GNU banner must be the first non-error debug message */
44109ef0b394Smrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
44119ef0b394SmrgEOF
44129ef0b394Smrg	    cat <<"EOF"
44139ef0b394Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
44149ef0b394Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
4415266e564dSmrg
4416698f425bSmrg  tmp_pathspec = find_executable (argv[0]);
4417698f425bSmrg  if (tmp_pathspec == NULL)
44189ef0b394Smrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
44199ef0b394Smrg  lt_debugprintf (__FILE__, __LINE__,
44209ef0b394Smrg                  "(main) found exe (before symlink chase) at: %s\n",
44219ef0b394Smrg		  tmp_pathspec);
4422698f425bSmrg
4423698f425bSmrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
44249ef0b394Smrg  lt_debugprintf (__FILE__, __LINE__,
44259ef0b394Smrg                  "(main) found exe (after symlink chase) at: %s\n",
44269ef0b394Smrg		  actual_cwrapper_path);
4427698f425bSmrg  XFREE (tmp_pathspec);
4428698f425bSmrg
44299ef0b394Smrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
4430698f425bSmrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
4431698f425bSmrg
4432698f425bSmrg  /* wrapper name transforms */
4433698f425bSmrg  strendzap (actual_cwrapper_name, ".exe");
4434698f425bSmrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
4435698f425bSmrg  XFREE (actual_cwrapper_name);
4436698f425bSmrg  actual_cwrapper_name = tmp_pathspec;
4437698f425bSmrg  tmp_pathspec = 0;
4438698f425bSmrg
4439698f425bSmrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
4440698f425bSmrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
4441698f425bSmrg  strendzap (target_name, ".exe");
4442698f425bSmrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
4443698f425bSmrg  XFREE (target_name);
4444698f425bSmrg  target_name = tmp_pathspec;
4445698f425bSmrg  tmp_pathspec = 0;
4446698f425bSmrg
44479ef0b394Smrg  lt_debugprintf (__FILE__, __LINE__,
44489ef0b394Smrg		  "(main) libtool target name: %s\n",
44499ef0b394Smrg		  target_name);
4450698f425bSmrgEOF
4451266e564dSmrg
4452698f425bSmrg	    cat <<EOF
4453698f425bSmrg  newargz[0] =
4454698f425bSmrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
4455698f425bSmrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
4456698f425bSmrg  strcpy (newargz[0], actual_cwrapper_path);
4457698f425bSmrg  strcat (newargz[0], "$objdir");
4458698f425bSmrg  strcat (newargz[0], "/");
4459698f425bSmrgEOF
4460266e564dSmrg
4461698f425bSmrg	    cat <<"EOF"
4462698f425bSmrg  /* stop here, and copy so we don't have to do this twice */
4463698f425bSmrg  tmp_pathspec = xstrdup (newargz[0]);
4464266e564dSmrg
4465698f425bSmrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
4466698f425bSmrg  strcat (newargz[0], actual_cwrapper_name);
4467266e564dSmrg
4468698f425bSmrg  /* DO want the lt- prefix here if it exists, so use target_name */
4469698f425bSmrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
4470698f425bSmrg  XFREE (tmp_pathspec);
4471698f425bSmrg  tmp_pathspec = NULL;
4472698f425bSmrgEOF
4473266e564dSmrg
4474698f425bSmrg	    case $host_os in
4475698f425bSmrg	      mingw*)
4476698f425bSmrg	    cat <<"EOF"
4477698f425bSmrg  {
4478698f425bSmrg    char* p;
4479698f425bSmrg    while ((p = strchr (newargz[0], '\\')) != NULL)
4480698f425bSmrg      {
4481698f425bSmrg	*p = '/';
4482698f425bSmrg      }
4483698f425bSmrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
4484698f425bSmrg      {
4485698f425bSmrg	*p = '/';
4486698f425bSmrg      }
4487698f425bSmrg  }
4488698f425bSmrgEOF
4489698f425bSmrg	    ;;
4490698f425bSmrg	    esac
4491266e564dSmrg
4492698f425bSmrg	    cat <<"EOF"
4493698f425bSmrg  XFREE (target_name);
4494698f425bSmrg  XFREE (actual_cwrapper_path);
4495698f425bSmrg  XFREE (actual_cwrapper_name);
4496266e564dSmrg
4497698f425bSmrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
4498698f425bSmrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
44999ef0b394Smrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
45009ef0b394Smrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
45019ef0b394Smrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
45029ef0b394Smrg     libraries must come first. */
4503698f425bSmrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
45049ef0b394Smrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
4505266e564dSmrg
45069ef0b394Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
45079ef0b394Smrg		  nonnull (lt_argv_zero));
4508698f425bSmrg  for (i = 0; i < newargc; i++)
4509698f425bSmrg    {
45109ef0b394Smrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
45119ef0b394Smrg		      i, nonnull (newargz[i]));
4512698f425bSmrg    }
4513266e564dSmrg
4514698f425bSmrgEOF
4515266e564dSmrg
4516698f425bSmrg	    case $host_os in
4517698f425bSmrg	      mingw*)
4518698f425bSmrg		cat <<"EOF"
4519698f425bSmrg  /* execv doesn't actually work on mingw as expected on unix */
45209ef0b394Smrg  newargz = prepare_spawn (newargz);
4521698f425bSmrg  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
4522698f425bSmrg  if (rval == -1)
4523698f425bSmrg    {
4524698f425bSmrg      /* failed to start process */
45259ef0b394Smrg      lt_debugprintf (__FILE__, __LINE__,
45269ef0b394Smrg		      "(main) failed to launch target \"%s\": %s\n",
45279ef0b394Smrg		      lt_argv_zero, nonnull (strerror (errno)));
4528698f425bSmrg      return 127;
4529698f425bSmrg    }
4530698f425bSmrg  return rval;
4531698f425bSmrgEOF
4532698f425bSmrg		;;
4533698f425bSmrg	      *)
4534698f425bSmrg		cat <<"EOF"
4535698f425bSmrg  execv (lt_argv_zero, newargz);
4536698f425bSmrg  return rval; /* =127, but avoids unused variable warning */
4537698f425bSmrgEOF
4538698f425bSmrg		;;
4539698f425bSmrg	    esac
4540266e564dSmrg
4541698f425bSmrg	    cat <<"EOF"
4542698f425bSmrg}
4543266e564dSmrg
4544698f425bSmrgvoid *
4545698f425bSmrgxmalloc (size_t num)
4546698f425bSmrg{
4547698f425bSmrg  void *p = (void *) malloc (num);
4548698f425bSmrg  if (!p)
45499ef0b394Smrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
4550266e564dSmrg
4551698f425bSmrg  return p;
4552698f425bSmrg}
4553266e564dSmrg
4554698f425bSmrgchar *
4555698f425bSmrgxstrdup (const char *string)
4556698f425bSmrg{
4557698f425bSmrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
4558698f425bSmrg			  string) : NULL;
4559698f425bSmrg}
4560266e564dSmrg
4561698f425bSmrgconst char *
4562698f425bSmrgbase_name (const char *name)
4563698f425bSmrg{
4564698f425bSmrg  const char *base;
4565266e564dSmrg
4566698f425bSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4567698f425bSmrg  /* Skip over the disk name in MSDOS pathnames. */
4568698f425bSmrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
4569698f425bSmrg    name += 2;
4570698f425bSmrg#endif
4571266e564dSmrg
4572698f425bSmrg  for (base = name; *name; name++)
4573698f425bSmrg    if (IS_DIR_SEPARATOR (*name))
4574698f425bSmrg      base = name + 1;
4575698f425bSmrg  return base;
4576698f425bSmrg}
4577266e564dSmrg
4578698f425bSmrgint
4579698f425bSmrgcheck_executable (const char *path)
4580698f425bSmrg{
4581698f425bSmrg  struct stat st;
4582266e564dSmrg
45839ef0b394Smrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
45849ef0b394Smrg                  nonempty (path));
4585698f425bSmrg  if ((!path) || (!*path))
4586698f425bSmrg    return 0;
4587266e564dSmrg
4588698f425bSmrg  if ((stat (path, &st) >= 0)
4589698f425bSmrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
4590698f425bSmrg    return 1;
4591698f425bSmrg  else
4592698f425bSmrg    return 0;
4593698f425bSmrg}
4594266e564dSmrg
4595698f425bSmrgint
4596698f425bSmrgmake_executable (const char *path)
4597698f425bSmrg{
4598698f425bSmrg  int rval = 0;
4599698f425bSmrg  struct stat st;
4600266e564dSmrg
46019ef0b394Smrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
46029ef0b394Smrg                  nonempty (path));
4603698f425bSmrg  if ((!path) || (!*path))
4604698f425bSmrg    return 0;
4605266e564dSmrg
4606698f425bSmrg  if (stat (path, &st) >= 0)
4607698f425bSmrg    {
4608698f425bSmrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
4609698f425bSmrg    }
4610698f425bSmrg  return rval;
4611698f425bSmrg}
4612266e564dSmrg
4613698f425bSmrg/* Searches for the full path of the wrapper.  Returns
4614698f425bSmrg   newly allocated full path name if found, NULL otherwise
4615698f425bSmrg   Does not chase symlinks, even on platforms that support them.
4616698f425bSmrg*/
4617698f425bSmrgchar *
4618698f425bSmrgfind_executable (const char *wrapper)
4619698f425bSmrg{
4620698f425bSmrg  int has_slash = 0;
4621698f425bSmrg  const char *p;
4622698f425bSmrg  const char *p_next;
4623698f425bSmrg  /* static buffer for getcwd */
4624698f425bSmrg  char tmp[LT_PATHMAX + 1];
4625698f425bSmrg  int tmp_len;
4626698f425bSmrg  char *concat_name;
4627266e564dSmrg
46289ef0b394Smrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
46299ef0b394Smrg                  nonempty (wrapper));
4630266e564dSmrg
4631698f425bSmrg  if ((wrapper == NULL) || (*wrapper == '\0'))
4632698f425bSmrg    return NULL;
4633266e564dSmrg
4634698f425bSmrg  /* Absolute path? */
4635698f425bSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4636698f425bSmrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
4637698f425bSmrg    {
4638698f425bSmrg      concat_name = xstrdup (wrapper);
4639698f425bSmrg      if (check_executable (concat_name))
4640698f425bSmrg	return concat_name;
4641698f425bSmrg      XFREE (concat_name);
4642698f425bSmrg    }
4643698f425bSmrg  else
4644698f425bSmrg    {
4645698f425bSmrg#endif
4646698f425bSmrg      if (IS_DIR_SEPARATOR (wrapper[0]))
4647698f425bSmrg	{
4648698f425bSmrg	  concat_name = xstrdup (wrapper);
4649698f425bSmrg	  if (check_executable (concat_name))
4650698f425bSmrg	    return concat_name;
4651698f425bSmrg	  XFREE (concat_name);
4652698f425bSmrg	}
4653698f425bSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4654698f425bSmrg    }
4655698f425bSmrg#endif
4656266e564dSmrg
4657698f425bSmrg  for (p = wrapper; *p; p++)
4658698f425bSmrg    if (*p == '/')
4659698f425bSmrg      {
4660698f425bSmrg	has_slash = 1;
4661698f425bSmrg	break;
4662698f425bSmrg      }
4663698f425bSmrg  if (!has_slash)
4664698f425bSmrg    {
4665698f425bSmrg      /* no slashes; search PATH */
4666698f425bSmrg      const char *path = getenv ("PATH");
4667698f425bSmrg      if (path != NULL)
4668698f425bSmrg	{
4669698f425bSmrg	  for (p = path; *p; p = p_next)
4670698f425bSmrg	    {
4671698f425bSmrg	      const char *q;
4672698f425bSmrg	      size_t p_len;
4673698f425bSmrg	      for (q = p; *q; q++)
4674698f425bSmrg		if (IS_PATH_SEPARATOR (*q))
4675698f425bSmrg		  break;
4676698f425bSmrg	      p_len = q - p;
4677698f425bSmrg	      p_next = (*q == '\0' ? q : q + 1);
4678698f425bSmrg	      if (p_len == 0)
4679698f425bSmrg		{
4680698f425bSmrg		  /* empty path: current directory */
4681698f425bSmrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
46829ef0b394Smrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
46839ef0b394Smrg                              nonnull (strerror (errno)));
4684698f425bSmrg		  tmp_len = strlen (tmp);
4685698f425bSmrg		  concat_name =
4686698f425bSmrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4687698f425bSmrg		  memcpy (concat_name, tmp, tmp_len);
4688698f425bSmrg		  concat_name[tmp_len] = '/';
4689698f425bSmrg		  strcpy (concat_name + tmp_len + 1, wrapper);
4690698f425bSmrg		}
4691698f425bSmrg	      else
4692698f425bSmrg		{
4693698f425bSmrg		  concat_name =
4694698f425bSmrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
4695698f425bSmrg		  memcpy (concat_name, p, p_len);
4696698f425bSmrg		  concat_name[p_len] = '/';
4697698f425bSmrg		  strcpy (concat_name + p_len + 1, wrapper);
4698698f425bSmrg		}
4699698f425bSmrg	      if (check_executable (concat_name))
4700698f425bSmrg		return concat_name;
4701698f425bSmrg	      XFREE (concat_name);
4702698f425bSmrg	    }
4703698f425bSmrg	}
4704698f425bSmrg      /* not found in PATH; assume curdir */
4705698f425bSmrg    }
4706698f425bSmrg  /* Relative path | not found in path: prepend cwd */
4707698f425bSmrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
47089ef0b394Smrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
47099ef0b394Smrg              nonnull (strerror (errno)));
4710698f425bSmrg  tmp_len = strlen (tmp);
4711698f425bSmrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4712698f425bSmrg  memcpy (concat_name, tmp, tmp_len);
4713698f425bSmrg  concat_name[tmp_len] = '/';
4714698f425bSmrg  strcpy (concat_name + tmp_len + 1, wrapper);
4715266e564dSmrg
4716698f425bSmrg  if (check_executable (concat_name))
4717698f425bSmrg    return concat_name;
4718698f425bSmrg  XFREE (concat_name);
4719698f425bSmrg  return NULL;
4720698f425bSmrg}
4721266e564dSmrg
4722698f425bSmrgchar *
4723698f425bSmrgchase_symlinks (const char *pathspec)
4724698f425bSmrg{
4725698f425bSmrg#ifndef S_ISLNK
4726698f425bSmrg  return xstrdup (pathspec);
4727698f425bSmrg#else
4728698f425bSmrg  char buf[LT_PATHMAX];
4729698f425bSmrg  struct stat s;
4730698f425bSmrg  char *tmp_pathspec = xstrdup (pathspec);
4731698f425bSmrg  char *p;
4732698f425bSmrg  int has_symlinks = 0;
4733698f425bSmrg  while (strlen (tmp_pathspec) && !has_symlinks)
4734698f425bSmrg    {
47359ef0b394Smrg      lt_debugprintf (__FILE__, __LINE__,
47369ef0b394Smrg		      "checking path component for symlinks: %s\n",
47379ef0b394Smrg		      tmp_pathspec);
4738698f425bSmrg      if (lstat (tmp_pathspec, &s) == 0)
4739698f425bSmrg	{
4740698f425bSmrg	  if (S_ISLNK (s.st_mode) != 0)
4741698f425bSmrg	    {
4742698f425bSmrg	      has_symlinks = 1;
4743698f425bSmrg	      break;
4744698f425bSmrg	    }
4745266e564dSmrg
4746698f425bSmrg	  /* search backwards for last DIR_SEPARATOR */
4747698f425bSmrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
4748698f425bSmrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4749698f425bSmrg	    p--;
4750698f425bSmrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4751698f425bSmrg	    {
4752698f425bSmrg	      /* no more DIR_SEPARATORS left */
4753698f425bSmrg	      break;
4754698f425bSmrg	    }
4755698f425bSmrg	  *p = '\0';
4756698f425bSmrg	}
4757698f425bSmrg      else
4758698f425bSmrg	{
47599ef0b394Smrg	  lt_fatal (__FILE__, __LINE__,
47609ef0b394Smrg		    "error accessing file \"%s\": %s",
47619ef0b394Smrg		    tmp_pathspec, nonnull (strerror (errno)));
4762698f425bSmrg	}
4763698f425bSmrg    }
4764698f425bSmrg  XFREE (tmp_pathspec);
4765266e564dSmrg
4766698f425bSmrg  if (!has_symlinks)
4767698f425bSmrg    {
4768698f425bSmrg      return xstrdup (pathspec);
4769698f425bSmrg    }
4770266e564dSmrg
4771698f425bSmrg  tmp_pathspec = realpath (pathspec, buf);
4772698f425bSmrg  if (tmp_pathspec == 0)
4773698f425bSmrg    {
47749ef0b394Smrg      lt_fatal (__FILE__, __LINE__,
47759ef0b394Smrg		"could not follow symlinks for %s", pathspec);
4776698f425bSmrg    }
4777698f425bSmrg  return xstrdup (tmp_pathspec);
4778698f425bSmrg#endif
4779698f425bSmrg}
4780266e564dSmrg
4781698f425bSmrgchar *
4782698f425bSmrgstrendzap (char *str, const char *pat)
4783698f425bSmrg{
4784698f425bSmrg  size_t len, patlen;
4785266e564dSmrg
4786698f425bSmrg  assert (str != NULL);
4787698f425bSmrg  assert (pat != NULL);
4788266e564dSmrg
4789698f425bSmrg  len = strlen (str);
4790698f425bSmrg  patlen = strlen (pat);
4791266e564dSmrg
4792698f425bSmrg  if (patlen <= len)
4793698f425bSmrg    {
4794698f425bSmrg      str += len - patlen;
4795698f425bSmrg      if (strcmp (str, pat) == 0)
4796698f425bSmrg	*str = '\0';
4797698f425bSmrg    }
4798698f425bSmrg  return str;
4799698f425bSmrg}
4800266e564dSmrg
48019ef0b394Smrgvoid
48029ef0b394Smrglt_debugprintf (const char *file, int line, const char *fmt, ...)
48039ef0b394Smrg{
48049ef0b394Smrg  va_list args;
48059ef0b394Smrg  if (lt_debug)
48069ef0b394Smrg    {
48079ef0b394Smrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
48089ef0b394Smrg      va_start (args, fmt);
48099ef0b394Smrg      (void) vfprintf (stderr, fmt, args);
48109ef0b394Smrg      va_end (args);
48119ef0b394Smrg    }
48129ef0b394Smrg}
48139ef0b394Smrg
4814698f425bSmrgstatic void
48159ef0b394Smrglt_error_core (int exit_status, const char *file,
48169ef0b394Smrg	       int line, const char *mode,
4817698f425bSmrg	       const char *message, va_list ap)
4818698f425bSmrg{
48199ef0b394Smrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
4820698f425bSmrg  vfprintf (stderr, message, ap);
4821698f425bSmrg  fprintf (stderr, ".\n");
4822266e564dSmrg
4823698f425bSmrg  if (exit_status >= 0)
4824698f425bSmrg    exit (exit_status);
4825698f425bSmrg}
4826266e564dSmrg
4827698f425bSmrgvoid
48289ef0b394Smrglt_fatal (const char *file, int line, const char *message, ...)
4829698f425bSmrg{
4830698f425bSmrg  va_list ap;
4831698f425bSmrg  va_start (ap, message);
48329ef0b394Smrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
4833698f425bSmrg  va_end (ap);
4834698f425bSmrg}
4835266e564dSmrg
48369ef0b394Smrgstatic const char *
48379ef0b394Smrgnonnull (const char *s)
48389ef0b394Smrg{
48399ef0b394Smrg  return s ? s : "(null)";
48409ef0b394Smrg}
48419ef0b394Smrg
48429ef0b394Smrgstatic const char *
48439ef0b394Smrgnonempty (const char *s)
48449ef0b394Smrg{
48459ef0b394Smrg  return (s && !*s) ? "(empty)" : nonnull (s);
48469ef0b394Smrg}
48479ef0b394Smrg
4848698f425bSmrgvoid
4849698f425bSmrglt_setenv (const char *name, const char *value)
4850698f425bSmrg{
48519ef0b394Smrg  lt_debugprintf (__FILE__, __LINE__,
48529ef0b394Smrg		  "(lt_setenv) setting '%s' to '%s'\n",
48539ef0b394Smrg                  nonnull (name), nonnull (value));
4854698f425bSmrg  {
4855698f425bSmrg#ifdef HAVE_SETENV
4856698f425bSmrg    /* always make a copy, for consistency with !HAVE_SETENV */
4857698f425bSmrg    char *str = xstrdup (value);
4858698f425bSmrg    setenv (name, str, 1);
4859698f425bSmrg#else
4860698f425bSmrg    int len = strlen (name) + 1 + strlen (value) + 1;
4861698f425bSmrg    char *str = XMALLOC (char, len);
4862698f425bSmrg    sprintf (str, "%s=%s", name, value);
4863698f425bSmrg    if (putenv (str) != EXIT_SUCCESS)
4864698f425bSmrg      {
4865698f425bSmrg        XFREE (str);
4866698f425bSmrg      }
4867698f425bSmrg#endif
4868698f425bSmrg  }
4869698f425bSmrg}
4870266e564dSmrg
4871698f425bSmrgchar *
4872698f425bSmrglt_extend_str (const char *orig_value, const char *add, int to_end)
4873698f425bSmrg{
4874698f425bSmrg  char *new_value;
4875698f425bSmrg  if (orig_value && *orig_value)
4876698f425bSmrg    {
4877698f425bSmrg      int orig_value_len = strlen (orig_value);
4878698f425bSmrg      int add_len = strlen (add);
4879698f425bSmrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
4880698f425bSmrg      if (to_end)
4881698f425bSmrg        {
4882698f425bSmrg          strcpy (new_value, orig_value);
4883698f425bSmrg          strcpy (new_value + orig_value_len, add);
4884698f425bSmrg        }
4885698f425bSmrg      else
4886698f425bSmrg        {
4887698f425bSmrg          strcpy (new_value, add);
4888698f425bSmrg          strcpy (new_value + add_len, orig_value);
4889698f425bSmrg        }
4890698f425bSmrg    }
4891698f425bSmrg  else
4892698f425bSmrg    {
4893698f425bSmrg      new_value = xstrdup (add);
4894698f425bSmrg    }
4895698f425bSmrg  return new_value;
4896698f425bSmrg}
4897266e564dSmrg
4898698f425bSmrgvoid
4899698f425bSmrglt_update_exe_path (const char *name, const char *value)
4900698f425bSmrg{
49019ef0b394Smrg  lt_debugprintf (__FILE__, __LINE__,
49029ef0b394Smrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
49039ef0b394Smrg                  nonnull (name), nonnull (value));
4904266e564dSmrg
4905698f425bSmrg  if (name && *name && value && *value)
4906698f425bSmrg    {
4907698f425bSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
4908698f425bSmrg      /* some systems can't cope with a ':'-terminated path #' */
4909698f425bSmrg      int len = strlen (new_value);
4910698f425bSmrg      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
4911698f425bSmrg        {
4912698f425bSmrg          new_value[len-1] = '\0';
4913698f425bSmrg        }
4914698f425bSmrg      lt_setenv (name, new_value);
4915698f425bSmrg      XFREE (new_value);
4916698f425bSmrg    }
4917698f425bSmrg}
4918266e564dSmrg
4919698f425bSmrgvoid
4920698f425bSmrglt_update_lib_path (const char *name, const char *value)
4921698f425bSmrg{
49229ef0b394Smrg  lt_debugprintf (__FILE__, __LINE__,
49239ef0b394Smrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
49249ef0b394Smrg                  nonnull (name), nonnull (value));
4925266e564dSmrg
4926698f425bSmrg  if (name && *name && value && *value)
4927698f425bSmrg    {
4928698f425bSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
4929698f425bSmrg      lt_setenv (name, new_value);
4930698f425bSmrg      XFREE (new_value);
4931698f425bSmrg    }
4932698f425bSmrg}
4933266e564dSmrg
49349ef0b394SmrgEOF
49359ef0b394Smrg	    case $host_os in
49369ef0b394Smrg	      mingw*)
49379ef0b394Smrg		cat <<"EOF"
49389ef0b394Smrg
49399ef0b394Smrg/* Prepares an argument vector before calling spawn().
49409ef0b394Smrg   Note that spawn() does not by itself call the command interpreter
49419ef0b394Smrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
49429ef0b394Smrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
49439ef0b394Smrg         GetVersionEx(&v);
49449ef0b394Smrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
49459ef0b394Smrg      }) ? "cmd.exe" : "command.com").
49469ef0b394Smrg   Instead it simply concatenates the arguments, separated by ' ', and calls
49479ef0b394Smrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
49489ef0b394Smrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
49499ef0b394Smrg   special way:
49509ef0b394Smrg   - Space and tab are interpreted as delimiters. They are not treated as
49519ef0b394Smrg     delimiters if they are surrounded by double quotes: "...".
49529ef0b394Smrg   - Unescaped double quotes are removed from the input. Their only effect is
49539ef0b394Smrg     that within double quotes, space and tab are treated like normal
49549ef0b394Smrg     characters.
49559ef0b394Smrg   - Backslashes not followed by double quotes are not special.
49569ef0b394Smrg   - But 2*n+1 backslashes followed by a double quote become
49579ef0b394Smrg     n backslashes followed by a double quote (n >= 0):
49589ef0b394Smrg       \" -> "
49599ef0b394Smrg       \\\" -> \"
49609ef0b394Smrg       \\\\\" -> \\"
49619ef0b394Smrg */
49629ef0b394Smrg#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"
49639ef0b394Smrg#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"
49649ef0b394Smrgchar **
49659ef0b394Smrgprepare_spawn (char **argv)
49669ef0b394Smrg{
49679ef0b394Smrg  size_t argc;
49689ef0b394Smrg  char **new_argv;
49699ef0b394Smrg  size_t i;
49709ef0b394Smrg
49719ef0b394Smrg  /* Count number of arguments.  */
49729ef0b394Smrg  for (argc = 0; argv[argc] != NULL; argc++)
49739ef0b394Smrg    ;
49749ef0b394Smrg
49759ef0b394Smrg  /* Allocate new argument vector.  */
49769ef0b394Smrg  new_argv = XMALLOC (char *, argc + 1);
49779ef0b394Smrg
49789ef0b394Smrg  /* Put quoted arguments into the new argument vector.  */
49799ef0b394Smrg  for (i = 0; i < argc; i++)
49809ef0b394Smrg    {
49819ef0b394Smrg      const char *string = argv[i];
49829ef0b394Smrg
49839ef0b394Smrg      if (string[0] == '\0')
49849ef0b394Smrg	new_argv[i] = xstrdup ("\"\"");
49859ef0b394Smrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
49869ef0b394Smrg	{
49879ef0b394Smrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
49889ef0b394Smrg	  size_t length;
49899ef0b394Smrg	  unsigned int backslashes;
49909ef0b394Smrg	  const char *s;
49919ef0b394Smrg	  char *quoted_string;
49929ef0b394Smrg	  char *p;
49939ef0b394Smrg
49949ef0b394Smrg	  length = 0;
49959ef0b394Smrg	  backslashes = 0;
49969ef0b394Smrg	  if (quote_around)
49979ef0b394Smrg	    length++;
49989ef0b394Smrg	  for (s = string; *s != '\0'; s++)
49999ef0b394Smrg	    {
50009ef0b394Smrg	      char c = *s;
50019ef0b394Smrg	      if (c == '"')
50029ef0b394Smrg		length += backslashes + 1;
50039ef0b394Smrg	      length++;
50049ef0b394Smrg	      if (c == '\\')
50059ef0b394Smrg		backslashes++;
50069ef0b394Smrg	      else
50079ef0b394Smrg		backslashes = 0;
50089ef0b394Smrg	    }
50099ef0b394Smrg	  if (quote_around)
50109ef0b394Smrg	    length += backslashes + 1;
50119ef0b394Smrg
50129ef0b394Smrg	  quoted_string = XMALLOC (char, length + 1);
50139ef0b394Smrg
50149ef0b394Smrg	  p = quoted_string;
50159ef0b394Smrg	  backslashes = 0;
50169ef0b394Smrg	  if (quote_around)
50179ef0b394Smrg	    *p++ = '"';
50189ef0b394Smrg	  for (s = string; *s != '\0'; s++)
50199ef0b394Smrg	    {
50209ef0b394Smrg	      char c = *s;
50219ef0b394Smrg	      if (c == '"')
50229ef0b394Smrg		{
50239ef0b394Smrg		  unsigned int j;
50249ef0b394Smrg		  for (j = backslashes + 1; j > 0; j--)
50259ef0b394Smrg		    *p++ = '\\';
50269ef0b394Smrg		}
50279ef0b394Smrg	      *p++ = c;
50289ef0b394Smrg	      if (c == '\\')
50299ef0b394Smrg		backslashes++;
50309ef0b394Smrg	      else
50319ef0b394Smrg		backslashes = 0;
50329ef0b394Smrg	    }
50339ef0b394Smrg	  if (quote_around)
50349ef0b394Smrg	    {
50359ef0b394Smrg	      unsigned int j;
50369ef0b394Smrg	      for (j = backslashes; j > 0; j--)
50379ef0b394Smrg		*p++ = '\\';
50389ef0b394Smrg	      *p++ = '"';
50399ef0b394Smrg	    }
50409ef0b394Smrg	  *p = '\0';
50419ef0b394Smrg
50429ef0b394Smrg	  new_argv[i] = quoted_string;
50439ef0b394Smrg	}
50449ef0b394Smrg      else
50459ef0b394Smrg	new_argv[i] = (char *) string;
50469ef0b394Smrg    }
50479ef0b394Smrg  new_argv[argc] = NULL;
50489ef0b394Smrg
50499ef0b394Smrg  return new_argv;
50509ef0b394Smrg}
50519ef0b394SmrgEOF
50529ef0b394Smrg		;;
50539ef0b394Smrg	    esac
50549ef0b394Smrg
50559ef0b394Smrg            cat <<"EOF"
50569ef0b394Smrgvoid lt_dump_script (FILE* f)
50579ef0b394Smrg{
50589ef0b394SmrgEOF
50599ef0b394Smrg	    func_emit_wrapper yes |
50609ef0b394Smrg              $SED -e 's/\([\\"]\)/\\\1/g' \
50619ef0b394Smrg	           -e 's/^/  fputs ("/' -e 's/$/\\n", f);/'
5062266e564dSmrg
50639ef0b394Smrg            cat <<"EOF"
50649ef0b394Smrg}
5065698f425bSmrgEOF
5066698f425bSmrg}
5067698f425bSmrg# end: func_emit_cwrapperexe_src
5068266e564dSmrg
50699ef0b394Smrg# func_win32_import_lib_p ARG
50709ef0b394Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd
50719ef0b394Smrgfunc_win32_import_lib_p ()
50729ef0b394Smrg{
50739ef0b394Smrg    $opt_debug
50749ef0b394Smrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
50759ef0b394Smrg    *import*) : ;;
50769ef0b394Smrg    *) false ;;
50779ef0b394Smrg    esac
50789ef0b394Smrg}
50799ef0b394Smrg
5080698f425bSmrg# func_mode_link arg...
5081698f425bSmrgfunc_mode_link ()
5082698f425bSmrg{
5083698f425bSmrg    $opt_debug
5084698f425bSmrg    case $host in
5085698f425bSmrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5086698f425bSmrg      # It is impossible to link a dll without this setting, and
5087698f425bSmrg      # we shouldn't force the makefile maintainer to figure out
5088698f425bSmrg      # which system we are compiling for in order to pass an extra
5089698f425bSmrg      # flag for every libtool invocation.
5090698f425bSmrg      # allow_undefined=no
5091266e564dSmrg
5092698f425bSmrg      # FIXME: Unfortunately, there are problems with the above when trying
5093698f425bSmrg      # to make a dll which has undefined symbols, in which case not
5094698f425bSmrg      # even a static library is built.  For now, we need to specify
5095698f425bSmrg      # -no-undefined on the libtool link line when we can be certain
5096698f425bSmrg      # that all symbols are satisfied, otherwise we get a static library.
5097698f425bSmrg      allow_undefined=yes
5098698f425bSmrg      ;;
5099698f425bSmrg    *)
5100698f425bSmrg      allow_undefined=yes
5101698f425bSmrg      ;;
5102698f425bSmrg    esac
5103698f425bSmrg    libtool_args=$nonopt
5104698f425bSmrg    base_compile="$nonopt $@"
5105698f425bSmrg    compile_command=$nonopt
5106698f425bSmrg    finalize_command=$nonopt
5107266e564dSmrg
5108698f425bSmrg    compile_rpath=
5109698f425bSmrg    finalize_rpath=
5110698f425bSmrg    compile_shlibpath=
5111698f425bSmrg    finalize_shlibpath=
5112698f425bSmrg    convenience=
5113698f425bSmrg    old_convenience=
5114698f425bSmrg    deplibs=
5115698f425bSmrg    old_deplibs=
5116698f425bSmrg    compiler_flags=
5117698f425bSmrg    linker_flags=
5118698f425bSmrg    dllsearchpath=
5119698f425bSmrg    lib_search_path=`pwd`
5120698f425bSmrg    inst_prefix_dir=
5121698f425bSmrg    new_inherited_linker_flags=
5122266e564dSmrg
5123698f425bSmrg    avoid_version=no
51249ef0b394Smrg    bindir=
5125698f425bSmrg    dlfiles=
5126698f425bSmrg    dlprefiles=
5127698f425bSmrg    dlself=no
5128698f425bSmrg    export_dynamic=no
5129698f425bSmrg    export_symbols=
5130698f425bSmrg    export_symbols_regex=
5131698f425bSmrg    generated=
5132698f425bSmrg    libobjs=
5133698f425bSmrg    ltlibs=
5134698f425bSmrg    module=no
5135698f425bSmrg    no_install=no
5136698f425bSmrg    objs=
5137698f425bSmrg    non_pic_objects=
5138698f425bSmrg    precious_files_regex=
5139698f425bSmrg    prefer_static_libs=no
5140698f425bSmrg    preload=no
5141698f425bSmrg    prev=
5142698f425bSmrg    prevarg=
5143698f425bSmrg    release=
5144698f425bSmrg    rpath=
5145698f425bSmrg    xrpath=
5146698f425bSmrg    perm_rpath=
5147698f425bSmrg    temp_rpath=
5148698f425bSmrg    thread_safe=no
5149698f425bSmrg    vinfo=
5150698f425bSmrg    vinfo_number=no
5151698f425bSmrg    weak_libs=
5152698f425bSmrg    single_module="${wl}-single_module"
5153698f425bSmrg    func_infer_tag $base_compile
5154266e564dSmrg
5155698f425bSmrg    # We need to know -static, to get the right output filenames.
5156698f425bSmrg    for arg
5157698f425bSmrg    do
5158698f425bSmrg      case $arg in
5159698f425bSmrg      -shared)
5160698f425bSmrg	test "$build_libtool_libs" != yes && \
5161698f425bSmrg	  func_fatal_configuration "can not build a shared library"
5162698f425bSmrg	build_old_libs=no
5163698f425bSmrg	break
5164698f425bSmrg	;;
5165698f425bSmrg      -all-static | -static | -static-libtool-libs)
5166698f425bSmrg	case $arg in
5167698f425bSmrg	-all-static)
5168698f425bSmrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
5169698f425bSmrg	    func_warning "complete static linking is impossible in this configuration"
5170698f425bSmrg	  fi
5171698f425bSmrg	  if test -n "$link_static_flag"; then
5172698f425bSmrg	    dlopen_self=$dlopen_self_static
5173698f425bSmrg	  fi
5174698f425bSmrg	  prefer_static_libs=yes
5175698f425bSmrg	  ;;
5176698f425bSmrg	-static)
5177698f425bSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5178698f425bSmrg	    dlopen_self=$dlopen_self_static
5179698f425bSmrg	  fi
5180698f425bSmrg	  prefer_static_libs=built
5181698f425bSmrg	  ;;
5182698f425bSmrg	-static-libtool-libs)
5183698f425bSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5184698f425bSmrg	    dlopen_self=$dlopen_self_static
5185698f425bSmrg	  fi
5186698f425bSmrg	  prefer_static_libs=yes
5187698f425bSmrg	  ;;
5188698f425bSmrg	esac
5189698f425bSmrg	build_libtool_libs=no
5190698f425bSmrg	build_old_libs=yes
5191698f425bSmrg	break
5192698f425bSmrg	;;
5193698f425bSmrg      esac
5194698f425bSmrg    done
5195266e564dSmrg
5196698f425bSmrg    # See if our shared archives depend on static archives.
5197698f425bSmrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
5198266e564dSmrg
5199698f425bSmrg    # Go through the arguments, transforming them on the way.
5200698f425bSmrg    while test "$#" -gt 0; do
5201698f425bSmrg      arg="$1"
5202698f425bSmrg      shift
5203698f425bSmrg      func_quote_for_eval "$arg"
5204698f425bSmrg      qarg=$func_quote_for_eval_unquoted_result
5205698f425bSmrg      func_append libtool_args " $func_quote_for_eval_result"
5206266e564dSmrg
5207698f425bSmrg      # If the previous option needs an argument, assign it.
5208698f425bSmrg      if test -n "$prev"; then
5209698f425bSmrg	case $prev in
5210698f425bSmrg	output)
5211698f425bSmrg	  func_append compile_command " @OUTPUT@"
5212698f425bSmrg	  func_append finalize_command " @OUTPUT@"
5213698f425bSmrg	  ;;
5214698f425bSmrg	esac
5215266e564dSmrg
5216698f425bSmrg	case $prev in
52179ef0b394Smrg	bindir)
52189ef0b394Smrg	  bindir="$arg"
52199ef0b394Smrg	  prev=
52209ef0b394Smrg	  continue
52219ef0b394Smrg	  ;;
5222698f425bSmrg	dlfiles|dlprefiles)
5223698f425bSmrg	  if test "$preload" = no; then
5224698f425bSmrg	    # Add the symbol object into the linking commands.
5225698f425bSmrg	    func_append compile_command " @SYMFILE@"
5226698f425bSmrg	    func_append finalize_command " @SYMFILE@"
5227698f425bSmrg	    preload=yes
5228266e564dSmrg	  fi
5229698f425bSmrg	  case $arg in
5230698f425bSmrg	  *.la | *.lo) ;;  # We handle these cases below.
5231698f425bSmrg	  force)
5232698f425bSmrg	    if test "$dlself" = no; then
5233698f425bSmrg	      dlself=needless
5234698f425bSmrg	      export_dynamic=yes
5235698f425bSmrg	    fi
5236698f425bSmrg	    prev=
5237698f425bSmrg	    continue
5238698f425bSmrg	    ;;
5239698f425bSmrg	  self)
5240698f425bSmrg	    if test "$prev" = dlprefiles; then
5241698f425bSmrg	      dlself=yes
5242698f425bSmrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
5243698f425bSmrg	      dlself=yes
5244698f425bSmrg	    else
5245698f425bSmrg	      dlself=needless
5246698f425bSmrg	      export_dynamic=yes
5247698f425bSmrg	    fi
5248698f425bSmrg	    prev=
5249698f425bSmrg	    continue
5250698f425bSmrg	    ;;
5251698f425bSmrg	  *)
5252698f425bSmrg	    if test "$prev" = dlfiles; then
52539ef0b394Smrg	      func_append dlfiles " $arg"
5254698f425bSmrg	    else
52559ef0b394Smrg	      func_append dlprefiles " $arg"
5256698f425bSmrg	    fi
5257698f425bSmrg	    prev=
5258698f425bSmrg	    continue
5259698f425bSmrg	    ;;
5260698f425bSmrg	  esac
5261698f425bSmrg	  ;;
5262698f425bSmrg	expsyms)
5263698f425bSmrg	  export_symbols="$arg"
5264698f425bSmrg	  test -f "$arg" \
5265698f425bSmrg	    || func_fatal_error "symbol file \`$arg' does not exist"
5266698f425bSmrg	  prev=
5267698f425bSmrg	  continue
5268698f425bSmrg	  ;;
5269698f425bSmrg	expsyms_regex)
5270698f425bSmrg	  export_symbols_regex="$arg"
5271698f425bSmrg	  prev=
5272698f425bSmrg	  continue
5273698f425bSmrg	  ;;
5274698f425bSmrg	framework)
5275266e564dSmrg	  case $host in
5276698f425bSmrg	    *-*-darwin*)
5277698f425bSmrg	      case "$deplibs " in
5278698f425bSmrg		*" $qarg.ltframework "*) ;;
52799ef0b394Smrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
5280698f425bSmrg		   ;;
5281698f425bSmrg	      esac
5282698f425bSmrg	      ;;
5283266e564dSmrg	  esac
5284698f425bSmrg	  prev=
5285698f425bSmrg	  continue
5286266e564dSmrg	  ;;
5287698f425bSmrg	inst_prefix)
5288698f425bSmrg	  inst_prefix_dir="$arg"
5289698f425bSmrg	  prev=
5290698f425bSmrg	  continue
5291266e564dSmrg	  ;;
5292698f425bSmrg	objectlist)
5293698f425bSmrg	  if test -f "$arg"; then
5294698f425bSmrg	    save_arg=$arg
5295698f425bSmrg	    moreargs=
5296698f425bSmrg	    for fil in `cat "$save_arg"`
5297698f425bSmrg	    do
52989ef0b394Smrg#	      func_append moreargs " $fil"
5299698f425bSmrg	      arg=$fil
5300698f425bSmrg	      # A libtool-controlled object.
5301266e564dSmrg
5302698f425bSmrg	      # Check to see that this really is a libtool object.
5303698f425bSmrg	      if func_lalib_unsafe_p "$arg"; then
5304698f425bSmrg		pic_object=
5305698f425bSmrg		non_pic_object=
5306266e564dSmrg
5307698f425bSmrg		# Read the .lo file
5308698f425bSmrg		func_source "$arg"
5309266e564dSmrg
5310698f425bSmrg		if test -z "$pic_object" ||
5311698f425bSmrg		   test -z "$non_pic_object" ||
5312698f425bSmrg		   test "$pic_object" = none &&
5313698f425bSmrg		   test "$non_pic_object" = none; then
5314698f425bSmrg		  func_fatal_error "cannot find name of object for \`$arg'"
5315698f425bSmrg		fi
5316266e564dSmrg
5317698f425bSmrg		# Extract subdirectory from the argument.
5318698f425bSmrg		func_dirname "$arg" "/" ""
5319698f425bSmrg		xdir="$func_dirname_result"
5320266e564dSmrg
5321698f425bSmrg		if test "$pic_object" != none; then
5322698f425bSmrg		  # Prepend the subdirectory the object is found in.
5323698f425bSmrg		  pic_object="$xdir$pic_object"
5324266e564dSmrg
5325698f425bSmrg		  if test "$prev" = dlfiles; then
5326698f425bSmrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
53279ef0b394Smrg		      func_append dlfiles " $pic_object"
5328698f425bSmrg		      prev=
5329698f425bSmrg		      continue
5330698f425bSmrg		    else
5331698f425bSmrg		      # If libtool objects are unsupported, then we need to preload.
5332698f425bSmrg		      prev=dlprefiles
5333698f425bSmrg		    fi
5334698f425bSmrg		  fi
5335266e564dSmrg
5336698f425bSmrg		  # CHECK ME:  I think I busted this.  -Ossama
5337698f425bSmrg		  if test "$prev" = dlprefiles; then
5338698f425bSmrg		    # Preload the old-style object.
53399ef0b394Smrg		    func_append dlprefiles " $pic_object"
5340698f425bSmrg		    prev=
5341698f425bSmrg		  fi
5342266e564dSmrg
5343698f425bSmrg		  # A PIC object.
5344698f425bSmrg		  func_append libobjs " $pic_object"
5345698f425bSmrg		  arg="$pic_object"
5346698f425bSmrg		fi
5347266e564dSmrg
5348698f425bSmrg		# Non-PIC object.
5349698f425bSmrg		if test "$non_pic_object" != none; then
5350698f425bSmrg		  # Prepend the subdirectory the object is found in.
5351698f425bSmrg		  non_pic_object="$xdir$non_pic_object"
5352698f425bSmrg
5353698f425bSmrg		  # A standard non-PIC object
5354698f425bSmrg		  func_append non_pic_objects " $non_pic_object"
5355698f425bSmrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
5356698f425bSmrg		    arg="$non_pic_object"
5357698f425bSmrg		  fi
5358698f425bSmrg		else
5359698f425bSmrg		  # If the PIC object exists, use it instead.
5360698f425bSmrg		  # $xdir was prepended to $pic_object above.
5361698f425bSmrg		  non_pic_object="$pic_object"
5362698f425bSmrg		  func_append non_pic_objects " $non_pic_object"
5363698f425bSmrg		fi
5364698f425bSmrg	      else
5365698f425bSmrg		# Only an error if not doing a dry-run.
5366698f425bSmrg		if $opt_dry_run; then
5367698f425bSmrg		  # Extract subdirectory from the argument.
5368698f425bSmrg		  func_dirname "$arg" "/" ""
5369698f425bSmrg		  xdir="$func_dirname_result"
5370698f425bSmrg
5371698f425bSmrg		  func_lo2o "$arg"
5372698f425bSmrg		  pic_object=$xdir$objdir/$func_lo2o_result
5373698f425bSmrg		  non_pic_object=$xdir$func_lo2o_result
5374698f425bSmrg		  func_append libobjs " $pic_object"
5375698f425bSmrg		  func_append non_pic_objects " $non_pic_object"
5376698f425bSmrg	        else
5377698f425bSmrg		  func_fatal_error "\`$arg' is not a valid libtool object"
5378698f425bSmrg		fi
5379698f425bSmrg	      fi
5380698f425bSmrg	    done
5381266e564dSmrg	  else
5382698f425bSmrg	    func_fatal_error "link input file \`$arg' does not exist"
5383266e564dSmrg	  fi
5384698f425bSmrg	  arg=$save_arg
5385698f425bSmrg	  prev=
5386698f425bSmrg	  continue
5387698f425bSmrg	  ;;
5388698f425bSmrg	precious_regex)
5389698f425bSmrg	  precious_files_regex="$arg"
5390698f425bSmrg	  prev=
5391698f425bSmrg	  continue
5392698f425bSmrg	  ;;
5393698f425bSmrg	release)
5394698f425bSmrg	  release="-$arg"
5395698f425bSmrg	  prev=
5396698f425bSmrg	  continue
5397698f425bSmrg	  ;;
5398698f425bSmrg	rpath | xrpath)
5399698f425bSmrg	  # We need an absolute path.
5400698f425bSmrg	  case $arg in
5401698f425bSmrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
5402698f425bSmrg	  *)
5403698f425bSmrg	    func_fatal_error "only absolute run-paths are allowed"
5404698f425bSmrg	    ;;
5405698f425bSmrg	  esac
5406698f425bSmrg	  if test "$prev" = rpath; then
5407698f425bSmrg	    case "$rpath " in
5408698f425bSmrg	    *" $arg "*) ;;
54099ef0b394Smrg	    *) func_append rpath " $arg" ;;
5410698f425bSmrg	    esac
5411266e564dSmrg	  else
5412698f425bSmrg	    case "$xrpath " in
5413698f425bSmrg	    *" $arg "*) ;;
54149ef0b394Smrg	    *) func_append xrpath " $arg" ;;
5415698f425bSmrg	    esac
5416266e564dSmrg	  fi
5417698f425bSmrg	  prev=
5418698f425bSmrg	  continue
5419698f425bSmrg	  ;;
5420698f425bSmrg	shrext)
5421698f425bSmrg	  shrext_cmds="$arg"
5422698f425bSmrg	  prev=
5423698f425bSmrg	  continue
5424698f425bSmrg	  ;;
5425698f425bSmrg	weak)
54269ef0b394Smrg	  func_append weak_libs " $arg"
5427698f425bSmrg	  prev=
5428698f425bSmrg	  continue
5429698f425bSmrg	  ;;
5430698f425bSmrg	xcclinker)
54319ef0b394Smrg	  func_append linker_flags " $qarg"
54329ef0b394Smrg	  func_append compiler_flags " $qarg"
5433698f425bSmrg	  prev=
5434698f425bSmrg	  func_append compile_command " $qarg"
5435698f425bSmrg	  func_append finalize_command " $qarg"
5436698f425bSmrg	  continue
5437698f425bSmrg	  ;;
5438698f425bSmrg	xcompiler)
54399ef0b394Smrg	  func_append compiler_flags " $qarg"
5440698f425bSmrg	  prev=
5441698f425bSmrg	  func_append compile_command " $qarg"
5442698f425bSmrg	  func_append finalize_command " $qarg"
5443698f425bSmrg	  continue
5444698f425bSmrg	  ;;
5445698f425bSmrg	xlinker)
54469ef0b394Smrg	  func_append linker_flags " $qarg"
54479ef0b394Smrg	  func_append compiler_flags " $wl$qarg"
5448698f425bSmrg	  prev=
5449698f425bSmrg	  func_append compile_command " $wl$qarg"
5450698f425bSmrg	  func_append finalize_command " $wl$qarg"
5451698f425bSmrg	  continue
5452698f425bSmrg	  ;;
5453698f425bSmrg	*)
5454698f425bSmrg	  eval "$prev=\"\$arg\""
5455698f425bSmrg	  prev=
5456698f425bSmrg	  continue
5457698f425bSmrg	  ;;
5458266e564dSmrg	esac
5459698f425bSmrg      fi # test -n "$prev"
5460266e564dSmrg
5461698f425bSmrg      prevarg="$arg"
5462266e564dSmrg
5463698f425bSmrg      case $arg in
5464698f425bSmrg      -all-static)
5465698f425bSmrg	if test -n "$link_static_flag"; then
5466698f425bSmrg	  # See comment for -static flag below, for more details.
5467698f425bSmrg	  func_append compile_command " $link_static_flag"
5468698f425bSmrg	  func_append finalize_command " $link_static_flag"
5469698f425bSmrg	fi
5470698f425bSmrg	continue
5471698f425bSmrg	;;
5472266e564dSmrg
5473698f425bSmrg      -allow-undefined)
5474698f425bSmrg	# FIXME: remove this flag sometime in the future.
5475698f425bSmrg	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
5476698f425bSmrg	;;
5477266e564dSmrg
5478698f425bSmrg      -avoid-version)
5479698f425bSmrg	avoid_version=yes
5480698f425bSmrg	continue
5481698f425bSmrg	;;
5482266e564dSmrg
54839ef0b394Smrg      -bindir)
54849ef0b394Smrg	prev=bindir
54859ef0b394Smrg	continue
54869ef0b394Smrg	;;
54879ef0b394Smrg
5488698f425bSmrg      -dlopen)
5489698f425bSmrg	prev=dlfiles
5490698f425bSmrg	continue
5491698f425bSmrg	;;
5492266e564dSmrg
5493698f425bSmrg      -dlpreopen)
5494698f425bSmrg	prev=dlprefiles
5495698f425bSmrg	continue
5496698f425bSmrg	;;
5497266e564dSmrg
5498698f425bSmrg      -export-dynamic)
5499698f425bSmrg	export_dynamic=yes
5500698f425bSmrg	continue
5501698f425bSmrg	;;
5502266e564dSmrg
5503698f425bSmrg      -export-symbols | -export-symbols-regex)
5504698f425bSmrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
5505698f425bSmrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
5506698f425bSmrg	fi
5507698f425bSmrg	if test "X$arg" = "X-export-symbols"; then
5508698f425bSmrg	  prev=expsyms
5509698f425bSmrg	else
5510698f425bSmrg	  prev=expsyms_regex
5511698f425bSmrg	fi
5512698f425bSmrg	continue
5513698f425bSmrg	;;
5514266e564dSmrg
5515698f425bSmrg      -framework)
5516698f425bSmrg	prev=framework
5517698f425bSmrg	continue
5518698f425bSmrg	;;
5519266e564dSmrg
5520698f425bSmrg      -inst-prefix-dir)
5521698f425bSmrg	prev=inst_prefix
5522698f425bSmrg	continue
5523698f425bSmrg	;;
5524266e564dSmrg
5525698f425bSmrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
5526698f425bSmrg      # so, if we see these flags be careful not to treat them like -L
5527698f425bSmrg      -L[A-Z][A-Z]*:*)
5528698f425bSmrg	case $with_gcc/$host in
5529698f425bSmrg	no/*-*-irix* | /*-*-irix*)
5530698f425bSmrg	  func_append compile_command " $arg"
5531698f425bSmrg	  func_append finalize_command " $arg"
5532698f425bSmrg	  ;;
5533698f425bSmrg	esac
5534698f425bSmrg	continue
5535698f425bSmrg	;;
5536266e564dSmrg
5537698f425bSmrg      -L*)
55389ef0b394Smrg	func_stripname "-L" '' "$arg"
55399ef0b394Smrg	if test -z "$func_stripname_result"; then
5540698f425bSmrg	  if test "$#" -gt 0; then
5541698f425bSmrg	    func_fatal_error "require no space between \`-L' and \`$1'"
5542698f425bSmrg	  else
5543698f425bSmrg	    func_fatal_error "need path for \`-L' option"
5544698f425bSmrg	  fi
5545698f425bSmrg	fi
55469ef0b394Smrg	func_resolve_sysroot "$func_stripname_result"
55479ef0b394Smrg	dir=$func_resolve_sysroot_result
5548698f425bSmrg	# We need an absolute path.
5549698f425bSmrg	case $dir in
5550698f425bSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
5551698f425bSmrg	*)
5552698f425bSmrg	  absdir=`cd "$dir" && pwd`
5553698f425bSmrg	  test -z "$absdir" && \
5554698f425bSmrg	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
5555698f425bSmrg	  dir="$absdir"
5556698f425bSmrg	  ;;
5557698f425bSmrg	esac
5558698f425bSmrg	case "$deplibs " in
55599ef0b394Smrg	*" -L$dir "* | *" $arg "*)
55609ef0b394Smrg	  # Will only happen for absolute or sysroot arguments
55619ef0b394Smrg	  ;;
5562698f425bSmrg	*)
55639ef0b394Smrg	  # Preserve sysroot, but never include relative directories
55649ef0b394Smrg	  case $dir in
55659ef0b394Smrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
55669ef0b394Smrg	    *) func_append deplibs " -L$dir" ;;
55679ef0b394Smrg	  esac
55689ef0b394Smrg	  func_append lib_search_path " $dir"
5569698f425bSmrg	  ;;
5570698f425bSmrg	esac
5571698f425bSmrg	case $host in
5572698f425bSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
55739ef0b394Smrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
5574698f425bSmrg	  case :$dllsearchpath: in
5575698f425bSmrg	  *":$dir:"*) ;;
5576698f425bSmrg	  ::) dllsearchpath=$dir;;
55779ef0b394Smrg	  *) func_append dllsearchpath ":$dir";;
5578698f425bSmrg	  esac
5579698f425bSmrg	  case :$dllsearchpath: in
5580698f425bSmrg	  *":$testbindir:"*) ;;
5581698f425bSmrg	  ::) dllsearchpath=$testbindir;;
55829ef0b394Smrg	  *) func_append dllsearchpath ":$testbindir";;
5583698f425bSmrg	  esac
5584698f425bSmrg	  ;;
5585698f425bSmrg	esac
5586698f425bSmrg	continue
5587698f425bSmrg	;;
5588266e564dSmrg
5589698f425bSmrg      -l*)
5590698f425bSmrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
5591698f425bSmrg	  case $host in
55929ef0b394Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
5593698f425bSmrg	    # These systems don't actually have a C or math library (as such)
5594698f425bSmrg	    continue
5595698f425bSmrg	    ;;
5596698f425bSmrg	  *-*-os2*)
5597698f425bSmrg	    # These systems don't actually have a C library (as such)
5598698f425bSmrg	    test "X$arg" = "X-lc" && continue
5599698f425bSmrg	    ;;
5600698f425bSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5601698f425bSmrg	    # Do not include libc due to us having libc/libc_r.
5602698f425bSmrg	    test "X$arg" = "X-lc" && continue
5603698f425bSmrg	    ;;
5604698f425bSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
5605698f425bSmrg	    # Rhapsody C and math libraries are in the System framework
56069ef0b394Smrg	    func_append deplibs " System.ltframework"
5607698f425bSmrg	    continue
5608698f425bSmrg	    ;;
5609698f425bSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
5610698f425bSmrg	    # Causes problems with __ctype
5611698f425bSmrg	    test "X$arg" = "X-lc" && continue
5612698f425bSmrg	    ;;
5613698f425bSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
5614698f425bSmrg	    # Compiler inserts libc in the correct place for threads to work
5615698f425bSmrg	    test "X$arg" = "X-lc" && continue
5616698f425bSmrg	    ;;
5617698f425bSmrg	  esac
5618698f425bSmrg	elif test "X$arg" = "X-lc_r"; then
5619698f425bSmrg	 case $host in
5620698f425bSmrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5621698f425bSmrg	   # Do not include libc_r directly, use -pthread flag.
5622698f425bSmrg	   continue
5623698f425bSmrg	   ;;
5624698f425bSmrg	 esac
5625698f425bSmrg	fi
56269ef0b394Smrg	func_append deplibs " $arg"
5627698f425bSmrg	continue
5628698f425bSmrg	;;
5629266e564dSmrg
5630698f425bSmrg      -module)
5631698f425bSmrg	module=yes
5632698f425bSmrg	continue
5633698f425bSmrg	;;
5634266e564dSmrg
5635698f425bSmrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
5636698f425bSmrg      # classes, name mangling, and exception handling.
5637698f425bSmrg      # Darwin uses the -arch flag to determine output architecture.
56389ef0b394Smrg      -model|-arch|-isysroot|--sysroot)
56399ef0b394Smrg	func_append compiler_flags " $arg"
5640698f425bSmrg	func_append compile_command " $arg"
5641698f425bSmrg	func_append finalize_command " $arg"
5642698f425bSmrg	prev=xcompiler
5643698f425bSmrg	continue
5644698f425bSmrg	;;
5645266e564dSmrg
5646698f425bSmrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
56479ef0b394Smrg	func_append compiler_flags " $arg"
5648698f425bSmrg	func_append compile_command " $arg"
5649698f425bSmrg	func_append finalize_command " $arg"
5650698f425bSmrg	case "$new_inherited_linker_flags " in
5651698f425bSmrg	    *" $arg "*) ;;
56529ef0b394Smrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
5653698f425bSmrg	esac
5654698f425bSmrg	continue
5655698f425bSmrg	;;
5656266e564dSmrg
5657698f425bSmrg      -multi_module)
5658698f425bSmrg	single_module="${wl}-multi_module"
5659698f425bSmrg	continue
5660698f425bSmrg	;;
5661266e564dSmrg
5662698f425bSmrg      -no-fast-install)
5663698f425bSmrg	fast_install=no
5664698f425bSmrg	continue
5665698f425bSmrg	;;
5666266e564dSmrg
5667698f425bSmrg      -no-install)
5668698f425bSmrg	case $host in
5669698f425bSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
5670698f425bSmrg	  # The PATH hackery in wrapper scripts is required on Windows
5671698f425bSmrg	  # and Darwin in order for the loader to find any dlls it needs.
5672698f425bSmrg	  func_warning "\`-no-install' is ignored for $host"
5673698f425bSmrg	  func_warning "assuming \`-no-fast-install' instead"
5674698f425bSmrg	  fast_install=no
5675698f425bSmrg	  ;;
5676698f425bSmrg	*) no_install=yes ;;
5677698f425bSmrg	esac
5678698f425bSmrg	continue
5679698f425bSmrg	;;
5680266e564dSmrg
5681698f425bSmrg      -no-undefined)
5682698f425bSmrg	allow_undefined=no
5683698f425bSmrg	continue
5684698f425bSmrg	;;
5685266e564dSmrg
5686698f425bSmrg      -objectlist)
5687698f425bSmrg	prev=objectlist
5688698f425bSmrg	continue
5689698f425bSmrg	;;
5690266e564dSmrg
5691698f425bSmrg      -o) prev=output ;;
5692266e564dSmrg
5693698f425bSmrg      -precious-files-regex)
5694698f425bSmrg	prev=precious_regex
5695698f425bSmrg	continue
5696698f425bSmrg	;;
5697266e564dSmrg
5698698f425bSmrg      -release)
5699698f425bSmrg	prev=release
5700698f425bSmrg	continue
5701698f425bSmrg	;;
5702266e564dSmrg
5703698f425bSmrg      -rpath)
5704698f425bSmrg	prev=rpath
5705698f425bSmrg	continue
5706698f425bSmrg	;;
5707266e564dSmrg
5708698f425bSmrg      -R)
5709698f425bSmrg	prev=xrpath
5710698f425bSmrg	continue
5711698f425bSmrg	;;
5712266e564dSmrg
5713698f425bSmrg      -R*)
5714698f425bSmrg	func_stripname '-R' '' "$arg"
5715698f425bSmrg	dir=$func_stripname_result
5716698f425bSmrg	# We need an absolute path.
5717698f425bSmrg	case $dir in
5718698f425bSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
57199ef0b394Smrg	=*)
57209ef0b394Smrg	  func_stripname '=' '' "$dir"
57219ef0b394Smrg	  dir=$lt_sysroot$func_stripname_result
57229ef0b394Smrg	  ;;
5723698f425bSmrg	*)
5724698f425bSmrg	  func_fatal_error "only absolute run-paths are allowed"
5725698f425bSmrg	  ;;
5726698f425bSmrg	esac
5727698f425bSmrg	case "$xrpath " in
5728698f425bSmrg	*" $dir "*) ;;
57299ef0b394Smrg	*) func_append xrpath " $dir" ;;
5730698f425bSmrg	esac
5731698f425bSmrg	continue
5732698f425bSmrg	;;
5733266e564dSmrg
5734698f425bSmrg      -shared)
5735698f425bSmrg	# The effects of -shared are defined in a previous loop.
5736698f425bSmrg	continue
5737698f425bSmrg	;;
5738266e564dSmrg
5739698f425bSmrg      -shrext)
5740698f425bSmrg	prev=shrext
5741698f425bSmrg	continue
5742698f425bSmrg	;;
5743266e564dSmrg
5744698f425bSmrg      -static | -static-libtool-libs)
5745698f425bSmrg	# The effects of -static are defined in a previous loop.
5746698f425bSmrg	# We used to do the same as -all-static on platforms that
5747698f425bSmrg	# didn't have a PIC flag, but the assumption that the effects
5748698f425bSmrg	# would be equivalent was wrong.  It would break on at least
5749698f425bSmrg	# Digital Unix and AIX.
5750698f425bSmrg	continue
5751698f425bSmrg	;;
5752266e564dSmrg
5753698f425bSmrg      -thread-safe)
5754698f425bSmrg	thread_safe=yes
5755698f425bSmrg	continue
5756698f425bSmrg	;;
5757266e564dSmrg
5758698f425bSmrg      -version-info)
5759698f425bSmrg	prev=vinfo
5760698f425bSmrg	continue
5761698f425bSmrg	;;
5762266e564dSmrg
5763698f425bSmrg      -version-number)
5764698f425bSmrg	prev=vinfo
5765698f425bSmrg	vinfo_number=yes
5766698f425bSmrg	continue
5767698f425bSmrg	;;
5768266e564dSmrg
5769698f425bSmrg      -weak)
5770698f425bSmrg        prev=weak
5771698f425bSmrg	continue
5772698f425bSmrg	;;
5773266e564dSmrg
5774698f425bSmrg      -Wc,*)
5775698f425bSmrg	func_stripname '-Wc,' '' "$arg"
5776698f425bSmrg	args=$func_stripname_result
5777698f425bSmrg	arg=
5778698f425bSmrg	save_ifs="$IFS"; IFS=','
5779698f425bSmrg	for flag in $args; do
5780698f425bSmrg	  IFS="$save_ifs"
5781698f425bSmrg          func_quote_for_eval "$flag"
57829ef0b394Smrg	  func_append arg " $func_quote_for_eval_result"
57839ef0b394Smrg	  func_append compiler_flags " $func_quote_for_eval_result"
5784698f425bSmrg	done
5785698f425bSmrg	IFS="$save_ifs"
5786698f425bSmrg	func_stripname ' ' '' "$arg"
5787698f425bSmrg	arg=$func_stripname_result
5788698f425bSmrg	;;
5789266e564dSmrg
5790698f425bSmrg      -Wl,*)
5791698f425bSmrg	func_stripname '-Wl,' '' "$arg"
5792698f425bSmrg	args=$func_stripname_result
5793698f425bSmrg	arg=
5794698f425bSmrg	save_ifs="$IFS"; IFS=','
5795698f425bSmrg	for flag in $args; do
5796698f425bSmrg	  IFS="$save_ifs"
5797698f425bSmrg          func_quote_for_eval "$flag"
57989ef0b394Smrg	  func_append arg " $wl$func_quote_for_eval_result"
57999ef0b394Smrg	  func_append compiler_flags " $wl$func_quote_for_eval_result"
58009ef0b394Smrg	  func_append linker_flags " $func_quote_for_eval_result"
5801698f425bSmrg	done
5802698f425bSmrg	IFS="$save_ifs"
5803698f425bSmrg	func_stripname ' ' '' "$arg"
5804698f425bSmrg	arg=$func_stripname_result
5805698f425bSmrg	;;
5806266e564dSmrg
5807698f425bSmrg      -Xcompiler)
5808698f425bSmrg	prev=xcompiler
5809698f425bSmrg	continue
5810698f425bSmrg	;;
5811266e564dSmrg
5812698f425bSmrg      -Xlinker)
5813698f425bSmrg	prev=xlinker
5814698f425bSmrg	continue
5815698f425bSmrg	;;
5816266e564dSmrg
5817698f425bSmrg      -XCClinker)
5818698f425bSmrg	prev=xcclinker
5819698f425bSmrg	continue
5820698f425bSmrg	;;
5821266e564dSmrg
5822698f425bSmrg      # -msg_* for osf cc
5823698f425bSmrg      -msg_*)
5824698f425bSmrg	func_quote_for_eval "$arg"
5825698f425bSmrg	arg="$func_quote_for_eval_result"
5826698f425bSmrg	;;
5827266e564dSmrg
58289ef0b394Smrg      # Flags to be passed through unchanged, with rationale:
58299ef0b394Smrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
58309ef0b394Smrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
58319ef0b394Smrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
58329ef0b394Smrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
58339ef0b394Smrg      # -q*                  compiler args for the IBM compiler
58349ef0b394Smrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
58359ef0b394Smrg      # -F/path              path to uninstalled frameworks, gcc on darwin
58369ef0b394Smrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
58379ef0b394Smrg      # @file                GCC response files
58389ef0b394Smrg      # -tp=*                Portland pgcc target processor selection
58399ef0b394Smrg      # --sysroot=*          for sysroot support
58409ef0b394Smrg      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
5841698f425bSmrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
58429ef0b394Smrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
58439ef0b394Smrg      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
5844698f425bSmrg        func_quote_for_eval "$arg"
5845698f425bSmrg	arg="$func_quote_for_eval_result"
5846698f425bSmrg        func_append compile_command " $arg"
5847698f425bSmrg        func_append finalize_command " $arg"
58489ef0b394Smrg        func_append compiler_flags " $arg"
5849698f425bSmrg        continue
5850698f425bSmrg        ;;
5851266e564dSmrg
5852698f425bSmrg      # Some other compiler flag.
5853698f425bSmrg      -* | +*)
5854698f425bSmrg        func_quote_for_eval "$arg"
5855698f425bSmrg	arg="$func_quote_for_eval_result"
5856698f425bSmrg	;;
5857266e564dSmrg
5858698f425bSmrg      *.$objext)
5859698f425bSmrg	# A standard object.
58609ef0b394Smrg	func_append objs " $arg"
5861698f425bSmrg	;;
5862266e564dSmrg
5863698f425bSmrg      *.lo)
5864698f425bSmrg	# A libtool-controlled object.
5865266e564dSmrg
5866698f425bSmrg	# Check to see that this really is a libtool object.
5867698f425bSmrg	if func_lalib_unsafe_p "$arg"; then
5868698f425bSmrg	  pic_object=
5869698f425bSmrg	  non_pic_object=
5870266e564dSmrg
5871698f425bSmrg	  # Read the .lo file
5872698f425bSmrg	  func_source "$arg"
5873266e564dSmrg
5874698f425bSmrg	  if test -z "$pic_object" ||
5875698f425bSmrg	     test -z "$non_pic_object" ||
5876698f425bSmrg	     test "$pic_object" = none &&
5877698f425bSmrg	     test "$non_pic_object" = none; then
5878698f425bSmrg	    func_fatal_error "cannot find name of object for \`$arg'"
5879698f425bSmrg	  fi
5880c5629e66Smrg
5881698f425bSmrg	  # Extract subdirectory from the argument.
5882698f425bSmrg	  func_dirname "$arg" "/" ""
5883698f425bSmrg	  xdir="$func_dirname_result"
5884266e564dSmrg
5885698f425bSmrg	  if test "$pic_object" != none; then
5886698f425bSmrg	    # Prepend the subdirectory the object is found in.
5887698f425bSmrg	    pic_object="$xdir$pic_object"
5888266e564dSmrg
5889698f425bSmrg	    if test "$prev" = dlfiles; then
5890698f425bSmrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
58919ef0b394Smrg		func_append dlfiles " $pic_object"
5892698f425bSmrg		prev=
5893698f425bSmrg		continue
5894698f425bSmrg	      else
5895698f425bSmrg		# If libtool objects are unsupported, then we need to preload.
5896698f425bSmrg		prev=dlprefiles
5897698f425bSmrg	      fi
5898698f425bSmrg	    fi
5899266e564dSmrg
5900698f425bSmrg	    # CHECK ME:  I think I busted this.  -Ossama
5901698f425bSmrg	    if test "$prev" = dlprefiles; then
5902698f425bSmrg	      # Preload the old-style object.
59039ef0b394Smrg	      func_append dlprefiles " $pic_object"
5904698f425bSmrg	      prev=
5905698f425bSmrg	    fi
5906266e564dSmrg
5907698f425bSmrg	    # A PIC object.
5908698f425bSmrg	    func_append libobjs " $pic_object"
5909698f425bSmrg	    arg="$pic_object"
5910698f425bSmrg	  fi
5911266e564dSmrg
5912698f425bSmrg	  # Non-PIC object.
5913698f425bSmrg	  if test "$non_pic_object" != none; then
5914698f425bSmrg	    # Prepend the subdirectory the object is found in.
5915698f425bSmrg	    non_pic_object="$xdir$non_pic_object"
5916266e564dSmrg
5917698f425bSmrg	    # A standard non-PIC object
5918698f425bSmrg	    func_append non_pic_objects " $non_pic_object"
5919698f425bSmrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
5920698f425bSmrg	      arg="$non_pic_object"
5921698f425bSmrg	    fi
5922698f425bSmrg	  else
5923698f425bSmrg	    # If the PIC object exists, use it instead.
5924698f425bSmrg	    # $xdir was prepended to $pic_object above.
5925698f425bSmrg	    non_pic_object="$pic_object"
5926698f425bSmrg	    func_append non_pic_objects " $non_pic_object"
5927698f425bSmrg	  fi
5928698f425bSmrg	else
5929698f425bSmrg	  # Only an error if not doing a dry-run.
5930698f425bSmrg	  if $opt_dry_run; then
5931698f425bSmrg	    # Extract subdirectory from the argument.
5932698f425bSmrg	    func_dirname "$arg" "/" ""
5933698f425bSmrg	    xdir="$func_dirname_result"
5934698f425bSmrg
5935698f425bSmrg	    func_lo2o "$arg"
5936698f425bSmrg	    pic_object=$xdir$objdir/$func_lo2o_result
5937698f425bSmrg	    non_pic_object=$xdir$func_lo2o_result
5938698f425bSmrg	    func_append libobjs " $pic_object"
5939698f425bSmrg	    func_append non_pic_objects " $non_pic_object"
5940698f425bSmrg	  else
5941698f425bSmrg	    func_fatal_error "\`$arg' is not a valid libtool object"
5942698f425bSmrg	  fi
5943698f425bSmrg	fi
5944698f425bSmrg	;;
5945698f425bSmrg
5946698f425bSmrg      *.$libext)
5947698f425bSmrg	# An archive.
59489ef0b394Smrg	func_append deplibs " $arg"
59499ef0b394Smrg	func_append old_deplibs " $arg"
5950698f425bSmrg	continue
5951698f425bSmrg	;;
5952698f425bSmrg
5953698f425bSmrg      *.la)
5954698f425bSmrg	# A libtool-controlled library.
5955698f425bSmrg
59569ef0b394Smrg	func_resolve_sysroot "$arg"
5957698f425bSmrg	if test "$prev" = dlfiles; then
5958698f425bSmrg	  # This library was specified with -dlopen.
59599ef0b394Smrg	  func_append dlfiles " $func_resolve_sysroot_result"
5960698f425bSmrg	  prev=
5961698f425bSmrg	elif test "$prev" = dlprefiles; then
5962698f425bSmrg	  # The library was specified with -dlpreopen.
59639ef0b394Smrg	  func_append dlprefiles " $func_resolve_sysroot_result"
5964698f425bSmrg	  prev=
5965698f425bSmrg	else
59669ef0b394Smrg	  func_append deplibs " $func_resolve_sysroot_result"
5967698f425bSmrg	fi
5968698f425bSmrg	continue
5969698f425bSmrg	;;
5970698f425bSmrg
5971698f425bSmrg      # Some other compiler argument.
5972698f425bSmrg      *)
5973698f425bSmrg	# Unknown arguments in both finalize_command and compile_command need
5974698f425bSmrg	# to be aesthetically quoted because they are evaled later.
5975698f425bSmrg	func_quote_for_eval "$arg"
5976698f425bSmrg	arg="$func_quote_for_eval_result"
5977698f425bSmrg	;;
5978698f425bSmrg      esac # arg
5979698f425bSmrg
5980698f425bSmrg      # Now actually substitute the argument into the commands.
5981698f425bSmrg      if test -n "$arg"; then
5982698f425bSmrg	func_append compile_command " $arg"
5983698f425bSmrg	func_append finalize_command " $arg"
5984698f425bSmrg      fi
5985698f425bSmrg    done # argument parsing loop
5986698f425bSmrg
5987698f425bSmrg    test -n "$prev" && \
5988698f425bSmrg      func_fatal_help "the \`$prevarg' option requires an argument"
5989698f425bSmrg
5990698f425bSmrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
5991698f425bSmrg      eval arg=\"$export_dynamic_flag_spec\"
5992698f425bSmrg      func_append compile_command " $arg"
5993698f425bSmrg      func_append finalize_command " $arg"
5994698f425bSmrg    fi
5995698f425bSmrg
5996698f425bSmrg    oldlibs=
5997698f425bSmrg    # calculate the name of the file, without its directory
5998698f425bSmrg    func_basename "$output"
5999698f425bSmrg    outputname="$func_basename_result"
6000698f425bSmrg    libobjs_save="$libobjs"
6001698f425bSmrg
6002698f425bSmrg    if test -n "$shlibpath_var"; then
6003698f425bSmrg      # get the directories listed in $shlibpath_var
60049ef0b394Smrg      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
6005698f425bSmrg    else
6006698f425bSmrg      shlib_search_path=
6007698f425bSmrg    fi
6008698f425bSmrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
6009698f425bSmrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
6010698f425bSmrg
6011698f425bSmrg    func_dirname "$output" "/" ""
6012698f425bSmrg    output_objdir="$func_dirname_result$objdir"
60139ef0b394Smrg    func_to_tool_file "$output_objdir/"
60149ef0b394Smrg    tool_output_objdir=$func_to_tool_file_result
6015698f425bSmrg    # Create the object directory.
6016698f425bSmrg    func_mkdir_p "$output_objdir"
6017698f425bSmrg
6018698f425bSmrg    # Determine the type of output
6019698f425bSmrg    case $output in
6020698f425bSmrg    "")
6021698f425bSmrg      func_fatal_help "you must specify an output file"
6022698f425bSmrg      ;;
6023698f425bSmrg    *.$libext) linkmode=oldlib ;;
6024698f425bSmrg    *.lo | *.$objext) linkmode=obj ;;
6025698f425bSmrg    *.la) linkmode=lib ;;
6026698f425bSmrg    *) linkmode=prog ;; # Anything else should be a program.
6027698f425bSmrg    esac
6028698f425bSmrg
6029698f425bSmrg    specialdeplibs=
6030698f425bSmrg
6031698f425bSmrg    libs=
6032698f425bSmrg    # Find all interdependent deplibs by searching for libraries
6033698f425bSmrg    # that are linked more than once (e.g. -la -lb -la)
6034698f425bSmrg    for deplib in $deplibs; do
60359ef0b394Smrg      if $opt_preserve_dup_deps ; then
6036698f425bSmrg	case "$libs " in
60379ef0b394Smrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
6038698f425bSmrg	esac
6039698f425bSmrg      fi
60409ef0b394Smrg      func_append libs " $deplib"
6041698f425bSmrg    done
6042698f425bSmrg
6043698f425bSmrg    if test "$linkmode" = lib; then
6044698f425bSmrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
6045698f425bSmrg
6046698f425bSmrg      # Compute libraries that are listed more than once in $predeps
6047698f425bSmrg      # $postdeps and mark them as special (i.e., whose duplicates are
6048698f425bSmrg      # not to be eliminated).
6049698f425bSmrg      pre_post_deps=
6050698f425bSmrg      if $opt_duplicate_compiler_generated_deps; then
6051698f425bSmrg	for pre_post_dep in $predeps $postdeps; do
6052698f425bSmrg	  case "$pre_post_deps " in
60539ef0b394Smrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
6054698f425bSmrg	  esac
60559ef0b394Smrg	  func_append pre_post_deps " $pre_post_dep"
6056698f425bSmrg	done
6057698f425bSmrg      fi
6058698f425bSmrg      pre_post_deps=
6059698f425bSmrg    fi
6060698f425bSmrg
6061698f425bSmrg    deplibs=
6062698f425bSmrg    newdependency_libs=
6063698f425bSmrg    newlib_search_path=
6064698f425bSmrg    need_relink=no # whether we're linking any uninstalled libtool libraries
6065698f425bSmrg    notinst_deplibs= # not-installed libtool libraries
6066698f425bSmrg    notinst_path= # paths that contain not-installed libtool libraries
6067698f425bSmrg
6068698f425bSmrg    case $linkmode in
6069698f425bSmrg    lib)
6070698f425bSmrg	passes="conv dlpreopen link"
6071698f425bSmrg	for file in $dlfiles $dlprefiles; do
6072698f425bSmrg	  case $file in
6073698f425bSmrg	  *.la) ;;
6074698f425bSmrg	  *)
6075698f425bSmrg	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
6076698f425bSmrg	    ;;
6077698f425bSmrg	  esac
6078698f425bSmrg	done
6079698f425bSmrg	;;
6080698f425bSmrg    prog)
6081698f425bSmrg	compile_deplibs=
6082698f425bSmrg	finalize_deplibs=
6083698f425bSmrg	alldeplibs=no
6084698f425bSmrg	newdlfiles=
6085698f425bSmrg	newdlprefiles=
6086698f425bSmrg	passes="conv scan dlopen dlpreopen link"
6087698f425bSmrg	;;
6088698f425bSmrg    *)  passes="conv"
6089698f425bSmrg	;;
6090698f425bSmrg    esac
6091698f425bSmrg
6092698f425bSmrg    for pass in $passes; do
6093698f425bSmrg      # The preopen pass in lib mode reverses $deplibs; put it back here
6094698f425bSmrg      # so that -L comes before libs that need it for instance...
6095698f425bSmrg      if test "$linkmode,$pass" = "lib,link"; then
6096698f425bSmrg	## FIXME: Find the place where the list is rebuilt in the wrong
6097698f425bSmrg	##        order, and fix it there properly
6098698f425bSmrg        tmp_deplibs=
6099698f425bSmrg	for deplib in $deplibs; do
6100698f425bSmrg	  tmp_deplibs="$deplib $tmp_deplibs"
6101698f425bSmrg	done
6102698f425bSmrg	deplibs="$tmp_deplibs"
6103698f425bSmrg      fi
6104698f425bSmrg
6105698f425bSmrg      if test "$linkmode,$pass" = "lib,link" ||
6106698f425bSmrg	 test "$linkmode,$pass" = "prog,scan"; then
6107698f425bSmrg	libs="$deplibs"
6108698f425bSmrg	deplibs=
6109698f425bSmrg      fi
6110698f425bSmrg      if test "$linkmode" = prog; then
6111698f425bSmrg	case $pass in
6112698f425bSmrg	dlopen) libs="$dlfiles" ;;
6113698f425bSmrg	dlpreopen) libs="$dlprefiles" ;;
6114698f425bSmrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
6115698f425bSmrg	esac
6116698f425bSmrg      fi
6117698f425bSmrg      if test "$linkmode,$pass" = "lib,dlpreopen"; then
6118698f425bSmrg	# Collect and forward deplibs of preopened libtool libs
6119698f425bSmrg	for lib in $dlprefiles; do
6120698f425bSmrg	  # Ignore non-libtool-libs
6121698f425bSmrg	  dependency_libs=
61229ef0b394Smrg	  func_resolve_sysroot "$lib"
6123698f425bSmrg	  case $lib in
61249ef0b394Smrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
6125698f425bSmrg	  esac
6126698f425bSmrg
6127698f425bSmrg	  # Collect preopened libtool deplibs, except any this library
6128698f425bSmrg	  # has declared as weak libs
6129698f425bSmrg	  for deplib in $dependency_libs; do
61309ef0b394Smrg	    func_basename "$deplib"
61319ef0b394Smrg            deplib_base=$func_basename_result
6132698f425bSmrg	    case " $weak_libs " in
6133698f425bSmrg	    *" $deplib_base "*) ;;
61349ef0b394Smrg	    *) func_append deplibs " $deplib" ;;
6135698f425bSmrg	    esac
6136698f425bSmrg	  done
6137698f425bSmrg	done
6138698f425bSmrg	libs="$dlprefiles"
6139698f425bSmrg      fi
6140698f425bSmrg      if test "$pass" = dlopen; then
6141698f425bSmrg	# Collect dlpreopened libraries
6142698f425bSmrg	save_deplibs="$deplibs"
6143698f425bSmrg	deplibs=
6144698f425bSmrg      fi
6145698f425bSmrg
6146698f425bSmrg      for deplib in $libs; do
6147698f425bSmrg	lib=
6148698f425bSmrg	found=no
6149698f425bSmrg	case $deplib in
6150698f425bSmrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
6151698f425bSmrg	  if test "$linkmode,$pass" = "prog,link"; then
6152698f425bSmrg	    compile_deplibs="$deplib $compile_deplibs"
6153698f425bSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
6154698f425bSmrg	  else
61559ef0b394Smrg	    func_append compiler_flags " $deplib"
6156698f425bSmrg	    if test "$linkmode" = lib ; then
6157698f425bSmrg		case "$new_inherited_linker_flags " in
6158698f425bSmrg		    *" $deplib "*) ;;
61599ef0b394Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6160698f425bSmrg		esac
6161698f425bSmrg	    fi
6162698f425bSmrg	  fi
6163698f425bSmrg	  continue
6164698f425bSmrg	  ;;
6165698f425bSmrg	-l*)
6166698f425bSmrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
6167698f425bSmrg	    func_warning "\`-l' is ignored for archives/objects"
6168698f425bSmrg	    continue
6169698f425bSmrg	  fi
6170698f425bSmrg	  func_stripname '-l' '' "$deplib"
6171698f425bSmrg	  name=$func_stripname_result
6172698f425bSmrg	  if test "$linkmode" = lib; then
6173698f425bSmrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
6174698f425bSmrg	  else
6175698f425bSmrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
6176698f425bSmrg	  fi
6177698f425bSmrg	  for searchdir in $searchdirs; do
6178698f425bSmrg	    for search_ext in .la $std_shrext .so .a; do
6179698f425bSmrg	      # Search the libtool library
6180698f425bSmrg	      lib="$searchdir/lib${name}${search_ext}"
6181698f425bSmrg	      if test -f "$lib"; then
6182698f425bSmrg		if test "$search_ext" = ".la"; then
6183698f425bSmrg		  found=yes
6184698f425bSmrg		else
6185698f425bSmrg		  found=no
6186698f425bSmrg		fi
6187698f425bSmrg		break 2
6188698f425bSmrg	      fi
6189698f425bSmrg	    done
6190698f425bSmrg	  done
6191698f425bSmrg	  if test "$found" != yes; then
6192698f425bSmrg	    # deplib doesn't seem to be a libtool library
6193698f425bSmrg	    if test "$linkmode,$pass" = "prog,link"; then
6194698f425bSmrg	      compile_deplibs="$deplib $compile_deplibs"
6195698f425bSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
6196698f425bSmrg	    else
6197698f425bSmrg	      deplibs="$deplib $deplibs"
6198698f425bSmrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6199698f425bSmrg	    fi
6200698f425bSmrg	    continue
6201698f425bSmrg	  else # deplib is a libtool library
6202698f425bSmrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
6203698f425bSmrg	    # We need to do some special things here, and not later.
6204698f425bSmrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6205698f425bSmrg	      case " $predeps $postdeps " in
6206698f425bSmrg	      *" $deplib "*)
6207698f425bSmrg		if func_lalib_p "$lib"; then
6208698f425bSmrg		  library_names=
6209698f425bSmrg		  old_library=
6210698f425bSmrg		  func_source "$lib"
6211698f425bSmrg		  for l in $old_library $library_names; do
6212698f425bSmrg		    ll="$l"
6213698f425bSmrg		  done
6214698f425bSmrg		  if test "X$ll" = "X$old_library" ; then # only static version available
6215698f425bSmrg		    found=no
6216698f425bSmrg		    func_dirname "$lib" "" "."
6217698f425bSmrg		    ladir="$func_dirname_result"
6218698f425bSmrg		    lib=$ladir/$old_library
6219698f425bSmrg		    if test "$linkmode,$pass" = "prog,link"; then
6220698f425bSmrg		      compile_deplibs="$deplib $compile_deplibs"
6221698f425bSmrg		      finalize_deplibs="$deplib $finalize_deplibs"
6222698f425bSmrg		    else
6223698f425bSmrg		      deplibs="$deplib $deplibs"
6224698f425bSmrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6225698f425bSmrg		    fi
6226698f425bSmrg		    continue
6227698f425bSmrg		  fi
6228698f425bSmrg		fi
6229698f425bSmrg		;;
6230698f425bSmrg	      *) ;;
6231698f425bSmrg	      esac
6232698f425bSmrg	    fi
6233698f425bSmrg	  fi
6234698f425bSmrg	  ;; # -l
6235698f425bSmrg	*.ltframework)
6236698f425bSmrg	  if test "$linkmode,$pass" = "prog,link"; then
6237698f425bSmrg	    compile_deplibs="$deplib $compile_deplibs"
6238698f425bSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
6239698f425bSmrg	  else
6240698f425bSmrg	    deplibs="$deplib $deplibs"
6241698f425bSmrg	    if test "$linkmode" = lib ; then
6242698f425bSmrg		case "$new_inherited_linker_flags " in
6243698f425bSmrg		    *" $deplib "*) ;;
62449ef0b394Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6245698f425bSmrg		esac
6246698f425bSmrg	    fi
6247698f425bSmrg	  fi
6248698f425bSmrg	  continue
6249698f425bSmrg	  ;;
6250698f425bSmrg	-L*)
6251698f425bSmrg	  case $linkmode in
6252698f425bSmrg	  lib)
6253698f425bSmrg	    deplibs="$deplib $deplibs"
6254698f425bSmrg	    test "$pass" = conv && continue
6255698f425bSmrg	    newdependency_libs="$deplib $newdependency_libs"
6256698f425bSmrg	    func_stripname '-L' '' "$deplib"
62579ef0b394Smrg	    func_resolve_sysroot "$func_stripname_result"
62589ef0b394Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
6259698f425bSmrg	    ;;
6260698f425bSmrg	  prog)
6261698f425bSmrg	    if test "$pass" = conv; then
6262698f425bSmrg	      deplibs="$deplib $deplibs"
6263698f425bSmrg	      continue
6264698f425bSmrg	    fi
6265698f425bSmrg	    if test "$pass" = scan; then
6266698f425bSmrg	      deplibs="$deplib $deplibs"
6267698f425bSmrg	    else
6268698f425bSmrg	      compile_deplibs="$deplib $compile_deplibs"
6269698f425bSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
6270698f425bSmrg	    fi
6271698f425bSmrg	    func_stripname '-L' '' "$deplib"
62729ef0b394Smrg	    func_resolve_sysroot "$func_stripname_result"
62739ef0b394Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
6274698f425bSmrg	    ;;
6275698f425bSmrg	  *)
6276698f425bSmrg	    func_warning "\`-L' is ignored for archives/objects"
6277698f425bSmrg	    ;;
6278698f425bSmrg	  esac # linkmode
6279698f425bSmrg	  continue
6280698f425bSmrg	  ;; # -L
6281698f425bSmrg	-R*)
6282698f425bSmrg	  if test "$pass" = link; then
6283698f425bSmrg	    func_stripname '-R' '' "$deplib"
62849ef0b394Smrg	    func_resolve_sysroot "$func_stripname_result"
62859ef0b394Smrg	    dir=$func_resolve_sysroot_result
6286698f425bSmrg	    # Make sure the xrpath contains only unique directories.
6287698f425bSmrg	    case "$xrpath " in
6288698f425bSmrg	    *" $dir "*) ;;
62899ef0b394Smrg	    *) func_append xrpath " $dir" ;;
6290698f425bSmrg	    esac
6291698f425bSmrg	  fi
6292698f425bSmrg	  deplibs="$deplib $deplibs"
6293698f425bSmrg	  continue
6294698f425bSmrg	  ;;
62959ef0b394Smrg	*.la)
62969ef0b394Smrg	  func_resolve_sysroot "$deplib"
62979ef0b394Smrg	  lib=$func_resolve_sysroot_result
62989ef0b394Smrg	  ;;
6299698f425bSmrg	*.$libext)
6300698f425bSmrg	  if test "$pass" = conv; then
6301698f425bSmrg	    deplibs="$deplib $deplibs"
6302698f425bSmrg	    continue
6303698f425bSmrg	  fi
6304698f425bSmrg	  case $linkmode in
6305698f425bSmrg	  lib)
6306698f425bSmrg	    # Linking convenience modules into shared libraries is allowed,
6307698f425bSmrg	    # but linking other static libraries is non-portable.
6308698f425bSmrg	    case " $dlpreconveniencelibs " in
6309698f425bSmrg	    *" $deplib "*) ;;
6310698f425bSmrg	    *)
6311698f425bSmrg	      valid_a_lib=no
6312698f425bSmrg	      case $deplibs_check_method in
6313698f425bSmrg		match_pattern*)
6314698f425bSmrg		  set dummy $deplibs_check_method; shift
6315698f425bSmrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
63169ef0b394Smrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
6317698f425bSmrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
6318698f425bSmrg		    valid_a_lib=yes
6319698f425bSmrg		  fi
6320698f425bSmrg		;;
6321698f425bSmrg		pass_all)
6322698f425bSmrg		  valid_a_lib=yes
6323698f425bSmrg		;;
6324698f425bSmrg	      esac
6325698f425bSmrg	      if test "$valid_a_lib" != yes; then
63269ef0b394Smrg		echo
6327698f425bSmrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
63289ef0b394Smrg		echo "*** I have the capability to make that library automatically link in when"
63299ef0b394Smrg		echo "*** you link to this library.  But I can only do this if you have a"
63309ef0b394Smrg		echo "*** shared version of the library, which you do not appear to have"
63319ef0b394Smrg		echo "*** because the file extensions .$libext of this argument makes me believe"
63329ef0b394Smrg		echo "*** that it is just a static archive that I should not use here."
6333698f425bSmrg	      else
63349ef0b394Smrg		echo
6335698f425bSmrg		$ECHO "*** Warning: Linking the shared library $output against the"
6336698f425bSmrg		$ECHO "*** static library $deplib is not portable!"
6337698f425bSmrg		deplibs="$deplib $deplibs"
6338698f425bSmrg	      fi
6339698f425bSmrg	      ;;
6340698f425bSmrg	    esac
6341698f425bSmrg	    continue
6342698f425bSmrg	    ;;
6343698f425bSmrg	  prog)
6344698f425bSmrg	    if test "$pass" != link; then
6345698f425bSmrg	      deplibs="$deplib $deplibs"
6346698f425bSmrg	    else
6347698f425bSmrg	      compile_deplibs="$deplib $compile_deplibs"
6348698f425bSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
6349698f425bSmrg	    fi
6350698f425bSmrg	    continue
6351698f425bSmrg	    ;;
6352698f425bSmrg	  esac # linkmode
6353698f425bSmrg	  ;; # *.$libext
6354698f425bSmrg	*.lo | *.$objext)
6355698f425bSmrg	  if test "$pass" = conv; then
6356698f425bSmrg	    deplibs="$deplib $deplibs"
6357698f425bSmrg	  elif test "$linkmode" = prog; then
6358698f425bSmrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
6359698f425bSmrg	      # If there is no dlopen support or we're linking statically,
6360698f425bSmrg	      # we need to preload.
63619ef0b394Smrg	      func_append newdlprefiles " $deplib"
6362698f425bSmrg	      compile_deplibs="$deplib $compile_deplibs"
6363698f425bSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
6364698f425bSmrg	    else
63659ef0b394Smrg	      func_append newdlfiles " $deplib"
6366698f425bSmrg	    fi
6367698f425bSmrg	  fi
6368698f425bSmrg	  continue
6369698f425bSmrg	  ;;
6370698f425bSmrg	%DEPLIBS%)
6371698f425bSmrg	  alldeplibs=yes
6372698f425bSmrg	  continue
6373698f425bSmrg	  ;;
6374698f425bSmrg	esac # case $deplib
6375698f425bSmrg
6376698f425bSmrg	if test "$found" = yes || test -f "$lib"; then :
6377698f425bSmrg	else
6378698f425bSmrg	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
6379698f425bSmrg	fi
6380698f425bSmrg
6381698f425bSmrg	# Check to see that this really is a libtool archive.
6382698f425bSmrg	func_lalib_unsafe_p "$lib" \
6383698f425bSmrg	  || func_fatal_error "\`$lib' is not a valid libtool archive"
6384698f425bSmrg
6385698f425bSmrg	func_dirname "$lib" "" "."
6386698f425bSmrg	ladir="$func_dirname_result"
6387698f425bSmrg
6388698f425bSmrg	dlname=
6389698f425bSmrg	dlopen=
6390698f425bSmrg	dlpreopen=
6391698f425bSmrg	libdir=
6392698f425bSmrg	library_names=
6393698f425bSmrg	old_library=
6394698f425bSmrg	inherited_linker_flags=
6395698f425bSmrg	# If the library was installed with an old release of libtool,
6396698f425bSmrg	# it will not redefine variables installed, or shouldnotlink
6397698f425bSmrg	installed=yes
6398698f425bSmrg	shouldnotlink=no
6399698f425bSmrg	avoidtemprpath=
6400698f425bSmrg
6401698f425bSmrg
6402698f425bSmrg	# Read the .la file
6403698f425bSmrg	func_source "$lib"
6404698f425bSmrg
6405698f425bSmrg	# Convert "-framework foo" to "foo.ltframework"
6406698f425bSmrg	if test -n "$inherited_linker_flags"; then
64079ef0b394Smrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
6408698f425bSmrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
6409698f425bSmrg	    case " $new_inherited_linker_flags " in
6410698f425bSmrg	      *" $tmp_inherited_linker_flag "*) ;;
64119ef0b394Smrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
6412698f425bSmrg	    esac
6413698f425bSmrg	  done
6414698f425bSmrg	fi
64159ef0b394Smrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
6416698f425bSmrg	if test "$linkmode,$pass" = "lib,link" ||
6417698f425bSmrg	   test "$linkmode,$pass" = "prog,scan" ||
6418698f425bSmrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
64199ef0b394Smrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
64209ef0b394Smrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
6421698f425bSmrg	fi
6422698f425bSmrg
6423698f425bSmrg	if test "$pass" = conv; then
6424698f425bSmrg	  # Only check for convenience libraries
6425698f425bSmrg	  deplibs="$lib $deplibs"
6426698f425bSmrg	  if test -z "$libdir"; then
6427698f425bSmrg	    if test -z "$old_library"; then
6428698f425bSmrg	      func_fatal_error "cannot find name of link library for \`$lib'"
6429698f425bSmrg	    fi
6430698f425bSmrg	    # It is a libtool convenience library, so add in its objects.
64319ef0b394Smrg	    func_append convenience " $ladir/$objdir/$old_library"
64329ef0b394Smrg	    func_append old_convenience " $ladir/$objdir/$old_library"
6433698f425bSmrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
6434698f425bSmrg	    func_fatal_error "\`$lib' is not a convenience library"
6435698f425bSmrg	  fi
6436698f425bSmrg	  tmp_libs=
6437698f425bSmrg	  for deplib in $dependency_libs; do
6438698f425bSmrg	    deplibs="$deplib $deplibs"
64399ef0b394Smrg	    if $opt_preserve_dup_deps ; then
6440698f425bSmrg	      case "$tmp_libs " in
64419ef0b394Smrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6442698f425bSmrg	      esac
6443698f425bSmrg	    fi
64449ef0b394Smrg	    func_append tmp_libs " $deplib"
6445698f425bSmrg	  done
6446698f425bSmrg	  continue
6447698f425bSmrg	fi # $pass = conv
6448698f425bSmrg
6449698f425bSmrg
6450698f425bSmrg	# Get the name of the library we link against.
6451698f425bSmrg	linklib=
64529ef0b394Smrg	if test -n "$old_library" &&
64539ef0b394Smrg	   { test "$prefer_static_libs" = yes ||
64549ef0b394Smrg	     test "$prefer_static_libs,$installed" = "built,no"; }; then
64559ef0b394Smrg	  linklib=$old_library
64569ef0b394Smrg	else
64579ef0b394Smrg	  for l in $old_library $library_names; do
64589ef0b394Smrg	    linklib="$l"
64599ef0b394Smrg	  done
64609ef0b394Smrg	fi
6461698f425bSmrg	if test -z "$linklib"; then
6462698f425bSmrg	  func_fatal_error "cannot find name of link library for \`$lib'"
6463698f425bSmrg	fi
6464698f425bSmrg
6465698f425bSmrg	# This library was specified with -dlopen.
6466698f425bSmrg	if test "$pass" = dlopen; then
6467698f425bSmrg	  if test -z "$libdir"; then
6468698f425bSmrg	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
6469698f425bSmrg	  fi
6470698f425bSmrg	  if test -z "$dlname" ||
6471698f425bSmrg	     test "$dlopen_support" != yes ||
6472698f425bSmrg	     test "$build_libtool_libs" = no; then
6473698f425bSmrg	    # If there is no dlname, no dlopen support or we're linking
6474698f425bSmrg	    # statically, we need to preload.  We also need to preload any
6475698f425bSmrg	    # dependent libraries so libltdl's deplib preloader doesn't
6476698f425bSmrg	    # bomb out in the load deplibs phase.
64779ef0b394Smrg	    func_append dlprefiles " $lib $dependency_libs"
6478698f425bSmrg	  else
64799ef0b394Smrg	    func_append newdlfiles " $lib"
6480698f425bSmrg	  fi
6481698f425bSmrg	  continue
6482698f425bSmrg	fi # $pass = dlopen
6483698f425bSmrg
6484698f425bSmrg	# We need an absolute path.
6485698f425bSmrg	case $ladir in
6486698f425bSmrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
6487698f425bSmrg	*)
6488698f425bSmrg	  abs_ladir=`cd "$ladir" && pwd`
6489698f425bSmrg	  if test -z "$abs_ladir"; then
6490698f425bSmrg	    func_warning "cannot determine absolute directory name of \`$ladir'"
6491698f425bSmrg	    func_warning "passing it literally to the linker, although it might fail"
6492698f425bSmrg	    abs_ladir="$ladir"
6493698f425bSmrg	  fi
6494698f425bSmrg	  ;;
6495698f425bSmrg	esac
6496698f425bSmrg	func_basename "$lib"
6497698f425bSmrg	laname="$func_basename_result"
6498698f425bSmrg
6499698f425bSmrg	# Find the relevant object directory and library name.
6500698f425bSmrg	if test "X$installed" = Xyes; then
65019ef0b394Smrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6502698f425bSmrg	    func_warning "library \`$lib' was moved."
6503698f425bSmrg	    dir="$ladir"
6504698f425bSmrg	    absdir="$abs_ladir"
6505698f425bSmrg	    libdir="$abs_ladir"
6506698f425bSmrg	  else
65079ef0b394Smrg	    dir="$lt_sysroot$libdir"
65089ef0b394Smrg	    absdir="$lt_sysroot$libdir"
6509698f425bSmrg	  fi
6510698f425bSmrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
6511698f425bSmrg	else
6512698f425bSmrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6513698f425bSmrg	    dir="$ladir"
6514698f425bSmrg	    absdir="$abs_ladir"
6515698f425bSmrg	    # Remove this search path later
65169ef0b394Smrg	    func_append notinst_path " $abs_ladir"
6517698f425bSmrg	  else
6518698f425bSmrg	    dir="$ladir/$objdir"
6519698f425bSmrg	    absdir="$abs_ladir/$objdir"
6520698f425bSmrg	    # Remove this search path later
65219ef0b394Smrg	    func_append notinst_path " $abs_ladir"
6522698f425bSmrg	  fi
6523698f425bSmrg	fi # $installed = yes
6524698f425bSmrg	func_stripname 'lib' '.la' "$laname"
6525698f425bSmrg	name=$func_stripname_result
6526698f425bSmrg
6527698f425bSmrg	# This library was specified with -dlpreopen.
6528698f425bSmrg	if test "$pass" = dlpreopen; then
6529698f425bSmrg	  if test -z "$libdir" && test "$linkmode" = prog; then
6530698f425bSmrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
6531698f425bSmrg	  fi
65329ef0b394Smrg	  case "$host" in
65339ef0b394Smrg	    # special handling for platforms with PE-DLLs.
65349ef0b394Smrg	    *cygwin* | *mingw* | *cegcc* )
65359ef0b394Smrg	      # Linker will automatically link against shared library if both
65369ef0b394Smrg	      # static and shared are present.  Therefore, ensure we extract
65379ef0b394Smrg	      # symbols from the import library if a shared library is present
65389ef0b394Smrg	      # (otherwise, the dlopen module name will be incorrect).  We do
65399ef0b394Smrg	      # this by putting the import library name into $newdlprefiles.
65409ef0b394Smrg	      # We recover the dlopen module name by 'saving' the la file
65419ef0b394Smrg	      # name in a special purpose variable, and (later) extracting the
65429ef0b394Smrg	      # dlname from the la file.
65439ef0b394Smrg	      if test -n "$dlname"; then
65449ef0b394Smrg	        func_tr_sh "$dir/$linklib"
65459ef0b394Smrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
65469ef0b394Smrg	        func_append newdlprefiles " $dir/$linklib"
65479ef0b394Smrg	      else
65489ef0b394Smrg	        func_append newdlprefiles " $dir/$old_library"
65499ef0b394Smrg	        # Keep a list of preopened convenience libraries to check
65509ef0b394Smrg	        # that they are being used correctly in the link pass.
65519ef0b394Smrg	        test -z "$libdir" && \
65529ef0b394Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
65539ef0b394Smrg	      fi
65549ef0b394Smrg	    ;;
65559ef0b394Smrg	    * )
65569ef0b394Smrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
65579ef0b394Smrg	      # are required to link).
65589ef0b394Smrg	      if test -n "$old_library"; then
65599ef0b394Smrg	        func_append newdlprefiles " $dir/$old_library"
65609ef0b394Smrg	        # Keep a list of preopened convenience libraries to check
65619ef0b394Smrg	        # that they are being used correctly in the link pass.
65629ef0b394Smrg	        test -z "$libdir" && \
65639ef0b394Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
65649ef0b394Smrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
65659ef0b394Smrg	      elif test -n "$dlname"; then
65669ef0b394Smrg	        func_append newdlprefiles " $dir/$dlname"
65679ef0b394Smrg	      else
65689ef0b394Smrg	        func_append newdlprefiles " $dir/$linklib"
65699ef0b394Smrg	      fi
65709ef0b394Smrg	    ;;
65719ef0b394Smrg	  esac
6572698f425bSmrg	fi # $pass = dlpreopen
6573698f425bSmrg
6574698f425bSmrg	if test -z "$libdir"; then
6575698f425bSmrg	  # Link the convenience library
6576698f425bSmrg	  if test "$linkmode" = lib; then
6577698f425bSmrg	    deplibs="$dir/$old_library $deplibs"
6578698f425bSmrg	  elif test "$linkmode,$pass" = "prog,link"; then
6579698f425bSmrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
6580698f425bSmrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
6581698f425bSmrg	  else
6582698f425bSmrg	    deplibs="$lib $deplibs" # used for prog,scan pass
6583698f425bSmrg	  fi
6584698f425bSmrg	  continue
6585698f425bSmrg	fi
6586698f425bSmrg
6587698f425bSmrg
6588698f425bSmrg	if test "$linkmode" = prog && test "$pass" != link; then
65899ef0b394Smrg	  func_append newlib_search_path " $ladir"
6590698f425bSmrg	  deplibs="$lib $deplibs"
6591698f425bSmrg
6592698f425bSmrg	  linkalldeplibs=no
6593698f425bSmrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
6594698f425bSmrg	     test "$build_libtool_libs" = no; then
6595698f425bSmrg	    linkalldeplibs=yes
6596698f425bSmrg	  fi
6597698f425bSmrg
6598698f425bSmrg	  tmp_libs=
6599698f425bSmrg	  for deplib in $dependency_libs; do
6600698f425bSmrg	    case $deplib in
6601698f425bSmrg	    -L*) func_stripname '-L' '' "$deplib"
66029ef0b394Smrg	         func_resolve_sysroot "$func_stripname_result"
66039ef0b394Smrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
6604698f425bSmrg		 ;;
6605698f425bSmrg	    esac
6606698f425bSmrg	    # Need to link against all dependency_libs?
6607698f425bSmrg	    if test "$linkalldeplibs" = yes; then
6608698f425bSmrg	      deplibs="$deplib $deplibs"
6609698f425bSmrg	    else
6610698f425bSmrg	      # Need to hardcode shared library paths
6611698f425bSmrg	      # or/and link against static libraries
6612698f425bSmrg	      newdependency_libs="$deplib $newdependency_libs"
6613698f425bSmrg	    fi
66149ef0b394Smrg	    if $opt_preserve_dup_deps ; then
6615698f425bSmrg	      case "$tmp_libs " in
66169ef0b394Smrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6617698f425bSmrg	      esac
6618698f425bSmrg	    fi
66199ef0b394Smrg	    func_append tmp_libs " $deplib"
6620698f425bSmrg	  done # for deplib
6621698f425bSmrg	  continue
6622698f425bSmrg	fi # $linkmode = prog...
6623698f425bSmrg
6624698f425bSmrg	if test "$linkmode,$pass" = "prog,link"; then
6625698f425bSmrg	  if test -n "$library_names" &&
6626698f425bSmrg	     { { test "$prefer_static_libs" = no ||
6627698f425bSmrg	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
6628698f425bSmrg	       test -z "$old_library"; }; then
6629698f425bSmrg	    # We need to hardcode the library path
6630698f425bSmrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
6631698f425bSmrg	      # Make sure the rpath contains only unique directories.
6632698f425bSmrg	      case "$temp_rpath:" in
6633698f425bSmrg	      *"$absdir:"*) ;;
66349ef0b394Smrg	      *) func_append temp_rpath "$absdir:" ;;
6635698f425bSmrg	      esac
6636698f425bSmrg	    fi
6637698f425bSmrg
6638698f425bSmrg	    # Hardcode the library path.
6639698f425bSmrg	    # Skip directories that are in the system default run-time
6640698f425bSmrg	    # search path.
6641698f425bSmrg	    case " $sys_lib_dlsearch_path " in
6642698f425bSmrg	    *" $absdir "*) ;;
6643698f425bSmrg	    *)
6644698f425bSmrg	      case "$compile_rpath " in
6645698f425bSmrg	      *" $absdir "*) ;;
66469ef0b394Smrg	      *) func_append compile_rpath " $absdir" ;;
6647698f425bSmrg	      esac
6648698f425bSmrg	      ;;
6649698f425bSmrg	    esac
6650698f425bSmrg	    case " $sys_lib_dlsearch_path " in
6651698f425bSmrg	    *" $libdir "*) ;;
6652698f425bSmrg	    *)
6653698f425bSmrg	      case "$finalize_rpath " in
6654698f425bSmrg	      *" $libdir "*) ;;
66559ef0b394Smrg	      *) func_append finalize_rpath " $libdir" ;;
6656698f425bSmrg	      esac
6657698f425bSmrg	      ;;
6658698f425bSmrg	    esac
6659698f425bSmrg	  fi # $linkmode,$pass = prog,link...
6660698f425bSmrg
6661698f425bSmrg	  if test "$alldeplibs" = yes &&
6662698f425bSmrg	     { test "$deplibs_check_method" = pass_all ||
6663698f425bSmrg	       { test "$build_libtool_libs" = yes &&
6664698f425bSmrg		 test -n "$library_names"; }; }; then
6665698f425bSmrg	    # We only need to search for static libraries
6666698f425bSmrg	    continue
6667698f425bSmrg	  fi
6668698f425bSmrg	fi
6669698f425bSmrg
6670698f425bSmrg	link_static=no # Whether the deplib will be linked statically
6671698f425bSmrg	use_static_libs=$prefer_static_libs
6672698f425bSmrg	if test "$use_static_libs" = built && test "$installed" = yes; then
6673698f425bSmrg	  use_static_libs=no
6674698f425bSmrg	fi
6675698f425bSmrg	if test -n "$library_names" &&
6676698f425bSmrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
6677698f425bSmrg	  case $host in
6678698f425bSmrg	  *cygwin* | *mingw* | *cegcc*)
6679698f425bSmrg	      # No point in relinking DLLs because paths are not encoded
66809ef0b394Smrg	      func_append notinst_deplibs " $lib"
6681698f425bSmrg	      need_relink=no
6682698f425bSmrg	    ;;
6683698f425bSmrg	  *)
6684698f425bSmrg	    if test "$installed" = no; then
66859ef0b394Smrg	      func_append notinst_deplibs " $lib"
6686698f425bSmrg	      need_relink=yes
6687698f425bSmrg	    fi
6688698f425bSmrg	    ;;
6689698f425bSmrg	  esac
6690698f425bSmrg	  # This is a shared library
6691698f425bSmrg
6692698f425bSmrg	  # Warn about portability, can't link against -module's on some
6693698f425bSmrg	  # systems (darwin).  Don't bleat about dlopened modules though!
6694698f425bSmrg	  dlopenmodule=""
6695698f425bSmrg	  for dlpremoduletest in $dlprefiles; do
6696698f425bSmrg	    if test "X$dlpremoduletest" = "X$lib"; then
6697698f425bSmrg	      dlopenmodule="$dlpremoduletest"
6698698f425bSmrg	      break
6699698f425bSmrg	    fi
6700698f425bSmrg	  done
6701698f425bSmrg	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
67029ef0b394Smrg	    echo
6703698f425bSmrg	    if test "$linkmode" = prog; then
6704698f425bSmrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
6705698f425bSmrg	    else
6706698f425bSmrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
6707698f425bSmrg	    fi
6708698f425bSmrg	    $ECHO "*** $linklib is not portable!"
6709698f425bSmrg	  fi
6710698f425bSmrg	  if test "$linkmode" = lib &&
6711698f425bSmrg	     test "$hardcode_into_libs" = yes; then
6712698f425bSmrg	    # Hardcode the library path.
6713698f425bSmrg	    # Skip directories that are in the system default run-time
6714698f425bSmrg	    # search path.
6715698f425bSmrg	    case " $sys_lib_dlsearch_path " in
6716698f425bSmrg	    *" $absdir "*) ;;
6717698f425bSmrg	    *)
6718698f425bSmrg	      case "$compile_rpath " in
6719698f425bSmrg	      *" $absdir "*) ;;
67209ef0b394Smrg	      *) func_append compile_rpath " $absdir" ;;
6721698f425bSmrg	      esac
6722698f425bSmrg	      ;;
6723698f425bSmrg	    esac
6724698f425bSmrg	    case " $sys_lib_dlsearch_path " in
6725698f425bSmrg	    *" $libdir "*) ;;
6726698f425bSmrg	    *)
6727698f425bSmrg	      case "$finalize_rpath " in
6728698f425bSmrg	      *" $libdir "*) ;;
67299ef0b394Smrg	      *) func_append finalize_rpath " $libdir" ;;
6730698f425bSmrg	      esac
6731698f425bSmrg	      ;;
6732698f425bSmrg	    esac
6733698f425bSmrg	  fi
6734698f425bSmrg
6735698f425bSmrg	  if test -n "$old_archive_from_expsyms_cmds"; then
6736698f425bSmrg	    # figure out the soname
6737698f425bSmrg	    set dummy $library_names
6738698f425bSmrg	    shift
6739698f425bSmrg	    realname="$1"
6740698f425bSmrg	    shift
6741698f425bSmrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
6742698f425bSmrg	    # use dlname if we got it. it's perfectly good, no?
6743698f425bSmrg	    if test -n "$dlname"; then
6744698f425bSmrg	      soname="$dlname"
6745698f425bSmrg	    elif test -n "$soname_spec"; then
6746698f425bSmrg	      # bleh windows
6747698f425bSmrg	      case $host in
6748698f425bSmrg	      *cygwin* | mingw* | *cegcc*)
6749698f425bSmrg	        func_arith $current - $age
6750698f425bSmrg		major=$func_arith_result
6751698f425bSmrg		versuffix="-$major"
6752698f425bSmrg		;;
6753698f425bSmrg	      esac
6754698f425bSmrg	      eval soname=\"$soname_spec\"
6755698f425bSmrg	    else
6756698f425bSmrg	      soname="$realname"
6757698f425bSmrg	    fi
6758698f425bSmrg
6759698f425bSmrg	    # Make a new name for the extract_expsyms_cmds to use
6760698f425bSmrg	    soroot="$soname"
6761698f425bSmrg	    func_basename "$soroot"
6762698f425bSmrg	    soname="$func_basename_result"
6763698f425bSmrg	    func_stripname 'lib' '.dll' "$soname"
6764698f425bSmrg	    newlib=libimp-$func_stripname_result.a
6765698f425bSmrg
6766698f425bSmrg	    # If the library has no export list, then create one now
6767698f425bSmrg	    if test -f "$output_objdir/$soname-def"; then :
6768698f425bSmrg	    else
6769698f425bSmrg	      func_verbose "extracting exported symbol list from \`$soname'"
6770698f425bSmrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
6771698f425bSmrg	    fi
6772698f425bSmrg
6773698f425bSmrg	    # Create $newlib
6774698f425bSmrg	    if test -f "$output_objdir/$newlib"; then :; else
6775698f425bSmrg	      func_verbose "generating import library for \`$soname'"
6776698f425bSmrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
6777698f425bSmrg	    fi
6778698f425bSmrg	    # make sure the library variables are pointing to the new library
6779698f425bSmrg	    dir=$output_objdir
6780698f425bSmrg	    linklib=$newlib
6781698f425bSmrg	  fi # test -n "$old_archive_from_expsyms_cmds"
6782698f425bSmrg
67839ef0b394Smrg	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
6784698f425bSmrg	    add_shlibpath=
6785698f425bSmrg	    add_dir=
6786698f425bSmrg	    add=
6787698f425bSmrg	    lib_linked=yes
6788698f425bSmrg	    case $hardcode_action in
6789698f425bSmrg	    immediate | unsupported)
6790698f425bSmrg	      if test "$hardcode_direct" = no; then
6791698f425bSmrg		add="$dir/$linklib"
6792698f425bSmrg		case $host in
6793698f425bSmrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
6794698f425bSmrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
6795698f425bSmrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
6796698f425bSmrg		    *-*-unixware7*) add_dir="-L$dir" ;;
6797698f425bSmrg		  *-*-darwin* )
6798698f425bSmrg		    # if the lib is a (non-dlopened) module then we can not
6799698f425bSmrg		    # link against it, someone is ignoring the earlier warnings
6800698f425bSmrg		    if /usr/bin/file -L $add 2> /dev/null |
6801698f425bSmrg			 $GREP ": [^:]* bundle" >/dev/null ; then
6802698f425bSmrg		      if test "X$dlopenmodule" != "X$lib"; then
6803698f425bSmrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
6804698f425bSmrg			if test -z "$old_library" ; then
68059ef0b394Smrg			  echo
68069ef0b394Smrg			  echo "*** And there doesn't seem to be a static archive available"
68079ef0b394Smrg			  echo "*** The link will probably fail, sorry"
6808698f425bSmrg			else
6809698f425bSmrg			  add="$dir/$old_library"
6810698f425bSmrg			fi
6811698f425bSmrg		      elif test -n "$old_library"; then
6812698f425bSmrg			add="$dir/$old_library"
6813698f425bSmrg		      fi
6814698f425bSmrg		    fi
6815698f425bSmrg		esac
6816698f425bSmrg	      elif test "$hardcode_minus_L" = no; then
6817698f425bSmrg		case $host in
6818698f425bSmrg		*-*-sunos*) add_shlibpath="$dir" ;;
6819698f425bSmrg		esac
6820698f425bSmrg		add_dir="-L$dir"
6821698f425bSmrg		add="-l$name"
6822698f425bSmrg	      elif test "$hardcode_shlibpath_var" = no; then
6823698f425bSmrg		add_shlibpath="$dir"
6824698f425bSmrg		add="-l$name"
6825698f425bSmrg	      else
6826698f425bSmrg		lib_linked=no
6827698f425bSmrg	      fi
6828698f425bSmrg	      ;;
6829698f425bSmrg	    relink)
6830698f425bSmrg	      if test "$hardcode_direct" = yes &&
6831698f425bSmrg	         test "$hardcode_direct_absolute" = no; then
6832698f425bSmrg		add="$dir/$linklib"
6833698f425bSmrg	      elif test "$hardcode_minus_L" = yes; then
6834698f425bSmrg		add_dir="-L$dir"
6835698f425bSmrg		# Try looking first in the location we're being installed to.
6836698f425bSmrg		if test -n "$inst_prefix_dir"; then
6837698f425bSmrg		  case $libdir in
6838698f425bSmrg		    [\\/]*)
68399ef0b394Smrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
6840698f425bSmrg		      ;;
6841698f425bSmrg		  esac
6842698f425bSmrg		fi
6843698f425bSmrg		add="-l$name"
6844698f425bSmrg	      elif test "$hardcode_shlibpath_var" = yes; then
6845698f425bSmrg		add_shlibpath="$dir"
6846698f425bSmrg		add="-l$name"
6847698f425bSmrg	      else
6848698f425bSmrg		lib_linked=no
6849698f425bSmrg	      fi
6850698f425bSmrg	      ;;
6851698f425bSmrg	    *) lib_linked=no ;;
6852698f425bSmrg	    esac
6853698f425bSmrg
6854698f425bSmrg	    if test "$lib_linked" != yes; then
6855698f425bSmrg	      func_fatal_configuration "unsupported hardcode properties"
6856698f425bSmrg	    fi
6857698f425bSmrg
6858698f425bSmrg	    if test -n "$add_shlibpath"; then
6859698f425bSmrg	      case :$compile_shlibpath: in
6860698f425bSmrg	      *":$add_shlibpath:"*) ;;
68619ef0b394Smrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
6862698f425bSmrg	      esac
6863698f425bSmrg	    fi
6864698f425bSmrg	    if test "$linkmode" = prog; then
6865698f425bSmrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
6866698f425bSmrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
6867698f425bSmrg	    else
6868698f425bSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6869698f425bSmrg	      test -n "$add" && deplibs="$add $deplibs"
6870698f425bSmrg	      if test "$hardcode_direct" != yes &&
6871698f425bSmrg		 test "$hardcode_minus_L" != yes &&
6872698f425bSmrg		 test "$hardcode_shlibpath_var" = yes; then
6873698f425bSmrg		case :$finalize_shlibpath: in
6874698f425bSmrg		*":$libdir:"*) ;;
68759ef0b394Smrg		*) func_append finalize_shlibpath "$libdir:" ;;
6876698f425bSmrg		esac
6877698f425bSmrg	      fi
6878698f425bSmrg	    fi
6879698f425bSmrg	  fi
6880698f425bSmrg
68819ef0b394Smrg	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
6882698f425bSmrg	    add_shlibpath=
6883698f425bSmrg	    add_dir=
6884698f425bSmrg	    add=
6885698f425bSmrg	    # Finalize command for both is simple: just hardcode it.
6886698f425bSmrg	    if test "$hardcode_direct" = yes &&
6887698f425bSmrg	       test "$hardcode_direct_absolute" = no; then
6888698f425bSmrg	      add="$libdir/$linklib"
6889698f425bSmrg	    elif test "$hardcode_minus_L" = yes; then
6890698f425bSmrg	      add_dir="-L$libdir"
6891698f425bSmrg	      add="-l$name"
6892698f425bSmrg	    elif test "$hardcode_shlibpath_var" = yes; then
6893698f425bSmrg	      case :$finalize_shlibpath: in
6894698f425bSmrg	      *":$libdir:"*) ;;
68959ef0b394Smrg	      *) func_append finalize_shlibpath "$libdir:" ;;
6896698f425bSmrg	      esac
6897698f425bSmrg	      add="-l$name"
6898698f425bSmrg	    elif test "$hardcode_automatic" = yes; then
6899698f425bSmrg	      if test -n "$inst_prefix_dir" &&
6900698f425bSmrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
6901698f425bSmrg		add="$inst_prefix_dir$libdir/$linklib"
6902698f425bSmrg	      else
6903698f425bSmrg		add="$libdir/$linklib"
6904698f425bSmrg	      fi
6905698f425bSmrg	    else
6906698f425bSmrg	      # We cannot seem to hardcode it, guess we'll fake it.
6907698f425bSmrg	      add_dir="-L$libdir"
6908698f425bSmrg	      # Try looking first in the location we're being installed to.
6909698f425bSmrg	      if test -n "$inst_prefix_dir"; then
6910698f425bSmrg		case $libdir in
6911698f425bSmrg		  [\\/]*)
69129ef0b394Smrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
6913698f425bSmrg		    ;;
6914698f425bSmrg		esac
6915698f425bSmrg	      fi
6916698f425bSmrg	      add="-l$name"
6917698f425bSmrg	    fi
6918698f425bSmrg
6919698f425bSmrg	    if test "$linkmode" = prog; then
6920698f425bSmrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
6921698f425bSmrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
6922698f425bSmrg	    else
6923698f425bSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6924698f425bSmrg	      test -n "$add" && deplibs="$add $deplibs"
6925698f425bSmrg	    fi
6926698f425bSmrg	  fi
6927698f425bSmrg	elif test "$linkmode" = prog; then
6928698f425bSmrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
6929698f425bSmrg	  # is not unsupported.  This is valid on all known static and
6930698f425bSmrg	  # shared platforms.
6931698f425bSmrg	  if test "$hardcode_direct" != unsupported; then
6932698f425bSmrg	    test -n "$old_library" && linklib="$old_library"
6933698f425bSmrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
6934698f425bSmrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
6935698f425bSmrg	  else
6936698f425bSmrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
6937698f425bSmrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
6938698f425bSmrg	  fi
6939698f425bSmrg	elif test "$build_libtool_libs" = yes; then
6940698f425bSmrg	  # Not a shared library
6941698f425bSmrg	  if test "$deplibs_check_method" != pass_all; then
6942698f425bSmrg	    # We're trying link a shared library against a static one
6943698f425bSmrg	    # but the system doesn't support it.
6944698f425bSmrg
6945698f425bSmrg	    # Just print a warning and add the library to dependency_libs so
6946698f425bSmrg	    # that the program can be linked against the static library.
69479ef0b394Smrg	    echo
6948698f425bSmrg	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
69499ef0b394Smrg	    echo "*** I have the capability to make that library automatically link in when"
69509ef0b394Smrg	    echo "*** you link to this library.  But I can only do this if you have a"
69519ef0b394Smrg	    echo "*** shared version of the library, which you do not appear to have."
6952698f425bSmrg	    if test "$module" = yes; then
69539ef0b394Smrg	      echo "*** But as you try to build a module library, libtool will still create "
69549ef0b394Smrg	      echo "*** a static module, that should work as long as the dlopening application"
69559ef0b394Smrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
6956698f425bSmrg	      if test -z "$global_symbol_pipe"; then
69579ef0b394Smrg		echo
69589ef0b394Smrg		echo "*** However, this would only work if libtool was able to extract symbol"
69599ef0b394Smrg		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
69609ef0b394Smrg		echo "*** not find such a program.  So, this module is probably useless."
69619ef0b394Smrg		echo "*** \`nm' from GNU binutils and a full rebuild may help."
6962698f425bSmrg	      fi
6963698f425bSmrg	      if test "$build_old_libs" = no; then
6964698f425bSmrg		build_libtool_libs=module
6965698f425bSmrg		build_old_libs=yes
6966698f425bSmrg	      else
6967698f425bSmrg		build_libtool_libs=no
6968698f425bSmrg	      fi
6969698f425bSmrg	    fi
6970698f425bSmrg	  else
6971698f425bSmrg	    deplibs="$dir/$old_library $deplibs"
6972698f425bSmrg	    link_static=yes
6973698f425bSmrg	  fi
6974698f425bSmrg	fi # link shared/static library?
6975698f425bSmrg
6976698f425bSmrg	if test "$linkmode" = lib; then
6977698f425bSmrg	  if test -n "$dependency_libs" &&
6978698f425bSmrg	     { test "$hardcode_into_libs" != yes ||
6979698f425bSmrg	       test "$build_old_libs" = yes ||
6980698f425bSmrg	       test "$link_static" = yes; }; then
6981698f425bSmrg	    # Extract -R from dependency_libs
6982698f425bSmrg	    temp_deplibs=
6983698f425bSmrg	    for libdir in $dependency_libs; do
6984698f425bSmrg	      case $libdir in
6985698f425bSmrg	      -R*) func_stripname '-R' '' "$libdir"
6986698f425bSmrg	           temp_xrpath=$func_stripname_result
6987698f425bSmrg		   case " $xrpath " in
6988698f425bSmrg		   *" $temp_xrpath "*) ;;
69899ef0b394Smrg		   *) func_append xrpath " $temp_xrpath";;
6990698f425bSmrg		   esac;;
69919ef0b394Smrg	      *) func_append temp_deplibs " $libdir";;
6992698f425bSmrg	      esac
6993698f425bSmrg	    done
6994698f425bSmrg	    dependency_libs="$temp_deplibs"
6995698f425bSmrg	  fi
6996698f425bSmrg
69979ef0b394Smrg	  func_append newlib_search_path " $absdir"
6998698f425bSmrg	  # Link against this library
6999698f425bSmrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
7000698f425bSmrg	  # ... and its dependency_libs
7001698f425bSmrg	  tmp_libs=
7002698f425bSmrg	  for deplib in $dependency_libs; do
7003698f425bSmrg	    newdependency_libs="$deplib $newdependency_libs"
70049ef0b394Smrg	    case $deplib in
70059ef0b394Smrg              -L*) func_stripname '-L' '' "$deplib"
70069ef0b394Smrg                   func_resolve_sysroot "$func_stripname_result";;
70079ef0b394Smrg              *) func_resolve_sysroot "$deplib" ;;
70089ef0b394Smrg            esac
70099ef0b394Smrg	    if $opt_preserve_dup_deps ; then
7010698f425bSmrg	      case "$tmp_libs " in
70119ef0b394Smrg	      *" $func_resolve_sysroot_result "*)
70129ef0b394Smrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
7013698f425bSmrg	      esac
7014698f425bSmrg	    fi
70159ef0b394Smrg	    func_append tmp_libs " $func_resolve_sysroot_result"
7016698f425bSmrg	  done
7017698f425bSmrg
7018698f425bSmrg	  if test "$link_all_deplibs" != no; then
7019698f425bSmrg	    # Add the search paths of all dependency libraries
7020698f425bSmrg	    for deplib in $dependency_libs; do
70219ef0b394Smrg	      path=
7022698f425bSmrg	      case $deplib in
7023698f425bSmrg	      -L*) path="$deplib" ;;
7024698f425bSmrg	      *.la)
70259ef0b394Smrg	        func_resolve_sysroot "$deplib"
70269ef0b394Smrg	        deplib=$func_resolve_sysroot_result
7027698f425bSmrg	        func_dirname "$deplib" "" "."
70289ef0b394Smrg		dir=$func_dirname_result
7029698f425bSmrg		# We need an absolute path.
7030698f425bSmrg		case $dir in
7031698f425bSmrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
7032698f425bSmrg		*)
7033698f425bSmrg		  absdir=`cd "$dir" && pwd`
7034698f425bSmrg		  if test -z "$absdir"; then
7035698f425bSmrg		    func_warning "cannot determine absolute directory name of \`$dir'"
7036698f425bSmrg		    absdir="$dir"
7037698f425bSmrg		  fi
7038698f425bSmrg		  ;;
7039698f425bSmrg		esac
7040698f425bSmrg		if $GREP "^installed=no" $deplib > /dev/null; then
7041698f425bSmrg		case $host in
7042698f425bSmrg		*-*-darwin*)
7043698f425bSmrg		  depdepl=
7044698f425bSmrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
7045698f425bSmrg		  if test -n "$deplibrary_names" ; then
7046698f425bSmrg		    for tmp in $deplibrary_names ; do
7047698f425bSmrg		      depdepl=$tmp
7048698f425bSmrg		    done
7049698f425bSmrg		    if test -f "$absdir/$objdir/$depdepl" ; then
7050698f425bSmrg		      depdepl="$absdir/$objdir/$depdepl"
7051698f425bSmrg		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
7052698f425bSmrg                      if test -z "$darwin_install_name"; then
7053698f425bSmrg                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
7054698f425bSmrg                      fi
70559ef0b394Smrg		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
70569ef0b394Smrg		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
7057698f425bSmrg		      path=
7058698f425bSmrg		    fi
7059698f425bSmrg		  fi
7060698f425bSmrg		  ;;
7061698f425bSmrg		*)
7062698f425bSmrg		  path="-L$absdir/$objdir"
7063698f425bSmrg		  ;;
7064698f425bSmrg		esac
7065698f425bSmrg		else
7066698f425bSmrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
7067698f425bSmrg		  test -z "$libdir" && \
7068698f425bSmrg		    func_fatal_error "\`$deplib' is not a valid libtool archive"
7069698f425bSmrg		  test "$absdir" != "$libdir" && \
7070698f425bSmrg		    func_warning "\`$deplib' seems to be moved"
7071698f425bSmrg
7072698f425bSmrg		  path="-L$absdir"
7073698f425bSmrg		fi
7074698f425bSmrg		;;
7075698f425bSmrg	      esac
7076698f425bSmrg	      case " $deplibs " in
7077698f425bSmrg	      *" $path "*) ;;
7078698f425bSmrg	      *) deplibs="$path $deplibs" ;;
7079698f425bSmrg	      esac
7080698f425bSmrg	    done
7081698f425bSmrg	  fi # link_all_deplibs != no
7082698f425bSmrg	fi # linkmode = lib
7083698f425bSmrg      done # for deplib in $libs
7084698f425bSmrg      if test "$pass" = link; then
7085698f425bSmrg	if test "$linkmode" = "prog"; then
7086698f425bSmrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
7087698f425bSmrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
7088698f425bSmrg	else
70899ef0b394Smrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7090698f425bSmrg	fi
7091698f425bSmrg      fi
7092698f425bSmrg      dependency_libs="$newdependency_libs"
7093698f425bSmrg      if test "$pass" = dlpreopen; then
7094698f425bSmrg	# Link the dlpreopened libraries before other libraries
7095698f425bSmrg	for deplib in $save_deplibs; do
7096698f425bSmrg	  deplibs="$deplib $deplibs"
7097698f425bSmrg	done
7098698f425bSmrg      fi
7099698f425bSmrg      if test "$pass" != dlopen; then
7100698f425bSmrg	if test "$pass" != conv; then
7101698f425bSmrg	  # Make sure lib_search_path contains only unique directories.
7102698f425bSmrg	  lib_search_path=
7103698f425bSmrg	  for dir in $newlib_search_path; do
7104698f425bSmrg	    case "$lib_search_path " in
7105698f425bSmrg	    *" $dir "*) ;;
71069ef0b394Smrg	    *) func_append lib_search_path " $dir" ;;
7107698f425bSmrg	    esac
7108698f425bSmrg	  done
7109698f425bSmrg	  newlib_search_path=
7110698f425bSmrg	fi
7111698f425bSmrg
7112698f425bSmrg	if test "$linkmode,$pass" != "prog,link"; then
7113698f425bSmrg	  vars="deplibs"
7114698f425bSmrg	else
7115698f425bSmrg	  vars="compile_deplibs finalize_deplibs"
7116698f425bSmrg	fi
7117698f425bSmrg	for var in $vars dependency_libs; do
7118698f425bSmrg	  # Add libraries to $var in reverse order
7119698f425bSmrg	  eval tmp_libs=\"\$$var\"
7120698f425bSmrg	  new_libs=
7121698f425bSmrg	  for deplib in $tmp_libs; do
7122698f425bSmrg	    # FIXME: Pedantically, this is the right thing to do, so
7123698f425bSmrg	    #        that some nasty dependency loop isn't accidentally
7124698f425bSmrg	    #        broken:
7125698f425bSmrg	    #new_libs="$deplib $new_libs"
7126698f425bSmrg	    # Pragmatically, this seems to cause very few problems in
7127698f425bSmrg	    # practice:
7128698f425bSmrg	    case $deplib in
7129698f425bSmrg	    -L*) new_libs="$deplib $new_libs" ;;
7130698f425bSmrg	    -R*) ;;
7131698f425bSmrg	    *)
7132698f425bSmrg	      # And here is the reason: when a library appears more
7133698f425bSmrg	      # than once as an explicit dependence of a library, or
7134698f425bSmrg	      # is implicitly linked in more than once by the
7135698f425bSmrg	      # compiler, it is considered special, and multiple
7136698f425bSmrg	      # occurrences thereof are not removed.  Compare this
7137698f425bSmrg	      # with having the same library being listed as a
7138698f425bSmrg	      # dependency of multiple other libraries: in this case,
7139698f425bSmrg	      # we know (pedantically, we assume) the library does not
7140698f425bSmrg	      # need to be listed more than once, so we keep only the
7141698f425bSmrg	      # last copy.  This is not always right, but it is rare
7142698f425bSmrg	      # enough that we require users that really mean to play
7143698f425bSmrg	      # such unportable linking tricks to link the library
7144698f425bSmrg	      # using -Wl,-lname, so that libtool does not consider it
7145698f425bSmrg	      # for duplicate removal.
7146698f425bSmrg	      case " $specialdeplibs " in
7147698f425bSmrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
7148698f425bSmrg	      *)
7149698f425bSmrg		case " $new_libs " in
7150698f425bSmrg		*" $deplib "*) ;;
7151698f425bSmrg		*) new_libs="$deplib $new_libs" ;;
7152698f425bSmrg		esac
7153698f425bSmrg		;;
7154698f425bSmrg	      esac
7155698f425bSmrg	      ;;
7156698f425bSmrg	    esac
7157698f425bSmrg	  done
7158698f425bSmrg	  tmp_libs=
7159698f425bSmrg	  for deplib in $new_libs; do
7160698f425bSmrg	    case $deplib in
7161698f425bSmrg	    -L*)
7162698f425bSmrg	      case " $tmp_libs " in
7163698f425bSmrg	      *" $deplib "*) ;;
71649ef0b394Smrg	      *) func_append tmp_libs " $deplib" ;;
7165698f425bSmrg	      esac
7166698f425bSmrg	      ;;
71679ef0b394Smrg	    *) func_append tmp_libs " $deplib" ;;
7168698f425bSmrg	    esac
7169698f425bSmrg	  done
7170698f425bSmrg	  eval $var=\"$tmp_libs\"
7171698f425bSmrg	done # for var
7172698f425bSmrg      fi
7173698f425bSmrg      # Last step: remove runtime libs from dependency_libs
7174698f425bSmrg      # (they stay in deplibs)
7175698f425bSmrg      tmp_libs=
7176698f425bSmrg      for i in $dependency_libs ; do
7177698f425bSmrg	case " $predeps $postdeps $compiler_lib_search_path " in
7178698f425bSmrg	*" $i "*)
7179698f425bSmrg	  i=""
7180698f425bSmrg	  ;;
7181698f425bSmrg	esac
7182698f425bSmrg	if test -n "$i" ; then
71839ef0b394Smrg	  func_append tmp_libs " $i"
7184698f425bSmrg	fi
7185698f425bSmrg      done
7186698f425bSmrg      dependency_libs=$tmp_libs
7187698f425bSmrg    done # for pass
7188698f425bSmrg    if test "$linkmode" = prog; then
7189698f425bSmrg      dlfiles="$newdlfiles"
7190698f425bSmrg    fi
7191698f425bSmrg    if test "$linkmode" = prog || test "$linkmode" = lib; then
7192698f425bSmrg      dlprefiles="$newdlprefiles"
7193698f425bSmrg    fi
7194698f425bSmrg
7195698f425bSmrg    case $linkmode in
7196698f425bSmrg    oldlib)
7197698f425bSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
7198698f425bSmrg	func_warning "\`-dlopen' is ignored for archives"
7199698f425bSmrg      fi
7200698f425bSmrg
7201698f425bSmrg      case " $deplibs" in
7202698f425bSmrg      *\ -l* | *\ -L*)
7203698f425bSmrg	func_warning "\`-l' and \`-L' are ignored for archives" ;;
7204698f425bSmrg      esac
7205698f425bSmrg
7206698f425bSmrg      test -n "$rpath" && \
7207698f425bSmrg	func_warning "\`-rpath' is ignored for archives"
7208698f425bSmrg
7209698f425bSmrg      test -n "$xrpath" && \
7210698f425bSmrg	func_warning "\`-R' is ignored for archives"
7211698f425bSmrg
7212698f425bSmrg      test -n "$vinfo" && \
7213698f425bSmrg	func_warning "\`-version-info/-version-number' is ignored for archives"
7214698f425bSmrg
7215698f425bSmrg      test -n "$release" && \
7216698f425bSmrg	func_warning "\`-release' is ignored for archives"
7217698f425bSmrg
7218698f425bSmrg      test -n "$export_symbols$export_symbols_regex" && \
7219698f425bSmrg	func_warning "\`-export-symbols' is ignored for archives"
7220698f425bSmrg
7221698f425bSmrg      # Now set the variables for building old libraries.
7222698f425bSmrg      build_libtool_libs=no
7223698f425bSmrg      oldlibs="$output"
72249ef0b394Smrg      func_append objs "$old_deplibs"
7225698f425bSmrg      ;;
7226698f425bSmrg
7227698f425bSmrg    lib)
7228698f425bSmrg      # Make sure we only generate libraries of the form `libNAME.la'.
7229698f425bSmrg      case $outputname in
7230698f425bSmrg      lib*)
7231698f425bSmrg	func_stripname 'lib' '.la' "$outputname"
7232698f425bSmrg	name=$func_stripname_result
7233698f425bSmrg	eval shared_ext=\"$shrext_cmds\"
7234698f425bSmrg	eval libname=\"$libname_spec\"
7235698f425bSmrg	;;
7236698f425bSmrg      *)
7237698f425bSmrg	test "$module" = no && \
7238698f425bSmrg	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
7239698f425bSmrg
7240698f425bSmrg	if test "$need_lib_prefix" != no; then
7241698f425bSmrg	  # Add the "lib" prefix for modules if required
7242698f425bSmrg	  func_stripname '' '.la' "$outputname"
7243698f425bSmrg	  name=$func_stripname_result
7244698f425bSmrg	  eval shared_ext=\"$shrext_cmds\"
7245698f425bSmrg	  eval libname=\"$libname_spec\"
7246698f425bSmrg	else
7247698f425bSmrg	  func_stripname '' '.la' "$outputname"
7248698f425bSmrg	  libname=$func_stripname_result
7249698f425bSmrg	fi
7250698f425bSmrg	;;
7251698f425bSmrg      esac
7252698f425bSmrg
7253698f425bSmrg      if test -n "$objs"; then
7254698f425bSmrg	if test "$deplibs_check_method" != pass_all; then
7255698f425bSmrg	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
7256698f425bSmrg	else
72579ef0b394Smrg	  echo
7258698f425bSmrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
7259698f425bSmrg	  $ECHO "*** objects $objs is not portable!"
72609ef0b394Smrg	  func_append libobjs " $objs"
7261698f425bSmrg	fi
7262698f425bSmrg      fi
7263698f425bSmrg
7264698f425bSmrg      test "$dlself" != no && \
7265698f425bSmrg	func_warning "\`-dlopen self' is ignored for libtool libraries"
7266698f425bSmrg
7267698f425bSmrg      set dummy $rpath
7268698f425bSmrg      shift
7269698f425bSmrg      test "$#" -gt 1 && \
7270698f425bSmrg	func_warning "ignoring multiple \`-rpath's for a libtool library"
7271698f425bSmrg
7272698f425bSmrg      install_libdir="$1"
7273698f425bSmrg
7274698f425bSmrg      oldlibs=
7275698f425bSmrg      if test -z "$rpath"; then
7276698f425bSmrg	if test "$build_libtool_libs" = yes; then
7277698f425bSmrg	  # Building a libtool convenience library.
7278698f425bSmrg	  # Some compilers have problems with a `.al' extension so
7279698f425bSmrg	  # convenience libraries should have the same extension an
7280698f425bSmrg	  # archive normally would.
7281698f425bSmrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
7282698f425bSmrg	  build_libtool_libs=convenience
7283698f425bSmrg	  build_old_libs=yes
7284698f425bSmrg	fi
7285698f425bSmrg
7286698f425bSmrg	test -n "$vinfo" && \
7287698f425bSmrg	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
7288698f425bSmrg
7289698f425bSmrg	test -n "$release" && \
7290698f425bSmrg	  func_warning "\`-release' is ignored for convenience libraries"
7291698f425bSmrg      else
7292698f425bSmrg
7293698f425bSmrg	# Parse the version information argument.
7294698f425bSmrg	save_ifs="$IFS"; IFS=':'
7295698f425bSmrg	set dummy $vinfo 0 0 0
7296698f425bSmrg	shift
7297698f425bSmrg	IFS="$save_ifs"
7298698f425bSmrg
7299698f425bSmrg	test -n "$7" && \
7300698f425bSmrg	  func_fatal_help "too many parameters to \`-version-info'"
7301698f425bSmrg
7302698f425bSmrg	# convert absolute version numbers to libtool ages
7303698f425bSmrg	# this retains compatibility with .la files and attempts
7304698f425bSmrg	# to make the code below a bit more comprehensible
7305698f425bSmrg
7306698f425bSmrg	case $vinfo_number in
7307698f425bSmrg	yes)
7308698f425bSmrg	  number_major="$1"
7309698f425bSmrg	  number_minor="$2"
7310698f425bSmrg	  number_revision="$3"
7311698f425bSmrg	  #
7312698f425bSmrg	  # There are really only two kinds -- those that
7313698f425bSmrg	  # use the current revision as the major version
7314698f425bSmrg	  # and those that subtract age and use age as
7315698f425bSmrg	  # a minor version.  But, then there is irix
7316698f425bSmrg	  # which has an extra 1 added just for fun
7317698f425bSmrg	  #
7318698f425bSmrg	  case $version_type in
7319698f425bSmrg	  darwin|linux|osf|windows|none)
7320698f425bSmrg	    func_arith $number_major + $number_minor
7321698f425bSmrg	    current=$func_arith_result
7322698f425bSmrg	    age="$number_minor"
7323698f425bSmrg	    revision="$number_revision"
7324698f425bSmrg	    ;;
73259ef0b394Smrg	  freebsd-aout|freebsd-elf|qnx|sunos)
7326698f425bSmrg	    current="$number_major"
7327698f425bSmrg	    revision="$number_minor"
7328698f425bSmrg	    age="0"
7329698f425bSmrg	    ;;
7330698f425bSmrg	  irix|nonstopux)
7331698f425bSmrg	    func_arith $number_major + $number_minor
7332698f425bSmrg	    current=$func_arith_result
7333698f425bSmrg	    age="$number_minor"
7334698f425bSmrg	    revision="$number_minor"
7335698f425bSmrg	    lt_irix_increment=no
7336698f425bSmrg	    ;;
7337698f425bSmrg	  esac
7338698f425bSmrg	  ;;
7339698f425bSmrg	no)
7340698f425bSmrg	  current="$1"
7341698f425bSmrg	  revision="$2"
7342698f425bSmrg	  age="$3"
7343698f425bSmrg	  ;;
7344698f425bSmrg	esac
7345698f425bSmrg
7346698f425bSmrg	# Check that each of the things are valid numbers.
7347698f425bSmrg	case $current in
7348698f425bSmrg	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]) ;;
7349698f425bSmrg	*)
7350698f425bSmrg	  func_error "CURRENT \`$current' must be a nonnegative integer"
7351698f425bSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
7352698f425bSmrg	  ;;
7353698f425bSmrg	esac
7354698f425bSmrg
7355698f425bSmrg	case $revision in
7356698f425bSmrg	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]) ;;
7357698f425bSmrg	*)
7358698f425bSmrg	  func_error "REVISION \`$revision' must be a nonnegative integer"
7359698f425bSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
7360698f425bSmrg	  ;;
7361698f425bSmrg	esac
7362698f425bSmrg
7363698f425bSmrg	case $age in
7364698f425bSmrg	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]) ;;
7365698f425bSmrg	*)
7366698f425bSmrg	  func_error "AGE \`$age' must be a nonnegative integer"
7367698f425bSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
7368698f425bSmrg	  ;;
7369698f425bSmrg	esac
7370698f425bSmrg
7371698f425bSmrg	if test "$age" -gt "$current"; then
7372698f425bSmrg	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
7373698f425bSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
7374698f425bSmrg	fi
7375698f425bSmrg
7376698f425bSmrg	# Calculate the version variables.
7377698f425bSmrg	major=
7378698f425bSmrg	versuffix=
7379698f425bSmrg	verstring=
7380698f425bSmrg	case $version_type in
7381698f425bSmrg	none) ;;
7382698f425bSmrg
7383698f425bSmrg	darwin)
7384698f425bSmrg	  # Like Linux, but with the current version available in
7385698f425bSmrg	  # verstring for coding it into the library header
7386698f425bSmrg	  func_arith $current - $age
7387698f425bSmrg	  major=.$func_arith_result
7388698f425bSmrg	  versuffix="$major.$age.$revision"
7389698f425bSmrg	  # Darwin ld doesn't like 0 for these options...
7390698f425bSmrg	  func_arith $current + 1
7391698f425bSmrg	  minor_current=$func_arith_result
7392698f425bSmrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
7393698f425bSmrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
7394698f425bSmrg	  ;;
7395698f425bSmrg
7396698f425bSmrg	freebsd-aout)
7397698f425bSmrg	  major=".$current"
7398698f425bSmrg	  versuffix=".$current.$revision";
7399698f425bSmrg	  ;;
7400698f425bSmrg
7401698f425bSmrg	freebsd-elf)
7402698f425bSmrg	  major=".$current"
7403698f425bSmrg	  versuffix=".$current"
7404698f425bSmrg	  ;;
7405698f425bSmrg
7406698f425bSmrg	irix | nonstopux)
7407698f425bSmrg	  if test "X$lt_irix_increment" = "Xno"; then
7408698f425bSmrg	    func_arith $current - $age
7409698f425bSmrg	  else
7410698f425bSmrg	    func_arith $current - $age + 1
7411698f425bSmrg	  fi
7412698f425bSmrg	  major=$func_arith_result
7413698f425bSmrg
7414698f425bSmrg	  case $version_type in
7415698f425bSmrg	    nonstopux) verstring_prefix=nonstopux ;;
7416698f425bSmrg	    *)         verstring_prefix=sgi ;;
7417698f425bSmrg	  esac
7418698f425bSmrg	  verstring="$verstring_prefix$major.$revision"
7419698f425bSmrg
7420698f425bSmrg	  # Add in all the interfaces that we are compatible with.
7421698f425bSmrg	  loop=$revision
7422698f425bSmrg	  while test "$loop" -ne 0; do
7423698f425bSmrg	    func_arith $revision - $loop
7424698f425bSmrg	    iface=$func_arith_result
7425698f425bSmrg	    func_arith $loop - 1
7426698f425bSmrg	    loop=$func_arith_result
7427698f425bSmrg	    verstring="$verstring_prefix$major.$iface:$verstring"
7428698f425bSmrg	  done
7429698f425bSmrg
7430698f425bSmrg	  # Before this point, $major must not contain `.'.
7431698f425bSmrg	  major=.$major
7432698f425bSmrg	  versuffix="$major.$revision"
7433698f425bSmrg	  ;;
7434698f425bSmrg
7435698f425bSmrg	linux)
7436698f425bSmrg	  func_arith $current - $age
7437698f425bSmrg	  major=.$func_arith_result
7438698f425bSmrg	  versuffix="$major.$age.$revision"
7439698f425bSmrg	  ;;
7440698f425bSmrg
7441698f425bSmrg	osf)
7442698f425bSmrg	  func_arith $current - $age
7443698f425bSmrg	  major=.$func_arith_result
7444698f425bSmrg	  versuffix=".$current.$age.$revision"
7445698f425bSmrg	  verstring="$current.$age.$revision"
7446698f425bSmrg
7447698f425bSmrg	  # Add in all the interfaces that we are compatible with.
7448698f425bSmrg	  loop=$age
7449698f425bSmrg	  while test "$loop" -ne 0; do
7450698f425bSmrg	    func_arith $current - $loop
7451698f425bSmrg	    iface=$func_arith_result
7452698f425bSmrg	    func_arith $loop - 1
7453698f425bSmrg	    loop=$func_arith_result
7454698f425bSmrg	    verstring="$verstring:${iface}.0"
7455698f425bSmrg	  done
7456698f425bSmrg
7457698f425bSmrg	  # Make executables depend on our current version.
74589ef0b394Smrg	  func_append verstring ":${current}.0"
7459698f425bSmrg	  ;;
7460698f425bSmrg
7461698f425bSmrg	qnx)
7462698f425bSmrg	  major=".$current"
7463698f425bSmrg	  versuffix=".$current"
7464698f425bSmrg	  ;;
7465698f425bSmrg
7466698f425bSmrg	sunos)
7467698f425bSmrg	  major=".$current"
7468698f425bSmrg	  versuffix=".$current.$revision"
7469698f425bSmrg	  ;;
7470698f425bSmrg
7471698f425bSmrg	windows)
7472698f425bSmrg	  # Use '-' rather than '.', since we only want one
7473698f425bSmrg	  # extension on DOS 8.3 filesystems.
7474698f425bSmrg	  func_arith $current - $age
7475698f425bSmrg	  major=$func_arith_result
7476698f425bSmrg	  versuffix="-$major"
7477698f425bSmrg	  ;;
7478698f425bSmrg
7479698f425bSmrg	*)
7480698f425bSmrg	  func_fatal_configuration "unknown library version type \`$version_type'"
7481698f425bSmrg	  ;;
7482698f425bSmrg	esac
7483698f425bSmrg
7484698f425bSmrg	# Clear the version info if we defaulted, and they specified a release.
7485698f425bSmrg	if test -z "$vinfo" && test -n "$release"; then
7486698f425bSmrg	  major=
7487698f425bSmrg	  case $version_type in
7488698f425bSmrg	  darwin)
7489698f425bSmrg	    # we can't check for "0.0" in archive_cmds due to quoting
7490698f425bSmrg	    # problems, so we reset it completely
7491698f425bSmrg	    verstring=
7492698f425bSmrg	    ;;
7493698f425bSmrg	  *)
7494698f425bSmrg	    verstring="0.0"
7495698f425bSmrg	    ;;
7496698f425bSmrg	  esac
7497698f425bSmrg	  if test "$need_version" = no; then
7498698f425bSmrg	    versuffix=
7499698f425bSmrg	  else
7500698f425bSmrg	    versuffix=".0.0"
7501698f425bSmrg	  fi
7502698f425bSmrg	fi
7503698f425bSmrg
7504698f425bSmrg	# Remove version info from name if versioning should be avoided
7505698f425bSmrg	if test "$avoid_version" = yes && test "$need_version" = no; then
7506698f425bSmrg	  major=
7507698f425bSmrg	  versuffix=
7508698f425bSmrg	  verstring=""
7509698f425bSmrg	fi
7510698f425bSmrg
7511698f425bSmrg	# Check to see if the archive will have undefined symbols.
7512698f425bSmrg	if test "$allow_undefined" = yes; then
7513698f425bSmrg	  if test "$allow_undefined_flag" = unsupported; then
7514698f425bSmrg	    func_warning "undefined symbols not allowed in $host shared libraries"
7515698f425bSmrg	    build_libtool_libs=no
7516698f425bSmrg	    build_old_libs=yes
7517698f425bSmrg	  fi
7518698f425bSmrg	else
7519698f425bSmrg	  # Don't allow undefined symbols.
7520698f425bSmrg	  allow_undefined_flag="$no_undefined_flag"
7521698f425bSmrg	fi
7522698f425bSmrg
7523698f425bSmrg      fi
7524698f425bSmrg
7525698f425bSmrg      func_generate_dlsyms "$libname" "$libname" "yes"
75269ef0b394Smrg      func_append libobjs " $symfileobj"
7527698f425bSmrg      test "X$libobjs" = "X " && libobjs=
7528698f425bSmrg
75299ef0b394Smrg      if test "$opt_mode" != relink; then
7530698f425bSmrg	# Remove our outputs, but don't remove object files since they
7531698f425bSmrg	# may have been created when compiling PIC objects.
7532698f425bSmrg	removelist=
7533698f425bSmrg	tempremovelist=`$ECHO "$output_objdir/*"`
7534698f425bSmrg	for p in $tempremovelist; do
7535698f425bSmrg	  case $p in
7536698f425bSmrg	    *.$objext | *.gcno)
7537698f425bSmrg	       ;;
7538698f425bSmrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
7539698f425bSmrg	       if test "X$precious_files_regex" != "X"; then
7540698f425bSmrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
7541698f425bSmrg		 then
7542698f425bSmrg		   continue
7543698f425bSmrg		 fi
7544698f425bSmrg	       fi
75459ef0b394Smrg	       func_append removelist " $p"
7546698f425bSmrg	       ;;
7547698f425bSmrg	    *) ;;
7548698f425bSmrg	  esac
7549698f425bSmrg	done
7550698f425bSmrg	test -n "$removelist" && \
7551698f425bSmrg	  func_show_eval "${RM}r \$removelist"
7552698f425bSmrg      fi
7553698f425bSmrg
7554698f425bSmrg      # Now set the variables for building old libraries.
7555698f425bSmrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
75569ef0b394Smrg	func_append oldlibs " $output_objdir/$libname.$libext"
7557698f425bSmrg
7558698f425bSmrg	# Transform .lo files to .o files.
75599ef0b394Smrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
7560698f425bSmrg      fi
7561698f425bSmrg
7562698f425bSmrg      # Eliminate all temporary directories.
7563698f425bSmrg      #for path in $notinst_path; do
75649ef0b394Smrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
75659ef0b394Smrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
75669ef0b394Smrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
7567698f425bSmrg      #done
7568698f425bSmrg
7569698f425bSmrg      if test -n "$xrpath"; then
7570698f425bSmrg	# If the user specified any rpath flags, then add them.
7571698f425bSmrg	temp_xrpath=
7572698f425bSmrg	for libdir in $xrpath; do
75739ef0b394Smrg	  func_replace_sysroot "$libdir"
75749ef0b394Smrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
7575698f425bSmrg	  case "$finalize_rpath " in
7576698f425bSmrg	  *" $libdir "*) ;;
75779ef0b394Smrg	  *) func_append finalize_rpath " $libdir" ;;
7578698f425bSmrg	  esac
7579698f425bSmrg	done
7580698f425bSmrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
7581698f425bSmrg	  dependency_libs="$temp_xrpath $dependency_libs"
7582698f425bSmrg	fi
7583698f425bSmrg      fi
7584698f425bSmrg
7585698f425bSmrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
7586698f425bSmrg      old_dlfiles="$dlfiles"
7587698f425bSmrg      dlfiles=
7588698f425bSmrg      for lib in $old_dlfiles; do
7589698f425bSmrg	case " $dlprefiles $dlfiles " in
7590698f425bSmrg	*" $lib "*) ;;
75919ef0b394Smrg	*) func_append dlfiles " $lib" ;;
7592698f425bSmrg	esac
7593698f425bSmrg      done
7594698f425bSmrg
7595698f425bSmrg      # Make sure dlprefiles contains only unique files
7596698f425bSmrg      old_dlprefiles="$dlprefiles"
7597698f425bSmrg      dlprefiles=
7598698f425bSmrg      for lib in $old_dlprefiles; do
7599698f425bSmrg	case "$dlprefiles " in
7600698f425bSmrg	*" $lib "*) ;;
76019ef0b394Smrg	*) func_append dlprefiles " $lib" ;;
7602698f425bSmrg	esac
7603698f425bSmrg      done
7604698f425bSmrg
7605698f425bSmrg      if test "$build_libtool_libs" = yes; then
7606698f425bSmrg	if test -n "$rpath"; then
7607698f425bSmrg	  case $host in
76089ef0b394Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
7609698f425bSmrg	    # these systems don't actually have a c library (as such)!
7610698f425bSmrg	    ;;
7611698f425bSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
7612698f425bSmrg	    # Rhapsody C library is in the System framework
76139ef0b394Smrg	    func_append deplibs " System.ltframework"
7614698f425bSmrg	    ;;
7615698f425bSmrg	  *-*-netbsd*)
7616698f425bSmrg	    # Don't link with libc until the a.out ld.so is fixed.
7617698f425bSmrg	    ;;
7618698f425bSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
7619698f425bSmrg	    # Do not include libc due to us having libc/libc_r.
7620698f425bSmrg	    ;;
7621698f425bSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
7622698f425bSmrg	    # Causes problems with __ctype
7623698f425bSmrg	    ;;
7624698f425bSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
7625698f425bSmrg	    # Compiler inserts libc in the correct place for threads to work
7626698f425bSmrg	    ;;
7627698f425bSmrg	  *)
7628698f425bSmrg	    # Add libc to deplibs on all other systems if necessary.
7629698f425bSmrg	    if test "$build_libtool_need_lc" = "yes"; then
76309ef0b394Smrg	      func_append deplibs " -lc"
7631698f425bSmrg	    fi
7632698f425bSmrg	    ;;
7633698f425bSmrg	  esac
7634698f425bSmrg	fi
7635698f425bSmrg
7636698f425bSmrg	# Transform deplibs into only deplibs that can be linked in shared.
7637698f425bSmrg	name_save=$name
7638698f425bSmrg	libname_save=$libname
7639698f425bSmrg	release_save=$release
7640698f425bSmrg	versuffix_save=$versuffix
7641698f425bSmrg	major_save=$major
7642698f425bSmrg	# I'm not sure if I'm treating the release correctly.  I think
7643698f425bSmrg	# release should show up in the -l (ie -lgmp5) so we don't want to
7644698f425bSmrg	# add it in twice.  Is that correct?
7645698f425bSmrg	release=""
7646698f425bSmrg	versuffix=""
7647698f425bSmrg	major=""
7648698f425bSmrg	newdeplibs=
7649698f425bSmrg	droppeddeps=no
7650698f425bSmrg	case $deplibs_check_method in
7651698f425bSmrg	pass_all)
7652698f425bSmrg	  # Don't check for shared/static.  Everything works.
7653698f425bSmrg	  # This might be a little naive.  We might want to check
7654698f425bSmrg	  # whether the library exists or not.  But this is on
7655698f425bSmrg	  # osf3 & osf4 and I'm not really sure... Just
7656698f425bSmrg	  # implementing what was already the behavior.
7657698f425bSmrg	  newdeplibs=$deplibs
7658698f425bSmrg	  ;;
7659698f425bSmrg	test_compile)
7660698f425bSmrg	  # This code stresses the "libraries are programs" paradigm to its
7661698f425bSmrg	  # limits. Maybe even breaks it.  We compile a program, linking it
7662698f425bSmrg	  # against the deplibs as a proxy for the library.  Then we can check
7663698f425bSmrg	  # whether they linked in statically or dynamically with ldd.
7664698f425bSmrg	  $opt_dry_run || $RM conftest.c
7665698f425bSmrg	  cat > conftest.c <<EOF
7666698f425bSmrg	  int main() { return 0; }
7667698f425bSmrgEOF
7668698f425bSmrg	  $opt_dry_run || $RM conftest
7669698f425bSmrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
7670698f425bSmrg	    ldd_output=`ldd conftest`
7671698f425bSmrg	    for i in $deplibs; do
7672698f425bSmrg	      case $i in
7673698f425bSmrg	      -l*)
7674698f425bSmrg		func_stripname -l '' "$i"
7675698f425bSmrg		name=$func_stripname_result
7676698f425bSmrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7677698f425bSmrg		  case " $predeps $postdeps " in
7678698f425bSmrg		  *" $i "*)
76799ef0b394Smrg		    func_append newdeplibs " $i"
7680698f425bSmrg		    i=""
7681698f425bSmrg		    ;;
7682698f425bSmrg		  esac
7683698f425bSmrg		fi
7684698f425bSmrg		if test -n "$i" ; then
7685698f425bSmrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
7686698f425bSmrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7687698f425bSmrg		  set dummy $deplib_matches; shift
7688698f425bSmrg		  deplib_match=$1
7689698f425bSmrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
76909ef0b394Smrg		    func_append newdeplibs " $i"
7691698f425bSmrg		  else
7692698f425bSmrg		    droppeddeps=yes
76939ef0b394Smrg		    echo
7694698f425bSmrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
76959ef0b394Smrg		    echo "*** I have the capability to make that library automatically link in when"
76969ef0b394Smrg		    echo "*** you link to this library.  But I can only do this if you have a"
76979ef0b394Smrg		    echo "*** shared version of the library, which I believe you do not have"
76989ef0b394Smrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
76999ef0b394Smrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
7700698f425bSmrg		  fi
7701698f425bSmrg		fi
7702698f425bSmrg		;;
7703698f425bSmrg	      *)
77049ef0b394Smrg		func_append newdeplibs " $i"
7705698f425bSmrg		;;
7706698f425bSmrg	      esac
7707698f425bSmrg	    done
7708698f425bSmrg	  else
7709698f425bSmrg	    # Error occurred in the first compile.  Let's try to salvage
7710698f425bSmrg	    # the situation: Compile a separate program for each library.
7711698f425bSmrg	    for i in $deplibs; do
7712698f425bSmrg	      case $i in
7713698f425bSmrg	      -l*)
7714698f425bSmrg		func_stripname -l '' "$i"
7715698f425bSmrg		name=$func_stripname_result
7716698f425bSmrg		$opt_dry_run || $RM conftest
7717698f425bSmrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
7718698f425bSmrg		  ldd_output=`ldd conftest`
7719698f425bSmrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7720698f425bSmrg		    case " $predeps $postdeps " in
7721698f425bSmrg		    *" $i "*)
77229ef0b394Smrg		      func_append newdeplibs " $i"
7723698f425bSmrg		      i=""
7724698f425bSmrg		      ;;
7725698f425bSmrg		    esac
7726698f425bSmrg		  fi
7727698f425bSmrg		  if test -n "$i" ; then
7728698f425bSmrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
7729698f425bSmrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7730698f425bSmrg		    set dummy $deplib_matches; shift
7731698f425bSmrg		    deplib_match=$1
7732698f425bSmrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
77339ef0b394Smrg		      func_append newdeplibs " $i"
7734698f425bSmrg		    else
7735698f425bSmrg		      droppeddeps=yes
77369ef0b394Smrg		      echo
7737698f425bSmrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
77389ef0b394Smrg		      echo "*** I have the capability to make that library automatically link in when"
77399ef0b394Smrg		      echo "*** you link to this library.  But I can only do this if you have a"
77409ef0b394Smrg		      echo "*** shared version of the library, which you do not appear to have"
77419ef0b394Smrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
77429ef0b394Smrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
7743698f425bSmrg		    fi
7744698f425bSmrg		  fi
7745698f425bSmrg		else
7746698f425bSmrg		  droppeddeps=yes
77479ef0b394Smrg		  echo
7748698f425bSmrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
77499ef0b394Smrg		  echo "*** make it link in!  You will probably need to install it or some"
77509ef0b394Smrg		  echo "*** library that it depends on before this library will be fully"
77519ef0b394Smrg		  echo "*** functional.  Installing it before continuing would be even better."
7752698f425bSmrg		fi
7753698f425bSmrg		;;
7754698f425bSmrg	      *)
77559ef0b394Smrg		func_append newdeplibs " $i"
7756698f425bSmrg		;;
7757698f425bSmrg	      esac
7758698f425bSmrg	    done
7759698f425bSmrg	  fi
7760698f425bSmrg	  ;;
7761698f425bSmrg	file_magic*)
7762698f425bSmrg	  set dummy $deplibs_check_method; shift
7763698f425bSmrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7764698f425bSmrg	  for a_deplib in $deplibs; do
7765698f425bSmrg	    case $a_deplib in
7766698f425bSmrg	    -l*)
7767698f425bSmrg	      func_stripname -l '' "$a_deplib"
7768698f425bSmrg	      name=$func_stripname_result
7769698f425bSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7770698f425bSmrg		case " $predeps $postdeps " in
7771698f425bSmrg		*" $a_deplib "*)
77729ef0b394Smrg		  func_append newdeplibs " $a_deplib"
7773698f425bSmrg		  a_deplib=""
7774698f425bSmrg		  ;;
7775698f425bSmrg		esac
7776698f425bSmrg	      fi
7777698f425bSmrg	      if test -n "$a_deplib" ; then
7778698f425bSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
77799ef0b394Smrg		if test -n "$file_magic_glob"; then
77809ef0b394Smrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
77819ef0b394Smrg		else
77829ef0b394Smrg		  libnameglob=$libname
77839ef0b394Smrg		fi
77849ef0b394Smrg		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
7785698f425bSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
77869ef0b394Smrg		  if test "$want_nocaseglob" = yes; then
77879ef0b394Smrg		    shopt -s nocaseglob
77889ef0b394Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
77899ef0b394Smrg		    $nocaseglob
77909ef0b394Smrg		  else
77919ef0b394Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
77929ef0b394Smrg		  fi
7793698f425bSmrg		  for potent_lib in $potential_libs; do
7794698f425bSmrg		      # Follow soft links.
7795698f425bSmrg		      if ls -lLd "$potent_lib" 2>/dev/null |
7796698f425bSmrg			 $GREP " -> " >/dev/null; then
7797698f425bSmrg			continue
7798698f425bSmrg		      fi
7799698f425bSmrg		      # The statement above tries to avoid entering an
7800698f425bSmrg		      # endless loop below, in case of cyclic links.
7801698f425bSmrg		      # We might still enter an endless loop, since a link
7802698f425bSmrg		      # loop can be closed while we follow links,
7803698f425bSmrg		      # but so what?
7804698f425bSmrg		      potlib="$potent_lib"
7805698f425bSmrg		      while test -h "$potlib" 2>/dev/null; do
7806698f425bSmrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
7807698f425bSmrg			case $potliblink in
7808698f425bSmrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
78099ef0b394Smrg			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
7810698f425bSmrg			esac
7811698f425bSmrg		      done
7812698f425bSmrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
7813698f425bSmrg			 $SED -e 10q |
7814698f425bSmrg			 $EGREP "$file_magic_regex" > /dev/null; then
78159ef0b394Smrg			func_append newdeplibs " $a_deplib"
7816698f425bSmrg			a_deplib=""
7817698f425bSmrg			break 2
7818698f425bSmrg		      fi
7819698f425bSmrg		  done
7820698f425bSmrg		done
7821698f425bSmrg	      fi
7822698f425bSmrg	      if test -n "$a_deplib" ; then
7823698f425bSmrg		droppeddeps=yes
78249ef0b394Smrg		echo
7825698f425bSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
78269ef0b394Smrg		echo "*** I have the capability to make that library automatically link in when"
78279ef0b394Smrg		echo "*** you link to this library.  But I can only do this if you have a"
78289ef0b394Smrg		echo "*** shared version of the library, which you do not appear to have"
78299ef0b394Smrg		echo "*** because I did check the linker path looking for a file starting"
7830698f425bSmrg		if test -z "$potlib" ; then
7831698f425bSmrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
7832698f425bSmrg		else
7833698f425bSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7834698f425bSmrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
7835698f425bSmrg		fi
7836698f425bSmrg	      fi
7837698f425bSmrg	      ;;
7838698f425bSmrg	    *)
7839698f425bSmrg	      # Add a -L argument.
78409ef0b394Smrg	      func_append newdeplibs " $a_deplib"
7841698f425bSmrg	      ;;
7842698f425bSmrg	    esac
7843698f425bSmrg	  done # Gone through all deplibs.
7844698f425bSmrg	  ;;
7845698f425bSmrg	match_pattern*)
7846698f425bSmrg	  set dummy $deplibs_check_method; shift
7847698f425bSmrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7848698f425bSmrg	  for a_deplib in $deplibs; do
7849698f425bSmrg	    case $a_deplib in
7850698f425bSmrg	    -l*)
7851698f425bSmrg	      func_stripname -l '' "$a_deplib"
7852698f425bSmrg	      name=$func_stripname_result
7853698f425bSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7854698f425bSmrg		case " $predeps $postdeps " in
7855698f425bSmrg		*" $a_deplib "*)
78569ef0b394Smrg		  func_append newdeplibs " $a_deplib"
7857698f425bSmrg		  a_deplib=""
7858698f425bSmrg		  ;;
7859698f425bSmrg		esac
7860698f425bSmrg	      fi
7861698f425bSmrg	      if test -n "$a_deplib" ; then
7862698f425bSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
7863698f425bSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7864698f425bSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
7865698f425bSmrg		  for potent_lib in $potential_libs; do
7866698f425bSmrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
78679ef0b394Smrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
7868698f425bSmrg		       $EGREP "$match_pattern_regex" > /dev/null; then
78699ef0b394Smrg		      func_append newdeplibs " $a_deplib"
7870698f425bSmrg		      a_deplib=""
7871698f425bSmrg		      break 2
7872698f425bSmrg		    fi
7873698f425bSmrg		  done
7874698f425bSmrg		done
7875698f425bSmrg	      fi
7876698f425bSmrg	      if test -n "$a_deplib" ; then
7877698f425bSmrg		droppeddeps=yes
78789ef0b394Smrg		echo
7879698f425bSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
78809ef0b394Smrg		echo "*** I have the capability to make that library automatically link in when"
78819ef0b394Smrg		echo "*** you link to this library.  But I can only do this if you have a"
78829ef0b394Smrg		echo "*** shared version of the library, which you do not appear to have"
78839ef0b394Smrg		echo "*** because I did check the linker path looking for a file starting"
7884698f425bSmrg		if test -z "$potlib" ; then
7885698f425bSmrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
7886698f425bSmrg		else
7887698f425bSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7888698f425bSmrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
7889698f425bSmrg		fi
7890698f425bSmrg	      fi
7891698f425bSmrg	      ;;
7892698f425bSmrg	    *)
7893698f425bSmrg	      # Add a -L argument.
78949ef0b394Smrg	      func_append newdeplibs " $a_deplib"
7895698f425bSmrg	      ;;
7896698f425bSmrg	    esac
7897698f425bSmrg	  done # Gone through all deplibs.
7898698f425bSmrg	  ;;
7899698f425bSmrg	none | unknown | *)
7900698f425bSmrg	  newdeplibs=""
79019ef0b394Smrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
7902698f425bSmrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7903698f425bSmrg	    for i in $predeps $postdeps ; do
7904698f425bSmrg	      # can't use Xsed below, because $i might contain '/'
79059ef0b394Smrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
7906698f425bSmrg	    done
7907698f425bSmrg	  fi
79089ef0b394Smrg	  case $tmp_deplibs in
79099ef0b394Smrg	  *[!\	\ ]*)
79109ef0b394Smrg	    echo
7911698f425bSmrg	    if test "X$deplibs_check_method" = "Xnone"; then
79129ef0b394Smrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
7913698f425bSmrg	    else
79149ef0b394Smrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
7915698f425bSmrg	    fi
79169ef0b394Smrg	    echo "*** All declared inter-library dependencies are being dropped."
7917698f425bSmrg	    droppeddeps=yes
79189ef0b394Smrg	    ;;
79199ef0b394Smrg	  esac
7920698f425bSmrg	  ;;
7921698f425bSmrg	esac
7922698f425bSmrg	versuffix=$versuffix_save
7923698f425bSmrg	major=$major_save
7924698f425bSmrg	release=$release_save
7925698f425bSmrg	libname=$libname_save
7926698f425bSmrg	name=$name_save
7927698f425bSmrg
7928698f425bSmrg	case $host in
7929698f425bSmrg	*-*-rhapsody* | *-*-darwin1.[012])
7930698f425bSmrg	  # On Rhapsody replace the C library with the System framework
79319ef0b394Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
7932698f425bSmrg	  ;;
7933698f425bSmrg	esac
7934698f425bSmrg
7935698f425bSmrg	if test "$droppeddeps" = yes; then
7936698f425bSmrg	  if test "$module" = yes; then
79379ef0b394Smrg	    echo
79389ef0b394Smrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
7939698f425bSmrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
79409ef0b394Smrg	    echo "*** a static module, that should work as long as the dlopening"
79419ef0b394Smrg	    echo "*** application is linked with the -dlopen flag."
7942698f425bSmrg	    if test -z "$global_symbol_pipe"; then
79439ef0b394Smrg	      echo
79449ef0b394Smrg	      echo "*** However, this would only work if libtool was able to extract symbol"
79459ef0b394Smrg	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
79469ef0b394Smrg	      echo "*** not find such a program.  So, this module is probably useless."
79479ef0b394Smrg	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
7948698f425bSmrg	    fi
7949698f425bSmrg	    if test "$build_old_libs" = no; then
7950698f425bSmrg	      oldlibs="$output_objdir/$libname.$libext"
7951698f425bSmrg	      build_libtool_libs=module
7952698f425bSmrg	      build_old_libs=yes
7953698f425bSmrg	    else
7954698f425bSmrg	      build_libtool_libs=no
7955698f425bSmrg	    fi
7956698f425bSmrg	  else
79579ef0b394Smrg	    echo "*** The inter-library dependencies that have been dropped here will be"
79589ef0b394Smrg	    echo "*** automatically added whenever a program is linked with this library"
79599ef0b394Smrg	    echo "*** or is declared to -dlopen it."
7960698f425bSmrg
7961698f425bSmrg	    if test "$allow_undefined" = no; then
79629ef0b394Smrg	      echo
79639ef0b394Smrg	      echo "*** Since this library must not contain undefined symbols,"
79649ef0b394Smrg	      echo "*** because either the platform does not support them or"
79659ef0b394Smrg	      echo "*** it was explicitly requested with -no-undefined,"
79669ef0b394Smrg	      echo "*** libtool will only create a static version of it."
7967698f425bSmrg	      if test "$build_old_libs" = no; then
7968698f425bSmrg		oldlibs="$output_objdir/$libname.$libext"
7969698f425bSmrg		build_libtool_libs=module
7970698f425bSmrg		build_old_libs=yes
7971698f425bSmrg	      else
7972698f425bSmrg		build_libtool_libs=no
7973698f425bSmrg	      fi
7974698f425bSmrg	    fi
7975698f425bSmrg	  fi
7976698f425bSmrg	fi
7977698f425bSmrg	# Done checking deplibs!
7978698f425bSmrg	deplibs=$newdeplibs
7979698f425bSmrg      fi
7980698f425bSmrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
7981698f425bSmrg      case $host in
7982698f425bSmrg	*-*-darwin*)
79839ef0b394Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
79849ef0b394Smrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
79859ef0b394Smrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7986698f425bSmrg	  ;;
7987698f425bSmrg      esac
7988698f425bSmrg
7989698f425bSmrg      # move library search paths that coincide with paths to not yet
7990698f425bSmrg      # installed libraries to the beginning of the library search list
7991698f425bSmrg      new_libs=
7992698f425bSmrg      for path in $notinst_path; do
7993698f425bSmrg	case " $new_libs " in
7994698f425bSmrg	*" -L$path/$objdir "*) ;;
7995698f425bSmrg	*)
7996698f425bSmrg	  case " $deplibs " in
7997698f425bSmrg	  *" -L$path/$objdir "*)
79989ef0b394Smrg	    func_append new_libs " -L$path/$objdir" ;;
7999698f425bSmrg	  esac
8000698f425bSmrg	  ;;
8001698f425bSmrg	esac
8002698f425bSmrg      done
8003698f425bSmrg      for deplib in $deplibs; do
8004698f425bSmrg	case $deplib in
8005698f425bSmrg	-L*)
8006698f425bSmrg	  case " $new_libs " in
8007698f425bSmrg	  *" $deplib "*) ;;
80089ef0b394Smrg	  *) func_append new_libs " $deplib" ;;
8009698f425bSmrg	  esac
8010698f425bSmrg	  ;;
80119ef0b394Smrg	*) func_append new_libs " $deplib" ;;
8012698f425bSmrg	esac
8013698f425bSmrg      done
8014698f425bSmrg      deplibs="$new_libs"
8015698f425bSmrg
8016698f425bSmrg      # All the library-specific variables (install_libdir is set above).
8017698f425bSmrg      library_names=
8018698f425bSmrg      old_library=
8019698f425bSmrg      dlname=
8020698f425bSmrg
8021698f425bSmrg      # Test again, we may have decided not to build it any more
8022698f425bSmrg      if test "$build_libtool_libs" = yes; then
8023698f425bSmrg	if test "$hardcode_into_libs" = yes; then
8024698f425bSmrg	  # Hardcode the library paths
8025698f425bSmrg	  hardcode_libdirs=
8026698f425bSmrg	  dep_rpath=
8027698f425bSmrg	  rpath="$finalize_rpath"
80289ef0b394Smrg	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
8029698f425bSmrg	  for libdir in $rpath; do
8030698f425bSmrg	    if test -n "$hardcode_libdir_flag_spec"; then
8031698f425bSmrg	      if test -n "$hardcode_libdir_separator"; then
80329ef0b394Smrg		func_replace_sysroot "$libdir"
80339ef0b394Smrg		libdir=$func_replace_sysroot_result
8034698f425bSmrg		if test -z "$hardcode_libdirs"; then
8035698f425bSmrg		  hardcode_libdirs="$libdir"
8036698f425bSmrg		else
8037698f425bSmrg		  # Just accumulate the unique libdirs.
8038698f425bSmrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8039698f425bSmrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8040698f425bSmrg		    ;;
8041698f425bSmrg		  *)
80429ef0b394Smrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8043698f425bSmrg		    ;;
8044698f425bSmrg		  esac
8045698f425bSmrg		fi
8046698f425bSmrg	      else
8047698f425bSmrg		eval flag=\"$hardcode_libdir_flag_spec\"
80489ef0b394Smrg		func_append dep_rpath " $flag"
8049698f425bSmrg	      fi
8050698f425bSmrg	    elif test -n "$runpath_var"; then
8051698f425bSmrg	      case "$perm_rpath " in
8052698f425bSmrg	      *" $libdir "*) ;;
80539ef0b394Smrg	      *) func_apped perm_rpath " $libdir" ;;
8054698f425bSmrg	      esac
8055698f425bSmrg	    fi
8056698f425bSmrg	  done
8057698f425bSmrg	  # Substitute the hardcoded libdirs into the rpath.
8058698f425bSmrg	  if test -n "$hardcode_libdir_separator" &&
8059698f425bSmrg	     test -n "$hardcode_libdirs"; then
8060698f425bSmrg	    libdir="$hardcode_libdirs"
8061698f425bSmrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
8062698f425bSmrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
8063698f425bSmrg	    else
8064698f425bSmrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
8065698f425bSmrg	    fi
8066698f425bSmrg	  fi
8067698f425bSmrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
8068698f425bSmrg	    # We should set the runpath_var.
8069698f425bSmrg	    rpath=
8070698f425bSmrg	    for dir in $perm_rpath; do
80719ef0b394Smrg	      func_append rpath "$dir:"
8072698f425bSmrg	    done
8073698f425bSmrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
8074698f425bSmrg	  fi
8075698f425bSmrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
8076698f425bSmrg	fi
8077266e564dSmrg
8078698f425bSmrg	shlibpath="$finalize_shlibpath"
80799ef0b394Smrg	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
8080698f425bSmrg	if test -n "$shlibpath"; then
8081698f425bSmrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
8082698f425bSmrg	fi
8083266e564dSmrg
8084698f425bSmrg	# Get the real and link names of the library.
8085698f425bSmrg	eval shared_ext=\"$shrext_cmds\"
8086698f425bSmrg	eval library_names=\"$library_names_spec\"
8087698f425bSmrg	set dummy $library_names
8088698f425bSmrg	shift
8089698f425bSmrg	realname="$1"
8090698f425bSmrg	shift
8091266e564dSmrg
8092698f425bSmrg	if test -n "$soname_spec"; then
8093698f425bSmrg	  eval soname=\"$soname_spec\"
8094698f425bSmrg	else
8095698f425bSmrg	  soname="$realname"
8096698f425bSmrg	fi
8097698f425bSmrg	if test -z "$dlname"; then
8098698f425bSmrg	  dlname=$soname
8099698f425bSmrg	fi
8100266e564dSmrg
8101698f425bSmrg	lib="$output_objdir/$realname"
8102698f425bSmrg	linknames=
8103698f425bSmrg	for link
8104698f425bSmrg	do
81059ef0b394Smrg	  func_append linknames " $link"
8106698f425bSmrg	done
8107266e564dSmrg
8108698f425bSmrg	# Use standard objects if they are pic
81099ef0b394Smrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
8110698f425bSmrg	test "X$libobjs" = "X " && libobjs=
8111266e564dSmrg
8112698f425bSmrg	delfiles=
8113698f425bSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8114698f425bSmrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
8115698f425bSmrg	  export_symbols="$output_objdir/$libname.uexp"
81169ef0b394Smrg	  func_append delfiles " $export_symbols"
8117698f425bSmrg	fi
8118266e564dSmrg
8119698f425bSmrg	orig_export_symbols=
8120698f425bSmrg	case $host_os in
8121698f425bSmrg	cygwin* | mingw* | cegcc*)
8122698f425bSmrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
8123698f425bSmrg	    # exporting using user supplied symfile
8124698f425bSmrg	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
8125698f425bSmrg	      # and it's NOT already a .def file. Must figure out
8126698f425bSmrg	      # which of the given symbols are data symbols and tag
8127698f425bSmrg	      # them as such. So, trigger use of export_symbols_cmds.
8128698f425bSmrg	      # export_symbols gets reassigned inside the "prepare
8129698f425bSmrg	      # the list of exported symbols" if statement, so the
8130698f425bSmrg	      # include_expsyms logic still works.
8131698f425bSmrg	      orig_export_symbols="$export_symbols"
8132698f425bSmrg	      export_symbols=
8133698f425bSmrg	      always_export_symbols=yes
8134698f425bSmrg	    fi
8135698f425bSmrg	  fi
8136698f425bSmrg	  ;;
8137698f425bSmrg	esac
8138266e564dSmrg
8139698f425bSmrg	# Prepare the list of exported symbols
8140698f425bSmrg	if test -z "$export_symbols"; then
8141698f425bSmrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
8142698f425bSmrg	    func_verbose "generating symbol list for \`$libname.la'"
8143698f425bSmrg	    export_symbols="$output_objdir/$libname.exp"
8144698f425bSmrg	    $opt_dry_run || $RM $export_symbols
8145698f425bSmrg	    cmds=$export_symbols_cmds
8146698f425bSmrg	    save_ifs="$IFS"; IFS='~'
81479ef0b394Smrg	    for cmd1 in $cmds; do
8148698f425bSmrg	      IFS="$save_ifs"
81499ef0b394Smrg	      # Take the normal branch if the nm_file_list_spec branch
81509ef0b394Smrg	      # doesn't work or if tool conversion is not needed.
81519ef0b394Smrg	      case $nm_file_list_spec~$to_tool_file_cmd in
81529ef0b394Smrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
81539ef0b394Smrg		  try_normal_branch=yes
81549ef0b394Smrg		  eval cmd=\"$cmd1\"
81559ef0b394Smrg		  func_len " $cmd"
81569ef0b394Smrg		  len=$func_len_result
81579ef0b394Smrg		  ;;
81589ef0b394Smrg		*)
81599ef0b394Smrg		  try_normal_branch=no
81609ef0b394Smrg		  ;;
81619ef0b394Smrg	      esac
81629ef0b394Smrg	      if test "$try_normal_branch" = yes \
81639ef0b394Smrg		 && { test "$len" -lt "$max_cmd_len" \
81649ef0b394Smrg		      || test "$max_cmd_len" -le -1; }
81659ef0b394Smrg	      then
81669ef0b394Smrg		func_show_eval "$cmd" 'exit $?'
81679ef0b394Smrg		skipped_export=false
81689ef0b394Smrg	      elif test -n "$nm_file_list_spec"; then
81699ef0b394Smrg		func_basename "$output"
81709ef0b394Smrg		output_la=$func_basename_result
81719ef0b394Smrg		save_libobjs=$libobjs
81729ef0b394Smrg		save_output=$output
81739ef0b394Smrg		output=${output_objdir}/${output_la}.nm
81749ef0b394Smrg		func_to_tool_file "$output"
81759ef0b394Smrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
81769ef0b394Smrg		func_append delfiles " $output"
81779ef0b394Smrg		func_verbose "creating $NM input file list: $output"
81789ef0b394Smrg		for obj in $save_libobjs; do
81799ef0b394Smrg		  func_to_tool_file "$obj"
81809ef0b394Smrg		  $ECHO "$func_to_tool_file_result"
81819ef0b394Smrg		done > "$output"
81829ef0b394Smrg		eval cmd=\"$cmd1\"
8183698f425bSmrg		func_show_eval "$cmd" 'exit $?'
81849ef0b394Smrg		output=$save_output
81859ef0b394Smrg		libobjs=$save_libobjs
8186698f425bSmrg		skipped_export=false
8187698f425bSmrg	      else
8188698f425bSmrg		# The command line is too long to execute in one step.
8189698f425bSmrg		func_verbose "using reloadable object file for export list..."
8190698f425bSmrg		skipped_export=:
8191698f425bSmrg		# Break out early, otherwise skipped_export may be
8192698f425bSmrg		# set to false by a later but shorter cmd.
8193698f425bSmrg		break
8194698f425bSmrg	      fi
8195698f425bSmrg	    done
8196698f425bSmrg	    IFS="$save_ifs"
8197698f425bSmrg	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
8198698f425bSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8199698f425bSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8200698f425bSmrg	    fi
8201698f425bSmrg	  fi
8202266e564dSmrg	fi
8203266e564dSmrg
8204698f425bSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8205698f425bSmrg	  tmp_export_symbols="$export_symbols"
8206698f425bSmrg	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
82079ef0b394Smrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8208698f425bSmrg	fi
8209266e564dSmrg
8210698f425bSmrg	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
8211698f425bSmrg	  # The given exports_symbols file has to be filtered, so filter it.
8212698f425bSmrg	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8213698f425bSmrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
8214698f425bSmrg	  # 's' commands which not all seds can handle. GNU sed should be fine
8215698f425bSmrg	  # though. Also, the filter scales superlinearly with the number of
8216698f425bSmrg	  # global variables. join(1) would be nice here, but unfortunately
8217698f425bSmrg	  # isn't a blessed tool.
8218698f425bSmrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
82199ef0b394Smrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8220698f425bSmrg	  export_symbols=$output_objdir/$libname.def
8221698f425bSmrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8222698f425bSmrg	fi
8223266e564dSmrg
8224698f425bSmrg	tmp_deplibs=
8225698f425bSmrg	for test_deplib in $deplibs; do
8226698f425bSmrg	  case " $convenience " in
8227698f425bSmrg	  *" $test_deplib "*) ;;
8228698f425bSmrg	  *)
82299ef0b394Smrg	    func_append tmp_deplibs " $test_deplib"
8230698f425bSmrg	    ;;
8231698f425bSmrg	  esac
8232698f425bSmrg	done
8233698f425bSmrg	deplibs="$tmp_deplibs"
8234266e564dSmrg
8235698f425bSmrg	if test -n "$convenience"; then
8236698f425bSmrg	  if test -n "$whole_archive_flag_spec" &&
8237698f425bSmrg	    test "$compiler_needs_object" = yes &&
8238698f425bSmrg	    test -z "$libobjs"; then
8239698f425bSmrg	    # extract the archives, so we have objects to list.
8240698f425bSmrg	    # TODO: could optimize this to just extract one archive.
8241698f425bSmrg	    whole_archive_flag_spec=
8242698f425bSmrg	  fi
8243698f425bSmrg	  if test -n "$whole_archive_flag_spec"; then
8244698f425bSmrg	    save_libobjs=$libobjs
8245698f425bSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8246698f425bSmrg	    test "X$libobjs" = "X " && libobjs=
8247698f425bSmrg	  else
8248698f425bSmrg	    gentop="$output_objdir/${outputname}x"
82499ef0b394Smrg	    func_append generated " $gentop"
8250266e564dSmrg
8251698f425bSmrg	    func_extract_archives $gentop $convenience
82529ef0b394Smrg	    func_append libobjs " $func_extract_archives_result"
8253698f425bSmrg	    test "X$libobjs" = "X " && libobjs=
8254698f425bSmrg	  fi
8255266e564dSmrg	fi
8256266e564dSmrg
8257698f425bSmrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
8258698f425bSmrg	  eval flag=\"$thread_safe_flag_spec\"
82599ef0b394Smrg	  func_append linker_flags " $flag"
8260266e564dSmrg	fi
8261266e564dSmrg
8262698f425bSmrg	# Make a backup of the uninstalled library when relinking
82639ef0b394Smrg	if test "$opt_mode" = relink; then
8264698f425bSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
8265698f425bSmrg	fi
8266266e564dSmrg
8267698f425bSmrg	# Do each of the archive commands.
8268698f425bSmrg	if test "$module" = yes && test -n "$module_cmds" ; then
8269698f425bSmrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8270698f425bSmrg	    eval test_cmds=\"$module_expsym_cmds\"
8271698f425bSmrg	    cmds=$module_expsym_cmds
8272698f425bSmrg	  else
8273698f425bSmrg	    eval test_cmds=\"$module_cmds\"
8274698f425bSmrg	    cmds=$module_cmds
8275698f425bSmrg	  fi
8276266e564dSmrg	else
8277698f425bSmrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8278698f425bSmrg	    eval test_cmds=\"$archive_expsym_cmds\"
8279698f425bSmrg	    cmds=$archive_expsym_cmds
8280698f425bSmrg	  else
8281698f425bSmrg	    eval test_cmds=\"$archive_cmds\"
8282698f425bSmrg	    cmds=$archive_cmds
8283698f425bSmrg	  fi
8284266e564dSmrg	fi
8285266e564dSmrg
8286698f425bSmrg	if test "X$skipped_export" != "X:" &&
8287698f425bSmrg	   func_len " $test_cmds" &&
8288698f425bSmrg	   len=$func_len_result &&
8289698f425bSmrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
8290698f425bSmrg	  :
8291698f425bSmrg	else
8292698f425bSmrg	  # The command line is too long to link in one step, link piecewise
8293698f425bSmrg	  # or, if using GNU ld and skipped_export is not :, use a linker
8294698f425bSmrg	  # script.
8295266e564dSmrg
8296698f425bSmrg	  # Save the value of $output and $libobjs because we want to
8297698f425bSmrg	  # use them later.  If we have whole_archive_flag_spec, we
8298698f425bSmrg	  # want to use save_libobjs as it was before
8299698f425bSmrg	  # whole_archive_flag_spec was expanded, because we can't
8300698f425bSmrg	  # assume the linker understands whole_archive_flag_spec.
8301698f425bSmrg	  # This may have to be revisited, in case too many
8302698f425bSmrg	  # convenience libraries get linked in and end up exceeding
8303698f425bSmrg	  # the spec.
8304698f425bSmrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
8305698f425bSmrg	    save_libobjs=$libobjs
8306698f425bSmrg	  fi
8307698f425bSmrg	  save_output=$output
83089ef0b394Smrg	  func_basename "$output"
83099ef0b394Smrg	  output_la=$func_basename_result
8310266e564dSmrg
8311698f425bSmrg	  # Clear the reloadable object creation command queue and
8312698f425bSmrg	  # initialize k to one.
8313698f425bSmrg	  test_cmds=
8314698f425bSmrg	  concat_cmds=
8315698f425bSmrg	  objlist=
8316698f425bSmrg	  last_robj=
8317698f425bSmrg	  k=1
8318698f425bSmrg
8319698f425bSmrg	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
8320698f425bSmrg	    output=${output_objdir}/${output_la}.lnkscript
8321698f425bSmrg	    func_verbose "creating GNU ld script: $output"
83229ef0b394Smrg	    echo 'INPUT (' > $output
8323698f425bSmrg	    for obj in $save_libobjs
8324266e564dSmrg	    do
83259ef0b394Smrg	      func_to_tool_file "$obj"
83269ef0b394Smrg	      $ECHO "$func_to_tool_file_result" >> $output
8327698f425bSmrg	    done
83289ef0b394Smrg	    echo ')' >> $output
83299ef0b394Smrg	    func_append delfiles " $output"
83309ef0b394Smrg	    func_to_tool_file "$output"
83319ef0b394Smrg	    output=$func_to_tool_file_result
8332698f425bSmrg	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
8333698f425bSmrg	    output=${output_objdir}/${output_la}.lnk
8334698f425bSmrg	    func_verbose "creating linker input file list: $output"
8335698f425bSmrg	    : > $output
8336698f425bSmrg	    set x $save_libobjs
8337698f425bSmrg	    shift
8338698f425bSmrg	    firstobj=
8339698f425bSmrg	    if test "$compiler_needs_object" = yes; then
8340698f425bSmrg	      firstobj="$1 "
8341698f425bSmrg	      shift
8342698f425bSmrg	    fi
8343698f425bSmrg	    for obj
8344698f425bSmrg	    do
83459ef0b394Smrg	      func_to_tool_file "$obj"
83469ef0b394Smrg	      $ECHO "$func_to_tool_file_result" >> $output
8347698f425bSmrg	    done
83489ef0b394Smrg	    func_append delfiles " $output"
83499ef0b394Smrg	    func_to_tool_file "$output"
83509ef0b394Smrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
8351698f425bSmrg	  else
8352698f425bSmrg	    if test -n "$save_libobjs"; then
8353698f425bSmrg	      func_verbose "creating reloadable object files..."
8354698f425bSmrg	      output=$output_objdir/$output_la-${k}.$objext
8355698f425bSmrg	      eval test_cmds=\"$reload_cmds\"
8356698f425bSmrg	      func_len " $test_cmds"
8357698f425bSmrg	      len0=$func_len_result
8358698f425bSmrg	      len=$len0
8359698f425bSmrg
8360698f425bSmrg	      # Loop over the list of objects to be linked.
8361698f425bSmrg	      for obj in $save_libobjs
8362698f425bSmrg	      do
8363698f425bSmrg		func_len " $obj"
8364698f425bSmrg		func_arith $len + $func_len_result
8365698f425bSmrg		len=$func_arith_result
8366698f425bSmrg		if test "X$objlist" = X ||
8367698f425bSmrg		   test "$len" -lt "$max_cmd_len"; then
8368698f425bSmrg		  func_append objlist " $obj"
8369698f425bSmrg		else
8370698f425bSmrg		  # The command $test_cmds is almost too long, add a
8371698f425bSmrg		  # command to the queue.
8372698f425bSmrg		  if test "$k" -eq 1 ; then
8373698f425bSmrg		    # The first file doesn't have a previous command to add.
83749ef0b394Smrg		    reload_objs=$objlist
83759ef0b394Smrg		    eval concat_cmds=\"$reload_cmds\"
8376698f425bSmrg		  else
8377698f425bSmrg		    # All subsequent reloadable object files will link in
8378698f425bSmrg		    # the last one created.
83799ef0b394Smrg		    reload_objs="$objlist $last_robj"
83809ef0b394Smrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
8381698f425bSmrg		  fi
8382698f425bSmrg		  last_robj=$output_objdir/$output_la-${k}.$objext
8383698f425bSmrg		  func_arith $k + 1
8384698f425bSmrg		  k=$func_arith_result
8385698f425bSmrg		  output=$output_objdir/$output_la-${k}.$objext
83869ef0b394Smrg		  objlist=" $obj"
8387698f425bSmrg		  func_len " $last_robj"
8388698f425bSmrg		  func_arith $len0 + $func_len_result
8389698f425bSmrg		  len=$func_arith_result
8390698f425bSmrg		fi
8391698f425bSmrg	      done
8392698f425bSmrg	      # Handle the remaining objects by creating one last
8393698f425bSmrg	      # reloadable object file.  All subsequent reloadable object
8394698f425bSmrg	      # files will link in the last one created.
8395698f425bSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
83969ef0b394Smrg	      reload_objs="$objlist $last_robj"
83979ef0b394Smrg	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
8398698f425bSmrg	      if test -n "$last_robj"; then
8399698f425bSmrg	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
8400698f425bSmrg	      fi
84019ef0b394Smrg	      func_append delfiles " $output"
8402266e564dSmrg
8403698f425bSmrg	    else
8404698f425bSmrg	      output=
8405698f425bSmrg	    fi
8406266e564dSmrg
8407698f425bSmrg	    if ${skipped_export-false}; then
8408698f425bSmrg	      func_verbose "generating symbol list for \`$libname.la'"
8409698f425bSmrg	      export_symbols="$output_objdir/$libname.exp"
8410698f425bSmrg	      $opt_dry_run || $RM $export_symbols
8411698f425bSmrg	      libobjs=$output
8412698f425bSmrg	      # Append the command to create the export file.
8413698f425bSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8414698f425bSmrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
8415698f425bSmrg	      if test -n "$last_robj"; then
8416698f425bSmrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
8417698f425bSmrg	      fi
8418266e564dSmrg	    fi
8419266e564dSmrg
8420698f425bSmrg	    test -n "$save_libobjs" &&
8421698f425bSmrg	      func_verbose "creating a temporary reloadable object file: $output"
8422266e564dSmrg
8423698f425bSmrg	    # Loop through the commands generated above and execute them.
8424698f425bSmrg	    save_ifs="$IFS"; IFS='~'
8425698f425bSmrg	    for cmd in $concat_cmds; do
8426698f425bSmrg	      IFS="$save_ifs"
8427698f425bSmrg	      $opt_silent || {
8428698f425bSmrg		  func_quote_for_expand "$cmd"
8429698f425bSmrg		  eval "func_echo $func_quote_for_expand_result"
8430698f425bSmrg	      }
8431698f425bSmrg	      $opt_dry_run || eval "$cmd" || {
8432698f425bSmrg		lt_exit=$?
8433698f425bSmrg
8434698f425bSmrg		# Restore the uninstalled library and exit
84359ef0b394Smrg		if test "$opt_mode" = relink; then
8436698f425bSmrg		  ( cd "$output_objdir" && \
8437698f425bSmrg		    $RM "${realname}T" && \
8438698f425bSmrg		    $MV "${realname}U" "$realname" )
8439698f425bSmrg		fi
8440266e564dSmrg
8441698f425bSmrg		exit $lt_exit
8442698f425bSmrg	      }
8443698f425bSmrg	    done
8444698f425bSmrg	    IFS="$save_ifs"
8445266e564dSmrg
8446698f425bSmrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
8447698f425bSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8448698f425bSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8449266e564dSmrg	    fi
8450266e564dSmrg	  fi
8451266e564dSmrg
8452698f425bSmrg          if ${skipped_export-false}; then
8453698f425bSmrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
8454698f425bSmrg	      tmp_export_symbols="$export_symbols"
8455698f425bSmrg	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
84569ef0b394Smrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8457698f425bSmrg	    fi
8458266e564dSmrg
8459698f425bSmrg	    if test -n "$orig_export_symbols"; then
8460698f425bSmrg	      # The given exports_symbols file has to be filtered, so filter it.
8461698f425bSmrg	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8462698f425bSmrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
8463698f425bSmrg	      # 's' commands which not all seds can handle. GNU sed should be fine
8464698f425bSmrg	      # though. Also, the filter scales superlinearly with the number of
8465698f425bSmrg	      # global variables. join(1) would be nice here, but unfortunately
8466698f425bSmrg	      # isn't a blessed tool.
8467698f425bSmrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
84689ef0b394Smrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8469698f425bSmrg	      export_symbols=$output_objdir/$libname.def
8470698f425bSmrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8471698f425bSmrg	    fi
8472698f425bSmrg	  fi
8473266e564dSmrg
8474698f425bSmrg	  libobjs=$output
8475698f425bSmrg	  # Restore the value of output.
8476698f425bSmrg	  output=$save_output
8477266e564dSmrg
8478698f425bSmrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
8479698f425bSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8480698f425bSmrg	    test "X$libobjs" = "X " && libobjs=
8481698f425bSmrg	  fi
8482698f425bSmrg	  # Expand the library linking commands again to reset the
8483698f425bSmrg	  # value of $libobjs for piecewise linking.
8484266e564dSmrg
8485698f425bSmrg	  # Do each of the archive commands.
8486698f425bSmrg	  if test "$module" = yes && test -n "$module_cmds" ; then
8487698f425bSmrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8488698f425bSmrg	      cmds=$module_expsym_cmds
8489698f425bSmrg	    else
8490698f425bSmrg	      cmds=$module_cmds
8491266e564dSmrg	    fi
8492266e564dSmrg	  else
8493698f425bSmrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8494698f425bSmrg	      cmds=$archive_expsym_cmds
8495698f425bSmrg	    else
8496698f425bSmrg	      cmds=$archive_cmds
8497698f425bSmrg	    fi
8498266e564dSmrg	  fi
8499698f425bSmrg	fi
8500266e564dSmrg
8501698f425bSmrg	if test -n "$delfiles"; then
8502698f425bSmrg	  # Append the command to remove temporary files to $cmds.
8503698f425bSmrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
8504698f425bSmrg	fi
8505266e564dSmrg
8506698f425bSmrg	# Add any objects from preloaded convenience libraries
8507698f425bSmrg	if test -n "$dlprefiles"; then
8508698f425bSmrg	  gentop="$output_objdir/${outputname}x"
85099ef0b394Smrg	  func_append generated " $gentop"
8510266e564dSmrg
8511698f425bSmrg	  func_extract_archives $gentop $dlprefiles
85129ef0b394Smrg	  func_append libobjs " $func_extract_archives_result"
8513698f425bSmrg	  test "X$libobjs" = "X " && libobjs=
8514698f425bSmrg	fi
8515266e564dSmrg
8516698f425bSmrg	save_ifs="$IFS"; IFS='~'
8517698f425bSmrg	for cmd in $cmds; do
8518698f425bSmrg	  IFS="$save_ifs"
8519698f425bSmrg	  eval cmd=\"$cmd\"
8520698f425bSmrg	  $opt_silent || {
8521698f425bSmrg	    func_quote_for_expand "$cmd"
8522698f425bSmrg	    eval "func_echo $func_quote_for_expand_result"
8523698f425bSmrg	  }
8524698f425bSmrg	  $opt_dry_run || eval "$cmd" || {
8525698f425bSmrg	    lt_exit=$?
8526266e564dSmrg
8527698f425bSmrg	    # Restore the uninstalled library and exit
85289ef0b394Smrg	    if test "$opt_mode" = relink; then
8529698f425bSmrg	      ( cd "$output_objdir" && \
8530698f425bSmrg	        $RM "${realname}T" && \
8531698f425bSmrg		$MV "${realname}U" "$realname" )
8532698f425bSmrg	    fi
8533266e564dSmrg
8534698f425bSmrg	    exit $lt_exit
8535698f425bSmrg	  }
8536698f425bSmrg	done
8537698f425bSmrg	IFS="$save_ifs"
8538266e564dSmrg
8539698f425bSmrg	# Restore the uninstalled library and exit
85409ef0b394Smrg	if test "$opt_mode" = relink; then
8541698f425bSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
8542266e564dSmrg
8543698f425bSmrg	  if test -n "$convenience"; then
8544698f425bSmrg	    if test -z "$whole_archive_flag_spec"; then
8545698f425bSmrg	      func_show_eval '${RM}r "$gentop"'
8546698f425bSmrg	    fi
8547698f425bSmrg	  fi
8548266e564dSmrg
8549698f425bSmrg	  exit $EXIT_SUCCESS
8550698f425bSmrg	fi
8551698f425bSmrg
8552698f425bSmrg	# Create links to the real library.
8553698f425bSmrg	for linkname in $linknames; do
8554698f425bSmrg	  if test "$realname" != "$linkname"; then
8555698f425bSmrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
8556266e564dSmrg	  fi
8557266e564dSmrg	done
8558266e564dSmrg
8559698f425bSmrg	# If -module or -export-dynamic was specified, set the dlname.
8560698f425bSmrg	if test "$module" = yes || test "$export_dynamic" = yes; then
8561698f425bSmrg	  # On all known operating systems, these are identical.
8562698f425bSmrg	  dlname="$soname"
8563698f425bSmrg	fi
8564698f425bSmrg      fi
8565266e564dSmrg      ;;
8566266e564dSmrg
8567698f425bSmrg    obj)
8568698f425bSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
8569698f425bSmrg	func_warning "\`-dlopen' is ignored for objects"
8570698f425bSmrg      fi
8571266e564dSmrg
8572698f425bSmrg      case " $deplibs" in
8573698f425bSmrg      *\ -l* | *\ -L*)
8574698f425bSmrg	func_warning "\`-l' and \`-L' are ignored for objects" ;;
8575266e564dSmrg      esac
8576266e564dSmrg
8577698f425bSmrg      test -n "$rpath" && \
8578698f425bSmrg	func_warning "\`-rpath' is ignored for objects"
8579698f425bSmrg
8580698f425bSmrg      test -n "$xrpath" && \
8581698f425bSmrg	func_warning "\`-R' is ignored for objects"
8582266e564dSmrg
8583698f425bSmrg      test -n "$vinfo" && \
8584698f425bSmrg	func_warning "\`-version-info' is ignored for objects"
8585266e564dSmrg
8586698f425bSmrg      test -n "$release" && \
8587698f425bSmrg	func_warning "\`-release' is ignored for objects"
8588698f425bSmrg
8589698f425bSmrg      case $output in
8590698f425bSmrg      *.lo)
8591698f425bSmrg	test -n "$objs$old_deplibs" && \
8592698f425bSmrg	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
8593698f425bSmrg
8594698f425bSmrg	libobj=$output
8595698f425bSmrg	func_lo2o "$libobj"
8596698f425bSmrg	obj=$func_lo2o_result
8597266e564dSmrg	;;
8598266e564dSmrg      *)
8599698f425bSmrg	libobj=
8600698f425bSmrg	obj="$output"
8601266e564dSmrg	;;
8602266e564dSmrg      esac
8603266e564dSmrg
8604698f425bSmrg      # Delete the old objects.
8605698f425bSmrg      $opt_dry_run || $RM $obj $libobj
8606266e564dSmrg
8607698f425bSmrg      # Objects from convenience libraries.  This assumes
8608698f425bSmrg      # single-version convenience libraries.  Whenever we create
8609698f425bSmrg      # different ones for PIC/non-PIC, this we'll have to duplicate
8610698f425bSmrg      # the extraction.
8611698f425bSmrg      reload_conv_objs=
8612698f425bSmrg      gentop=
8613698f425bSmrg      # reload_cmds runs $LD directly, so let us get rid of
8614698f425bSmrg      # -Wl from whole_archive_flag_spec and hope we can get by with
8615698f425bSmrg      # turning comma into space..
8616698f425bSmrg      wl=
8617266e564dSmrg
8618698f425bSmrg      if test -n "$convenience"; then
8619698f425bSmrg	if test -n "$whole_archive_flag_spec"; then
8620698f425bSmrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
86219ef0b394Smrg	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
8622698f425bSmrg	else
8623698f425bSmrg	  gentop="$output_objdir/${obj}x"
86249ef0b394Smrg	  func_append generated " $gentop"
8625266e564dSmrg
8626698f425bSmrg	  func_extract_archives $gentop $convenience
8627698f425bSmrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
8628698f425bSmrg	fi
8629266e564dSmrg      fi
8630266e564dSmrg
86319ef0b394Smrg      # If we're not building shared, we need to use non_pic_objs
86329ef0b394Smrg      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
86339ef0b394Smrg
8634698f425bSmrg      # Create the old-style object.
86359ef0b394Smrg      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
8636266e564dSmrg
8637698f425bSmrg      output="$obj"
8638698f425bSmrg      func_execute_cmds "$reload_cmds" 'exit $?'
8639266e564dSmrg
8640698f425bSmrg      # Exit if we aren't doing a library object file.
8641698f425bSmrg      if test -z "$libobj"; then
8642698f425bSmrg	if test -n "$gentop"; then
8643698f425bSmrg	  func_show_eval '${RM}r "$gentop"'
8644698f425bSmrg	fi
8645698f425bSmrg
8646698f425bSmrg	exit $EXIT_SUCCESS
8647266e564dSmrg      fi
8648698f425bSmrg
8649698f425bSmrg      if test "$build_libtool_libs" != yes; then
8650698f425bSmrg	if test -n "$gentop"; then
8651698f425bSmrg	  func_show_eval '${RM}r "$gentop"'
8652698f425bSmrg	fi
8653698f425bSmrg
8654698f425bSmrg	# Create an invalid libtool object if no PIC, so that we don't
8655698f425bSmrg	# accidentally link it into a program.
8656698f425bSmrg	# $show "echo timestamp > $libobj"
8657698f425bSmrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
8658698f425bSmrg	exit $EXIT_SUCCESS
8659698f425bSmrg      fi
8660698f425bSmrg
8661698f425bSmrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
8662698f425bSmrg	# Only do commands if we really have different PIC objects.
8663698f425bSmrg	reload_objs="$libobjs $reload_conv_objs"
8664698f425bSmrg	output="$libobj"
8665698f425bSmrg	func_execute_cmds "$reload_cmds" 'exit $?'
8666698f425bSmrg      fi
8667698f425bSmrg
8668698f425bSmrg      if test -n "$gentop"; then
8669698f425bSmrg	func_show_eval '${RM}r "$gentop"'
8670698f425bSmrg      fi
8671698f425bSmrg
8672698f425bSmrg      exit $EXIT_SUCCESS
8673266e564dSmrg      ;;
8674266e564dSmrg
8675698f425bSmrg    prog)
8676698f425bSmrg      case $host in
8677698f425bSmrg	*cygwin*) func_stripname '' '.exe' "$output"
8678698f425bSmrg	          output=$func_stripname_result.exe;;
8679698f425bSmrg      esac
8680698f425bSmrg      test -n "$vinfo" && \
8681698f425bSmrg	func_warning "\`-version-info' is ignored for programs"
8682266e564dSmrg
8683698f425bSmrg      test -n "$release" && \
8684698f425bSmrg	func_warning "\`-release' is ignored for programs"
8685266e564dSmrg
8686698f425bSmrg      test "$preload" = yes \
8687698f425bSmrg        && test "$dlopen_support" = unknown \
8688698f425bSmrg	&& test "$dlopen_self" = unknown \
8689698f425bSmrg	&& test "$dlopen_self_static" = unknown && \
8690698f425bSmrg	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
8691698f425bSmrg
8692698f425bSmrg      case $host in
8693698f425bSmrg      *-*-rhapsody* | *-*-darwin1.[012])
8694698f425bSmrg	# On Rhapsody replace the C library is the System framework
86959ef0b394Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
86969ef0b394Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
8697266e564dSmrg	;;
8698698f425bSmrg      esac
8699266e564dSmrg
8700698f425bSmrg      case $host in
8701698f425bSmrg      *-*-darwin*)
8702698f425bSmrg	# Don't allow lazy linking, it breaks C++ global constructors
8703698f425bSmrg	# But is supposedly fixed on 10.4 or later (yay!).
8704698f425bSmrg	if test "$tagname" = CXX ; then
8705698f425bSmrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
8706698f425bSmrg	    10.[0123])
87079ef0b394Smrg	      func_append compile_command " ${wl}-bind_at_load"
87089ef0b394Smrg	      func_append finalize_command " ${wl}-bind_at_load"
8709698f425bSmrg	    ;;
8710698f425bSmrg	  esac
8711266e564dSmrg	fi
8712698f425bSmrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
87139ef0b394Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
87149ef0b394Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8715698f425bSmrg	;;
8716698f425bSmrg      esac
8717266e564dSmrg
8718266e564dSmrg
8719698f425bSmrg      # move library search paths that coincide with paths to not yet
8720698f425bSmrg      # installed libraries to the beginning of the library search list
8721698f425bSmrg      new_libs=
8722698f425bSmrg      for path in $notinst_path; do
8723698f425bSmrg	case " $new_libs " in
8724698f425bSmrg	*" -L$path/$objdir "*) ;;
8725698f425bSmrg	*)
8726698f425bSmrg	  case " $compile_deplibs " in
8727698f425bSmrg	  *" -L$path/$objdir "*)
87289ef0b394Smrg	    func_append new_libs " -L$path/$objdir" ;;
8729266e564dSmrg	  esac
8730698f425bSmrg	  ;;
8731698f425bSmrg	esac
8732698f425bSmrg      done
8733698f425bSmrg      for deplib in $compile_deplibs; do
8734698f425bSmrg	case $deplib in
8735698f425bSmrg	-L*)
8736698f425bSmrg	  case " $new_libs " in
8737698f425bSmrg	  *" $deplib "*) ;;
87389ef0b394Smrg	  *) func_append new_libs " $deplib" ;;
8739266e564dSmrg	  esac
8740698f425bSmrg	  ;;
87419ef0b394Smrg	*) func_append new_libs " $deplib" ;;
8742698f425bSmrg	esac
8743698f425bSmrg      done
8744698f425bSmrg      compile_deplibs="$new_libs"
8745266e564dSmrg
8746266e564dSmrg
87479ef0b394Smrg      func_append compile_command " $compile_deplibs"
87489ef0b394Smrg      func_append finalize_command " $finalize_deplibs"
8749266e564dSmrg
8750698f425bSmrg      if test -n "$rpath$xrpath"; then
8751698f425bSmrg	# If the user specified any rpath flags, then add them.
8752698f425bSmrg	for libdir in $rpath $xrpath; do
8753698f425bSmrg	  # This is the magic to use -rpath.
8754698f425bSmrg	  case "$finalize_rpath " in
8755698f425bSmrg	  *" $libdir "*) ;;
87569ef0b394Smrg	  *) func_append finalize_rpath " $libdir" ;;
8757698f425bSmrg	  esac
8758698f425bSmrg	done
8759698f425bSmrg      fi
8760266e564dSmrg
8761698f425bSmrg      # Now hardcode the library paths
8762698f425bSmrg      rpath=
8763698f425bSmrg      hardcode_libdirs=
8764698f425bSmrg      for libdir in $compile_rpath $finalize_rpath; do
8765698f425bSmrg	if test -n "$hardcode_libdir_flag_spec"; then
8766698f425bSmrg	  if test -n "$hardcode_libdir_separator"; then
8767698f425bSmrg	    if test -z "$hardcode_libdirs"; then
8768698f425bSmrg	      hardcode_libdirs="$libdir"
8769698f425bSmrg	    else
8770698f425bSmrg	      # Just accumulate the unique libdirs.
8771698f425bSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8772698f425bSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8773698f425bSmrg		;;
8774698f425bSmrg	      *)
87759ef0b394Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8776698f425bSmrg		;;
8777698f425bSmrg	      esac
8778698f425bSmrg	    fi
8779266e564dSmrg	  else
8780698f425bSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
87819ef0b394Smrg	    func_append rpath " $flag"
8782266e564dSmrg	  fi
8783698f425bSmrg	elif test -n "$runpath_var"; then
8784698f425bSmrg	  case "$perm_rpath " in
8785698f425bSmrg	  *" $libdir "*) ;;
87869ef0b394Smrg	  *) func_append perm_rpath " $libdir" ;;
8787698f425bSmrg	  esac
8788698f425bSmrg	fi
8789698f425bSmrg	case $host in
8790698f425bSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
8791698f425bSmrg	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
8792698f425bSmrg	  case :$dllsearchpath: in
8793698f425bSmrg	  *":$libdir:"*) ;;
8794698f425bSmrg	  ::) dllsearchpath=$libdir;;
87959ef0b394Smrg	  *) func_append dllsearchpath ":$libdir";;
8796698f425bSmrg	  esac
8797698f425bSmrg	  case :$dllsearchpath: in
8798698f425bSmrg	  *":$testbindir:"*) ;;
8799698f425bSmrg	  ::) dllsearchpath=$testbindir;;
88009ef0b394Smrg	  *) func_append dllsearchpath ":$testbindir";;
8801698f425bSmrg	  esac
8802698f425bSmrg	  ;;
8803698f425bSmrg	esac
8804698f425bSmrg      done
8805698f425bSmrg      # Substitute the hardcoded libdirs into the rpath.
8806698f425bSmrg      if test -n "$hardcode_libdir_separator" &&
8807698f425bSmrg	 test -n "$hardcode_libdirs"; then
8808698f425bSmrg	libdir="$hardcode_libdirs"
8809698f425bSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
8810698f425bSmrg      fi
8811698f425bSmrg      compile_rpath="$rpath"
8812266e564dSmrg
8813698f425bSmrg      rpath=
8814698f425bSmrg      hardcode_libdirs=
8815698f425bSmrg      for libdir in $finalize_rpath; do
8816698f425bSmrg	if test -n "$hardcode_libdir_flag_spec"; then
8817698f425bSmrg	  if test -n "$hardcode_libdir_separator"; then
8818698f425bSmrg	    if test -z "$hardcode_libdirs"; then
8819698f425bSmrg	      hardcode_libdirs="$libdir"
8820698f425bSmrg	    else
8821698f425bSmrg	      # Just accumulate the unique libdirs.
8822698f425bSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8823698f425bSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8824698f425bSmrg		;;
8825698f425bSmrg	      *)
88269ef0b394Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8827698f425bSmrg		;;
8828698f425bSmrg	      esac
8829698f425bSmrg	    fi
8830266e564dSmrg	  else
8831698f425bSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
88329ef0b394Smrg	    func_append rpath " $flag"
8833266e564dSmrg	  fi
8834698f425bSmrg	elif test -n "$runpath_var"; then
8835698f425bSmrg	  case "$finalize_perm_rpath " in
8836698f425bSmrg	  *" $libdir "*) ;;
88379ef0b394Smrg	  *) func_append finalize_perm_rpath " $libdir" ;;
8838698f425bSmrg	  esac
8839266e564dSmrg	fi
8840698f425bSmrg      done
8841698f425bSmrg      # Substitute the hardcoded libdirs into the rpath.
8842698f425bSmrg      if test -n "$hardcode_libdir_separator" &&
8843698f425bSmrg	 test -n "$hardcode_libdirs"; then
8844698f425bSmrg	libdir="$hardcode_libdirs"
8845698f425bSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
8846698f425bSmrg      fi
8847698f425bSmrg      finalize_rpath="$rpath"
8848266e564dSmrg
8849698f425bSmrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
8850698f425bSmrg	# Transform all the library objects into standard objects.
88519ef0b394Smrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
88529ef0b394Smrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8853698f425bSmrg      fi
8854266e564dSmrg
8855698f425bSmrg      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
8856266e564dSmrg
8857698f425bSmrg      # template prelinking step
8858698f425bSmrg      if test -n "$prelink_cmds"; then
8859698f425bSmrg	func_execute_cmds "$prelink_cmds" 'exit $?'
8860698f425bSmrg      fi
8861266e564dSmrg
8862698f425bSmrg      wrappers_required=yes
8863698f425bSmrg      case $host in
88649ef0b394Smrg      *cegcc* | *mingw32ce*)
88659ef0b394Smrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
88669ef0b394Smrg        wrappers_required=no
88679ef0b394Smrg        ;;
8868698f425bSmrg      *cygwin* | *mingw* )
8869698f425bSmrg        if test "$build_libtool_libs" != yes; then
8870698f425bSmrg          wrappers_required=no
8871698f425bSmrg        fi
8872698f425bSmrg        ;;
8873698f425bSmrg      *)
8874698f425bSmrg        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
8875698f425bSmrg          wrappers_required=no
8876698f425bSmrg        fi
8877698f425bSmrg        ;;
8878698f425bSmrg      esac
8879698f425bSmrg      if test "$wrappers_required" = no; then
8880698f425bSmrg	# Replace the output file specification.
88819ef0b394Smrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8882698f425bSmrg	link_command="$compile_command$compile_rpath"
8883266e564dSmrg
8884698f425bSmrg	# We have no uninstalled library dependencies, so finalize right now.
8885698f425bSmrg	exit_status=0
8886698f425bSmrg	func_show_eval "$link_command" 'exit_status=$?'
8887266e564dSmrg
88889ef0b394Smrg	if test -n "$postlink_cmds"; then
88899ef0b394Smrg	  func_to_tool_file "$output"
88909ef0b394Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
88919ef0b394Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
88929ef0b394Smrg	fi
88939ef0b394Smrg
8894698f425bSmrg	# Delete the generated files.
8895698f425bSmrg	if test -f "$output_objdir/${outputname}S.${objext}"; then
8896698f425bSmrg	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
8897266e564dSmrg	fi
8898266e564dSmrg
8899698f425bSmrg	exit $exit_status
8900698f425bSmrg      fi
8901266e564dSmrg
8902698f425bSmrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
8903698f425bSmrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
8904698f425bSmrg      fi
8905698f425bSmrg      if test -n "$finalize_shlibpath"; then
8906698f425bSmrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
8907698f425bSmrg      fi
8908266e564dSmrg
8909698f425bSmrg      compile_var=
8910698f425bSmrg      finalize_var=
8911698f425bSmrg      if test -n "$runpath_var"; then
8912698f425bSmrg	if test -n "$perm_rpath"; then
8913698f425bSmrg	  # We should set the runpath_var.
8914698f425bSmrg	  rpath=
8915698f425bSmrg	  for dir in $perm_rpath; do
89169ef0b394Smrg	    func_append rpath "$dir:"
8917698f425bSmrg	  done
8918698f425bSmrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
8919266e564dSmrg	fi
8920698f425bSmrg	if test -n "$finalize_perm_rpath"; then
8921698f425bSmrg	  # We should set the runpath_var.
8922698f425bSmrg	  rpath=
8923698f425bSmrg	  for dir in $finalize_perm_rpath; do
89249ef0b394Smrg	    func_append rpath "$dir:"
8925698f425bSmrg	  done
8926698f425bSmrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
8927266e564dSmrg	fi
8928698f425bSmrg      fi
8929266e564dSmrg
8930698f425bSmrg      if test "$no_install" = yes; then
8931698f425bSmrg	# We don't need to create a wrapper script.
8932698f425bSmrg	link_command="$compile_var$compile_command$compile_rpath"
8933698f425bSmrg	# Replace the output file specification.
89349ef0b394Smrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8935698f425bSmrg	# Delete the old output file.
8936698f425bSmrg	$opt_dry_run || $RM $output
8937698f425bSmrg	# Link the executable and exit
8938698f425bSmrg	func_show_eval "$link_command" 'exit $?'
89399ef0b394Smrg
89409ef0b394Smrg	if test -n "$postlink_cmds"; then
89419ef0b394Smrg	  func_to_tool_file "$output"
89429ef0b394Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
89439ef0b394Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
89449ef0b394Smrg	fi
89459ef0b394Smrg
8946266e564dSmrg	exit $EXIT_SUCCESS
8947698f425bSmrg      fi
8948266e564dSmrg
8949698f425bSmrg      if test "$hardcode_action" = relink; then
8950698f425bSmrg	# Fast installation is not supported
8951698f425bSmrg	link_command="$compile_var$compile_command$compile_rpath"
8952698f425bSmrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
8953698f425bSmrg
8954698f425bSmrg	func_warning "this platform does not like uninstalled shared libraries"
8955698f425bSmrg	func_warning "\`$output' will be relinked during installation"
8956698f425bSmrg      else
8957698f425bSmrg	if test "$fast_install" != no; then
8958698f425bSmrg	  link_command="$finalize_var$compile_command$finalize_rpath"
8959698f425bSmrg	  if test "$fast_install" = yes; then
89609ef0b394Smrg	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
8961698f425bSmrg	  else
8962698f425bSmrg	    # fast_install is set to needless
8963698f425bSmrg	    relink_command=
8964698f425bSmrg	  fi
8965266e564dSmrg	else
8966698f425bSmrg	  link_command="$compile_var$compile_command$compile_rpath"
8967698f425bSmrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
8968266e564dSmrg	fi
8969698f425bSmrg      fi
8970266e564dSmrg
8971698f425bSmrg      # Replace the output file specification.
89729ef0b394Smrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
8973266e564dSmrg
8974698f425bSmrg      # Delete the old output files.
8975698f425bSmrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
8976266e564dSmrg
8977698f425bSmrg      func_show_eval "$link_command" 'exit $?'
8978266e564dSmrg
89799ef0b394Smrg      if test -n "$postlink_cmds"; then
89809ef0b394Smrg	func_to_tool_file "$output_objdir/$outputname"
89819ef0b394Smrg	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'`
89829ef0b394Smrg	func_execute_cmds "$postlink_cmds" 'exit $?'
89839ef0b394Smrg      fi
89849ef0b394Smrg
8985698f425bSmrg      # Now create the wrapper script.
8986698f425bSmrg      func_verbose "creating $output"
8987266e564dSmrg
8988698f425bSmrg      # Quote the relink command for shipping.
8989698f425bSmrg      if test -n "$relink_command"; then
8990698f425bSmrg	# Preserve any variables that may affect compiler behavior
8991698f425bSmrg	for var in $variables_saved_for_relink; do
8992698f425bSmrg	  if eval test -z \"\${$var+set}\"; then
8993698f425bSmrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
8994698f425bSmrg	  elif eval var_value=\$$var; test -z "$var_value"; then
8995698f425bSmrg	    relink_command="$var=; export $var; $relink_command"
8996266e564dSmrg	  else
8997698f425bSmrg	    func_quote_for_eval "$var_value"
8998698f425bSmrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
8999266e564dSmrg	  fi
9000698f425bSmrg	done
9001698f425bSmrg	relink_command="(cd `pwd`; $relink_command)"
90029ef0b394Smrg	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9003698f425bSmrg      fi
9004698f425bSmrg
9005698f425bSmrg      # Only actually do things if not in dry run mode.
9006698f425bSmrg      $opt_dry_run || {
9007698f425bSmrg	# win32 will think the script is a binary if it has
9008698f425bSmrg	# a .exe suffix, so we strip it off here.
9009698f425bSmrg	case $output in
9010698f425bSmrg	  *.exe) func_stripname '' '.exe' "$output"
9011698f425bSmrg	         output=$func_stripname_result ;;
9012698f425bSmrg	esac
9013698f425bSmrg	# test for cygwin because mv fails w/o .exe extensions
9014698f425bSmrg	case $host in
9015698f425bSmrg	  *cygwin*)
9016698f425bSmrg	    exeext=.exe
9017698f425bSmrg	    func_stripname '' '.exe' "$outputname"
9018698f425bSmrg	    outputname=$func_stripname_result ;;
9019698f425bSmrg	  *) exeext= ;;
9020266e564dSmrg	esac
9021698f425bSmrg	case $host in
9022698f425bSmrg	  *cygwin* | *mingw* )
9023698f425bSmrg	    func_dirname_and_basename "$output" "" "."
9024698f425bSmrg	    output_name=$func_basename_result
9025698f425bSmrg	    output_path=$func_dirname_result
9026698f425bSmrg	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
9027698f425bSmrg	    cwrapper="$output_path/$output_name.exe"
9028698f425bSmrg	    $RM $cwrappersource $cwrapper
9029698f425bSmrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
9030698f425bSmrg
9031698f425bSmrg	    func_emit_cwrapperexe_src > $cwrappersource
9032698f425bSmrg
9033698f425bSmrg	    # The wrapper executable is built using the $host compiler,
9034698f425bSmrg	    # because it contains $host paths and files. If cross-
9035698f425bSmrg	    # compiling, it, like the target executable, must be
9036698f425bSmrg	    # executed on the $host or under an emulation environment.
9037698f425bSmrg	    $opt_dry_run || {
9038698f425bSmrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
9039698f425bSmrg	      $STRIP $cwrapper
9040698f425bSmrg	    }
9041266e564dSmrg
9042698f425bSmrg	    # Now, create the wrapper script for func_source use:
9043698f425bSmrg	    func_ltwrapper_scriptname $cwrapper
9044698f425bSmrg	    $RM $func_ltwrapper_scriptname_result
9045698f425bSmrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
9046698f425bSmrg	    $opt_dry_run || {
9047698f425bSmrg	      # note: this script will not be executed, so do not chmod.
9048698f425bSmrg	      if test "x$build" = "x$host" ; then
9049698f425bSmrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
9050698f425bSmrg	      else
9051698f425bSmrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
9052698f425bSmrg	      fi
9053698f425bSmrg	    }
9054698f425bSmrg	  ;;
9055698f425bSmrg	  * )
9056698f425bSmrg	    $RM $output
9057698f425bSmrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
9058266e564dSmrg
9059698f425bSmrg	    func_emit_wrapper no > $output
9060698f425bSmrg	    chmod +x $output
9061698f425bSmrg	  ;;
9062698f425bSmrg	esac
9063698f425bSmrg      }
9064698f425bSmrg      exit $EXIT_SUCCESS
9065698f425bSmrg      ;;
9066698f425bSmrg    esac
9067266e564dSmrg
9068698f425bSmrg    # See if we need to build an old-fashioned archive.
9069698f425bSmrg    for oldlib in $oldlibs; do
9070266e564dSmrg
9071698f425bSmrg      if test "$build_libtool_libs" = convenience; then
9072698f425bSmrg	oldobjs="$libobjs_save $symfileobj"
9073698f425bSmrg	addlibs="$convenience"
9074698f425bSmrg	build_libtool_libs=no
9075698f425bSmrg      else
9076698f425bSmrg	if test "$build_libtool_libs" = module; then
9077698f425bSmrg	  oldobjs="$libobjs_save"
9078698f425bSmrg	  build_libtool_libs=no
9079698f425bSmrg	else
9080698f425bSmrg	  oldobjs="$old_deplibs $non_pic_objects"
9081698f425bSmrg	  if test "$preload" = yes && test -f "$symfileobj"; then
90829ef0b394Smrg	    func_append oldobjs " $symfileobj"
9083698f425bSmrg	  fi
9084698f425bSmrg	fi
9085698f425bSmrg	addlibs="$old_convenience"
9086266e564dSmrg      fi
9087266e564dSmrg
9088698f425bSmrg      if test -n "$addlibs"; then
9089698f425bSmrg	gentop="$output_objdir/${outputname}x"
90909ef0b394Smrg	func_append generated " $gentop"
9091266e564dSmrg
9092698f425bSmrg	func_extract_archives $gentop $addlibs
90939ef0b394Smrg	func_append oldobjs " $func_extract_archives_result"
9094698f425bSmrg      fi
9095266e564dSmrg
9096698f425bSmrg      # Do each command in the archive commands.
9097698f425bSmrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
9098698f425bSmrg	cmds=$old_archive_from_new_cmds
9099698f425bSmrg      else
9100266e564dSmrg
9101698f425bSmrg	# Add any objects from preloaded convenience libraries
9102698f425bSmrg	if test -n "$dlprefiles"; then
9103698f425bSmrg	  gentop="$output_objdir/${outputname}x"
91049ef0b394Smrg	  func_append generated " $gentop"
9105266e564dSmrg
9106698f425bSmrg	  func_extract_archives $gentop $dlprefiles
91079ef0b394Smrg	  func_append oldobjs " $func_extract_archives_result"
9108698f425bSmrg	fi
9109266e564dSmrg
9110698f425bSmrg	# POSIX demands no paths to be encoded in archives.  We have
9111698f425bSmrg	# to avoid creating archives with duplicate basenames if we
9112698f425bSmrg	# might have to extract them afterwards, e.g., when creating a
9113698f425bSmrg	# static archive out of a convenience library, or when linking
9114698f425bSmrg	# the entirety of a libtool archive into another (currently
9115698f425bSmrg	# not supported by libtool).
9116698f425bSmrg	if (for obj in $oldobjs
9117698f425bSmrg	    do
9118698f425bSmrg	      func_basename "$obj"
9119698f425bSmrg	      $ECHO "$func_basename_result"
9120698f425bSmrg	    done | sort | sort -uc >/dev/null 2>&1); then
9121698f425bSmrg	  :
9122698f425bSmrg	else
91239ef0b394Smrg	  echo "copying selected object files to avoid basename conflicts..."
9124698f425bSmrg	  gentop="$output_objdir/${outputname}x"
91259ef0b394Smrg	  func_append generated " $gentop"
9126698f425bSmrg	  func_mkdir_p "$gentop"
9127698f425bSmrg	  save_oldobjs=$oldobjs
9128698f425bSmrg	  oldobjs=
9129698f425bSmrg	  counter=1
9130698f425bSmrg	  for obj in $save_oldobjs
9131698f425bSmrg	  do
9132698f425bSmrg	    func_basename "$obj"
9133698f425bSmrg	    objbase="$func_basename_result"
9134698f425bSmrg	    case " $oldobjs " in
9135698f425bSmrg	    " ") oldobjs=$obj ;;
9136698f425bSmrg	    *[\ /]"$objbase "*)
9137698f425bSmrg	      while :; do
9138698f425bSmrg		# Make sure we don't pick an alternate name that also
9139698f425bSmrg		# overlaps.
9140698f425bSmrg		newobj=lt$counter-$objbase
9141698f425bSmrg		func_arith $counter + 1
9142698f425bSmrg		counter=$func_arith_result
9143698f425bSmrg		case " $oldobjs " in
9144698f425bSmrg		*[\ /]"$newobj "*) ;;
9145698f425bSmrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
9146698f425bSmrg		esac
9147698f425bSmrg	      done
9148698f425bSmrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
91499ef0b394Smrg	      func_append oldobjs " $gentop/$newobj"
9150698f425bSmrg	      ;;
91519ef0b394Smrg	    *) func_append oldobjs " $obj" ;;
9152698f425bSmrg	    esac
9153266e564dSmrg	  done
9154266e564dSmrg	fi
9155698f425bSmrg	eval cmds=\"$old_archive_cmds\"
9156266e564dSmrg
9157698f425bSmrg	func_len " $cmds"
9158698f425bSmrg	len=$func_len_result
9159698f425bSmrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
9160698f425bSmrg	  cmds=$old_archive_cmds
91619ef0b394Smrg	elif test -n "$archiver_list_spec"; then
91629ef0b394Smrg	  func_verbose "using command file archive linking..."
91639ef0b394Smrg	  for obj in $oldobjs
91649ef0b394Smrg	  do
91659ef0b394Smrg	    func_to_tool_file "$obj"
91669ef0b394Smrg	    $ECHO "$func_to_tool_file_result"
91679ef0b394Smrg	  done > $output_objdir/$libname.libcmd
91689ef0b394Smrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
91699ef0b394Smrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
91709ef0b394Smrg	  cmds=$old_archive_cmds
9171698f425bSmrg	else
9172698f425bSmrg	  # the command line is too long to link in one step, link in parts
9173698f425bSmrg	  func_verbose "using piecewise archive linking..."
9174698f425bSmrg	  save_RANLIB=$RANLIB
9175698f425bSmrg	  RANLIB=:
9176698f425bSmrg	  objlist=
9177698f425bSmrg	  concat_cmds=
9178698f425bSmrg	  save_oldobjs=$oldobjs
9179698f425bSmrg	  oldobjs=
9180698f425bSmrg	  # Is there a better way of finding the last object in the list?
9181698f425bSmrg	  for obj in $save_oldobjs
9182698f425bSmrg	  do
9183698f425bSmrg	    last_oldobj=$obj
9184698f425bSmrg	  done
9185698f425bSmrg	  eval test_cmds=\"$old_archive_cmds\"
9186698f425bSmrg	  func_len " $test_cmds"
9187698f425bSmrg	  len0=$func_len_result
9188698f425bSmrg	  len=$len0
9189698f425bSmrg	  for obj in $save_oldobjs
9190698f425bSmrg	  do
9191698f425bSmrg	    func_len " $obj"
9192698f425bSmrg	    func_arith $len + $func_len_result
9193698f425bSmrg	    len=$func_arith_result
9194698f425bSmrg	    func_append objlist " $obj"
9195698f425bSmrg	    if test "$len" -lt "$max_cmd_len"; then
9196698f425bSmrg	      :
9197698f425bSmrg	    else
9198698f425bSmrg	      # the above command should be used before it gets too long
9199698f425bSmrg	      oldobjs=$objlist
9200698f425bSmrg	      if test "$obj" = "$last_oldobj" ; then
9201698f425bSmrg		RANLIB=$save_RANLIB
9202698f425bSmrg	      fi
9203698f425bSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9204698f425bSmrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
9205698f425bSmrg	      objlist=
9206698f425bSmrg	      len=$len0
9207698f425bSmrg	    fi
9208698f425bSmrg	  done
9209698f425bSmrg	  RANLIB=$save_RANLIB
9210698f425bSmrg	  oldobjs=$objlist
9211698f425bSmrg	  if test "X$oldobjs" = "X" ; then
9212698f425bSmrg	    eval cmds=\"\$concat_cmds\"
9213698f425bSmrg	  else
9214698f425bSmrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
9215698f425bSmrg	  fi
9216698f425bSmrg	fi
9217698f425bSmrg      fi
9218698f425bSmrg      func_execute_cmds "$cmds" 'exit $?'
9219266e564dSmrg    done
9220266e564dSmrg
9221698f425bSmrg    test -n "$generated" && \
9222698f425bSmrg      func_show_eval "${RM}r$generated"
9223266e564dSmrg
9224698f425bSmrg    # Now create the libtool archive.
9225698f425bSmrg    case $output in
9226698f425bSmrg    *.la)
9227698f425bSmrg      old_library=
9228698f425bSmrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
9229698f425bSmrg      func_verbose "creating $output"
9230266e564dSmrg
9231698f425bSmrg      # Preserve any variables that may affect compiler behavior
9232698f425bSmrg      for var in $variables_saved_for_relink; do
9233698f425bSmrg	if eval test -z \"\${$var+set}\"; then
9234698f425bSmrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9235698f425bSmrg	elif eval var_value=\$$var; test -z "$var_value"; then
9236698f425bSmrg	  relink_command="$var=; export $var; $relink_command"
9237266e564dSmrg	else
9238698f425bSmrg	  func_quote_for_eval "$var_value"
9239698f425bSmrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9240266e564dSmrg	fi
9241698f425bSmrg      done
9242698f425bSmrg      # Quote the link command for shipping.
9243698f425bSmrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
92449ef0b394Smrg      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9245698f425bSmrg      if test "$hardcode_automatic" = yes ; then
9246698f425bSmrg	relink_command=
9247698f425bSmrg      fi
9248266e564dSmrg
9249698f425bSmrg      # Only create the output if not a dry run.
9250698f425bSmrg      $opt_dry_run || {
9251698f425bSmrg	for installed in no yes; do
9252698f425bSmrg	  if test "$installed" = yes; then
9253698f425bSmrg	    if test -z "$install_libdir"; then
9254698f425bSmrg	      break
9255698f425bSmrg	    fi
9256698f425bSmrg	    output="$output_objdir/$outputname"i
9257698f425bSmrg	    # Replace all uninstalled libtool libraries with the installed ones
9258698f425bSmrg	    newdependency_libs=
9259698f425bSmrg	    for deplib in $dependency_libs; do
9260698f425bSmrg	      case $deplib in
9261698f425bSmrg	      *.la)
9262698f425bSmrg		func_basename "$deplib"
9263698f425bSmrg		name="$func_basename_result"
9264698f425bSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
9265698f425bSmrg		test -z "$libdir" && \
9266698f425bSmrg		  func_fatal_error "\`$deplib' is not a valid libtool archive"
92679ef0b394Smrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
92689ef0b394Smrg		;;
92699ef0b394Smrg	      -L*)
92709ef0b394Smrg		func_stripname -L '' "$deplib"
92719ef0b394Smrg		func_replace_sysroot "$func_stripname_result"
92729ef0b394Smrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
9273698f425bSmrg		;;
92749ef0b394Smrg	      -R*)
92759ef0b394Smrg		func_stripname -R '' "$deplib"
92769ef0b394Smrg		func_replace_sysroot "$func_stripname_result"
92779ef0b394Smrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
92789ef0b394Smrg		;;
92799ef0b394Smrg	      *) func_append newdependency_libs " $deplib" ;;
9280698f425bSmrg	      esac
9281698f425bSmrg	    done
9282698f425bSmrg	    dependency_libs="$newdependency_libs"
9283698f425bSmrg	    newdlfiles=
9284698f425bSmrg
9285698f425bSmrg	    for lib in $dlfiles; do
9286698f425bSmrg	      case $lib in
9287698f425bSmrg	      *.la)
9288698f425bSmrg	        func_basename "$lib"
9289698f425bSmrg		name="$func_basename_result"
9290698f425bSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9291698f425bSmrg		test -z "$libdir" && \
9292698f425bSmrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
92939ef0b394Smrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
9294698f425bSmrg		;;
92959ef0b394Smrg	      *) func_append newdlfiles " $lib" ;;
9296698f425bSmrg	      esac
9297698f425bSmrg	    done
9298698f425bSmrg	    dlfiles="$newdlfiles"
9299698f425bSmrg	    newdlprefiles=
9300698f425bSmrg	    for lib in $dlprefiles; do
9301698f425bSmrg	      case $lib in
9302698f425bSmrg	      *.la)
9303698f425bSmrg		# Only pass preopened files to the pseudo-archive (for
9304698f425bSmrg		# eventual linking with the app. that links it) if we
9305698f425bSmrg		# didn't already link the preopened objects directly into
9306698f425bSmrg		# the library:
9307698f425bSmrg		func_basename "$lib"
9308698f425bSmrg		name="$func_basename_result"
9309698f425bSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9310698f425bSmrg		test -z "$libdir" && \
9311698f425bSmrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
93129ef0b394Smrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
9313698f425bSmrg		;;
9314698f425bSmrg	      esac
9315698f425bSmrg	    done
9316698f425bSmrg	    dlprefiles="$newdlprefiles"
9317698f425bSmrg	  else
9318698f425bSmrg	    newdlfiles=
9319698f425bSmrg	    for lib in $dlfiles; do
9320698f425bSmrg	      case $lib in
9321698f425bSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9322698f425bSmrg		*) abs=`pwd`"/$lib" ;;
9323698f425bSmrg	      esac
93249ef0b394Smrg	      func_append newdlfiles " $abs"
9325698f425bSmrg	    done
9326698f425bSmrg	    dlfiles="$newdlfiles"
9327698f425bSmrg	    newdlprefiles=
9328698f425bSmrg	    for lib in $dlprefiles; do
9329698f425bSmrg	      case $lib in
9330698f425bSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9331698f425bSmrg		*) abs=`pwd`"/$lib" ;;
9332698f425bSmrg	      esac
93339ef0b394Smrg	      func_append newdlprefiles " $abs"
9334698f425bSmrg	    done
9335698f425bSmrg	    dlprefiles="$newdlprefiles"
9336698f425bSmrg	  fi
9337698f425bSmrg	  $RM $output
9338698f425bSmrg	  # place dlname in correct position for cygwin
93399ef0b394Smrg	  # In fact, it would be nice if we could use this code for all target
93409ef0b394Smrg	  # systems that can't hard-code library paths into their executables
93419ef0b394Smrg	  # and that have no shared library path variable independent of PATH,
93429ef0b394Smrg	  # but it turns out we can't easily determine that from inspecting
93439ef0b394Smrg	  # libtool variables, so we have to hard-code the OSs to which it
93449ef0b394Smrg	  # applies here; at the moment, that means platforms that use the PE
93459ef0b394Smrg	  # object format with DLL files.  See the long comment at the top of
93469ef0b394Smrg	  # tests/bindir.at for full details.
9347698f425bSmrg	  tdlname=$dlname
9348698f425bSmrg	  case $host,$output,$installed,$module,$dlname in
93499ef0b394Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
93509ef0b394Smrg	      # If a -bindir argument was supplied, place the dll there.
93519ef0b394Smrg	      if test "x$bindir" != x ;
93529ef0b394Smrg	      then
93539ef0b394Smrg		func_relative_path "$install_libdir" "$bindir"
93549ef0b394Smrg		tdlname=$func_relative_path_result$dlname
93559ef0b394Smrg	      else
93569ef0b394Smrg		# Otherwise fall back on heuristic.
93579ef0b394Smrg		tdlname=../bin/$dlname
93589ef0b394Smrg	      fi
93599ef0b394Smrg	      ;;
9360698f425bSmrg	  esac
9361698f425bSmrg	  $ECHO > $output "\
9362698f425bSmrg# $outputname - a libtool library file
9363698f425bSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
9364698f425bSmrg#
9365698f425bSmrg# Please DO NOT delete this file!
9366698f425bSmrg# It is necessary for linking the library.
9367266e564dSmrg
9368698f425bSmrg# The name that we can dlopen(3).
9369698f425bSmrgdlname='$tdlname'
9370266e564dSmrg
9371698f425bSmrg# Names of this library.
9372698f425bSmrglibrary_names='$library_names'
9373266e564dSmrg
9374698f425bSmrg# The name of the static archive.
9375698f425bSmrgold_library='$old_library'
9376266e564dSmrg
9377698f425bSmrg# Linker flags that can not go in dependency_libs.
9378698f425bSmrginherited_linker_flags='$new_inherited_linker_flags'
9379266e564dSmrg
9380698f425bSmrg# Libraries that this one depends upon.
9381698f425bSmrgdependency_libs='$dependency_libs'
9382266e564dSmrg
9383698f425bSmrg# Names of additional weak libraries provided by this library
9384698f425bSmrgweak_library_names='$weak_libs'
9385266e564dSmrg
9386698f425bSmrg# Version information for $libname.
9387698f425bSmrgcurrent=$current
9388698f425bSmrgage=$age
9389698f425bSmrgrevision=$revision
9390266e564dSmrg
9391698f425bSmrg# Is this an already installed library?
9392698f425bSmrginstalled=$installed
9393266e564dSmrg
9394698f425bSmrg# Should we warn about portability when linking against -modules?
9395698f425bSmrgshouldnotlink=$module
9396266e564dSmrg
9397698f425bSmrg# Files to dlopen/dlpreopen
9398698f425bSmrgdlopen='$dlfiles'
9399698f425bSmrgdlpreopen='$dlprefiles'
9400266e564dSmrg
9401698f425bSmrg# Directory that this library needs to be installed in:
9402698f425bSmrglibdir='$install_libdir'"
9403698f425bSmrg	  if test "$installed" = no && test "$need_relink" = yes; then
9404698f425bSmrg	    $ECHO >> $output "\
9405698f425bSmrgrelink_command=\"$relink_command\""
9406698f425bSmrg	  fi
9407698f425bSmrg	done
9408698f425bSmrg      }
9409266e564dSmrg
9410698f425bSmrg      # Do a symbolic link so that the libtool archive can be found in
9411698f425bSmrg      # LD_LIBRARY_PATH before the program is installed.
9412698f425bSmrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
9413698f425bSmrg      ;;
9414698f425bSmrg    esac
9415698f425bSmrg    exit $EXIT_SUCCESS
9416698f425bSmrg}
9417266e564dSmrg
94189ef0b394Smrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
9419698f425bSmrg    func_mode_link ${1+"$@"}
9420266e564dSmrg
9421266e564dSmrg
9422698f425bSmrg# func_mode_uninstall arg...
9423698f425bSmrgfunc_mode_uninstall ()
9424698f425bSmrg{
9425698f425bSmrg    $opt_debug
9426698f425bSmrg    RM="$nonopt"
9427266e564dSmrg    files=
9428266e564dSmrg    rmforce=
9429266e564dSmrg    exit_status=0
9430266e564dSmrg
9431266e564dSmrg    # This variable tells wrapper scripts just to set variables rather
9432266e564dSmrg    # than running their programs.
9433266e564dSmrg    libtool_install_magic="$magic"
9434266e564dSmrg
9435266e564dSmrg    for arg
9436266e564dSmrg    do
9437266e564dSmrg      case $arg in
94389ef0b394Smrg      -f) func_append RM " $arg"; rmforce=yes ;;
94399ef0b394Smrg      -*) func_append RM " $arg" ;;
94409ef0b394Smrg      *) func_append files " $arg" ;;
9441266e564dSmrg      esac
9442266e564dSmrg    done
9443266e564dSmrg
9444698f425bSmrg    test -z "$RM" && \
9445698f425bSmrg      func_fatal_help "you must specify an RM program"
9446266e564dSmrg
9447266e564dSmrg    rmdirs=
9448266e564dSmrg
9449266e564dSmrg    for file in $files; do
9450698f425bSmrg      func_dirname "$file" "" "."
9451698f425bSmrg      dir="$func_dirname_result"
9452698f425bSmrg      if test "X$dir" = X.; then
94539ef0b394Smrg	odir="$objdir"
9454266e564dSmrg      else
94559ef0b394Smrg	odir="$dir/$objdir"
9456266e564dSmrg      fi
9457698f425bSmrg      func_basename "$file"
9458698f425bSmrg      name="$func_basename_result"
94599ef0b394Smrg      test "$opt_mode" = uninstall && odir="$dir"
9460266e564dSmrg
94619ef0b394Smrg      # Remember odir for removal later, being careful to avoid duplicates
94629ef0b394Smrg      if test "$opt_mode" = clean; then
9463266e564dSmrg	case " $rmdirs " in
94649ef0b394Smrg	  *" $odir "*) ;;
94659ef0b394Smrg	  *) func_append rmdirs " $odir" ;;
9466266e564dSmrg	esac
9467266e564dSmrg      fi
9468266e564dSmrg
9469266e564dSmrg      # Don't error if the file doesn't exist and rm -f was used.
9470698f425bSmrg      if { test -L "$file"; } >/dev/null 2>&1 ||
9471698f425bSmrg	 { test -h "$file"; } >/dev/null 2>&1 ||
9472698f425bSmrg	 test -f "$file"; then
9473266e564dSmrg	:
9474266e564dSmrg      elif test -d "$file"; then
9475266e564dSmrg	exit_status=1
9476266e564dSmrg	continue
9477266e564dSmrg      elif test "$rmforce" = yes; then
9478266e564dSmrg	continue
9479266e564dSmrg      fi
9480266e564dSmrg
9481266e564dSmrg      rmfiles="$file"
9482266e564dSmrg
9483266e564dSmrg      case $name in
9484266e564dSmrg      *.la)
9485266e564dSmrg	# Possibly a libtool archive, so verify it.
9486698f425bSmrg	if func_lalib_p "$file"; then
9487698f425bSmrg	  func_source $dir/$name
9488266e564dSmrg
9489266e564dSmrg	  # Delete the libtool libraries and symlinks.
9490266e564dSmrg	  for n in $library_names; do
94919ef0b394Smrg	    func_append rmfiles " $odir/$n"
9492266e564dSmrg	  done
94939ef0b394Smrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
9494266e564dSmrg
94959ef0b394Smrg	  case "$opt_mode" in
9496266e564dSmrg	  clean)
94979ef0b394Smrg	    case " $library_names " in
9498266e564dSmrg	    *" $dlname "*) ;;
94999ef0b394Smrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
9500266e564dSmrg	    esac
95019ef0b394Smrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
9502266e564dSmrg	    ;;
9503266e564dSmrg	  uninstall)
9504266e564dSmrg	    if test -n "$library_names"; then
9505266e564dSmrg	      # Do each command in the postuninstall commands.
9506698f425bSmrg	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9507266e564dSmrg	    fi
9508266e564dSmrg
9509266e564dSmrg	    if test -n "$old_library"; then
9510266e564dSmrg	      # Do each command in the old_postuninstall commands.
9511698f425bSmrg	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9512266e564dSmrg	    fi
9513266e564dSmrg	    # FIXME: should reinstall the best remaining shared library.
9514266e564dSmrg	    ;;
9515266e564dSmrg	  esac
9516266e564dSmrg	fi
9517266e564dSmrg	;;
9518266e564dSmrg
9519266e564dSmrg      *.lo)
9520266e564dSmrg	# Possibly a libtool object, so verify it.
9521698f425bSmrg	if func_lalib_p "$file"; then
9522266e564dSmrg
9523266e564dSmrg	  # Read the .lo file
9524698f425bSmrg	  func_source $dir/$name
9525266e564dSmrg
9526266e564dSmrg	  # Add PIC object to the list of files to remove.
9527698f425bSmrg	  if test -n "$pic_object" &&
9528698f425bSmrg	     test "$pic_object" != none; then
95299ef0b394Smrg	    func_append rmfiles " $dir/$pic_object"
9530266e564dSmrg	  fi
9531266e564dSmrg
9532266e564dSmrg	  # Add non-PIC object to the list of files to remove.
9533698f425bSmrg	  if test -n "$non_pic_object" &&
9534698f425bSmrg	     test "$non_pic_object" != none; then
95359ef0b394Smrg	    func_append rmfiles " $dir/$non_pic_object"
9536266e564dSmrg	  fi
9537266e564dSmrg	fi
9538266e564dSmrg	;;
9539266e564dSmrg
9540266e564dSmrg      *)
95419ef0b394Smrg	if test "$opt_mode" = clean ; then
9542266e564dSmrg	  noexename=$name
9543266e564dSmrg	  case $file in
9544266e564dSmrg	  *.exe)
9545698f425bSmrg	    func_stripname '' '.exe' "$file"
9546698f425bSmrg	    file=$func_stripname_result
9547698f425bSmrg	    func_stripname '' '.exe' "$name"
9548698f425bSmrg	    noexename=$func_stripname_result
9549266e564dSmrg	    # $file with .exe has already been added to rmfiles,
9550266e564dSmrg	    # add $file without .exe
95519ef0b394Smrg	    func_append rmfiles " $file"
9552266e564dSmrg	    ;;
9553266e564dSmrg	  esac
9554266e564dSmrg	  # Do a test to see if this is a libtool program.
9555698f425bSmrg	  if func_ltwrapper_p "$file"; then
9556698f425bSmrg	    if func_ltwrapper_executable_p "$file"; then
9557698f425bSmrg	      func_ltwrapper_scriptname "$file"
9558698f425bSmrg	      relink_command=
9559698f425bSmrg	      func_source $func_ltwrapper_scriptname_result
95609ef0b394Smrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
9561698f425bSmrg	    else
9562698f425bSmrg	      relink_command=
9563698f425bSmrg	      func_source $dir/$noexename
9564698f425bSmrg	    fi
9565266e564dSmrg
9566266e564dSmrg	    # note $name still contains .exe if it was in $file originally
9567266e564dSmrg	    # as does the version of $file that was added into $rmfiles
95689ef0b394Smrg	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
9569266e564dSmrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
95709ef0b394Smrg	      func_append rmfiles " $odir/lt-$name"
9571266e564dSmrg	    fi
9572266e564dSmrg	    if test "X$noexename" != "X$name" ; then
95739ef0b394Smrg	      func_append rmfiles " $odir/lt-${noexename}.c"
9574266e564dSmrg	    fi
9575266e564dSmrg	  fi
9576266e564dSmrg	fi
9577266e564dSmrg	;;
9578266e564dSmrg      esac
9579698f425bSmrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
9580266e564dSmrg    done
9581266e564dSmrg
9582266e564dSmrg    # Try to remove the ${objdir}s in the directories where we deleted files
9583266e564dSmrg    for dir in $rmdirs; do
9584266e564dSmrg      if test -d "$dir"; then
9585698f425bSmrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
9586266e564dSmrg      fi
9587266e564dSmrg    done
9588266e564dSmrg
9589266e564dSmrg    exit $exit_status
9590698f425bSmrg}
9591266e564dSmrg
95929ef0b394Smrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
9593698f425bSmrg    func_mode_uninstall ${1+"$@"}
9594266e564dSmrg
95959ef0b394Smrgtest -z "$opt_mode" && {
9596698f425bSmrg  help="$generic_help"
9597698f425bSmrg  func_fatal_help "you must specify a MODE"
9598698f425bSmrg}
9599698f425bSmrg
9600698f425bSmrgtest -z "$exec_cmd" && \
96019ef0b394Smrg  func_fatal_help "invalid operation mode \`$opt_mode'"
9602266e564dSmrg
9603266e564dSmrgif test -n "$exec_cmd"; then
9604698f425bSmrg  eval exec "$exec_cmd"
9605266e564dSmrg  exit $EXIT_FAILURE
9606266e564dSmrgfi
9607266e564dSmrg
9608698f425bSmrgexit $exit_status
9609266e564dSmrg
9610266e564dSmrg
9611266e564dSmrg# The TAGs below are defined such that we never get into a situation
9612266e564dSmrg# in which we disable both kinds of libraries.  Given conflicting
9613266e564dSmrg# choices, we go for a static library, that is the most portable,
9614266e564dSmrg# since we can't tell whether shared libraries were disabled because
9615266e564dSmrg# the user asked for that or because the platform doesn't support
9616266e564dSmrg# them.  This is particularly important on AIX, because we don't
9617266e564dSmrg# support having both static and shared libraries enabled at the same
9618266e564dSmrg# time on that platform, so we default to a shared-only configuration.
9619266e564dSmrg# If a disable-shared tag is given, we'll fallback to a static-only
9620266e564dSmrg# configuration.  But we'll never go from static-only to shared-only.
9621266e564dSmrg
9622266e564dSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
9623698f425bSmrgbuild_libtool_libs=no
9624698f425bSmrgbuild_old_libs=yes
9625266e564dSmrg# ### END LIBTOOL TAG CONFIG: disable-shared
9626266e564dSmrg
9627266e564dSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
9628698f425bSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
9629266e564dSmrg# ### END LIBTOOL TAG CONFIG: disable-static
9630266e564dSmrg
9631266e564dSmrg# Local Variables:
9632266e564dSmrg# mode:shell-script
9633266e564dSmrg# sh-indentation:2
9634266e564dSmrg# End:
9635698f425bSmrg# vi:sw=2
9636698f425bSmrg
9637