ltmain.sh revision 1fb744b4
11fb744b4Smrg
21fb744b4Smrg# libtool (GNU libtool) 2.4.2
31fb744b4Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
41fb744b4Smrg
5518bcf38Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
61fb744b4Smrg# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
71fb744b4Smrg# This is free software; see the source for copying conditions.  There is NO
81fb744b4Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
91fb744b4Smrg
101fb744b4Smrg# GNU Libtool is free software; you can redistribute it and/or modify
11c35d236eSmrg# it under the terms of the GNU General Public License as published by
12c35d236eSmrg# the Free Software Foundation; either version 2 of the License, or
13c35d236eSmrg# (at your option) any later version.
14c35d236eSmrg#
151fb744b4Smrg# As a special exception to the GNU General Public License,
161fb744b4Smrg# if you distribute this file as part of a program or library that
171fb744b4Smrg# is built using GNU Libtool, you may include this file under the
181fb744b4Smrg# same distribution terms that you use for the rest of that program.
191fb744b4Smrg#
201fb744b4Smrg# GNU Libtool is distributed in the hope that it will be useful, but
21c35d236eSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
22c35d236eSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23c35d236eSmrg# General Public License for more details.
24c35d236eSmrg#
25c35d236eSmrg# You should have received a copy of the GNU General Public License
261fb744b4Smrg# along with GNU Libtool; see the file COPYING.  If not, a copy
271fb744b4Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html,
281fb744b4Smrg# or obtained by writing to the Free Software Foundation, Inc.,
291fb744b4Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30518bcf38Smrg
311fb744b4Smrg# Usage: $progname [OPTION]... [MODE-ARG]...
321fb744b4Smrg#
331fb744b4Smrg# Provide generalized library-building support services.
341fb744b4Smrg#
351fb744b4Smrg#       --config             show all configuration variables
361fb744b4Smrg#       --debug              enable verbose shell tracing
371fb744b4Smrg#   -n, --dry-run            display commands without modifying any files
381fb744b4Smrg#       --features           display basic configuration information and exit
391fb744b4Smrg#       --mode=MODE          use operation mode MODE
401fb744b4Smrg#       --preserve-dup-deps  don't remove duplicate dependency libraries
411fb744b4Smrg#       --quiet, --silent    don't print informational messages
421fb744b4Smrg#       --no-quiet, --no-silent
431fb744b4Smrg#                            print informational messages (default)
441fb744b4Smrg#       --no-warn            don't display warning messages
451fb744b4Smrg#       --tag=TAG            use configuration variables from tag TAG
461fb744b4Smrg#   -v, --verbose            print more informational messages than default
471fb744b4Smrg#       --no-verbose         don't print the extra informational messages
481fb744b4Smrg#       --version            print version information
491fb744b4Smrg#   -h, --help, --help-all   print short, long, or detailed help message
501fb744b4Smrg#
511fb744b4Smrg# MODE must be one of the following:
521fb744b4Smrg#
531fb744b4Smrg#         clean              remove files from the build directory
541fb744b4Smrg#         compile            compile a source file into a libtool object
551fb744b4Smrg#         execute            automatically set library path, then run a program
561fb744b4Smrg#         finish             complete the installation of libtool libraries
571fb744b4Smrg#         install            install libraries or executables
581fb744b4Smrg#         link               create a library or an executable
591fb744b4Smrg#         uninstall          remove libraries from an installed directory
601fb744b4Smrg#
611fb744b4Smrg# MODE-ARGS vary depending on the MODE.  When passed as first option,
621fb744b4Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
631fb744b4Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
641fb744b4Smrg#
651fb744b4Smrg# When reporting a bug, please describe a test case to reproduce it and
661fb744b4Smrg# include the following information:
671fb744b4Smrg#
681fb744b4Smrg#         host-triplet:	$host
691fb744b4Smrg#         shell:		$SHELL
701fb744b4Smrg#         compiler:		$LTCC
711fb744b4Smrg#         compiler flags:		$LTCFLAGS
721fb744b4Smrg#         linker:		$LD (gnu? $with_gnu_ld)
731fb744b4Smrg#         $progname:	(GNU libtool) 2.4.2
741fb744b4Smrg#         automake:	$automake_version
751fb744b4Smrg#         autoconf:	$autoconf_version
761fb744b4Smrg#
771fb744b4Smrg# Report bugs to <bug-libtool@gnu.org>.
781fb744b4Smrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
791fb744b4Smrg# General help using GNU software: <http://www.gnu.org/gethelp/>.
80c35d236eSmrg
811fb744b4SmrgPROGRAM=libtool
82c35d236eSmrgPACKAGE=libtool
831fb744b4SmrgVERSION=2.4.2
841fb744b4SmrgTIMESTAMP=""
851fb744b4Smrgpackage_revision=1.3337
86c35d236eSmrg
871fb744b4Smrg# Be Bourne compatible
884f6cd06fSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
894f6cd06fSmrg  emulate sh
904f6cd06fSmrg  NULLCMD=:
914f6cd06fSmrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
924f6cd06fSmrg  # is contrary to our usage.  Disable this feature.
934f6cd06fSmrg  alias -g '${1+"$@"}'='"$@"'
94c35d236eSmrg  setopt NO_GLOB_SUBST
954f6cd06fSmrgelse
964f6cd06fSmrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
97c35d236eSmrgfi
98f55e6a01SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
99f55e6a01SmrgDUALCASE=1; export DUALCASE # for MKS sh
100c35d236eSmrg
1011fb744b4Smrg# A function that is used when there is no print builtin or printf.
1021fb744b4Smrgfunc_fallback_echo ()
1031fb744b4Smrg{
1041fb744b4Smrg  eval 'cat <<_LTECHO_EOF
1051fb744b4Smrg$1
1061fb744b4Smrg_LTECHO_EOF'
1071fb744b4Smrg}
108518bcf38Smrg
1091fb744b4Smrg# NLS nuisances: We save the old values to restore during execute mode.
1101fb744b4Smrglt_user_locale=
1111fb744b4Smrglt_safe_locale=
112f55e6a01Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
1134f6cd06fSmrgdo
1144f6cd06fSmrg  eval "if test \"\${$lt_var+set}\" = set; then
1151fb744b4Smrg          save_$lt_var=\$$lt_var
1161fb744b4Smrg          $lt_var=C
117f55e6a01Smrg	  export $lt_var
1181fb744b4Smrg	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
1191fb744b4Smrg	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
120f55e6a01Smrg	fi"
1214f6cd06fSmrgdone
1221fb744b4SmrgLC_ALL=C
1231fb744b4SmrgLANGUAGE=C
1241fb744b4Smrgexport LANGUAGE LC_ALL
1251fb744b4Smrg
1261fb744b4Smrg$lt_unset CDPATH
127c35d236eSmrg
1281fb744b4Smrg
1291fb744b4Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
1301fb744b4Smrg# is ksh but when the shell is invoked as "sh" and the current value of
1311fb744b4Smrg# the _XPG environment variable is not equal to 1 (one), the special
1321fb744b4Smrg# positional parameter $0, within a function call, is the name of the
1331fb744b4Smrg# function.
1341fb744b4Smrgprogpath="$0"
1351fb744b4Smrg
1361fb744b4Smrg
1371fb744b4Smrg
1381fb744b4Smrg: ${CP="cp -f"}
1391fb744b4Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
1401fb744b4Smrg: ${MAKE="make"}
1411fb744b4Smrg: ${MKDIR="mkdir"}
1421fb744b4Smrg: ${MV="mv -f"}
1431fb744b4Smrg: ${RM="rm -f"}
1441fb744b4Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
1451fb744b4Smrg: ${Xsed="$SED -e 1s/^X//"}
1461fb744b4Smrg
1471fb744b4Smrg# Global variables:
1481fb744b4SmrgEXIT_SUCCESS=0
1491fb744b4SmrgEXIT_FAILURE=1
1501fb744b4SmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
1511fb744b4SmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
1521fb744b4Smrg
1531fb744b4Smrgexit_status=$EXIT_SUCCESS
154f55e6a01Smrg
155c35d236eSmrg# Make sure IFS has a sensible default
156c35d236eSmrglt_nl='
157c35d236eSmrg'
158c35d236eSmrgIFS=" 	$lt_nl"
159c35d236eSmrg
1601fb744b4Smrgdirname="s,/[^/]*$,,"
1611fb744b4Smrgbasename="s,^.*/,,"
162f55e6a01Smrg
1631fb744b4Smrg# func_dirname file append nondir_replacement
1641fb744b4Smrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
1651fb744b4Smrg# otherwise set result to NONDIR_REPLACEMENT.
1661fb744b4Smrgfunc_dirname ()
1671fb744b4Smrg{
1681fb744b4Smrg    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
1691fb744b4Smrg    if test "X$func_dirname_result" = "X${1}"; then
1701fb744b4Smrg      func_dirname_result="${3}"
1711fb744b4Smrg    else
1721fb744b4Smrg      func_dirname_result="$func_dirname_result${2}"
1731fb744b4Smrg    fi
1741fb744b4Smrg} # func_dirname may be replaced by extended shell implementation
1751fb744b4Smrg
1761fb744b4Smrg
1771fb744b4Smrg# func_basename file
1781fb744b4Smrgfunc_basename ()
1791fb744b4Smrg{
1801fb744b4Smrg    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
1811fb744b4Smrg} # func_basename may be replaced by extended shell implementation
1821fb744b4Smrg
1831fb744b4Smrg
1841fb744b4Smrg# func_dirname_and_basename file append nondir_replacement
1851fb744b4Smrg# perform func_basename and func_dirname in a single function
1861fb744b4Smrg# call:
1871fb744b4Smrg#   dirname:  Compute the dirname of FILE.  If nonempty,
1881fb744b4Smrg#             add APPEND to the result, otherwise set result
1891fb744b4Smrg#             to NONDIR_REPLACEMENT.
1901fb744b4Smrg#             value returned in "$func_dirname_result"
1911fb744b4Smrg#   basename: Compute filename of FILE.
1921fb744b4Smrg#             value retuned in "$func_basename_result"
1931fb744b4Smrg# Implementation must be kept synchronized with func_dirname
1941fb744b4Smrg# and func_basename. For efficiency, we do not delegate to
1951fb744b4Smrg# those functions but instead duplicate the functionality here.
1961fb744b4Smrgfunc_dirname_and_basename ()
1971fb744b4Smrg{
1981fb744b4Smrg    # Extract subdirectory from the argument.
1991fb744b4Smrg    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
2001fb744b4Smrg    if test "X$func_dirname_result" = "X${1}"; then
2011fb744b4Smrg      func_dirname_result="${3}"
2021fb744b4Smrg    else
2031fb744b4Smrg      func_dirname_result="$func_dirname_result${2}"
2041fb744b4Smrg    fi
2051fb744b4Smrg    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
2061fb744b4Smrg} # func_dirname_and_basename may be replaced by extended shell implementation
2071fb744b4Smrg
2081fb744b4Smrg
2091fb744b4Smrg# func_stripname prefix suffix name
2101fb744b4Smrg# strip PREFIX and SUFFIX off of NAME.
2111fb744b4Smrg# PREFIX and SUFFIX must not contain globbing or regex special
2121fb744b4Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading
2131fb744b4Smrg# dot (in which case that matches only a dot).
2141fb744b4Smrg# func_strip_suffix prefix name
2151fb744b4Smrgfunc_stripname ()
2161fb744b4Smrg{
2171fb744b4Smrg    case ${2} in
2181fb744b4Smrg      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
2191fb744b4Smrg      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
2201fb744b4Smrg    esac
2211fb744b4Smrg} # func_stripname may be replaced by extended shell implementation
2221fb744b4Smrg
2231fb744b4Smrg
2241fb744b4Smrg# These SED scripts presuppose an absolute path with a trailing slash.
2251fb744b4Smrgpathcar='s,^/\([^/]*\).*$,\1,'
2261fb744b4Smrgpathcdr='s,^/[^/]*,,'
2271fb744b4Smrgremovedotparts=':dotsl
2281fb744b4Smrg		s@/\./@/@g
2291fb744b4Smrg		t dotsl
2301fb744b4Smrg		s,/\.$,/,'
2311fb744b4Smrgcollapseslashes='s@/\{1,\}@/@g'
2321fb744b4Smrgfinalslash='s,/*$,/,'
2331fb744b4Smrg
2341fb744b4Smrg# func_normal_abspath PATH
2351fb744b4Smrg# Remove doubled-up and trailing slashes, "." path components,
2361fb744b4Smrg# and cancel out any ".." path components in PATH after making
2371fb744b4Smrg# it an absolute path.
2381fb744b4Smrg#             value returned in "$func_normal_abspath_result"
2391fb744b4Smrgfunc_normal_abspath ()
2401fb744b4Smrg{
2411fb744b4Smrg  # Start from root dir and reassemble the path.
2421fb744b4Smrg  func_normal_abspath_result=
2431fb744b4Smrg  func_normal_abspath_tpath=$1
2441fb744b4Smrg  func_normal_abspath_altnamespace=
2451fb744b4Smrg  case $func_normal_abspath_tpath in
2461fb744b4Smrg    "")
2471fb744b4Smrg      # Empty path, that just means $cwd.
2481fb744b4Smrg      func_stripname '' '/' "`pwd`"
2491fb744b4Smrg      func_normal_abspath_result=$func_stripname_result
2501fb744b4Smrg      return
2511fb744b4Smrg    ;;
2521fb744b4Smrg    # The next three entries are used to spot a run of precisely
2531fb744b4Smrg    # two leading slashes without using negated character classes;
2541fb744b4Smrg    # we take advantage of case's first-match behaviour.
2551fb744b4Smrg    ///*)
2561fb744b4Smrg      # Unusual form of absolute path, do nothing.
2571fb744b4Smrg    ;;
2581fb744b4Smrg    //*)
2591fb744b4Smrg      # Not necessarily an ordinary path; POSIX reserves leading '//'
2601fb744b4Smrg      # and for example Cygwin uses it to access remote file shares
2611fb744b4Smrg      # over CIFS/SMB, so we conserve a leading double slash if found.
2621fb744b4Smrg      func_normal_abspath_altnamespace=/
2631fb744b4Smrg    ;;
2641fb744b4Smrg    /*)
2651fb744b4Smrg      # Absolute path, do nothing.
2661fb744b4Smrg    ;;
2671fb744b4Smrg    *)
2681fb744b4Smrg      # Relative path, prepend $cwd.
2691fb744b4Smrg      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
2701fb744b4Smrg    ;;
2711fb744b4Smrg  esac
2721fb744b4Smrg  # Cancel out all the simple stuff to save iterations.  We also want
2731fb744b4Smrg  # the path to end with a slash for ease of parsing, so make sure
2741fb744b4Smrg  # there is one (and only one) here.
2751fb744b4Smrg  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
2761fb744b4Smrg        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
2771fb744b4Smrg  while :; do
2781fb744b4Smrg    # Processed it all yet?
2791fb744b4Smrg    if test "$func_normal_abspath_tpath" = / ; then
2801fb744b4Smrg      # If we ascended to the root using ".." the result may be empty now.
2811fb744b4Smrg      if test -z "$func_normal_abspath_result" ; then
2821fb744b4Smrg        func_normal_abspath_result=/
2831fb744b4Smrg      fi
2841fb744b4Smrg      break
2851fb744b4Smrg    fi
2861fb744b4Smrg    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
2871fb744b4Smrg        -e "$pathcar"`
2881fb744b4Smrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
2891fb744b4Smrg        -e "$pathcdr"`
2901fb744b4Smrg    # Figure out what to do with it
2911fb744b4Smrg    case $func_normal_abspath_tcomponent in
2921fb744b4Smrg      "")
2931fb744b4Smrg        # Trailing empty path component, ignore it.
2941fb744b4Smrg      ;;
2951fb744b4Smrg      ..)
2961fb744b4Smrg        # Parent dir; strip last assembled component from result.
2971fb744b4Smrg        func_dirname "$func_normal_abspath_result"
2981fb744b4Smrg        func_normal_abspath_result=$func_dirname_result
2991fb744b4Smrg      ;;
3001fb744b4Smrg      *)
3011fb744b4Smrg        # Actual path component, append it.
3021fb744b4Smrg        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
3031fb744b4Smrg      ;;
3041fb744b4Smrg    esac
3051fb744b4Smrg  done
3061fb744b4Smrg  # Restore leading double-slash if one was found on entry.
3071fb744b4Smrg  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
3081fb744b4Smrg}
3091fb744b4Smrg
3101fb744b4Smrg# func_relative_path SRCDIR DSTDIR
3111fb744b4Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing
3121fb744b4Smrg# slash if non-empty, suitable for immediately appending a filename
3131fb744b4Smrg# without needing to append a separator.
3141fb744b4Smrg#             value returned in "$func_relative_path_result"
3151fb744b4Smrgfunc_relative_path ()
3161fb744b4Smrg{
3171fb744b4Smrg  func_relative_path_result=
3181fb744b4Smrg  func_normal_abspath "$1"
3191fb744b4Smrg  func_relative_path_tlibdir=$func_normal_abspath_result
3201fb744b4Smrg  func_normal_abspath "$2"
3211fb744b4Smrg  func_relative_path_tbindir=$func_normal_abspath_result
3221fb744b4Smrg
3231fb744b4Smrg  # Ascend the tree starting from libdir
3241fb744b4Smrg  while :; do
3251fb744b4Smrg    # check if we have found a prefix of bindir
3261fb744b4Smrg    case $func_relative_path_tbindir in
3271fb744b4Smrg      $func_relative_path_tlibdir)
3281fb744b4Smrg        # found an exact match
3291fb744b4Smrg        func_relative_path_tcancelled=
3301fb744b4Smrg        break
3311fb744b4Smrg        ;;
3321fb744b4Smrg      $func_relative_path_tlibdir*)
3331fb744b4Smrg        # found a matching prefix
3341fb744b4Smrg        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
3351fb744b4Smrg        func_relative_path_tcancelled=$func_stripname_result
3361fb744b4Smrg        if test -z "$func_relative_path_result"; then
3371fb744b4Smrg          func_relative_path_result=.
3381fb744b4Smrg        fi
3391fb744b4Smrg        break
3401fb744b4Smrg        ;;
3411fb744b4Smrg      *)
3421fb744b4Smrg        func_dirname $func_relative_path_tlibdir
3431fb744b4Smrg        func_relative_path_tlibdir=${func_dirname_result}
3441fb744b4Smrg        if test "x$func_relative_path_tlibdir" = x ; then
3451fb744b4Smrg          # Have to descend all the way to the root!
3461fb744b4Smrg          func_relative_path_result=../$func_relative_path_result
3471fb744b4Smrg          func_relative_path_tcancelled=$func_relative_path_tbindir
3481fb744b4Smrg          break
3491fb744b4Smrg        fi
3501fb744b4Smrg        func_relative_path_result=../$func_relative_path_result
3511fb744b4Smrg        ;;
3521fb744b4Smrg    esac
3531fb744b4Smrg  done
3541fb744b4Smrg
3551fb744b4Smrg  # Now calculate path; take care to avoid doubling-up slashes.
3561fb744b4Smrg  func_stripname '' '/' "$func_relative_path_result"
3571fb744b4Smrg  func_relative_path_result=$func_stripname_result
3581fb744b4Smrg  func_stripname '/' '/' "$func_relative_path_tcancelled"
3591fb744b4Smrg  if test "x$func_stripname_result" != x ; then
3601fb744b4Smrg    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
3611fb744b4Smrg  fi
3621fb744b4Smrg
3631fb744b4Smrg  # Normalisation. If bindir is libdir, return empty string,
3641fb744b4Smrg  # else relative path ending with a slash; either way, target
3651fb744b4Smrg  # file name can be directly appended.
3661fb744b4Smrg  if test ! -z "$func_relative_path_result"; then
3671fb744b4Smrg    func_stripname './' '' "$func_relative_path_result/"
3681fb744b4Smrg    func_relative_path_result=$func_stripname_result
3691fb744b4Smrg  fi
3701fb744b4Smrg}
3711fb744b4Smrg
3721fb744b4Smrg# The name of this program:
3731fb744b4Smrgfunc_dirname_and_basename "$progpath"
3741fb744b4Smrgprogname=$func_basename_result
3751fb744b4Smrg
3761fb744b4Smrg# Make sure we have an absolute path for reexecution:
3771fb744b4Smrgcase $progpath in
3781fb744b4Smrg  [\\/]*|[A-Za-z]:\\*) ;;
3791fb744b4Smrg  *[\\/]*)
3801fb744b4Smrg     progdir=$func_dirname_result
3811fb744b4Smrg     progdir=`cd "$progdir" && pwd`
3821fb744b4Smrg     progpath="$progdir/$progname"
3831fb744b4Smrg     ;;
3841fb744b4Smrg  *)
3851fb744b4Smrg     save_IFS="$IFS"
3861fb744b4Smrg     IFS=${PATH_SEPARATOR-:}
3871fb744b4Smrg     for progdir in $PATH; do
3881fb744b4Smrg       IFS="$save_IFS"
3891fb744b4Smrg       test -x "$progdir/$progname" && break
3901fb744b4Smrg     done
3911fb744b4Smrg     IFS="$save_IFS"
3921fb744b4Smrg     test -n "$progdir" || progdir=`pwd`
3931fb744b4Smrg     progpath="$progdir/$progname"
3941fb744b4Smrg     ;;
3951fb744b4Smrgesac
3961fb744b4Smrg
3971fb744b4Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
3981fb744b4Smrg# metacharacters that are still active within double-quoted strings.
3991fb744b4SmrgXsed="${SED}"' -e 1s/^X//'
4001fb744b4Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
4011fb744b4Smrg
4021fb744b4Smrg# Same as above, but do not quote variable references.
4031fb744b4Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
4041fb744b4Smrg
4051fb744b4Smrg# Sed substitution that turns a string into a regex matching for the
4061fb744b4Smrg# string literally.
4071fb744b4Smrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
4081fb744b4Smrg
4091fb744b4Smrg# Sed substitution that converts a w32 file name or path
4101fb744b4Smrg# which contains forward slashes, into one that contains
4111fb744b4Smrg# (escaped) backslashes.  A very naive implementation.
4121fb744b4Smrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
4131fb744b4Smrg
4141fb744b4Smrg# Re-`\' parameter expansions in output of double_quote_subst that were
4151fb744b4Smrg# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
4161fb744b4Smrg# in input to double_quote_subst, that '$' was protected from expansion.
4171fb744b4Smrg# Since each input `\' is now two `\'s, look for any number of runs of
4181fb744b4Smrg# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
4191fb744b4Smrgbs='\\'
4201fb744b4Smrgbs2='\\\\'
4211fb744b4Smrgbs4='\\\\\\\\'
4221fb744b4Smrgdollar='\$'
4231fb744b4Smrgsed_double_backslash="\
4241fb744b4Smrg  s/$bs4/&\\
4251fb744b4Smrg/g
4261fb744b4Smrg  s/^$bs2$dollar/$bs&/
4271fb744b4Smrg  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
4281fb744b4Smrg  s/\n//g"
4291fb744b4Smrg
4301fb744b4Smrg# Standard options:
4311fb744b4Smrgopt_dry_run=false
4321fb744b4Smrgopt_help=false
4331fb744b4Smrgopt_quiet=false
4341fb744b4Smrgopt_verbose=false
4351fb744b4Smrgopt_warning=:
4361fb744b4Smrg
4371fb744b4Smrg# func_echo arg...
4381fb744b4Smrg# Echo program name prefixed message, along with the current mode
4391fb744b4Smrg# name if it has been set yet.
4401fb744b4Smrgfunc_echo ()
4411fb744b4Smrg{
4421fb744b4Smrg    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
4431fb744b4Smrg}
4441fb744b4Smrg
4451fb744b4Smrg# func_verbose arg...
4461fb744b4Smrg# Echo program name prefixed message in verbose mode only.
4471fb744b4Smrgfunc_verbose ()
4481fb744b4Smrg{
4491fb744b4Smrg    $opt_verbose && func_echo ${1+"$@"}
4501fb744b4Smrg
4511fb744b4Smrg    # A bug in bash halts the script if the last line of a function
4521fb744b4Smrg    # fails when set -e is in force, so we need another command to
4531fb744b4Smrg    # work around that:
4541fb744b4Smrg    :
4551fb744b4Smrg}
4561fb744b4Smrg
4571fb744b4Smrg# func_echo_all arg...
4581fb744b4Smrg# Invoke $ECHO with all args, space-separated.
4591fb744b4Smrgfunc_echo_all ()
4601fb744b4Smrg{
4611fb744b4Smrg    $ECHO "$*"
4621fb744b4Smrg}
4631fb744b4Smrg
4641fb744b4Smrg# func_error arg...
4651fb744b4Smrg# Echo program name prefixed message to standard error.
4661fb744b4Smrgfunc_error ()
4671fb744b4Smrg{
4681fb744b4Smrg    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
4691fb744b4Smrg}
4701fb744b4Smrg
4711fb744b4Smrg# func_warning arg...
4721fb744b4Smrg# Echo program name prefixed warning message to standard error.
4731fb744b4Smrgfunc_warning ()
4741fb744b4Smrg{
4751fb744b4Smrg    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
4761fb744b4Smrg
4771fb744b4Smrg    # bash bug again:
4781fb744b4Smrg    :
4791fb744b4Smrg}
4801fb744b4Smrg
4811fb744b4Smrg# func_fatal_error arg...
4821fb744b4Smrg# Echo program name prefixed message to standard error, and exit.
4831fb744b4Smrgfunc_fatal_error ()
4841fb744b4Smrg{
4851fb744b4Smrg    func_error ${1+"$@"}
4861fb744b4Smrg    exit $EXIT_FAILURE
4871fb744b4Smrg}
4881fb744b4Smrg
4891fb744b4Smrg# func_fatal_help arg...
4901fb744b4Smrg# Echo program name prefixed message to standard error, followed by
4911fb744b4Smrg# a help hint, and exit.
4921fb744b4Smrgfunc_fatal_help ()
4931fb744b4Smrg{
4941fb744b4Smrg    func_error ${1+"$@"}
4951fb744b4Smrg    func_fatal_error "$help"
4961fb744b4Smrg}
4971fb744b4Smrghelp="Try \`$progname --help' for more information."  ## default
4981fb744b4Smrg
4991fb744b4Smrg
5001fb744b4Smrg# func_grep expression filename
5011fb744b4Smrg# Check whether EXPRESSION matches any line of FILENAME, without output.
5021fb744b4Smrgfunc_grep ()
5031fb744b4Smrg{
5041fb744b4Smrg    $GREP "$1" "$2" >/dev/null 2>&1
5051fb744b4Smrg}
5061fb744b4Smrg
5071fb744b4Smrg
5081fb744b4Smrg# func_mkdir_p directory-path
5091fb744b4Smrg# Make sure the entire path to DIRECTORY-PATH is available.
5101fb744b4Smrgfunc_mkdir_p ()
5111fb744b4Smrg{
5121fb744b4Smrg    my_directory_path="$1"
5131fb744b4Smrg    my_dir_list=
5141fb744b4Smrg
5151fb744b4Smrg    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
5161fb744b4Smrg
5171fb744b4Smrg      # Protect directory names starting with `-'
5181fb744b4Smrg      case $my_directory_path in
5191fb744b4Smrg        -*) my_directory_path="./$my_directory_path" ;;
5201fb744b4Smrg      esac
5211fb744b4Smrg
5221fb744b4Smrg      # While some portion of DIR does not yet exist...
5231fb744b4Smrg      while test ! -d "$my_directory_path"; do
5241fb744b4Smrg        # ...make a list in topmost first order.  Use a colon delimited
5251fb744b4Smrg	# list incase some portion of path contains whitespace.
5261fb744b4Smrg        my_dir_list="$my_directory_path:$my_dir_list"
5271fb744b4Smrg
5281fb744b4Smrg        # If the last portion added has no slash in it, the list is done
5291fb744b4Smrg        case $my_directory_path in */*) ;; *) break ;; esac
5301fb744b4Smrg
5311fb744b4Smrg        # ...otherwise throw away the child directory and loop
5321fb744b4Smrg        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
5331fb744b4Smrg      done
5341fb744b4Smrg      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
5351fb744b4Smrg
5361fb744b4Smrg      save_mkdir_p_IFS="$IFS"; IFS=':'
5371fb744b4Smrg      for my_dir in $my_dir_list; do
5381fb744b4Smrg	IFS="$save_mkdir_p_IFS"
5391fb744b4Smrg        # mkdir can fail with a `File exist' error if two processes
5401fb744b4Smrg        # try to create one of the directories concurrently.  Don't
5411fb744b4Smrg        # stop in that case!
5421fb744b4Smrg        $MKDIR "$my_dir" 2>/dev/null || :
5431fb744b4Smrg      done
5441fb744b4Smrg      IFS="$save_mkdir_p_IFS"
5451fb744b4Smrg
5461fb744b4Smrg      # Bail out if we (or some other process) failed to create a directory.
5471fb744b4Smrg      test -d "$my_directory_path" || \
5481fb744b4Smrg        func_fatal_error "Failed to create \`$1'"
5491fb744b4Smrg    fi
5501fb744b4Smrg}
551c35d236eSmrg
552c35d236eSmrg
553c35d236eSmrg# func_mktempdir [string]
554c35d236eSmrg# Make a temporary directory that won't clash with other running
555c35d236eSmrg# libtool processes, and avoids race conditions if possible.  If
556c35d236eSmrg# given, STRING is the basename for that directory.
557c35d236eSmrgfunc_mktempdir ()
558c35d236eSmrg{
559c35d236eSmrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
560c35d236eSmrg
5611fb744b4Smrg    if test "$opt_dry_run" = ":"; then
562c35d236eSmrg      # Return a directory name, but don't create it in dry-run mode
563c35d236eSmrg      my_tmpdir="${my_template}-$$"
564c35d236eSmrg    else
565c35d236eSmrg
566c35d236eSmrg      # If mktemp works, use that first and foremost
567c35d236eSmrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
568c35d236eSmrg
569c35d236eSmrg      if test ! -d "$my_tmpdir"; then
5701fb744b4Smrg        # Failing that, at least try and use $RANDOM to avoid a race
5711fb744b4Smrg        my_tmpdir="${my_template}-${RANDOM-0}$$"
572c35d236eSmrg
5731fb744b4Smrg        save_mktempdir_umask=`umask`
5741fb744b4Smrg        umask 0077
5751fb744b4Smrg        $MKDIR "$my_tmpdir"
5761fb744b4Smrg        umask $save_mktempdir_umask
577c35d236eSmrg      fi
578c35d236eSmrg
579c35d236eSmrg      # If we're not in dry-run mode, bomb out on failure
5801fb744b4Smrg      test -d "$my_tmpdir" || \
5811fb744b4Smrg        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
582c35d236eSmrg    fi
583c35d236eSmrg
5841fb744b4Smrg    $ECHO "$my_tmpdir"
585c35d236eSmrg}
586c35d236eSmrg
587c35d236eSmrg
5881fb744b4Smrg# func_quote_for_eval arg
5891fb744b4Smrg# Aesthetically quote ARG to be evaled later.
5901fb744b4Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
5911fb744b4Smrg# is double-quoted, suitable for a subsequent eval, whereas
5921fb744b4Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
5931fb744b4Smrg# which are still active within double quotes backslashified.
5941fb744b4Smrgfunc_quote_for_eval ()
595c35d236eSmrg{
5961fb744b4Smrg    case $1 in
5971fb744b4Smrg      *[\\\`\"\$]*)
5981fb744b4Smrg	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
5991fb744b4Smrg      *)
6001fb744b4Smrg        func_quote_for_eval_unquoted_result="$1" ;;
6011fb744b4Smrg    esac
6021fb744b4Smrg
6031fb744b4Smrg    case $func_quote_for_eval_unquoted_result in
6041fb744b4Smrg      # Double-quote args containing shell metacharacters to delay
6051fb744b4Smrg      # word splitting, command substitution and and variable
6061fb744b4Smrg      # expansion for a subsequent eval.
6071fb744b4Smrg      # Many Bourne shells cannot handle close brackets correctly
6081fb744b4Smrg      # in scan sets, so we specify it separately.
6091fb744b4Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
6101fb744b4Smrg        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
6111fb744b4Smrg        ;;
6121fb744b4Smrg      *)
6131fb744b4Smrg        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
6141fb744b4Smrg    esac
6151fb744b4Smrg}
6161fb744b4Smrg
6171fb744b4Smrg
6181fb744b4Smrg# func_quote_for_expand arg
6191fb744b4Smrg# Aesthetically quote ARG to be evaled later; same as above,
6201fb744b4Smrg# but do not quote variable references.
6211fb744b4Smrgfunc_quote_for_expand ()
6221fb744b4Smrg{
6231fb744b4Smrg    case $1 in
6241fb744b4Smrg      *[\\\`\"]*)
6251fb744b4Smrg	my_arg=`$ECHO "$1" | $SED \
6261fb744b4Smrg	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
6271fb744b4Smrg      *)
6281fb744b4Smrg        my_arg="$1" ;;
6291fb744b4Smrg    esac
6301fb744b4Smrg
6311fb744b4Smrg    case $my_arg in
6321fb744b4Smrg      # Double-quote args containing shell metacharacters to delay
6331fb744b4Smrg      # word splitting and command substitution for a subsequent eval.
6341fb744b4Smrg      # Many Bourne shells cannot handle close brackets correctly
6351fb744b4Smrg      # in scan sets, so we specify it separately.
6361fb744b4Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
6371fb744b4Smrg        my_arg="\"$my_arg\""
6381fb744b4Smrg        ;;
6391fb744b4Smrg    esac
6401fb744b4Smrg
6411fb744b4Smrg    func_quote_for_expand_result="$my_arg"
6421fb744b4Smrg}
6431fb744b4Smrg
6441fb744b4Smrg
6451fb744b4Smrg# func_show_eval cmd [fail_exp]
6461fb744b4Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
6471fb744b4Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
6481fb744b4Smrg# is given, then evaluate it.
6491fb744b4Smrgfunc_show_eval ()
6501fb744b4Smrg{
6511fb744b4Smrg    my_cmd="$1"
6521fb744b4Smrg    my_fail_exp="${2-:}"
6531fb744b4Smrg
6541fb744b4Smrg    ${opt_silent-false} || {
6551fb744b4Smrg      func_quote_for_expand "$my_cmd"
6561fb744b4Smrg      eval "func_echo $func_quote_for_expand_result"
6571fb744b4Smrg    }
6581fb744b4Smrg
6591fb744b4Smrg    if ${opt_dry_run-false}; then :; else
6601fb744b4Smrg      eval "$my_cmd"
6611fb744b4Smrg      my_status=$?
6621fb744b4Smrg      if test "$my_status" -eq 0; then :; else
6631fb744b4Smrg	eval "(exit $my_status); $my_fail_exp"
6641fb744b4Smrg      fi
665518bcf38Smrg    fi
6661fb744b4Smrg}
6671fb744b4Smrg
6681fb744b4Smrg
6691fb744b4Smrg# func_show_eval_locale cmd [fail_exp]
6701fb744b4Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
6711fb744b4Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
6721fb744b4Smrg# is given, then evaluate it.  Use the saved locale for evaluation.
6731fb744b4Smrgfunc_show_eval_locale ()
6741fb744b4Smrg{
6751fb744b4Smrg    my_cmd="$1"
6761fb744b4Smrg    my_fail_exp="${2-:}"
6771fb744b4Smrg
6781fb744b4Smrg    ${opt_silent-false} || {
6791fb744b4Smrg      func_quote_for_expand "$my_cmd"
6801fb744b4Smrg      eval "func_echo $func_quote_for_expand_result"
6811fb744b4Smrg    }
6821fb744b4Smrg
6831fb744b4Smrg    if ${opt_dry_run-false}; then :; else
6841fb744b4Smrg      eval "$lt_user_locale
6851fb744b4Smrg	    $my_cmd"
6861fb744b4Smrg      my_status=$?
6871fb744b4Smrg      eval "$lt_safe_locale"
6881fb744b4Smrg      if test "$my_status" -eq 0; then :; else
6891fb744b4Smrg	eval "(exit $my_status); $my_fail_exp"
6901fb744b4Smrg      fi
6911fb744b4Smrg    fi
6921fb744b4Smrg}
6931fb744b4Smrg
6941fb744b4Smrg# func_tr_sh
6951fb744b4Smrg# Turn $1 into a string suitable for a shell variable name.
6961fb744b4Smrg# Result is stored in $func_tr_sh_result.  All characters
6971fb744b4Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
6981fb744b4Smrg# if $1 begins with a digit, a '_' is prepended as well.
6991fb744b4Smrgfunc_tr_sh ()
7001fb744b4Smrg{
7011fb744b4Smrg  case $1 in
7021fb744b4Smrg  [0-9]* | *[!a-zA-Z0-9_]*)
7031fb744b4Smrg    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
704518bcf38Smrg    ;;
7051fb744b4Smrg  * )
7061fb744b4Smrg    func_tr_sh_result=$1
707518bcf38Smrg    ;;
708518bcf38Smrg  esac
709c35d236eSmrg}
710c35d236eSmrg
711c35d236eSmrg
7121fb744b4Smrg# func_version
7131fb744b4Smrg# Echo version message to standard output and exit.
7141fb744b4Smrgfunc_version ()
715c35d236eSmrg{
7161fb744b4Smrg    $opt_debug
7171fb744b4Smrg
7181fb744b4Smrg    $SED -n '/(C)/!b go
7191fb744b4Smrg	:more
7201fb744b4Smrg	/\./!{
7211fb744b4Smrg	  N
7221fb744b4Smrg	  s/\n# / /
7231fb744b4Smrg	  b more
7241fb744b4Smrg	}
7251fb744b4Smrg	:go
7261fb744b4Smrg	/^# '$PROGRAM' (GNU /,/# warranty; / {
7271fb744b4Smrg        s/^# //
7281fb744b4Smrg	s/^# *$//
7291fb744b4Smrg        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
7301fb744b4Smrg        p
7311fb744b4Smrg     }' < "$progpath"
7321fb744b4Smrg     exit $?
733c35d236eSmrg}
734c35d236eSmrg
7351fb744b4Smrg# func_usage
7361fb744b4Smrg# Echo short help message to standard output and exit.
7371fb744b4Smrgfunc_usage ()
738c35d236eSmrg{
7391fb744b4Smrg    $opt_debug
7401fb744b4Smrg
7411fb744b4Smrg    $SED -n '/^# Usage:/,/^#  *.*--help/ {
7421fb744b4Smrg        s/^# //
7431fb744b4Smrg	s/^# *$//
7441fb744b4Smrg	s/\$progname/'$progname'/
7451fb744b4Smrg	p
7461fb744b4Smrg    }' < "$progpath"
7471fb744b4Smrg    echo
7481fb744b4Smrg    $ECHO "run \`$progname --help | more' for full usage"
7491fb744b4Smrg    exit $?
750c35d236eSmrg}
751c35d236eSmrg
7521fb744b4Smrg# func_help [NOEXIT]
7531fb744b4Smrg# Echo long help message to standard output and exit,
7541fb744b4Smrg# unless 'noexit' is passed as argument.
7551fb744b4Smrgfunc_help ()
756c35d236eSmrg{
7571fb744b4Smrg    $opt_debug
7581fb744b4Smrg
7591fb744b4Smrg    $SED -n '/^# Usage:/,/# Report bugs to/ {
7601fb744b4Smrg	:print
7611fb744b4Smrg        s/^# //
7621fb744b4Smrg	s/^# *$//
7631fb744b4Smrg	s*\$progname*'$progname'*
7641fb744b4Smrg	s*\$host*'"$host"'*
7651fb744b4Smrg	s*\$SHELL*'"$SHELL"'*
7661fb744b4Smrg	s*\$LTCC*'"$LTCC"'*
7671fb744b4Smrg	s*\$LTCFLAGS*'"$LTCFLAGS"'*
7681fb744b4Smrg	s*\$LD*'"$LD"'*
7691fb744b4Smrg	s/\$with_gnu_ld/'"$with_gnu_ld"'/
7701fb744b4Smrg	s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
7711fb744b4Smrg	s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
7721fb744b4Smrg	p
7731fb744b4Smrg	d
7741fb744b4Smrg     }
7751fb744b4Smrg     /^# .* home page:/b print
7761fb744b4Smrg     /^# General help using/b print
7771fb744b4Smrg     ' < "$progpath"
7781fb744b4Smrg    ret=$?
7791fb744b4Smrg    if test -z "$1"; then
7801fb744b4Smrg      exit $ret
781c35d236eSmrg    fi
7821fb744b4Smrg}
783c35d236eSmrg
7841fb744b4Smrg# func_missing_arg argname
7851fb744b4Smrg# Echo program name prefixed message to standard error and set global
7861fb744b4Smrg# exit_cmd.
7871fb744b4Smrgfunc_missing_arg ()
7881fb744b4Smrg{
7891fb744b4Smrg    $opt_debug
790f55e6a01Smrg
7911fb744b4Smrg    func_error "missing argument for $1."
7921fb744b4Smrg    exit_cmd=exit
793c35d236eSmrg}
794c35d236eSmrg
795f55e6a01Smrg
7961fb744b4Smrg# func_split_short_opt shortopt
7971fb744b4Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
7981fb744b4Smrg# variables after splitting SHORTOPT after the 2nd character.
7991fb744b4Smrgfunc_split_short_opt ()
8001fb744b4Smrg{
8011fb744b4Smrg    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
8021fb744b4Smrg    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
8031fb744b4Smrg
8041fb744b4Smrg    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
8051fb744b4Smrg    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
8061fb744b4Smrg} # func_split_short_opt may be replaced by extended shell implementation
807f55e6a01Smrg
808c35d236eSmrg
8091fb744b4Smrg# func_split_long_opt longopt
8101fb744b4Smrg# Set func_split_long_opt_name and func_split_long_opt_arg shell
8111fb744b4Smrg# variables after splitting LONGOPT at the `=' sign.
8121fb744b4Smrgfunc_split_long_opt ()
8131fb744b4Smrg{
8141fb744b4Smrg    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
8151fb744b4Smrg    my_sed_long_arg='1s/^--[^=]*=//'
816c35d236eSmrg
8171fb744b4Smrg    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
8181fb744b4Smrg    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
8191fb744b4Smrg} # func_split_long_opt may be replaced by extended shell implementation
820c35d236eSmrg
8211fb744b4Smrgexit_cmd=:
822c35d236eSmrg
823c35d236eSmrg
824c35d236eSmrg
825f55e6a01Smrg
826f55e6a01Smrg
8271fb744b4Smrgmagic="%%%MAGIC variable%%%"
8281fb744b4Smrgmagic_exe="%%%MAGIC EXE variable%%%"
8291fb744b4Smrg
8301fb744b4Smrg# Global variables.
8311fb744b4Smrgnonopt=
8321fb744b4Smrgpreserve_args=
8331fb744b4Smrglo2o="s/\\.lo\$/.${objext}/"
8341fb744b4Smrgo2lo="s/\\.${objext}\$/.lo/"
8351fb744b4Smrgextracted_archives=
8361fb744b4Smrgextracted_serial=0
8371fb744b4Smrg
8381fb744b4Smrg# If this variable is set in any of the actions, the command in it
8391fb744b4Smrg# will be execed at the end.  This prevents here-documents from being
8401fb744b4Smrg# left over by shells.
8411fb744b4Smrgexec_cmd=
8421fb744b4Smrg
8431fb744b4Smrg# func_append var value
8441fb744b4Smrg# Append VALUE to the end of shell variable VAR.
8451fb744b4Smrgfunc_append ()
8461fb744b4Smrg{
8471fb744b4Smrg    eval "${1}=\$${1}\${2}"
8481fb744b4Smrg} # func_append may be replaced by extended shell implementation
8491fb744b4Smrg
8501fb744b4Smrg# func_append_quoted var value
8511fb744b4Smrg# Quote VALUE and append to the end of shell variable VAR, separated
8521fb744b4Smrg# by a space.
8531fb744b4Smrgfunc_append_quoted ()
8541fb744b4Smrg{
8551fb744b4Smrg    func_quote_for_eval "${2}"
8561fb744b4Smrg    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
8571fb744b4Smrg} # func_append_quoted may be replaced by extended shell implementation
8581fb744b4Smrg
8591fb744b4Smrg
8601fb744b4Smrg# func_arith arithmetic-term...
8611fb744b4Smrgfunc_arith ()
8621fb744b4Smrg{
8631fb744b4Smrg    func_arith_result=`expr "${@}"`
8641fb744b4Smrg} # func_arith may be replaced by extended shell implementation
8651fb744b4Smrg
8661fb744b4Smrg
8671fb744b4Smrg# func_len string
8681fb744b4Smrg# STRING may not start with a hyphen.
8691fb744b4Smrgfunc_len ()
8701fb744b4Smrg{
8711fb744b4Smrg    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
8721fb744b4Smrg} # func_len may be replaced by extended shell implementation
8731fb744b4Smrg
8741fb744b4Smrg
8751fb744b4Smrg# func_lo2o object
8761fb744b4Smrgfunc_lo2o ()
8771fb744b4Smrg{
8781fb744b4Smrg    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
8791fb744b4Smrg} # func_lo2o may be replaced by extended shell implementation
8801fb744b4Smrg
8811fb744b4Smrg
8821fb744b4Smrg# func_xform libobj-or-source
8831fb744b4Smrgfunc_xform ()
8841fb744b4Smrg{
8851fb744b4Smrg    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
8861fb744b4Smrg} # func_xform may be replaced by extended shell implementation
8871fb744b4Smrg
8881fb744b4Smrg
8891fb744b4Smrg# func_fatal_configuration arg...
8901fb744b4Smrg# Echo program name prefixed message to standard error, followed by
8911fb744b4Smrg# a configuration failure hint, and exit.
8921fb744b4Smrgfunc_fatal_configuration ()
8931fb744b4Smrg{
8941fb744b4Smrg    func_error ${1+"$@"}
8951fb744b4Smrg    func_error "See the $PACKAGE documentation for more information."
8961fb744b4Smrg    func_fatal_error "Fatal configuration error."
8971fb744b4Smrg}
8981fb744b4Smrg
8991fb744b4Smrg
9001fb744b4Smrg# func_config
9011fb744b4Smrg# Display the configuration for all the tags in this script.
9021fb744b4Smrgfunc_config ()
9031fb744b4Smrg{
9041fb744b4Smrg    re_begincf='^# ### BEGIN LIBTOOL'
9051fb744b4Smrg    re_endcf='^# ### END LIBTOOL'
9061fb744b4Smrg
9071fb744b4Smrg    # Default configuration.
9081fb744b4Smrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
9091fb744b4Smrg
910c35d236eSmrg    # Now print the configurations for the tags.
911c35d236eSmrg    for tagname in $taglist; do
9121fb744b4Smrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
913c35d236eSmrg    done
914518bcf38Smrg
9151fb744b4Smrg    exit $?
9161fb744b4Smrg}
917518bcf38Smrg
9181fb744b4Smrg# func_features
9191fb744b4Smrg# Display the features supported by this script.
9201fb744b4Smrgfunc_features ()
9211fb744b4Smrg{
9221fb744b4Smrg    echo "host: $host"
923c35d236eSmrg    if test "$build_libtool_libs" = yes; then
9241fb744b4Smrg      echo "enable shared libraries"
925c35d236eSmrg    else
9261fb744b4Smrg      echo "disable shared libraries"
927c35d236eSmrg    fi
928c35d236eSmrg    if test "$build_old_libs" = yes; then
9291fb744b4Smrg      echo "enable static libraries"
930c35d236eSmrg    else
9311fb744b4Smrg      echo "disable static libraries"
932c35d236eSmrg    fi
933c35d236eSmrg
9341fb744b4Smrg    exit $?
9351fb744b4Smrg}
936f55e6a01Smrg
9371fb744b4Smrg# func_enable_tag tagname
9381fb744b4Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or
9391fb744b4Smrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
9401fb744b4Smrg# variable here.
9411fb744b4Smrgfunc_enable_tag ()
9421fb744b4Smrg{
9431fb744b4Smrg  # Global variable:
9441fb744b4Smrg  tagname="$1"
945c35d236eSmrg
9461fb744b4Smrg  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
9471fb744b4Smrg  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
9481fb744b4Smrg  sed_extractcf="/$re_begincf/,/$re_endcf/p"
949518bcf38Smrg
9501fb744b4Smrg  # Validate tagname.
9511fb744b4Smrg  case $tagname in
9521fb744b4Smrg    *[!-_A-Za-z0-9,/]*)
9531fb744b4Smrg      func_fatal_error "invalid tag name: $tagname"
9541fb744b4Smrg      ;;
9551fb744b4Smrg  esac
956518bcf38Smrg
9571fb744b4Smrg  # Don't test for the "default" C tag, as we know it's
9581fb744b4Smrg  # there but not specially marked.
9591fb744b4Smrg  case $tagname in
9601fb744b4Smrg    CC) ;;
9611fb744b4Smrg    *)
9621fb744b4Smrg      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
9631fb744b4Smrg	taglist="$taglist $tagname"
9641fb744b4Smrg
9651fb744b4Smrg	# Evaluate the configuration.  Be careful to quote the path
9661fb744b4Smrg	# and the sed script, to avoid splitting on whitespace, but
9671fb744b4Smrg	# also don't use non-portable quotes within backquotes within
9681fb744b4Smrg	# quotes we have to do it in 2 steps:
9691fb744b4Smrg	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
9701fb744b4Smrg	eval "$extractedcf"
9711fb744b4Smrg      else
9721fb744b4Smrg	func_error "ignoring unknown tag $tagname"
9731fb744b4Smrg      fi
9741fb744b4Smrg      ;;
9751fb744b4Smrg  esac
9761fb744b4Smrg}
977518bcf38Smrg
9781fb744b4Smrg# func_check_version_match
9791fb744b4Smrg# Ensure that we are using m4 macros, and libtool script from the same
9801fb744b4Smrg# release of libtool.
9811fb744b4Smrgfunc_check_version_match ()
9821fb744b4Smrg{
9831fb744b4Smrg  if test "$package_revision" != "$macro_revision"; then
9841fb744b4Smrg    if test "$VERSION" != "$macro_version"; then
9851fb744b4Smrg      if test -z "$macro_version"; then
9861fb744b4Smrg        cat >&2 <<_LT_EOF
9871fb744b4Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
9881fb744b4Smrg$progname: definition of this LT_INIT comes from an older release.
9891fb744b4Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
9901fb744b4Smrg$progname: and run autoconf again.
9911fb744b4Smrg_LT_EOF
9921fb744b4Smrg      else
9931fb744b4Smrg        cat >&2 <<_LT_EOF
9941fb744b4Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
9951fb744b4Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
9961fb744b4Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
9971fb744b4Smrg$progname: and run autoconf again.
9981fb744b4Smrg_LT_EOF
9991fb744b4Smrg      fi
10001fb744b4Smrg    else
10011fb744b4Smrg      cat >&2 <<_LT_EOF
10021fb744b4Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
10031fb744b4Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
10041fb744b4Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
10051fb744b4Smrg$progname: of $PACKAGE $VERSION and run autoconf again.
10061fb744b4Smrg_LT_EOF
10071fb744b4Smrg    fi
1008518bcf38Smrg
10091fb744b4Smrg    exit $EXIT_MISMATCH
10101fb744b4Smrg  fi
10111fb744b4Smrg}
1012c35d236eSmrg
1013f55e6a01Smrg
10141fb744b4Smrg# Shorthand for --mode=foo, only valid as the first argument
10151fb744b4Smrgcase $1 in
10161fb744b4Smrgclean|clea|cle|cl)
10171fb744b4Smrg  shift; set dummy --mode clean ${1+"$@"}; shift
10181fb744b4Smrg  ;;
10191fb744b4Smrgcompile|compil|compi|comp|com|co|c)
10201fb744b4Smrg  shift; set dummy --mode compile ${1+"$@"}; shift
10211fb744b4Smrg  ;;
10221fb744b4Smrgexecute|execut|execu|exec|exe|ex|e)
10231fb744b4Smrg  shift; set dummy --mode execute ${1+"$@"}; shift
10241fb744b4Smrg  ;;
10251fb744b4Smrgfinish|finis|fini|fin|fi|f)
10261fb744b4Smrg  shift; set dummy --mode finish ${1+"$@"}; shift
1027518bcf38Smrg  ;;
10281fb744b4Smrginstall|instal|insta|inst|ins|in|i)
10291fb744b4Smrg  shift; set dummy --mode install ${1+"$@"}; shift
1030518bcf38Smrg  ;;
10311fb744b4Smrglink|lin|li|l)
10321fb744b4Smrg  shift; set dummy --mode link ${1+"$@"}; shift
10331fb744b4Smrg  ;;
10341fb744b4Smrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
10351fb744b4Smrg  shift; set dummy --mode uninstall ${1+"$@"}; shift
1036518bcf38Smrg  ;;
1037518bcf38Smrgesac
1038f55e6a01Smrg
1039f55e6a01Smrg
1040f55e6a01Smrg
10411fb744b4Smrg# Option defaults:
10421fb744b4Smrgopt_debug=:
10431fb744b4Smrgopt_dry_run=false
10441fb744b4Smrgopt_config=false
10451fb744b4Smrgopt_preserve_dup_deps=false
10461fb744b4Smrgopt_features=false
10471fb744b4Smrgopt_finish=false
10481fb744b4Smrgopt_help=false
10491fb744b4Smrgopt_help_all=false
10501fb744b4Smrgopt_silent=:
10511fb744b4Smrgopt_warning=:
10521fb744b4Smrgopt_verbose=:
10531fb744b4Smrgopt_silent=false
10541fb744b4Smrgopt_verbose=false
1055f55e6a01Smrg
10561fb744b4Smrg
10571fb744b4Smrg# Parse options once, thoroughly.  This comes as soon as possible in the
10581fb744b4Smrg# script to make things like `--version' happen as quickly as we can.
10591fb744b4Smrg{
10601fb744b4Smrg  # this just eases exit handling
10611fb744b4Smrg  while test $# -gt 0; do
10621fb744b4Smrg    opt="$1"
10631fb744b4Smrg    shift
10641fb744b4Smrg    case $opt in
10651fb744b4Smrg      --debug|-x)	opt_debug='set -x'
10661fb744b4Smrg			func_echo "enabling shell trace mode"
10671fb744b4Smrg			$opt_debug
10681fb744b4Smrg			;;
10691fb744b4Smrg      --dry-run|--dryrun|-n)
10701fb744b4Smrg			opt_dry_run=:
10711fb744b4Smrg			;;
10721fb744b4Smrg      --config)
10731fb744b4Smrg			opt_config=:
10741fb744b4Smrgfunc_config
10751fb744b4Smrg			;;
10761fb744b4Smrg      --dlopen|-dlopen)
10771fb744b4Smrg			optarg="$1"
10781fb744b4Smrg			opt_dlopen="${opt_dlopen+$opt_dlopen
10791fb744b4Smrg}$optarg"
10801fb744b4Smrg			shift
10811fb744b4Smrg			;;
10821fb744b4Smrg      --preserve-dup-deps)
10831fb744b4Smrg			opt_preserve_dup_deps=:
10841fb744b4Smrg			;;
10851fb744b4Smrg      --features)
10861fb744b4Smrg			opt_features=:
10871fb744b4Smrgfunc_features
10881fb744b4Smrg			;;
10891fb744b4Smrg      --finish)
10901fb744b4Smrg			opt_finish=:
10911fb744b4Smrgset dummy --mode finish ${1+"$@"}; shift
10921fb744b4Smrg			;;
10931fb744b4Smrg      --help)
10941fb744b4Smrg			opt_help=:
10951fb744b4Smrg			;;
10961fb744b4Smrg      --help-all)
10971fb744b4Smrg			opt_help_all=:
10981fb744b4Smrgopt_help=': help-all'
10991fb744b4Smrg			;;
11001fb744b4Smrg      --mode)
11011fb744b4Smrg			test $# = 0 && func_missing_arg $opt && break
11021fb744b4Smrg			optarg="$1"
11031fb744b4Smrg			opt_mode="$optarg"
11041fb744b4Smrgcase $optarg in
11051fb744b4Smrg  # Valid mode arguments:
11061fb744b4Smrg  clean|compile|execute|finish|install|link|relink|uninstall) ;;
11071fb744b4Smrg
11081fb744b4Smrg  # Catch anything else as an error
11091fb744b4Smrg  *) func_error "invalid argument for $opt"
11101fb744b4Smrg     exit_cmd=exit
11111fb744b4Smrg     break
11121fb744b4Smrg     ;;
11131fb744b4Smrgesac
11141fb744b4Smrg			shift
11151fb744b4Smrg			;;
11161fb744b4Smrg      --no-silent|--no-quiet)
11171fb744b4Smrg			opt_silent=false
11181fb744b4Smrgfunc_append preserve_args " $opt"
11191fb744b4Smrg			;;
11201fb744b4Smrg      --no-warning|--no-warn)
11211fb744b4Smrg			opt_warning=false
11221fb744b4Smrgfunc_append preserve_args " $opt"
11231fb744b4Smrg			;;
11241fb744b4Smrg      --no-verbose)
11251fb744b4Smrg			opt_verbose=false
11261fb744b4Smrgfunc_append preserve_args " $opt"
11271fb744b4Smrg			;;
11281fb744b4Smrg      --silent|--quiet)
11291fb744b4Smrg			opt_silent=:
11301fb744b4Smrgfunc_append preserve_args " $opt"
11311fb744b4Smrg        opt_verbose=false
11321fb744b4Smrg			;;
11331fb744b4Smrg      --verbose|-v)
11341fb744b4Smrg			opt_verbose=:
11351fb744b4Smrgfunc_append preserve_args " $opt"
11361fb744b4Smrgopt_silent=false
11371fb744b4Smrg			;;
11381fb744b4Smrg      --tag)
11391fb744b4Smrg			test $# = 0 && func_missing_arg $opt && break
11401fb744b4Smrg			optarg="$1"
11411fb744b4Smrg			opt_tag="$optarg"
11421fb744b4Smrgfunc_append preserve_args " $opt $optarg"
11431fb744b4Smrgfunc_enable_tag "$optarg"
11441fb744b4Smrg			shift
11451fb744b4Smrg			;;
11461fb744b4Smrg
11471fb744b4Smrg      -\?|-h)		func_usage				;;
11481fb744b4Smrg      --help)		func_help				;;
11491fb744b4Smrg      --version)	func_version				;;
11501fb744b4Smrg
11511fb744b4Smrg      # Separate optargs to long options:
11521fb744b4Smrg      --*=*)
11531fb744b4Smrg			func_split_long_opt "$opt"
11541fb744b4Smrg			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
11551fb744b4Smrg			shift
11561fb744b4Smrg			;;
11571fb744b4Smrg
11581fb744b4Smrg      # Separate non-argument short options:
11591fb744b4Smrg      -\?*|-h*|-n*|-v*)
11601fb744b4Smrg			func_split_short_opt "$opt"
11611fb744b4Smrg			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
11621fb744b4Smrg			shift
11631fb744b4Smrg			;;
11641fb744b4Smrg
11651fb744b4Smrg      --)		break					;;
11661fb744b4Smrg      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
11671fb744b4Smrg      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
1168518bcf38Smrg    esac
11691fb744b4Smrg  done
1170c35d236eSmrg
11711fb744b4Smrg  # Validate options:
11721fb744b4Smrg
11731fb744b4Smrg  # save first non-option argument
11741fb744b4Smrg  if test "$#" -gt 0; then
11751fb744b4Smrg    nonopt="$opt"
11761fb744b4Smrg    shift
1177c35d236eSmrg  fi
1178c35d236eSmrg
11791fb744b4Smrg  # preserve --debug
11801fb744b4Smrg  test "$opt_debug" = : || func_append preserve_args " --debug"
1181c35d236eSmrg
11821fb744b4Smrg  case $host in
11831fb744b4Smrg    *cygwin* | *mingw* | *pw32* | *cegcc*)
11841fb744b4Smrg      # don't eliminate duplications in $postdeps and $predeps
11851fb744b4Smrg      opt_duplicate_compiler_generated_deps=:
11861fb744b4Smrg      ;;
11871fb744b4Smrg    *)
11881fb744b4Smrg      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
11891fb744b4Smrg      ;;
11901fb744b4Smrg  esac
1191c35d236eSmrg
11921fb744b4Smrg  $opt_help || {
11931fb744b4Smrg    # Sanity checks first:
11941fb744b4Smrg    func_check_version_match
1195c35d236eSmrg
11961fb744b4Smrg    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
11971fb744b4Smrg      func_fatal_configuration "not configured to build any kind of library"
11981fb744b4Smrg    fi
1199f55e6a01Smrg
12001fb744b4Smrg    # Darwin sucks
12011fb744b4Smrg    eval std_shrext=\"$shrext_cmds\"
1202c35d236eSmrg
12031fb744b4Smrg    # Only execute mode is allowed to have -dlopen flags.
12041fb744b4Smrg    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
12051fb744b4Smrg      func_error "unrecognized option \`-dlopen'"
12061fb744b4Smrg      $ECHO "$help" 1>&2
12071fb744b4Smrg      exit $EXIT_FAILURE
12081fb744b4Smrg    fi
1209c35d236eSmrg
12101fb744b4Smrg    # Change the help message to a mode-specific one.
12111fb744b4Smrg    generic_help="$help"
12121fb744b4Smrg    help="Try \`$progname --help --mode=$opt_mode' for more information."
12131fb744b4Smrg  }
1214518bcf38Smrg
1215c35d236eSmrg
12161fb744b4Smrg  # Bail if the options were screwed
12171fb744b4Smrg  $exit_cmd $EXIT_FAILURE
12181fb744b4Smrg}
1219c35d236eSmrg
1220c35d236eSmrg
1221518bcf38Smrg
1222518bcf38Smrg
12231fb744b4Smrg## ----------- ##
12241fb744b4Smrg##    Main.    ##
12251fb744b4Smrg## ----------- ##
1226c35d236eSmrg
12271fb744b4Smrg# func_lalib_p file
12281fb744b4Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
12291fb744b4Smrg# This function is only a basic sanity check; it will hardly flush out
12301fb744b4Smrg# determined imposters.
12311fb744b4Smrgfunc_lalib_p ()
12321fb744b4Smrg{
12331fb744b4Smrg    test -f "$1" &&
12341fb744b4Smrg      $SED -e 4q "$1" 2>/dev/null \
12351fb744b4Smrg        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
12361fb744b4Smrg}
1237c35d236eSmrg
12381fb744b4Smrg# func_lalib_unsafe_p file
12391fb744b4Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
12401fb744b4Smrg# This function implements the same check as func_lalib_p without
12411fb744b4Smrg# resorting to external programs.  To this end, it redirects stdin and
12421fb744b4Smrg# closes it afterwards, without saving the original file descriptor.
12431fb744b4Smrg# As a safety measure, use it only where a negative result would be
12441fb744b4Smrg# fatal anyway.  Works if `file' does not exist.
12451fb744b4Smrgfunc_lalib_unsafe_p ()
12461fb744b4Smrg{
12471fb744b4Smrg    lalib_p=no
12481fb744b4Smrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
12491fb744b4Smrg	for lalib_p_l in 1 2 3 4
12501fb744b4Smrg	do
12511fb744b4Smrg	    read lalib_p_line
12521fb744b4Smrg	    case "$lalib_p_line" in
12531fb744b4Smrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
12541fb744b4Smrg	    esac
12551fb744b4Smrg	done
12561fb744b4Smrg	exec 0<&5 5<&-
12571fb744b4Smrg    fi
12581fb744b4Smrg    test "$lalib_p" = yes
12591fb744b4Smrg}
1260c35d236eSmrg
12611fb744b4Smrg# func_ltwrapper_script_p file
12621fb744b4Smrg# True iff FILE is a libtool wrapper script
12631fb744b4Smrg# This function is only a basic sanity check; it will hardly flush out
12641fb744b4Smrg# determined imposters.
12651fb744b4Smrgfunc_ltwrapper_script_p ()
12661fb744b4Smrg{
12671fb744b4Smrg    func_lalib_p "$1"
12681fb744b4Smrg}
1269518bcf38Smrg
12701fb744b4Smrg# func_ltwrapper_executable_p file
12711fb744b4Smrg# True iff FILE is a libtool wrapper executable
12721fb744b4Smrg# This function is only a basic sanity check; it will hardly flush out
12731fb744b4Smrg# determined imposters.
12741fb744b4Smrgfunc_ltwrapper_executable_p ()
12751fb744b4Smrg{
12761fb744b4Smrg    func_ltwrapper_exec_suffix=
12771fb744b4Smrg    case $1 in
12781fb744b4Smrg    *.exe) ;;
12791fb744b4Smrg    *) func_ltwrapper_exec_suffix=.exe ;;
1280c35d236eSmrg    esac
12811fb744b4Smrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
12821fb744b4Smrg}
1283c35d236eSmrg
12841fb744b4Smrg# func_ltwrapper_scriptname file
12851fb744b4Smrg# Assumes file is an ltwrapper_executable
12861fb744b4Smrg# uses $file to determine the appropriate filename for a
12871fb744b4Smrg# temporary ltwrapper_script.
12881fb744b4Smrgfunc_ltwrapper_scriptname ()
12891fb744b4Smrg{
12901fb744b4Smrg    func_dirname_and_basename "$1" "" "."
12911fb744b4Smrg    func_stripname '' '.exe' "$func_basename_result"
12921fb744b4Smrg    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
12931fb744b4Smrg}
1294c35d236eSmrg
12951fb744b4Smrg# func_ltwrapper_p file
12961fb744b4Smrg# True iff FILE is a libtool wrapper script or wrapper executable
12971fb744b4Smrg# This function is only a basic sanity check; it will hardly flush out
12981fb744b4Smrg# determined imposters.
12991fb744b4Smrgfunc_ltwrapper_p ()
13001fb744b4Smrg{
13011fb744b4Smrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
13021fb744b4Smrg}
1303c35d236eSmrg
1304c35d236eSmrg
13051fb744b4Smrg# func_execute_cmds commands fail_cmd
13061fb744b4Smrg# Execute tilde-delimited COMMANDS.
13071fb744b4Smrg# If FAIL_CMD is given, eval that upon failure.
13081fb744b4Smrg# FAIL_CMD may read-access the current command in variable CMD!
13091fb744b4Smrgfunc_execute_cmds ()
13101fb744b4Smrg{
13111fb744b4Smrg    $opt_debug
13121fb744b4Smrg    save_ifs=$IFS; IFS='~'
13131fb744b4Smrg    for cmd in $1; do
13141fb744b4Smrg      IFS=$save_ifs
13151fb744b4Smrg      eval cmd=\"$cmd\"
13161fb744b4Smrg      func_show_eval "$cmd" "${2-:}"
1317c35d236eSmrg    done
13181fb744b4Smrg    IFS=$save_ifs
13191fb744b4Smrg}
1320c35d236eSmrg
1321c35d236eSmrg
13221fb744b4Smrg# func_source file
13231fb744b4Smrg# Source FILE, adding directory component if necessary.
13241fb744b4Smrg# Note that it is not necessary on cygwin/mingw to append a dot to
13251fb744b4Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
13261fb744b4Smrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
13271fb744b4Smrg# `FILE.' does not work on cygwin managed mounts.
13281fb744b4Smrgfunc_source ()
13291fb744b4Smrg{
13301fb744b4Smrg    $opt_debug
13311fb744b4Smrg    case $1 in
13321fb744b4Smrg    */* | *\\*)	. "$1" ;;
13331fb744b4Smrg    *)		. "./$1" ;;
13341fb744b4Smrg    esac
13351fb744b4Smrg}
1336c35d236eSmrg
1337c35d236eSmrg
13381fb744b4Smrg# func_resolve_sysroot PATH
13391fb744b4Smrg# Replace a leading = in PATH with a sysroot.  Store the result into
13401fb744b4Smrg# func_resolve_sysroot_result
13411fb744b4Smrgfunc_resolve_sysroot ()
13421fb744b4Smrg{
13431fb744b4Smrg  func_resolve_sysroot_result=$1
13441fb744b4Smrg  case $func_resolve_sysroot_result in
13451fb744b4Smrg  =*)
13461fb744b4Smrg    func_stripname '=' '' "$func_resolve_sysroot_result"
13471fb744b4Smrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
13481fb744b4Smrg    ;;
13491fb744b4Smrg  esac
13501fb744b4Smrg}
1351518bcf38Smrg
13521fb744b4Smrg# func_replace_sysroot PATH
13531fb744b4Smrg# If PATH begins with the sysroot, replace it with = and
13541fb744b4Smrg# store the result into func_replace_sysroot_result.
13551fb744b4Smrgfunc_replace_sysroot ()
13561fb744b4Smrg{
13571fb744b4Smrg  case "$lt_sysroot:$1" in
13581fb744b4Smrg  ?*:"$lt_sysroot"*)
13591fb744b4Smrg    func_stripname "$lt_sysroot" '' "$1"
13601fb744b4Smrg    func_replace_sysroot_result="=$func_stripname_result"
13611fb744b4Smrg    ;;
13621fb744b4Smrg  *)
13631fb744b4Smrg    # Including no sysroot.
13641fb744b4Smrg    func_replace_sysroot_result=$1
13651fb744b4Smrg    ;;
13661fb744b4Smrg  esac
13671fb744b4Smrg}
1368c35d236eSmrg
13691fb744b4Smrg# func_infer_tag arg
13701fb744b4Smrg# Infer tagged configuration to use if any are available and
13711fb744b4Smrg# if one wasn't chosen via the "--tag" command line option.
13721fb744b4Smrg# Only attempt this if the compiler in the base compile
13731fb744b4Smrg# command doesn't match the default compiler.
13741fb744b4Smrg# arg is usually of the form 'gcc ...'
13751fb744b4Smrgfunc_infer_tag ()
13761fb744b4Smrg{
13771fb744b4Smrg    $opt_debug
13781fb744b4Smrg    if test -n "$available_tags" && test -z "$tagname"; then
13791fb744b4Smrg      CC_quoted=
13801fb744b4Smrg      for arg in $CC; do
13811fb744b4Smrg	func_append_quoted CC_quoted "$arg"
13821fb744b4Smrg      done
13831fb744b4Smrg      CC_expanded=`func_echo_all $CC`
13841fb744b4Smrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
13851fb744b4Smrg      case $@ in
13861fb744b4Smrg      # Blanks in the command may have been stripped by the calling shell,
13871fb744b4Smrg      # but not from the CC environment variable when configure was run.
13881fb744b4Smrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
13891fb744b4Smrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
13901fb744b4Smrg      # Blanks at the start of $base_compile will cause this to fail
13911fb744b4Smrg      # if we don't check for them as well.
13921fb744b4Smrg      *)
13931fb744b4Smrg	for z in $available_tags; do
13941fb744b4Smrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
13951fb744b4Smrg	    # Evaluate the configuration.
13961fb744b4Smrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
13971fb744b4Smrg	    CC_quoted=
13981fb744b4Smrg	    for arg in $CC; do
13991fb744b4Smrg	      # Double-quote args containing other shell metacharacters.
14001fb744b4Smrg	      func_append_quoted CC_quoted "$arg"
14011fb744b4Smrg	    done
14021fb744b4Smrg	    CC_expanded=`func_echo_all $CC`
14031fb744b4Smrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
14041fb744b4Smrg	    case "$@ " in
14051fb744b4Smrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
14061fb744b4Smrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
14071fb744b4Smrg	      # The compiler in the base compile command matches
14081fb744b4Smrg	      # the one in the tagged configuration.
14091fb744b4Smrg	      # Assume this is the tagged configuration we want.
14101fb744b4Smrg	      tagname=$z
14111fb744b4Smrg	      break
14121fb744b4Smrg	      ;;
14131fb744b4Smrg	    esac
14141fb744b4Smrg	  fi
14151fb744b4Smrg	done
14161fb744b4Smrg	# If $tagname still isn't set, then no tagged configuration
14171fb744b4Smrg	# was found and let the user know that the "--tag" command
14181fb744b4Smrg	# line option must be used.
14191fb744b4Smrg	if test -z "$tagname"; then
14201fb744b4Smrg	  func_echo "unable to infer tagged configuration"
14211fb744b4Smrg	  func_fatal_error "specify a tag with \`--tag'"
14221fb744b4Smrg#	else
14231fb744b4Smrg#	  func_verbose "using $tagname tagged configuration"
14241fb744b4Smrg	fi
14251fb744b4Smrg	;;
14261fb744b4Smrg      esac
1427c35d236eSmrg    fi
14281fb744b4Smrg}
1429c35d236eSmrg
1430c35d236eSmrg
1431c35d236eSmrg
14321fb744b4Smrg# func_write_libtool_object output_name pic_name nonpic_name
14331fb744b4Smrg# Create a libtool object file (analogous to a ".la" file),
14341fb744b4Smrg# but don't create it if we're doing a dry run.
14351fb744b4Smrgfunc_write_libtool_object ()
14361fb744b4Smrg{
14371fb744b4Smrg    write_libobj=${1}
14381fb744b4Smrg    if test "$build_libtool_libs" = yes; then
14391fb744b4Smrg      write_lobj=\'${2}\'
14401fb744b4Smrg    else
14411fb744b4Smrg      write_lobj=none
1442c35d236eSmrg    fi
1443c35d236eSmrg
14441fb744b4Smrg    if test "$build_old_libs" = yes; then
14451fb744b4Smrg      write_oldobj=\'${3}\'
14461fb744b4Smrg    else
14471fb744b4Smrg      write_oldobj=none
1448c35d236eSmrg    fi
1449518bcf38Smrg
14501fb744b4Smrg    $opt_dry_run || {
14511fb744b4Smrg      cat >${write_libobj}T <<EOF
14521fb744b4Smrg# $write_libobj - a libtool object file
14531fb744b4Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1454518bcf38Smrg#
1455518bcf38Smrg# Please DO NOT delete this file!
1456518bcf38Smrg# It is necessary for linking the library.
1457518bcf38Smrg
1458518bcf38Smrg# Name of the PIC object.
14591fb744b4Smrgpic_object=$write_lobj
1460c35d236eSmrg
14611fb744b4Smrg# Name of the non-PIC object
14621fb744b4Smrgnon_pic_object=$write_oldobj
1463c35d236eSmrg
14641fb744b4SmrgEOF
14651fb744b4Smrg      $MV "${write_libobj}T" "${write_libobj}"
14661fb744b4Smrg    }
14671fb744b4Smrg}
1468c35d236eSmrg
1469c35d236eSmrg
14701fb744b4Smrg##################################################
14711fb744b4Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
14721fb744b4Smrg##################################################
1473c35d236eSmrg
14741fb744b4Smrg# func_convert_core_file_wine_to_w32 ARG
14751fb744b4Smrg# Helper function used by file name conversion functions when $build is *nix,
14761fb744b4Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
14771fb744b4Smrg# correctly configured wine environment available, with the winepath program
14781fb744b4Smrg# in $build's $PATH.
14791fb744b4Smrg#
14801fb744b4Smrg# ARG is the $build file name to be converted to w32 format.
14811fb744b4Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
14821fb744b4Smrg# be empty on error (or when ARG is empty)
14831fb744b4Smrgfunc_convert_core_file_wine_to_w32 ()
14841fb744b4Smrg{
14851fb744b4Smrg  $opt_debug
14861fb744b4Smrg  func_convert_core_file_wine_to_w32_result="$1"
14871fb744b4Smrg  if test -n "$1"; then
14881fb744b4Smrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
14891fb744b4Smrg    # are forced to check the contents of stdout. On the other hand, if the
14901fb744b4Smrg    # command is not found, the shell will set an exit code of 127 and print
14911fb744b4Smrg    # *an error message* to stdout. So we must check for both error code of
14921fb744b4Smrg    # zero AND non-empty stdout, which explains the odd construction:
14931fb744b4Smrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
14941fb744b4Smrg    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
14951fb744b4Smrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
14961fb744b4Smrg        $SED -e "$lt_sed_naive_backslashify"`
14971fb744b4Smrg    else
14981fb744b4Smrg      func_convert_core_file_wine_to_w32_result=
14991fb744b4Smrg    fi
15001fb744b4Smrg  fi
15011fb744b4Smrg}
15021fb744b4Smrg# end: func_convert_core_file_wine_to_w32
1503518bcf38Smrg
15041fb744b4Smrg
15051fb744b4Smrg# func_convert_core_path_wine_to_w32 ARG
15061fb744b4Smrg# Helper function used by path conversion functions when $build is *nix, and
15071fb744b4Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
15081fb744b4Smrg# configured wine environment available, with the winepath program in $build's
15091fb744b4Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
15101fb744b4Smrg#
15111fb744b4Smrg# ARG is path to be converted from $build format to win32.
15121fb744b4Smrg# Result is available in $func_convert_core_path_wine_to_w32_result.
15131fb744b4Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
15141fb744b4Smrg# are convertible, then the result may be empty.
15151fb744b4Smrgfunc_convert_core_path_wine_to_w32 ()
15161fb744b4Smrg{
15171fb744b4Smrg  $opt_debug
15181fb744b4Smrg  # unfortunately, winepath doesn't convert paths, only file names
15191fb744b4Smrg  func_convert_core_path_wine_to_w32_result=""
15201fb744b4Smrg  if test -n "$1"; then
15211fb744b4Smrg    oldIFS=$IFS
15221fb744b4Smrg    IFS=:
15231fb744b4Smrg    for func_convert_core_path_wine_to_w32_f in $1; do
15241fb744b4Smrg      IFS=$oldIFS
15251fb744b4Smrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
15261fb744b4Smrg      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
15271fb744b4Smrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
15281fb744b4Smrg          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
15291fb744b4Smrg        else
15301fb744b4Smrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
15311fb744b4Smrg        fi
1532518bcf38Smrg      fi
15331fb744b4Smrg    done
15341fb744b4Smrg    IFS=$oldIFS
15351fb744b4Smrg  fi
15361fb744b4Smrg}
15371fb744b4Smrg# end: func_convert_core_path_wine_to_w32
15381fb744b4Smrg
15391fb744b4Smrg
15401fb744b4Smrg# func_cygpath ARGS...
15411fb744b4Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
15421fb744b4Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
15431fb744b4Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
15441fb744b4Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
15451fb744b4Smrg# file name or path is assumed to be in w32 format, as previously converted
15461fb744b4Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
15471fb744b4Smrg# or path in func_cygpath_result (input file name or path is assumed to be in
15481fb744b4Smrg# Cygwin format). Returns an empty string on error.
15491fb744b4Smrg#
15501fb744b4Smrg# ARGS are passed to cygpath, with the last one being the file name or path to
15511fb744b4Smrg# be converted.
15521fb744b4Smrg#
15531fb744b4Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
15541fb744b4Smrg# environment variable; do not put it in $PATH.
15551fb744b4Smrgfunc_cygpath ()
15561fb744b4Smrg{
15571fb744b4Smrg  $opt_debug
15581fb744b4Smrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
15591fb744b4Smrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
15601fb744b4Smrg    if test "$?" -ne 0; then
15611fb744b4Smrg      # on failure, ensure result is empty
15621fb744b4Smrg      func_cygpath_result=
15631fb744b4Smrg    fi
15641fb744b4Smrg  else
15651fb744b4Smrg    func_cygpath_result=
15661fb744b4Smrg    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
15671fb744b4Smrg  fi
15681fb744b4Smrg}
15691fb744b4Smrg#end: func_cygpath
1570c35d236eSmrg
1571c35d236eSmrg
15721fb744b4Smrg# func_convert_core_msys_to_w32 ARG
15731fb744b4Smrg# Convert file name or path ARG from MSYS format to w32 format.  Return
15741fb744b4Smrg# result in func_convert_core_msys_to_w32_result.
15751fb744b4Smrgfunc_convert_core_msys_to_w32 ()
15761fb744b4Smrg{
15771fb744b4Smrg  $opt_debug
15781fb744b4Smrg  # awkward: cmd appends spaces to result
15791fb744b4Smrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
15801fb744b4Smrg    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
15811fb744b4Smrg}
15821fb744b4Smrg#end: func_convert_core_msys_to_w32
1583c35d236eSmrg
1584c35d236eSmrg
15851fb744b4Smrg# func_convert_file_check ARG1 ARG2
15861fb744b4Smrg# Verify that ARG1 (a file name in $build format) was converted to $host
15871fb744b4Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
15881fb744b4Smrg# func_to_host_file_result to ARG1).
15891fb744b4Smrgfunc_convert_file_check ()
15901fb744b4Smrg{
15911fb744b4Smrg  $opt_debug
15921fb744b4Smrg  if test -z "$2" && test -n "$1" ; then
15931fb744b4Smrg    func_error "Could not determine host file name corresponding to"
15941fb744b4Smrg    func_error "  \`$1'"
15951fb744b4Smrg    func_error "Continuing, but uninstalled executables may not work."
15961fb744b4Smrg    # Fallback:
15971fb744b4Smrg    func_to_host_file_result="$1"
15981fb744b4Smrg  fi
15991fb744b4Smrg}
16001fb744b4Smrg# end func_convert_file_check
1601c35d236eSmrg
1602c35d236eSmrg
16031fb744b4Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
16041fb744b4Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host
16051fb744b4Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
16061fb744b4Smrg# func_to_host_file_result to a simplistic fallback value (see below).
16071fb744b4Smrgfunc_convert_path_check ()
16081fb744b4Smrg{
16091fb744b4Smrg  $opt_debug
16101fb744b4Smrg  if test -z "$4" && test -n "$3"; then
16111fb744b4Smrg    func_error "Could not determine the host path corresponding to"
16121fb744b4Smrg    func_error "  \`$3'"
16131fb744b4Smrg    func_error "Continuing, but uninstalled executables may not work."
16141fb744b4Smrg    # Fallback.  This is a deliberately simplistic "conversion" and
16151fb744b4Smrg    # should not be "improved".  See libtool.info.
16161fb744b4Smrg    if test "x$1" != "x$2"; then
16171fb744b4Smrg      lt_replace_pathsep_chars="s|$1|$2|g"
16181fb744b4Smrg      func_to_host_path_result=`echo "$3" |
16191fb744b4Smrg        $SED -e "$lt_replace_pathsep_chars"`
16201fb744b4Smrg    else
16211fb744b4Smrg      func_to_host_path_result="$3"
16221fb744b4Smrg    fi
16231fb744b4Smrg  fi
16241fb744b4Smrg}
16251fb744b4Smrg# end func_convert_path_check
1626518bcf38Smrg
1627518bcf38Smrg
16281fb744b4Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
16291fb744b4Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
16301fb744b4Smrg# and appending REPL if ORIG matches BACKPAT.
16311fb744b4Smrgfunc_convert_path_front_back_pathsep ()
16321fb744b4Smrg{
16331fb744b4Smrg  $opt_debug
16341fb744b4Smrg  case $4 in
16351fb744b4Smrg  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
16361fb744b4Smrg    ;;
16371fb744b4Smrg  esac
16381fb744b4Smrg  case $4 in
16391fb744b4Smrg  $2 ) func_append func_to_host_path_result "$3"
16401fb744b4Smrg    ;;
16411fb744b4Smrg  esac
16421fb744b4Smrg}
16431fb744b4Smrg# end func_convert_path_front_back_pathsep
1644518bcf38Smrg
1645c35d236eSmrg
16461fb744b4Smrg##################################################
16471fb744b4Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
16481fb744b4Smrg##################################################
16491fb744b4Smrg# invoked via `$to_host_file_cmd ARG'
16501fb744b4Smrg#
16511fb744b4Smrg# In each case, ARG is the path to be converted from $build to $host format.
16521fb744b4Smrg# Result will be available in $func_to_host_file_result.
1653c35d236eSmrg
1654c35d236eSmrg
16551fb744b4Smrg# func_to_host_file ARG
16561fb744b4Smrg# Converts the file name ARG from $build format to $host format. Return result
16571fb744b4Smrg# in func_to_host_file_result.
16581fb744b4Smrgfunc_to_host_file ()
16591fb744b4Smrg{
16601fb744b4Smrg  $opt_debug
16611fb744b4Smrg  $to_host_file_cmd "$1"
16621fb744b4Smrg}
16631fb744b4Smrg# end func_to_host_file
1664c35d236eSmrg
1665c35d236eSmrg
16661fb744b4Smrg# func_to_tool_file ARG LAZY
16671fb744b4Smrg# converts the file name ARG from $build format to toolchain format. Return
16681fb744b4Smrg# result in func_to_tool_file_result.  If the conversion in use is listed
16691fb744b4Smrg# in (the comma separated) LAZY, no conversion takes place.
16701fb744b4Smrgfunc_to_tool_file ()
16711fb744b4Smrg{
16721fb744b4Smrg  $opt_debug
16731fb744b4Smrg  case ,$2, in
16741fb744b4Smrg    *,"$to_tool_file_cmd",*)
16751fb744b4Smrg      func_to_tool_file_result=$1
16761fb744b4Smrg      ;;
16771fb744b4Smrg    *)
16781fb744b4Smrg      $to_tool_file_cmd "$1"
16791fb744b4Smrg      func_to_tool_file_result=$func_to_host_file_result
16801fb744b4Smrg      ;;
16811fb744b4Smrg  esac
16821fb744b4Smrg}
16831fb744b4Smrg# end func_to_tool_file
1684c35d236eSmrg
1685c35d236eSmrg
16861fb744b4Smrg# func_convert_file_noop ARG
16871fb744b4Smrg# Copy ARG to func_to_host_file_result.
16881fb744b4Smrgfunc_convert_file_noop ()
16891fb744b4Smrg{
16901fb744b4Smrg  func_to_host_file_result="$1"
16911fb744b4Smrg}
16921fb744b4Smrg# end func_convert_file_noop
1693518bcf38Smrg
1694518bcf38Smrg
16951fb744b4Smrg# func_convert_file_msys_to_w32 ARG
16961fb744b4Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
16971fb744b4Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
16981fb744b4Smrg# func_to_host_file_result.
16991fb744b4Smrgfunc_convert_file_msys_to_w32 ()
17001fb744b4Smrg{
17011fb744b4Smrg  $opt_debug
17021fb744b4Smrg  func_to_host_file_result="$1"
17031fb744b4Smrg  if test -n "$1"; then
17041fb744b4Smrg    func_convert_core_msys_to_w32 "$1"
17051fb744b4Smrg    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
17061fb744b4Smrg  fi
17071fb744b4Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
17081fb744b4Smrg}
17091fb744b4Smrg# end func_convert_file_msys_to_w32
1710518bcf38Smrg
1711c35d236eSmrg
17121fb744b4Smrg# func_convert_file_cygwin_to_w32 ARG
17131fb744b4Smrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
17141fb744b4Smrg# func_to_host_file_result.
17151fb744b4Smrgfunc_convert_file_cygwin_to_w32 ()
17161fb744b4Smrg{
17171fb744b4Smrg  $opt_debug
17181fb744b4Smrg  func_to_host_file_result="$1"
17191fb744b4Smrg  if test -n "$1"; then
17201fb744b4Smrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
17211fb744b4Smrg    # LT_CYGPATH in this case.
17221fb744b4Smrg    func_to_host_file_result=`cygpath -m "$1"`
17231fb744b4Smrg  fi
17241fb744b4Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
17251fb744b4Smrg}
17261fb744b4Smrg# end func_convert_file_cygwin_to_w32
1727c35d236eSmrg
1728c35d236eSmrg
17291fb744b4Smrg# func_convert_file_nix_to_w32 ARG
17301fb744b4Smrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
17311fb744b4Smrg# and a working winepath. Returns result in func_to_host_file_result.
17321fb744b4Smrgfunc_convert_file_nix_to_w32 ()
17331fb744b4Smrg{
17341fb744b4Smrg  $opt_debug
17351fb744b4Smrg  func_to_host_file_result="$1"
17361fb744b4Smrg  if test -n "$1"; then
17371fb744b4Smrg    func_convert_core_file_wine_to_w32 "$1"
17381fb744b4Smrg    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
17391fb744b4Smrg  fi
17401fb744b4Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
17411fb744b4Smrg}
17421fb744b4Smrg# end func_convert_file_nix_to_w32
1743c35d236eSmrg
1744c35d236eSmrg
17451fb744b4Smrg# func_convert_file_msys_to_cygwin ARG
17461fb744b4Smrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
17471fb744b4Smrg# Returns result in func_to_host_file_result.
17481fb744b4Smrgfunc_convert_file_msys_to_cygwin ()
17491fb744b4Smrg{
17501fb744b4Smrg  $opt_debug
17511fb744b4Smrg  func_to_host_file_result="$1"
17521fb744b4Smrg  if test -n "$1"; then
17531fb744b4Smrg    func_convert_core_msys_to_w32 "$1"
17541fb744b4Smrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
17551fb744b4Smrg    func_to_host_file_result="$func_cygpath_result"
17561fb744b4Smrg  fi
17571fb744b4Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
17581fb744b4Smrg}
17591fb744b4Smrg# end func_convert_file_msys_to_cygwin
1760c35d236eSmrg
1761c35d236eSmrg
17621fb744b4Smrg# func_convert_file_nix_to_cygwin ARG
17631fb744b4Smrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
17641fb744b4Smrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
17651fb744b4Smrg# in func_to_host_file_result.
17661fb744b4Smrgfunc_convert_file_nix_to_cygwin ()
17671fb744b4Smrg{
17681fb744b4Smrg  $opt_debug
17691fb744b4Smrg  func_to_host_file_result="$1"
17701fb744b4Smrg  if test -n "$1"; then
17711fb744b4Smrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
17721fb744b4Smrg    func_convert_core_file_wine_to_w32 "$1"
17731fb744b4Smrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
17741fb744b4Smrg    func_to_host_file_result="$func_cygpath_result"
17751fb744b4Smrg  fi
17761fb744b4Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
17771fb744b4Smrg}
17781fb744b4Smrg# end func_convert_file_nix_to_cygwin
1779c35d236eSmrg
1780c35d236eSmrg
17811fb744b4Smrg#############################################
17821fb744b4Smrg# $build to $host PATH CONVERSION FUNCTIONS #
17831fb744b4Smrg#############################################
17841fb744b4Smrg# invoked via `$to_host_path_cmd ARG'
17851fb744b4Smrg#
17861fb744b4Smrg# In each case, ARG is the path to be converted from $build to $host format.
17871fb744b4Smrg# The result will be available in $func_to_host_path_result.
17881fb744b4Smrg#
17891fb744b4Smrg# Path separators are also converted from $build format to $host format.  If
17901fb744b4Smrg# ARG begins or ends with a path separator character, it is preserved (but
17911fb744b4Smrg# converted to $host format) on output.
17921fb744b4Smrg#
17931fb744b4Smrg# All path conversion functions are named using the following convention:
17941fb744b4Smrg#   file name conversion function    : func_convert_file_X_to_Y ()
17951fb744b4Smrg#   path conversion function         : func_convert_path_X_to_Y ()
17961fb744b4Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the
17971fb744b4Smrg# same.  If conversion functions are added for new $build/$host combinations,
17981fb744b4Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
17991fb744b4Smrg# will break.
18001fb744b4Smrg
18011fb744b4Smrg
18021fb744b4Smrg# func_init_to_host_path_cmd
18031fb744b4Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
18041fb744b4Smrg# appropriate value, based on the value of $to_host_file_cmd.
18051fb744b4Smrgto_host_path_cmd=
18061fb744b4Smrgfunc_init_to_host_path_cmd ()
18071fb744b4Smrg{
18081fb744b4Smrg  $opt_debug
18091fb744b4Smrg  if test -z "$to_host_path_cmd"; then
18101fb744b4Smrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
18111fb744b4Smrg    to_host_path_cmd="func_convert_path_${func_stripname_result}"
18121fb744b4Smrg  fi
18131fb744b4Smrg}
1814c35d236eSmrg
1815c35d236eSmrg
18161fb744b4Smrg# func_to_host_path ARG
18171fb744b4Smrg# Converts the path ARG from $build format to $host format. Return result
18181fb744b4Smrg# in func_to_host_path_result.
18191fb744b4Smrgfunc_to_host_path ()
18201fb744b4Smrg{
18211fb744b4Smrg  $opt_debug
18221fb744b4Smrg  func_init_to_host_path_cmd
18231fb744b4Smrg  $to_host_path_cmd "$1"
18241fb744b4Smrg}
18251fb744b4Smrg# end func_to_host_path
1826c35d236eSmrg
1827c35d236eSmrg
18281fb744b4Smrg# func_convert_path_noop ARG
18291fb744b4Smrg# Copy ARG to func_to_host_path_result.
18301fb744b4Smrgfunc_convert_path_noop ()
18311fb744b4Smrg{
18321fb744b4Smrg  func_to_host_path_result="$1"
18331fb744b4Smrg}
18341fb744b4Smrg# end func_convert_path_noop
1835c35d236eSmrg
1836c35d236eSmrg
18371fb744b4Smrg# func_convert_path_msys_to_w32 ARG
18381fb744b4Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
18391fb744b4Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
18401fb744b4Smrg# func_to_host_path_result.
18411fb744b4Smrgfunc_convert_path_msys_to_w32 ()
18421fb744b4Smrg{
18431fb744b4Smrg  $opt_debug
18441fb744b4Smrg  func_to_host_path_result="$1"
18451fb744b4Smrg  if test -n "$1"; then
18461fb744b4Smrg    # Remove leading and trailing path separator characters from ARG.  MSYS
18471fb744b4Smrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
18481fb744b4Smrg    # and winepath ignores them completely.
18491fb744b4Smrg    func_stripname : : "$1"
18501fb744b4Smrg    func_to_host_path_tmp1=$func_stripname_result
18511fb744b4Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
18521fb744b4Smrg    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
18531fb744b4Smrg    func_convert_path_check : ";" \
18541fb744b4Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
18551fb744b4Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
18561fb744b4Smrg  fi
18571fb744b4Smrg}
18581fb744b4Smrg# end func_convert_path_msys_to_w32
1859c35d236eSmrg
1860c35d236eSmrg
18611fb744b4Smrg# func_convert_path_cygwin_to_w32 ARG
18621fb744b4Smrg# Convert path ARG from Cygwin to w32 format.  Returns result in
18631fb744b4Smrg# func_to_host_file_result.
18641fb744b4Smrgfunc_convert_path_cygwin_to_w32 ()
18651fb744b4Smrg{
18661fb744b4Smrg  $opt_debug
18671fb744b4Smrg  func_to_host_path_result="$1"
18681fb744b4Smrg  if test -n "$1"; then
18691fb744b4Smrg    # See func_convert_path_msys_to_w32:
18701fb744b4Smrg    func_stripname : : "$1"
18711fb744b4Smrg    func_to_host_path_tmp1=$func_stripname_result
18721fb744b4Smrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
18731fb744b4Smrg    func_convert_path_check : ";" \
18741fb744b4Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
18751fb744b4Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
18761fb744b4Smrg  fi
18771fb744b4Smrg}
18781fb744b4Smrg# end func_convert_path_cygwin_to_w32
1879c35d236eSmrg
1880c35d236eSmrg
18811fb744b4Smrg# func_convert_path_nix_to_w32 ARG
18821fb744b4Smrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
18831fb744b4Smrg# a working winepath.  Returns result in func_to_host_file_result.
18841fb744b4Smrgfunc_convert_path_nix_to_w32 ()
18851fb744b4Smrg{
18861fb744b4Smrg  $opt_debug
18871fb744b4Smrg  func_to_host_path_result="$1"
18881fb744b4Smrg  if test -n "$1"; then
18891fb744b4Smrg    # See func_convert_path_msys_to_w32:
18901fb744b4Smrg    func_stripname : : "$1"
18911fb744b4Smrg    func_to_host_path_tmp1=$func_stripname_result
18921fb744b4Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
18931fb744b4Smrg    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
18941fb744b4Smrg    func_convert_path_check : ";" \
18951fb744b4Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
18961fb744b4Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
18971fb744b4Smrg  fi
18981fb744b4Smrg}
18991fb744b4Smrg# end func_convert_path_nix_to_w32
1900c35d236eSmrg
1901c35d236eSmrg
19021fb744b4Smrg# func_convert_path_msys_to_cygwin ARG
19031fb744b4Smrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
19041fb744b4Smrg# Returns result in func_to_host_file_result.
19051fb744b4Smrgfunc_convert_path_msys_to_cygwin ()
19061fb744b4Smrg{
19071fb744b4Smrg  $opt_debug
19081fb744b4Smrg  func_to_host_path_result="$1"
19091fb744b4Smrg  if test -n "$1"; then
19101fb744b4Smrg    # See func_convert_path_msys_to_w32:
19111fb744b4Smrg    func_stripname : : "$1"
19121fb744b4Smrg    func_to_host_path_tmp1=$func_stripname_result
19131fb744b4Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
19141fb744b4Smrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
19151fb744b4Smrg    func_to_host_path_result="$func_cygpath_result"
19161fb744b4Smrg    func_convert_path_check : : \
19171fb744b4Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
19181fb744b4Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
19191fb744b4Smrg  fi
19201fb744b4Smrg}
19211fb744b4Smrg# end func_convert_path_msys_to_cygwin
1922c35d236eSmrg
1923c35d236eSmrg
19241fb744b4Smrg# func_convert_path_nix_to_cygwin ARG
19251fb744b4Smrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
19261fb744b4Smrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
19271fb744b4Smrg# func_to_host_file_result.
19281fb744b4Smrgfunc_convert_path_nix_to_cygwin ()
19291fb744b4Smrg{
19301fb744b4Smrg  $opt_debug
19311fb744b4Smrg  func_to_host_path_result="$1"
19321fb744b4Smrg  if test -n "$1"; then
19331fb744b4Smrg    # Remove leading and trailing path separator characters from
19341fb744b4Smrg    # ARG. msys behavior is inconsistent here, cygpath turns them
19351fb744b4Smrg    # into '.;' and ';.', and winepath ignores them completely.
19361fb744b4Smrg    func_stripname : : "$1"
19371fb744b4Smrg    func_to_host_path_tmp1=$func_stripname_result
19381fb744b4Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
19391fb744b4Smrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
19401fb744b4Smrg    func_to_host_path_result="$func_cygpath_result"
19411fb744b4Smrg    func_convert_path_check : : \
19421fb744b4Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
19431fb744b4Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
19441fb744b4Smrg  fi
19451fb744b4Smrg}
19461fb744b4Smrg# end func_convert_path_nix_to_cygwin
1947c35d236eSmrg
1948c35d236eSmrg
19491fb744b4Smrg# func_mode_compile arg...
19501fb744b4Smrgfunc_mode_compile ()
19511fb744b4Smrg{
19521fb744b4Smrg    $opt_debug
19531fb744b4Smrg    # Get the compilation command and the source file.
19541fb744b4Smrg    base_compile=
19551fb744b4Smrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
19561fb744b4Smrg    suppress_opt=yes
19571fb744b4Smrg    suppress_output=
19581fb744b4Smrg    arg_mode=normal
19591fb744b4Smrg    libobj=
19601fb744b4Smrg    later=
19611fb744b4Smrg    pie_flag=
19621fb744b4Smrg
19631fb744b4Smrg    for arg
19641fb744b4Smrg    do
19651fb744b4Smrg      case $arg_mode in
19661fb744b4Smrg      arg  )
19671fb744b4Smrg	# do not "continue".  Instead, add this to base_compile
19681fb744b4Smrg	lastarg="$arg"
19691fb744b4Smrg	arg_mode=normal
19701fb744b4Smrg	;;
19711fb744b4Smrg
19721fb744b4Smrg      target )
19731fb744b4Smrg	libobj="$arg"
19741fb744b4Smrg	arg_mode=normal
19751fb744b4Smrg	continue
19761fb744b4Smrg	;;
19771fb744b4Smrg
19781fb744b4Smrg      normal )
19791fb744b4Smrg	# Accept any command-line options.
19801fb744b4Smrg	case $arg in
19811fb744b4Smrg	-o)
19821fb744b4Smrg	  test -n "$libobj" && \
19831fb744b4Smrg	    func_fatal_error "you cannot specify \`-o' more than once"
19841fb744b4Smrg	  arg_mode=target
1985518bcf38Smrg	  continue
1986518bcf38Smrg	  ;;
19871fb744b4Smrg
19881fb744b4Smrg	-pie | -fpie | -fPIE)
19891fb744b4Smrg          func_append pie_flag " $arg"
1990518bcf38Smrg	  continue
1991518bcf38Smrg	  ;;
19921fb744b4Smrg
19931fb744b4Smrg	-shared | -static | -prefer-pic | -prefer-non-pic)
19941fb744b4Smrg	  func_append later " $arg"
1995518bcf38Smrg	  continue
1996518bcf38Smrg	  ;;
19971fb744b4Smrg
19981fb744b4Smrg	-no-suppress)
19991fb744b4Smrg	  suppress_opt=no
2000518bcf38Smrg	  continue
2001518bcf38Smrg	  ;;
2002c35d236eSmrg
20031fb744b4Smrg	-Xcompiler)
20041fb744b4Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
20051fb744b4Smrg	  continue      #  The current "srcfile" will either be retained or
20061fb744b4Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
2007c35d236eSmrg
20081fb744b4Smrg	-Wc,*)
20091fb744b4Smrg	  func_stripname '-Wc,' '' "$arg"
20101fb744b4Smrg	  args=$func_stripname_result
20111fb744b4Smrg	  lastarg=
20121fb744b4Smrg	  save_ifs="$IFS"; IFS=','
20131fb744b4Smrg	  for arg in $args; do
20141fb744b4Smrg	    IFS="$save_ifs"
20151fb744b4Smrg	    func_append_quoted lastarg "$arg"
20161fb744b4Smrg	  done
20171fb744b4Smrg	  IFS="$save_ifs"
20181fb744b4Smrg	  func_stripname ' ' '' "$lastarg"
20191fb744b4Smrg	  lastarg=$func_stripname_result
2020c35d236eSmrg
20211fb744b4Smrg	  # Add the arguments to base_compile.
20221fb744b4Smrg	  func_append base_compile " $lastarg"
20231fb744b4Smrg	  continue
20241fb744b4Smrg	  ;;
2025c35d236eSmrg
20261fb744b4Smrg	*)
20271fb744b4Smrg	  # Accept the current argument as the source file.
20281fb744b4Smrg	  # The previous "srcfile" becomes the current argument.
20291fb744b4Smrg	  #
20301fb744b4Smrg	  lastarg="$srcfile"
20311fb744b4Smrg	  srcfile="$arg"
20321fb744b4Smrg	  ;;
20331fb744b4Smrg	esac  #  case $arg
2034518bcf38Smrg	;;
20351fb744b4Smrg      esac    #  case $arg_mode
2036c35d236eSmrg
20371fb744b4Smrg      # Aesthetically quote the previous argument.
20381fb744b4Smrg      func_append_quoted base_compile "$lastarg"
20391fb744b4Smrg    done # for arg
2040c35d236eSmrg
20411fb744b4Smrg    case $arg_mode in
20421fb744b4Smrg    arg)
20431fb744b4Smrg      func_fatal_error "you must specify an argument for -Xcompile"
20441fb744b4Smrg      ;;
20451fb744b4Smrg    target)
20461fb744b4Smrg      func_fatal_error "you must specify a target with \`-o'"
20471fb744b4Smrg      ;;
20481fb744b4Smrg    *)
20491fb744b4Smrg      # Get the name of the library object.
20501fb744b4Smrg      test -z "$libobj" && {
20511fb744b4Smrg	func_basename "$srcfile"
20521fb744b4Smrg	libobj="$func_basename_result"
20531fb744b4Smrg      }
20541fb744b4Smrg      ;;
20551fb744b4Smrg    esac
2056c35d236eSmrg
20571fb744b4Smrg    # Recognize several different file suffixes.
20581fb744b4Smrg    # If the user specifies -o file.o, it is replaced with file.lo
20591fb744b4Smrg    case $libobj in
20601fb744b4Smrg    *.[cCFSifmso] | \
20611fb744b4Smrg    *.ada | *.adb | *.ads | *.asm | \
20621fb744b4Smrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
20631fb744b4Smrg    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
20641fb744b4Smrg      func_xform "$libobj"
20651fb744b4Smrg      libobj=$func_xform_result
20661fb744b4Smrg      ;;
20671fb744b4Smrg    esac
2068c35d236eSmrg
20691fb744b4Smrg    case $libobj in
20701fb744b4Smrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
20711fb744b4Smrg    *)
20721fb744b4Smrg      func_fatal_error "cannot determine name of library object from \`$libobj'"
20731fb744b4Smrg      ;;
20741fb744b4Smrg    esac
2075c35d236eSmrg
20761fb744b4Smrg    func_infer_tag $base_compile
2077c35d236eSmrg
20781fb744b4Smrg    for arg in $later; do
20791fb744b4Smrg      case $arg in
20801fb744b4Smrg      -shared)
20811fb744b4Smrg	test "$build_libtool_libs" != yes && \
20821fb744b4Smrg	  func_fatal_configuration "can not build a shared library"
20831fb744b4Smrg	build_old_libs=no
2084518bcf38Smrg	continue
2085518bcf38Smrg	;;
2086c35d236eSmrg
20871fb744b4Smrg      -static)
20881fb744b4Smrg	build_libtool_libs=no
20891fb744b4Smrg	build_old_libs=yes
2090518bcf38Smrg	continue
2091518bcf38Smrg	;;
2092c35d236eSmrg
20931fb744b4Smrg      -prefer-pic)
20941fb744b4Smrg	pic_mode=yes
2095518bcf38Smrg	continue
2096518bcf38Smrg	;;
2097c35d236eSmrg
20981fb744b4Smrg      -prefer-non-pic)
20991fb744b4Smrg	pic_mode=no
2100518bcf38Smrg	continue
2101c35d236eSmrg	;;
21021fb744b4Smrg      esac
21031fb744b4Smrg    done
2104c35d236eSmrg
21051fb744b4Smrg    func_quote_for_eval "$libobj"
21061fb744b4Smrg    test "X$libobj" != "X$func_quote_for_eval_result" \
21071fb744b4Smrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
21081fb744b4Smrg      && func_warning "libobj name \`$libobj' may not contain shell special characters."
21091fb744b4Smrg    func_dirname_and_basename "$obj" "/" ""
21101fb744b4Smrg    objname="$func_basename_result"
21111fb744b4Smrg    xdir="$func_dirname_result"
21121fb744b4Smrg    lobj=${xdir}$objdir/$objname
2113c35d236eSmrg
21141fb744b4Smrg    test -z "$base_compile" && \
21151fb744b4Smrg      func_fatal_help "you must specify a compilation command"
2116c35d236eSmrg
21171fb744b4Smrg    # Delete any leftover library objects.
21181fb744b4Smrg    if test "$build_old_libs" = yes; then
21191fb744b4Smrg      removelist="$obj $lobj $libobj ${libobj}T"
21201fb744b4Smrg    else
21211fb744b4Smrg      removelist="$lobj $libobj ${libobj}T"
21221fb744b4Smrg    fi
2123c35d236eSmrg
21241fb744b4Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
21251fb744b4Smrg    case $host_os in
21261fb744b4Smrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
21271fb744b4Smrg      pic_mode=default
21281fb744b4Smrg      ;;
21291fb744b4Smrg    esac
21301fb744b4Smrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
21311fb744b4Smrg      # non-PIC code in shared libraries is not supported
21321fb744b4Smrg      pic_mode=default
21331fb744b4Smrg    fi
2134c35d236eSmrg
21351fb744b4Smrg    # Calculate the filename of the output object if compiler does
21361fb744b4Smrg    # not support -o with -c
21371fb744b4Smrg    if test "$compiler_c_o" = no; then
21381fb744b4Smrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
21391fb744b4Smrg      lockfile="$output_obj.lock"
21401fb744b4Smrg    else
21411fb744b4Smrg      output_obj=
21421fb744b4Smrg      need_locks=no
21431fb744b4Smrg      lockfile=
21441fb744b4Smrg    fi
2145c35d236eSmrg
21461fb744b4Smrg    # Lock this critical section if it is needed
21471fb744b4Smrg    # We use this script file to make the link, it avoids creating a new file
21481fb744b4Smrg    if test "$need_locks" = yes; then
21491fb744b4Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
21501fb744b4Smrg	func_echo "Waiting for $lockfile to be removed"
21511fb744b4Smrg	sleep 2
21521fb744b4Smrg      done
21531fb744b4Smrg    elif test "$need_locks" = warn; then
21541fb744b4Smrg      if test -f "$lockfile"; then
21551fb744b4Smrg	$ECHO "\
21561fb744b4Smrg*** ERROR, $lockfile exists and contains:
21571fb744b4Smrg`cat $lockfile 2>/dev/null`
2158c35d236eSmrg
21591fb744b4SmrgThis indicates that another process is trying to use the same
21601fb744b4Smrgtemporary object file, and libtool could not work around it because
21611fb744b4Smrgyour compiler does not support \`-c' and \`-o' together.  If you
21621fb744b4Smrgrepeat this compilation, it may succeed, by chance, but you had better
21631fb744b4Smrgavoid parallel builds (make -j) in this platform, or get a better
21641fb744b4Smrgcompiler."
2165c35d236eSmrg
21661fb744b4Smrg	$opt_dry_run || $RM $removelist
21671fb744b4Smrg	exit $EXIT_FAILURE
21681fb744b4Smrg      fi
21691fb744b4Smrg      func_append removelist " $output_obj"
21701fb744b4Smrg      $ECHO "$srcfile" > "$lockfile"
21711fb744b4Smrg    fi
2172c35d236eSmrg
21731fb744b4Smrg    $opt_dry_run || $RM $removelist
21741fb744b4Smrg    func_append removelist " $lockfile"
21751fb744b4Smrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
2176c35d236eSmrg
21771fb744b4Smrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
21781fb744b4Smrg    srcfile=$func_to_tool_file_result
21791fb744b4Smrg    func_quote_for_eval "$srcfile"
21801fb744b4Smrg    qsrcfile=$func_quote_for_eval_result
2181c35d236eSmrg
21821fb744b4Smrg    # Only build a PIC object if we are building libtool libraries.
21831fb744b4Smrg    if test "$build_libtool_libs" = yes; then
21841fb744b4Smrg      # Without this assignment, base_compile gets emptied.
21851fb744b4Smrg      fbsd_hideous_sh_bug=$base_compile
2186c35d236eSmrg
21871fb744b4Smrg      if test "$pic_mode" != no; then
21881fb744b4Smrg	command="$base_compile $qsrcfile $pic_flag"
21891fb744b4Smrg      else
21901fb744b4Smrg	# Don't build PIC code
21911fb744b4Smrg	command="$base_compile $qsrcfile"
21921fb744b4Smrg      fi
2193c35d236eSmrg
21941fb744b4Smrg      func_mkdir_p "$xdir$objdir"
2195c35d236eSmrg
21961fb744b4Smrg      if test -z "$output_obj"; then
21971fb744b4Smrg	# Place PIC objects in $objdir
21981fb744b4Smrg	func_append command " -o $lobj"
21991fb744b4Smrg      fi
2200c35d236eSmrg
22011fb744b4Smrg      func_show_eval_locale "$command"	\
22021fb744b4Smrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
2203c35d236eSmrg
22041fb744b4Smrg      if test "$need_locks" = warn &&
22051fb744b4Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
22061fb744b4Smrg	$ECHO "\
22071fb744b4Smrg*** ERROR, $lockfile contains:
22081fb744b4Smrg`cat $lockfile 2>/dev/null`
2209518bcf38Smrg
22101fb744b4Smrgbut it should contain:
22111fb744b4Smrg$srcfile
2212518bcf38Smrg
22131fb744b4SmrgThis indicates that another process is trying to use the same
22141fb744b4Smrgtemporary object file, and libtool could not work around it because
22151fb744b4Smrgyour compiler does not support \`-c' and \`-o' together.  If you
22161fb744b4Smrgrepeat this compilation, it may succeed, by chance, but you had better
22171fb744b4Smrgavoid parallel builds (make -j) in this platform, or get a better
22181fb744b4Smrgcompiler."
2219c35d236eSmrg
22201fb744b4Smrg	$opt_dry_run || $RM $removelist
22211fb744b4Smrg	exit $EXIT_FAILURE
22221fb744b4Smrg      fi
2223c35d236eSmrg
22241fb744b4Smrg      # Just move the object if needed, then go on to compile the next one
22251fb744b4Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
22261fb744b4Smrg	func_show_eval '$MV "$output_obj" "$lobj"' \
22271fb744b4Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
22281fb744b4Smrg      fi
2229c35d236eSmrg
22301fb744b4Smrg      # Allow error messages only from the first compilation.
22311fb744b4Smrg      if test "$suppress_opt" = yes; then
22321fb744b4Smrg	suppress_output=' >/dev/null 2>&1'
22331fb744b4Smrg      fi
22341fb744b4Smrg    fi
2235c35d236eSmrg
22361fb744b4Smrg    # Only build a position-dependent object if we build old libraries.
22371fb744b4Smrg    if test "$build_old_libs" = yes; then
22381fb744b4Smrg      if test "$pic_mode" != yes; then
22391fb744b4Smrg	# Don't build PIC code
22401fb744b4Smrg	command="$base_compile $qsrcfile$pie_flag"
22411fb744b4Smrg      else
22421fb744b4Smrg	command="$base_compile $qsrcfile $pic_flag"
22431fb744b4Smrg      fi
22441fb744b4Smrg      if test "$compiler_c_o" = yes; then
22451fb744b4Smrg	func_append command " -o $obj"
22461fb744b4Smrg      fi
2247c35d236eSmrg
22481fb744b4Smrg      # Suppress compiler output if we already did a PIC compilation.
22491fb744b4Smrg      func_append command "$suppress_output"
22501fb744b4Smrg      func_show_eval_locale "$command" \
22511fb744b4Smrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
2252c35d236eSmrg
22531fb744b4Smrg      if test "$need_locks" = warn &&
22541fb744b4Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
22551fb744b4Smrg	$ECHO "\
22561fb744b4Smrg*** ERROR, $lockfile contains:
22571fb744b4Smrg`cat $lockfile 2>/dev/null`
2258c35d236eSmrg
22591fb744b4Smrgbut it should contain:
22601fb744b4Smrg$srcfile
2261f55e6a01Smrg
22621fb744b4SmrgThis indicates that another process is trying to use the same
22631fb744b4Smrgtemporary object file, and libtool could not work around it because
22641fb744b4Smrgyour compiler does not support \`-c' and \`-o' together.  If you
22651fb744b4Smrgrepeat this compilation, it may succeed, by chance, but you had better
22661fb744b4Smrgavoid parallel builds (make -j) in this platform, or get a better
22671fb744b4Smrgcompiler."
2268f55e6a01Smrg
22691fb744b4Smrg	$opt_dry_run || $RM $removelist
22701fb744b4Smrg	exit $EXIT_FAILURE
22711fb744b4Smrg      fi
2272f55e6a01Smrg
22731fb744b4Smrg      # Just move the object if needed
22741fb744b4Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
22751fb744b4Smrg	func_show_eval '$MV "$output_obj" "$obj"' \
22761fb744b4Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
22771fb744b4Smrg      fi
22781fb744b4Smrg    fi
2279f55e6a01Smrg
22801fb744b4Smrg    $opt_dry_run || {
22811fb744b4Smrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
2282f55e6a01Smrg
22831fb744b4Smrg      # Unlock the critical section if it was locked
22841fb744b4Smrg      if test "$need_locks" != no; then
22851fb744b4Smrg	removelist=$lockfile
22861fb744b4Smrg        $RM "$lockfile"
22871fb744b4Smrg      fi
22881fb744b4Smrg    }
2289f55e6a01Smrg
22901fb744b4Smrg    exit $EXIT_SUCCESS
22911fb744b4Smrg}
2292f55e6a01Smrg
22931fb744b4Smrg$opt_help || {
22941fb744b4Smrg  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
22951fb744b4Smrg}
2296f55e6a01Smrg
22971fb744b4Smrgfunc_mode_help ()
22981fb744b4Smrg{
22991fb744b4Smrg    # We need to display help for each of the modes.
23001fb744b4Smrg    case $opt_mode in
23011fb744b4Smrg      "")
23021fb744b4Smrg        # Generic help is extracted from the usage comments
23031fb744b4Smrg        # at the start of this file.
23041fb744b4Smrg        func_help
23051fb744b4Smrg        ;;
2306f55e6a01Smrg
23071fb744b4Smrg      clean)
23081fb744b4Smrg        $ECHO \
23091fb744b4Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
2310f55e6a01Smrg
23111fb744b4SmrgRemove files from the build directory.
2312518bcf38Smrg
23131fb744b4SmrgRM is the name of the program to use to delete files associated with each FILE
23141fb744b4Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
23151fb744b4Smrgto RM.
2316f55e6a01Smrg
23171fb744b4SmrgIf FILE is a libtool library, object or program, all the files associated
23181fb744b4Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
23191fb744b4Smrg        ;;
2320f55e6a01Smrg
23211fb744b4Smrg      compile)
23221fb744b4Smrg      $ECHO \
23231fb744b4Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
2324f55e6a01Smrg
23251fb744b4SmrgCompile a source file into a libtool library object.
2326f55e6a01Smrg
23271fb744b4SmrgThis mode accepts the following additional options:
2328f55e6a01Smrg
23291fb744b4Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
23301fb744b4Smrg  -no-suppress      do not suppress compiler output for multiple passes
23311fb744b4Smrg  -prefer-pic       try to build PIC objects only
23321fb744b4Smrg  -prefer-non-pic   try to build non-PIC objects only
23331fb744b4Smrg  -shared           do not build a \`.o' file suitable for static linking
23341fb744b4Smrg  -static           only build a \`.o' file suitable for static linking
23351fb744b4Smrg  -Wc,FLAG          pass FLAG directly to the compiler
2336f55e6a01Smrg
23371fb744b4SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
23381fb744b4Smrgfrom the given SOURCEFILE.
2339c35d236eSmrg
23401fb744b4SmrgThe output file name is determined by removing the directory component from
23411fb744b4SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
23421fb744b4Smrglibrary object suffix, \`.lo'."
23431fb744b4Smrg        ;;
2344c35d236eSmrg
23451fb744b4Smrg      execute)
23461fb744b4Smrg        $ECHO \
23471fb744b4Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
2348c35d236eSmrg
23491fb744b4SmrgAutomatically set library path, then run a program.
2350c35d236eSmrg
23511fb744b4SmrgThis mode accepts the following additional options:
2352c35d236eSmrg
23531fb744b4Smrg  -dlopen FILE      add the directory containing FILE to the library path
2354f55e6a01Smrg
23551fb744b4SmrgThis mode sets the library path environment variable according to \`-dlopen'
23561fb744b4Smrgflags.
2357f55e6a01Smrg
23581fb744b4SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
23591fb744b4Smrginto their corresponding uninstalled binary, and any of their required library
23601fb744b4Smrgdirectories are added to the library path.
2361c35d236eSmrg
23621fb744b4SmrgThen, COMMAND is executed, with ARGS as arguments."
23631fb744b4Smrg        ;;
23641fb744b4Smrg
23651fb744b4Smrg      finish)
23661fb744b4Smrg        $ECHO \
23671fb744b4Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
23681fb744b4Smrg
23691fb744b4SmrgComplete the installation of libtool libraries.
23701fb744b4Smrg
23711fb744b4SmrgEach LIBDIR is a directory that contains libtool libraries.
23721fb744b4Smrg
23731fb744b4SmrgThe commands that this mode executes may require superuser privileges.  Use
23741fb744b4Smrgthe \`--dry-run' option if you just want to see what would be executed."
23751fb744b4Smrg        ;;
23761fb744b4Smrg
23771fb744b4Smrg      install)
23781fb744b4Smrg        $ECHO \
23791fb744b4Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
23801fb744b4Smrg
23811fb744b4SmrgInstall executables or libraries.
23821fb744b4Smrg
23831fb744b4SmrgINSTALL-COMMAND is the installation command.  The first component should be
23841fb744b4Smrgeither the \`install' or \`cp' program.
23851fb744b4Smrg
23861fb744b4SmrgThe following components of INSTALL-COMMAND are treated specially:
23871fb744b4Smrg
23881fb744b4Smrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
23891fb744b4Smrg
23901fb744b4SmrgThe rest of the components are interpreted as arguments to that command (only
23911fb744b4SmrgBSD-compatible install options are recognized)."
23921fb744b4Smrg        ;;
23931fb744b4Smrg
23941fb744b4Smrg      link)
23951fb744b4Smrg        $ECHO \
23961fb744b4Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
23971fb744b4Smrg
23981fb744b4SmrgLink object files or libraries together to form another library, or to
23991fb744b4Smrgcreate an executable program.
24001fb744b4Smrg
24011fb744b4SmrgLINK-COMMAND is a command using the C compiler that you would use to create
24021fb744b4Smrga program from several object files.
24031fb744b4Smrg
24041fb744b4SmrgThe following components of LINK-COMMAND are treated specially:
24051fb744b4Smrg
24061fb744b4Smrg  -all-static       do not do any dynamic linking at all
24071fb744b4Smrg  -avoid-version    do not add a version suffix if possible
24081fb744b4Smrg  -bindir BINDIR    specify path to binaries directory (for systems where
24091fb744b4Smrg                    libraries must be found in the PATH setting at runtime)
24101fb744b4Smrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
24111fb744b4Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
24121fb744b4Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
24131fb744b4Smrg  -export-symbols SYMFILE
24141fb744b4Smrg                    try to export only the symbols listed in SYMFILE
24151fb744b4Smrg  -export-symbols-regex REGEX
24161fb744b4Smrg                    try to export only the symbols matching REGEX
24171fb744b4Smrg  -LLIBDIR          search LIBDIR for required installed libraries
24181fb744b4Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
24191fb744b4Smrg  -module           build a library that can dlopened
24201fb744b4Smrg  -no-fast-install  disable the fast-install mode
24211fb744b4Smrg  -no-install       link a not-installable executable
24221fb744b4Smrg  -no-undefined     declare that a library does not refer to external symbols
24231fb744b4Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
24241fb744b4Smrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
24251fb744b4Smrg  -precious-files-regex REGEX
24261fb744b4Smrg                    don't remove output files matching REGEX
24271fb744b4Smrg  -release RELEASE  specify package release information
24281fb744b4Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
24291fb744b4Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
24301fb744b4Smrg  -shared           only do dynamic linking of libtool libraries
24311fb744b4Smrg  -shrext SUFFIX    override the standard shared library file extension
24321fb744b4Smrg  -static           do not do any dynamic linking of uninstalled libtool libraries
24331fb744b4Smrg  -static-libtool-libs
24341fb744b4Smrg                    do not do any dynamic linking of libtool libraries
24351fb744b4Smrg  -version-info CURRENT[:REVISION[:AGE]]
24361fb744b4Smrg                    specify library version info [each variable defaults to 0]
24371fb744b4Smrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
24381fb744b4Smrg  -Wc,FLAG
24391fb744b4Smrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
24401fb744b4Smrg  -Wl,FLAG
24411fb744b4Smrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
24421fb744b4Smrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
24431fb744b4Smrg
24441fb744b4SmrgAll other options (arguments beginning with \`-') are ignored.
24451fb744b4Smrg
24461fb744b4SmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
24471fb744b4Smrgtreated as uninstalled libtool libraries, other files are standard or library
24481fb744b4Smrgobject files.
24491fb744b4Smrg
24501fb744b4SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
24511fb744b4Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
24521fb744b4Smrgrequired, except when creating a convenience library.
24531fb744b4Smrg
24541fb744b4SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
24551fb744b4Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
24561fb744b4Smrg
24571fb744b4SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
24581fb744b4Smrgis created, otherwise an executable program is created."
24591fb744b4Smrg        ;;
24601fb744b4Smrg
24611fb744b4Smrg      uninstall)
24621fb744b4Smrg        $ECHO \
24631fb744b4Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
24641fb744b4Smrg
24651fb744b4SmrgRemove libraries from an installation directory.
24661fb744b4Smrg
24671fb744b4SmrgRM is the name of the program to use to delete files associated with each FILE
24681fb744b4Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
24691fb744b4Smrgto RM.
24701fb744b4Smrg
24711fb744b4SmrgIf FILE is a libtool library, all the files associated with it are deleted.
24721fb744b4SmrgOtherwise, only FILE itself is deleted using RM."
24731fb744b4Smrg        ;;
24741fb744b4Smrg
24751fb744b4Smrg      *)
24761fb744b4Smrg        func_fatal_help "invalid operation mode \`$opt_mode'"
24771fb744b4Smrg        ;;
2478518bcf38Smrg    esac
2479c35d236eSmrg
24801fb744b4Smrg    echo
24811fb744b4Smrg    $ECHO "Try \`$progname --help' for more information about other modes."
24821fb744b4Smrg}
2483c35d236eSmrg
24841fb744b4Smrg# Now that we've collected a possible --mode arg, show help if necessary
24851fb744b4Smrgif $opt_help; then
24861fb744b4Smrg  if test "$opt_help" = :; then
24871fb744b4Smrg    func_mode_help
24881fb744b4Smrg  else
24891fb744b4Smrg    {
24901fb744b4Smrg      func_help noexit
24911fb744b4Smrg      for opt_mode in compile link execute install finish uninstall clean; do
24921fb744b4Smrg	func_mode_help
24931fb744b4Smrg      done
24941fb744b4Smrg    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
24951fb744b4Smrg    {
24961fb744b4Smrg      func_help noexit
24971fb744b4Smrg      for opt_mode in compile link execute install finish uninstall clean; do
24981fb744b4Smrg	echo
24991fb744b4Smrg	func_mode_help
25001fb744b4Smrg      done
25011fb744b4Smrg    } |
25021fb744b4Smrg    sed '1d
25031fb744b4Smrg      /^When reporting/,/^Report/{
25041fb744b4Smrg	H
25051fb744b4Smrg	d
25061fb744b4Smrg      }
25071fb744b4Smrg      $x
25081fb744b4Smrg      /information about other modes/d
25091fb744b4Smrg      /more detailed .*MODE/d
25101fb744b4Smrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
25111fb744b4Smrg  fi
25121fb744b4Smrg  exit $?
25131fb744b4Smrgfi
2514c35d236eSmrg
2515c35d236eSmrg
25161fb744b4Smrg# func_mode_execute arg...
25171fb744b4Smrgfunc_mode_execute ()
25181fb744b4Smrg{
25191fb744b4Smrg    $opt_debug
25201fb744b4Smrg    # The first argument is the command name.
25211fb744b4Smrg    cmd="$nonopt"
25221fb744b4Smrg    test -z "$cmd" && \
25231fb744b4Smrg      func_fatal_help "you must specify a COMMAND"
25241fb744b4Smrg
25251fb744b4Smrg    # Handle -dlopen flags immediately.
25261fb744b4Smrg    for file in $opt_dlopen; do
25271fb744b4Smrg      test -f "$file" \
25281fb744b4Smrg	|| func_fatal_help "\`$file' is not a file"
25291fb744b4Smrg
25301fb744b4Smrg      dir=
25311fb744b4Smrg      case $file in
25321fb744b4Smrg      *.la)
25331fb744b4Smrg	func_resolve_sysroot "$file"
25341fb744b4Smrg	file=$func_resolve_sysroot_result
25351fb744b4Smrg
25361fb744b4Smrg	# Check to see that this really is a libtool archive.
25371fb744b4Smrg	func_lalib_unsafe_p "$file" \
25381fb744b4Smrg	  || func_fatal_help "\`$lib' is not a valid libtool archive"
25391fb744b4Smrg
25401fb744b4Smrg	# Read the libtool library.
25411fb744b4Smrg	dlname=
25421fb744b4Smrg	library_names=
25431fb744b4Smrg	func_source "$file"
25441fb744b4Smrg
25451fb744b4Smrg	# Skip this library if it cannot be dlopened.
25461fb744b4Smrg	if test -z "$dlname"; then
25471fb744b4Smrg	  # Warn if it was a shared library.
25481fb744b4Smrg	  test -n "$library_names" && \
25491fb744b4Smrg	    func_warning "\`$file' was not linked with \`-export-dynamic'"
25501fb744b4Smrg	  continue
25511fb744b4Smrg	fi
25521fb744b4Smrg
25531fb744b4Smrg	func_dirname "$file" "" "."
25541fb744b4Smrg	dir="$func_dirname_result"
25551fb744b4Smrg
25561fb744b4Smrg	if test -f "$dir/$objdir/$dlname"; then
25571fb744b4Smrg	  func_append dir "/$objdir"
25581fb744b4Smrg	else
25591fb744b4Smrg	  if test ! -f "$dir/$dlname"; then
25601fb744b4Smrg	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
25611fb744b4Smrg	  fi
25621fb744b4Smrg	fi
2563f55e6a01Smrg	;;
25641fb744b4Smrg
25651fb744b4Smrg      *.lo)
25661fb744b4Smrg	# Just add the directory containing the .lo file.
25671fb744b4Smrg	func_dirname "$file" "" "."
25681fb744b4Smrg	dir="$func_dirname_result"
2569518bcf38Smrg	;;
25701fb744b4Smrg
25711fb744b4Smrg      *)
25721fb744b4Smrg	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
25731fb744b4Smrg	continue
2574f55e6a01Smrg	;;
25751fb744b4Smrg      esac
25761fb744b4Smrg
25771fb744b4Smrg      # Get the absolute pathname.
25781fb744b4Smrg      absdir=`cd "$dir" && pwd`
25791fb744b4Smrg      test -n "$absdir" && dir="$absdir"
25801fb744b4Smrg
25811fb744b4Smrg      # Now add the directory to shlibpath_var.
25821fb744b4Smrg      if eval "test -z \"\$$shlibpath_var\""; then
25831fb744b4Smrg	eval "$shlibpath_var=\"\$dir\""
25841fb744b4Smrg      else
25851fb744b4Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
2586518bcf38Smrg      fi
25871fb744b4Smrg    done
25881fb744b4Smrg
25891fb744b4Smrg    # This variable tells wrapper scripts just to set shlibpath_var
25901fb744b4Smrg    # rather than running their programs.
25911fb744b4Smrg    libtool_execute_magic="$magic"
25921fb744b4Smrg
25931fb744b4Smrg    # Check if any of the arguments is a wrapper script.
25941fb744b4Smrg    args=
25951fb744b4Smrg    for file
25961fb744b4Smrg    do
25971fb744b4Smrg      case $file in
25981fb744b4Smrg      -* | *.la | *.lo ) ;;
25991fb744b4Smrg      *)
26001fb744b4Smrg	# Do a test to see if this is really a libtool program.
26011fb744b4Smrg	if func_ltwrapper_script_p "$file"; then
26021fb744b4Smrg	  func_source "$file"
26031fb744b4Smrg	  # Transform arg to wrapped name.
26041fb744b4Smrg	  file="$progdir/$program"
26051fb744b4Smrg	elif func_ltwrapper_executable_p "$file"; then
26061fb744b4Smrg	  func_ltwrapper_scriptname "$file"
26071fb744b4Smrg	  func_source "$func_ltwrapper_scriptname_result"
26081fb744b4Smrg	  # Transform arg to wrapped name.
26091fb744b4Smrg	  file="$progdir/$program"
26101fb744b4Smrg	fi
26111fb744b4Smrg	;;
26121fb744b4Smrg      esac
26131fb744b4Smrg      # Quote arguments (to preserve shell metacharacters).
26141fb744b4Smrg      func_append_quoted args "$file"
26151fb744b4Smrg    done
26161fb744b4Smrg
26171fb744b4Smrg    if test "X$opt_dry_run" = Xfalse; then
26181fb744b4Smrg      if test -n "$shlibpath_var"; then
26191fb744b4Smrg	# Export the shlibpath_var.
26201fb744b4Smrg	eval "export $shlibpath_var"
2621518bcf38Smrg      fi
26221fb744b4Smrg
26231fb744b4Smrg      # Restore saved environment variables
26241fb744b4Smrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
26251fb744b4Smrg      do
26261fb744b4Smrg	eval "if test \"\${save_$lt_var+set}\" = set; then
26271fb744b4Smrg                $lt_var=\$save_$lt_var; export $lt_var
26281fb744b4Smrg	      else
26291fb744b4Smrg		$lt_unset $lt_var
26301fb744b4Smrg	      fi"
26311fb744b4Smrg      done
26321fb744b4Smrg
26331fb744b4Smrg      # Now prepare to actually exec the command.
26341fb744b4Smrg      exec_cmd="\$cmd$args"
26351fb744b4Smrg    else
26361fb744b4Smrg      # Display what would be done.
26371fb744b4Smrg      if test -n "$shlibpath_var"; then
26381fb744b4Smrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
26391fb744b4Smrg	echo "export $shlibpath_var"
2640518bcf38Smrg      fi
26411fb744b4Smrg      $ECHO "$cmd$args"
26421fb744b4Smrg      exit $EXIT_SUCCESS
26431fb744b4Smrg    fi
26441fb744b4Smrg}
2645c35d236eSmrg
26461fb744b4Smrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"}
2647c35d236eSmrg
2648c35d236eSmrg
26491fb744b4Smrg# func_mode_finish arg...
26501fb744b4Smrgfunc_mode_finish ()
26511fb744b4Smrg{
26521fb744b4Smrg    $opt_debug
26531fb744b4Smrg    libs=
26541fb744b4Smrg    libdirs=
26551fb744b4Smrg    admincmds=
2656c35d236eSmrg
26571fb744b4Smrg    for opt in "$nonopt" ${1+"$@"}
26581fb744b4Smrg    do
26591fb744b4Smrg      if test -d "$opt"; then
26601fb744b4Smrg	func_append libdirs " $opt"
2661c35d236eSmrg
26621fb744b4Smrg      elif test -f "$opt"; then
26631fb744b4Smrg	if func_lalib_unsafe_p "$opt"; then
26641fb744b4Smrg	  func_append libs " $opt"
26651fb744b4Smrg	else
26661fb744b4Smrg	  func_warning "\`$opt' is not a valid libtool archive"
2667518bcf38Smrg	fi
2668c35d236eSmrg
26691fb744b4Smrg      else
26701fb744b4Smrg	func_fatal_error "invalid argument \`$opt'"
26711fb744b4Smrg      fi
26721fb744b4Smrg    done
2673c35d236eSmrg
26741fb744b4Smrg    if test -n "$libs"; then
26751fb744b4Smrg      if test -n "$lt_sysroot"; then
26761fb744b4Smrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
26771fb744b4Smrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
26781fb744b4Smrg      else
26791fb744b4Smrg        sysroot_cmd=
26801fb744b4Smrg      fi
2681c35d236eSmrg
26821fb744b4Smrg      # Remove sysroot references
26831fb744b4Smrg      if $opt_dry_run; then
26841fb744b4Smrg        for lib in $libs; do
26851fb744b4Smrg          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
26861fb744b4Smrg        done
26871fb744b4Smrg      else
26881fb744b4Smrg        tmpdir=`func_mktempdir`
26891fb744b4Smrg        for lib in $libs; do
26901fb744b4Smrg	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
26911fb744b4Smrg	    > $tmpdir/tmp-la
26921fb744b4Smrg	  mv -f $tmpdir/tmp-la $lib
2693518bcf38Smrg	done
26941fb744b4Smrg        ${RM}r "$tmpdir"
26951fb744b4Smrg      fi
26961fb744b4Smrg    fi
26971fb744b4Smrg
26981fb744b4Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
26991fb744b4Smrg      for libdir in $libdirs; do
27001fb744b4Smrg	if test -n "$finish_cmds"; then
27011fb744b4Smrg	  # Do each command in the finish commands.
27021fb744b4Smrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
27031fb744b4Smrg'"$cmd"'"'
27041fb744b4Smrg	fi
27051fb744b4Smrg	if test -n "$finish_eval"; then
27061fb744b4Smrg	  # Do the single finish_eval.
27071fb744b4Smrg	  eval cmds=\"$finish_eval\"
27081fb744b4Smrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
27091fb744b4Smrg       $cmds"
2710c35d236eSmrg	fi
27111fb744b4Smrg      done
27121fb744b4Smrg    fi
2713c35d236eSmrg
27141fb744b4Smrg    # Exit here if they wanted silent mode.
27151fb744b4Smrg    $opt_silent && exit $EXIT_SUCCESS
2716c35d236eSmrg
27171fb744b4Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
27181fb744b4Smrg      echo "----------------------------------------------------------------------"
27191fb744b4Smrg      echo "Libraries have been installed in:"
27201fb744b4Smrg      for libdir in $libdirs; do
27211fb744b4Smrg	$ECHO "   $libdir"
27221fb744b4Smrg      done
27231fb744b4Smrg      echo
27241fb744b4Smrg      echo "If you ever happen to want to link against installed libraries"
27251fb744b4Smrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
27261fb744b4Smrg      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
27271fb744b4Smrg      echo "flag during linking and do at least one of the following:"
27281fb744b4Smrg      if test -n "$shlibpath_var"; then
27291fb744b4Smrg	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
27301fb744b4Smrg	echo "     during execution"
27311fb744b4Smrg      fi
27321fb744b4Smrg      if test -n "$runpath_var"; then
27331fb744b4Smrg	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
27341fb744b4Smrg	echo "     during linking"
27351fb744b4Smrg      fi
27361fb744b4Smrg      if test -n "$hardcode_libdir_flag_spec"; then
27371fb744b4Smrg	libdir=LIBDIR
27381fb744b4Smrg	eval flag=\"$hardcode_libdir_flag_spec\"
27391fb744b4Smrg
27401fb744b4Smrg	$ECHO "   - use the \`$flag' linker flag"
27411fb744b4Smrg      fi
27421fb744b4Smrg      if test -n "$admincmds"; then
27431fb744b4Smrg	$ECHO "   - have your system administrator run these commands:$admincmds"
27441fb744b4Smrg      fi
27451fb744b4Smrg      if test -f /etc/ld.so.conf; then
27461fb744b4Smrg	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
27471fb744b4Smrg      fi
27481fb744b4Smrg      echo
27491fb744b4Smrg
27501fb744b4Smrg      echo "See any operating system documentation about shared libraries for"
27511fb744b4Smrg      case $host in
27521fb744b4Smrg	solaris2.[6789]|solaris2.1[0-9])
27531fb744b4Smrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
27541fb744b4Smrg	  echo "pages."
27551fb744b4Smrg	  ;;
2756518bcf38Smrg	*)
27571fb744b4Smrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
2758518bcf38Smrg	  ;;
27591fb744b4Smrg      esac
27601fb744b4Smrg      echo "----------------------------------------------------------------------"
27611fb744b4Smrg    fi
27621fb744b4Smrg    exit $EXIT_SUCCESS
27631fb744b4Smrg}
2764c35d236eSmrg
27651fb744b4Smrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"}
2766c35d236eSmrg
2767c35d236eSmrg
27681fb744b4Smrg# func_mode_install arg...
27691fb744b4Smrgfunc_mode_install ()
27701fb744b4Smrg{
27711fb744b4Smrg    $opt_debug
27721fb744b4Smrg    # There may be an optional sh(1) argument at the beginning of
27731fb744b4Smrg    # install_prog (especially on Windows NT).
27741fb744b4Smrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
27751fb744b4Smrg       # Allow the use of GNU shtool's install command.
27761fb744b4Smrg       case $nonopt in *shtool*) :;; *) false;; esac; then
27771fb744b4Smrg      # Aesthetically quote it.
27781fb744b4Smrg      func_quote_for_eval "$nonopt"
27791fb744b4Smrg      install_prog="$func_quote_for_eval_result "
27801fb744b4Smrg      arg=$1
27811fb744b4Smrg      shift
27821fb744b4Smrg    else
27831fb744b4Smrg      install_prog=
27841fb744b4Smrg      arg=$nonopt
27851fb744b4Smrg    fi
27861fb744b4Smrg
27871fb744b4Smrg    # The real first argument should be the name of the installation program.
27881fb744b4Smrg    # Aesthetically quote it.
27891fb744b4Smrg    func_quote_for_eval "$arg"
27901fb744b4Smrg    func_append install_prog "$func_quote_for_eval_result"
27911fb744b4Smrg    install_shared_prog=$install_prog
27921fb744b4Smrg    case " $install_prog " in
27931fb744b4Smrg      *[\\\ /]cp\ *) install_cp=: ;;
27941fb744b4Smrg      *) install_cp=false ;;
27951fb744b4Smrg    esac
27961fb744b4Smrg
27971fb744b4Smrg    # We need to accept at least all the BSD install flags.
27981fb744b4Smrg    dest=
27991fb744b4Smrg    files=
28001fb744b4Smrg    opts=
28011fb744b4Smrg    prev=
28021fb744b4Smrg    install_type=
28031fb744b4Smrg    isdir=no
28041fb744b4Smrg    stripme=
28051fb744b4Smrg    no_mode=:
28061fb744b4Smrg    for arg
28071fb744b4Smrg    do
28081fb744b4Smrg      arg2=
28091fb744b4Smrg      if test -n "$dest"; then
28101fb744b4Smrg	func_append files " $dest"
28111fb744b4Smrg	dest=$arg
28121fb744b4Smrg	continue
28131fb744b4Smrg      fi
28141fb744b4Smrg
28151fb744b4Smrg      case $arg in
28161fb744b4Smrg      -d) isdir=yes ;;
28171fb744b4Smrg      -f)
28181fb744b4Smrg	if $install_cp; then :; else
28191fb744b4Smrg	  prev=$arg
28201fb744b4Smrg	fi
28211fb744b4Smrg	;;
28221fb744b4Smrg      -g | -m | -o)
28231fb744b4Smrg	prev=$arg
28241fb744b4Smrg	;;
28251fb744b4Smrg      -s)
28261fb744b4Smrg	stripme=" -s"
28271fb744b4Smrg	continue
28281fb744b4Smrg	;;
28291fb744b4Smrg      -*)
28301fb744b4Smrg	;;
28311fb744b4Smrg      *)
28321fb744b4Smrg	# If the previous option needed an argument, then skip it.
28331fb744b4Smrg	if test -n "$prev"; then
28341fb744b4Smrg	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
28351fb744b4Smrg	    arg2=$install_override_mode
28361fb744b4Smrg	    no_mode=false
2837518bcf38Smrg	  fi
28381fb744b4Smrg	  prev=
28391fb744b4Smrg	else
28401fb744b4Smrg	  dest=$arg
2841518bcf38Smrg	  continue
2842518bcf38Smrg	fi
28431fb744b4Smrg	;;
28441fb744b4Smrg      esac
2845c35d236eSmrg
28461fb744b4Smrg      # Aesthetically quote the argument.
28471fb744b4Smrg      func_quote_for_eval "$arg"
28481fb744b4Smrg      func_append install_prog " $func_quote_for_eval_result"
28491fb744b4Smrg      if test -n "$arg2"; then
28501fb744b4Smrg	func_quote_for_eval "$arg2"
28511fb744b4Smrg      fi
28521fb744b4Smrg      func_append install_shared_prog " $func_quote_for_eval_result"
28531fb744b4Smrg    done
2854c35d236eSmrg
28551fb744b4Smrg    test -z "$install_prog" && \
28561fb744b4Smrg      func_fatal_help "you must specify an install program"
2857c35d236eSmrg
28581fb744b4Smrg    test -n "$prev" && \
28591fb744b4Smrg      func_fatal_help "the \`$prev' option requires an argument"
2860c35d236eSmrg
28611fb744b4Smrg    if test -n "$install_override_mode" && $no_mode; then
28621fb744b4Smrg      if $install_cp; then :; else
28631fb744b4Smrg	func_quote_for_eval "$install_override_mode"
28641fb744b4Smrg	func_append install_shared_prog " -m $func_quote_for_eval_result"
28651fb744b4Smrg      fi
28661fb744b4Smrg    fi
2867c35d236eSmrg
28681fb744b4Smrg    if test -z "$files"; then
28691fb744b4Smrg      if test -z "$dest"; then
28701fb744b4Smrg	func_fatal_help "no file or destination specified"
28711fb744b4Smrg      else
28721fb744b4Smrg	func_fatal_help "you must specify a destination"
28731fb744b4Smrg      fi
28741fb744b4Smrg    fi
2875c35d236eSmrg
28761fb744b4Smrg    # Strip any trailing slash from the destination.
28771fb744b4Smrg    func_stripname '' '/' "$dest"
28781fb744b4Smrg    dest=$func_stripname_result
2879c35d236eSmrg
28801fb744b4Smrg    # Check to see that the destination is a directory.
28811fb744b4Smrg    test -d "$dest" && isdir=yes
28821fb744b4Smrg    if test "$isdir" = yes; then
28831fb744b4Smrg      destdir="$dest"
28841fb744b4Smrg      destname=
28851fb744b4Smrg    else
28861fb744b4Smrg      func_dirname_and_basename "$dest" "" "."
28871fb744b4Smrg      destdir="$func_dirname_result"
28881fb744b4Smrg      destname="$func_basename_result"
2889c35d236eSmrg
28901fb744b4Smrg      # Not a directory, so check to see that there is only one file specified.
28911fb744b4Smrg      set dummy $files; shift
28921fb744b4Smrg      test "$#" -gt 1 && \
28931fb744b4Smrg	func_fatal_help "\`$dest' is not a directory"
28941fb744b4Smrg    fi
28951fb744b4Smrg    case $destdir in
28961fb744b4Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
28971fb744b4Smrg    *)
28981fb744b4Smrg      for file in $files; do
28991fb744b4Smrg	case $file in
29001fb744b4Smrg	*.lo) ;;
29011fb744b4Smrg	*)
29021fb744b4Smrg	  func_fatal_help "\`$destdir' must be an absolute directory name"
29031fb744b4Smrg	  ;;
29041fb744b4Smrg	esac
29051fb744b4Smrg      done
29061fb744b4Smrg      ;;
29071fb744b4Smrg    esac
2908c35d236eSmrg
29091fb744b4Smrg    # This variable tells wrapper scripts just to set variables rather
29101fb744b4Smrg    # than running their programs.
29111fb744b4Smrg    libtool_install_magic="$magic"
2912c35d236eSmrg
29131fb744b4Smrg    staticlibs=
29141fb744b4Smrg    future_libdirs=
29151fb744b4Smrg    current_libdirs=
29161fb744b4Smrg    for file in $files; do
2917c35d236eSmrg
29181fb744b4Smrg      # Do each installation.
29191fb744b4Smrg      case $file in
29201fb744b4Smrg      *.$libext)
29211fb744b4Smrg	# Do the static libraries later.
29221fb744b4Smrg	func_append staticlibs " $file"
29231fb744b4Smrg	;;
2924c35d236eSmrg
29251fb744b4Smrg      *.la)
29261fb744b4Smrg	func_resolve_sysroot "$file"
29271fb744b4Smrg	file=$func_resolve_sysroot_result
2928c35d236eSmrg
29291fb744b4Smrg	# Check to see that this really is a libtool archive.
29301fb744b4Smrg	func_lalib_unsafe_p "$file" \
29311fb744b4Smrg	  || func_fatal_help "\`$file' is not a valid libtool archive"
2932c35d236eSmrg
29331fb744b4Smrg	library_names=
29341fb744b4Smrg	old_library=
29351fb744b4Smrg	relink_command=
29361fb744b4Smrg	func_source "$file"
2937c35d236eSmrg
29381fb744b4Smrg	# Add the libdir to current_libdirs if it is the destination.
29391fb744b4Smrg	if test "X$destdir" = "X$libdir"; then
29401fb744b4Smrg	  case "$current_libdirs " in
29411fb744b4Smrg	  *" $libdir "*) ;;
29421fb744b4Smrg	  *) func_append current_libdirs " $libdir" ;;
29431fb744b4Smrg	  esac
29441fb744b4Smrg	else
29451fb744b4Smrg	  # Note the libdir as a future libdir.
29461fb744b4Smrg	  case "$future_libdirs " in
29471fb744b4Smrg	  *" $libdir "*) ;;
29481fb744b4Smrg	  *) func_append future_libdirs " $libdir" ;;
29491fb744b4Smrg	  esac
29501fb744b4Smrg	fi
2951c35d236eSmrg
29521fb744b4Smrg	func_dirname "$file" "/" ""
29531fb744b4Smrg	dir="$func_dirname_result"
29541fb744b4Smrg	func_append dir "$objdir"
2955f55e6a01Smrg
29561fb744b4Smrg	if test -n "$relink_command"; then
29571fb744b4Smrg	  # Determine the prefix the user has applied to our future dir.
29581fb744b4Smrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
2959f55e6a01Smrg
29601fb744b4Smrg	  # Don't allow the user to place us outside of our expected
29611fb744b4Smrg	  # location b/c this prevents finding dependent libraries that
29621fb744b4Smrg	  # are installed to the same prefix.
29631fb744b4Smrg	  # At present, this check doesn't affect windows .dll's that
29641fb744b4Smrg	  # are installed into $libdir/../bin (currently, that works fine)
29651fb744b4Smrg	  # but it's something to keep an eye on.
29661fb744b4Smrg	  test "$inst_prefix_dir" = "$destdir" && \
29671fb744b4Smrg	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
29681fb744b4Smrg
29691fb744b4Smrg	  if test -n "$inst_prefix_dir"; then
29701fb744b4Smrg	    # Stick the inst_prefix_dir data into the link command.
29711fb744b4Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2972518bcf38Smrg	  else
29731fb744b4Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
2974518bcf38Smrg	  fi
2975f55e6a01Smrg
29761fb744b4Smrg	  func_warning "relinking \`$file'"
29771fb744b4Smrg	  func_show_eval "$relink_command" \
29781fb744b4Smrg	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
29791fb744b4Smrg	fi
29801fb744b4Smrg
29811fb744b4Smrg	# See the names of the shared library.
29821fb744b4Smrg	set dummy $library_names; shift
29831fb744b4Smrg	if test -n "$1"; then
29841fb744b4Smrg	  realname="$1"
29851fb744b4Smrg	  shift
29861fb744b4Smrg
29871fb744b4Smrg	  srcname="$realname"
29881fb744b4Smrg	  test -n "$relink_command" && srcname="$realname"T
29891fb744b4Smrg
29901fb744b4Smrg	  # Install the shared library and build the symlinks.
29911fb744b4Smrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
29921fb744b4Smrg	      'exit $?'
29931fb744b4Smrg	  tstripme="$stripme"
29941fb744b4Smrg	  case $host_os in
29951fb744b4Smrg	  cygwin* | mingw* | pw32* | cegcc*)
29961fb744b4Smrg	    case $realname in
29971fb744b4Smrg	    *.dll.a)
29981fb744b4Smrg	      tstripme=""
29991fb744b4Smrg	      ;;
30001fb744b4Smrg	    esac
30011fb744b4Smrg	    ;;
30021fb744b4Smrg	  esac
30031fb744b4Smrg	  if test -n "$tstripme" && test -n "$striplib"; then
30041fb744b4Smrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
3005518bcf38Smrg	  fi
3006f55e6a01Smrg
30071fb744b4Smrg	  if test "$#" -gt 0; then
30081fb744b4Smrg	    # Delete the old symlinks, and create new ones.
30091fb744b4Smrg	    # Try `ln -sf' first, because the `ln' binary might depend on
30101fb744b4Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
30111fb744b4Smrg	    # so we also need to try rm && ln -s.
30121fb744b4Smrg	    for linkname
30131fb744b4Smrg	    do
30141fb744b4Smrg	      test "$linkname" != "$realname" \
30151fb744b4Smrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
3016518bcf38Smrg	    done
3017518bcf38Smrg	  fi
3018f55e6a01Smrg
30191fb744b4Smrg	  # Do each command in the postinstall commands.
30201fb744b4Smrg	  lib="$destdir/$realname"
30211fb744b4Smrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
30221fb744b4Smrg	fi
3023c35d236eSmrg
30241fb744b4Smrg	# Install the pseudo-library for information purposes.
30251fb744b4Smrg	func_basename "$file"
30261fb744b4Smrg	name="$func_basename_result"
30271fb744b4Smrg	instname="$dir/$name"i
30281fb744b4Smrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
3029518bcf38Smrg
30301fb744b4Smrg	# Maybe install the static library, too.
30311fb744b4Smrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
30321fb744b4Smrg	;;
30331fb744b4Smrg
30341fb744b4Smrg      *.lo)
30351fb744b4Smrg	# Install (i.e. copy) a libtool object.
30361fb744b4Smrg
30371fb744b4Smrg	# Figure out destination file name, if it wasn't already specified.
30381fb744b4Smrg	if test -n "$destname"; then
30391fb744b4Smrg	  destfile="$destdir/$destname"
3040518bcf38Smrg	else
30411fb744b4Smrg	  func_basename "$file"
30421fb744b4Smrg	  destfile="$func_basename_result"
30431fb744b4Smrg	  destfile="$destdir/$destfile"
3044518bcf38Smrg	fi
30451fb744b4Smrg
30461fb744b4Smrg	# Deduce the name of the destination old-style object file.
30471fb744b4Smrg	case $destfile in
30481fb744b4Smrg	*.lo)
30491fb744b4Smrg	  func_lo2o "$destfile"
30501fb744b4Smrg	  staticdest=$func_lo2o_result
30511fb744b4Smrg	  ;;
30521fb744b4Smrg	*.$objext)
30531fb744b4Smrg	  staticdest="$destfile"
30541fb744b4Smrg	  destfile=
30551fb744b4Smrg	  ;;
30561fb744b4Smrg	*)
30571fb744b4Smrg	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
3058c35d236eSmrg	  ;;
3059c35d236eSmrg	esac
3060c35d236eSmrg
30611fb744b4Smrg	# Install the libtool object if requested.
30621fb744b4Smrg	test -n "$destfile" && \
30631fb744b4Smrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
3064c35d236eSmrg
30651fb744b4Smrg	# Install the old object if enabled.
30661fb744b4Smrg	if test "$build_old_libs" = yes; then
30671fb744b4Smrg	  # Deduce the name of the old-style object file.
30681fb744b4Smrg	  func_lo2o "$file"
30691fb744b4Smrg	  staticobj=$func_lo2o_result
30701fb744b4Smrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
30711fb744b4Smrg	fi
30721fb744b4Smrg	exit $EXIT_SUCCESS
30731fb744b4Smrg	;;
3074c35d236eSmrg
30751fb744b4Smrg      *)
30761fb744b4Smrg	# Figure out destination file name, if it wasn't already specified.
30771fb744b4Smrg	if test -n "$destname"; then
30781fb744b4Smrg	  destfile="$destdir/$destname"
30791fb744b4Smrg	else
30801fb744b4Smrg	  func_basename "$file"
30811fb744b4Smrg	  destfile="$func_basename_result"
30821fb744b4Smrg	  destfile="$destdir/$destfile"
30831fb744b4Smrg	fi
3084c35d236eSmrg
30851fb744b4Smrg	# If the file is missing, and there is a .exe on the end, strip it
30861fb744b4Smrg	# because it is most likely a libtool script we actually want to
30871fb744b4Smrg	# install
30881fb744b4Smrg	stripped_ext=""
30891fb744b4Smrg	case $file in
30901fb744b4Smrg	  *.exe)
30911fb744b4Smrg	    if test ! -f "$file"; then
30921fb744b4Smrg	      func_stripname '' '.exe' "$file"
30931fb744b4Smrg	      file=$func_stripname_result
30941fb744b4Smrg	      stripped_ext=".exe"
30951fb744b4Smrg	    fi
30961fb744b4Smrg	    ;;
30971fb744b4Smrg	esac
3098c35d236eSmrg
30991fb744b4Smrg	# Do a test to see if this is really a libtool program.
31001fb744b4Smrg	case $host in
31011fb744b4Smrg	*cygwin* | *mingw*)
31021fb744b4Smrg	    if func_ltwrapper_executable_p "$file"; then
31031fb744b4Smrg	      func_ltwrapper_scriptname "$file"
31041fb744b4Smrg	      wrapper=$func_ltwrapper_scriptname_result
31051fb744b4Smrg	    else
31061fb744b4Smrg	      func_stripname '' '.exe' "$file"
31071fb744b4Smrg	      wrapper=$func_stripname_result
31081fb744b4Smrg	    fi
31091fb744b4Smrg	    ;;
31101fb744b4Smrg	*)
31111fb744b4Smrg	    wrapper=$file
31121fb744b4Smrg	    ;;
31131fb744b4Smrg	esac
31141fb744b4Smrg	if func_ltwrapper_script_p "$wrapper"; then
31151fb744b4Smrg	  notinst_deplibs=
31161fb744b4Smrg	  relink_command=
3117c35d236eSmrg
31181fb744b4Smrg	  func_source "$wrapper"
3119c35d236eSmrg
31201fb744b4Smrg	  # Check the variables that should have been set.
31211fb744b4Smrg	  test -z "$generated_by_libtool_version" && \
31221fb744b4Smrg	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
3123c35d236eSmrg
31241fb744b4Smrg	  finalize=yes
31251fb744b4Smrg	  for lib in $notinst_deplibs; do
31261fb744b4Smrg	    # Check to see that each library is installed.
31271fb744b4Smrg	    libdir=
31281fb744b4Smrg	    if test -f "$lib"; then
31291fb744b4Smrg	      func_source "$lib"
31301fb744b4Smrg	    fi
31311fb744b4Smrg	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
31321fb744b4Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
31331fb744b4Smrg	      func_warning "\`$lib' has not been installed in \`$libdir'"
31341fb744b4Smrg	      finalize=no
31351fb744b4Smrg	    fi
31361fb744b4Smrg	  done
3137c35d236eSmrg
31381fb744b4Smrg	  relink_command=
31391fb744b4Smrg	  func_source "$wrapper"
31401fb744b4Smrg
31411fb744b4Smrg	  outputname=
31421fb744b4Smrg	  if test "$fast_install" = no && test -n "$relink_command"; then
31431fb744b4Smrg	    $opt_dry_run || {
31441fb744b4Smrg	      if test "$finalize" = yes; then
31451fb744b4Smrg	        tmpdir=`func_mktempdir`
31461fb744b4Smrg		func_basename "$file$stripped_ext"
31471fb744b4Smrg		file="$func_basename_result"
31481fb744b4Smrg	        outputname="$tmpdir/$file"
31491fb744b4Smrg	        # Replace the output file specification.
31501fb744b4Smrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
31511fb744b4Smrg
31521fb744b4Smrg	        $opt_silent || {
31531fb744b4Smrg	          func_quote_for_expand "$relink_command"
31541fb744b4Smrg		  eval "func_echo $func_quote_for_expand_result"
31551fb744b4Smrg	        }
31561fb744b4Smrg	        if eval "$relink_command"; then :
31571fb744b4Smrg	          else
31581fb744b4Smrg		  func_error "error: relink \`$file' with the above command before installing it"
31591fb744b4Smrg		  $opt_dry_run || ${RM}r "$tmpdir"
31601fb744b4Smrg		  continue
31611fb744b4Smrg	        fi
31621fb744b4Smrg	        file="$outputname"
31631fb744b4Smrg	      else
31641fb744b4Smrg	        func_warning "cannot relink \`$file'"
31651fb744b4Smrg	      fi
31661fb744b4Smrg	    }
31671fb744b4Smrg	  else
31681fb744b4Smrg	    # Install the binary that we compiled earlier.
31691fb744b4Smrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
31701fb744b4Smrg	  fi
3171518bcf38Smrg	fi
31721fb744b4Smrg
31731fb744b4Smrg	# remove .exe since cygwin /usr/bin/install will append another
31741fb744b4Smrg	# one anyway
31751fb744b4Smrg	case $install_prog,$host in
31761fb744b4Smrg	*/usr/bin/install*,*cygwin*)
31771fb744b4Smrg	  case $file:$destfile in
31781fb744b4Smrg	  *.exe:*.exe)
31791fb744b4Smrg	    # this is ok
31801fb744b4Smrg	    ;;
31811fb744b4Smrg	  *.exe:*)
31821fb744b4Smrg	    destfile=$destfile.exe
31831fb744b4Smrg	    ;;
31841fb744b4Smrg	  *:*.exe)
31851fb744b4Smrg	    func_stripname '' '.exe' "$destfile"
31861fb744b4Smrg	    destfile=$func_stripname_result
31871fb744b4Smrg	    ;;
31881fb744b4Smrg	  esac
31891fb744b4Smrg	  ;;
31901fb744b4Smrg	esac
31911fb744b4Smrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
31921fb744b4Smrg	$opt_dry_run || if test -n "$outputname"; then
31931fb744b4Smrg	  ${RM}r "$tmpdir"
3194518bcf38Smrg	fi
3195518bcf38Smrg	;;
3196518bcf38Smrg      esac
31971fb744b4Smrg    done
3198c35d236eSmrg
31991fb744b4Smrg    for file in $staticlibs; do
32001fb744b4Smrg      func_basename "$file"
32011fb744b4Smrg      name="$func_basename_result"
3202f55e6a01Smrg
32031fb744b4Smrg      # Set up the ranlib parameters.
32041fb744b4Smrg      oldlib="$destdir/$name"
32051fb744b4Smrg      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
32061fb744b4Smrg      tool_oldlib=$func_to_tool_file_result
3207f55e6a01Smrg
32081fb744b4Smrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
32091fb744b4Smrg
32101fb744b4Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
32111fb744b4Smrg	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
3212518bcf38Smrg      fi
3213f55e6a01Smrg
32141fb744b4Smrg      # Do each command in the postinstall commands.
32151fb744b4Smrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
32161fb744b4Smrg    done
3217f55e6a01Smrg
32181fb744b4Smrg    test -n "$future_libdirs" && \
32191fb744b4Smrg      func_warning "remember to run \`$progname --finish$future_libdirs'"
3220f55e6a01Smrg
32211fb744b4Smrg    if test -n "$current_libdirs"; then
32221fb744b4Smrg      # Maybe just do a dry run.
32231fb744b4Smrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
32241fb744b4Smrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
32251fb744b4Smrg    else
32261fb744b4Smrg      exit $EXIT_SUCCESS
32271fb744b4Smrg    fi
32281fb744b4Smrg}
3229f55e6a01Smrg
32301fb744b4Smrgtest "$opt_mode" = install && func_mode_install ${1+"$@"}
3231f55e6a01Smrg
3232f55e6a01Smrg
32331fb744b4Smrg# func_generate_dlsyms outputname originator pic_p
32341fb744b4Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with
32351fb744b4Smrg# a dlpreopen symbol table.
32361fb744b4Smrgfunc_generate_dlsyms ()
32371fb744b4Smrg{
32381fb744b4Smrg    $opt_debug
32391fb744b4Smrg    my_outputname="$1"
32401fb744b4Smrg    my_originator="$2"
32411fb744b4Smrg    my_pic_p="${3-no}"
32421fb744b4Smrg    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
32431fb744b4Smrg    my_dlsyms=
32441fb744b4Smrg
32451fb744b4Smrg    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
32461fb744b4Smrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
32471fb744b4Smrg	my_dlsyms="${my_outputname}S.c"
32481fb744b4Smrg      else
32491fb744b4Smrg	func_error "not configured to extract global symbols from dlpreopened files"
32501fb744b4Smrg      fi
32511fb744b4Smrg    fi
3252f55e6a01Smrg
32531fb744b4Smrg    if test -n "$my_dlsyms"; then
32541fb744b4Smrg      case $my_dlsyms in
32551fb744b4Smrg      "") ;;
32561fb744b4Smrg      *.c)
32571fb744b4Smrg	# Discover the nlist of each of the dlfiles.
32581fb744b4Smrg	nlist="$output_objdir/${my_outputname}.nm"
3259f55e6a01Smrg
32601fb744b4Smrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
3261f55e6a01Smrg
32621fb744b4Smrg	# Parse the name list into a source file.
32631fb744b4Smrg	func_verbose "creating $output_objdir/$my_dlsyms"
3264f55e6a01Smrg
32651fb744b4Smrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
32661fb744b4Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
32671fb744b4Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
3268f55e6a01Smrg
32691fb744b4Smrg#ifdef __cplusplus
32701fb744b4Smrgextern \"C\" {
32711fb744b4Smrg#endif
3272f55e6a01Smrg
32731fb744b4Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
32741fb744b4Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
32751fb744b4Smrg#endif
3276f55e6a01Smrg
32771fb744b4Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
32781fb744b4Smrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
32791fb744b4Smrg/* DATA imports from DLLs on WIN32 con't be const, because runtime
32801fb744b4Smrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
32811fb744b4Smrg# define LT_DLSYM_CONST
32821fb744b4Smrg#elif defined(__osf__)
32831fb744b4Smrg/* This system does not cope well with relocations in const data.  */
32841fb744b4Smrg# define LT_DLSYM_CONST
32851fb744b4Smrg#else
32861fb744b4Smrg# define LT_DLSYM_CONST const
32871fb744b4Smrg#endif
3288f55e6a01Smrg
32891fb744b4Smrg/* External symbol declarations for the compiler. */\
32901fb744b4Smrg"
3291f55e6a01Smrg
32921fb744b4Smrg	if test "$dlself" = yes; then
32931fb744b4Smrg	  func_verbose "generating symbol list for \`$output'"
3294f55e6a01Smrg
32951fb744b4Smrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
3296c35d236eSmrg
32971fb744b4Smrg	  # Add our own program objects to the symbol list.
32981fb744b4Smrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
32991fb744b4Smrg	  for progfile in $progfiles; do
33001fb744b4Smrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
33011fb744b4Smrg	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
33021fb744b4Smrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
3303518bcf38Smrg	  done
3304c35d236eSmrg
33051fb744b4Smrg	  if test -n "$exclude_expsyms"; then
33061fb744b4Smrg	    $opt_dry_run || {
33071fb744b4Smrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
33081fb744b4Smrg	      eval '$MV "$nlist"T "$nlist"'
33091fb744b4Smrg	    }
33101fb744b4Smrg	  fi
3311c35d236eSmrg
33121fb744b4Smrg	  if test -n "$export_symbols_regex"; then
33131fb744b4Smrg	    $opt_dry_run || {
33141fb744b4Smrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
33151fb744b4Smrg	      eval '$MV "$nlist"T "$nlist"'
33161fb744b4Smrg	    }
33171fb744b4Smrg	  fi
3318c35d236eSmrg
33191fb744b4Smrg	  # Prepare the list of exported symbols
33201fb744b4Smrg	  if test -z "$export_symbols"; then
33211fb744b4Smrg	    export_symbols="$output_objdir/$outputname.exp"
33221fb744b4Smrg	    $opt_dry_run || {
33231fb744b4Smrg	      $RM $export_symbols
33241fb744b4Smrg	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
33251fb744b4Smrg	      case $host in
33261fb744b4Smrg	      *cygwin* | *mingw* | *cegcc* )
33271fb744b4Smrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
33281fb744b4Smrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
33291fb744b4Smrg	        ;;
33301fb744b4Smrg	      esac
33311fb744b4Smrg	    }
33321fb744b4Smrg	  else
33331fb744b4Smrg	    $opt_dry_run || {
33341fb744b4Smrg	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
33351fb744b4Smrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
33361fb744b4Smrg	      eval '$MV "$nlist"T "$nlist"'
33371fb744b4Smrg	      case $host in
33381fb744b4Smrg	        *cygwin* | *mingw* | *cegcc* )
33391fb744b4Smrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
33401fb744b4Smrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
33411fb744b4Smrg	          ;;
33421fb744b4Smrg	      esac
33431fb744b4Smrg	    }
33441fb744b4Smrg	  fi
33451fb744b4Smrg	fi
3346c35d236eSmrg
33471fb744b4Smrg	for dlprefile in $dlprefiles; do
33481fb744b4Smrg	  func_verbose "extracting global C symbols from \`$dlprefile'"
33491fb744b4Smrg	  func_basename "$dlprefile"
33501fb744b4Smrg	  name="$func_basename_result"
33511fb744b4Smrg          case $host in
33521fb744b4Smrg	    *cygwin* | *mingw* | *cegcc* )
33531fb744b4Smrg	      # if an import library, we need to obtain dlname
33541fb744b4Smrg	      if func_win32_import_lib_p "$dlprefile"; then
33551fb744b4Smrg	        func_tr_sh "$dlprefile"
33561fb744b4Smrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
33571fb744b4Smrg	        dlprefile_dlbasename=""
33581fb744b4Smrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
33591fb744b4Smrg	          # Use subshell, to avoid clobbering current variable values
33601fb744b4Smrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
33611fb744b4Smrg	          if test -n "$dlprefile_dlname" ; then
33621fb744b4Smrg	            func_basename "$dlprefile_dlname"
33631fb744b4Smrg	            dlprefile_dlbasename="$func_basename_result"
33641fb744b4Smrg	          else
33651fb744b4Smrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
33661fb744b4Smrg	            $sharedlib_from_linklib_cmd "$dlprefile"
33671fb744b4Smrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
33681fb744b4Smrg	          fi
33691fb744b4Smrg	        fi
33701fb744b4Smrg	        $opt_dry_run || {
33711fb744b4Smrg	          if test -n "$dlprefile_dlbasename" ; then
33721fb744b4Smrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
33731fb744b4Smrg	          else
33741fb744b4Smrg	            func_warning "Could not compute DLL name from $name"
33751fb744b4Smrg	            eval '$ECHO ": $name " >> "$nlist"'
33761fb744b4Smrg	          fi
33771fb744b4Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
33781fb744b4Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
33791fb744b4Smrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
33801fb744b4Smrg	        }
33811fb744b4Smrg	      else # not an import lib
33821fb744b4Smrg	        $opt_dry_run || {
33831fb744b4Smrg	          eval '$ECHO ": $name " >> "$nlist"'
33841fb744b4Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
33851fb744b4Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
33861fb744b4Smrg	        }
33871fb744b4Smrg	      fi
33881fb744b4Smrg	    ;;
33891fb744b4Smrg	    *)
33901fb744b4Smrg	      $opt_dry_run || {
33911fb744b4Smrg	        eval '$ECHO ": $name " >> "$nlist"'
33921fb744b4Smrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
33931fb744b4Smrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
33941fb744b4Smrg	      }
33951fb744b4Smrg	    ;;
33961fb744b4Smrg          esac
33971fb744b4Smrg	done
3398c35d236eSmrg
33991fb744b4Smrg	$opt_dry_run || {
34001fb744b4Smrg	  # Make sure we have at least an empty file.
34011fb744b4Smrg	  test -f "$nlist" || : > "$nlist"
3402c35d236eSmrg
34031fb744b4Smrg	  if test -n "$exclude_expsyms"; then
34041fb744b4Smrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
34051fb744b4Smrg	    $MV "$nlist"T "$nlist"
34061fb744b4Smrg	  fi
3407c35d236eSmrg
34081fb744b4Smrg	  # Try sorting and uniquifying the output.
34091fb744b4Smrg	  if $GREP -v "^: " < "$nlist" |
34101fb744b4Smrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
34111fb744b4Smrg		sort -k 3
34121fb744b4Smrg	      else
34131fb744b4Smrg		sort +2
34141fb744b4Smrg	      fi |
34151fb744b4Smrg	      uniq > "$nlist"S; then
34161fb744b4Smrg	    :
34171fb744b4Smrg	  else
34181fb744b4Smrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
34191fb744b4Smrg	  fi
3420c35d236eSmrg
34211fb744b4Smrg	  if test -f "$nlist"S; then
34221fb744b4Smrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
34231fb744b4Smrg	  else
34241fb744b4Smrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
34251fb744b4Smrg	  fi
3426c35d236eSmrg
34271fb744b4Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
34281fb744b4Smrg
34291fb744b4Smrg/* The mapping between symbol names and symbols.  */
34301fb744b4Smrgtypedef struct {
34311fb744b4Smrg  const char *name;
34321fb744b4Smrg  void *address;
34331fb744b4Smrg} lt_dlsymlist;
34341fb744b4Smrgextern LT_DLSYM_CONST lt_dlsymlist
34351fb744b4Smrglt_${my_prefix}_LTX_preloaded_symbols[];
34361fb744b4SmrgLT_DLSYM_CONST lt_dlsymlist
34371fb744b4Smrglt_${my_prefix}_LTX_preloaded_symbols[] =
34381fb744b4Smrg{\
34391fb744b4Smrg  { \"$my_originator\", (void *) 0 },"
34401fb744b4Smrg
34411fb744b4Smrg	  case $need_lib_prefix in
34421fb744b4Smrg	  no)
34431fb744b4Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
3444f55e6a01Smrg	    ;;
3445518bcf38Smrg	  *)
34461fb744b4Smrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
3447518bcf38Smrg	    ;;
3448518bcf38Smrg	  esac
34491fb744b4Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
34501fb744b4Smrg  {0, (void *) 0}
34511fb744b4Smrg};
3452c35d236eSmrg
34531fb744b4Smrg/* This works around a problem in FreeBSD linker */
34541fb744b4Smrg#ifdef FREEBSD_WORKAROUND
34551fb744b4Smrgstatic const void *lt_preloaded_setup() {
34561fb744b4Smrg  return lt_${my_prefix}_LTX_preloaded_symbols;
34571fb744b4Smrg}
34581fb744b4Smrg#endif
3459c35d236eSmrg
34601fb744b4Smrg#ifdef __cplusplus
34611fb744b4Smrg}
34621fb744b4Smrg#endif\
34631fb744b4Smrg"
34641fb744b4Smrg	} # !$opt_dry_run
3465c35d236eSmrg
34661fb744b4Smrg	pic_flag_for_symtable=
34671fb744b4Smrg	case "$compile_command " in
34681fb744b4Smrg	*" -static "*) ;;
34691fb744b4Smrg	*)
34701fb744b4Smrg	  case $host in
34711fb744b4Smrg	  # compiling the symbol table file with pic_flag works around
34721fb744b4Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
34731fb744b4Smrg	  # linked before any other PIC object.  But we must not use
34741fb744b4Smrg	  # pic_flag when linking with -static.  The problem exists in
34751fb744b4Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
34761fb744b4Smrg	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
34771fb744b4Smrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
34781fb744b4Smrg	  *-*-hpux*)
34791fb744b4Smrg	    pic_flag_for_symtable=" $pic_flag"  ;;
34801fb744b4Smrg	  *)
34811fb744b4Smrg	    if test "X$my_pic_p" != Xno; then
34821fb744b4Smrg	      pic_flag_for_symtable=" $pic_flag"
34831fb744b4Smrg	    fi
34841fb744b4Smrg	    ;;
34851fb744b4Smrg	  esac
34861fb744b4Smrg	  ;;
34871fb744b4Smrg	esac
34881fb744b4Smrg	symtab_cflags=
34891fb744b4Smrg	for arg in $LTCFLAGS; do
34901fb744b4Smrg	  case $arg in
34911fb744b4Smrg	  -pie | -fpie | -fPIE) ;;
34921fb744b4Smrg	  *) func_append symtab_cflags " $arg" ;;
3493518bcf38Smrg	  esac
3494518bcf38Smrg	done
3495c35d236eSmrg
34961fb744b4Smrg	# Now compile the dynamic symbol file.
34971fb744b4Smrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
3498c35d236eSmrg
34991fb744b4Smrg	# Clean up the generated files.
35001fb744b4Smrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
3501c35d236eSmrg
35021fb744b4Smrg	# Transform the symbol file into the correct name.
35031fb744b4Smrg	symfileobj="$output_objdir/${my_outputname}S.$objext"
35041fb744b4Smrg	case $host in
35051fb744b4Smrg	*cygwin* | *mingw* | *cegcc* )
35061fb744b4Smrg	  if test -f "$output_objdir/$my_outputname.def"; then
35071fb744b4Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
35081fb744b4Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
35091fb744b4Smrg	  else
35101fb744b4Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
35111fb744b4Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
35121fb744b4Smrg	  fi
35131fb744b4Smrg	  ;;
35141fb744b4Smrg	*)
35151fb744b4Smrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
35161fb744b4Smrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
35171fb744b4Smrg	  ;;
35181fb744b4Smrg	esac
35191fb744b4Smrg	;;
35201fb744b4Smrg      *)
35211fb744b4Smrg	func_fatal_error "unknown suffix for \`$my_dlsyms'"
35221fb744b4Smrg	;;
35231fb744b4Smrg      esac
35241fb744b4Smrg    else
35251fb744b4Smrg      # We keep going just in case the user didn't refer to
35261fb744b4Smrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
35271fb744b4Smrg      # really was required.
3528c35d236eSmrg
35291fb744b4Smrg      # Nullify the symbol file.
35301fb744b4Smrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
35311fb744b4Smrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
35321fb744b4Smrg    fi
35331fb744b4Smrg}
3534c35d236eSmrg
35351fb744b4Smrg# func_win32_libid arg
35361fb744b4Smrg# return the library type of file 'arg'
35371fb744b4Smrg#
35381fb744b4Smrg# Need a lot of goo to handle *both* DLLs and import libs
35391fb744b4Smrg# Has to be a shell function in order to 'eat' the argument
35401fb744b4Smrg# that is supplied when $file_magic_command is called.
35411fb744b4Smrg# Despite the name, also deal with 64 bit binaries.
35421fb744b4Smrgfunc_win32_libid ()
35431fb744b4Smrg{
35441fb744b4Smrg  $opt_debug
35451fb744b4Smrg  win32_libid_type="unknown"
35461fb744b4Smrg  win32_fileres=`file -L $1 2>/dev/null`
35471fb744b4Smrg  case $win32_fileres in
35481fb744b4Smrg  *ar\ archive\ import\ library*) # definitely import
35491fb744b4Smrg    win32_libid_type="x86 archive import"
35501fb744b4Smrg    ;;
35511fb744b4Smrg  *ar\ archive*) # could be an import, or static
35521fb744b4Smrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
35531fb744b4Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
35541fb744b4Smrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
35551fb744b4Smrg      func_to_tool_file "$1" func_convert_file_msys_to_w32
35561fb744b4Smrg      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
35571fb744b4Smrg	$SED -n -e '
35581fb744b4Smrg	    1,100{
35591fb744b4Smrg		/ I /{
35601fb744b4Smrg		    s,.*,import,
35611fb744b4Smrg		    p
35621fb744b4Smrg		    q
35631fb744b4Smrg		}
35641fb744b4Smrg	    }'`
35651fb744b4Smrg      case $win32_nmres in
35661fb744b4Smrg      import*)  win32_libid_type="x86 archive import";;
35671fb744b4Smrg      *)        win32_libid_type="x86 archive static";;
35681fb744b4Smrg      esac
35691fb744b4Smrg    fi
35701fb744b4Smrg    ;;
35711fb744b4Smrg  *DLL*)
35721fb744b4Smrg    win32_libid_type="x86 DLL"
35731fb744b4Smrg    ;;
35741fb744b4Smrg  *executable*) # but shell scripts are "executable" too...
35751fb744b4Smrg    case $win32_fileres in
35761fb744b4Smrg    *MS\ Windows\ PE\ Intel*)
35771fb744b4Smrg      win32_libid_type="x86 DLL"
35781fb744b4Smrg      ;;
35791fb744b4Smrg    esac
35801fb744b4Smrg    ;;
35811fb744b4Smrg  esac
35821fb744b4Smrg  $ECHO "$win32_libid_type"
35831fb744b4Smrg}
35841fb744b4Smrg
35851fb744b4Smrg# func_cygming_dll_for_implib ARG
35861fb744b4Smrg#
35871fb744b4Smrg# Platform-specific function to extract the
35881fb744b4Smrg# name of the DLL associated with the specified
35891fb744b4Smrg# import library ARG.
35901fb744b4Smrg# Invoked by eval'ing the libtool variable
35911fb744b4Smrg#    $sharedlib_from_linklib_cmd
35921fb744b4Smrg# Result is available in the variable
35931fb744b4Smrg#    $sharedlib_from_linklib_result
35941fb744b4Smrgfunc_cygming_dll_for_implib ()
35951fb744b4Smrg{
35961fb744b4Smrg  $opt_debug
35971fb744b4Smrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
35981fb744b4Smrg}
35991fb744b4Smrg
36001fb744b4Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
36011fb744b4Smrg#
36021fb744b4Smrg# The is the core of a fallback implementation of a
36031fb744b4Smrg# platform-specific function to extract the name of the
36041fb744b4Smrg# DLL associated with the specified import library LIBNAME.
36051fb744b4Smrg#
36061fb744b4Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending
36071fb744b4Smrg# on the platform and compiler that created the implib.
36081fb744b4Smrg#
36091fb744b4Smrg# Echos the name of the DLL associated with the
36101fb744b4Smrg# specified import library.
36111fb744b4Smrgfunc_cygming_dll_for_implib_fallback_core ()
36121fb744b4Smrg{
36131fb744b4Smrg  $opt_debug
36141fb744b4Smrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
36151fb744b4Smrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
36161fb744b4Smrg    $SED '/^Contents of section '"$match_literal"':/{
36171fb744b4Smrg      # Place marker at beginning of archive member dllname section
36181fb744b4Smrg      s/.*/====MARK====/
36191fb744b4Smrg      p
36201fb744b4Smrg      d
36211fb744b4Smrg    }
36221fb744b4Smrg    # These lines can sometimes be longer than 43 characters, but
36231fb744b4Smrg    # are always uninteresting
36241fb744b4Smrg    /:[	 ]*file format pe[i]\{,1\}-/d
36251fb744b4Smrg    /^In archive [^:]*:/d
36261fb744b4Smrg    # Ensure marker is printed
36271fb744b4Smrg    /^====MARK====/p
36281fb744b4Smrg    # Remove all lines with less than 43 characters
36291fb744b4Smrg    /^.\{43\}/!d
36301fb744b4Smrg    # From remaining lines, remove first 43 characters
36311fb744b4Smrg    s/^.\{43\}//' |
36321fb744b4Smrg    $SED -n '
36331fb744b4Smrg      # Join marker and all lines until next marker into a single line
36341fb744b4Smrg      /^====MARK====/ b para
36351fb744b4Smrg      H
36361fb744b4Smrg      $ b para
36371fb744b4Smrg      b
36381fb744b4Smrg      :para
36391fb744b4Smrg      x
36401fb744b4Smrg      s/\n//g
36411fb744b4Smrg      # Remove the marker
36421fb744b4Smrg      s/^====MARK====//
36431fb744b4Smrg      # Remove trailing dots and whitespace
36441fb744b4Smrg      s/[\. \t]*$//
36451fb744b4Smrg      # Print
36461fb744b4Smrg      /./p' |
36471fb744b4Smrg    # we now have a list, one entry per line, of the stringified
36481fb744b4Smrg    # contents of the appropriate section of all members of the
36491fb744b4Smrg    # archive which possess that section. Heuristic: eliminate
36501fb744b4Smrg    # all those which have a first or second character that is
36511fb744b4Smrg    # a '.' (that is, objdump's representation of an unprintable
36521fb744b4Smrg    # character.) This should work for all archives with less than
36531fb744b4Smrg    # 0x302f exports -- but will fail for DLLs whose name actually
36541fb744b4Smrg    # begins with a literal '.' or a single character followed by
36551fb744b4Smrg    # a '.'.
36561fb744b4Smrg    #
36571fb744b4Smrg    # Of those that remain, print the first one.
36581fb744b4Smrg    $SED -e '/^\./d;/^.\./d;q'
36591fb744b4Smrg}
36601fb744b4Smrg
36611fb744b4Smrg# func_cygming_gnu_implib_p ARG
36621fb744b4Smrg# This predicate returns with zero status (TRUE) if
36631fb744b4Smrg# ARG is a GNU/binutils-style import library. Returns
36641fb744b4Smrg# with nonzero status (FALSE) otherwise.
36651fb744b4Smrgfunc_cygming_gnu_implib_p ()
36661fb744b4Smrg{
36671fb744b4Smrg  $opt_debug
36681fb744b4Smrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
36691fb744b4Smrg  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)$'`
36701fb744b4Smrg  test -n "$func_cygming_gnu_implib_tmp"
36711fb744b4Smrg}
36721fb744b4Smrg
36731fb744b4Smrg# func_cygming_ms_implib_p ARG
36741fb744b4Smrg# This predicate returns with zero status (TRUE) if
36751fb744b4Smrg# ARG is an MS-style import library. Returns
36761fb744b4Smrg# with nonzero status (FALSE) otherwise.
36771fb744b4Smrgfunc_cygming_ms_implib_p ()
36781fb744b4Smrg{
36791fb744b4Smrg  $opt_debug
36801fb744b4Smrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
36811fb744b4Smrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
36821fb744b4Smrg  test -n "$func_cygming_ms_implib_tmp"
36831fb744b4Smrg}
36841fb744b4Smrg
36851fb744b4Smrg# func_cygming_dll_for_implib_fallback ARG
36861fb744b4Smrg# Platform-specific function to extract the
36871fb744b4Smrg# name of the DLL associated with the specified
36881fb744b4Smrg# import library ARG.
36891fb744b4Smrg#
36901fb744b4Smrg# This fallback implementation is for use when $DLLTOOL
36911fb744b4Smrg# does not support the --identify-strict option.
36921fb744b4Smrg# Invoked by eval'ing the libtool variable
36931fb744b4Smrg#    $sharedlib_from_linklib_cmd
36941fb744b4Smrg# Result is available in the variable
36951fb744b4Smrg#    $sharedlib_from_linklib_result
36961fb744b4Smrgfunc_cygming_dll_for_implib_fallback ()
36971fb744b4Smrg{
36981fb744b4Smrg  $opt_debug
36991fb744b4Smrg  if func_cygming_gnu_implib_p "$1" ; then
37001fb744b4Smrg    # binutils import library
37011fb744b4Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
37021fb744b4Smrg  elif func_cygming_ms_implib_p "$1" ; then
37031fb744b4Smrg    # ms-generated import library
37041fb744b4Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
37051fb744b4Smrg  else
37061fb744b4Smrg    # unknown
37071fb744b4Smrg    sharedlib_from_linklib_result=""
37081fb744b4Smrg  fi
37091fb744b4Smrg}
37101fb744b4Smrg
37111fb744b4Smrg
37121fb744b4Smrg# func_extract_an_archive dir oldlib
37131fb744b4Smrgfunc_extract_an_archive ()
37141fb744b4Smrg{
37151fb744b4Smrg    $opt_debug
37161fb744b4Smrg    f_ex_an_ar_dir="$1"; shift
37171fb744b4Smrg    f_ex_an_ar_oldlib="$1"
37181fb744b4Smrg    if test "$lock_old_archive_extraction" = yes; then
37191fb744b4Smrg      lockfile=$f_ex_an_ar_oldlib.lock
37201fb744b4Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
37211fb744b4Smrg	func_echo "Waiting for $lockfile to be removed"
37221fb744b4Smrg	sleep 2
3723518bcf38Smrg      done
37241fb744b4Smrg    fi
37251fb744b4Smrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
37261fb744b4Smrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
37271fb744b4Smrg    if test "$lock_old_archive_extraction" = yes; then
37281fb744b4Smrg      $opt_dry_run || rm -f "$lockfile"
37291fb744b4Smrg    fi
37301fb744b4Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
37311fb744b4Smrg     :
37321fb744b4Smrg    else
37331fb744b4Smrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
37341fb744b4Smrg    fi
37351fb744b4Smrg}
3736c35d236eSmrg
37371fb744b4Smrg
37381fb744b4Smrg# func_extract_archives gentop oldlib ...
37391fb744b4Smrgfunc_extract_archives ()
37401fb744b4Smrg{
37411fb744b4Smrg    $opt_debug
37421fb744b4Smrg    my_gentop="$1"; shift
37431fb744b4Smrg    my_oldlibs=${1+"$@"}
37441fb744b4Smrg    my_oldobjs=""
37451fb744b4Smrg    my_xlib=""
37461fb744b4Smrg    my_xabs=""
37471fb744b4Smrg    my_xdir=""
37481fb744b4Smrg
37491fb744b4Smrg    for my_xlib in $my_oldlibs; do
37501fb744b4Smrg      # Extract the objects.
37511fb744b4Smrg      case $my_xlib in
37521fb744b4Smrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
37531fb744b4Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
37541fb744b4Smrg      esac
37551fb744b4Smrg      func_basename "$my_xlib"
37561fb744b4Smrg      my_xlib="$func_basename_result"
37571fb744b4Smrg      my_xlib_u=$my_xlib
37581fb744b4Smrg      while :; do
37591fb744b4Smrg        case " $extracted_archives " in
37601fb744b4Smrg	*" $my_xlib_u "*)
37611fb744b4Smrg	  func_arith $extracted_serial + 1
37621fb744b4Smrg	  extracted_serial=$func_arith_result
37631fb744b4Smrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
37641fb744b4Smrg	*) break ;;
3765518bcf38Smrg	esac
3766518bcf38Smrg      done
37671fb744b4Smrg      extracted_archives="$extracted_archives $my_xlib_u"
37681fb744b4Smrg      my_xdir="$my_gentop/$my_xlib_u"
3769c35d236eSmrg
37701fb744b4Smrg      func_mkdir_p "$my_xdir"
3771c35d236eSmrg
37721fb744b4Smrg      case $host in
37731fb744b4Smrg      *-darwin*)
37741fb744b4Smrg	func_verbose "Extracting $my_xabs"
37751fb744b4Smrg	# Do not bother doing anything if just a dry run
37761fb744b4Smrg	$opt_dry_run || {
37771fb744b4Smrg	  darwin_orig_dir=`pwd`
37781fb744b4Smrg	  cd $my_xdir || exit $?
37791fb744b4Smrg	  darwin_archive=$my_xabs
37801fb744b4Smrg	  darwin_curdir=`pwd`
37811fb744b4Smrg	  darwin_base_archive=`basename "$darwin_archive"`
37821fb744b4Smrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
37831fb744b4Smrg	  if test -n "$darwin_arches"; then
37841fb744b4Smrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
37851fb744b4Smrg	    darwin_arch=
37861fb744b4Smrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
37871fb744b4Smrg	    for darwin_arch in  $darwin_arches ; do
37881fb744b4Smrg	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
37891fb744b4Smrg	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
37901fb744b4Smrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
37911fb744b4Smrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
37921fb744b4Smrg	      cd "$darwin_curdir"
37931fb744b4Smrg	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
37941fb744b4Smrg	    done # $darwin_arches
37951fb744b4Smrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
37961fb744b4Smrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
37971fb744b4Smrg	    darwin_file=
37981fb744b4Smrg	    darwin_files=
37991fb744b4Smrg	    for darwin_file in $darwin_filelist; do
38001fb744b4Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
38011fb744b4Smrg	      $LIPO -create -output "$darwin_file" $darwin_files
38021fb744b4Smrg	    done # $darwin_filelist
38031fb744b4Smrg	    $RM -rf unfat-$$
38041fb744b4Smrg	    cd "$darwin_orig_dir"
3805518bcf38Smrg	  else
38061fb744b4Smrg	    cd $darwin_orig_dir
38071fb744b4Smrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
38081fb744b4Smrg	  fi # $darwin_arches
38091fb744b4Smrg	} # !$opt_dry_run
38101fb744b4Smrg	;;
38111fb744b4Smrg      *)
38121fb744b4Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
38131fb744b4Smrg	;;
38141fb744b4Smrg      esac
38151fb744b4Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
38161fb744b4Smrg    done
3817c35d236eSmrg
38181fb744b4Smrg    func_extract_archives_result="$my_oldobjs"
38191fb744b4Smrg}
3820c35d236eSmrg
3821c35d236eSmrg
38221fb744b4Smrg# func_emit_wrapper [arg=no]
38231fb744b4Smrg#
38241fb744b4Smrg# Emit a libtool wrapper script on stdout.
38251fb744b4Smrg# Don't directly open a file because we may want to
38261fb744b4Smrg# incorporate the script contents within a cygwin/mingw
38271fb744b4Smrg# wrapper executable.  Must ONLY be called from within
38281fb744b4Smrg# func_mode_link because it depends on a number of variables
38291fb744b4Smrg# set therein.
38301fb744b4Smrg#
38311fb744b4Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
38321fb744b4Smrg# variable will take.  If 'yes', then the emitted script
38331fb744b4Smrg# will assume that the directory in which it is stored is
38341fb744b4Smrg# the $objdir directory.  This is a cygwin/mingw-specific
38351fb744b4Smrg# behavior.
38361fb744b4Smrgfunc_emit_wrapper ()
38371fb744b4Smrg{
38381fb744b4Smrg	func_emit_wrapper_arg1=${1-no}
3839c35d236eSmrg
38401fb744b4Smrg	$ECHO "\
38411fb744b4Smrg#! $SHELL
3842c35d236eSmrg
38431fb744b4Smrg# $output - temporary wrapper script for $objdir/$outputname
38441fb744b4Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
38451fb744b4Smrg#
38461fb744b4Smrg# The $output program cannot be directly executed until all the libtool
38471fb744b4Smrg# libraries that it depends on are installed.
38481fb744b4Smrg#
38491fb744b4Smrg# This wrapper script should never be moved out of the build directory.
38501fb744b4Smrg# If it is, it will not operate correctly.
3851c35d236eSmrg
38521fb744b4Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
38531fb744b4Smrg# metacharacters that are still active within double-quoted strings.
38541fb744b4Smrgsed_quote_subst='$sed_quote_subst'
3855c35d236eSmrg
38561fb744b4Smrg# Be Bourne compatible
38571fb744b4Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
38581fb744b4Smrg  emulate sh
38591fb744b4Smrg  NULLCMD=:
38601fb744b4Smrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
38611fb744b4Smrg  # is contrary to our usage.  Disable this feature.
38621fb744b4Smrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
38631fb744b4Smrg  setopt NO_GLOB_SUBST
38641fb744b4Smrgelse
38651fb744b4Smrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
38661fb744b4Smrgfi
38671fb744b4SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
38681fb744b4SmrgDUALCASE=1; export DUALCASE # for MKS sh
3869c35d236eSmrg
38701fb744b4Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
38711fb744b4Smrg# if CDPATH is set.
38721fb744b4Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
3873c35d236eSmrg
38741fb744b4Smrgrelink_command=\"$relink_command\"
3875c35d236eSmrg
38761fb744b4Smrg# This environment variable determines our operation mode.
38771fb744b4Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
38781fb744b4Smrg  # install mode needs the following variables:
38791fb744b4Smrg  generated_by_libtool_version='$macro_version'
38801fb744b4Smrg  notinst_deplibs='$notinst_deplibs'
38811fb744b4Smrgelse
38821fb744b4Smrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
38831fb744b4Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
38841fb744b4Smrg    file=\"\$0\""
3885c35d236eSmrg
38861fb744b4Smrg    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
38871fb744b4Smrg    $ECHO "\
3888c35d236eSmrg
38891fb744b4Smrg# A function that is used when there is no print builtin or printf.
38901fb744b4Smrgfunc_fallback_echo ()
38911fb744b4Smrg{
38921fb744b4Smrg  eval 'cat <<_LTECHO_EOF
38931fb744b4Smrg\$1
38941fb744b4Smrg_LTECHO_EOF'
38951fb744b4Smrg}
38961fb744b4Smrg    ECHO=\"$qECHO\"
38971fb744b4Smrg  fi
3898c35d236eSmrg
38991fb744b4Smrg# Very basic option parsing. These options are (a) specific to
39001fb744b4Smrg# the libtool wrapper, (b) are identical between the wrapper
39011fb744b4Smrg# /script/ and the wrapper /executable/ which is used only on
39021fb744b4Smrg# windows platforms, and (c) all begin with the string "--lt-"
39031fb744b4Smrg# (application programs are unlikely to have options which match
39041fb744b4Smrg# this pattern).
39051fb744b4Smrg#
39061fb744b4Smrg# There are only two supported options: --lt-debug and
39071fb744b4Smrg# --lt-dump-script. There is, deliberately, no --lt-help.
39081fb744b4Smrg#
39091fb744b4Smrg# The first argument to this parsing function should be the
39101fb744b4Smrg# script's $0 value, followed by "$@".
39111fb744b4Smrglt_option_debug=
39121fb744b4Smrgfunc_parse_lt_options ()
39131fb744b4Smrg{
39141fb744b4Smrg  lt_script_arg0=\$0
39151fb744b4Smrg  shift
39161fb744b4Smrg  for lt_opt
39171fb744b4Smrg  do
39181fb744b4Smrg    case \"\$lt_opt\" in
39191fb744b4Smrg    --lt-debug) lt_option_debug=1 ;;
39201fb744b4Smrg    --lt-dump-script)
39211fb744b4Smrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
39221fb744b4Smrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
39231fb744b4Smrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
39241fb744b4Smrg        cat \"\$lt_dump_D/\$lt_dump_F\"
39251fb744b4Smrg        exit 0
39261fb744b4Smrg      ;;
39271fb744b4Smrg    --lt-*)
39281fb744b4Smrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
39291fb744b4Smrg        exit 1
39301fb744b4Smrg      ;;
39311fb744b4Smrg    esac
39321fb744b4Smrg  done
3933c35d236eSmrg
39341fb744b4Smrg  # Print the debug banner immediately:
39351fb744b4Smrg  if test -n \"\$lt_option_debug\"; then
39361fb744b4Smrg    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
39371fb744b4Smrg  fi
39381fb744b4Smrg}
3939c35d236eSmrg
39401fb744b4Smrg# Used when --lt-debug. Prints its arguments to stdout
39411fb744b4Smrg# (redirection is the responsibility of the caller)
39421fb744b4Smrgfunc_lt_dump_args ()
39431fb744b4Smrg{
39441fb744b4Smrg  lt_dump_args_N=1;
39451fb744b4Smrg  for lt_arg
39461fb744b4Smrg  do
39471fb744b4Smrg    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
39481fb744b4Smrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
39491fb744b4Smrg  done
39501fb744b4Smrg}
3951c35d236eSmrg
39521fb744b4Smrg# Core function for launching the target application
39531fb744b4Smrgfunc_exec_program_core ()
39541fb744b4Smrg{
39551fb744b4Smrg"
39561fb744b4Smrg  case $host in
39571fb744b4Smrg  # Backslashes separate directories on plain windows
39581fb744b4Smrg  *-*-mingw | *-*-os2* | *-cegcc*)
39591fb744b4Smrg    $ECHO "\
39601fb744b4Smrg      if test -n \"\$lt_option_debug\"; then
39611fb744b4Smrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
39621fb744b4Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
39631fb744b4Smrg      fi
39641fb744b4Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
39651fb744b4Smrg"
39661fb744b4Smrg    ;;
3967c35d236eSmrg
39681fb744b4Smrg  *)
39691fb744b4Smrg    $ECHO "\
39701fb744b4Smrg      if test -n \"\$lt_option_debug\"; then
39711fb744b4Smrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
39721fb744b4Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
39731fb744b4Smrg      fi
39741fb744b4Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
39751fb744b4Smrg"
39761fb744b4Smrg    ;;
39771fb744b4Smrg  esac
39781fb744b4Smrg  $ECHO "\
39791fb744b4Smrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
39801fb744b4Smrg      exit 1
39811fb744b4Smrg}
3982c35d236eSmrg
39831fb744b4Smrg# A function to encapsulate launching the target application
39841fb744b4Smrg# Strips options in the --lt-* namespace from \$@ and
39851fb744b4Smrg# launches target application with the remaining arguments.
39861fb744b4Smrgfunc_exec_program ()
39871fb744b4Smrg{
39881fb744b4Smrg  case \" \$* \" in
39891fb744b4Smrg  *\\ --lt-*)
39901fb744b4Smrg    for lt_wr_arg
39911fb744b4Smrg    do
39921fb744b4Smrg      case \$lt_wr_arg in
39931fb744b4Smrg      --lt-*) ;;
39941fb744b4Smrg      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
39951fb744b4Smrg      esac
39961fb744b4Smrg      shift
39971fb744b4Smrg    done ;;
39981fb744b4Smrg  esac
39991fb744b4Smrg  func_exec_program_core \${1+\"\$@\"}
40001fb744b4Smrg}
4001c35d236eSmrg
40021fb744b4Smrg  # Parse options
40031fb744b4Smrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
4004c35d236eSmrg
40051fb744b4Smrg  # Find the directory that this script lives in.
40061fb744b4Smrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
40071fb744b4Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
4008c35d236eSmrg
40091fb744b4Smrg  # Follow symbolic links until we get to the real thisdir.
40101fb744b4Smrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
40111fb744b4Smrg  while test -n \"\$file\"; do
40121fb744b4Smrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
4013c35d236eSmrg
40141fb744b4Smrg    # If there was a directory component, then change thisdir.
40151fb744b4Smrg    if test \"x\$destdir\" != \"x\$file\"; then
40161fb744b4Smrg      case \"\$destdir\" in
40171fb744b4Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
40181fb744b4Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
40191fb744b4Smrg      esac
40201fb744b4Smrg    fi
4021c35d236eSmrg
40221fb744b4Smrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
40231fb744b4Smrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
40241fb744b4Smrg  done
4025c35d236eSmrg
40261fb744b4Smrg  # Usually 'no', except on cygwin/mingw when embedded into
40271fb744b4Smrg  # the cwrapper.
40281fb744b4Smrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
40291fb744b4Smrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
40301fb744b4Smrg    # special case for '.'
40311fb744b4Smrg    if test \"\$thisdir\" = \".\"; then
40321fb744b4Smrg      thisdir=\`pwd\`
40331fb744b4Smrg    fi
40341fb744b4Smrg    # remove .libs from thisdir
40351fb744b4Smrg    case \"\$thisdir\" in
40361fb744b4Smrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
40371fb744b4Smrg    $objdir )   thisdir=. ;;
40381fb744b4Smrg    esac
40391fb744b4Smrg  fi
4040c35d236eSmrg
40411fb744b4Smrg  # Try to get the absolute directory name.
40421fb744b4Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
40431fb744b4Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
40441fb744b4Smrg"
4045c35d236eSmrg
40461fb744b4Smrg	if test "$fast_install" = yes; then
40471fb744b4Smrg	  $ECHO "\
40481fb744b4Smrg  program=lt-'$outputname'$exeext
40491fb744b4Smrg  progdir=\"\$thisdir/$objdir\"
4050c35d236eSmrg
40511fb744b4Smrg  if test ! -f \"\$progdir/\$program\" ||
40521fb744b4Smrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
40531fb744b4Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
4054c35d236eSmrg
40551fb744b4Smrg    file=\"\$\$-\$program\"
4056c35d236eSmrg
40571fb744b4Smrg    if test ! -d \"\$progdir\"; then
40581fb744b4Smrg      $MKDIR \"\$progdir\"
40591fb744b4Smrg    else
40601fb744b4Smrg      $RM \"\$progdir/\$file\"
40611fb744b4Smrg    fi"
4062c35d236eSmrg
40631fb744b4Smrg	  $ECHO "\
4064c35d236eSmrg
40651fb744b4Smrg    # relink executable if necessary
40661fb744b4Smrg    if test -n \"\$relink_command\"; then
40671fb744b4Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
40681fb744b4Smrg      else
40691fb744b4Smrg	$ECHO \"\$relink_command_output\" >&2
40701fb744b4Smrg	$RM \"\$progdir/\$file\"
40711fb744b4Smrg	exit 1
40721fb744b4Smrg      fi
40731fb744b4Smrg    fi
4074518bcf38Smrg
40751fb744b4Smrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
40761fb744b4Smrg    { $RM \"\$progdir/\$program\";
40771fb744b4Smrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
40781fb744b4Smrg    $RM \"\$progdir/\$file\"
40791fb744b4Smrg  fi"
40801fb744b4Smrg	else
40811fb744b4Smrg	  $ECHO "\
40821fb744b4Smrg  program='$outputname'
40831fb744b4Smrg  progdir=\"\$thisdir/$objdir\"
40841fb744b4Smrg"
40851fb744b4Smrg	fi
4086518bcf38Smrg
40871fb744b4Smrg	$ECHO "\
4088518bcf38Smrg
40891fb744b4Smrg  if test -f \"\$progdir/\$program\"; then"
40901fb744b4Smrg
40911fb744b4Smrg	# fixup the dll searchpath if we need to.
40921fb744b4Smrg	#
40931fb744b4Smrg	# Fix the DLL searchpath if we need to.  Do this before prepending
40941fb744b4Smrg	# to shlibpath, because on Windows, both are PATH and uninstalled
40951fb744b4Smrg	# libraries must come first.
40961fb744b4Smrg	if test -n "$dllsearchpath"; then
40971fb744b4Smrg	  $ECHO "\
40981fb744b4Smrg    # Add the dll search path components to the executable PATH
40991fb744b4Smrg    PATH=$dllsearchpath:\$PATH
41001fb744b4Smrg"
4101518bcf38Smrg	fi
4102518bcf38Smrg
41031fb744b4Smrg	# Export our shlibpath_var if we have one.
41041fb744b4Smrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
41051fb744b4Smrg	  $ECHO "\
41061fb744b4Smrg    # Add our own library path to $shlibpath_var
41071fb744b4Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
4108518bcf38Smrg
41091fb744b4Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
41101fb744b4Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
41111fb744b4Smrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
41121fb744b4Smrg
41131fb744b4Smrg    export $shlibpath_var
41141fb744b4Smrg"
4115518bcf38Smrg	fi
4116c35d236eSmrg
41171fb744b4Smrg	$ECHO "\
41181fb744b4Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
41191fb744b4Smrg      # Run the actual program with our arguments.
41201fb744b4Smrg      func_exec_program \${1+\"\$@\"}
41211fb744b4Smrg    fi
41221fb744b4Smrg  else
41231fb744b4Smrg    # The program doesn't exist.
41241fb744b4Smrg    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
41251fb744b4Smrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
41261fb744b4Smrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
41271fb744b4Smrg    exit 1
41281fb744b4Smrg  fi
41291fb744b4Smrgfi\
41301fb744b4Smrg"
41311fb744b4Smrg}
4132c35d236eSmrg
4133c35d236eSmrg
41341fb744b4Smrg# func_emit_cwrapperexe_src
41351fb744b4Smrg# emit the source code for a wrapper executable on stdout
41361fb744b4Smrg# Must ONLY be called from within func_mode_link because
41371fb744b4Smrg# it depends on a number of variable set therein.
41381fb744b4Smrgfunc_emit_cwrapperexe_src ()
41391fb744b4Smrg{
41401fb744b4Smrg	cat <<EOF
4141518bcf38Smrg
41421fb744b4Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
41431fb744b4Smrg   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
4144518bcf38Smrg
41451fb744b4Smrg   The $output program cannot be directly executed until all the libtool
41461fb744b4Smrg   libraries that it depends on are installed.
4147518bcf38Smrg
41481fb744b4Smrg   This wrapper executable should never be moved out of the build directory.
41491fb744b4Smrg   If it is, it will not operate correctly.
41501fb744b4Smrg*/
41511fb744b4SmrgEOF
41521fb744b4Smrg	    cat <<"EOF"
41531fb744b4Smrg#ifdef _MSC_VER
41541fb744b4Smrg# define _CRT_SECURE_NO_DEPRECATE 1
41551fb744b4Smrg#endif
41561fb744b4Smrg#include <stdio.h>
41571fb744b4Smrg#include <stdlib.h>
41581fb744b4Smrg#ifdef _MSC_VER
41591fb744b4Smrg# include <direct.h>
41601fb744b4Smrg# include <process.h>
41611fb744b4Smrg# include <io.h>
41621fb744b4Smrg#else
41631fb744b4Smrg# include <unistd.h>
41641fb744b4Smrg# include <stdint.h>
41651fb744b4Smrg# ifdef __CYGWIN__
41661fb744b4Smrg#  include <io.h>
41671fb744b4Smrg# endif
41681fb744b4Smrg#endif
41691fb744b4Smrg#include <malloc.h>
41701fb744b4Smrg#include <stdarg.h>
41711fb744b4Smrg#include <assert.h>
41721fb744b4Smrg#include <string.h>
41731fb744b4Smrg#include <ctype.h>
41741fb744b4Smrg#include <errno.h>
41751fb744b4Smrg#include <fcntl.h>
41761fb744b4Smrg#include <sys/stat.h>
4177518bcf38Smrg
41781fb744b4Smrg/* declarations of non-ANSI functions */
41791fb744b4Smrg#if defined(__MINGW32__)
41801fb744b4Smrg# ifdef __STRICT_ANSI__
41811fb744b4Smrgint _putenv (const char *);
41821fb744b4Smrg# endif
41831fb744b4Smrg#elif defined(__CYGWIN__)
41841fb744b4Smrg# ifdef __STRICT_ANSI__
41851fb744b4Smrgchar *realpath (const char *, char *);
41861fb744b4Smrgint putenv (char *);
41871fb744b4Smrgint setenv (const char *, const char *, int);
41881fb744b4Smrg# endif
41891fb744b4Smrg/* #elif defined (other platforms) ... */
41901fb744b4Smrg#endif
4191c35d236eSmrg
41921fb744b4Smrg/* portability defines, excluding path handling macros */
41931fb744b4Smrg#if defined(_MSC_VER)
41941fb744b4Smrg# define setmode _setmode
41951fb744b4Smrg# define stat    _stat
41961fb744b4Smrg# define chmod   _chmod
41971fb744b4Smrg# define getcwd  _getcwd
41981fb744b4Smrg# define putenv  _putenv
41991fb744b4Smrg# define S_IXUSR _S_IEXEC
42001fb744b4Smrg# ifndef _INTPTR_T_DEFINED
42011fb744b4Smrg#  define _INTPTR_T_DEFINED
42021fb744b4Smrg#  define intptr_t int
42031fb744b4Smrg# endif
42041fb744b4Smrg#elif defined(__MINGW32__)
42051fb744b4Smrg# define setmode _setmode
42061fb744b4Smrg# define stat    _stat
42071fb744b4Smrg# define chmod   _chmod
42081fb744b4Smrg# define getcwd  _getcwd
42091fb744b4Smrg# define putenv  _putenv
42101fb744b4Smrg#elif defined(__CYGWIN__)
42111fb744b4Smrg# define HAVE_SETENV
42121fb744b4Smrg# define FOPEN_WB "wb"
42131fb744b4Smrg/* #elif defined (other platforms) ... */
42141fb744b4Smrg#endif
4215c35d236eSmrg
42161fb744b4Smrg#if defined(PATH_MAX)
42171fb744b4Smrg# define LT_PATHMAX PATH_MAX
42181fb744b4Smrg#elif defined(MAXPATHLEN)
42191fb744b4Smrg# define LT_PATHMAX MAXPATHLEN
42201fb744b4Smrg#else
42211fb744b4Smrg# define LT_PATHMAX 1024
42221fb744b4Smrg#endif
4223c35d236eSmrg
42241fb744b4Smrg#ifndef S_IXOTH
42251fb744b4Smrg# define S_IXOTH 0
42261fb744b4Smrg#endif
42271fb744b4Smrg#ifndef S_IXGRP
42281fb744b4Smrg# define S_IXGRP 0
42291fb744b4Smrg#endif
4230c35d236eSmrg
42311fb744b4Smrg/* path handling portability macros */
42321fb744b4Smrg#ifndef DIR_SEPARATOR
42331fb744b4Smrg# define DIR_SEPARATOR '/'
42341fb744b4Smrg# define PATH_SEPARATOR ':'
42351fb744b4Smrg#endif
4236c35d236eSmrg
42371fb744b4Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
42381fb744b4Smrg  defined (__OS2__)
42391fb744b4Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
42401fb744b4Smrg# define FOPEN_WB "wb"
42411fb744b4Smrg# ifndef DIR_SEPARATOR_2
42421fb744b4Smrg#  define DIR_SEPARATOR_2 '\\'
42431fb744b4Smrg# endif
42441fb744b4Smrg# ifndef PATH_SEPARATOR_2
42451fb744b4Smrg#  define PATH_SEPARATOR_2 ';'
42461fb744b4Smrg# endif
42471fb744b4Smrg#endif
4248c35d236eSmrg
42491fb744b4Smrg#ifndef DIR_SEPARATOR_2
42501fb744b4Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
42511fb744b4Smrg#else /* DIR_SEPARATOR_2 */
42521fb744b4Smrg# define IS_DIR_SEPARATOR(ch) \
42531fb744b4Smrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
42541fb744b4Smrg#endif /* DIR_SEPARATOR_2 */
4255c35d236eSmrg
42561fb744b4Smrg#ifndef PATH_SEPARATOR_2
42571fb744b4Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
42581fb744b4Smrg#else /* PATH_SEPARATOR_2 */
42591fb744b4Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
42601fb744b4Smrg#endif /* PATH_SEPARATOR_2 */
4261c35d236eSmrg
42621fb744b4Smrg#ifndef FOPEN_WB
42631fb744b4Smrg# define FOPEN_WB "w"
42641fb744b4Smrg#endif
42651fb744b4Smrg#ifndef _O_BINARY
42661fb744b4Smrg# define _O_BINARY 0
42671fb744b4Smrg#endif
4268c35d236eSmrg
42691fb744b4Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
42701fb744b4Smrg#define XFREE(stale) do { \
42711fb744b4Smrg  if (stale) { free ((void *) stale); stale = 0; } \
42721fb744b4Smrg} while (0)
4273c35d236eSmrg
42741fb744b4Smrg#if defined(LT_DEBUGWRAPPER)
42751fb744b4Smrgstatic int lt_debug = 1;
42761fb744b4Smrg#else
42771fb744b4Smrgstatic int lt_debug = 0;
42781fb744b4Smrg#endif
4279c35d236eSmrg
42801fb744b4Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
42811fb744b4Smrg
42821fb744b4Smrgvoid *xmalloc (size_t num);
42831fb744b4Smrgchar *xstrdup (const char *string);
42841fb744b4Smrgconst char *base_name (const char *name);
42851fb744b4Smrgchar *find_executable (const char *wrapper);
42861fb744b4Smrgchar *chase_symlinks (const char *pathspec);
42871fb744b4Smrgint make_executable (const char *path);
42881fb744b4Smrgint check_executable (const char *path);
42891fb744b4Smrgchar *strendzap (char *str, const char *pat);
42901fb744b4Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
42911fb744b4Smrgvoid lt_fatal (const char *file, int line, const char *message, ...);
42921fb744b4Smrgstatic const char *nonnull (const char *s);
42931fb744b4Smrgstatic const char *nonempty (const char *s);
42941fb744b4Smrgvoid lt_setenv (const char *name, const char *value);
42951fb744b4Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
42961fb744b4Smrgvoid lt_update_exe_path (const char *name, const char *value);
42971fb744b4Smrgvoid lt_update_lib_path (const char *name, const char *value);
42981fb744b4Smrgchar **prepare_spawn (char **argv);
42991fb744b4Smrgvoid lt_dump_script (FILE *f);
43001fb744b4SmrgEOF
4301c35d236eSmrg
43021fb744b4Smrg	    cat <<EOF
43031fb744b4Smrgvolatile const char * MAGIC_EXE = "$magic_exe";
43041fb744b4Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
43051fb744b4SmrgEOF
4306c35d236eSmrg
43071fb744b4Smrg	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
43081fb744b4Smrg              func_to_host_path "$temp_rpath"
43091fb744b4Smrg	      cat <<EOF
43101fb744b4Smrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
43111fb744b4SmrgEOF
43121fb744b4Smrg	    else
43131fb744b4Smrg	      cat <<"EOF"
43141fb744b4Smrgconst char * LIB_PATH_VALUE   = "";
43151fb744b4SmrgEOF
43161fb744b4Smrg	    fi
4317c35d236eSmrg
43181fb744b4Smrg	    if test -n "$dllsearchpath"; then
43191fb744b4Smrg              func_to_host_path "$dllsearchpath:"
43201fb744b4Smrg	      cat <<EOF
43211fb744b4Smrgconst char * EXE_PATH_VARNAME = "PATH";
43221fb744b4Smrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
43231fb744b4SmrgEOF
43241fb744b4Smrg	    else
43251fb744b4Smrg	      cat <<"EOF"
43261fb744b4Smrgconst char * EXE_PATH_VARNAME = "";
43271fb744b4Smrgconst char * EXE_PATH_VALUE   = "";
43281fb744b4SmrgEOF
43291fb744b4Smrg	    fi
4330c35d236eSmrg
43311fb744b4Smrg	    if test "$fast_install" = yes; then
43321fb744b4Smrg	      cat <<EOF
43331fb744b4Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
43341fb744b4SmrgEOF
43351fb744b4Smrg	    else
43361fb744b4Smrg	      cat <<EOF
43371fb744b4Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
43381fb744b4SmrgEOF
43391fb744b4Smrg	    fi
4340c35d236eSmrg
4341c35d236eSmrg
43421fb744b4Smrg	    cat <<"EOF"
4343c35d236eSmrg
43441fb744b4Smrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
4345c35d236eSmrg
43461fb744b4Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
43471fb744b4Smrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
43481fb744b4Smrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
4349c35d236eSmrg
43501fb744b4Smrgint
43511fb744b4Smrgmain (int argc, char *argv[])
43521fb744b4Smrg{
43531fb744b4Smrg  char **newargz;
43541fb744b4Smrg  int  newargc;
43551fb744b4Smrg  char *tmp_pathspec;
43561fb744b4Smrg  char *actual_cwrapper_path;
43571fb744b4Smrg  char *actual_cwrapper_name;
43581fb744b4Smrg  char *target_name;
43591fb744b4Smrg  char *lt_argv_zero;
43601fb744b4Smrg  intptr_t rval = 127;
43611fb744b4Smrg
43621fb744b4Smrg  int i;
4363c35d236eSmrg
43641fb744b4Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
43651fb744b4Smrg  newargz = XMALLOC (char *, argc + 1);
4366c35d236eSmrg
43671fb744b4Smrg  /* very simple arg parsing; don't want to rely on getopt
43681fb744b4Smrg   * also, copy all non cwrapper options to newargz, except
43691fb744b4Smrg   * argz[0], which is handled differently
43701fb744b4Smrg   */
43711fb744b4Smrg  newargc=0;
43721fb744b4Smrg  for (i = 1; i < argc; i++)
43731fb744b4Smrg    {
43741fb744b4Smrg      if (strcmp (argv[i], dumpscript_opt) == 0)
43751fb744b4Smrg	{
43761fb744b4SmrgEOF
43771fb744b4Smrg	    case "$host" in
43781fb744b4Smrg	      *mingw* | *cygwin* )
43791fb744b4Smrg		# make stdout use "unix" line endings
43801fb744b4Smrg		echo "          setmode(1,_O_BINARY);"
43811fb744b4Smrg		;;
43821fb744b4Smrg	      esac
4383c35d236eSmrg
43841fb744b4Smrg	    cat <<"EOF"
43851fb744b4Smrg	  lt_dump_script (stdout);
43861fb744b4Smrg	  return 0;
43871fb744b4Smrg	}
43881fb744b4Smrg      if (strcmp (argv[i], debug_opt) == 0)
43891fb744b4Smrg	{
43901fb744b4Smrg          lt_debug = 1;
43911fb744b4Smrg          continue;
43921fb744b4Smrg	}
43931fb744b4Smrg      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
43941fb744b4Smrg        {
43951fb744b4Smrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
43961fb744b4Smrg             namespace, but it is not one of the ones we know about and
43971fb744b4Smrg             have already dealt with, above (inluding dump-script), then
43981fb744b4Smrg             report an error. Otherwise, targets might begin to believe
43991fb744b4Smrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
44001fb744b4Smrg             namespace. The first time any user complains about this, we'll
44011fb744b4Smrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
44021fb744b4Smrg             or a configure.ac-settable value.
44031fb744b4Smrg           */
44041fb744b4Smrg          lt_fatal (__FILE__, __LINE__,
44051fb744b4Smrg		    "unrecognized %s option: '%s'",
44061fb744b4Smrg                    ltwrapper_option_prefix, argv[i]);
44071fb744b4Smrg        }
44081fb744b4Smrg      /* otherwise ... */
44091fb744b4Smrg      newargz[++newargc] = xstrdup (argv[i]);
44101fb744b4Smrg    }
44111fb744b4Smrg  newargz[++newargc] = NULL;
4412c35d236eSmrg
44131fb744b4SmrgEOF
44141fb744b4Smrg	    cat <<EOF
44151fb744b4Smrg  /* The GNU banner must be the first non-error debug message */
44161fb744b4Smrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
44171fb744b4SmrgEOF
44181fb744b4Smrg	    cat <<"EOF"
44191fb744b4Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
44201fb744b4Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
44211fb744b4Smrg
44221fb744b4Smrg  tmp_pathspec = find_executable (argv[0]);
44231fb744b4Smrg  if (tmp_pathspec == NULL)
44241fb744b4Smrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
44251fb744b4Smrg  lt_debugprintf (__FILE__, __LINE__,
44261fb744b4Smrg                  "(main) found exe (before symlink chase) at: %s\n",
44271fb744b4Smrg		  tmp_pathspec);
44281fb744b4Smrg
44291fb744b4Smrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
44301fb744b4Smrg  lt_debugprintf (__FILE__, __LINE__,
44311fb744b4Smrg                  "(main) found exe (after symlink chase) at: %s\n",
44321fb744b4Smrg		  actual_cwrapper_path);
44331fb744b4Smrg  XFREE (tmp_pathspec);
44341fb744b4Smrg
44351fb744b4Smrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
44361fb744b4Smrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
44371fb744b4Smrg
44381fb744b4Smrg  /* wrapper name transforms */
44391fb744b4Smrg  strendzap (actual_cwrapper_name, ".exe");
44401fb744b4Smrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
44411fb744b4Smrg  XFREE (actual_cwrapper_name);
44421fb744b4Smrg  actual_cwrapper_name = tmp_pathspec;
44431fb744b4Smrg  tmp_pathspec = 0;
44441fb744b4Smrg
44451fb744b4Smrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
44461fb744b4Smrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
44471fb744b4Smrg  strendzap (target_name, ".exe");
44481fb744b4Smrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
44491fb744b4Smrg  XFREE (target_name);
44501fb744b4Smrg  target_name = tmp_pathspec;
44511fb744b4Smrg  tmp_pathspec = 0;
44521fb744b4Smrg
44531fb744b4Smrg  lt_debugprintf (__FILE__, __LINE__,
44541fb744b4Smrg		  "(main) libtool target name: %s\n",
44551fb744b4Smrg		  target_name);
44561fb744b4SmrgEOF
44571fb744b4Smrg
44581fb744b4Smrg	    cat <<EOF
44591fb744b4Smrg  newargz[0] =
44601fb744b4Smrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
44611fb744b4Smrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
44621fb744b4Smrg  strcpy (newargz[0], actual_cwrapper_path);
44631fb744b4Smrg  strcat (newargz[0], "$objdir");
44641fb744b4Smrg  strcat (newargz[0], "/");
44651fb744b4SmrgEOF
44661fb744b4Smrg
44671fb744b4Smrg	    cat <<"EOF"
44681fb744b4Smrg  /* stop here, and copy so we don't have to do this twice */
44691fb744b4Smrg  tmp_pathspec = xstrdup (newargz[0]);
44701fb744b4Smrg
44711fb744b4Smrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
44721fb744b4Smrg  strcat (newargz[0], actual_cwrapper_name);
44731fb744b4Smrg
44741fb744b4Smrg  /* DO want the lt- prefix here if it exists, so use target_name */
44751fb744b4Smrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
44761fb744b4Smrg  XFREE (tmp_pathspec);
44771fb744b4Smrg  tmp_pathspec = NULL;
44781fb744b4SmrgEOF
44791fb744b4Smrg
44801fb744b4Smrg	    case $host_os in
44811fb744b4Smrg	      mingw*)
44821fb744b4Smrg	    cat <<"EOF"
44831fb744b4Smrg  {
44841fb744b4Smrg    char* p;
44851fb744b4Smrg    while ((p = strchr (newargz[0], '\\')) != NULL)
44861fb744b4Smrg      {
44871fb744b4Smrg	*p = '/';
44881fb744b4Smrg      }
44891fb744b4Smrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
44901fb744b4Smrg      {
44911fb744b4Smrg	*p = '/';
44921fb744b4Smrg      }
44931fb744b4Smrg  }
44941fb744b4SmrgEOF
44951fb744b4Smrg	    ;;
44961fb744b4Smrg	    esac
44971fb744b4Smrg
44981fb744b4Smrg	    cat <<"EOF"
44991fb744b4Smrg  XFREE (target_name);
45001fb744b4Smrg  XFREE (actual_cwrapper_path);
45011fb744b4Smrg  XFREE (actual_cwrapper_name);
45021fb744b4Smrg
45031fb744b4Smrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
45041fb744b4Smrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
45051fb744b4Smrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
45061fb744b4Smrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
45071fb744b4Smrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
45081fb744b4Smrg     libraries must come first. */
45091fb744b4Smrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
45101fb744b4Smrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
45111fb744b4Smrg
45121fb744b4Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
45131fb744b4Smrg		  nonnull (lt_argv_zero));
45141fb744b4Smrg  for (i = 0; i < newargc; i++)
45151fb744b4Smrg    {
45161fb744b4Smrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
45171fb744b4Smrg		      i, nonnull (newargz[i]));
45181fb744b4Smrg    }
45191fb744b4Smrg
45201fb744b4SmrgEOF
45211fb744b4Smrg
45221fb744b4Smrg	    case $host_os in
45231fb744b4Smrg	      mingw*)
45241fb744b4Smrg		cat <<"EOF"
45251fb744b4Smrg  /* execv doesn't actually work on mingw as expected on unix */
45261fb744b4Smrg  newargz = prepare_spawn (newargz);
45271fb744b4Smrg  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
45281fb744b4Smrg  if (rval == -1)
45291fb744b4Smrg    {
45301fb744b4Smrg      /* failed to start process */
45311fb744b4Smrg      lt_debugprintf (__FILE__, __LINE__,
45321fb744b4Smrg		      "(main) failed to launch target \"%s\": %s\n",
45331fb744b4Smrg		      lt_argv_zero, nonnull (strerror (errno)));
45341fb744b4Smrg      return 127;
45351fb744b4Smrg    }
45361fb744b4Smrg  return rval;
45371fb744b4SmrgEOF
4538518bcf38Smrg		;;
4539518bcf38Smrg	      *)
45401fb744b4Smrg		cat <<"EOF"
45411fb744b4Smrg  execv (lt_argv_zero, newargz);
45421fb744b4Smrg  return rval; /* =127, but avoids unused variable warning */
45431fb744b4SmrgEOF
4544518bcf38Smrg		;;
45451fb744b4Smrg	    esac
4546c35d236eSmrg
45471fb744b4Smrg	    cat <<"EOF"
45481fb744b4Smrg}
4549c35d236eSmrg
45501fb744b4Smrgvoid *
45511fb744b4Smrgxmalloc (size_t num)
45521fb744b4Smrg{
45531fb744b4Smrg  void *p = (void *) malloc (num);
45541fb744b4Smrg  if (!p)
45551fb744b4Smrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
4556c35d236eSmrg
45571fb744b4Smrg  return p;
45581fb744b4Smrg}
4559c35d236eSmrg
45601fb744b4Smrgchar *
45611fb744b4Smrgxstrdup (const char *string)
45621fb744b4Smrg{
45631fb744b4Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
45641fb744b4Smrg			  string) : NULL;
45651fb744b4Smrg}
4566c35d236eSmrg
45671fb744b4Smrgconst char *
45681fb744b4Smrgbase_name (const char *name)
45691fb744b4Smrg{
45701fb744b4Smrg  const char *base;
4571c35d236eSmrg
45721fb744b4Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
45731fb744b4Smrg  /* Skip over the disk name in MSDOS pathnames. */
45741fb744b4Smrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
45751fb744b4Smrg    name += 2;
4576518bcf38Smrg#endif
4577c35d236eSmrg
45781fb744b4Smrg  for (base = name; *name; name++)
45791fb744b4Smrg    if (IS_DIR_SEPARATOR (*name))
45801fb744b4Smrg      base = name + 1;
45811fb744b4Smrg  return base;
45821fb744b4Smrg}
4583c35d236eSmrg
45841fb744b4Smrgint
45851fb744b4Smrgcheck_executable (const char *path)
45861fb744b4Smrg{
45871fb744b4Smrg  struct stat st;
4588c35d236eSmrg
45891fb744b4Smrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
45901fb744b4Smrg                  nonempty (path));
45911fb744b4Smrg  if ((!path) || (!*path))
45921fb744b4Smrg    return 0;
4593c35d236eSmrg
45941fb744b4Smrg  if ((stat (path, &st) >= 0)
45951fb744b4Smrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
45961fb744b4Smrg    return 1;
45971fb744b4Smrg  else
45981fb744b4Smrg    return 0;
45991fb744b4Smrg}
4600c35d236eSmrg
46011fb744b4Smrgint
46021fb744b4Smrgmake_executable (const char *path)
46031fb744b4Smrg{
46041fb744b4Smrg  int rval = 0;
46051fb744b4Smrg  struct stat st;
4606c35d236eSmrg
46071fb744b4Smrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
46081fb744b4Smrg                  nonempty (path));
46091fb744b4Smrg  if ((!path) || (!*path))
46101fb744b4Smrg    return 0;
4611c35d236eSmrg
46121fb744b4Smrg  if (stat (path, &st) >= 0)
46131fb744b4Smrg    {
46141fb744b4Smrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
46151fb744b4Smrg    }
46161fb744b4Smrg  return rval;
46171fb744b4Smrg}
4618c35d236eSmrg
46191fb744b4Smrg/* Searches for the full path of the wrapper.  Returns
46201fb744b4Smrg   newly allocated full path name if found, NULL otherwise
46211fb744b4Smrg   Does not chase symlinks, even on platforms that support them.
46221fb744b4Smrg*/
46231fb744b4Smrgchar *
46241fb744b4Smrgfind_executable (const char *wrapper)
46251fb744b4Smrg{
46261fb744b4Smrg  int has_slash = 0;
46271fb744b4Smrg  const char *p;
46281fb744b4Smrg  const char *p_next;
46291fb744b4Smrg  /* static buffer for getcwd */
46301fb744b4Smrg  char tmp[LT_PATHMAX + 1];
46311fb744b4Smrg  int tmp_len;
46321fb744b4Smrg  char *concat_name;
4633c35d236eSmrg
46341fb744b4Smrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
46351fb744b4Smrg                  nonempty (wrapper));
4636c35d236eSmrg
46371fb744b4Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
46381fb744b4Smrg    return NULL;
4639c35d236eSmrg
46401fb744b4Smrg  /* Absolute path? */
46411fb744b4Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
46421fb744b4Smrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
46431fb744b4Smrg    {
46441fb744b4Smrg      concat_name = xstrdup (wrapper);
46451fb744b4Smrg      if (check_executable (concat_name))
46461fb744b4Smrg	return concat_name;
46471fb744b4Smrg      XFREE (concat_name);
46481fb744b4Smrg    }
46491fb744b4Smrg  else
46501fb744b4Smrg    {
46511fb744b4Smrg#endif
46521fb744b4Smrg      if (IS_DIR_SEPARATOR (wrapper[0]))
46531fb744b4Smrg	{
46541fb744b4Smrg	  concat_name = xstrdup (wrapper);
46551fb744b4Smrg	  if (check_executable (concat_name))
46561fb744b4Smrg	    return concat_name;
46571fb744b4Smrg	  XFREE (concat_name);
46581fb744b4Smrg	}
46591fb744b4Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
46601fb744b4Smrg    }
46611fb744b4Smrg#endif
4662c35d236eSmrg
46631fb744b4Smrg  for (p = wrapper; *p; p++)
46641fb744b4Smrg    if (*p == '/')
46651fb744b4Smrg      {
46661fb744b4Smrg	has_slash = 1;
46671fb744b4Smrg	break;
46681fb744b4Smrg      }
46691fb744b4Smrg  if (!has_slash)
46701fb744b4Smrg    {
46711fb744b4Smrg      /* no slashes; search PATH */
46721fb744b4Smrg      const char *path = getenv ("PATH");
46731fb744b4Smrg      if (path != NULL)
46741fb744b4Smrg	{
46751fb744b4Smrg	  for (p = path; *p; p = p_next)
46761fb744b4Smrg	    {
46771fb744b4Smrg	      const char *q;
46781fb744b4Smrg	      size_t p_len;
46791fb744b4Smrg	      for (q = p; *q; q++)
46801fb744b4Smrg		if (IS_PATH_SEPARATOR (*q))
46811fb744b4Smrg		  break;
46821fb744b4Smrg	      p_len = q - p;
46831fb744b4Smrg	      p_next = (*q == '\0' ? q : q + 1);
46841fb744b4Smrg	      if (p_len == 0)
46851fb744b4Smrg		{
46861fb744b4Smrg		  /* empty path: current directory */
46871fb744b4Smrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
46881fb744b4Smrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
46891fb744b4Smrg                              nonnull (strerror (errno)));
46901fb744b4Smrg		  tmp_len = strlen (tmp);
46911fb744b4Smrg		  concat_name =
46921fb744b4Smrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
46931fb744b4Smrg		  memcpy (concat_name, tmp, tmp_len);
46941fb744b4Smrg		  concat_name[tmp_len] = '/';
46951fb744b4Smrg		  strcpy (concat_name + tmp_len + 1, wrapper);
46961fb744b4Smrg		}
46971fb744b4Smrg	      else
46981fb744b4Smrg		{
46991fb744b4Smrg		  concat_name =
47001fb744b4Smrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
47011fb744b4Smrg		  memcpy (concat_name, p, p_len);
47021fb744b4Smrg		  concat_name[p_len] = '/';
47031fb744b4Smrg		  strcpy (concat_name + p_len + 1, wrapper);
47041fb744b4Smrg		}
47051fb744b4Smrg	      if (check_executable (concat_name))
47061fb744b4Smrg		return concat_name;
47071fb744b4Smrg	      XFREE (concat_name);
47081fb744b4Smrg	    }
47091fb744b4Smrg	}
47101fb744b4Smrg      /* not found in PATH; assume curdir */
47111fb744b4Smrg    }
47121fb744b4Smrg  /* Relative path | not found in path: prepend cwd */
47131fb744b4Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
47141fb744b4Smrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
47151fb744b4Smrg              nonnull (strerror (errno)));
47161fb744b4Smrg  tmp_len = strlen (tmp);
47171fb744b4Smrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
47181fb744b4Smrg  memcpy (concat_name, tmp, tmp_len);
47191fb744b4Smrg  concat_name[tmp_len] = '/';
47201fb744b4Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
4721c35d236eSmrg
47221fb744b4Smrg  if (check_executable (concat_name))
47231fb744b4Smrg    return concat_name;
47241fb744b4Smrg  XFREE (concat_name);
47251fb744b4Smrg  return NULL;
47261fb744b4Smrg}
4727c35d236eSmrg
47281fb744b4Smrgchar *
47291fb744b4Smrgchase_symlinks (const char *pathspec)
47301fb744b4Smrg{
47311fb744b4Smrg#ifndef S_ISLNK
47321fb744b4Smrg  return xstrdup (pathspec);
47331fb744b4Smrg#else
47341fb744b4Smrg  char buf[LT_PATHMAX];
47351fb744b4Smrg  struct stat s;
47361fb744b4Smrg  char *tmp_pathspec = xstrdup (pathspec);
47371fb744b4Smrg  char *p;
47381fb744b4Smrg  int has_symlinks = 0;
47391fb744b4Smrg  while (strlen (tmp_pathspec) && !has_symlinks)
47401fb744b4Smrg    {
47411fb744b4Smrg      lt_debugprintf (__FILE__, __LINE__,
47421fb744b4Smrg		      "checking path component for symlinks: %s\n",
47431fb744b4Smrg		      tmp_pathspec);
47441fb744b4Smrg      if (lstat (tmp_pathspec, &s) == 0)
47451fb744b4Smrg	{
47461fb744b4Smrg	  if (S_ISLNK (s.st_mode) != 0)
47471fb744b4Smrg	    {
47481fb744b4Smrg	      has_symlinks = 1;
47491fb744b4Smrg	      break;
47501fb744b4Smrg	    }
47511fb744b4Smrg
47521fb744b4Smrg	  /* search backwards for last DIR_SEPARATOR */
47531fb744b4Smrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
47541fb744b4Smrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
47551fb744b4Smrg	    p--;
47561fb744b4Smrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
47571fb744b4Smrg	    {
47581fb744b4Smrg	      /* no more DIR_SEPARATORS left */
47591fb744b4Smrg	      break;
47601fb744b4Smrg	    }
47611fb744b4Smrg	  *p = '\0';
47621fb744b4Smrg	}
47631fb744b4Smrg      else
47641fb744b4Smrg	{
47651fb744b4Smrg	  lt_fatal (__FILE__, __LINE__,
47661fb744b4Smrg		    "error accessing file \"%s\": %s",
47671fb744b4Smrg		    tmp_pathspec, nonnull (strerror (errno)));
47681fb744b4Smrg	}
47691fb744b4Smrg    }
47701fb744b4Smrg  XFREE (tmp_pathspec);
4771c35d236eSmrg
47721fb744b4Smrg  if (!has_symlinks)
47731fb744b4Smrg    {
47741fb744b4Smrg      return xstrdup (pathspec);
47751fb744b4Smrg    }
47764f6cd06fSmrg
47771fb744b4Smrg  tmp_pathspec = realpath (pathspec, buf);
47781fb744b4Smrg  if (tmp_pathspec == 0)
47791fb744b4Smrg    {
47801fb744b4Smrg      lt_fatal (__FILE__, __LINE__,
47811fb744b4Smrg		"could not follow symlinks for %s", pathspec);
47821fb744b4Smrg    }
47831fb744b4Smrg  return xstrdup (tmp_pathspec);
4784518bcf38Smrg#endif
47851fb744b4Smrg}
4786c35d236eSmrg
47871fb744b4Smrgchar *
47881fb744b4Smrgstrendzap (char *str, const char *pat)
47891fb744b4Smrg{
47901fb744b4Smrg  size_t len, patlen;
4791c35d236eSmrg
47921fb744b4Smrg  assert (str != NULL);
47931fb744b4Smrg  assert (pat != NULL);
4794c35d236eSmrg
47951fb744b4Smrg  len = strlen (str);
47961fb744b4Smrg  patlen = strlen (pat);
4797c35d236eSmrg
47981fb744b4Smrg  if (patlen <= len)
47991fb744b4Smrg    {
48001fb744b4Smrg      str += len - patlen;
48011fb744b4Smrg      if (strcmp (str, pat) == 0)
48021fb744b4Smrg	*str = '\0';
48031fb744b4Smrg    }
48041fb744b4Smrg  return str;
4805518bcf38Smrg}
4806c35d236eSmrg
48071fb744b4Smrgvoid
48081fb744b4Smrglt_debugprintf (const char *file, int line, const char *fmt, ...)
48091fb744b4Smrg{
48101fb744b4Smrg  va_list args;
48111fb744b4Smrg  if (lt_debug)
48121fb744b4Smrg    {
48131fb744b4Smrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
48141fb744b4Smrg      va_start (args, fmt);
48151fb744b4Smrg      (void) vfprintf (stderr, fmt, args);
48161fb744b4Smrg      va_end (args);
48171fb744b4Smrg    }
48181fb744b4Smrg}
4819c35d236eSmrg
48201fb744b4Smrgstatic void
48211fb744b4Smrglt_error_core (int exit_status, const char *file,
48221fb744b4Smrg	       int line, const char *mode,
48231fb744b4Smrg	       const char *message, va_list ap)
48241fb744b4Smrg{
48251fb744b4Smrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
48261fb744b4Smrg  vfprintf (stderr, message, ap);
48271fb744b4Smrg  fprintf (stderr, ".\n");
4828c35d236eSmrg
48291fb744b4Smrg  if (exit_status >= 0)
48301fb744b4Smrg    exit (exit_status);
4831518bcf38Smrg}
4832c35d236eSmrg
48331fb744b4Smrgvoid
48341fb744b4Smrglt_fatal (const char *file, int line, const char *message, ...)
48351fb744b4Smrg{
48361fb744b4Smrg  va_list ap;
48371fb744b4Smrg  va_start (ap, message);
48381fb744b4Smrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
48391fb744b4Smrg  va_end (ap);
4840518bcf38Smrg}
4841c35d236eSmrg
48421fb744b4Smrgstatic const char *
48431fb744b4Smrgnonnull (const char *s)
48441fb744b4Smrg{
48451fb744b4Smrg  return s ? s : "(null)";
48461fb744b4Smrg}
4847f55e6a01Smrg
48481fb744b4Smrgstatic const char *
48491fb744b4Smrgnonempty (const char *s)
48501fb744b4Smrg{
48511fb744b4Smrg  return (s && !*s) ? "(empty)" : nonnull (s);
48521fb744b4Smrg}
4853c35d236eSmrg
48541fb744b4Smrgvoid
48551fb744b4Smrglt_setenv (const char *name, const char *value)
48561fb744b4Smrg{
48571fb744b4Smrg  lt_debugprintf (__FILE__, __LINE__,
48581fb744b4Smrg		  "(lt_setenv) setting '%s' to '%s'\n",
48591fb744b4Smrg                  nonnull (name), nonnull (value));
48601fb744b4Smrg  {
48611fb744b4Smrg#ifdef HAVE_SETENV
48621fb744b4Smrg    /* always make a copy, for consistency with !HAVE_SETENV */
48631fb744b4Smrg    char *str = xstrdup (value);
48641fb744b4Smrg    setenv (name, str, 1);
48651fb744b4Smrg#else
48661fb744b4Smrg    int len = strlen (name) + 1 + strlen (value) + 1;
48671fb744b4Smrg    char *str = XMALLOC (char, len);
48681fb744b4Smrg    sprintf (str, "%s=%s", name, value);
48691fb744b4Smrg    if (putenv (str) != EXIT_SUCCESS)
48701fb744b4Smrg      {
48711fb744b4Smrg        XFREE (str);
48721fb744b4Smrg      }
48731fb744b4Smrg#endif
48741fb744b4Smrg  }
48751fb744b4Smrg}
4876c35d236eSmrg
48771fb744b4Smrgchar *
48781fb744b4Smrglt_extend_str (const char *orig_value, const char *add, int to_end)
48791fb744b4Smrg{
48801fb744b4Smrg  char *new_value;
48811fb744b4Smrg  if (orig_value && *orig_value)
48821fb744b4Smrg    {
48831fb744b4Smrg      int orig_value_len = strlen (orig_value);
48841fb744b4Smrg      int add_len = strlen (add);
48851fb744b4Smrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
48861fb744b4Smrg      if (to_end)
48871fb744b4Smrg        {
48881fb744b4Smrg          strcpy (new_value, orig_value);
48891fb744b4Smrg          strcpy (new_value + orig_value_len, add);
48901fb744b4Smrg        }
4891518bcf38Smrg      else
48921fb744b4Smrg        {
48931fb744b4Smrg          strcpy (new_value, add);
48941fb744b4Smrg          strcpy (new_value + add_len, orig_value);
48951fb744b4Smrg        }
48961fb744b4Smrg    }
48971fb744b4Smrg  else
48981fb744b4Smrg    {
48991fb744b4Smrg      new_value = xstrdup (add);
49001fb744b4Smrg    }
49011fb744b4Smrg  return new_value;
49021fb744b4Smrg}
4903f55e6a01Smrg
49041fb744b4Smrgvoid
49051fb744b4Smrglt_update_exe_path (const char *name, const char *value)
49061fb744b4Smrg{
49071fb744b4Smrg  lt_debugprintf (__FILE__, __LINE__,
49081fb744b4Smrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
49091fb744b4Smrg                  nonnull (name), nonnull (value));
4910f55e6a01Smrg
49111fb744b4Smrg  if (name && *name && value && *value)
49121fb744b4Smrg    {
49131fb744b4Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
49141fb744b4Smrg      /* some systems can't cope with a ':'-terminated path #' */
49151fb744b4Smrg      int len = strlen (new_value);
49161fb744b4Smrg      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
49171fb744b4Smrg        {
49181fb744b4Smrg          new_value[len-1] = '\0';
49191fb744b4Smrg        }
49201fb744b4Smrg      lt_setenv (name, new_value);
49211fb744b4Smrg      XFREE (new_value);
49221fb744b4Smrg    }
49231fb744b4Smrg}
4924f55e6a01Smrg
49251fb744b4Smrgvoid
49261fb744b4Smrglt_update_lib_path (const char *name, const char *value)
49271fb744b4Smrg{
49281fb744b4Smrg  lt_debugprintf (__FILE__, __LINE__,
49291fb744b4Smrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
49301fb744b4Smrg                  nonnull (name), nonnull (value));
4931f55e6a01Smrg
49321fb744b4Smrg  if (name && *name && value && *value)
49331fb744b4Smrg    {
49341fb744b4Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
49351fb744b4Smrg      lt_setenv (name, new_value);
49361fb744b4Smrg      XFREE (new_value);
49371fb744b4Smrg    }
49381fb744b4Smrg}
4939f55e6a01Smrg
4940518bcf38SmrgEOF
49411fb744b4Smrg	    case $host_os in
49421fb744b4Smrg	      mingw*)
49431fb744b4Smrg		cat <<"EOF"
49441fb744b4Smrg
49451fb744b4Smrg/* Prepares an argument vector before calling spawn().
49461fb744b4Smrg   Note that spawn() does not by itself call the command interpreter
49471fb744b4Smrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
49481fb744b4Smrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
49491fb744b4Smrg         GetVersionEx(&v);
49501fb744b4Smrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
49511fb744b4Smrg      }) ? "cmd.exe" : "command.com").
49521fb744b4Smrg   Instead it simply concatenates the arguments, separated by ' ', and calls
49531fb744b4Smrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
49541fb744b4Smrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
49551fb744b4Smrg   special way:
49561fb744b4Smrg   - Space and tab are interpreted as delimiters. They are not treated as
49571fb744b4Smrg     delimiters if they are surrounded by double quotes: "...".
49581fb744b4Smrg   - Unescaped double quotes are removed from the input. Their only effect is
49591fb744b4Smrg     that within double quotes, space and tab are treated like normal
49601fb744b4Smrg     characters.
49611fb744b4Smrg   - Backslashes not followed by double quotes are not special.
49621fb744b4Smrg   - But 2*n+1 backslashes followed by a double quote become
49631fb744b4Smrg     n backslashes followed by a double quote (n >= 0):
49641fb744b4Smrg       \" -> "
49651fb744b4Smrg       \\\" -> \"
49661fb744b4Smrg       \\\\\" -> \\"
49671fb744b4Smrg */
49681fb744b4Smrg#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"
49691fb744b4Smrg#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"
49701fb744b4Smrgchar **
49711fb744b4Smrgprepare_spawn (char **argv)
4972518bcf38Smrg{
49731fb744b4Smrg  size_t argc;
49741fb744b4Smrg  char **new_argv;
49751fb744b4Smrg  size_t i;
4976f55e6a01Smrg
49771fb744b4Smrg  /* Count number of arguments.  */
49781fb744b4Smrg  for (argc = 0; argv[argc] != NULL; argc++)
49791fb744b4Smrg    ;
4980f55e6a01Smrg
49811fb744b4Smrg  /* Allocate new argument vector.  */
49821fb744b4Smrg  new_argv = XMALLOC (char *, argc + 1);
4983f55e6a01Smrg
49841fb744b4Smrg  /* Put quoted arguments into the new argument vector.  */
49851fb744b4Smrg  for (i = 0; i < argc; i++)
49861fb744b4Smrg    {
49871fb744b4Smrg      const char *string = argv[i];
49881fb744b4Smrg
49891fb744b4Smrg      if (string[0] == '\0')
49901fb744b4Smrg	new_argv[i] = xstrdup ("\"\"");
49911fb744b4Smrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
49921fb744b4Smrg	{
49931fb744b4Smrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
49941fb744b4Smrg	  size_t length;
49951fb744b4Smrg	  unsigned int backslashes;
49961fb744b4Smrg	  const char *s;
49971fb744b4Smrg	  char *quoted_string;
49981fb744b4Smrg	  char *p;
49991fb744b4Smrg
50001fb744b4Smrg	  length = 0;
50011fb744b4Smrg	  backslashes = 0;
50021fb744b4Smrg	  if (quote_around)
50031fb744b4Smrg	    length++;
50041fb744b4Smrg	  for (s = string; *s != '\0'; s++)
50051fb744b4Smrg	    {
50061fb744b4Smrg	      char c = *s;
50071fb744b4Smrg	      if (c == '"')
50081fb744b4Smrg		length += backslashes + 1;
50091fb744b4Smrg	      length++;
50101fb744b4Smrg	      if (c == '\\')
50111fb744b4Smrg		backslashes++;
50121fb744b4Smrg	      else
50131fb744b4Smrg		backslashes = 0;
50141fb744b4Smrg	    }
50151fb744b4Smrg	  if (quote_around)
50161fb744b4Smrg	    length += backslashes + 1;
50171fb744b4Smrg
50181fb744b4Smrg	  quoted_string = XMALLOC (char, length + 1);
50191fb744b4Smrg
50201fb744b4Smrg	  p = quoted_string;
50211fb744b4Smrg	  backslashes = 0;
50221fb744b4Smrg	  if (quote_around)
50231fb744b4Smrg	    *p++ = '"';
50241fb744b4Smrg	  for (s = string; *s != '\0'; s++)
50251fb744b4Smrg	    {
50261fb744b4Smrg	      char c = *s;
50271fb744b4Smrg	      if (c == '"')
50281fb744b4Smrg		{
50291fb744b4Smrg		  unsigned int j;
50301fb744b4Smrg		  for (j = backslashes + 1; j > 0; j--)
50311fb744b4Smrg		    *p++ = '\\';
50321fb744b4Smrg		}
50331fb744b4Smrg	      *p++ = c;
50341fb744b4Smrg	      if (c == '\\')
50351fb744b4Smrg		backslashes++;
50361fb744b4Smrg	      else
50371fb744b4Smrg		backslashes = 0;
50381fb744b4Smrg	    }
50391fb744b4Smrg	  if (quote_around)
50401fb744b4Smrg	    {
50411fb744b4Smrg	      unsigned int j;
50421fb744b4Smrg	      for (j = backslashes; j > 0; j--)
50431fb744b4Smrg		*p++ = '\\';
50441fb744b4Smrg	      *p++ = '"';
50451fb744b4Smrg	    }
50461fb744b4Smrg	  *p = '\0';
5047f55e6a01Smrg
50481fb744b4Smrg	  new_argv[i] = quoted_string;
50491fb744b4Smrg	}
50501fb744b4Smrg      else
50511fb744b4Smrg	new_argv[i] = (char *) string;
50521fb744b4Smrg    }
50531fb744b4Smrg  new_argv[argc] = NULL;
5054f55e6a01Smrg
50551fb744b4Smrg  return new_argv;
50561fb744b4Smrg}
5057518bcf38SmrgEOF
50581fb744b4Smrg		;;
50591fb744b4Smrg	    esac
5060f55e6a01Smrg
50611fb744b4Smrg            cat <<"EOF"
50621fb744b4Smrgvoid lt_dump_script (FILE* f)
50631fb744b4Smrg{
5064518bcf38SmrgEOF
50651fb744b4Smrg	    func_emit_wrapper yes |
50661fb744b4Smrg	      $SED -n -e '
50671fb744b4Smrgs/^\(.\{79\}\)\(..*\)/\1\
50681fb744b4Smrg\2/
50691fb744b4Smrgh
50701fb744b4Smrgs/\([\\"]\)/\\\1/g
50711fb744b4Smrgs/$/\\n/
50721fb744b4Smrgs/\([^\n]*\).*/  fputs ("\1", f);/p
50731fb744b4Smrgg
50741fb744b4SmrgD'
50751fb744b4Smrg            cat <<"EOF"
5076518bcf38Smrg}
50771fb744b4SmrgEOF
5078518bcf38Smrg}
50791fb744b4Smrg# end: func_emit_cwrapperexe_src
5080f55e6a01Smrg
50811fb744b4Smrg# func_win32_import_lib_p ARG
50821fb744b4Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd
50831fb744b4Smrgfunc_win32_import_lib_p ()
5084518bcf38Smrg{
50851fb744b4Smrg    $opt_debug
50861fb744b4Smrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
50871fb744b4Smrg    *import*) : ;;
50881fb744b4Smrg    *) false ;;
50891fb744b4Smrg    esac
5090518bcf38Smrg}
5091f55e6a01Smrg
50921fb744b4Smrg# func_mode_link arg...
50931fb744b4Smrgfunc_mode_link ()
5094518bcf38Smrg{
50951fb744b4Smrg    $opt_debug
50961fb744b4Smrg    case $host in
50971fb744b4Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
50981fb744b4Smrg      # It is impossible to link a dll without this setting, and
50991fb744b4Smrg      # we shouldn't force the makefile maintainer to figure out
51001fb744b4Smrg      # which system we are compiling for in order to pass an extra
51011fb744b4Smrg      # flag for every libtool invocation.
51021fb744b4Smrg      # allow_undefined=no
5103f55e6a01Smrg
51041fb744b4Smrg      # FIXME: Unfortunately, there are problems with the above when trying
51051fb744b4Smrg      # to make a dll which has undefined symbols, in which case not
51061fb744b4Smrg      # even a static library is built.  For now, we need to specify
51071fb744b4Smrg      # -no-undefined on the libtool link line when we can be certain
51081fb744b4Smrg      # that all symbols are satisfied, otherwise we get a static library.
51091fb744b4Smrg      allow_undefined=yes
51101fb744b4Smrg      ;;
51111fb744b4Smrg    *)
51121fb744b4Smrg      allow_undefined=yes
51131fb744b4Smrg      ;;
51141fb744b4Smrg    esac
51151fb744b4Smrg    libtool_args=$nonopt
51161fb744b4Smrg    base_compile="$nonopt $@"
51171fb744b4Smrg    compile_command=$nonopt
51181fb744b4Smrg    finalize_command=$nonopt
5119f55e6a01Smrg
51201fb744b4Smrg    compile_rpath=
51211fb744b4Smrg    finalize_rpath=
51221fb744b4Smrg    compile_shlibpath=
51231fb744b4Smrg    finalize_shlibpath=
51241fb744b4Smrg    convenience=
51251fb744b4Smrg    old_convenience=
51261fb744b4Smrg    deplibs=
51271fb744b4Smrg    old_deplibs=
51281fb744b4Smrg    compiler_flags=
51291fb744b4Smrg    linker_flags=
51301fb744b4Smrg    dllsearchpath=
51311fb744b4Smrg    lib_search_path=`pwd`
51321fb744b4Smrg    inst_prefix_dir=
51331fb744b4Smrg    new_inherited_linker_flags=
5134f55e6a01Smrg
51351fb744b4Smrg    avoid_version=no
51361fb744b4Smrg    bindir=
51371fb744b4Smrg    dlfiles=
51381fb744b4Smrg    dlprefiles=
51391fb744b4Smrg    dlself=no
51401fb744b4Smrg    export_dynamic=no
51411fb744b4Smrg    export_symbols=
51421fb744b4Smrg    export_symbols_regex=
51431fb744b4Smrg    generated=
51441fb744b4Smrg    libobjs=
51451fb744b4Smrg    ltlibs=
51461fb744b4Smrg    module=no
51471fb744b4Smrg    no_install=no
51481fb744b4Smrg    objs=
51491fb744b4Smrg    non_pic_objects=
51501fb744b4Smrg    precious_files_regex=
51511fb744b4Smrg    prefer_static_libs=no
51521fb744b4Smrg    preload=no
51531fb744b4Smrg    prev=
51541fb744b4Smrg    prevarg=
51551fb744b4Smrg    release=
51561fb744b4Smrg    rpath=
51571fb744b4Smrg    xrpath=
51581fb744b4Smrg    perm_rpath=
51591fb744b4Smrg    temp_rpath=
51601fb744b4Smrg    thread_safe=no
51611fb744b4Smrg    vinfo=
51621fb744b4Smrg    vinfo_number=no
51631fb744b4Smrg    weak_libs=
51641fb744b4Smrg    single_module="${wl}-single_module"
51651fb744b4Smrg    func_infer_tag $base_compile
5166c35d236eSmrg
51671fb744b4Smrg    # We need to know -static, to get the right output filenames.
51681fb744b4Smrg    for arg
51691fb744b4Smrg    do
51701fb744b4Smrg      case $arg in
51711fb744b4Smrg      -shared)
51721fb744b4Smrg	test "$build_libtool_libs" != yes && \
51731fb744b4Smrg	  func_fatal_configuration "can not build a shared library"
51741fb744b4Smrg	build_old_libs=no
51751fb744b4Smrg	break
51761fb744b4Smrg	;;
51771fb744b4Smrg      -all-static | -static | -static-libtool-libs)
51781fb744b4Smrg	case $arg in
51791fb744b4Smrg	-all-static)
51801fb744b4Smrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
51811fb744b4Smrg	    func_warning "complete static linking is impossible in this configuration"
51821fb744b4Smrg	  fi
51831fb744b4Smrg	  if test -n "$link_static_flag"; then
51841fb744b4Smrg	    dlopen_self=$dlopen_self_static
51851fb744b4Smrg	  fi
51861fb744b4Smrg	  prefer_static_libs=yes
51871fb744b4Smrg	  ;;
51881fb744b4Smrg	-static)
51891fb744b4Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
51901fb744b4Smrg	    dlopen_self=$dlopen_self_static
51911fb744b4Smrg	  fi
51921fb744b4Smrg	  prefer_static_libs=built
51931fb744b4Smrg	  ;;
51941fb744b4Smrg	-static-libtool-libs)
51951fb744b4Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
51961fb744b4Smrg	    dlopen_self=$dlopen_self_static
51971fb744b4Smrg	  fi
51981fb744b4Smrg	  prefer_static_libs=yes
51991fb744b4Smrg	  ;;
52001fb744b4Smrg	esac
52011fb744b4Smrg	build_libtool_libs=no
52021fb744b4Smrg	build_old_libs=yes
52031fb744b4Smrg	break
52041fb744b4Smrg	;;
52051fb744b4Smrg      esac
52061fb744b4Smrg    done
5207c35d236eSmrg
52081fb744b4Smrg    # See if our shared archives depend on static archives.
52091fb744b4Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
5210c35d236eSmrg
52111fb744b4Smrg    # Go through the arguments, transforming them on the way.
52121fb744b4Smrg    while test "$#" -gt 0; do
52131fb744b4Smrg      arg="$1"
52141fb744b4Smrg      shift
52151fb744b4Smrg      func_quote_for_eval "$arg"
52161fb744b4Smrg      qarg=$func_quote_for_eval_unquoted_result
52171fb744b4Smrg      func_append libtool_args " $func_quote_for_eval_result"
5218c35d236eSmrg
52191fb744b4Smrg      # If the previous option needs an argument, assign it.
52201fb744b4Smrg      if test -n "$prev"; then
52211fb744b4Smrg	case $prev in
52221fb744b4Smrg	output)
52231fb744b4Smrg	  func_append compile_command " @OUTPUT@"
52241fb744b4Smrg	  func_append finalize_command " @OUTPUT@"
52251fb744b4Smrg	  ;;
52261fb744b4Smrg	esac
5227518bcf38Smrg
52281fb744b4Smrg	case $prev in
52291fb744b4Smrg	bindir)
52301fb744b4Smrg	  bindir="$arg"
52311fb744b4Smrg	  prev=
52321fb744b4Smrg	  continue
52331fb744b4Smrg	  ;;
52341fb744b4Smrg	dlfiles|dlprefiles)
52351fb744b4Smrg	  if test "$preload" = no; then
52361fb744b4Smrg	    # Add the symbol object into the linking commands.
52371fb744b4Smrg	    func_append compile_command " @SYMFILE@"
52381fb744b4Smrg	    func_append finalize_command " @SYMFILE@"
52391fb744b4Smrg	    preload=yes
52401fb744b4Smrg	  fi
52411fb744b4Smrg	  case $arg in
52421fb744b4Smrg	  *.la | *.lo) ;;  # We handle these cases below.
52431fb744b4Smrg	  force)
52441fb744b4Smrg	    if test "$dlself" = no; then
52451fb744b4Smrg	      dlself=needless
52461fb744b4Smrg	      export_dynamic=yes
52471fb744b4Smrg	    fi
52481fb744b4Smrg	    prev=
52491fb744b4Smrg	    continue
52501fb744b4Smrg	    ;;
52511fb744b4Smrg	  self)
52521fb744b4Smrg	    if test "$prev" = dlprefiles; then
52531fb744b4Smrg	      dlself=yes
52541fb744b4Smrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
52551fb744b4Smrg	      dlself=yes
52561fb744b4Smrg	    else
52571fb744b4Smrg	      dlself=needless
52581fb744b4Smrg	      export_dynamic=yes
52591fb744b4Smrg	    fi
52601fb744b4Smrg	    prev=
52611fb744b4Smrg	    continue
52621fb744b4Smrg	    ;;
52631fb744b4Smrg	  *)
52641fb744b4Smrg	    if test "$prev" = dlfiles; then
52651fb744b4Smrg	      func_append dlfiles " $arg"
52661fb744b4Smrg	    else
52671fb744b4Smrg	      func_append dlprefiles " $arg"
52681fb744b4Smrg	    fi
52691fb744b4Smrg	    prev=
52701fb744b4Smrg	    continue
52711fb744b4Smrg	    ;;
52721fb744b4Smrg	  esac
52731fb744b4Smrg	  ;;
52741fb744b4Smrg	expsyms)
52751fb744b4Smrg	  export_symbols="$arg"
52761fb744b4Smrg	  test -f "$arg" \
52771fb744b4Smrg	    || func_fatal_error "symbol file \`$arg' does not exist"
52781fb744b4Smrg	  prev=
52791fb744b4Smrg	  continue
52801fb744b4Smrg	  ;;
52811fb744b4Smrg	expsyms_regex)
52821fb744b4Smrg	  export_symbols_regex="$arg"
52831fb744b4Smrg	  prev=
52841fb744b4Smrg	  continue
52851fb744b4Smrg	  ;;
52861fb744b4Smrg	framework)
52871fb744b4Smrg	  case $host in
52881fb744b4Smrg	    *-*-darwin*)
52891fb744b4Smrg	      case "$deplibs " in
52901fb744b4Smrg		*" $qarg.ltframework "*) ;;
52911fb744b4Smrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
52921fb744b4Smrg		   ;;
52931fb744b4Smrg	      esac
52941fb744b4Smrg	      ;;
52951fb744b4Smrg	  esac
52961fb744b4Smrg	  prev=
52971fb744b4Smrg	  continue
52981fb744b4Smrg	  ;;
52991fb744b4Smrg	inst_prefix)
53001fb744b4Smrg	  inst_prefix_dir="$arg"
53011fb744b4Smrg	  prev=
53021fb744b4Smrg	  continue
53031fb744b4Smrg	  ;;
53041fb744b4Smrg	objectlist)
53051fb744b4Smrg	  if test -f "$arg"; then
53061fb744b4Smrg	    save_arg=$arg
53071fb744b4Smrg	    moreargs=
53081fb744b4Smrg	    for fil in `cat "$save_arg"`
53091fb744b4Smrg	    do
53101fb744b4Smrg#	      func_append moreargs " $fil"
53111fb744b4Smrg	      arg=$fil
53121fb744b4Smrg	      # A libtool-controlled object.
5313518bcf38Smrg
53141fb744b4Smrg	      # Check to see that this really is a libtool object.
53151fb744b4Smrg	      if func_lalib_unsafe_p "$arg"; then
53161fb744b4Smrg		pic_object=
53171fb744b4Smrg		non_pic_object=
5318518bcf38Smrg
53191fb744b4Smrg		# Read the .lo file
53201fb744b4Smrg		func_source "$arg"
5321518bcf38Smrg
53221fb744b4Smrg		if test -z "$pic_object" ||
53231fb744b4Smrg		   test -z "$non_pic_object" ||
53241fb744b4Smrg		   test "$pic_object" = none &&
53251fb744b4Smrg		   test "$non_pic_object" = none; then
53261fb744b4Smrg		  func_fatal_error "cannot find name of object for \`$arg'"
53271fb744b4Smrg		fi
5328518bcf38Smrg
53291fb744b4Smrg		# Extract subdirectory from the argument.
53301fb744b4Smrg		func_dirname "$arg" "/" ""
53311fb744b4Smrg		xdir="$func_dirname_result"
5332518bcf38Smrg
53331fb744b4Smrg		if test "$pic_object" != none; then
53341fb744b4Smrg		  # Prepend the subdirectory the object is found in.
53351fb744b4Smrg		  pic_object="$xdir$pic_object"
5336518bcf38Smrg
53371fb744b4Smrg		  if test "$prev" = dlfiles; then
53381fb744b4Smrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
53391fb744b4Smrg		      func_append dlfiles " $pic_object"
53401fb744b4Smrg		      prev=
53411fb744b4Smrg		      continue
53421fb744b4Smrg		    else
53431fb744b4Smrg		      # If libtool objects are unsupported, then we need to preload.
53441fb744b4Smrg		      prev=dlprefiles
53451fb744b4Smrg		    fi
53461fb744b4Smrg		  fi
5347518bcf38Smrg
53481fb744b4Smrg		  # CHECK ME:  I think I busted this.  -Ossama
53491fb744b4Smrg		  if test "$prev" = dlprefiles; then
53501fb744b4Smrg		    # Preload the old-style object.
53511fb744b4Smrg		    func_append dlprefiles " $pic_object"
53521fb744b4Smrg		    prev=
53531fb744b4Smrg		  fi
5354518bcf38Smrg
53551fb744b4Smrg		  # A PIC object.
53561fb744b4Smrg		  func_append libobjs " $pic_object"
53571fb744b4Smrg		  arg="$pic_object"
53581fb744b4Smrg		fi
5359518bcf38Smrg
53601fb744b4Smrg		# Non-PIC object.
53611fb744b4Smrg		if test "$non_pic_object" != none; then
53621fb744b4Smrg		  # Prepend the subdirectory the object is found in.
53631fb744b4Smrg		  non_pic_object="$xdir$non_pic_object"
5364518bcf38Smrg
53651fb744b4Smrg		  # A standard non-PIC object
53661fb744b4Smrg		  func_append non_pic_objects " $non_pic_object"
53671fb744b4Smrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
53681fb744b4Smrg		    arg="$non_pic_object"
53691fb744b4Smrg		  fi
53701fb744b4Smrg		else
53711fb744b4Smrg		  # If the PIC object exists, use it instead.
53721fb744b4Smrg		  # $xdir was prepended to $pic_object above.
53731fb744b4Smrg		  non_pic_object="$pic_object"
53741fb744b4Smrg		  func_append non_pic_objects " $non_pic_object"
53751fb744b4Smrg		fi
53761fb744b4Smrg	      else
53771fb744b4Smrg		# Only an error if not doing a dry-run.
53781fb744b4Smrg		if $opt_dry_run; then
53791fb744b4Smrg		  # Extract subdirectory from the argument.
53801fb744b4Smrg		  func_dirname "$arg" "/" ""
53811fb744b4Smrg		  xdir="$func_dirname_result"
53821fb744b4Smrg
53831fb744b4Smrg		  func_lo2o "$arg"
53841fb744b4Smrg		  pic_object=$xdir$objdir/$func_lo2o_result
53851fb744b4Smrg		  non_pic_object=$xdir$func_lo2o_result
53861fb744b4Smrg		  func_append libobjs " $pic_object"
53871fb744b4Smrg		  func_append non_pic_objects " $non_pic_object"
53881fb744b4Smrg	        else
53891fb744b4Smrg		  func_fatal_error "\`$arg' is not a valid libtool object"
53901fb744b4Smrg		fi
53911fb744b4Smrg	      fi
53921fb744b4Smrg	    done
53931fb744b4Smrg	  else
53941fb744b4Smrg	    func_fatal_error "link input file \`$arg' does not exist"
53951fb744b4Smrg	  fi
53961fb744b4Smrg	  arg=$save_arg
53971fb744b4Smrg	  prev=
53981fb744b4Smrg	  continue
53991fb744b4Smrg	  ;;
54001fb744b4Smrg	precious_regex)
54011fb744b4Smrg	  precious_files_regex="$arg"
54021fb744b4Smrg	  prev=
54031fb744b4Smrg	  continue
54041fb744b4Smrg	  ;;
54051fb744b4Smrg	release)
54061fb744b4Smrg	  release="-$arg"
54071fb744b4Smrg	  prev=
54081fb744b4Smrg	  continue
54091fb744b4Smrg	  ;;
54101fb744b4Smrg	rpath | xrpath)
54111fb744b4Smrg	  # We need an absolute path.
54121fb744b4Smrg	  case $arg in
54131fb744b4Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
54141fb744b4Smrg	  *)
54151fb744b4Smrg	    func_fatal_error "only absolute run-paths are allowed"
54161fb744b4Smrg	    ;;
54171fb744b4Smrg	  esac
54181fb744b4Smrg	  if test "$prev" = rpath; then
54191fb744b4Smrg	    case "$rpath " in
54201fb744b4Smrg	    *" $arg "*) ;;
54211fb744b4Smrg	    *) func_append rpath " $arg" ;;
54221fb744b4Smrg	    esac
54231fb744b4Smrg	  else
54241fb744b4Smrg	    case "$xrpath " in
54251fb744b4Smrg	    *" $arg "*) ;;
54261fb744b4Smrg	    *) func_append xrpath " $arg" ;;
54271fb744b4Smrg	    esac
54281fb744b4Smrg	  fi
54291fb744b4Smrg	  prev=
54301fb744b4Smrg	  continue
54311fb744b4Smrg	  ;;
54321fb744b4Smrg	shrext)
54331fb744b4Smrg	  shrext_cmds="$arg"
54341fb744b4Smrg	  prev=
54351fb744b4Smrg	  continue
54361fb744b4Smrg	  ;;
54371fb744b4Smrg	weak)
54381fb744b4Smrg	  func_append weak_libs " $arg"
54391fb744b4Smrg	  prev=
54401fb744b4Smrg	  continue
54411fb744b4Smrg	  ;;
54421fb744b4Smrg	xcclinker)
54431fb744b4Smrg	  func_append linker_flags " $qarg"
54441fb744b4Smrg	  func_append compiler_flags " $qarg"
54451fb744b4Smrg	  prev=
54461fb744b4Smrg	  func_append compile_command " $qarg"
54471fb744b4Smrg	  func_append finalize_command " $qarg"
54481fb744b4Smrg	  continue
54491fb744b4Smrg	  ;;
54501fb744b4Smrg	xcompiler)
54511fb744b4Smrg	  func_append compiler_flags " $qarg"
54521fb744b4Smrg	  prev=
54531fb744b4Smrg	  func_append compile_command " $qarg"
54541fb744b4Smrg	  func_append finalize_command " $qarg"
54551fb744b4Smrg	  continue
54561fb744b4Smrg	  ;;
54571fb744b4Smrg	xlinker)
54581fb744b4Smrg	  func_append linker_flags " $qarg"
54591fb744b4Smrg	  func_append compiler_flags " $wl$qarg"
54601fb744b4Smrg	  prev=
54611fb744b4Smrg	  func_append compile_command " $wl$qarg"
54621fb744b4Smrg	  func_append finalize_command " $wl$qarg"
54631fb744b4Smrg	  continue
54641fb744b4Smrg	  ;;
54651fb744b4Smrg	*)
54661fb744b4Smrg	  eval "$prev=\"\$arg\""
54671fb744b4Smrg	  prev=
54681fb744b4Smrg	  continue
54691fb744b4Smrg	  ;;
54701fb744b4Smrg	esac
54711fb744b4Smrg      fi # test -n "$prev"
5472518bcf38Smrg
54731fb744b4Smrg      prevarg="$arg"
5474518bcf38Smrg
54751fb744b4Smrg      case $arg in
54761fb744b4Smrg      -all-static)
54771fb744b4Smrg	if test -n "$link_static_flag"; then
54781fb744b4Smrg	  # See comment for -static flag below, for more details.
54791fb744b4Smrg	  func_append compile_command " $link_static_flag"
54801fb744b4Smrg	  func_append finalize_command " $link_static_flag"
54811fb744b4Smrg	fi
54821fb744b4Smrg	continue
54831fb744b4Smrg	;;
5484518bcf38Smrg
54851fb744b4Smrg      -allow-undefined)
54861fb744b4Smrg	# FIXME: remove this flag sometime in the future.
54871fb744b4Smrg	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
54881fb744b4Smrg	;;
5489518bcf38Smrg
54901fb744b4Smrg      -avoid-version)
54911fb744b4Smrg	avoid_version=yes
54921fb744b4Smrg	continue
54931fb744b4Smrg	;;
5494518bcf38Smrg
54951fb744b4Smrg      -bindir)
54961fb744b4Smrg	prev=bindir
54971fb744b4Smrg	continue
54981fb744b4Smrg	;;
5499c35d236eSmrg
55001fb744b4Smrg      -dlopen)
55011fb744b4Smrg	prev=dlfiles
55021fb744b4Smrg	continue
55031fb744b4Smrg	;;
5504c35d236eSmrg
55051fb744b4Smrg      -dlpreopen)
55061fb744b4Smrg	prev=dlprefiles
55071fb744b4Smrg	continue
55081fb744b4Smrg	;;
5509c35d236eSmrg
55101fb744b4Smrg      -export-dynamic)
55111fb744b4Smrg	export_dynamic=yes
55121fb744b4Smrg	continue
55131fb744b4Smrg	;;
5514f55e6a01Smrg
55151fb744b4Smrg      -export-symbols | -export-symbols-regex)
55161fb744b4Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
55171fb744b4Smrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
55181fb744b4Smrg	fi
55191fb744b4Smrg	if test "X$arg" = "X-export-symbols"; then
55201fb744b4Smrg	  prev=expsyms
55211fb744b4Smrg	else
55221fb744b4Smrg	  prev=expsyms_regex
55231fb744b4Smrg	fi
55241fb744b4Smrg	continue
55251fb744b4Smrg	;;
5526f55e6a01Smrg
55271fb744b4Smrg      -framework)
55281fb744b4Smrg	prev=framework
55291fb744b4Smrg	continue
55301fb744b4Smrg	;;
5531c35d236eSmrg
55321fb744b4Smrg      -inst-prefix-dir)
55331fb744b4Smrg	prev=inst_prefix
55341fb744b4Smrg	continue
55351fb744b4Smrg	;;
5536c35d236eSmrg
55371fb744b4Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
55381fb744b4Smrg      # so, if we see these flags be careful not to treat them like -L
55391fb744b4Smrg      -L[A-Z][A-Z]*:*)
55401fb744b4Smrg	case $with_gcc/$host in
55411fb744b4Smrg	no/*-*-irix* | /*-*-irix*)
55421fb744b4Smrg	  func_append compile_command " $arg"
55431fb744b4Smrg	  func_append finalize_command " $arg"
55441fb744b4Smrg	  ;;
55451fb744b4Smrg	esac
55461fb744b4Smrg	continue
55471fb744b4Smrg	;;
5548c35d236eSmrg
55491fb744b4Smrg      -L*)
55501fb744b4Smrg	func_stripname "-L" '' "$arg"
55511fb744b4Smrg	if test -z "$func_stripname_result"; then
55521fb744b4Smrg	  if test "$#" -gt 0; then
55531fb744b4Smrg	    func_fatal_error "require no space between \`-L' and \`$1'"
55541fb744b4Smrg	  else
55551fb744b4Smrg	    func_fatal_error "need path for \`-L' option"
55561fb744b4Smrg	  fi
55571fb744b4Smrg	fi
55581fb744b4Smrg	func_resolve_sysroot "$func_stripname_result"
55591fb744b4Smrg	dir=$func_resolve_sysroot_result
55601fb744b4Smrg	# We need an absolute path.
55611fb744b4Smrg	case $dir in
55621fb744b4Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
55631fb744b4Smrg	*)
55641fb744b4Smrg	  absdir=`cd "$dir" && pwd`
55651fb744b4Smrg	  test -z "$absdir" && \
55661fb744b4Smrg	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
55671fb744b4Smrg	  dir="$absdir"
55681fb744b4Smrg	  ;;
55691fb744b4Smrg	esac
55701fb744b4Smrg	case "$deplibs " in
55711fb744b4Smrg	*" -L$dir "* | *" $arg "*)
55721fb744b4Smrg	  # Will only happen for absolute or sysroot arguments
55731fb744b4Smrg	  ;;
55741fb744b4Smrg	*)
55751fb744b4Smrg	  # Preserve sysroot, but never include relative directories
55761fb744b4Smrg	  case $dir in
55771fb744b4Smrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
55781fb744b4Smrg	    *) func_append deplibs " -L$dir" ;;
55791fb744b4Smrg	  esac
55801fb744b4Smrg	  func_append lib_search_path " $dir"
55811fb744b4Smrg	  ;;
55821fb744b4Smrg	esac
55831fb744b4Smrg	case $host in
55841fb744b4Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
55851fb744b4Smrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
55861fb744b4Smrg	  case :$dllsearchpath: in
55871fb744b4Smrg	  *":$dir:"*) ;;
55881fb744b4Smrg	  ::) dllsearchpath=$dir;;
55891fb744b4Smrg	  *) func_append dllsearchpath ":$dir";;
55901fb744b4Smrg	  esac
55911fb744b4Smrg	  case :$dllsearchpath: in
55921fb744b4Smrg	  *":$testbindir:"*) ;;
55931fb744b4Smrg	  ::) dllsearchpath=$testbindir;;
55941fb744b4Smrg	  *) func_append dllsearchpath ":$testbindir";;
55951fb744b4Smrg	  esac
55961fb744b4Smrg	  ;;
55971fb744b4Smrg	esac
55981fb744b4Smrg	continue
55991fb744b4Smrg	;;
5600c35d236eSmrg
56011fb744b4Smrg      -l*)
56021fb744b4Smrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
56031fb744b4Smrg	  case $host in
56041fb744b4Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
56051fb744b4Smrg	    # These systems don't actually have a C or math library (as such)
56061fb744b4Smrg	    continue
56071fb744b4Smrg	    ;;
56081fb744b4Smrg	  *-*-os2*)
56091fb744b4Smrg	    # These systems don't actually have a C library (as such)
56101fb744b4Smrg	    test "X$arg" = "X-lc" && continue
56111fb744b4Smrg	    ;;
56121fb744b4Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
56131fb744b4Smrg	    # Do not include libc due to us having libc/libc_r.
56141fb744b4Smrg	    test "X$arg" = "X-lc" && continue
56151fb744b4Smrg	    ;;
56161fb744b4Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
56171fb744b4Smrg	    # Rhapsody C and math libraries are in the System framework
56181fb744b4Smrg	    func_append deplibs " System.ltframework"
56191fb744b4Smrg	    continue
56201fb744b4Smrg	    ;;
56211fb744b4Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
56221fb744b4Smrg	    # Causes problems with __ctype
56231fb744b4Smrg	    test "X$arg" = "X-lc" && continue
56241fb744b4Smrg	    ;;
56251fb744b4Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
56261fb744b4Smrg	    # Compiler inserts libc in the correct place for threads to work
56271fb744b4Smrg	    test "X$arg" = "X-lc" && continue
56281fb744b4Smrg	    ;;
56291fb744b4Smrg	  esac
56301fb744b4Smrg	elif test "X$arg" = "X-lc_r"; then
56311fb744b4Smrg	 case $host in
56321fb744b4Smrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
56331fb744b4Smrg	   # Do not include libc_r directly, use -pthread flag.
56341fb744b4Smrg	   continue
56351fb744b4Smrg	   ;;
56361fb744b4Smrg	 esac
56371fb744b4Smrg	fi
56381fb744b4Smrg	func_append deplibs " $arg"
56391fb744b4Smrg	continue
56401fb744b4Smrg	;;
56411fb744b4Smrg
56421fb744b4Smrg      -module)
56431fb744b4Smrg	module=yes
56441fb744b4Smrg	continue
56451fb744b4Smrg	;;
56461fb744b4Smrg
56471fb744b4Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
56481fb744b4Smrg      # classes, name mangling, and exception handling.
56491fb744b4Smrg      # Darwin uses the -arch flag to determine output architecture.
56501fb744b4Smrg      -model|-arch|-isysroot|--sysroot)
56511fb744b4Smrg	func_append compiler_flags " $arg"
56521fb744b4Smrg	func_append compile_command " $arg"
56531fb744b4Smrg	func_append finalize_command " $arg"
56541fb744b4Smrg	prev=xcompiler
56551fb744b4Smrg	continue
56561fb744b4Smrg	;;
56571fb744b4Smrg
56581fb744b4Smrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
56591fb744b4Smrg      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
56601fb744b4Smrg	func_append compiler_flags " $arg"
56611fb744b4Smrg	func_append compile_command " $arg"
56621fb744b4Smrg	func_append finalize_command " $arg"
56631fb744b4Smrg	case "$new_inherited_linker_flags " in
56641fb744b4Smrg	    *" $arg "*) ;;
56651fb744b4Smrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
56661fb744b4Smrg	esac
56671fb744b4Smrg	continue
56681fb744b4Smrg	;;
56691fb744b4Smrg
56701fb744b4Smrg      -multi_module)
56711fb744b4Smrg	single_module="${wl}-multi_module"
56721fb744b4Smrg	continue
56731fb744b4Smrg	;;
56741fb744b4Smrg
56751fb744b4Smrg      -no-fast-install)
56761fb744b4Smrg	fast_install=no
56771fb744b4Smrg	continue
56781fb744b4Smrg	;;
56791fb744b4Smrg
56801fb744b4Smrg      -no-install)
56811fb744b4Smrg	case $host in
56821fb744b4Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
56831fb744b4Smrg	  # The PATH hackery in wrapper scripts is required on Windows
56841fb744b4Smrg	  # and Darwin in order for the loader to find any dlls it needs.
56851fb744b4Smrg	  func_warning "\`-no-install' is ignored for $host"
56861fb744b4Smrg	  func_warning "assuming \`-no-fast-install' instead"
56871fb744b4Smrg	  fast_install=no
56881fb744b4Smrg	  ;;
56891fb744b4Smrg	*) no_install=yes ;;
56901fb744b4Smrg	esac
56911fb744b4Smrg	continue
56921fb744b4Smrg	;;
56931fb744b4Smrg
56941fb744b4Smrg      -no-undefined)
56951fb744b4Smrg	allow_undefined=no
56961fb744b4Smrg	continue
56971fb744b4Smrg	;;
56981fb744b4Smrg
56991fb744b4Smrg      -objectlist)
57001fb744b4Smrg	prev=objectlist
57011fb744b4Smrg	continue
57021fb744b4Smrg	;;
57031fb744b4Smrg
57041fb744b4Smrg      -o) prev=output ;;
57051fb744b4Smrg
57061fb744b4Smrg      -precious-files-regex)
57071fb744b4Smrg	prev=precious_regex
57081fb744b4Smrg	continue
57091fb744b4Smrg	;;
57101fb744b4Smrg
57111fb744b4Smrg      -release)
57121fb744b4Smrg	prev=release
57131fb744b4Smrg	continue
57141fb744b4Smrg	;;
57151fb744b4Smrg
57161fb744b4Smrg      -rpath)
57171fb744b4Smrg	prev=rpath
57181fb744b4Smrg	continue
57191fb744b4Smrg	;;
57201fb744b4Smrg
57211fb744b4Smrg      -R)
57221fb744b4Smrg	prev=xrpath
57231fb744b4Smrg	continue
57241fb744b4Smrg	;;
57251fb744b4Smrg
57261fb744b4Smrg      -R*)
57271fb744b4Smrg	func_stripname '-R' '' "$arg"
57281fb744b4Smrg	dir=$func_stripname_result
57291fb744b4Smrg	# We need an absolute path.
57301fb744b4Smrg	case $dir in
57311fb744b4Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
57321fb744b4Smrg	=*)
57331fb744b4Smrg	  func_stripname '=' '' "$dir"
57341fb744b4Smrg	  dir=$lt_sysroot$func_stripname_result
57351fb744b4Smrg	  ;;
57361fb744b4Smrg	*)
57371fb744b4Smrg	  func_fatal_error "only absolute run-paths are allowed"
57381fb744b4Smrg	  ;;
57391fb744b4Smrg	esac
57401fb744b4Smrg	case "$xrpath " in
57411fb744b4Smrg	*" $dir "*) ;;
57421fb744b4Smrg	*) func_append xrpath " $dir" ;;
57431fb744b4Smrg	esac
57441fb744b4Smrg	continue
57451fb744b4Smrg	;;
57461fb744b4Smrg
57471fb744b4Smrg      -shared)
57481fb744b4Smrg	# The effects of -shared are defined in a previous loop.
57491fb744b4Smrg	continue
57501fb744b4Smrg	;;
57511fb744b4Smrg
57521fb744b4Smrg      -shrext)
57531fb744b4Smrg	prev=shrext
57541fb744b4Smrg	continue
57551fb744b4Smrg	;;
57561fb744b4Smrg
57571fb744b4Smrg      -static | -static-libtool-libs)
57581fb744b4Smrg	# The effects of -static are defined in a previous loop.
57591fb744b4Smrg	# We used to do the same as -all-static on platforms that
57601fb744b4Smrg	# didn't have a PIC flag, but the assumption that the effects
57611fb744b4Smrg	# would be equivalent was wrong.  It would break on at least
57621fb744b4Smrg	# Digital Unix and AIX.
57631fb744b4Smrg	continue
57641fb744b4Smrg	;;
57651fb744b4Smrg
57661fb744b4Smrg      -thread-safe)
57671fb744b4Smrg	thread_safe=yes
57681fb744b4Smrg	continue
57691fb744b4Smrg	;;
57701fb744b4Smrg
57711fb744b4Smrg      -version-info)
57721fb744b4Smrg	prev=vinfo
57731fb744b4Smrg	continue
57741fb744b4Smrg	;;
57751fb744b4Smrg
57761fb744b4Smrg      -version-number)
57771fb744b4Smrg	prev=vinfo
57781fb744b4Smrg	vinfo_number=yes
57791fb744b4Smrg	continue
57801fb744b4Smrg	;;
57811fb744b4Smrg
57821fb744b4Smrg      -weak)
57831fb744b4Smrg        prev=weak
57841fb744b4Smrg	continue
57851fb744b4Smrg	;;
57861fb744b4Smrg
57871fb744b4Smrg      -Wc,*)
57881fb744b4Smrg	func_stripname '-Wc,' '' "$arg"
57891fb744b4Smrg	args=$func_stripname_result
57901fb744b4Smrg	arg=
57911fb744b4Smrg	save_ifs="$IFS"; IFS=','
57921fb744b4Smrg	for flag in $args; do
57931fb744b4Smrg	  IFS="$save_ifs"
57941fb744b4Smrg          func_quote_for_eval "$flag"
57951fb744b4Smrg	  func_append arg " $func_quote_for_eval_result"
57961fb744b4Smrg	  func_append compiler_flags " $func_quote_for_eval_result"
57971fb744b4Smrg	done
57981fb744b4Smrg	IFS="$save_ifs"
57991fb744b4Smrg	func_stripname ' ' '' "$arg"
58001fb744b4Smrg	arg=$func_stripname_result
58011fb744b4Smrg	;;
58021fb744b4Smrg
58031fb744b4Smrg      -Wl,*)
58041fb744b4Smrg	func_stripname '-Wl,' '' "$arg"
58051fb744b4Smrg	args=$func_stripname_result
58061fb744b4Smrg	arg=
58071fb744b4Smrg	save_ifs="$IFS"; IFS=','
58081fb744b4Smrg	for flag in $args; do
58091fb744b4Smrg	  IFS="$save_ifs"
58101fb744b4Smrg          func_quote_for_eval "$flag"
58111fb744b4Smrg	  func_append arg " $wl$func_quote_for_eval_result"
58121fb744b4Smrg	  func_append compiler_flags " $wl$func_quote_for_eval_result"
58131fb744b4Smrg	  func_append linker_flags " $func_quote_for_eval_result"
58141fb744b4Smrg	done
58151fb744b4Smrg	IFS="$save_ifs"
58161fb744b4Smrg	func_stripname ' ' '' "$arg"
58171fb744b4Smrg	arg=$func_stripname_result
58181fb744b4Smrg	;;
58191fb744b4Smrg
58201fb744b4Smrg      -Xcompiler)
58211fb744b4Smrg	prev=xcompiler
58221fb744b4Smrg	continue
58231fb744b4Smrg	;;
58241fb744b4Smrg
58251fb744b4Smrg      -Xlinker)
58261fb744b4Smrg	prev=xlinker
58271fb744b4Smrg	continue
58281fb744b4Smrg	;;
58291fb744b4Smrg
58301fb744b4Smrg      -XCClinker)
58311fb744b4Smrg	prev=xcclinker
58321fb744b4Smrg	continue
58331fb744b4Smrg	;;
58341fb744b4Smrg
58351fb744b4Smrg      # -msg_* for osf cc
58361fb744b4Smrg      -msg_*)
58371fb744b4Smrg	func_quote_for_eval "$arg"
58381fb744b4Smrg	arg="$func_quote_for_eval_result"
58391fb744b4Smrg	;;
58401fb744b4Smrg
58411fb744b4Smrg      # Flags to be passed through unchanged, with rationale:
58421fb744b4Smrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
58431fb744b4Smrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
58441fb744b4Smrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
58451fb744b4Smrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
58461fb744b4Smrg      # -q*                  compiler args for the IBM compiler
58471fb744b4Smrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
58481fb744b4Smrg      # -F/path              path to uninstalled frameworks, gcc on darwin
58491fb744b4Smrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
58501fb744b4Smrg      # @file                GCC response files
58511fb744b4Smrg      # -tp=*                Portland pgcc target processor selection
58521fb744b4Smrg      # --sysroot=*          for sysroot support
58531fb744b4Smrg      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
58541fb744b4Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
58551fb744b4Smrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
58561fb744b4Smrg      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
58571fb744b4Smrg        func_quote_for_eval "$arg"
58581fb744b4Smrg	arg="$func_quote_for_eval_result"
58591fb744b4Smrg        func_append compile_command " $arg"
58601fb744b4Smrg        func_append finalize_command " $arg"
58611fb744b4Smrg        func_append compiler_flags " $arg"
58621fb744b4Smrg        continue
58631fb744b4Smrg        ;;
58641fb744b4Smrg
58651fb744b4Smrg      # Some other compiler flag.
58661fb744b4Smrg      -* | +*)
58671fb744b4Smrg        func_quote_for_eval "$arg"
58681fb744b4Smrg	arg="$func_quote_for_eval_result"
58691fb744b4Smrg	;;
58701fb744b4Smrg
58711fb744b4Smrg      *.$objext)
58721fb744b4Smrg	# A standard object.
58731fb744b4Smrg	func_append objs " $arg"
58741fb744b4Smrg	;;
58751fb744b4Smrg
58761fb744b4Smrg      *.lo)
58771fb744b4Smrg	# A libtool-controlled object.
58781fb744b4Smrg
58791fb744b4Smrg	# Check to see that this really is a libtool object.
58801fb744b4Smrg	if func_lalib_unsafe_p "$arg"; then
58811fb744b4Smrg	  pic_object=
58821fb744b4Smrg	  non_pic_object=
58831fb744b4Smrg
58841fb744b4Smrg	  # Read the .lo file
58851fb744b4Smrg	  func_source "$arg"
58861fb744b4Smrg
58871fb744b4Smrg	  if test -z "$pic_object" ||
58881fb744b4Smrg	     test -z "$non_pic_object" ||
58891fb744b4Smrg	     test "$pic_object" = none &&
58901fb744b4Smrg	     test "$non_pic_object" = none; then
58911fb744b4Smrg	    func_fatal_error "cannot find name of object for \`$arg'"
58921fb744b4Smrg	  fi
58931fb744b4Smrg
58941fb744b4Smrg	  # Extract subdirectory from the argument.
58951fb744b4Smrg	  func_dirname "$arg" "/" ""
58961fb744b4Smrg	  xdir="$func_dirname_result"
58971fb744b4Smrg
58981fb744b4Smrg	  if test "$pic_object" != none; then
58991fb744b4Smrg	    # Prepend the subdirectory the object is found in.
59001fb744b4Smrg	    pic_object="$xdir$pic_object"
59011fb744b4Smrg
59021fb744b4Smrg	    if test "$prev" = dlfiles; then
59031fb744b4Smrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
59041fb744b4Smrg		func_append dlfiles " $pic_object"
59051fb744b4Smrg		prev=
59061fb744b4Smrg		continue
59071fb744b4Smrg	      else
59081fb744b4Smrg		# If libtool objects are unsupported, then we need to preload.
59091fb744b4Smrg		prev=dlprefiles
59101fb744b4Smrg	      fi
59111fb744b4Smrg	    fi
59121fb744b4Smrg
59131fb744b4Smrg	    # CHECK ME:  I think I busted this.  -Ossama
59141fb744b4Smrg	    if test "$prev" = dlprefiles; then
59151fb744b4Smrg	      # Preload the old-style object.
59161fb744b4Smrg	      func_append dlprefiles " $pic_object"
59171fb744b4Smrg	      prev=
59181fb744b4Smrg	    fi
59191fb744b4Smrg
59201fb744b4Smrg	    # A PIC object.
59211fb744b4Smrg	    func_append libobjs " $pic_object"
59221fb744b4Smrg	    arg="$pic_object"
59231fb744b4Smrg	  fi
59241fb744b4Smrg
59251fb744b4Smrg	  # Non-PIC object.
59261fb744b4Smrg	  if test "$non_pic_object" != none; then
59271fb744b4Smrg	    # Prepend the subdirectory the object is found in.
59281fb744b4Smrg	    non_pic_object="$xdir$non_pic_object"
59291fb744b4Smrg
59301fb744b4Smrg	    # A standard non-PIC object
59311fb744b4Smrg	    func_append non_pic_objects " $non_pic_object"
59321fb744b4Smrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
59331fb744b4Smrg	      arg="$non_pic_object"
59341fb744b4Smrg	    fi
59351fb744b4Smrg	  else
59361fb744b4Smrg	    # If the PIC object exists, use it instead.
59371fb744b4Smrg	    # $xdir was prepended to $pic_object above.
59381fb744b4Smrg	    non_pic_object="$pic_object"
59391fb744b4Smrg	    func_append non_pic_objects " $non_pic_object"
59401fb744b4Smrg	  fi
59411fb744b4Smrg	else
59421fb744b4Smrg	  # Only an error if not doing a dry-run.
59431fb744b4Smrg	  if $opt_dry_run; then
59441fb744b4Smrg	    # Extract subdirectory from the argument.
59451fb744b4Smrg	    func_dirname "$arg" "/" ""
59461fb744b4Smrg	    xdir="$func_dirname_result"
59471fb744b4Smrg
59481fb744b4Smrg	    func_lo2o "$arg"
59491fb744b4Smrg	    pic_object=$xdir$objdir/$func_lo2o_result
59501fb744b4Smrg	    non_pic_object=$xdir$func_lo2o_result
59511fb744b4Smrg	    func_append libobjs " $pic_object"
59521fb744b4Smrg	    func_append non_pic_objects " $non_pic_object"
59531fb744b4Smrg	  else
59541fb744b4Smrg	    func_fatal_error "\`$arg' is not a valid libtool object"
59551fb744b4Smrg	  fi
59561fb744b4Smrg	fi
59571fb744b4Smrg	;;
59581fb744b4Smrg
59591fb744b4Smrg      *.$libext)
59601fb744b4Smrg	# An archive.
59611fb744b4Smrg	func_append deplibs " $arg"
59621fb744b4Smrg	func_append old_deplibs " $arg"
59631fb744b4Smrg	continue
59641fb744b4Smrg	;;
59651fb744b4Smrg
59661fb744b4Smrg      *.la)
59671fb744b4Smrg	# A libtool-controlled library.
59681fb744b4Smrg
59691fb744b4Smrg	func_resolve_sysroot "$arg"
59701fb744b4Smrg	if test "$prev" = dlfiles; then
59711fb744b4Smrg	  # This library was specified with -dlopen.
59721fb744b4Smrg	  func_append dlfiles " $func_resolve_sysroot_result"
59731fb744b4Smrg	  prev=
59741fb744b4Smrg	elif test "$prev" = dlprefiles; then
59751fb744b4Smrg	  # The library was specified with -dlpreopen.
59761fb744b4Smrg	  func_append dlprefiles " $func_resolve_sysroot_result"
59771fb744b4Smrg	  prev=
59781fb744b4Smrg	else
59791fb744b4Smrg	  func_append deplibs " $func_resolve_sysroot_result"
59801fb744b4Smrg	fi
59811fb744b4Smrg	continue
59821fb744b4Smrg	;;
59831fb744b4Smrg
59841fb744b4Smrg      # Some other compiler argument.
59851fb744b4Smrg      *)
59861fb744b4Smrg	# Unknown arguments in both finalize_command and compile_command need
59871fb744b4Smrg	# to be aesthetically quoted because they are evaled later.
59881fb744b4Smrg	func_quote_for_eval "$arg"
59891fb744b4Smrg	arg="$func_quote_for_eval_result"
59901fb744b4Smrg	;;
59911fb744b4Smrg      esac # arg
59921fb744b4Smrg
59931fb744b4Smrg      # Now actually substitute the argument into the commands.
59941fb744b4Smrg      if test -n "$arg"; then
59951fb744b4Smrg	func_append compile_command " $arg"
59961fb744b4Smrg	func_append finalize_command " $arg"
59971fb744b4Smrg      fi
59981fb744b4Smrg    done # argument parsing loop
59991fb744b4Smrg
60001fb744b4Smrg    test -n "$prev" && \
60011fb744b4Smrg      func_fatal_help "the \`$prevarg' option requires an argument"
60021fb744b4Smrg
60031fb744b4Smrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
60041fb744b4Smrg      eval arg=\"$export_dynamic_flag_spec\"
60051fb744b4Smrg      func_append compile_command " $arg"
60061fb744b4Smrg      func_append finalize_command " $arg"
60071fb744b4Smrg    fi
60081fb744b4Smrg
60091fb744b4Smrg    oldlibs=
60101fb744b4Smrg    # calculate the name of the file, without its directory
60111fb744b4Smrg    func_basename "$output"
60121fb744b4Smrg    outputname="$func_basename_result"
60131fb744b4Smrg    libobjs_save="$libobjs"
60141fb744b4Smrg
60151fb744b4Smrg    if test -n "$shlibpath_var"; then
60161fb744b4Smrg      # get the directories listed in $shlibpath_var
60171fb744b4Smrg      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
60181fb744b4Smrg    else
60191fb744b4Smrg      shlib_search_path=
60201fb744b4Smrg    fi
60211fb744b4Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
60221fb744b4Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
60231fb744b4Smrg
60241fb744b4Smrg    func_dirname "$output" "/" ""
60251fb744b4Smrg    output_objdir="$func_dirname_result$objdir"
60261fb744b4Smrg    func_to_tool_file "$output_objdir/"
60271fb744b4Smrg    tool_output_objdir=$func_to_tool_file_result
60281fb744b4Smrg    # Create the object directory.
60291fb744b4Smrg    func_mkdir_p "$output_objdir"
60301fb744b4Smrg
60311fb744b4Smrg    # Determine the type of output
60321fb744b4Smrg    case $output in
60331fb744b4Smrg    "")
60341fb744b4Smrg      func_fatal_help "you must specify an output file"
60351fb744b4Smrg      ;;
60361fb744b4Smrg    *.$libext) linkmode=oldlib ;;
60371fb744b4Smrg    *.lo | *.$objext) linkmode=obj ;;
60381fb744b4Smrg    *.la) linkmode=lib ;;
60391fb744b4Smrg    *) linkmode=prog ;; # Anything else should be a program.
60401fb744b4Smrg    esac
60411fb744b4Smrg
60421fb744b4Smrg    specialdeplibs=
60431fb744b4Smrg
60441fb744b4Smrg    libs=
60451fb744b4Smrg    # Find all interdependent deplibs by searching for libraries
60461fb744b4Smrg    # that are linked more than once (e.g. -la -lb -la)
60471fb744b4Smrg    for deplib in $deplibs; do
60481fb744b4Smrg      if $opt_preserve_dup_deps ; then
60491fb744b4Smrg	case "$libs " in
60501fb744b4Smrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
60511fb744b4Smrg	esac
60521fb744b4Smrg      fi
60531fb744b4Smrg      func_append libs " $deplib"
60541fb744b4Smrg    done
60551fb744b4Smrg
60561fb744b4Smrg    if test "$linkmode" = lib; then
60571fb744b4Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
60581fb744b4Smrg
60591fb744b4Smrg      # Compute libraries that are listed more than once in $predeps
60601fb744b4Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
60611fb744b4Smrg      # not to be eliminated).
60621fb744b4Smrg      pre_post_deps=
60631fb744b4Smrg      if $opt_duplicate_compiler_generated_deps; then
60641fb744b4Smrg	for pre_post_dep in $predeps $postdeps; do
60651fb744b4Smrg	  case "$pre_post_deps " in
60661fb744b4Smrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
60671fb744b4Smrg	  esac
60681fb744b4Smrg	  func_append pre_post_deps " $pre_post_dep"
60691fb744b4Smrg	done
60701fb744b4Smrg      fi
60711fb744b4Smrg      pre_post_deps=
60721fb744b4Smrg    fi
60731fb744b4Smrg
60741fb744b4Smrg    deplibs=
60751fb744b4Smrg    newdependency_libs=
60761fb744b4Smrg    newlib_search_path=
60771fb744b4Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
60781fb744b4Smrg    notinst_deplibs= # not-installed libtool libraries
60791fb744b4Smrg    notinst_path= # paths that contain not-installed libtool libraries
60801fb744b4Smrg
60811fb744b4Smrg    case $linkmode in
60821fb744b4Smrg    lib)
60831fb744b4Smrg	passes="conv dlpreopen link"
60841fb744b4Smrg	for file in $dlfiles $dlprefiles; do
60851fb744b4Smrg	  case $file in
60861fb744b4Smrg	  *.la) ;;
60871fb744b4Smrg	  *)
60881fb744b4Smrg	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
60891fb744b4Smrg	    ;;
60901fb744b4Smrg	  esac
60911fb744b4Smrg	done
60921fb744b4Smrg	;;
60931fb744b4Smrg    prog)
60941fb744b4Smrg	compile_deplibs=
60951fb744b4Smrg	finalize_deplibs=
60961fb744b4Smrg	alldeplibs=no
60971fb744b4Smrg	newdlfiles=
60981fb744b4Smrg	newdlprefiles=
60991fb744b4Smrg	passes="conv scan dlopen dlpreopen link"
61001fb744b4Smrg	;;
61011fb744b4Smrg    *)  passes="conv"
61021fb744b4Smrg	;;
61031fb744b4Smrg    esac
61041fb744b4Smrg
61051fb744b4Smrg    for pass in $passes; do
61061fb744b4Smrg      # The preopen pass in lib mode reverses $deplibs; put it back here
61071fb744b4Smrg      # so that -L comes before libs that need it for instance...
61081fb744b4Smrg      if test "$linkmode,$pass" = "lib,link"; then
61091fb744b4Smrg	## FIXME: Find the place where the list is rebuilt in the wrong
61101fb744b4Smrg	##        order, and fix it there properly
61111fb744b4Smrg        tmp_deplibs=
61121fb744b4Smrg	for deplib in $deplibs; do
61131fb744b4Smrg	  tmp_deplibs="$deplib $tmp_deplibs"
61141fb744b4Smrg	done
61151fb744b4Smrg	deplibs="$tmp_deplibs"
61161fb744b4Smrg      fi
61171fb744b4Smrg
61181fb744b4Smrg      if test "$linkmode,$pass" = "lib,link" ||
61191fb744b4Smrg	 test "$linkmode,$pass" = "prog,scan"; then
61201fb744b4Smrg	libs="$deplibs"
61211fb744b4Smrg	deplibs=
61221fb744b4Smrg      fi
61231fb744b4Smrg      if test "$linkmode" = prog; then
61241fb744b4Smrg	case $pass in
61251fb744b4Smrg	dlopen) libs="$dlfiles" ;;
61261fb744b4Smrg	dlpreopen) libs="$dlprefiles" ;;
61271fb744b4Smrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
61281fb744b4Smrg	esac
61291fb744b4Smrg      fi
61301fb744b4Smrg      if test "$linkmode,$pass" = "lib,dlpreopen"; then
61311fb744b4Smrg	# Collect and forward deplibs of preopened libtool libs
61321fb744b4Smrg	for lib in $dlprefiles; do
61331fb744b4Smrg	  # Ignore non-libtool-libs
61341fb744b4Smrg	  dependency_libs=
61351fb744b4Smrg	  func_resolve_sysroot "$lib"
61361fb744b4Smrg	  case $lib in
61371fb744b4Smrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
61381fb744b4Smrg	  esac
61391fb744b4Smrg
61401fb744b4Smrg	  # Collect preopened libtool deplibs, except any this library
61411fb744b4Smrg	  # has declared as weak libs
61421fb744b4Smrg	  for deplib in $dependency_libs; do
61431fb744b4Smrg	    func_basename "$deplib"
61441fb744b4Smrg            deplib_base=$func_basename_result
61451fb744b4Smrg	    case " $weak_libs " in
61461fb744b4Smrg	    *" $deplib_base "*) ;;
61471fb744b4Smrg	    *) func_append deplibs " $deplib" ;;
61481fb744b4Smrg	    esac
61491fb744b4Smrg	  done
61501fb744b4Smrg	done
61511fb744b4Smrg	libs="$dlprefiles"
61521fb744b4Smrg      fi
61531fb744b4Smrg      if test "$pass" = dlopen; then
61541fb744b4Smrg	# Collect dlpreopened libraries
61551fb744b4Smrg	save_deplibs="$deplibs"
61561fb744b4Smrg	deplibs=
61571fb744b4Smrg      fi
61581fb744b4Smrg
61591fb744b4Smrg      for deplib in $libs; do
61601fb744b4Smrg	lib=
61611fb744b4Smrg	found=no
61621fb744b4Smrg	case $deplib in
61631fb744b4Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
61641fb744b4Smrg        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
61651fb744b4Smrg	  if test "$linkmode,$pass" = "prog,link"; then
61661fb744b4Smrg	    compile_deplibs="$deplib $compile_deplibs"
61671fb744b4Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
61681fb744b4Smrg	  else
61691fb744b4Smrg	    func_append compiler_flags " $deplib"
61701fb744b4Smrg	    if test "$linkmode" = lib ; then
61711fb744b4Smrg		case "$new_inherited_linker_flags " in
61721fb744b4Smrg		    *" $deplib "*) ;;
61731fb744b4Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
61741fb744b4Smrg		esac
61751fb744b4Smrg	    fi
61761fb744b4Smrg	  fi
61771fb744b4Smrg	  continue
61781fb744b4Smrg	  ;;
61791fb744b4Smrg	-l*)
61801fb744b4Smrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
61811fb744b4Smrg	    func_warning "\`-l' is ignored for archives/objects"
61821fb744b4Smrg	    continue
61831fb744b4Smrg	  fi
61841fb744b4Smrg	  func_stripname '-l' '' "$deplib"
61851fb744b4Smrg	  name=$func_stripname_result
61861fb744b4Smrg	  if test "$linkmode" = lib; then
61871fb744b4Smrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
61881fb744b4Smrg	  else
61891fb744b4Smrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
61901fb744b4Smrg	  fi
61911fb744b4Smrg	  for searchdir in $searchdirs; do
61921fb744b4Smrg	    for search_ext in .la $std_shrext .so .a; do
61931fb744b4Smrg	      # Search the libtool library
61941fb744b4Smrg	      lib="$searchdir/lib${name}${search_ext}"
61951fb744b4Smrg	      if test -f "$lib"; then
61961fb744b4Smrg		if test "$search_ext" = ".la"; then
61971fb744b4Smrg		  found=yes
61981fb744b4Smrg		else
61991fb744b4Smrg		  found=no
62001fb744b4Smrg		fi
62011fb744b4Smrg		break 2
62021fb744b4Smrg	      fi
62031fb744b4Smrg	    done
62041fb744b4Smrg	  done
62051fb744b4Smrg	  if test "$found" != yes; then
62061fb744b4Smrg	    # deplib doesn't seem to be a libtool library
62071fb744b4Smrg	    if test "$linkmode,$pass" = "prog,link"; then
62081fb744b4Smrg	      compile_deplibs="$deplib $compile_deplibs"
62091fb744b4Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
62101fb744b4Smrg	    else
62111fb744b4Smrg	      deplibs="$deplib $deplibs"
62121fb744b4Smrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
62131fb744b4Smrg	    fi
62141fb744b4Smrg	    continue
62151fb744b4Smrg	  else # deplib is a libtool library
62161fb744b4Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
62171fb744b4Smrg	    # We need to do some special things here, and not later.
62181fb744b4Smrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
62191fb744b4Smrg	      case " $predeps $postdeps " in
62201fb744b4Smrg	      *" $deplib "*)
62211fb744b4Smrg		if func_lalib_p "$lib"; then
62221fb744b4Smrg		  library_names=
62231fb744b4Smrg		  old_library=
62241fb744b4Smrg		  func_source "$lib"
62251fb744b4Smrg		  for l in $old_library $library_names; do
62261fb744b4Smrg		    ll="$l"
62271fb744b4Smrg		  done
62281fb744b4Smrg		  if test "X$ll" = "X$old_library" ; then # only static version available
62291fb744b4Smrg		    found=no
62301fb744b4Smrg		    func_dirname "$lib" "" "."
62311fb744b4Smrg		    ladir="$func_dirname_result"
62321fb744b4Smrg		    lib=$ladir/$old_library
62331fb744b4Smrg		    if test "$linkmode,$pass" = "prog,link"; then
62341fb744b4Smrg		      compile_deplibs="$deplib $compile_deplibs"
62351fb744b4Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
62361fb744b4Smrg		    else
62371fb744b4Smrg		      deplibs="$deplib $deplibs"
62381fb744b4Smrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
62391fb744b4Smrg		    fi
62401fb744b4Smrg		    continue
62411fb744b4Smrg		  fi
62421fb744b4Smrg		fi
62431fb744b4Smrg		;;
62441fb744b4Smrg	      *) ;;
62451fb744b4Smrg	      esac
62461fb744b4Smrg	    fi
62471fb744b4Smrg	  fi
62481fb744b4Smrg	  ;; # -l
62491fb744b4Smrg	*.ltframework)
62501fb744b4Smrg	  if test "$linkmode,$pass" = "prog,link"; then
62511fb744b4Smrg	    compile_deplibs="$deplib $compile_deplibs"
62521fb744b4Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
62531fb744b4Smrg	  else
62541fb744b4Smrg	    deplibs="$deplib $deplibs"
62551fb744b4Smrg	    if test "$linkmode" = lib ; then
62561fb744b4Smrg		case "$new_inherited_linker_flags " in
62571fb744b4Smrg		    *" $deplib "*) ;;
62581fb744b4Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
62591fb744b4Smrg		esac
62601fb744b4Smrg	    fi
62611fb744b4Smrg	  fi
62621fb744b4Smrg	  continue
62631fb744b4Smrg	  ;;
62641fb744b4Smrg	-L*)
62651fb744b4Smrg	  case $linkmode in
62661fb744b4Smrg	  lib)
62671fb744b4Smrg	    deplibs="$deplib $deplibs"
62681fb744b4Smrg	    test "$pass" = conv && continue
62691fb744b4Smrg	    newdependency_libs="$deplib $newdependency_libs"
62701fb744b4Smrg	    func_stripname '-L' '' "$deplib"
62711fb744b4Smrg	    func_resolve_sysroot "$func_stripname_result"
62721fb744b4Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
62731fb744b4Smrg	    ;;
62741fb744b4Smrg	  prog)
62751fb744b4Smrg	    if test "$pass" = conv; then
62761fb744b4Smrg	      deplibs="$deplib $deplibs"
62771fb744b4Smrg	      continue
62781fb744b4Smrg	    fi
62791fb744b4Smrg	    if test "$pass" = scan; then
62801fb744b4Smrg	      deplibs="$deplib $deplibs"
62811fb744b4Smrg	    else
62821fb744b4Smrg	      compile_deplibs="$deplib $compile_deplibs"
62831fb744b4Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
62841fb744b4Smrg	    fi
62851fb744b4Smrg	    func_stripname '-L' '' "$deplib"
62861fb744b4Smrg	    func_resolve_sysroot "$func_stripname_result"
62871fb744b4Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
62881fb744b4Smrg	    ;;
62891fb744b4Smrg	  *)
62901fb744b4Smrg	    func_warning "\`-L' is ignored for archives/objects"
62911fb744b4Smrg	    ;;
62921fb744b4Smrg	  esac # linkmode
62931fb744b4Smrg	  continue
62941fb744b4Smrg	  ;; # -L
62951fb744b4Smrg	-R*)
62961fb744b4Smrg	  if test "$pass" = link; then
62971fb744b4Smrg	    func_stripname '-R' '' "$deplib"
62981fb744b4Smrg	    func_resolve_sysroot "$func_stripname_result"
62991fb744b4Smrg	    dir=$func_resolve_sysroot_result
63001fb744b4Smrg	    # Make sure the xrpath contains only unique directories.
63011fb744b4Smrg	    case "$xrpath " in
63021fb744b4Smrg	    *" $dir "*) ;;
63031fb744b4Smrg	    *) func_append xrpath " $dir" ;;
63041fb744b4Smrg	    esac
63051fb744b4Smrg	  fi
63061fb744b4Smrg	  deplibs="$deplib $deplibs"
63071fb744b4Smrg	  continue
63081fb744b4Smrg	  ;;
63091fb744b4Smrg	*.la)
63101fb744b4Smrg	  func_resolve_sysroot "$deplib"
63111fb744b4Smrg	  lib=$func_resolve_sysroot_result
63121fb744b4Smrg	  ;;
63131fb744b4Smrg	*.$libext)
63141fb744b4Smrg	  if test "$pass" = conv; then
63151fb744b4Smrg	    deplibs="$deplib $deplibs"
63161fb744b4Smrg	    continue
63171fb744b4Smrg	  fi
63181fb744b4Smrg	  case $linkmode in
63191fb744b4Smrg	  lib)
63201fb744b4Smrg	    # Linking convenience modules into shared libraries is allowed,
63211fb744b4Smrg	    # but linking other static libraries is non-portable.
63221fb744b4Smrg	    case " $dlpreconveniencelibs " in
63231fb744b4Smrg	    *" $deplib "*) ;;
63241fb744b4Smrg	    *)
63251fb744b4Smrg	      valid_a_lib=no
63261fb744b4Smrg	      case $deplibs_check_method in
63271fb744b4Smrg		match_pattern*)
63281fb744b4Smrg		  set dummy $deplibs_check_method; shift
63291fb744b4Smrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
63301fb744b4Smrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
63311fb744b4Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
63321fb744b4Smrg		    valid_a_lib=yes
63331fb744b4Smrg		  fi
63341fb744b4Smrg		;;
63351fb744b4Smrg		pass_all)
63361fb744b4Smrg		  valid_a_lib=yes
63371fb744b4Smrg		;;
63381fb744b4Smrg	      esac
63391fb744b4Smrg	      if test "$valid_a_lib" != yes; then
63401fb744b4Smrg		echo
63411fb744b4Smrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
63421fb744b4Smrg		echo "*** I have the capability to make that library automatically link in when"
63431fb744b4Smrg		echo "*** you link to this library.  But I can only do this if you have a"
63441fb744b4Smrg		echo "*** shared version of the library, which you do not appear to have"
63451fb744b4Smrg		echo "*** because the file extensions .$libext of this argument makes me believe"
63461fb744b4Smrg		echo "*** that it is just a static archive that I should not use here."
63471fb744b4Smrg	      else
63481fb744b4Smrg		echo
63491fb744b4Smrg		$ECHO "*** Warning: Linking the shared library $output against the"
63501fb744b4Smrg		$ECHO "*** static library $deplib is not portable!"
63511fb744b4Smrg		deplibs="$deplib $deplibs"
63521fb744b4Smrg	      fi
63531fb744b4Smrg	      ;;
63541fb744b4Smrg	    esac
63551fb744b4Smrg	    continue
63561fb744b4Smrg	    ;;
63571fb744b4Smrg	  prog)
63581fb744b4Smrg	    if test "$pass" != link; then
63591fb744b4Smrg	      deplibs="$deplib $deplibs"
63601fb744b4Smrg	    else
63611fb744b4Smrg	      compile_deplibs="$deplib $compile_deplibs"
63621fb744b4Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
63631fb744b4Smrg	    fi
63641fb744b4Smrg	    continue
63651fb744b4Smrg	    ;;
63661fb744b4Smrg	  esac # linkmode
63671fb744b4Smrg	  ;; # *.$libext
63681fb744b4Smrg	*.lo | *.$objext)
63691fb744b4Smrg	  if test "$pass" = conv; then
63701fb744b4Smrg	    deplibs="$deplib $deplibs"
63711fb744b4Smrg	  elif test "$linkmode" = prog; then
63721fb744b4Smrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
63731fb744b4Smrg	      # If there is no dlopen support or we're linking statically,
63741fb744b4Smrg	      # we need to preload.
63751fb744b4Smrg	      func_append newdlprefiles " $deplib"
63761fb744b4Smrg	      compile_deplibs="$deplib $compile_deplibs"
63771fb744b4Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
63781fb744b4Smrg	    else
63791fb744b4Smrg	      func_append newdlfiles " $deplib"
63801fb744b4Smrg	    fi
63811fb744b4Smrg	  fi
63821fb744b4Smrg	  continue
63831fb744b4Smrg	  ;;
63841fb744b4Smrg	%DEPLIBS%)
63851fb744b4Smrg	  alldeplibs=yes
63861fb744b4Smrg	  continue
63871fb744b4Smrg	  ;;
63881fb744b4Smrg	esac # case $deplib
63891fb744b4Smrg
63901fb744b4Smrg	if test "$found" = yes || test -f "$lib"; then :
63911fb744b4Smrg	else
63921fb744b4Smrg	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
63931fb744b4Smrg	fi
63941fb744b4Smrg
63951fb744b4Smrg	# Check to see that this really is a libtool archive.
63961fb744b4Smrg	func_lalib_unsafe_p "$lib" \
63971fb744b4Smrg	  || func_fatal_error "\`$lib' is not a valid libtool archive"
63981fb744b4Smrg
63991fb744b4Smrg	func_dirname "$lib" "" "."
64001fb744b4Smrg	ladir="$func_dirname_result"
64011fb744b4Smrg
64021fb744b4Smrg	dlname=
64031fb744b4Smrg	dlopen=
64041fb744b4Smrg	dlpreopen=
64051fb744b4Smrg	libdir=
64061fb744b4Smrg	library_names=
64071fb744b4Smrg	old_library=
64081fb744b4Smrg	inherited_linker_flags=
64091fb744b4Smrg	# If the library was installed with an old release of libtool,
64101fb744b4Smrg	# it will not redefine variables installed, or shouldnotlink
64111fb744b4Smrg	installed=yes
64121fb744b4Smrg	shouldnotlink=no
64131fb744b4Smrg	avoidtemprpath=
64141fb744b4Smrg
64151fb744b4Smrg
64161fb744b4Smrg	# Read the .la file
64171fb744b4Smrg	func_source "$lib"
64181fb744b4Smrg
64191fb744b4Smrg	# Convert "-framework foo" to "foo.ltframework"
64201fb744b4Smrg	if test -n "$inherited_linker_flags"; then
64211fb744b4Smrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
64221fb744b4Smrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
64231fb744b4Smrg	    case " $new_inherited_linker_flags " in
64241fb744b4Smrg	      *" $tmp_inherited_linker_flag "*) ;;
64251fb744b4Smrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
64261fb744b4Smrg	    esac
64271fb744b4Smrg	  done
64281fb744b4Smrg	fi
64291fb744b4Smrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
64301fb744b4Smrg	if test "$linkmode,$pass" = "lib,link" ||
64311fb744b4Smrg	   test "$linkmode,$pass" = "prog,scan" ||
64321fb744b4Smrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
64331fb744b4Smrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
64341fb744b4Smrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
64351fb744b4Smrg	fi
64361fb744b4Smrg
64371fb744b4Smrg	if test "$pass" = conv; then
64381fb744b4Smrg	  # Only check for convenience libraries
64391fb744b4Smrg	  deplibs="$lib $deplibs"
64401fb744b4Smrg	  if test -z "$libdir"; then
64411fb744b4Smrg	    if test -z "$old_library"; then
64421fb744b4Smrg	      func_fatal_error "cannot find name of link library for \`$lib'"
64431fb744b4Smrg	    fi
64441fb744b4Smrg	    # It is a libtool convenience library, so add in its objects.
64451fb744b4Smrg	    func_append convenience " $ladir/$objdir/$old_library"
64461fb744b4Smrg	    func_append old_convenience " $ladir/$objdir/$old_library"
64471fb744b4Smrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
64481fb744b4Smrg	    func_fatal_error "\`$lib' is not a convenience library"
64491fb744b4Smrg	  fi
64501fb744b4Smrg	  tmp_libs=
64511fb744b4Smrg	  for deplib in $dependency_libs; do
64521fb744b4Smrg	    deplibs="$deplib $deplibs"
64531fb744b4Smrg	    if $opt_preserve_dup_deps ; then
64541fb744b4Smrg	      case "$tmp_libs " in
64551fb744b4Smrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
64561fb744b4Smrg	      esac
64571fb744b4Smrg	    fi
64581fb744b4Smrg	    func_append tmp_libs " $deplib"
64591fb744b4Smrg	  done
64601fb744b4Smrg	  continue
64611fb744b4Smrg	fi # $pass = conv
64621fb744b4Smrg
64631fb744b4Smrg
64641fb744b4Smrg	# Get the name of the library we link against.
64651fb744b4Smrg	linklib=
64661fb744b4Smrg	if test -n "$old_library" &&
64671fb744b4Smrg	   { test "$prefer_static_libs" = yes ||
64681fb744b4Smrg	     test "$prefer_static_libs,$installed" = "built,no"; }; then
64691fb744b4Smrg	  linklib=$old_library
64701fb744b4Smrg	else
64711fb744b4Smrg	  for l in $old_library $library_names; do
64721fb744b4Smrg	    linklib="$l"
64731fb744b4Smrg	  done
64741fb744b4Smrg	fi
64751fb744b4Smrg	if test -z "$linklib"; then
64761fb744b4Smrg	  func_fatal_error "cannot find name of link library for \`$lib'"
64771fb744b4Smrg	fi
64781fb744b4Smrg
64791fb744b4Smrg	# This library was specified with -dlopen.
64801fb744b4Smrg	if test "$pass" = dlopen; then
64811fb744b4Smrg	  if test -z "$libdir"; then
64821fb744b4Smrg	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
64831fb744b4Smrg	  fi
64841fb744b4Smrg	  if test -z "$dlname" ||
64851fb744b4Smrg	     test "$dlopen_support" != yes ||
64861fb744b4Smrg	     test "$build_libtool_libs" = no; then
64871fb744b4Smrg	    # If there is no dlname, no dlopen support or we're linking
64881fb744b4Smrg	    # statically, we need to preload.  We also need to preload any
64891fb744b4Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
64901fb744b4Smrg	    # bomb out in the load deplibs phase.
64911fb744b4Smrg	    func_append dlprefiles " $lib $dependency_libs"
64921fb744b4Smrg	  else
64931fb744b4Smrg	    func_append newdlfiles " $lib"
64941fb744b4Smrg	  fi
64951fb744b4Smrg	  continue
64961fb744b4Smrg	fi # $pass = dlopen
64971fb744b4Smrg
64981fb744b4Smrg	# We need an absolute path.
64991fb744b4Smrg	case $ladir in
65001fb744b4Smrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
65011fb744b4Smrg	*)
65021fb744b4Smrg	  abs_ladir=`cd "$ladir" && pwd`
65031fb744b4Smrg	  if test -z "$abs_ladir"; then
65041fb744b4Smrg	    func_warning "cannot determine absolute directory name of \`$ladir'"
65051fb744b4Smrg	    func_warning "passing it literally to the linker, although it might fail"
65061fb744b4Smrg	    abs_ladir="$ladir"
65071fb744b4Smrg	  fi
65081fb744b4Smrg	  ;;
65091fb744b4Smrg	esac
65101fb744b4Smrg	func_basename "$lib"
65111fb744b4Smrg	laname="$func_basename_result"
65121fb744b4Smrg
65131fb744b4Smrg	# Find the relevant object directory and library name.
65141fb744b4Smrg	if test "X$installed" = Xyes; then
65151fb744b4Smrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
65161fb744b4Smrg	    func_warning "library \`$lib' was moved."
65171fb744b4Smrg	    dir="$ladir"
65181fb744b4Smrg	    absdir="$abs_ladir"
65191fb744b4Smrg	    libdir="$abs_ladir"
65201fb744b4Smrg	  else
65211fb744b4Smrg	    dir="$lt_sysroot$libdir"
65221fb744b4Smrg	    absdir="$lt_sysroot$libdir"
65231fb744b4Smrg	  fi
65241fb744b4Smrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
65251fb744b4Smrg	else
65261fb744b4Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
65271fb744b4Smrg	    dir="$ladir"
65281fb744b4Smrg	    absdir="$abs_ladir"
65291fb744b4Smrg	    # Remove this search path later
65301fb744b4Smrg	    func_append notinst_path " $abs_ladir"
65311fb744b4Smrg	  else
65321fb744b4Smrg	    dir="$ladir/$objdir"
65331fb744b4Smrg	    absdir="$abs_ladir/$objdir"
65341fb744b4Smrg	    # Remove this search path later
65351fb744b4Smrg	    func_append notinst_path " $abs_ladir"
65361fb744b4Smrg	  fi
65371fb744b4Smrg	fi # $installed = yes
65381fb744b4Smrg	func_stripname 'lib' '.la' "$laname"
65391fb744b4Smrg	name=$func_stripname_result
65401fb744b4Smrg
65411fb744b4Smrg	# This library was specified with -dlpreopen.
65421fb744b4Smrg	if test "$pass" = dlpreopen; then
65431fb744b4Smrg	  if test -z "$libdir" && test "$linkmode" = prog; then
65441fb744b4Smrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
65451fb744b4Smrg	  fi
65461fb744b4Smrg	  case "$host" in
65471fb744b4Smrg	    # special handling for platforms with PE-DLLs.
65481fb744b4Smrg	    *cygwin* | *mingw* | *cegcc* )
65491fb744b4Smrg	      # Linker will automatically link against shared library if both
65501fb744b4Smrg	      # static and shared are present.  Therefore, ensure we extract
65511fb744b4Smrg	      # symbols from the import library if a shared library is present
65521fb744b4Smrg	      # (otherwise, the dlopen module name will be incorrect).  We do
65531fb744b4Smrg	      # this by putting the import library name into $newdlprefiles.
65541fb744b4Smrg	      # We recover the dlopen module name by 'saving' the la file
65551fb744b4Smrg	      # name in a special purpose variable, and (later) extracting the
65561fb744b4Smrg	      # dlname from the la file.
65571fb744b4Smrg	      if test -n "$dlname"; then
65581fb744b4Smrg	        func_tr_sh "$dir/$linklib"
65591fb744b4Smrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
65601fb744b4Smrg	        func_append newdlprefiles " $dir/$linklib"
65611fb744b4Smrg	      else
65621fb744b4Smrg	        func_append newdlprefiles " $dir/$old_library"
65631fb744b4Smrg	        # Keep a list of preopened convenience libraries to check
65641fb744b4Smrg	        # that they are being used correctly in the link pass.
65651fb744b4Smrg	        test -z "$libdir" && \
65661fb744b4Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
65671fb744b4Smrg	      fi
65681fb744b4Smrg	    ;;
65691fb744b4Smrg	    * )
65701fb744b4Smrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
65711fb744b4Smrg	      # are required to link).
65721fb744b4Smrg	      if test -n "$old_library"; then
65731fb744b4Smrg	        func_append newdlprefiles " $dir/$old_library"
65741fb744b4Smrg	        # Keep a list of preopened convenience libraries to check
65751fb744b4Smrg	        # that they are being used correctly in the link pass.
65761fb744b4Smrg	        test -z "$libdir" && \
65771fb744b4Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
65781fb744b4Smrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
65791fb744b4Smrg	      elif test -n "$dlname"; then
65801fb744b4Smrg	        func_append newdlprefiles " $dir/$dlname"
65811fb744b4Smrg	      else
65821fb744b4Smrg	        func_append newdlprefiles " $dir/$linklib"
65831fb744b4Smrg	      fi
65841fb744b4Smrg	    ;;
65851fb744b4Smrg	  esac
65861fb744b4Smrg	fi # $pass = dlpreopen
65871fb744b4Smrg
65881fb744b4Smrg	if test -z "$libdir"; then
65891fb744b4Smrg	  # Link the convenience library
65901fb744b4Smrg	  if test "$linkmode" = lib; then
65911fb744b4Smrg	    deplibs="$dir/$old_library $deplibs"
65921fb744b4Smrg	  elif test "$linkmode,$pass" = "prog,link"; then
65931fb744b4Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
65941fb744b4Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
65951fb744b4Smrg	  else
65961fb744b4Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
65971fb744b4Smrg	  fi
65981fb744b4Smrg	  continue
65991fb744b4Smrg	fi
66001fb744b4Smrg
66011fb744b4Smrg
66021fb744b4Smrg	if test "$linkmode" = prog && test "$pass" != link; then
66031fb744b4Smrg	  func_append newlib_search_path " $ladir"
66041fb744b4Smrg	  deplibs="$lib $deplibs"
66051fb744b4Smrg
66061fb744b4Smrg	  linkalldeplibs=no
66071fb744b4Smrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
66081fb744b4Smrg	     test "$build_libtool_libs" = no; then
66091fb744b4Smrg	    linkalldeplibs=yes
66101fb744b4Smrg	  fi
66111fb744b4Smrg
66121fb744b4Smrg	  tmp_libs=
66131fb744b4Smrg	  for deplib in $dependency_libs; do
66141fb744b4Smrg	    case $deplib in
66151fb744b4Smrg	    -L*) func_stripname '-L' '' "$deplib"
66161fb744b4Smrg	         func_resolve_sysroot "$func_stripname_result"
66171fb744b4Smrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
66181fb744b4Smrg		 ;;
66191fb744b4Smrg	    esac
66201fb744b4Smrg	    # Need to link against all dependency_libs?
66211fb744b4Smrg	    if test "$linkalldeplibs" = yes; then
66221fb744b4Smrg	      deplibs="$deplib $deplibs"
66231fb744b4Smrg	    else
66241fb744b4Smrg	      # Need to hardcode shared library paths
66251fb744b4Smrg	      # or/and link against static libraries
66261fb744b4Smrg	      newdependency_libs="$deplib $newdependency_libs"
66271fb744b4Smrg	    fi
66281fb744b4Smrg	    if $opt_preserve_dup_deps ; then
66291fb744b4Smrg	      case "$tmp_libs " in
66301fb744b4Smrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
66311fb744b4Smrg	      esac
66321fb744b4Smrg	    fi
66331fb744b4Smrg	    func_append tmp_libs " $deplib"
66341fb744b4Smrg	  done # for deplib
66351fb744b4Smrg	  continue
66361fb744b4Smrg	fi # $linkmode = prog...
66371fb744b4Smrg
66381fb744b4Smrg	if test "$linkmode,$pass" = "prog,link"; then
66391fb744b4Smrg	  if test -n "$library_names" &&
66401fb744b4Smrg	     { { test "$prefer_static_libs" = no ||
66411fb744b4Smrg	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
66421fb744b4Smrg	       test -z "$old_library"; }; then
66431fb744b4Smrg	    # We need to hardcode the library path
66441fb744b4Smrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
66451fb744b4Smrg	      # Make sure the rpath contains only unique directories.
66461fb744b4Smrg	      case "$temp_rpath:" in
66471fb744b4Smrg	      *"$absdir:"*) ;;
66481fb744b4Smrg	      *) func_append temp_rpath "$absdir:" ;;
66491fb744b4Smrg	      esac
66501fb744b4Smrg	    fi
66511fb744b4Smrg
66521fb744b4Smrg	    # Hardcode the library path.
66531fb744b4Smrg	    # Skip directories that are in the system default run-time
66541fb744b4Smrg	    # search path.
66551fb744b4Smrg	    case " $sys_lib_dlsearch_path " in
66561fb744b4Smrg	    *" $absdir "*) ;;
66571fb744b4Smrg	    *)
66581fb744b4Smrg	      case "$compile_rpath " in
66591fb744b4Smrg	      *" $absdir "*) ;;
66601fb744b4Smrg	      *) func_append compile_rpath " $absdir" ;;
66611fb744b4Smrg	      esac
66621fb744b4Smrg	      ;;
66631fb744b4Smrg	    esac
66641fb744b4Smrg	    case " $sys_lib_dlsearch_path " in
66651fb744b4Smrg	    *" $libdir "*) ;;
66661fb744b4Smrg	    *)
66671fb744b4Smrg	      case "$finalize_rpath " in
66681fb744b4Smrg	      *" $libdir "*) ;;
66691fb744b4Smrg	      *) func_append finalize_rpath " $libdir" ;;
66701fb744b4Smrg	      esac
66711fb744b4Smrg	      ;;
66721fb744b4Smrg	    esac
66731fb744b4Smrg	  fi # $linkmode,$pass = prog,link...
66741fb744b4Smrg
66751fb744b4Smrg	  if test "$alldeplibs" = yes &&
66761fb744b4Smrg	     { test "$deplibs_check_method" = pass_all ||
66771fb744b4Smrg	       { test "$build_libtool_libs" = yes &&
66781fb744b4Smrg		 test -n "$library_names"; }; }; then
66791fb744b4Smrg	    # We only need to search for static libraries
66801fb744b4Smrg	    continue
66811fb744b4Smrg	  fi
66821fb744b4Smrg	fi
66831fb744b4Smrg
66841fb744b4Smrg	link_static=no # Whether the deplib will be linked statically
66851fb744b4Smrg	use_static_libs=$prefer_static_libs
66861fb744b4Smrg	if test "$use_static_libs" = built && test "$installed" = yes; then
66871fb744b4Smrg	  use_static_libs=no
66881fb744b4Smrg	fi
66891fb744b4Smrg	if test -n "$library_names" &&
66901fb744b4Smrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
66911fb744b4Smrg	  case $host in
66921fb744b4Smrg	  *cygwin* | *mingw* | *cegcc*)
66931fb744b4Smrg	      # No point in relinking DLLs because paths are not encoded
66941fb744b4Smrg	      func_append notinst_deplibs " $lib"
66951fb744b4Smrg	      need_relink=no
66961fb744b4Smrg	    ;;
66971fb744b4Smrg	  *)
66981fb744b4Smrg	    if test "$installed" = no; then
66991fb744b4Smrg	      func_append notinst_deplibs " $lib"
67001fb744b4Smrg	      need_relink=yes
67011fb744b4Smrg	    fi
67021fb744b4Smrg	    ;;
67031fb744b4Smrg	  esac
67041fb744b4Smrg	  # This is a shared library
67051fb744b4Smrg
67061fb744b4Smrg	  # Warn about portability, can't link against -module's on some
67071fb744b4Smrg	  # systems (darwin).  Don't bleat about dlopened modules though!
67081fb744b4Smrg	  dlopenmodule=""
67091fb744b4Smrg	  for dlpremoduletest in $dlprefiles; do
67101fb744b4Smrg	    if test "X$dlpremoduletest" = "X$lib"; then
67111fb744b4Smrg	      dlopenmodule="$dlpremoduletest"
67121fb744b4Smrg	      break
67131fb744b4Smrg	    fi
67141fb744b4Smrg	  done
67151fb744b4Smrg	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
67161fb744b4Smrg	    echo
67171fb744b4Smrg	    if test "$linkmode" = prog; then
67181fb744b4Smrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
67191fb744b4Smrg	    else
67201fb744b4Smrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
67211fb744b4Smrg	    fi
67221fb744b4Smrg	    $ECHO "*** $linklib is not portable!"
67231fb744b4Smrg	  fi
67241fb744b4Smrg	  if test "$linkmode" = lib &&
67251fb744b4Smrg	     test "$hardcode_into_libs" = yes; then
67261fb744b4Smrg	    # Hardcode the library path.
67271fb744b4Smrg	    # Skip directories that are in the system default run-time
67281fb744b4Smrg	    # search path.
67291fb744b4Smrg	    case " $sys_lib_dlsearch_path " in
67301fb744b4Smrg	    *" $absdir "*) ;;
67311fb744b4Smrg	    *)
67321fb744b4Smrg	      case "$compile_rpath " in
67331fb744b4Smrg	      *" $absdir "*) ;;
67341fb744b4Smrg	      *) func_append compile_rpath " $absdir" ;;
67351fb744b4Smrg	      esac
67361fb744b4Smrg	      ;;
67371fb744b4Smrg	    esac
67381fb744b4Smrg	    case " $sys_lib_dlsearch_path " in
67391fb744b4Smrg	    *" $libdir "*) ;;
67401fb744b4Smrg	    *)
67411fb744b4Smrg	      case "$finalize_rpath " in
67421fb744b4Smrg	      *" $libdir "*) ;;
67431fb744b4Smrg	      *) func_append finalize_rpath " $libdir" ;;
67441fb744b4Smrg	      esac
67451fb744b4Smrg	      ;;
67461fb744b4Smrg	    esac
67471fb744b4Smrg	  fi
67481fb744b4Smrg
67491fb744b4Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
67501fb744b4Smrg	    # figure out the soname
67511fb744b4Smrg	    set dummy $library_names
67521fb744b4Smrg	    shift
67531fb744b4Smrg	    realname="$1"
67541fb744b4Smrg	    shift
67551fb744b4Smrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
67561fb744b4Smrg	    # use dlname if we got it. it's perfectly good, no?
67571fb744b4Smrg	    if test -n "$dlname"; then
67581fb744b4Smrg	      soname="$dlname"
67591fb744b4Smrg	    elif test -n "$soname_spec"; then
67601fb744b4Smrg	      # bleh windows
67611fb744b4Smrg	      case $host in
67621fb744b4Smrg	      *cygwin* | mingw* | *cegcc*)
67631fb744b4Smrg	        func_arith $current - $age
67641fb744b4Smrg		major=$func_arith_result
67651fb744b4Smrg		versuffix="-$major"
67661fb744b4Smrg		;;
67671fb744b4Smrg	      esac
67681fb744b4Smrg	      eval soname=\"$soname_spec\"
67691fb744b4Smrg	    else
67701fb744b4Smrg	      soname="$realname"
67711fb744b4Smrg	    fi
67721fb744b4Smrg
67731fb744b4Smrg	    # Make a new name for the extract_expsyms_cmds to use
67741fb744b4Smrg	    soroot="$soname"
67751fb744b4Smrg	    func_basename "$soroot"
67761fb744b4Smrg	    soname="$func_basename_result"
67771fb744b4Smrg	    func_stripname 'lib' '.dll' "$soname"
67781fb744b4Smrg	    newlib=libimp-$func_stripname_result.a
67791fb744b4Smrg
67801fb744b4Smrg	    # If the library has no export list, then create one now
67811fb744b4Smrg	    if test -f "$output_objdir/$soname-def"; then :
67821fb744b4Smrg	    else
67831fb744b4Smrg	      func_verbose "extracting exported symbol list from \`$soname'"
67841fb744b4Smrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
67851fb744b4Smrg	    fi
67861fb744b4Smrg
67871fb744b4Smrg	    # Create $newlib
67881fb744b4Smrg	    if test -f "$output_objdir/$newlib"; then :; else
67891fb744b4Smrg	      func_verbose "generating import library for \`$soname'"
67901fb744b4Smrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
67911fb744b4Smrg	    fi
67921fb744b4Smrg	    # make sure the library variables are pointing to the new library
67931fb744b4Smrg	    dir=$output_objdir
67941fb744b4Smrg	    linklib=$newlib
67951fb744b4Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
67961fb744b4Smrg
67971fb744b4Smrg	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
67981fb744b4Smrg	    add_shlibpath=
67991fb744b4Smrg	    add_dir=
68001fb744b4Smrg	    add=
68011fb744b4Smrg	    lib_linked=yes
68021fb744b4Smrg	    case $hardcode_action in
68031fb744b4Smrg	    immediate | unsupported)
68041fb744b4Smrg	      if test "$hardcode_direct" = no; then
68051fb744b4Smrg		add="$dir/$linklib"
68061fb744b4Smrg		case $host in
68071fb744b4Smrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
68081fb744b4Smrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
68091fb744b4Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
68101fb744b4Smrg		    *-*-unixware7*) add_dir="-L$dir" ;;
68111fb744b4Smrg		  *-*-darwin* )
68121fb744b4Smrg		    # if the lib is a (non-dlopened) module then we can not
68131fb744b4Smrg		    # link against it, someone is ignoring the earlier warnings
68141fb744b4Smrg		    if /usr/bin/file -L $add 2> /dev/null |
68151fb744b4Smrg			 $GREP ": [^:]* bundle" >/dev/null ; then
68161fb744b4Smrg		      if test "X$dlopenmodule" != "X$lib"; then
68171fb744b4Smrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
68181fb744b4Smrg			if test -z "$old_library" ; then
68191fb744b4Smrg			  echo
68201fb744b4Smrg			  echo "*** And there doesn't seem to be a static archive available"
68211fb744b4Smrg			  echo "*** The link will probably fail, sorry"
68221fb744b4Smrg			else
68231fb744b4Smrg			  add="$dir/$old_library"
68241fb744b4Smrg			fi
68251fb744b4Smrg		      elif test -n "$old_library"; then
68261fb744b4Smrg			add="$dir/$old_library"
68271fb744b4Smrg		      fi
68281fb744b4Smrg		    fi
68291fb744b4Smrg		esac
68301fb744b4Smrg	      elif test "$hardcode_minus_L" = no; then
68311fb744b4Smrg		case $host in
68321fb744b4Smrg		*-*-sunos*) add_shlibpath="$dir" ;;
68331fb744b4Smrg		esac
68341fb744b4Smrg		add_dir="-L$dir"
68351fb744b4Smrg		add="-l$name"
68361fb744b4Smrg	      elif test "$hardcode_shlibpath_var" = no; then
68371fb744b4Smrg		add_shlibpath="$dir"
68381fb744b4Smrg		add="-l$name"
68391fb744b4Smrg	      else
68401fb744b4Smrg		lib_linked=no
68411fb744b4Smrg	      fi
68421fb744b4Smrg	      ;;
68431fb744b4Smrg	    relink)
68441fb744b4Smrg	      if test "$hardcode_direct" = yes &&
68451fb744b4Smrg	         test "$hardcode_direct_absolute" = no; then
68461fb744b4Smrg		add="$dir/$linklib"
68471fb744b4Smrg	      elif test "$hardcode_minus_L" = yes; then
68481fb744b4Smrg		add_dir="-L$absdir"
68491fb744b4Smrg		# Try looking first in the location we're being installed to.
68501fb744b4Smrg		if test -n "$inst_prefix_dir"; then
68511fb744b4Smrg		  case $libdir in
68521fb744b4Smrg		    [\\/]*)
68531fb744b4Smrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
68541fb744b4Smrg		      ;;
68551fb744b4Smrg		  esac
68561fb744b4Smrg		fi
68571fb744b4Smrg		add="-l$name"
68581fb744b4Smrg	      elif test "$hardcode_shlibpath_var" = yes; then
68591fb744b4Smrg		add_shlibpath="$dir"
68601fb744b4Smrg		add="-l$name"
68611fb744b4Smrg	      else
68621fb744b4Smrg		lib_linked=no
68631fb744b4Smrg	      fi
68641fb744b4Smrg	      ;;
68651fb744b4Smrg	    *) lib_linked=no ;;
68661fb744b4Smrg	    esac
68671fb744b4Smrg
68681fb744b4Smrg	    if test "$lib_linked" != yes; then
68691fb744b4Smrg	      func_fatal_configuration "unsupported hardcode properties"
68701fb744b4Smrg	    fi
68711fb744b4Smrg
68721fb744b4Smrg	    if test -n "$add_shlibpath"; then
68731fb744b4Smrg	      case :$compile_shlibpath: in
68741fb744b4Smrg	      *":$add_shlibpath:"*) ;;
68751fb744b4Smrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
68761fb744b4Smrg	      esac
68771fb744b4Smrg	    fi
68781fb744b4Smrg	    if test "$linkmode" = prog; then
68791fb744b4Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
68801fb744b4Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
68811fb744b4Smrg	    else
68821fb744b4Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
68831fb744b4Smrg	      test -n "$add" && deplibs="$add $deplibs"
68841fb744b4Smrg	      if test "$hardcode_direct" != yes &&
68851fb744b4Smrg		 test "$hardcode_minus_L" != yes &&
68861fb744b4Smrg		 test "$hardcode_shlibpath_var" = yes; then
68871fb744b4Smrg		case :$finalize_shlibpath: in
68881fb744b4Smrg		*":$libdir:"*) ;;
68891fb744b4Smrg		*) func_append finalize_shlibpath "$libdir:" ;;
68901fb744b4Smrg		esac
68911fb744b4Smrg	      fi
68921fb744b4Smrg	    fi
68931fb744b4Smrg	  fi
68941fb744b4Smrg
68951fb744b4Smrg	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
68961fb744b4Smrg	    add_shlibpath=
68971fb744b4Smrg	    add_dir=
68981fb744b4Smrg	    add=
68991fb744b4Smrg	    # Finalize command for both is simple: just hardcode it.
69001fb744b4Smrg	    if test "$hardcode_direct" = yes &&
69011fb744b4Smrg	       test "$hardcode_direct_absolute" = no; then
69021fb744b4Smrg	      add="$libdir/$linklib"
69031fb744b4Smrg	    elif test "$hardcode_minus_L" = yes; then
69041fb744b4Smrg	      add_dir="-L$libdir"
69051fb744b4Smrg	      add="-l$name"
69061fb744b4Smrg	    elif test "$hardcode_shlibpath_var" = yes; then
69071fb744b4Smrg	      case :$finalize_shlibpath: in
69081fb744b4Smrg	      *":$libdir:"*) ;;
69091fb744b4Smrg	      *) func_append finalize_shlibpath "$libdir:" ;;
69101fb744b4Smrg	      esac
69111fb744b4Smrg	      add="-l$name"
69121fb744b4Smrg	    elif test "$hardcode_automatic" = yes; then
69131fb744b4Smrg	      if test -n "$inst_prefix_dir" &&
69141fb744b4Smrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
69151fb744b4Smrg		add="$inst_prefix_dir$libdir/$linklib"
69161fb744b4Smrg	      else
69171fb744b4Smrg		add="$libdir/$linklib"
69181fb744b4Smrg	      fi
69191fb744b4Smrg	    else
69201fb744b4Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
69211fb744b4Smrg	      add_dir="-L$libdir"
69221fb744b4Smrg	      # Try looking first in the location we're being installed to.
69231fb744b4Smrg	      if test -n "$inst_prefix_dir"; then
69241fb744b4Smrg		case $libdir in
69251fb744b4Smrg		  [\\/]*)
69261fb744b4Smrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
69271fb744b4Smrg		    ;;
69281fb744b4Smrg		esac
69291fb744b4Smrg	      fi
69301fb744b4Smrg	      add="-l$name"
69311fb744b4Smrg	    fi
69321fb744b4Smrg
69331fb744b4Smrg	    if test "$linkmode" = prog; then
69341fb744b4Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
69351fb744b4Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
69361fb744b4Smrg	    else
69371fb744b4Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
69381fb744b4Smrg	      test -n "$add" && deplibs="$add $deplibs"
69391fb744b4Smrg	    fi
69401fb744b4Smrg	  fi
69411fb744b4Smrg	elif test "$linkmode" = prog; then
69421fb744b4Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
69431fb744b4Smrg	  # is not unsupported.  This is valid on all known static and
69441fb744b4Smrg	  # shared platforms.
69451fb744b4Smrg	  if test "$hardcode_direct" != unsupported; then
69461fb744b4Smrg	    test -n "$old_library" && linklib="$old_library"
69471fb744b4Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
69481fb744b4Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
69491fb744b4Smrg	  else
69501fb744b4Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
69511fb744b4Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
69521fb744b4Smrg	  fi
69531fb744b4Smrg	elif test "$build_libtool_libs" = yes; then
69541fb744b4Smrg	  # Not a shared library
69551fb744b4Smrg	  if test "$deplibs_check_method" != pass_all; then
69561fb744b4Smrg	    # We're trying link a shared library against a static one
69571fb744b4Smrg	    # but the system doesn't support it.
69581fb744b4Smrg
69591fb744b4Smrg	    # Just print a warning and add the library to dependency_libs so
69601fb744b4Smrg	    # that the program can be linked against the static library.
69611fb744b4Smrg	    echo
69621fb744b4Smrg	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
69631fb744b4Smrg	    echo "*** I have the capability to make that library automatically link in when"
69641fb744b4Smrg	    echo "*** you link to this library.  But I can only do this if you have a"
69651fb744b4Smrg	    echo "*** shared version of the library, which you do not appear to have."
69661fb744b4Smrg	    if test "$module" = yes; then
69671fb744b4Smrg	      echo "*** But as you try to build a module library, libtool will still create "
69681fb744b4Smrg	      echo "*** a static module, that should work as long as the dlopening application"
69691fb744b4Smrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
69701fb744b4Smrg	      if test -z "$global_symbol_pipe"; then
69711fb744b4Smrg		echo
69721fb744b4Smrg		echo "*** However, this would only work if libtool was able to extract symbol"
69731fb744b4Smrg		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
69741fb744b4Smrg		echo "*** not find such a program.  So, this module is probably useless."
69751fb744b4Smrg		echo "*** \`nm' from GNU binutils and a full rebuild may help."
69761fb744b4Smrg	      fi
69771fb744b4Smrg	      if test "$build_old_libs" = no; then
69781fb744b4Smrg		build_libtool_libs=module
69791fb744b4Smrg		build_old_libs=yes
69801fb744b4Smrg	      else
69811fb744b4Smrg		build_libtool_libs=no
69821fb744b4Smrg	      fi
69831fb744b4Smrg	    fi
69841fb744b4Smrg	  else
69851fb744b4Smrg	    deplibs="$dir/$old_library $deplibs"
69861fb744b4Smrg	    link_static=yes
69871fb744b4Smrg	  fi
69881fb744b4Smrg	fi # link shared/static library?
69891fb744b4Smrg
69901fb744b4Smrg	if test "$linkmode" = lib; then
69911fb744b4Smrg	  if test -n "$dependency_libs" &&
69921fb744b4Smrg	     { test "$hardcode_into_libs" != yes ||
69931fb744b4Smrg	       test "$build_old_libs" = yes ||
69941fb744b4Smrg	       test "$link_static" = yes; }; then
69951fb744b4Smrg	    # Extract -R from dependency_libs
69961fb744b4Smrg	    temp_deplibs=
69971fb744b4Smrg	    for libdir in $dependency_libs; do
69981fb744b4Smrg	      case $libdir in
69991fb744b4Smrg	      -R*) func_stripname '-R' '' "$libdir"
70001fb744b4Smrg	           temp_xrpath=$func_stripname_result
70011fb744b4Smrg		   case " $xrpath " in
70021fb744b4Smrg		   *" $temp_xrpath "*) ;;
70031fb744b4Smrg		   *) func_append xrpath " $temp_xrpath";;
70041fb744b4Smrg		   esac;;
70051fb744b4Smrg	      *) func_append temp_deplibs " $libdir";;
70061fb744b4Smrg	      esac
70071fb744b4Smrg	    done
70081fb744b4Smrg	    dependency_libs="$temp_deplibs"
70091fb744b4Smrg	  fi
70101fb744b4Smrg
70111fb744b4Smrg	  func_append newlib_search_path " $absdir"
70121fb744b4Smrg	  # Link against this library
70131fb744b4Smrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
70141fb744b4Smrg	  # ... and its dependency_libs
70151fb744b4Smrg	  tmp_libs=
70161fb744b4Smrg	  for deplib in $dependency_libs; do
70171fb744b4Smrg	    newdependency_libs="$deplib $newdependency_libs"
70181fb744b4Smrg	    case $deplib in
70191fb744b4Smrg              -L*) func_stripname '-L' '' "$deplib"
70201fb744b4Smrg                   func_resolve_sysroot "$func_stripname_result";;
70211fb744b4Smrg              *) func_resolve_sysroot "$deplib" ;;
70221fb744b4Smrg            esac
70231fb744b4Smrg	    if $opt_preserve_dup_deps ; then
70241fb744b4Smrg	      case "$tmp_libs " in
70251fb744b4Smrg	      *" $func_resolve_sysroot_result "*)
70261fb744b4Smrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
70271fb744b4Smrg	      esac
70281fb744b4Smrg	    fi
70291fb744b4Smrg	    func_append tmp_libs " $func_resolve_sysroot_result"
70301fb744b4Smrg	  done
70311fb744b4Smrg
70321fb744b4Smrg	  if test "$link_all_deplibs" != no; then
70331fb744b4Smrg	    # Add the search paths of all dependency libraries
70341fb744b4Smrg	    for deplib in $dependency_libs; do
70351fb744b4Smrg	      path=
70361fb744b4Smrg	      case $deplib in
70371fb744b4Smrg	      -L*) path="$deplib" ;;
70381fb744b4Smrg	      *.la)
70391fb744b4Smrg	        func_resolve_sysroot "$deplib"
70401fb744b4Smrg	        deplib=$func_resolve_sysroot_result
70411fb744b4Smrg	        func_dirname "$deplib" "" "."
70421fb744b4Smrg		dir=$func_dirname_result
70431fb744b4Smrg		# We need an absolute path.
70441fb744b4Smrg		case $dir in
70451fb744b4Smrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
70461fb744b4Smrg		*)
70471fb744b4Smrg		  absdir=`cd "$dir" && pwd`
70481fb744b4Smrg		  if test -z "$absdir"; then
70491fb744b4Smrg		    func_warning "cannot determine absolute directory name of \`$dir'"
70501fb744b4Smrg		    absdir="$dir"
70511fb744b4Smrg		  fi
70521fb744b4Smrg		  ;;
70531fb744b4Smrg		esac
70541fb744b4Smrg		if $GREP "^installed=no" $deplib > /dev/null; then
70551fb744b4Smrg		case $host in
70561fb744b4Smrg		*-*-darwin*)
70571fb744b4Smrg		  depdepl=
70581fb744b4Smrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
70591fb744b4Smrg		  if test -n "$deplibrary_names" ; then
70601fb744b4Smrg		    for tmp in $deplibrary_names ; do
70611fb744b4Smrg		      depdepl=$tmp
70621fb744b4Smrg		    done
70631fb744b4Smrg		    if test -f "$absdir/$objdir/$depdepl" ; then
70641fb744b4Smrg		      depdepl="$absdir/$objdir/$depdepl"
70651fb744b4Smrg		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
70661fb744b4Smrg                      if test -z "$darwin_install_name"; then
70671fb744b4Smrg                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
70681fb744b4Smrg                      fi
70691fb744b4Smrg		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
70701fb744b4Smrg		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
70711fb744b4Smrg		      path=
70721fb744b4Smrg		    fi
70731fb744b4Smrg		  fi
70741fb744b4Smrg		  ;;
70751fb744b4Smrg		*)
70761fb744b4Smrg		  path="-L$absdir/$objdir"
70771fb744b4Smrg		  ;;
70781fb744b4Smrg		esac
70791fb744b4Smrg		else
70801fb744b4Smrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
70811fb744b4Smrg		  test -z "$libdir" && \
70821fb744b4Smrg		    func_fatal_error "\`$deplib' is not a valid libtool archive"
70831fb744b4Smrg		  test "$absdir" != "$libdir" && \
70841fb744b4Smrg		    func_warning "\`$deplib' seems to be moved"
70851fb744b4Smrg
70861fb744b4Smrg		  path="-L$absdir"
70871fb744b4Smrg		fi
70881fb744b4Smrg		;;
70891fb744b4Smrg	      esac
70901fb744b4Smrg	      case " $deplibs " in
70911fb744b4Smrg	      *" $path "*) ;;
70921fb744b4Smrg	      *) deplibs="$path $deplibs" ;;
70931fb744b4Smrg	      esac
70941fb744b4Smrg	    done
70951fb744b4Smrg	  fi # link_all_deplibs != no
70961fb744b4Smrg	fi # linkmode = lib
70971fb744b4Smrg      done # for deplib in $libs
70981fb744b4Smrg      if test "$pass" = link; then
70991fb744b4Smrg	if test "$linkmode" = "prog"; then
71001fb744b4Smrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
71011fb744b4Smrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
71021fb744b4Smrg	else
71031fb744b4Smrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
71041fb744b4Smrg	fi
71051fb744b4Smrg      fi
71061fb744b4Smrg      dependency_libs="$newdependency_libs"
71071fb744b4Smrg      if test "$pass" = dlpreopen; then
71081fb744b4Smrg	# Link the dlpreopened libraries before other libraries
71091fb744b4Smrg	for deplib in $save_deplibs; do
71101fb744b4Smrg	  deplibs="$deplib $deplibs"
71111fb744b4Smrg	done
71121fb744b4Smrg      fi
71131fb744b4Smrg      if test "$pass" != dlopen; then
71141fb744b4Smrg	if test "$pass" != conv; then
71151fb744b4Smrg	  # Make sure lib_search_path contains only unique directories.
71161fb744b4Smrg	  lib_search_path=
71171fb744b4Smrg	  for dir in $newlib_search_path; do
71181fb744b4Smrg	    case "$lib_search_path " in
71191fb744b4Smrg	    *" $dir "*) ;;
71201fb744b4Smrg	    *) func_append lib_search_path " $dir" ;;
71211fb744b4Smrg	    esac
71221fb744b4Smrg	  done
71231fb744b4Smrg	  newlib_search_path=
71241fb744b4Smrg	fi
71251fb744b4Smrg
71261fb744b4Smrg	if test "$linkmode,$pass" != "prog,link"; then
71271fb744b4Smrg	  vars="deplibs"
71281fb744b4Smrg	else
71291fb744b4Smrg	  vars="compile_deplibs finalize_deplibs"
71301fb744b4Smrg	fi
71311fb744b4Smrg	for var in $vars dependency_libs; do
71321fb744b4Smrg	  # Add libraries to $var in reverse order
71331fb744b4Smrg	  eval tmp_libs=\"\$$var\"
71341fb744b4Smrg	  new_libs=
71351fb744b4Smrg	  for deplib in $tmp_libs; do
71361fb744b4Smrg	    # FIXME: Pedantically, this is the right thing to do, so
71371fb744b4Smrg	    #        that some nasty dependency loop isn't accidentally
71381fb744b4Smrg	    #        broken:
71391fb744b4Smrg	    #new_libs="$deplib $new_libs"
71401fb744b4Smrg	    # Pragmatically, this seems to cause very few problems in
71411fb744b4Smrg	    # practice:
71421fb744b4Smrg	    case $deplib in
71431fb744b4Smrg	    -L*) new_libs="$deplib $new_libs" ;;
71441fb744b4Smrg	    -R*) ;;
71451fb744b4Smrg	    *)
71461fb744b4Smrg	      # And here is the reason: when a library appears more
71471fb744b4Smrg	      # than once as an explicit dependence of a library, or
71481fb744b4Smrg	      # is implicitly linked in more than once by the
71491fb744b4Smrg	      # compiler, it is considered special, and multiple
71501fb744b4Smrg	      # occurrences thereof are not removed.  Compare this
71511fb744b4Smrg	      # with having the same library being listed as a
71521fb744b4Smrg	      # dependency of multiple other libraries: in this case,
71531fb744b4Smrg	      # we know (pedantically, we assume) the library does not
71541fb744b4Smrg	      # need to be listed more than once, so we keep only the
71551fb744b4Smrg	      # last copy.  This is not always right, but it is rare
71561fb744b4Smrg	      # enough that we require users that really mean to play
71571fb744b4Smrg	      # such unportable linking tricks to link the library
71581fb744b4Smrg	      # using -Wl,-lname, so that libtool does not consider it
71591fb744b4Smrg	      # for duplicate removal.
71601fb744b4Smrg	      case " $specialdeplibs " in
71611fb744b4Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
71621fb744b4Smrg	      *)
71631fb744b4Smrg		case " $new_libs " in
71641fb744b4Smrg		*" $deplib "*) ;;
71651fb744b4Smrg		*) new_libs="$deplib $new_libs" ;;
71661fb744b4Smrg		esac
71671fb744b4Smrg		;;
71681fb744b4Smrg	      esac
71691fb744b4Smrg	      ;;
71701fb744b4Smrg	    esac
71711fb744b4Smrg	  done
71721fb744b4Smrg	  tmp_libs=
71731fb744b4Smrg	  for deplib in $new_libs; do
71741fb744b4Smrg	    case $deplib in
71751fb744b4Smrg	    -L*)
71761fb744b4Smrg	      case " $tmp_libs " in
71771fb744b4Smrg	      *" $deplib "*) ;;
71781fb744b4Smrg	      *) func_append tmp_libs " $deplib" ;;
71791fb744b4Smrg	      esac
71801fb744b4Smrg	      ;;
71811fb744b4Smrg	    *) func_append tmp_libs " $deplib" ;;
71821fb744b4Smrg	    esac
71831fb744b4Smrg	  done
71841fb744b4Smrg	  eval $var=\"$tmp_libs\"
71851fb744b4Smrg	done # for var
71861fb744b4Smrg      fi
71871fb744b4Smrg      # Last step: remove runtime libs from dependency_libs
71881fb744b4Smrg      # (they stay in deplibs)
71891fb744b4Smrg      tmp_libs=
71901fb744b4Smrg      for i in $dependency_libs ; do
71911fb744b4Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
71921fb744b4Smrg	*" $i "*)
71931fb744b4Smrg	  i=""
71941fb744b4Smrg	  ;;
71951fb744b4Smrg	esac
71961fb744b4Smrg	if test -n "$i" ; then
71971fb744b4Smrg	  func_append tmp_libs " $i"
71981fb744b4Smrg	fi
71991fb744b4Smrg      done
72001fb744b4Smrg      dependency_libs=$tmp_libs
72011fb744b4Smrg    done # for pass
72021fb744b4Smrg    if test "$linkmode" = prog; then
72031fb744b4Smrg      dlfiles="$newdlfiles"
72041fb744b4Smrg    fi
72051fb744b4Smrg    if test "$linkmode" = prog || test "$linkmode" = lib; then
72061fb744b4Smrg      dlprefiles="$newdlprefiles"
72071fb744b4Smrg    fi
72081fb744b4Smrg
72091fb744b4Smrg    case $linkmode in
72101fb744b4Smrg    oldlib)
72111fb744b4Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
72121fb744b4Smrg	func_warning "\`-dlopen' is ignored for archives"
72131fb744b4Smrg      fi
72141fb744b4Smrg
72151fb744b4Smrg      case " $deplibs" in
72161fb744b4Smrg      *\ -l* | *\ -L*)
72171fb744b4Smrg	func_warning "\`-l' and \`-L' are ignored for archives" ;;
72181fb744b4Smrg      esac
72191fb744b4Smrg
72201fb744b4Smrg      test -n "$rpath" && \
72211fb744b4Smrg	func_warning "\`-rpath' is ignored for archives"
72221fb744b4Smrg
72231fb744b4Smrg      test -n "$xrpath" && \
72241fb744b4Smrg	func_warning "\`-R' is ignored for archives"
72251fb744b4Smrg
72261fb744b4Smrg      test -n "$vinfo" && \
72271fb744b4Smrg	func_warning "\`-version-info/-version-number' is ignored for archives"
72281fb744b4Smrg
72291fb744b4Smrg      test -n "$release" && \
72301fb744b4Smrg	func_warning "\`-release' is ignored for archives"
72311fb744b4Smrg
72321fb744b4Smrg      test -n "$export_symbols$export_symbols_regex" && \
72331fb744b4Smrg	func_warning "\`-export-symbols' is ignored for archives"
72341fb744b4Smrg
72351fb744b4Smrg      # Now set the variables for building old libraries.
72361fb744b4Smrg      build_libtool_libs=no
72371fb744b4Smrg      oldlibs="$output"
72381fb744b4Smrg      func_append objs "$old_deplibs"
72391fb744b4Smrg      ;;
72401fb744b4Smrg
72411fb744b4Smrg    lib)
72421fb744b4Smrg      # Make sure we only generate libraries of the form `libNAME.la'.
72431fb744b4Smrg      case $outputname in
72441fb744b4Smrg      lib*)
72451fb744b4Smrg	func_stripname 'lib' '.la' "$outputname"
72461fb744b4Smrg	name=$func_stripname_result
72471fb744b4Smrg	eval shared_ext=\"$shrext_cmds\"
72481fb744b4Smrg	eval libname=\"$libname_spec\"
72491fb744b4Smrg	;;
72501fb744b4Smrg      *)
72511fb744b4Smrg	test "$module" = no && \
72521fb744b4Smrg	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
72531fb744b4Smrg
72541fb744b4Smrg	if test "$need_lib_prefix" != no; then
72551fb744b4Smrg	  # Add the "lib" prefix for modules if required
72561fb744b4Smrg	  func_stripname '' '.la' "$outputname"
72571fb744b4Smrg	  name=$func_stripname_result
72581fb744b4Smrg	  eval shared_ext=\"$shrext_cmds\"
72591fb744b4Smrg	  eval libname=\"$libname_spec\"
72601fb744b4Smrg	else
72611fb744b4Smrg	  func_stripname '' '.la' "$outputname"
72621fb744b4Smrg	  libname=$func_stripname_result
72631fb744b4Smrg	fi
72641fb744b4Smrg	;;
72651fb744b4Smrg      esac
72661fb744b4Smrg
72671fb744b4Smrg      if test -n "$objs"; then
72681fb744b4Smrg	if test "$deplibs_check_method" != pass_all; then
72691fb744b4Smrg	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
72701fb744b4Smrg	else
72711fb744b4Smrg	  echo
72721fb744b4Smrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
72731fb744b4Smrg	  $ECHO "*** objects $objs is not portable!"
72741fb744b4Smrg	  func_append libobjs " $objs"
72751fb744b4Smrg	fi
72761fb744b4Smrg      fi
72771fb744b4Smrg
72781fb744b4Smrg      test "$dlself" != no && \
72791fb744b4Smrg	func_warning "\`-dlopen self' is ignored for libtool libraries"
72801fb744b4Smrg
72811fb744b4Smrg      set dummy $rpath
72821fb744b4Smrg      shift
72831fb744b4Smrg      test "$#" -gt 1 && \
72841fb744b4Smrg	func_warning "ignoring multiple \`-rpath's for a libtool library"
72851fb744b4Smrg
72861fb744b4Smrg      install_libdir="$1"
72871fb744b4Smrg
72881fb744b4Smrg      oldlibs=
72891fb744b4Smrg      if test -z "$rpath"; then
72901fb744b4Smrg	if test "$build_libtool_libs" = yes; then
72911fb744b4Smrg	  # Building a libtool convenience library.
72921fb744b4Smrg	  # Some compilers have problems with a `.al' extension so
72931fb744b4Smrg	  # convenience libraries should have the same extension an
72941fb744b4Smrg	  # archive normally would.
72951fb744b4Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
72961fb744b4Smrg	  build_libtool_libs=convenience
72971fb744b4Smrg	  build_old_libs=yes
72981fb744b4Smrg	fi
72991fb744b4Smrg
73001fb744b4Smrg	test -n "$vinfo" && \
73011fb744b4Smrg	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
73021fb744b4Smrg
73031fb744b4Smrg	test -n "$release" && \
73041fb744b4Smrg	  func_warning "\`-release' is ignored for convenience libraries"
73051fb744b4Smrg      else
73061fb744b4Smrg
73071fb744b4Smrg	# Parse the version information argument.
73081fb744b4Smrg	save_ifs="$IFS"; IFS=':'
73091fb744b4Smrg	set dummy $vinfo 0 0 0
73101fb744b4Smrg	shift
73111fb744b4Smrg	IFS="$save_ifs"
73121fb744b4Smrg
73131fb744b4Smrg	test -n "$7" && \
73141fb744b4Smrg	  func_fatal_help "too many parameters to \`-version-info'"
73151fb744b4Smrg
73161fb744b4Smrg	# convert absolute version numbers to libtool ages
73171fb744b4Smrg	# this retains compatibility with .la files and attempts
73181fb744b4Smrg	# to make the code below a bit more comprehensible
73191fb744b4Smrg
73201fb744b4Smrg	case $vinfo_number in
73211fb744b4Smrg	yes)
73221fb744b4Smrg	  number_major="$1"
73231fb744b4Smrg	  number_minor="$2"
73241fb744b4Smrg	  number_revision="$3"
73251fb744b4Smrg	  #
73261fb744b4Smrg	  # There are really only two kinds -- those that
73271fb744b4Smrg	  # use the current revision as the major version
73281fb744b4Smrg	  # and those that subtract age and use age as
73291fb744b4Smrg	  # a minor version.  But, then there is irix
73301fb744b4Smrg	  # which has an extra 1 added just for fun
73311fb744b4Smrg	  #
73321fb744b4Smrg	  case $version_type in
73331fb744b4Smrg	  # correct linux to gnu/linux during the next big refactor
73341fb744b4Smrg	  darwin|linux|osf|windows|none)
73351fb744b4Smrg	    func_arith $number_major + $number_minor
73361fb744b4Smrg	    current=$func_arith_result
73371fb744b4Smrg	    age="$number_minor"
73381fb744b4Smrg	    revision="$number_revision"
73391fb744b4Smrg	    ;;
73401fb744b4Smrg	  freebsd-aout|freebsd-elf|qnx|sunos)
73411fb744b4Smrg	    current="$number_major"
73421fb744b4Smrg	    revision="$number_minor"
73431fb744b4Smrg	    age="0"
73441fb744b4Smrg	    ;;
73451fb744b4Smrg	  irix|nonstopux)
73461fb744b4Smrg	    func_arith $number_major + $number_minor
73471fb744b4Smrg	    current=$func_arith_result
73481fb744b4Smrg	    age="$number_minor"
73491fb744b4Smrg	    revision="$number_minor"
73501fb744b4Smrg	    lt_irix_increment=no
73511fb744b4Smrg	    ;;
73521fb744b4Smrg	  esac
73531fb744b4Smrg	  ;;
73541fb744b4Smrg	no)
73551fb744b4Smrg	  current="$1"
73561fb744b4Smrg	  revision="$2"
73571fb744b4Smrg	  age="$3"
73581fb744b4Smrg	  ;;
73591fb744b4Smrg	esac
73601fb744b4Smrg
73611fb744b4Smrg	# Check that each of the things are valid numbers.
73621fb744b4Smrg	case $current in
73631fb744b4Smrg	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]) ;;
73641fb744b4Smrg	*)
73651fb744b4Smrg	  func_error "CURRENT \`$current' must be a nonnegative integer"
73661fb744b4Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
73671fb744b4Smrg	  ;;
73681fb744b4Smrg	esac
73691fb744b4Smrg
73701fb744b4Smrg	case $revision in
73711fb744b4Smrg	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]) ;;
73721fb744b4Smrg	*)
73731fb744b4Smrg	  func_error "REVISION \`$revision' must be a nonnegative integer"
73741fb744b4Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
73751fb744b4Smrg	  ;;
73761fb744b4Smrg	esac
73771fb744b4Smrg
73781fb744b4Smrg	case $age in
73791fb744b4Smrg	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]) ;;
73801fb744b4Smrg	*)
73811fb744b4Smrg	  func_error "AGE \`$age' must be a nonnegative integer"
73821fb744b4Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
73831fb744b4Smrg	  ;;
73841fb744b4Smrg	esac
73851fb744b4Smrg
73861fb744b4Smrg	if test "$age" -gt "$current"; then
73871fb744b4Smrg	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
73881fb744b4Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
73891fb744b4Smrg	fi
73901fb744b4Smrg
73911fb744b4Smrg	# Calculate the version variables.
73921fb744b4Smrg	major=
73931fb744b4Smrg	versuffix=
73941fb744b4Smrg	verstring=
73951fb744b4Smrg	case $version_type in
73961fb744b4Smrg	none) ;;
73971fb744b4Smrg
73981fb744b4Smrg	darwin)
73991fb744b4Smrg	  # Like Linux, but with the current version available in
74001fb744b4Smrg	  # verstring for coding it into the library header
74011fb744b4Smrg	  func_arith $current - $age
74021fb744b4Smrg	  major=.$func_arith_result
74031fb744b4Smrg	  versuffix="$major.$age.$revision"
74041fb744b4Smrg	  # Darwin ld doesn't like 0 for these options...
74051fb744b4Smrg	  func_arith $current + 1
74061fb744b4Smrg	  minor_current=$func_arith_result
74071fb744b4Smrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
74081fb744b4Smrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
74091fb744b4Smrg	  ;;
74101fb744b4Smrg
74111fb744b4Smrg	freebsd-aout)
74121fb744b4Smrg	  major=".$current"
74131fb744b4Smrg	  versuffix=".$current.$revision";
74141fb744b4Smrg	  ;;
74151fb744b4Smrg
74161fb744b4Smrg	freebsd-elf)
74171fb744b4Smrg	  major=".$current"
74181fb744b4Smrg	  versuffix=".$current"
74191fb744b4Smrg	  ;;
74201fb744b4Smrg
74211fb744b4Smrg	irix | nonstopux)
74221fb744b4Smrg	  if test "X$lt_irix_increment" = "Xno"; then
74231fb744b4Smrg	    func_arith $current - $age
74241fb744b4Smrg	  else
74251fb744b4Smrg	    func_arith $current - $age + 1
74261fb744b4Smrg	  fi
74271fb744b4Smrg	  major=$func_arith_result
74281fb744b4Smrg
74291fb744b4Smrg	  case $version_type in
74301fb744b4Smrg	    nonstopux) verstring_prefix=nonstopux ;;
74311fb744b4Smrg	    *)         verstring_prefix=sgi ;;
74321fb744b4Smrg	  esac
74331fb744b4Smrg	  verstring="$verstring_prefix$major.$revision"
74341fb744b4Smrg
74351fb744b4Smrg	  # Add in all the interfaces that we are compatible with.
74361fb744b4Smrg	  loop=$revision
74371fb744b4Smrg	  while test "$loop" -ne 0; do
74381fb744b4Smrg	    func_arith $revision - $loop
74391fb744b4Smrg	    iface=$func_arith_result
74401fb744b4Smrg	    func_arith $loop - 1
74411fb744b4Smrg	    loop=$func_arith_result
74421fb744b4Smrg	    verstring="$verstring_prefix$major.$iface:$verstring"
74431fb744b4Smrg	  done
74441fb744b4Smrg
74451fb744b4Smrg	  # Before this point, $major must not contain `.'.
74461fb744b4Smrg	  major=.$major
74471fb744b4Smrg	  versuffix="$major.$revision"
74481fb744b4Smrg	  ;;
74491fb744b4Smrg
74501fb744b4Smrg	linux) # correct to gnu/linux during the next big refactor
74511fb744b4Smrg	  func_arith $current - $age
74521fb744b4Smrg	  major=.$func_arith_result
74531fb744b4Smrg	  versuffix="$major.$age.$revision"
74541fb744b4Smrg	  ;;
74551fb744b4Smrg
74561fb744b4Smrg	osf)
74571fb744b4Smrg	  func_arith $current - $age
74581fb744b4Smrg	  major=.$func_arith_result
74591fb744b4Smrg	  versuffix=".$current.$age.$revision"
74601fb744b4Smrg	  verstring="$current.$age.$revision"
74611fb744b4Smrg
74621fb744b4Smrg	  # Add in all the interfaces that we are compatible with.
74631fb744b4Smrg	  loop=$age
74641fb744b4Smrg	  while test "$loop" -ne 0; do
74651fb744b4Smrg	    func_arith $current - $loop
74661fb744b4Smrg	    iface=$func_arith_result
74671fb744b4Smrg	    func_arith $loop - 1
74681fb744b4Smrg	    loop=$func_arith_result
74691fb744b4Smrg	    verstring="$verstring:${iface}.0"
74701fb744b4Smrg	  done
74711fb744b4Smrg
74721fb744b4Smrg	  # Make executables depend on our current version.
74731fb744b4Smrg	  func_append verstring ":${current}.0"
74741fb744b4Smrg	  ;;
74751fb744b4Smrg
74761fb744b4Smrg	qnx)
74771fb744b4Smrg	  major=".$current"
74781fb744b4Smrg	  versuffix=".$current"
74791fb744b4Smrg	  ;;
74801fb744b4Smrg
74811fb744b4Smrg	sunos)
74821fb744b4Smrg	  major=".$current"
74831fb744b4Smrg	  versuffix=".$current.$revision"
74841fb744b4Smrg	  ;;
74851fb744b4Smrg
74861fb744b4Smrg	windows)
74871fb744b4Smrg	  # Use '-' rather than '.', since we only want one
74881fb744b4Smrg	  # extension on DOS 8.3 filesystems.
74891fb744b4Smrg	  func_arith $current - $age
74901fb744b4Smrg	  major=$func_arith_result
74911fb744b4Smrg	  versuffix="-$major"
74921fb744b4Smrg	  ;;
74931fb744b4Smrg
74941fb744b4Smrg	*)
74951fb744b4Smrg	  func_fatal_configuration "unknown library version type \`$version_type'"
74961fb744b4Smrg	  ;;
74971fb744b4Smrg	esac
74981fb744b4Smrg
74991fb744b4Smrg	# Clear the version info if we defaulted, and they specified a release.
75001fb744b4Smrg	if test -z "$vinfo" && test -n "$release"; then
75011fb744b4Smrg	  major=
75021fb744b4Smrg	  case $version_type in
75031fb744b4Smrg	  darwin)
75041fb744b4Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
75051fb744b4Smrg	    # problems, so we reset it completely
75061fb744b4Smrg	    verstring=
75071fb744b4Smrg	    ;;
75081fb744b4Smrg	  *)
75091fb744b4Smrg	    verstring="0.0"
75101fb744b4Smrg	    ;;
75111fb744b4Smrg	  esac
75121fb744b4Smrg	  if test "$need_version" = no; then
75131fb744b4Smrg	    versuffix=
75141fb744b4Smrg	  else
75151fb744b4Smrg	    versuffix=".0.0"
75161fb744b4Smrg	  fi
75171fb744b4Smrg	fi
75181fb744b4Smrg
75191fb744b4Smrg	# Remove version info from name if versioning should be avoided
75201fb744b4Smrg	if test "$avoid_version" = yes && test "$need_version" = no; then
75211fb744b4Smrg	  major=
75221fb744b4Smrg	  versuffix=
75231fb744b4Smrg	  verstring=""
75241fb744b4Smrg	fi
75251fb744b4Smrg
75261fb744b4Smrg	# Check to see if the archive will have undefined symbols.
75271fb744b4Smrg	if test "$allow_undefined" = yes; then
75281fb744b4Smrg	  if test "$allow_undefined_flag" = unsupported; then
75291fb744b4Smrg	    func_warning "undefined symbols not allowed in $host shared libraries"
75301fb744b4Smrg	    build_libtool_libs=no
75311fb744b4Smrg	    build_old_libs=yes
75321fb744b4Smrg	  fi
75331fb744b4Smrg	else
75341fb744b4Smrg	  # Don't allow undefined symbols.
75351fb744b4Smrg	  allow_undefined_flag="$no_undefined_flag"
75361fb744b4Smrg	fi
75371fb744b4Smrg
75381fb744b4Smrg      fi
75391fb744b4Smrg
75401fb744b4Smrg      func_generate_dlsyms "$libname" "$libname" "yes"
75411fb744b4Smrg      func_append libobjs " $symfileobj"
75421fb744b4Smrg      test "X$libobjs" = "X " && libobjs=
75431fb744b4Smrg
75441fb744b4Smrg      if test "$opt_mode" != relink; then
75451fb744b4Smrg	# Remove our outputs, but don't remove object files since they
75461fb744b4Smrg	# may have been created when compiling PIC objects.
75471fb744b4Smrg	removelist=
75481fb744b4Smrg	tempremovelist=`$ECHO "$output_objdir/*"`
75491fb744b4Smrg	for p in $tempremovelist; do
75501fb744b4Smrg	  case $p in
75511fb744b4Smrg	    *.$objext | *.gcno)
75521fb744b4Smrg	       ;;
75531fb744b4Smrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
75541fb744b4Smrg	       if test "X$precious_files_regex" != "X"; then
75551fb744b4Smrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
75561fb744b4Smrg		 then
75571fb744b4Smrg		   continue
75581fb744b4Smrg		 fi
75591fb744b4Smrg	       fi
75601fb744b4Smrg	       func_append removelist " $p"
75611fb744b4Smrg	       ;;
75621fb744b4Smrg	    *) ;;
75631fb744b4Smrg	  esac
75641fb744b4Smrg	done
75651fb744b4Smrg	test -n "$removelist" && \
75661fb744b4Smrg	  func_show_eval "${RM}r \$removelist"
75671fb744b4Smrg      fi
75681fb744b4Smrg
75691fb744b4Smrg      # Now set the variables for building old libraries.
75701fb744b4Smrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
75711fb744b4Smrg	func_append oldlibs " $output_objdir/$libname.$libext"
75721fb744b4Smrg
75731fb744b4Smrg	# Transform .lo files to .o files.
75741fb744b4Smrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
75751fb744b4Smrg      fi
75761fb744b4Smrg
75771fb744b4Smrg      # Eliminate all temporary directories.
75781fb744b4Smrg      #for path in $notinst_path; do
75791fb744b4Smrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
75801fb744b4Smrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
75811fb744b4Smrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
75821fb744b4Smrg      #done
75831fb744b4Smrg
75841fb744b4Smrg      if test -n "$xrpath"; then
75851fb744b4Smrg	# If the user specified any rpath flags, then add them.
75861fb744b4Smrg	temp_xrpath=
75871fb744b4Smrg	for libdir in $xrpath; do
75881fb744b4Smrg	  func_replace_sysroot "$libdir"
75891fb744b4Smrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
75901fb744b4Smrg	  case "$finalize_rpath " in
75911fb744b4Smrg	  *" $libdir "*) ;;
75921fb744b4Smrg	  *) func_append finalize_rpath " $libdir" ;;
75931fb744b4Smrg	  esac
75941fb744b4Smrg	done
75951fb744b4Smrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
75961fb744b4Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
75971fb744b4Smrg	fi
75981fb744b4Smrg      fi
75991fb744b4Smrg
76001fb744b4Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
76011fb744b4Smrg      old_dlfiles="$dlfiles"
76021fb744b4Smrg      dlfiles=
76031fb744b4Smrg      for lib in $old_dlfiles; do
76041fb744b4Smrg	case " $dlprefiles $dlfiles " in
76051fb744b4Smrg	*" $lib "*) ;;
76061fb744b4Smrg	*) func_append dlfiles " $lib" ;;
76071fb744b4Smrg	esac
76081fb744b4Smrg      done
76091fb744b4Smrg
76101fb744b4Smrg      # Make sure dlprefiles contains only unique files
76111fb744b4Smrg      old_dlprefiles="$dlprefiles"
76121fb744b4Smrg      dlprefiles=
76131fb744b4Smrg      for lib in $old_dlprefiles; do
76141fb744b4Smrg	case "$dlprefiles " in
76151fb744b4Smrg	*" $lib "*) ;;
76161fb744b4Smrg	*) func_append dlprefiles " $lib" ;;
76171fb744b4Smrg	esac
76181fb744b4Smrg      done
76191fb744b4Smrg
76201fb744b4Smrg      if test "$build_libtool_libs" = yes; then
76211fb744b4Smrg	if test -n "$rpath"; then
76221fb744b4Smrg	  case $host in
76231fb744b4Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
76241fb744b4Smrg	    # these systems don't actually have a c library (as such)!
76251fb744b4Smrg	    ;;
76261fb744b4Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
76271fb744b4Smrg	    # Rhapsody C library is in the System framework
76281fb744b4Smrg	    func_append deplibs " System.ltframework"
76291fb744b4Smrg	    ;;
76301fb744b4Smrg	  *-*-netbsd*)
76311fb744b4Smrg	    # Don't link with libc until the a.out ld.so is fixed.
76321fb744b4Smrg	    ;;
76331fb744b4Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
76341fb744b4Smrg	    # Do not include libc due to us having libc/libc_r.
76351fb744b4Smrg	    ;;
76361fb744b4Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
76371fb744b4Smrg	    # Causes problems with __ctype
76381fb744b4Smrg	    ;;
76391fb744b4Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
76401fb744b4Smrg	    # Compiler inserts libc in the correct place for threads to work
76411fb744b4Smrg	    ;;
76421fb744b4Smrg	  *)
76431fb744b4Smrg	    # Add libc to deplibs on all other systems if necessary.
76441fb744b4Smrg	    if test "$build_libtool_need_lc" = "yes"; then
76451fb744b4Smrg	      func_append deplibs " -lc"
76461fb744b4Smrg	    fi
76471fb744b4Smrg	    ;;
76481fb744b4Smrg	  esac
76491fb744b4Smrg	fi
76501fb744b4Smrg
76511fb744b4Smrg	# Transform deplibs into only deplibs that can be linked in shared.
76521fb744b4Smrg	name_save=$name
76531fb744b4Smrg	libname_save=$libname
76541fb744b4Smrg	release_save=$release
76551fb744b4Smrg	versuffix_save=$versuffix
76561fb744b4Smrg	major_save=$major
76571fb744b4Smrg	# I'm not sure if I'm treating the release correctly.  I think
76581fb744b4Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
76591fb744b4Smrg	# add it in twice.  Is that correct?
76601fb744b4Smrg	release=""
76611fb744b4Smrg	versuffix=""
76621fb744b4Smrg	major=""
76631fb744b4Smrg	newdeplibs=
76641fb744b4Smrg	droppeddeps=no
76651fb744b4Smrg	case $deplibs_check_method in
76661fb744b4Smrg	pass_all)
76671fb744b4Smrg	  # Don't check for shared/static.  Everything works.
76681fb744b4Smrg	  # This might be a little naive.  We might want to check
76691fb744b4Smrg	  # whether the library exists or not.  But this is on
76701fb744b4Smrg	  # osf3 & osf4 and I'm not really sure... Just
76711fb744b4Smrg	  # implementing what was already the behavior.
76721fb744b4Smrg	  newdeplibs=$deplibs
76731fb744b4Smrg	  ;;
76741fb744b4Smrg	test_compile)
76751fb744b4Smrg	  # This code stresses the "libraries are programs" paradigm to its
76761fb744b4Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
76771fb744b4Smrg	  # against the deplibs as a proxy for the library.  Then we can check
76781fb744b4Smrg	  # whether they linked in statically or dynamically with ldd.
76791fb744b4Smrg	  $opt_dry_run || $RM conftest.c
76801fb744b4Smrg	  cat > conftest.c <<EOF
76811fb744b4Smrg	  int main() { return 0; }
76821fb744b4SmrgEOF
76831fb744b4Smrg	  $opt_dry_run || $RM conftest
76841fb744b4Smrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
76851fb744b4Smrg	    ldd_output=`ldd conftest`
76861fb744b4Smrg	    for i in $deplibs; do
76871fb744b4Smrg	      case $i in
76881fb744b4Smrg	      -l*)
76891fb744b4Smrg		func_stripname -l '' "$i"
76901fb744b4Smrg		name=$func_stripname_result
76911fb744b4Smrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
76921fb744b4Smrg		  case " $predeps $postdeps " in
76931fb744b4Smrg		  *" $i "*)
76941fb744b4Smrg		    func_append newdeplibs " $i"
76951fb744b4Smrg		    i=""
76961fb744b4Smrg		    ;;
76971fb744b4Smrg		  esac
76981fb744b4Smrg		fi
76991fb744b4Smrg		if test -n "$i" ; then
77001fb744b4Smrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
77011fb744b4Smrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
77021fb744b4Smrg		  set dummy $deplib_matches; shift
77031fb744b4Smrg		  deplib_match=$1
77041fb744b4Smrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
77051fb744b4Smrg		    func_append newdeplibs " $i"
77061fb744b4Smrg		  else
77071fb744b4Smrg		    droppeddeps=yes
77081fb744b4Smrg		    echo
77091fb744b4Smrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
77101fb744b4Smrg		    echo "*** I have the capability to make that library automatically link in when"
77111fb744b4Smrg		    echo "*** you link to this library.  But I can only do this if you have a"
77121fb744b4Smrg		    echo "*** shared version of the library, which I believe you do not have"
77131fb744b4Smrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
77141fb744b4Smrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
77151fb744b4Smrg		  fi
77161fb744b4Smrg		fi
77171fb744b4Smrg		;;
77181fb744b4Smrg	      *)
77191fb744b4Smrg		func_append newdeplibs " $i"
77201fb744b4Smrg		;;
77211fb744b4Smrg	      esac
77221fb744b4Smrg	    done
77231fb744b4Smrg	  else
77241fb744b4Smrg	    # Error occurred in the first compile.  Let's try to salvage
77251fb744b4Smrg	    # the situation: Compile a separate program for each library.
77261fb744b4Smrg	    for i in $deplibs; do
77271fb744b4Smrg	      case $i in
77281fb744b4Smrg	      -l*)
77291fb744b4Smrg		func_stripname -l '' "$i"
77301fb744b4Smrg		name=$func_stripname_result
77311fb744b4Smrg		$opt_dry_run || $RM conftest
77321fb744b4Smrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
77331fb744b4Smrg		  ldd_output=`ldd conftest`
77341fb744b4Smrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
77351fb744b4Smrg		    case " $predeps $postdeps " in
77361fb744b4Smrg		    *" $i "*)
77371fb744b4Smrg		      func_append newdeplibs " $i"
77381fb744b4Smrg		      i=""
77391fb744b4Smrg		      ;;
77401fb744b4Smrg		    esac
77411fb744b4Smrg		  fi
77421fb744b4Smrg		  if test -n "$i" ; then
77431fb744b4Smrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
77441fb744b4Smrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
77451fb744b4Smrg		    set dummy $deplib_matches; shift
77461fb744b4Smrg		    deplib_match=$1
77471fb744b4Smrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
77481fb744b4Smrg		      func_append newdeplibs " $i"
77491fb744b4Smrg		    else
77501fb744b4Smrg		      droppeddeps=yes
77511fb744b4Smrg		      echo
77521fb744b4Smrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
77531fb744b4Smrg		      echo "*** I have the capability to make that library automatically link in when"
77541fb744b4Smrg		      echo "*** you link to this library.  But I can only do this if you have a"
77551fb744b4Smrg		      echo "*** shared version of the library, which you do not appear to have"
77561fb744b4Smrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
77571fb744b4Smrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
77581fb744b4Smrg		    fi
77591fb744b4Smrg		  fi
77601fb744b4Smrg		else
77611fb744b4Smrg		  droppeddeps=yes
77621fb744b4Smrg		  echo
77631fb744b4Smrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
77641fb744b4Smrg		  echo "*** make it link in!  You will probably need to install it or some"
77651fb744b4Smrg		  echo "*** library that it depends on before this library will be fully"
77661fb744b4Smrg		  echo "*** functional.  Installing it before continuing would be even better."
77671fb744b4Smrg		fi
77681fb744b4Smrg		;;
77691fb744b4Smrg	      *)
77701fb744b4Smrg		func_append newdeplibs " $i"
77711fb744b4Smrg		;;
77721fb744b4Smrg	      esac
77731fb744b4Smrg	    done
77741fb744b4Smrg	  fi
77751fb744b4Smrg	  ;;
77761fb744b4Smrg	file_magic*)
77771fb744b4Smrg	  set dummy $deplibs_check_method; shift
77781fb744b4Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
77791fb744b4Smrg	  for a_deplib in $deplibs; do
77801fb744b4Smrg	    case $a_deplib in
77811fb744b4Smrg	    -l*)
77821fb744b4Smrg	      func_stripname -l '' "$a_deplib"
77831fb744b4Smrg	      name=$func_stripname_result
77841fb744b4Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
77851fb744b4Smrg		case " $predeps $postdeps " in
77861fb744b4Smrg		*" $a_deplib "*)
77871fb744b4Smrg		  func_append newdeplibs " $a_deplib"
77881fb744b4Smrg		  a_deplib=""
77891fb744b4Smrg		  ;;
77901fb744b4Smrg		esac
77911fb744b4Smrg	      fi
77921fb744b4Smrg	      if test -n "$a_deplib" ; then
77931fb744b4Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
77941fb744b4Smrg		if test -n "$file_magic_glob"; then
77951fb744b4Smrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
77961fb744b4Smrg		else
77971fb744b4Smrg		  libnameglob=$libname
77981fb744b4Smrg		fi
77991fb744b4Smrg		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
78001fb744b4Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
78011fb744b4Smrg		  if test "$want_nocaseglob" = yes; then
78021fb744b4Smrg		    shopt -s nocaseglob
78031fb744b4Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
78041fb744b4Smrg		    $nocaseglob
78051fb744b4Smrg		  else
78061fb744b4Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
78071fb744b4Smrg		  fi
78081fb744b4Smrg		  for potent_lib in $potential_libs; do
78091fb744b4Smrg		      # Follow soft links.
78101fb744b4Smrg		      if ls -lLd "$potent_lib" 2>/dev/null |
78111fb744b4Smrg			 $GREP " -> " >/dev/null; then
78121fb744b4Smrg			continue
78131fb744b4Smrg		      fi
78141fb744b4Smrg		      # The statement above tries to avoid entering an
78151fb744b4Smrg		      # endless loop below, in case of cyclic links.
78161fb744b4Smrg		      # We might still enter an endless loop, since a link
78171fb744b4Smrg		      # loop can be closed while we follow links,
78181fb744b4Smrg		      # but so what?
78191fb744b4Smrg		      potlib="$potent_lib"
78201fb744b4Smrg		      while test -h "$potlib" 2>/dev/null; do
78211fb744b4Smrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
78221fb744b4Smrg			case $potliblink in
78231fb744b4Smrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
78241fb744b4Smrg			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
78251fb744b4Smrg			esac
78261fb744b4Smrg		      done
78271fb744b4Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
78281fb744b4Smrg			 $SED -e 10q |
78291fb744b4Smrg			 $EGREP "$file_magic_regex" > /dev/null; then
78301fb744b4Smrg			func_append newdeplibs " $a_deplib"
78311fb744b4Smrg			a_deplib=""
78321fb744b4Smrg			break 2
78331fb744b4Smrg		      fi
78341fb744b4Smrg		  done
78351fb744b4Smrg		done
78361fb744b4Smrg	      fi
78371fb744b4Smrg	      if test -n "$a_deplib" ; then
78381fb744b4Smrg		droppeddeps=yes
78391fb744b4Smrg		echo
78401fb744b4Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
78411fb744b4Smrg		echo "*** I have the capability to make that library automatically link in when"
78421fb744b4Smrg		echo "*** you link to this library.  But I can only do this if you have a"
78431fb744b4Smrg		echo "*** shared version of the library, which you do not appear to have"
78441fb744b4Smrg		echo "*** because I did check the linker path looking for a file starting"
78451fb744b4Smrg		if test -z "$potlib" ; then
78461fb744b4Smrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
78471fb744b4Smrg		else
78481fb744b4Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
78491fb744b4Smrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
78501fb744b4Smrg		fi
78511fb744b4Smrg	      fi
78521fb744b4Smrg	      ;;
78531fb744b4Smrg	    *)
78541fb744b4Smrg	      # Add a -L argument.
78551fb744b4Smrg	      func_append newdeplibs " $a_deplib"
78561fb744b4Smrg	      ;;
78571fb744b4Smrg	    esac
78581fb744b4Smrg	  done # Gone through all deplibs.
78591fb744b4Smrg	  ;;
78601fb744b4Smrg	match_pattern*)
78611fb744b4Smrg	  set dummy $deplibs_check_method; shift
78621fb744b4Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
78631fb744b4Smrg	  for a_deplib in $deplibs; do
78641fb744b4Smrg	    case $a_deplib in
78651fb744b4Smrg	    -l*)
78661fb744b4Smrg	      func_stripname -l '' "$a_deplib"
78671fb744b4Smrg	      name=$func_stripname_result
78681fb744b4Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
78691fb744b4Smrg		case " $predeps $postdeps " in
78701fb744b4Smrg		*" $a_deplib "*)
78711fb744b4Smrg		  func_append newdeplibs " $a_deplib"
78721fb744b4Smrg		  a_deplib=""
78731fb744b4Smrg		  ;;
78741fb744b4Smrg		esac
78751fb744b4Smrg	      fi
78761fb744b4Smrg	      if test -n "$a_deplib" ; then
78771fb744b4Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
78781fb744b4Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
78791fb744b4Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
78801fb744b4Smrg		  for potent_lib in $potential_libs; do
78811fb744b4Smrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
78821fb744b4Smrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
78831fb744b4Smrg		       $EGREP "$match_pattern_regex" > /dev/null; then
78841fb744b4Smrg		      func_append newdeplibs " $a_deplib"
78851fb744b4Smrg		      a_deplib=""
78861fb744b4Smrg		      break 2
78871fb744b4Smrg		    fi
78881fb744b4Smrg		  done
78891fb744b4Smrg		done
78901fb744b4Smrg	      fi
78911fb744b4Smrg	      if test -n "$a_deplib" ; then
78921fb744b4Smrg		droppeddeps=yes
78931fb744b4Smrg		echo
78941fb744b4Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
78951fb744b4Smrg		echo "*** I have the capability to make that library automatically link in when"
78961fb744b4Smrg		echo "*** you link to this library.  But I can only do this if you have a"
78971fb744b4Smrg		echo "*** shared version of the library, which you do not appear to have"
78981fb744b4Smrg		echo "*** because I did check the linker path looking for a file starting"
78991fb744b4Smrg		if test -z "$potlib" ; then
79001fb744b4Smrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
79011fb744b4Smrg		else
79021fb744b4Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
79031fb744b4Smrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
79041fb744b4Smrg		fi
79051fb744b4Smrg	      fi
79061fb744b4Smrg	      ;;
79071fb744b4Smrg	    *)
79081fb744b4Smrg	      # Add a -L argument.
79091fb744b4Smrg	      func_append newdeplibs " $a_deplib"
79101fb744b4Smrg	      ;;
79111fb744b4Smrg	    esac
79121fb744b4Smrg	  done # Gone through all deplibs.
79131fb744b4Smrg	  ;;
79141fb744b4Smrg	none | unknown | *)
79151fb744b4Smrg	  newdeplibs=""
79161fb744b4Smrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
79171fb744b4Smrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
79181fb744b4Smrg	    for i in $predeps $postdeps ; do
79191fb744b4Smrg	      # can't use Xsed below, because $i might contain '/'
79201fb744b4Smrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
79211fb744b4Smrg	    done
79221fb744b4Smrg	  fi
79231fb744b4Smrg	  case $tmp_deplibs in
79241fb744b4Smrg	  *[!\	\ ]*)
79251fb744b4Smrg	    echo
79261fb744b4Smrg	    if test "X$deplibs_check_method" = "Xnone"; then
79271fb744b4Smrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
79281fb744b4Smrg	    else
79291fb744b4Smrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
79301fb744b4Smrg	    fi
79311fb744b4Smrg	    echo "*** All declared inter-library dependencies are being dropped."
79321fb744b4Smrg	    droppeddeps=yes
79331fb744b4Smrg	    ;;
79341fb744b4Smrg	  esac
79351fb744b4Smrg	  ;;
79361fb744b4Smrg	esac
79371fb744b4Smrg	versuffix=$versuffix_save
79381fb744b4Smrg	major=$major_save
79391fb744b4Smrg	release=$release_save
79401fb744b4Smrg	libname=$libname_save
79411fb744b4Smrg	name=$name_save
7942c35d236eSmrg
79431fb744b4Smrg	case $host in
79441fb744b4Smrg	*-*-rhapsody* | *-*-darwin1.[012])
79451fb744b4Smrg	  # On Rhapsody replace the C library with the System framework
79461fb744b4Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
79471fb744b4Smrg	  ;;
79481fb744b4Smrg	esac
7949f55e6a01Smrg
79501fb744b4Smrg	if test "$droppeddeps" = yes; then
79511fb744b4Smrg	  if test "$module" = yes; then
79521fb744b4Smrg	    echo
79531fb744b4Smrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
79541fb744b4Smrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
79551fb744b4Smrg	    echo "*** a static module, that should work as long as the dlopening"
79561fb744b4Smrg	    echo "*** application is linked with the -dlopen flag."
79571fb744b4Smrg	    if test -z "$global_symbol_pipe"; then
79581fb744b4Smrg	      echo
79591fb744b4Smrg	      echo "*** However, this would only work if libtool was able to extract symbol"
79601fb744b4Smrg	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
79611fb744b4Smrg	      echo "*** not find such a program.  So, this module is probably useless."
79621fb744b4Smrg	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
79631fb744b4Smrg	    fi
79641fb744b4Smrg	    if test "$build_old_libs" = no; then
79651fb744b4Smrg	      oldlibs="$output_objdir/$libname.$libext"
79661fb744b4Smrg	      build_libtool_libs=module
79671fb744b4Smrg	      build_old_libs=yes
79681fb744b4Smrg	    else
79691fb744b4Smrg	      build_libtool_libs=no
79701fb744b4Smrg	    fi
79711fb744b4Smrg	  else
79721fb744b4Smrg	    echo "*** The inter-library dependencies that have been dropped here will be"
79731fb744b4Smrg	    echo "*** automatically added whenever a program is linked with this library"
79741fb744b4Smrg	    echo "*** or is declared to -dlopen it."
7975f55e6a01Smrg
79761fb744b4Smrg	    if test "$allow_undefined" = no; then
79771fb744b4Smrg	      echo
79781fb744b4Smrg	      echo "*** Since this library must not contain undefined symbols,"
79791fb744b4Smrg	      echo "*** because either the platform does not support them or"
79801fb744b4Smrg	      echo "*** it was explicitly requested with -no-undefined,"
79811fb744b4Smrg	      echo "*** libtool will only create a static version of it."
79821fb744b4Smrg	      if test "$build_old_libs" = no; then
79831fb744b4Smrg		oldlibs="$output_objdir/$libname.$libext"
79841fb744b4Smrg		build_libtool_libs=module
79851fb744b4Smrg		build_old_libs=yes
79861fb744b4Smrg	      else
79871fb744b4Smrg		build_libtool_libs=no
79881fb744b4Smrg	      fi
79891fb744b4Smrg	    fi
79901fb744b4Smrg	  fi
7991c35d236eSmrg	fi
79921fb744b4Smrg	# Done checking deplibs!
79931fb744b4Smrg	deplibs=$newdeplibs
79941fb744b4Smrg      fi
79951fb744b4Smrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
79961fb744b4Smrg      case $host in
79971fb744b4Smrg	*-*-darwin*)
79981fb744b4Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
79991fb744b4Smrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
80001fb744b4Smrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
80011fb744b4Smrg	  ;;
80021fb744b4Smrg      esac
8003c35d236eSmrg
80041fb744b4Smrg      # move library search paths that coincide with paths to not yet
80051fb744b4Smrg      # installed libraries to the beginning of the library search list
80061fb744b4Smrg      new_libs=
80071fb744b4Smrg      for path in $notinst_path; do
80081fb744b4Smrg	case " $new_libs " in
80091fb744b4Smrg	*" -L$path/$objdir "*) ;;
80101fb744b4Smrg	*)
80111fb744b4Smrg	  case " $deplibs " in
80121fb744b4Smrg	  *" -L$path/$objdir "*)
80131fb744b4Smrg	    func_append new_libs " -L$path/$objdir" ;;
80141fb744b4Smrg	  esac
80151fb744b4Smrg	  ;;
80161fb744b4Smrg	esac
80171fb744b4Smrg      done
80181fb744b4Smrg      for deplib in $deplibs; do
80191fb744b4Smrg	case $deplib in
80201fb744b4Smrg	-L*)
80211fb744b4Smrg	  case " $new_libs " in
80221fb744b4Smrg	  *" $deplib "*) ;;
80231fb744b4Smrg	  *) func_append new_libs " $deplib" ;;
80241fb744b4Smrg	  esac
80251fb744b4Smrg	  ;;
80261fb744b4Smrg	*) func_append new_libs " $deplib" ;;
80271fb744b4Smrg	esac
80281fb744b4Smrg      done
80291fb744b4Smrg      deplibs="$new_libs"
8030c35d236eSmrg
80311fb744b4Smrg      # All the library-specific variables (install_libdir is set above).
80321fb744b4Smrg      library_names=
80331fb744b4Smrg      old_library=
80341fb744b4Smrg      dlname=
8035c35d236eSmrg
80361fb744b4Smrg      # Test again, we may have decided not to build it any more
80371fb744b4Smrg      if test "$build_libtool_libs" = yes; then
80381fb744b4Smrg	# Remove ${wl} instances when linking with ld.
80391fb744b4Smrg	# FIXME: should test the right _cmds variable.
80401fb744b4Smrg	case $archive_cmds in
80411fb744b4Smrg	  *\$LD\ *) wl= ;;
80421fb744b4Smrg        esac
80431fb744b4Smrg	if test "$hardcode_into_libs" = yes; then
80441fb744b4Smrg	  # Hardcode the library paths
80451fb744b4Smrg	  hardcode_libdirs=
80461fb744b4Smrg	  dep_rpath=
80471fb744b4Smrg	  rpath="$finalize_rpath"
80481fb744b4Smrg	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
80491fb744b4Smrg	  for libdir in $rpath; do
80501fb744b4Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
80511fb744b4Smrg	      if test -n "$hardcode_libdir_separator"; then
80521fb744b4Smrg		func_replace_sysroot "$libdir"
80531fb744b4Smrg		libdir=$func_replace_sysroot_result
80541fb744b4Smrg		if test -z "$hardcode_libdirs"; then
80551fb744b4Smrg		  hardcode_libdirs="$libdir"
80561fb744b4Smrg		else
80571fb744b4Smrg		  # Just accumulate the unique libdirs.
80581fb744b4Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
80591fb744b4Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
80601fb744b4Smrg		    ;;
80611fb744b4Smrg		  *)
80621fb744b4Smrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
80631fb744b4Smrg		    ;;
80641fb744b4Smrg		  esac
80651fb744b4Smrg		fi
80661fb744b4Smrg	      else
80671fb744b4Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
80681fb744b4Smrg		func_append dep_rpath " $flag"
80691fb744b4Smrg	      fi
80701fb744b4Smrg	    elif test -n "$runpath_var"; then
80711fb744b4Smrg	      case "$perm_rpath " in
80721fb744b4Smrg	      *" $libdir "*) ;;
80731fb744b4Smrg	      *) func_append perm_rpath " $libdir" ;;
80741fb744b4Smrg	      esac
80751fb744b4Smrg	    fi
80761fb744b4Smrg	  done
80771fb744b4Smrg	  # Substitute the hardcoded libdirs into the rpath.
80781fb744b4Smrg	  if test -n "$hardcode_libdir_separator" &&
80791fb744b4Smrg	     test -n "$hardcode_libdirs"; then
80801fb744b4Smrg	    libdir="$hardcode_libdirs"
80811fb744b4Smrg	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
80821fb744b4Smrg	  fi
80831fb744b4Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
80841fb744b4Smrg	    # We should set the runpath_var.
80851fb744b4Smrg	    rpath=
80861fb744b4Smrg	    for dir in $perm_rpath; do
80871fb744b4Smrg	      func_append rpath "$dir:"
80881fb744b4Smrg	    done
80891fb744b4Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
80901fb744b4Smrg	  fi
80911fb744b4Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
8092518bcf38Smrg	fi
8093f55e6a01Smrg
80941fb744b4Smrg	shlibpath="$finalize_shlibpath"
80951fb744b4Smrg	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
80961fb744b4Smrg	if test -n "$shlibpath"; then
80971fb744b4Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
8098518bcf38Smrg	fi
8099f55e6a01Smrg
81001fb744b4Smrg	# Get the real and link names of the library.
81011fb744b4Smrg	eval shared_ext=\"$shrext_cmds\"
81021fb744b4Smrg	eval library_names=\"$library_names_spec\"
81031fb744b4Smrg	set dummy $library_names
81041fb744b4Smrg	shift
81051fb744b4Smrg	realname="$1"
81061fb744b4Smrg	shift
8107f55e6a01Smrg
81081fb744b4Smrg	if test -n "$soname_spec"; then
81091fb744b4Smrg	  eval soname=\"$soname_spec\"
8110518bcf38Smrg	else
81111fb744b4Smrg	  soname="$realname"
81121fb744b4Smrg	fi
81131fb744b4Smrg	if test -z "$dlname"; then
81141fb744b4Smrg	  dlname=$soname
8115518bcf38Smrg	fi
8116f55e6a01Smrg
81171fb744b4Smrg	lib="$output_objdir/$realname"
81181fb744b4Smrg	linknames=
81191fb744b4Smrg	for link
81201fb744b4Smrg	do
81211fb744b4Smrg	  func_append linknames " $link"
81221fb744b4Smrg	done
8123f55e6a01Smrg
81241fb744b4Smrg	# Use standard objects if they are pic
81251fb744b4Smrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
81261fb744b4Smrg	test "X$libobjs" = "X " && libobjs=
8127f55e6a01Smrg
81281fb744b4Smrg	delfiles=
81291fb744b4Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
81301fb744b4Smrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
81311fb744b4Smrg	  export_symbols="$output_objdir/$libname.uexp"
81321fb744b4Smrg	  func_append delfiles " $export_symbols"
81331fb744b4Smrg	fi
8134c35d236eSmrg
81351fb744b4Smrg	orig_export_symbols=
81361fb744b4Smrg	case $host_os in
81371fb744b4Smrg	cygwin* | mingw* | cegcc*)
81381fb744b4Smrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
81391fb744b4Smrg	    # exporting using user supplied symfile
81401fb744b4Smrg	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
81411fb744b4Smrg	      # and it's NOT already a .def file. Must figure out
81421fb744b4Smrg	      # which of the given symbols are data symbols and tag
81431fb744b4Smrg	      # them as such. So, trigger use of export_symbols_cmds.
81441fb744b4Smrg	      # export_symbols gets reassigned inside the "prepare
81451fb744b4Smrg	      # the list of exported symbols" if statement, so the
81461fb744b4Smrg	      # include_expsyms logic still works.
81471fb744b4Smrg	      orig_export_symbols="$export_symbols"
81481fb744b4Smrg	      export_symbols=
81491fb744b4Smrg	      always_export_symbols=yes
8150f55e6a01Smrg	    fi
8151f55e6a01Smrg	  fi
81521fb744b4Smrg	  ;;
81531fb744b4Smrg	esac
8154c35d236eSmrg
81551fb744b4Smrg	# Prepare the list of exported symbols
81561fb744b4Smrg	if test -z "$export_symbols"; then
81571fb744b4Smrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
81581fb744b4Smrg	    func_verbose "generating symbol list for \`$libname.la'"
81591fb744b4Smrg	    export_symbols="$output_objdir/$libname.exp"
81601fb744b4Smrg	    $opt_dry_run || $RM $export_symbols
81611fb744b4Smrg	    cmds=$export_symbols_cmds
81621fb744b4Smrg	    save_ifs="$IFS"; IFS='~'
81631fb744b4Smrg	    for cmd1 in $cmds; do
81641fb744b4Smrg	      IFS="$save_ifs"
81651fb744b4Smrg	      # Take the normal branch if the nm_file_list_spec branch
81661fb744b4Smrg	      # doesn't work or if tool conversion is not needed.
81671fb744b4Smrg	      case $nm_file_list_spec~$to_tool_file_cmd in
81681fb744b4Smrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
81691fb744b4Smrg		  try_normal_branch=yes
81701fb744b4Smrg		  eval cmd=\"$cmd1\"
81711fb744b4Smrg		  func_len " $cmd"
81721fb744b4Smrg		  len=$func_len_result
81731fb744b4Smrg		  ;;
81741fb744b4Smrg		*)
81751fb744b4Smrg		  try_normal_branch=no
81761fb744b4Smrg		  ;;
81771fb744b4Smrg	      esac
81781fb744b4Smrg	      if test "$try_normal_branch" = yes \
81791fb744b4Smrg		 && { test "$len" -lt "$max_cmd_len" \
81801fb744b4Smrg		      || test "$max_cmd_len" -le -1; }
81811fb744b4Smrg	      then
81821fb744b4Smrg		func_show_eval "$cmd" 'exit $?'
81831fb744b4Smrg		skipped_export=false
81841fb744b4Smrg	      elif test -n "$nm_file_list_spec"; then
81851fb744b4Smrg		func_basename "$output"
81861fb744b4Smrg		output_la=$func_basename_result
81871fb744b4Smrg		save_libobjs=$libobjs
81881fb744b4Smrg		save_output=$output
81891fb744b4Smrg		output=${output_objdir}/${output_la}.nm
81901fb744b4Smrg		func_to_tool_file "$output"
81911fb744b4Smrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
81921fb744b4Smrg		func_append delfiles " $output"
81931fb744b4Smrg		func_verbose "creating $NM input file list: $output"
81941fb744b4Smrg		for obj in $save_libobjs; do
81951fb744b4Smrg		  func_to_tool_file "$obj"
81961fb744b4Smrg		  $ECHO "$func_to_tool_file_result"
81971fb744b4Smrg		done > "$output"
81981fb744b4Smrg		eval cmd=\"$cmd1\"
81991fb744b4Smrg		func_show_eval "$cmd" 'exit $?'
82001fb744b4Smrg		output=$save_output
82011fb744b4Smrg		libobjs=$save_libobjs
82021fb744b4Smrg		skipped_export=false
82031fb744b4Smrg	      else
82041fb744b4Smrg		# The command line is too long to execute in one step.
82051fb744b4Smrg		func_verbose "using reloadable object file for export list..."
82061fb744b4Smrg		skipped_export=:
82071fb744b4Smrg		# Break out early, otherwise skipped_export may be
82081fb744b4Smrg		# set to false by a later but shorter cmd.
82091fb744b4Smrg		break
82101fb744b4Smrg	      fi
82111fb744b4Smrg	    done
82121fb744b4Smrg	    IFS="$save_ifs"
82131fb744b4Smrg	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
82141fb744b4Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
82151fb744b4Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
82161fb744b4Smrg	    fi
82171fb744b4Smrg	  fi
82181fb744b4Smrg	fi
82191fb744b4Smrg
82201fb744b4Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
82211fb744b4Smrg	  tmp_export_symbols="$export_symbols"
82221fb744b4Smrg	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
82231fb744b4Smrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8224518bcf38Smrg	fi
8225c35d236eSmrg
82261fb744b4Smrg	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
82271fb744b4Smrg	  # The given exports_symbols file has to be filtered, so filter it.
82281fb744b4Smrg	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
82291fb744b4Smrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
82301fb744b4Smrg	  # 's' commands which not all seds can handle. GNU sed should be fine
82311fb744b4Smrg	  # though. Also, the filter scales superlinearly with the number of
82321fb744b4Smrg	  # global variables. join(1) would be nice here, but unfortunately
82331fb744b4Smrg	  # isn't a blessed tool.
82341fb744b4Smrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
82351fb744b4Smrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
82361fb744b4Smrg	  export_symbols=$output_objdir/$libname.def
82371fb744b4Smrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
82381fb744b4Smrg	fi
8239c35d236eSmrg
82401fb744b4Smrg	tmp_deplibs=
82411fb744b4Smrg	for test_deplib in $deplibs; do
82421fb744b4Smrg	  case " $convenience " in
82431fb744b4Smrg	  *" $test_deplib "*) ;;
82441fb744b4Smrg	  *)
82451fb744b4Smrg	    func_append tmp_deplibs " $test_deplib"
82461fb744b4Smrg	    ;;
82471fb744b4Smrg	  esac
82481fb744b4Smrg	done
82491fb744b4Smrg	deplibs="$tmp_deplibs"
8250518bcf38Smrg
82511fb744b4Smrg	if test -n "$convenience"; then
82521fb744b4Smrg	  if test -n "$whole_archive_flag_spec" &&
82531fb744b4Smrg	    test "$compiler_needs_object" = yes &&
82541fb744b4Smrg	    test -z "$libobjs"; then
82551fb744b4Smrg	    # extract the archives, so we have objects to list.
82561fb744b4Smrg	    # TODO: could optimize this to just extract one archive.
82571fb744b4Smrg	    whole_archive_flag_spec=
82581fb744b4Smrg	  fi
82591fb744b4Smrg	  if test -n "$whole_archive_flag_spec"; then
82601fb744b4Smrg	    save_libobjs=$libobjs
82611fb744b4Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
82621fb744b4Smrg	    test "X$libobjs" = "X " && libobjs=
8263f55e6a01Smrg	  else
82641fb744b4Smrg	    gentop="$output_objdir/${outputname}x"
82651fb744b4Smrg	    func_append generated " $gentop"
82661fb744b4Smrg
82671fb744b4Smrg	    func_extract_archives $gentop $convenience
82681fb744b4Smrg	    func_append libobjs " $func_extract_archives_result"
82691fb744b4Smrg	    test "X$libobjs" = "X " && libobjs=
8270f55e6a01Smrg	  fi
8271f55e6a01Smrg	fi
8272c35d236eSmrg
82731fb744b4Smrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
82741fb744b4Smrg	  eval flag=\"$thread_safe_flag_spec\"
82751fb744b4Smrg	  func_append linker_flags " $flag"
82761fb744b4Smrg	fi
8277c35d236eSmrg
82781fb744b4Smrg	# Make a backup of the uninstalled library when relinking
82791fb744b4Smrg	if test "$opt_mode" = relink; then
82801fb744b4Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
82811fb744b4Smrg	fi
8282f55e6a01Smrg
82831fb744b4Smrg	# Do each of the archive commands.
82841fb744b4Smrg	if test "$module" = yes && test -n "$module_cmds" ; then
82851fb744b4Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
82861fb744b4Smrg	    eval test_cmds=\"$module_expsym_cmds\"
82871fb744b4Smrg	    cmds=$module_expsym_cmds
82881fb744b4Smrg	  else
82891fb744b4Smrg	    eval test_cmds=\"$module_cmds\"
82901fb744b4Smrg	    cmds=$module_cmds
82911fb744b4Smrg	  fi
8292518bcf38Smrg	else
82931fb744b4Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
82941fb744b4Smrg	    eval test_cmds=\"$archive_expsym_cmds\"
82951fb744b4Smrg	    cmds=$archive_expsym_cmds
82961fb744b4Smrg	  else
82971fb744b4Smrg	    eval test_cmds=\"$archive_cmds\"
82981fb744b4Smrg	    cmds=$archive_cmds
82991fb744b4Smrg	  fi
8300f55e6a01Smrg	fi
8301c35d236eSmrg
83021fb744b4Smrg	if test "X$skipped_export" != "X:" &&
83031fb744b4Smrg	   func_len " $test_cmds" &&
83041fb744b4Smrg	   len=$func_len_result &&
83051fb744b4Smrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
83061fb744b4Smrg	  :
83071fb744b4Smrg	else
83081fb744b4Smrg	  # The command line is too long to link in one step, link piecewise
83091fb744b4Smrg	  # or, if using GNU ld and skipped_export is not :, use a linker
83101fb744b4Smrg	  # script.
8311c35d236eSmrg
83121fb744b4Smrg	  # Save the value of $output and $libobjs because we want to
83131fb744b4Smrg	  # use them later.  If we have whole_archive_flag_spec, we
83141fb744b4Smrg	  # want to use save_libobjs as it was before
83151fb744b4Smrg	  # whole_archive_flag_spec was expanded, because we can't
83161fb744b4Smrg	  # assume the linker understands whole_archive_flag_spec.
83171fb744b4Smrg	  # This may have to be revisited, in case too many
83181fb744b4Smrg	  # convenience libraries get linked in and end up exceeding
83191fb744b4Smrg	  # the spec.
83201fb744b4Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
83211fb744b4Smrg	    save_libobjs=$libobjs
83221fb744b4Smrg	  fi
83231fb744b4Smrg	  save_output=$output
83241fb744b4Smrg	  func_basename "$output"
83251fb744b4Smrg	  output_la=$func_basename_result
83261fb744b4Smrg
83271fb744b4Smrg	  # Clear the reloadable object creation command queue and
83281fb744b4Smrg	  # initialize k to one.
83291fb744b4Smrg	  test_cmds=
83301fb744b4Smrg	  concat_cmds=
83311fb744b4Smrg	  objlist=
83321fb744b4Smrg	  last_robj=
83331fb744b4Smrg	  k=1
83341fb744b4Smrg
83351fb744b4Smrg	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
83361fb744b4Smrg	    output=${output_objdir}/${output_la}.lnkscript
83371fb744b4Smrg	    func_verbose "creating GNU ld script: $output"
83381fb744b4Smrg	    echo 'INPUT (' > $output
83391fb744b4Smrg	    for obj in $save_libobjs
83401fb744b4Smrg	    do
83411fb744b4Smrg	      func_to_tool_file "$obj"
83421fb744b4Smrg	      $ECHO "$func_to_tool_file_result" >> $output
83431fb744b4Smrg	    done
83441fb744b4Smrg	    echo ')' >> $output
83451fb744b4Smrg	    func_append delfiles " $output"
83461fb744b4Smrg	    func_to_tool_file "$output"
83471fb744b4Smrg	    output=$func_to_tool_file_result
83481fb744b4Smrg	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
83491fb744b4Smrg	    output=${output_objdir}/${output_la}.lnk
83501fb744b4Smrg	    func_verbose "creating linker input file list: $output"
83511fb744b4Smrg	    : > $output
83521fb744b4Smrg	    set x $save_libobjs
83531fb744b4Smrg	    shift
83541fb744b4Smrg	    firstobj=
83551fb744b4Smrg	    if test "$compiler_needs_object" = yes; then
83561fb744b4Smrg	      firstobj="$1 "
83571fb744b4Smrg	      shift
8358518bcf38Smrg	    fi
83591fb744b4Smrg	    for obj
83601fb744b4Smrg	    do
83611fb744b4Smrg	      func_to_tool_file "$obj"
83621fb744b4Smrg	      $ECHO "$func_to_tool_file_result" >> $output
8363518bcf38Smrg	    done
83641fb744b4Smrg	    func_append delfiles " $output"
83651fb744b4Smrg	    func_to_tool_file "$output"
83661fb744b4Smrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
83671fb744b4Smrg	  else
83681fb744b4Smrg	    if test -n "$save_libobjs"; then
83691fb744b4Smrg	      func_verbose "creating reloadable object files..."
83701fb744b4Smrg	      output=$output_objdir/$output_la-${k}.$objext
83711fb744b4Smrg	      eval test_cmds=\"$reload_cmds\"
83721fb744b4Smrg	      func_len " $test_cmds"
83731fb744b4Smrg	      len0=$func_len_result
83741fb744b4Smrg	      len=$len0
83751fb744b4Smrg
83761fb744b4Smrg	      # Loop over the list of objects to be linked.
83771fb744b4Smrg	      for obj in $save_libobjs
83781fb744b4Smrg	      do
83791fb744b4Smrg		func_len " $obj"
83801fb744b4Smrg		func_arith $len + $func_len_result
83811fb744b4Smrg		len=$func_arith_result
83821fb744b4Smrg		if test "X$objlist" = X ||
83831fb744b4Smrg		   test "$len" -lt "$max_cmd_len"; then
83841fb744b4Smrg		  func_append objlist " $obj"
83851fb744b4Smrg		else
83861fb744b4Smrg		  # The command $test_cmds is almost too long, add a
83871fb744b4Smrg		  # command to the queue.
83881fb744b4Smrg		  if test "$k" -eq 1 ; then
83891fb744b4Smrg		    # The first file doesn't have a previous command to add.
83901fb744b4Smrg		    reload_objs=$objlist
83911fb744b4Smrg		    eval concat_cmds=\"$reload_cmds\"
83921fb744b4Smrg		  else
83931fb744b4Smrg		    # All subsequent reloadable object files will link in
83941fb744b4Smrg		    # the last one created.
83951fb744b4Smrg		    reload_objs="$objlist $last_robj"
83961fb744b4Smrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
83971fb744b4Smrg		  fi
83981fb744b4Smrg		  last_robj=$output_objdir/$output_la-${k}.$objext
83991fb744b4Smrg		  func_arith $k + 1
84001fb744b4Smrg		  k=$func_arith_result
84011fb744b4Smrg		  output=$output_objdir/$output_la-${k}.$objext
84021fb744b4Smrg		  objlist=" $obj"
84031fb744b4Smrg		  func_len " $last_robj"
84041fb744b4Smrg		  func_arith $len0 + $func_len_result
84051fb744b4Smrg		  len=$func_arith_result
84061fb744b4Smrg		fi
84071fb744b4Smrg	      done
84081fb744b4Smrg	      # Handle the remaining objects by creating one last
84091fb744b4Smrg	      # reloadable object file.  All subsequent reloadable object
84101fb744b4Smrg	      # files will link in the last one created.
84111fb744b4Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
84121fb744b4Smrg	      reload_objs="$objlist $last_robj"
84131fb744b4Smrg	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
84141fb744b4Smrg	      if test -n "$last_robj"; then
84151fb744b4Smrg	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
8416518bcf38Smrg	      fi
84171fb744b4Smrg	      func_append delfiles " $output"
84181fb744b4Smrg
84191fb744b4Smrg	    else
84201fb744b4Smrg	      output=
84211fb744b4Smrg	    fi
84221fb744b4Smrg
84231fb744b4Smrg	    if ${skipped_export-false}; then
84241fb744b4Smrg	      func_verbose "generating symbol list for \`$libname.la'"
84251fb744b4Smrg	      export_symbols="$output_objdir/$libname.exp"
84261fb744b4Smrg	      $opt_dry_run || $RM $export_symbols
84271fb744b4Smrg	      libobjs=$output
84281fb744b4Smrg	      # Append the command to create the export file.
84291fb744b4Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
84301fb744b4Smrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
84311fb744b4Smrg	      if test -n "$last_robj"; then
84321fb744b4Smrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
8433518bcf38Smrg	      fi
84341fb744b4Smrg	    fi
84351fb744b4Smrg
84361fb744b4Smrg	    test -n "$save_libobjs" &&
84371fb744b4Smrg	      func_verbose "creating a temporary reloadable object file: $output"
84381fb744b4Smrg
84391fb744b4Smrg	    # Loop through the commands generated above and execute them.
84401fb744b4Smrg	    save_ifs="$IFS"; IFS='~'
84411fb744b4Smrg	    for cmd in $concat_cmds; do
84421fb744b4Smrg	      IFS="$save_ifs"
84431fb744b4Smrg	      $opt_silent || {
84441fb744b4Smrg		  func_quote_for_expand "$cmd"
84451fb744b4Smrg		  eval "func_echo $func_quote_for_expand_result"
84461fb744b4Smrg	      }
84471fb744b4Smrg	      $opt_dry_run || eval "$cmd" || {
84481fb744b4Smrg		lt_exit=$?
84491fb744b4Smrg
84501fb744b4Smrg		# Restore the uninstalled library and exit
84511fb744b4Smrg		if test "$opt_mode" = relink; then
84521fb744b4Smrg		  ( cd "$output_objdir" && \
84531fb744b4Smrg		    $RM "${realname}T" && \
84541fb744b4Smrg		    $MV "${realname}U" "$realname" )
84551fb744b4Smrg		fi
84561fb744b4Smrg
84571fb744b4Smrg		exit $lt_exit
84581fb744b4Smrg	      }
8459518bcf38Smrg	    done
84601fb744b4Smrg	    IFS="$save_ifs"
84611fb744b4Smrg
84621fb744b4Smrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
84631fb744b4Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
84641fb744b4Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
84651fb744b4Smrg	    fi
84661fb744b4Smrg	  fi
84671fb744b4Smrg
84681fb744b4Smrg          if ${skipped_export-false}; then
84691fb744b4Smrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
84701fb744b4Smrg	      tmp_export_symbols="$export_symbols"
84711fb744b4Smrg	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
84721fb744b4Smrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
84731fb744b4Smrg	    fi
84741fb744b4Smrg
84751fb744b4Smrg	    if test -n "$orig_export_symbols"; then
84761fb744b4Smrg	      # The given exports_symbols file has to be filtered, so filter it.
84771fb744b4Smrg	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
84781fb744b4Smrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
84791fb744b4Smrg	      # 's' commands which not all seds can handle. GNU sed should be fine
84801fb744b4Smrg	      # though. Also, the filter scales superlinearly with the number of
84811fb744b4Smrg	      # global variables. join(1) would be nice here, but unfortunately
84821fb744b4Smrg	      # isn't a blessed tool.
84831fb744b4Smrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
84841fb744b4Smrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
84851fb744b4Smrg	      export_symbols=$output_objdir/$libname.def
84861fb744b4Smrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
84871fb744b4Smrg	    fi
84881fb744b4Smrg	  fi
84891fb744b4Smrg
84901fb744b4Smrg	  libobjs=$output
84911fb744b4Smrg	  # Restore the value of output.
84921fb744b4Smrg	  output=$save_output
84931fb744b4Smrg
84941fb744b4Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
84951fb744b4Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
84961fb744b4Smrg	    test "X$libobjs" = "X " && libobjs=
84971fb744b4Smrg	  fi
84981fb744b4Smrg	  # Expand the library linking commands again to reset the
84991fb744b4Smrg	  # value of $libobjs for piecewise linking.
85001fb744b4Smrg
85011fb744b4Smrg	  # Do each of the archive commands.
85021fb744b4Smrg	  if test "$module" = yes && test -n "$module_cmds" ; then
85031fb744b4Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
85041fb744b4Smrg	      cmds=$module_expsym_cmds
85051fb744b4Smrg	    else
85061fb744b4Smrg	      cmds=$module_cmds
85071fb744b4Smrg	    fi
8508518bcf38Smrg	  else
85091fb744b4Smrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
85101fb744b4Smrg	      cmds=$archive_expsym_cmds
85111fb744b4Smrg	    else
85121fb744b4Smrg	      cmds=$archive_cmds
85131fb744b4Smrg	    fi
8514518bcf38Smrg	  fi
85151fb744b4Smrg	fi
8516c35d236eSmrg
85171fb744b4Smrg	if test -n "$delfiles"; then
85181fb744b4Smrg	  # Append the command to remove temporary files to $cmds.
85191fb744b4Smrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
85201fb744b4Smrg	fi
8521c35d236eSmrg
85221fb744b4Smrg	# Add any objects from preloaded convenience libraries
85231fb744b4Smrg	if test -n "$dlprefiles"; then
85241fb744b4Smrg	  gentop="$output_objdir/${outputname}x"
85251fb744b4Smrg	  func_append generated " $gentop"
8526c35d236eSmrg
85271fb744b4Smrg	  func_extract_archives $gentop $dlprefiles
85281fb744b4Smrg	  func_append libobjs " $func_extract_archives_result"
85291fb744b4Smrg	  test "X$libobjs" = "X " && libobjs=
85301fb744b4Smrg	fi
8531c35d236eSmrg
85321fb744b4Smrg	save_ifs="$IFS"; IFS='~'
85331fb744b4Smrg	for cmd in $cmds; do
85341fb744b4Smrg	  IFS="$save_ifs"
85351fb744b4Smrg	  eval cmd=\"$cmd\"
85361fb744b4Smrg	  $opt_silent || {
85371fb744b4Smrg	    func_quote_for_expand "$cmd"
85381fb744b4Smrg	    eval "func_echo $func_quote_for_expand_result"
85391fb744b4Smrg	  }
85401fb744b4Smrg	  $opt_dry_run || eval "$cmd" || {
85411fb744b4Smrg	    lt_exit=$?
8542f55e6a01Smrg
85431fb744b4Smrg	    # Restore the uninstalled library and exit
85441fb744b4Smrg	    if test "$opt_mode" = relink; then
85451fb744b4Smrg	      ( cd "$output_objdir" && \
85461fb744b4Smrg	        $RM "${realname}T" && \
85471fb744b4Smrg		$MV "${realname}U" "$realname" )
85481fb744b4Smrg	    fi
8549f55e6a01Smrg
85501fb744b4Smrg	    exit $lt_exit
85511fb744b4Smrg	  }
85521fb744b4Smrg	done
85531fb744b4Smrg	IFS="$save_ifs"
8554f55e6a01Smrg
85551fb744b4Smrg	# Restore the uninstalled library and exit
85561fb744b4Smrg	if test "$opt_mode" = relink; then
85571fb744b4Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
8558f55e6a01Smrg
85591fb744b4Smrg	  if test -n "$convenience"; then
85601fb744b4Smrg	    if test -z "$whole_archive_flag_spec"; then
85611fb744b4Smrg	      func_show_eval '${RM}r "$gentop"'
85621fb744b4Smrg	    fi
85631fb744b4Smrg	  fi
8564f55e6a01Smrg
85651fb744b4Smrg	  exit $EXIT_SUCCESS
85661fb744b4Smrg	fi
85671fb744b4Smrg
85681fb744b4Smrg	# Create links to the real library.
85691fb744b4Smrg	for linkname in $linknames; do
85701fb744b4Smrg	  if test "$realname" != "$linkname"; then
85711fb744b4Smrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
8572518bcf38Smrg	  fi
8573518bcf38Smrg	done
8574f55e6a01Smrg
85751fb744b4Smrg	# If -module or -export-dynamic was specified, set the dlname.
85761fb744b4Smrg	if test "$module" = yes || test "$export_dynamic" = yes; then
85771fb744b4Smrg	  # On all known operating systems, these are identical.
85781fb744b4Smrg	  dlname="$soname"
85791fb744b4Smrg	fi
85801fb744b4Smrg      fi
8581c35d236eSmrg      ;;
8582c35d236eSmrg
85831fb744b4Smrg    obj)
85841fb744b4Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
85851fb744b4Smrg	func_warning "\`-dlopen' is ignored for objects"
85861fb744b4Smrg      fi
8587518bcf38Smrg
85881fb744b4Smrg      case " $deplibs" in
85891fb744b4Smrg      *\ -l* | *\ -L*)
85901fb744b4Smrg	func_warning "\`-l' and \`-L' are ignored for objects" ;;
8591f55e6a01Smrg      esac
8592c35d236eSmrg
85931fb744b4Smrg      test -n "$rpath" && \
85941fb744b4Smrg	func_warning "\`-rpath' is ignored for objects"
8595c35d236eSmrg
85961fb744b4Smrg      test -n "$xrpath" && \
85971fb744b4Smrg	func_warning "\`-R' is ignored for objects"
8598f55e6a01Smrg
85991fb744b4Smrg      test -n "$vinfo" && \
86001fb744b4Smrg	func_warning "\`-version-info' is ignored for objects"
86011fb744b4Smrg
86021fb744b4Smrg      test -n "$release" && \
86031fb744b4Smrg	func_warning "\`-release' is ignored for objects"
86041fb744b4Smrg
86051fb744b4Smrg      case $output in
86061fb744b4Smrg      *.lo)
86071fb744b4Smrg	test -n "$objs$old_deplibs" && \
86081fb744b4Smrg	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
86091fb744b4Smrg
86101fb744b4Smrg	libobj=$output
86111fb744b4Smrg	func_lo2o "$libobj"
86121fb744b4Smrg	obj=$func_lo2o_result
8613518bcf38Smrg	;;
8614518bcf38Smrg      *)
86151fb744b4Smrg	libobj=
86161fb744b4Smrg	obj="$output"
8617c35d236eSmrg	;;
8618f55e6a01Smrg      esac
8619c35d236eSmrg
86201fb744b4Smrg      # Delete the old objects.
86211fb744b4Smrg      $opt_dry_run || $RM $obj $libobj
8622c35d236eSmrg
86231fb744b4Smrg      # Objects from convenience libraries.  This assumes
86241fb744b4Smrg      # single-version convenience libraries.  Whenever we create
86251fb744b4Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
86261fb744b4Smrg      # the extraction.
86271fb744b4Smrg      reload_conv_objs=
86281fb744b4Smrg      gentop=
86291fb744b4Smrg      # reload_cmds runs $LD directly, so let us get rid of
86301fb744b4Smrg      # -Wl from whole_archive_flag_spec and hope we can get by with
86311fb744b4Smrg      # turning comma into space..
86321fb744b4Smrg      wl=
8633c35d236eSmrg
86341fb744b4Smrg      if test -n "$convenience"; then
86351fb744b4Smrg	if test -n "$whole_archive_flag_spec"; then
86361fb744b4Smrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
86371fb744b4Smrg	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
86381fb744b4Smrg	else
86391fb744b4Smrg	  gentop="$output_objdir/${obj}x"
86401fb744b4Smrg	  func_append generated " $gentop"
8641518bcf38Smrg
86421fb744b4Smrg	  func_extract_archives $gentop $convenience
86431fb744b4Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
86441fb744b4Smrg	fi
8645518bcf38Smrg      fi
8646518bcf38Smrg
86471fb744b4Smrg      # If we're not building shared, we need to use non_pic_objs
86481fb744b4Smrg      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
8649518bcf38Smrg
86501fb744b4Smrg      # Create the old-style object.
86511fb744b4Smrg      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
8652518bcf38Smrg
86531fb744b4Smrg      output="$obj"
86541fb744b4Smrg      func_execute_cmds "$reload_cmds" 'exit $?'
86551fb744b4Smrg
86561fb744b4Smrg      # Exit if we aren't doing a library object file.
86571fb744b4Smrg      if test -z "$libobj"; then
86581fb744b4Smrg	if test -n "$gentop"; then
86591fb744b4Smrg	  func_show_eval '${RM}r "$gentop"'
86601fb744b4Smrg	fi
86611fb744b4Smrg
86621fb744b4Smrg	exit $EXIT_SUCCESS
8663518bcf38Smrg      fi
86641fb744b4Smrg
86651fb744b4Smrg      if test "$build_libtool_libs" != yes; then
86661fb744b4Smrg	if test -n "$gentop"; then
86671fb744b4Smrg	  func_show_eval '${RM}r "$gentop"'
86681fb744b4Smrg	fi
86691fb744b4Smrg
86701fb744b4Smrg	# Create an invalid libtool object if no PIC, so that we don't
86711fb744b4Smrg	# accidentally link it into a program.
86721fb744b4Smrg	# $show "echo timestamp > $libobj"
86731fb744b4Smrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
86741fb744b4Smrg	exit $EXIT_SUCCESS
86751fb744b4Smrg      fi
86761fb744b4Smrg
86771fb744b4Smrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
86781fb744b4Smrg	# Only do commands if we really have different PIC objects.
86791fb744b4Smrg	reload_objs="$libobjs $reload_conv_objs"
86801fb744b4Smrg	output="$libobj"
86811fb744b4Smrg	func_execute_cmds "$reload_cmds" 'exit $?'
86821fb744b4Smrg      fi
86831fb744b4Smrg
86841fb744b4Smrg      if test -n "$gentop"; then
86851fb744b4Smrg	func_show_eval '${RM}r "$gentop"'
86861fb744b4Smrg      fi
86871fb744b4Smrg
86881fb744b4Smrg      exit $EXIT_SUCCESS
8689518bcf38Smrg      ;;
8690c35d236eSmrg
86911fb744b4Smrg    prog)
86921fb744b4Smrg      case $host in
86931fb744b4Smrg	*cygwin*) func_stripname '' '.exe' "$output"
86941fb744b4Smrg	          output=$func_stripname_result.exe;;
86951fb744b4Smrg      esac
86961fb744b4Smrg      test -n "$vinfo" && \
86971fb744b4Smrg	func_warning "\`-version-info' is ignored for programs"
8698c35d236eSmrg
86991fb744b4Smrg      test -n "$release" && \
87001fb744b4Smrg	func_warning "\`-release' is ignored for programs"
8701c35d236eSmrg
87021fb744b4Smrg      test "$preload" = yes \
87031fb744b4Smrg        && test "$dlopen_support" = unknown \
87041fb744b4Smrg	&& test "$dlopen_self" = unknown \
87051fb744b4Smrg	&& test "$dlopen_self_static" = unknown && \
87061fb744b4Smrg	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
87071fb744b4Smrg
87081fb744b4Smrg      case $host in
87091fb744b4Smrg      *-*-rhapsody* | *-*-darwin1.[012])
87101fb744b4Smrg	# On Rhapsody replace the C library is the System framework
87111fb744b4Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
87121fb744b4Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
8713518bcf38Smrg	;;
87141fb744b4Smrg      esac
8715518bcf38Smrg
87161fb744b4Smrg      case $host in
87171fb744b4Smrg      *-*-darwin*)
87181fb744b4Smrg	# Don't allow lazy linking, it breaks C++ global constructors
87191fb744b4Smrg	# But is supposedly fixed on 10.4 or later (yay!).
87201fb744b4Smrg	if test "$tagname" = CXX ; then
87211fb744b4Smrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
87221fb744b4Smrg	    10.[0123])
87231fb744b4Smrg	      func_append compile_command " ${wl}-bind_at_load"
87241fb744b4Smrg	      func_append finalize_command " ${wl}-bind_at_load"
87251fb744b4Smrg	    ;;
87261fb744b4Smrg	  esac
8727518bcf38Smrg	fi
87281fb744b4Smrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
87291fb744b4Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
87301fb744b4Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
87311fb744b4Smrg	;;
87321fb744b4Smrg      esac
8733518bcf38Smrg
8734518bcf38Smrg
87351fb744b4Smrg      # move library search paths that coincide with paths to not yet
87361fb744b4Smrg      # installed libraries to the beginning of the library search list
87371fb744b4Smrg      new_libs=
87381fb744b4Smrg      for path in $notinst_path; do
87391fb744b4Smrg	case " $new_libs " in
87401fb744b4Smrg	*" -L$path/$objdir "*) ;;
87411fb744b4Smrg	*)
87421fb744b4Smrg	  case " $compile_deplibs " in
87431fb744b4Smrg	  *" -L$path/$objdir "*)
87441fb744b4Smrg	    func_append new_libs " -L$path/$objdir" ;;
8745f55e6a01Smrg	  esac
87461fb744b4Smrg	  ;;
87471fb744b4Smrg	esac
87481fb744b4Smrg      done
87491fb744b4Smrg      for deplib in $compile_deplibs; do
87501fb744b4Smrg	case $deplib in
87511fb744b4Smrg	-L*)
87521fb744b4Smrg	  case " $new_libs " in
87531fb744b4Smrg	  *" $deplib "*) ;;
87541fb744b4Smrg	  *) func_append new_libs " $deplib" ;;
8755f55e6a01Smrg	  esac
87561fb744b4Smrg	  ;;
87571fb744b4Smrg	*) func_append new_libs " $deplib" ;;
87581fb744b4Smrg	esac
87591fb744b4Smrg      done
87601fb744b4Smrg      compile_deplibs="$new_libs"
8761c35d236eSmrg
8762518bcf38Smrg
87631fb744b4Smrg      func_append compile_command " $compile_deplibs"
87641fb744b4Smrg      func_append finalize_command " $finalize_deplibs"
8765518bcf38Smrg
87661fb744b4Smrg      if test -n "$rpath$xrpath"; then
87671fb744b4Smrg	# If the user specified any rpath flags, then add them.
87681fb744b4Smrg	for libdir in $rpath $xrpath; do
87691fb744b4Smrg	  # This is the magic to use -rpath.
87701fb744b4Smrg	  case "$finalize_rpath " in
87711fb744b4Smrg	  *" $libdir "*) ;;
87721fb744b4Smrg	  *) func_append finalize_rpath " $libdir" ;;
87731fb744b4Smrg	  esac
87741fb744b4Smrg	done
87751fb744b4Smrg      fi
8776518bcf38Smrg
87771fb744b4Smrg      # Now hardcode the library paths
87781fb744b4Smrg      rpath=
87791fb744b4Smrg      hardcode_libdirs=
87801fb744b4Smrg      for libdir in $compile_rpath $finalize_rpath; do
87811fb744b4Smrg	if test -n "$hardcode_libdir_flag_spec"; then
87821fb744b4Smrg	  if test -n "$hardcode_libdir_separator"; then
87831fb744b4Smrg	    if test -z "$hardcode_libdirs"; then
87841fb744b4Smrg	      hardcode_libdirs="$libdir"
87851fb744b4Smrg	    else
87861fb744b4Smrg	      # Just accumulate the unique libdirs.
87871fb744b4Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
87881fb744b4Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
87891fb744b4Smrg		;;
87901fb744b4Smrg	      *)
87911fb744b4Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
87921fb744b4Smrg		;;
87931fb744b4Smrg	      esac
87941fb744b4Smrg	    fi
8795518bcf38Smrg	  else
87961fb744b4Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
87971fb744b4Smrg	    func_append rpath " $flag"
8798518bcf38Smrg	  fi
87991fb744b4Smrg	elif test -n "$runpath_var"; then
88001fb744b4Smrg	  case "$perm_rpath " in
88011fb744b4Smrg	  *" $libdir "*) ;;
88021fb744b4Smrg	  *) func_append perm_rpath " $libdir" ;;
88031fb744b4Smrg	  esac
88041fb744b4Smrg	fi
88051fb744b4Smrg	case $host in
88061fb744b4Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
88071fb744b4Smrg	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
88081fb744b4Smrg	  case :$dllsearchpath: in
88091fb744b4Smrg	  *":$libdir:"*) ;;
88101fb744b4Smrg	  ::) dllsearchpath=$libdir;;
88111fb744b4Smrg	  *) func_append dllsearchpath ":$libdir";;
88121fb744b4Smrg	  esac
88131fb744b4Smrg	  case :$dllsearchpath: in
88141fb744b4Smrg	  *":$testbindir:"*) ;;
88151fb744b4Smrg	  ::) dllsearchpath=$testbindir;;
88161fb744b4Smrg	  *) func_append dllsearchpath ":$testbindir";;
88171fb744b4Smrg	  esac
88181fb744b4Smrg	  ;;
88191fb744b4Smrg	esac
88201fb744b4Smrg      done
88211fb744b4Smrg      # Substitute the hardcoded libdirs into the rpath.
88221fb744b4Smrg      if test -n "$hardcode_libdir_separator" &&
88231fb744b4Smrg	 test -n "$hardcode_libdirs"; then
88241fb744b4Smrg	libdir="$hardcode_libdirs"
88251fb744b4Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
88261fb744b4Smrg      fi
88271fb744b4Smrg      compile_rpath="$rpath"
8828518bcf38Smrg
88291fb744b4Smrg      rpath=
88301fb744b4Smrg      hardcode_libdirs=
88311fb744b4Smrg      for libdir in $finalize_rpath; do
88321fb744b4Smrg	if test -n "$hardcode_libdir_flag_spec"; then
88331fb744b4Smrg	  if test -n "$hardcode_libdir_separator"; then
88341fb744b4Smrg	    if test -z "$hardcode_libdirs"; then
88351fb744b4Smrg	      hardcode_libdirs="$libdir"
88361fb744b4Smrg	    else
88371fb744b4Smrg	      # Just accumulate the unique libdirs.
88381fb744b4Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
88391fb744b4Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
88401fb744b4Smrg		;;
88411fb744b4Smrg	      *)
88421fb744b4Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
88431fb744b4Smrg		;;
88441fb744b4Smrg	      esac
88451fb744b4Smrg	    fi
8846c35d236eSmrg	  else
88471fb744b4Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
88481fb744b4Smrg	    func_append rpath " $flag"
8849c35d236eSmrg	  fi
88501fb744b4Smrg	elif test -n "$runpath_var"; then
88511fb744b4Smrg	  case "$finalize_perm_rpath " in
88521fb744b4Smrg	  *" $libdir "*) ;;
88531fb744b4Smrg	  *) func_append finalize_perm_rpath " $libdir" ;;
88541fb744b4Smrg	  esac
8855c35d236eSmrg	fi
88561fb744b4Smrg      done
88571fb744b4Smrg      # Substitute the hardcoded libdirs into the rpath.
88581fb744b4Smrg      if test -n "$hardcode_libdir_separator" &&
88591fb744b4Smrg	 test -n "$hardcode_libdirs"; then
88601fb744b4Smrg	libdir="$hardcode_libdirs"
88611fb744b4Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
88621fb744b4Smrg      fi
88631fb744b4Smrg      finalize_rpath="$rpath"
8864c35d236eSmrg
88651fb744b4Smrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
88661fb744b4Smrg	# Transform all the library objects into standard objects.
88671fb744b4Smrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
88681fb744b4Smrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
88691fb744b4Smrg      fi
8870c35d236eSmrg
88711fb744b4Smrg      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
8872c35d236eSmrg
88731fb744b4Smrg      # template prelinking step
88741fb744b4Smrg      if test -n "$prelink_cmds"; then
88751fb744b4Smrg	func_execute_cmds "$prelink_cmds" 'exit $?'
88761fb744b4Smrg      fi
8877c35d236eSmrg
88781fb744b4Smrg      wrappers_required=yes
88791fb744b4Smrg      case $host in
88801fb744b4Smrg      *cegcc* | *mingw32ce*)
88811fb744b4Smrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
88821fb744b4Smrg        wrappers_required=no
88831fb744b4Smrg        ;;
88841fb744b4Smrg      *cygwin* | *mingw* )
88851fb744b4Smrg        if test "$build_libtool_libs" != yes; then
88861fb744b4Smrg          wrappers_required=no
88871fb744b4Smrg        fi
88881fb744b4Smrg        ;;
88891fb744b4Smrg      *)
88901fb744b4Smrg        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
88911fb744b4Smrg          wrappers_required=no
88921fb744b4Smrg        fi
88931fb744b4Smrg        ;;
88941fb744b4Smrg      esac
88951fb744b4Smrg      if test "$wrappers_required" = no; then
88961fb744b4Smrg	# Replace the output file specification.
88971fb744b4Smrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
88981fb744b4Smrg	link_command="$compile_command$compile_rpath"
8899c35d236eSmrg
89001fb744b4Smrg	# We have no uninstalled library dependencies, so finalize right now.
89011fb744b4Smrg	exit_status=0
89021fb744b4Smrg	func_show_eval "$link_command" 'exit_status=$?'
8903c35d236eSmrg
89041fb744b4Smrg	if test -n "$postlink_cmds"; then
89051fb744b4Smrg	  func_to_tool_file "$output"
89061fb744b4Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
89071fb744b4Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
8908c35d236eSmrg	fi
8909c35d236eSmrg
89101fb744b4Smrg	# Delete the generated files.
89111fb744b4Smrg	if test -f "$output_objdir/${outputname}S.${objext}"; then
89121fb744b4Smrg	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
89131fb744b4Smrg	fi
8914c35d236eSmrg
89151fb744b4Smrg	exit $exit_status
89161fb744b4Smrg      fi
8917c35d236eSmrg
89181fb744b4Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
89191fb744b4Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
89201fb744b4Smrg      fi
89211fb744b4Smrg      if test -n "$finalize_shlibpath"; then
89221fb744b4Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
89231fb744b4Smrg      fi
8924518bcf38Smrg
89251fb744b4Smrg      compile_var=
89261fb744b4Smrg      finalize_var=
89271fb744b4Smrg      if test -n "$runpath_var"; then
89281fb744b4Smrg	if test -n "$perm_rpath"; then
89291fb744b4Smrg	  # We should set the runpath_var.
89301fb744b4Smrg	  rpath=
89311fb744b4Smrg	  for dir in $perm_rpath; do
89321fb744b4Smrg	    func_append rpath "$dir:"
89331fb744b4Smrg	  done
89341fb744b4Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
8935c35d236eSmrg	fi
89361fb744b4Smrg	if test -n "$finalize_perm_rpath"; then
89371fb744b4Smrg	  # We should set the runpath_var.
89381fb744b4Smrg	  rpath=
89391fb744b4Smrg	  for dir in $finalize_perm_rpath; do
89401fb744b4Smrg	    func_append rpath "$dir:"
89411fb744b4Smrg	  done
89421fb744b4Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
8943c35d236eSmrg	fi
89441fb744b4Smrg      fi
8945c35d236eSmrg
89461fb744b4Smrg      if test "$no_install" = yes; then
89471fb744b4Smrg	# We don't need to create a wrapper script.
89481fb744b4Smrg	link_command="$compile_var$compile_command$compile_rpath"
89491fb744b4Smrg	# Replace the output file specification.
89501fb744b4Smrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
89511fb744b4Smrg	# Delete the old output file.
89521fb744b4Smrg	$opt_dry_run || $RM $output
89531fb744b4Smrg	# Link the executable and exit
89541fb744b4Smrg	func_show_eval "$link_command" 'exit $?'
8955c35d236eSmrg
89561fb744b4Smrg	if test -n "$postlink_cmds"; then
89571fb744b4Smrg	  func_to_tool_file "$output"
89581fb744b4Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
89591fb744b4Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
8960518bcf38Smrg	fi
89611fb744b4Smrg
8962518bcf38Smrg	exit $EXIT_SUCCESS
89631fb744b4Smrg      fi
8964f55e6a01Smrg
89651fb744b4Smrg      if test "$hardcode_action" = relink; then
89661fb744b4Smrg	# Fast installation is not supported
89671fb744b4Smrg	link_command="$compile_var$compile_command$compile_rpath"
89681fb744b4Smrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
89691fb744b4Smrg
89701fb744b4Smrg	func_warning "this platform does not like uninstalled shared libraries"
89711fb744b4Smrg	func_warning "\`$output' will be relinked during installation"
89721fb744b4Smrg      else
89731fb744b4Smrg	if test "$fast_install" != no; then
89741fb744b4Smrg	  link_command="$finalize_var$compile_command$finalize_rpath"
89751fb744b4Smrg	  if test "$fast_install" = yes; then
89761fb744b4Smrg	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
89771fb744b4Smrg	  else
89781fb744b4Smrg	    # fast_install is set to needless
89791fb744b4Smrg	    relink_command=
89801fb744b4Smrg	  fi
8981c35d236eSmrg	else
89821fb744b4Smrg	  link_command="$compile_var$compile_command$compile_rpath"
89831fb744b4Smrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
8984c35d236eSmrg	fi
89851fb744b4Smrg      fi
8986c35d236eSmrg
89871fb744b4Smrg      # Replace the output file specification.
89881fb744b4Smrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
8989c35d236eSmrg
89901fb744b4Smrg      # Delete the old output files.
89911fb744b4Smrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
8992c35d236eSmrg
89931fb744b4Smrg      func_show_eval "$link_command" 'exit $?'
8994c35d236eSmrg
89951fb744b4Smrg      if test -n "$postlink_cmds"; then
89961fb744b4Smrg	func_to_tool_file "$output_objdir/$outputname"
89971fb744b4Smrg	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'`
89981fb744b4Smrg	func_execute_cmds "$postlink_cmds" 'exit $?'
89991fb744b4Smrg      fi
9000518bcf38Smrg
90011fb744b4Smrg      # Now create the wrapper script.
90021fb744b4Smrg      func_verbose "creating $output"
9003518bcf38Smrg
90041fb744b4Smrg      # Quote the relink command for shipping.
90051fb744b4Smrg      if test -n "$relink_command"; then
90061fb744b4Smrg	# Preserve any variables that may affect compiler behavior
90071fb744b4Smrg	for var in $variables_saved_for_relink; do
90081fb744b4Smrg	  if eval test -z \"\${$var+set}\"; then
90091fb744b4Smrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
90101fb744b4Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
90111fb744b4Smrg	    relink_command="$var=; export $var; $relink_command"
9012c35d236eSmrg	  else
90131fb744b4Smrg	    func_quote_for_eval "$var_value"
90141fb744b4Smrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9015c35d236eSmrg	  fi
90161fb744b4Smrg	done
90171fb744b4Smrg	relink_command="(cd `pwd`; $relink_command)"
90181fb744b4Smrg	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
90191fb744b4Smrg      fi
90201fb744b4Smrg
90211fb744b4Smrg      # Only actually do things if not in dry run mode.
90221fb744b4Smrg      $opt_dry_run || {
90231fb744b4Smrg	# win32 will think the script is a binary if it has
90241fb744b4Smrg	# a .exe suffix, so we strip it off here.
90251fb744b4Smrg	case $output in
90261fb744b4Smrg	  *.exe) func_stripname '' '.exe' "$output"
90271fb744b4Smrg	         output=$func_stripname_result ;;
9028f55e6a01Smrg	esac
90291fb744b4Smrg	# test for cygwin because mv fails w/o .exe extensions
90301fb744b4Smrg	case $host in
90311fb744b4Smrg	  *cygwin*)
90321fb744b4Smrg	    exeext=.exe
90331fb744b4Smrg	    func_stripname '' '.exe' "$outputname"
90341fb744b4Smrg	    outputname=$func_stripname_result ;;
90351fb744b4Smrg	  *) exeext= ;;
90361fb744b4Smrg	esac
90371fb744b4Smrg	case $host in
90381fb744b4Smrg	  *cygwin* | *mingw* )
90391fb744b4Smrg	    func_dirname_and_basename "$output" "" "."
90401fb744b4Smrg	    output_name=$func_basename_result
90411fb744b4Smrg	    output_path=$func_dirname_result
90421fb744b4Smrg	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
90431fb744b4Smrg	    cwrapper="$output_path/$output_name.exe"
90441fb744b4Smrg	    $RM $cwrappersource $cwrapper
90451fb744b4Smrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
90461fb744b4Smrg
90471fb744b4Smrg	    func_emit_cwrapperexe_src > $cwrappersource
90481fb744b4Smrg
90491fb744b4Smrg	    # The wrapper executable is built using the $host compiler,
90501fb744b4Smrg	    # because it contains $host paths and files. If cross-
90511fb744b4Smrg	    # compiling, it, like the target executable, must be
90521fb744b4Smrg	    # executed on the $host or under an emulation environment.
90531fb744b4Smrg	    $opt_dry_run || {
90541fb744b4Smrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
90551fb744b4Smrg	      $STRIP $cwrapper
90561fb744b4Smrg	    }
9057c35d236eSmrg
90581fb744b4Smrg	    # Now, create the wrapper script for func_source use:
90591fb744b4Smrg	    func_ltwrapper_scriptname $cwrapper
90601fb744b4Smrg	    $RM $func_ltwrapper_scriptname_result
90611fb744b4Smrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
90621fb744b4Smrg	    $opt_dry_run || {
90631fb744b4Smrg	      # note: this script will not be executed, so do not chmod.
90641fb744b4Smrg	      if test "x$build" = "x$host" ; then
90651fb744b4Smrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
90661fb744b4Smrg	      else
90671fb744b4Smrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
90681fb744b4Smrg	      fi
90691fb744b4Smrg	    }
90701fb744b4Smrg	  ;;
90711fb744b4Smrg	  * )
90721fb744b4Smrg	    $RM $output
90731fb744b4Smrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
9074c35d236eSmrg
90751fb744b4Smrg	    func_emit_wrapper no > $output
90761fb744b4Smrg	    chmod +x $output
90771fb744b4Smrg	  ;;
90781fb744b4Smrg	esac
90791fb744b4Smrg      }
90801fb744b4Smrg      exit $EXIT_SUCCESS
90811fb744b4Smrg      ;;
90821fb744b4Smrg    esac
9083c35d236eSmrg
90841fb744b4Smrg    # See if we need to build an old-fashioned archive.
90851fb744b4Smrg    for oldlib in $oldlibs; do
9086c35d236eSmrg
90871fb744b4Smrg      if test "$build_libtool_libs" = convenience; then
90881fb744b4Smrg	oldobjs="$libobjs_save $symfileobj"
90891fb744b4Smrg	addlibs="$convenience"
90901fb744b4Smrg	build_libtool_libs=no
90911fb744b4Smrg      else
90921fb744b4Smrg	if test "$build_libtool_libs" = module; then
90931fb744b4Smrg	  oldobjs="$libobjs_save"
90941fb744b4Smrg	  build_libtool_libs=no
90951fb744b4Smrg	else
90961fb744b4Smrg	  oldobjs="$old_deplibs $non_pic_objects"
90971fb744b4Smrg	  if test "$preload" = yes && test -f "$symfileobj"; then
90981fb744b4Smrg	    func_append oldobjs " $symfileobj"
90991fb744b4Smrg	  fi
91001fb744b4Smrg	fi
91011fb744b4Smrg	addlibs="$old_convenience"
9102c35d236eSmrg      fi
9103c35d236eSmrg
91041fb744b4Smrg      if test -n "$addlibs"; then
91051fb744b4Smrg	gentop="$output_objdir/${outputname}x"
91061fb744b4Smrg	func_append generated " $gentop"
9107c35d236eSmrg
91081fb744b4Smrg	func_extract_archives $gentop $addlibs
91091fb744b4Smrg	func_append oldobjs " $func_extract_archives_result"
91101fb744b4Smrg      fi
9111c35d236eSmrg
91121fb744b4Smrg      # Do each command in the archive commands.
91131fb744b4Smrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
91141fb744b4Smrg	cmds=$old_archive_from_new_cmds
91151fb744b4Smrg      else
9116c35d236eSmrg
91171fb744b4Smrg	# Add any objects from preloaded convenience libraries
91181fb744b4Smrg	if test -n "$dlprefiles"; then
91191fb744b4Smrg	  gentop="$output_objdir/${outputname}x"
91201fb744b4Smrg	  func_append generated " $gentop"
9121c35d236eSmrg
91221fb744b4Smrg	  func_extract_archives $gentop $dlprefiles
91231fb744b4Smrg	  func_append oldobjs " $func_extract_archives_result"
91241fb744b4Smrg	fi
9125c35d236eSmrg
91261fb744b4Smrg	# POSIX demands no paths to be encoded in archives.  We have
91271fb744b4Smrg	# to avoid creating archives with duplicate basenames if we
91281fb744b4Smrg	# might have to extract them afterwards, e.g., when creating a
91291fb744b4Smrg	# static archive out of a convenience library, or when linking
91301fb744b4Smrg	# the entirety of a libtool archive into another (currently
91311fb744b4Smrg	# not supported by libtool).
91321fb744b4Smrg	if (for obj in $oldobjs
91331fb744b4Smrg	    do
91341fb744b4Smrg	      func_basename "$obj"
91351fb744b4Smrg	      $ECHO "$func_basename_result"
91361fb744b4Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
91371fb744b4Smrg	  :
91381fb744b4Smrg	else
91391fb744b4Smrg	  echo "copying selected object files to avoid basename conflicts..."
91401fb744b4Smrg	  gentop="$output_objdir/${outputname}x"
91411fb744b4Smrg	  func_append generated " $gentop"
91421fb744b4Smrg	  func_mkdir_p "$gentop"
91431fb744b4Smrg	  save_oldobjs=$oldobjs
91441fb744b4Smrg	  oldobjs=
91451fb744b4Smrg	  counter=1
91461fb744b4Smrg	  for obj in $save_oldobjs
91471fb744b4Smrg	  do
91481fb744b4Smrg	    func_basename "$obj"
91491fb744b4Smrg	    objbase="$func_basename_result"
91501fb744b4Smrg	    case " $oldobjs " in
91511fb744b4Smrg	    " ") oldobjs=$obj ;;
91521fb744b4Smrg	    *[\ /]"$objbase "*)
91531fb744b4Smrg	      while :; do
91541fb744b4Smrg		# Make sure we don't pick an alternate name that also
91551fb744b4Smrg		# overlaps.
91561fb744b4Smrg		newobj=lt$counter-$objbase
91571fb744b4Smrg		func_arith $counter + 1
91581fb744b4Smrg		counter=$func_arith_result
91591fb744b4Smrg		case " $oldobjs " in
91601fb744b4Smrg		*[\ /]"$newobj "*) ;;
91611fb744b4Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
91621fb744b4Smrg		esac
91631fb744b4Smrg	      done
91641fb744b4Smrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
91651fb744b4Smrg	      func_append oldobjs " $gentop/$newobj"
91661fb744b4Smrg	      ;;
91671fb744b4Smrg	    *) func_append oldobjs " $obj" ;;
91681fb744b4Smrg	    esac
9169c35d236eSmrg	  done
9170f55e6a01Smrg	fi
91711fb744b4Smrg	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
91721fb744b4Smrg	tool_oldlib=$func_to_tool_file_result
91731fb744b4Smrg	eval cmds=\"$old_archive_cmds\"
9174518bcf38Smrg
91751fb744b4Smrg	func_len " $cmds"
91761fb744b4Smrg	len=$func_len_result
91771fb744b4Smrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
91781fb744b4Smrg	  cmds=$old_archive_cmds
91791fb744b4Smrg	elif test -n "$archiver_list_spec"; then
91801fb744b4Smrg	  func_verbose "using command file archive linking..."
91811fb744b4Smrg	  for obj in $oldobjs
91821fb744b4Smrg	  do
91831fb744b4Smrg	    func_to_tool_file "$obj"
91841fb744b4Smrg	    $ECHO "$func_to_tool_file_result"
91851fb744b4Smrg	  done > $output_objdir/$libname.libcmd
91861fb744b4Smrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
91871fb744b4Smrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
91881fb744b4Smrg	  cmds=$old_archive_cmds
91891fb744b4Smrg	else
91901fb744b4Smrg	  # the command line is too long to link in one step, link in parts
91911fb744b4Smrg	  func_verbose "using piecewise archive linking..."
91921fb744b4Smrg	  save_RANLIB=$RANLIB
91931fb744b4Smrg	  RANLIB=:
91941fb744b4Smrg	  objlist=
91951fb744b4Smrg	  concat_cmds=
91961fb744b4Smrg	  save_oldobjs=$oldobjs
91971fb744b4Smrg	  oldobjs=
91981fb744b4Smrg	  # Is there a better way of finding the last object in the list?
91991fb744b4Smrg	  for obj in $save_oldobjs
92001fb744b4Smrg	  do
92011fb744b4Smrg	    last_oldobj=$obj
92021fb744b4Smrg	  done
92031fb744b4Smrg	  eval test_cmds=\"$old_archive_cmds\"
92041fb744b4Smrg	  func_len " $test_cmds"
92051fb744b4Smrg	  len0=$func_len_result
92061fb744b4Smrg	  len=$len0
92071fb744b4Smrg	  for obj in $save_oldobjs
92081fb744b4Smrg	  do
92091fb744b4Smrg	    func_len " $obj"
92101fb744b4Smrg	    func_arith $len + $func_len_result
92111fb744b4Smrg	    len=$func_arith_result
92121fb744b4Smrg	    func_append objlist " $obj"
92131fb744b4Smrg	    if test "$len" -lt "$max_cmd_len"; then
92141fb744b4Smrg	      :
92151fb744b4Smrg	    else
92161fb744b4Smrg	      # the above command should be used before it gets too long
92171fb744b4Smrg	      oldobjs=$objlist
92181fb744b4Smrg	      if test "$obj" = "$last_oldobj" ; then
92191fb744b4Smrg		RANLIB=$save_RANLIB
92201fb744b4Smrg	      fi
92211fb744b4Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
92221fb744b4Smrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
92231fb744b4Smrg	      objlist=
92241fb744b4Smrg	      len=$len0
92251fb744b4Smrg	    fi
92261fb744b4Smrg	  done
92271fb744b4Smrg	  RANLIB=$save_RANLIB
92281fb744b4Smrg	  oldobjs=$objlist
92291fb744b4Smrg	  if test "X$oldobjs" = "X" ; then
92301fb744b4Smrg	    eval cmds=\"\$concat_cmds\"
92311fb744b4Smrg	  else
92321fb744b4Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
92331fb744b4Smrg	  fi
92341fb744b4Smrg	fi
92351fb744b4Smrg      fi
92361fb744b4Smrg      func_execute_cmds "$cmds" 'exit $?'
9237c35d236eSmrg    done
9238c35d236eSmrg
92391fb744b4Smrg    test -n "$generated" && \
92401fb744b4Smrg      func_show_eval "${RM}r$generated"
9241c35d236eSmrg
92421fb744b4Smrg    # Now create the libtool archive.
92431fb744b4Smrg    case $output in
92441fb744b4Smrg    *.la)
92451fb744b4Smrg      old_library=
92461fb744b4Smrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
92471fb744b4Smrg      func_verbose "creating $output"
9248c35d236eSmrg
92491fb744b4Smrg      # Preserve any variables that may affect compiler behavior
92501fb744b4Smrg      for var in $variables_saved_for_relink; do
92511fb744b4Smrg	if eval test -z \"\${$var+set}\"; then
92521fb744b4Smrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
92531fb744b4Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
92541fb744b4Smrg	  relink_command="$var=; export $var; $relink_command"
9255518bcf38Smrg	else
92561fb744b4Smrg	  func_quote_for_eval "$var_value"
92571fb744b4Smrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9258518bcf38Smrg	fi
92591fb744b4Smrg      done
92601fb744b4Smrg      # Quote the link command for shipping.
92611fb744b4Smrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
92621fb744b4Smrg      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
92631fb744b4Smrg      if test "$hardcode_automatic" = yes ; then
92641fb744b4Smrg	relink_command=
92651fb744b4Smrg      fi
9266c35d236eSmrg
92671fb744b4Smrg      # Only create the output if not a dry run.
92681fb744b4Smrg      $opt_dry_run || {
92691fb744b4Smrg	for installed in no yes; do
92701fb744b4Smrg	  if test "$installed" = yes; then
92711fb744b4Smrg	    if test -z "$install_libdir"; then
92721fb744b4Smrg	      break
92731fb744b4Smrg	    fi
92741fb744b4Smrg	    output="$output_objdir/$outputname"i
92751fb744b4Smrg	    # Replace all uninstalled libtool libraries with the installed ones
92761fb744b4Smrg	    newdependency_libs=
92771fb744b4Smrg	    for deplib in $dependency_libs; do
92781fb744b4Smrg	      case $deplib in
92791fb744b4Smrg	      *.la)
92801fb744b4Smrg		func_basename "$deplib"
92811fb744b4Smrg		name="$func_basename_result"
92821fb744b4Smrg		func_resolve_sysroot "$deplib"
92831fb744b4Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
92841fb744b4Smrg		test -z "$libdir" && \
92851fb744b4Smrg		  func_fatal_error "\`$deplib' is not a valid libtool archive"
92861fb744b4Smrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
92871fb744b4Smrg		;;
92881fb744b4Smrg	      -L*)
92891fb744b4Smrg		func_stripname -L '' "$deplib"
92901fb744b4Smrg		func_replace_sysroot "$func_stripname_result"
92911fb744b4Smrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
92921fb744b4Smrg		;;
92931fb744b4Smrg	      -R*)
92941fb744b4Smrg		func_stripname -R '' "$deplib"
92951fb744b4Smrg		func_replace_sysroot "$func_stripname_result"
92961fb744b4Smrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
92971fb744b4Smrg		;;
92981fb744b4Smrg	      *) func_append newdependency_libs " $deplib" ;;
92991fb744b4Smrg	      esac
93001fb744b4Smrg	    done
93011fb744b4Smrg	    dependency_libs="$newdependency_libs"
93021fb744b4Smrg	    newdlfiles=
93031fb744b4Smrg
93041fb744b4Smrg	    for lib in $dlfiles; do
93051fb744b4Smrg	      case $lib in
93061fb744b4Smrg	      *.la)
93071fb744b4Smrg	        func_basename "$lib"
93081fb744b4Smrg		name="$func_basename_result"
93091fb744b4Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
93101fb744b4Smrg		test -z "$libdir" && \
93111fb744b4Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
93121fb744b4Smrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
93131fb744b4Smrg		;;
93141fb744b4Smrg	      *) func_append newdlfiles " $lib" ;;
93151fb744b4Smrg	      esac
93161fb744b4Smrg	    done
93171fb744b4Smrg	    dlfiles="$newdlfiles"
93181fb744b4Smrg	    newdlprefiles=
93191fb744b4Smrg	    for lib in $dlprefiles; do
93201fb744b4Smrg	      case $lib in
93211fb744b4Smrg	      *.la)
93221fb744b4Smrg		# Only pass preopened files to the pseudo-archive (for
93231fb744b4Smrg		# eventual linking with the app. that links it) if we
93241fb744b4Smrg		# didn't already link the preopened objects directly into
93251fb744b4Smrg		# the library:
93261fb744b4Smrg		func_basename "$lib"
93271fb744b4Smrg		name="$func_basename_result"
93281fb744b4Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
93291fb744b4Smrg		test -z "$libdir" && \
93301fb744b4Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
93311fb744b4Smrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
93321fb744b4Smrg		;;
93331fb744b4Smrg	      esac
93341fb744b4Smrg	    done
93351fb744b4Smrg	    dlprefiles="$newdlprefiles"
93361fb744b4Smrg	  else
93371fb744b4Smrg	    newdlfiles=
93381fb744b4Smrg	    for lib in $dlfiles; do
93391fb744b4Smrg	      case $lib in
93401fb744b4Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
93411fb744b4Smrg		*) abs=`pwd`"/$lib" ;;
93421fb744b4Smrg	      esac
93431fb744b4Smrg	      func_append newdlfiles " $abs"
93441fb744b4Smrg	    done
93451fb744b4Smrg	    dlfiles="$newdlfiles"
93461fb744b4Smrg	    newdlprefiles=
93471fb744b4Smrg	    for lib in $dlprefiles; do
93481fb744b4Smrg	      case $lib in
93491fb744b4Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
93501fb744b4Smrg		*) abs=`pwd`"/$lib" ;;
93511fb744b4Smrg	      esac
93521fb744b4Smrg	      func_append newdlprefiles " $abs"
93531fb744b4Smrg	    done
93541fb744b4Smrg	    dlprefiles="$newdlprefiles"
93551fb744b4Smrg	  fi
93561fb744b4Smrg	  $RM $output
93571fb744b4Smrg	  # place dlname in correct position for cygwin
93581fb744b4Smrg	  # In fact, it would be nice if we could use this code for all target
93591fb744b4Smrg	  # systems that can't hard-code library paths into their executables
93601fb744b4Smrg	  # and that have no shared library path variable independent of PATH,
93611fb744b4Smrg	  # but it turns out we can't easily determine that from inspecting
93621fb744b4Smrg	  # libtool variables, so we have to hard-code the OSs to which it
93631fb744b4Smrg	  # applies here; at the moment, that means platforms that use the PE
93641fb744b4Smrg	  # object format with DLL files.  See the long comment at the top of
93651fb744b4Smrg	  # tests/bindir.at for full details.
93661fb744b4Smrg	  tdlname=$dlname
93671fb744b4Smrg	  case $host,$output,$installed,$module,$dlname in
93681fb744b4Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
93691fb744b4Smrg	      # If a -bindir argument was supplied, place the dll there.
93701fb744b4Smrg	      if test "x$bindir" != x ;
93711fb744b4Smrg	      then
93721fb744b4Smrg		func_relative_path "$install_libdir" "$bindir"
93731fb744b4Smrg		tdlname=$func_relative_path_result$dlname
93741fb744b4Smrg	      else
93751fb744b4Smrg		# Otherwise fall back on heuristic.
93761fb744b4Smrg		tdlname=../bin/$dlname
93771fb744b4Smrg	      fi
93781fb744b4Smrg	      ;;
93791fb744b4Smrg	  esac
93801fb744b4Smrg	  $ECHO > $output "\
93811fb744b4Smrg# $outputname - a libtool library file
93821fb744b4Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
93831fb744b4Smrg#
93841fb744b4Smrg# Please DO NOT delete this file!
93851fb744b4Smrg# It is necessary for linking the library.
9386c35d236eSmrg
93871fb744b4Smrg# The name that we can dlopen(3).
93881fb744b4Smrgdlname='$tdlname'
9389c35d236eSmrg
93901fb744b4Smrg# Names of this library.
93911fb744b4Smrglibrary_names='$library_names'
9392c35d236eSmrg
93931fb744b4Smrg# The name of the static archive.
93941fb744b4Smrgold_library='$old_library'
9395c35d236eSmrg
93961fb744b4Smrg# Linker flags that can not go in dependency_libs.
93971fb744b4Smrginherited_linker_flags='$new_inherited_linker_flags'
9398c35d236eSmrg
93991fb744b4Smrg# Libraries that this one depends upon.
94001fb744b4Smrgdependency_libs='$dependency_libs'
9401c35d236eSmrg
94021fb744b4Smrg# Names of additional weak libraries provided by this library
94031fb744b4Smrgweak_library_names='$weak_libs'
9404c35d236eSmrg
94051fb744b4Smrg# Version information for $libname.
94061fb744b4Smrgcurrent=$current
94071fb744b4Smrgage=$age
94081fb744b4Smrgrevision=$revision
9409c35d236eSmrg
94101fb744b4Smrg# Is this an already installed library?
94111fb744b4Smrginstalled=$installed
9412c35d236eSmrg
94131fb744b4Smrg# Should we warn about portability when linking against -modules?
94141fb744b4Smrgshouldnotlink=$module
9415c35d236eSmrg
94161fb744b4Smrg# Files to dlopen/dlpreopen
94171fb744b4Smrgdlopen='$dlfiles'
94181fb744b4Smrgdlpreopen='$dlprefiles'
9419c35d236eSmrg
94201fb744b4Smrg# Directory that this library needs to be installed in:
94211fb744b4Smrglibdir='$install_libdir'"
94221fb744b4Smrg	  if test "$installed" = no && test "$need_relink" = yes; then
94231fb744b4Smrg	    $ECHO >> $output "\
94241fb744b4Smrgrelink_command=\"$relink_command\""
94251fb744b4Smrg	  fi
94261fb744b4Smrg	done
94271fb744b4Smrg      }
94284f6cd06fSmrg
94291fb744b4Smrg      # Do a symbolic link so that the libtool archive can be found in
94301fb744b4Smrg      # LD_LIBRARY_PATH before the program is installed.
94311fb744b4Smrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
94321fb744b4Smrg      ;;
94331fb744b4Smrg    esac
94341fb744b4Smrg    exit $EXIT_SUCCESS
94351fb744b4Smrg}
9436518bcf38Smrg
94371fb744b4Smrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
94381fb744b4Smrg    func_mode_link ${1+"$@"}
9439c35d236eSmrg
9440c35d236eSmrg
94411fb744b4Smrg# func_mode_uninstall arg...
94421fb744b4Smrgfunc_mode_uninstall ()
94431fb744b4Smrg{
94441fb744b4Smrg    $opt_debug
94451fb744b4Smrg    RM="$nonopt"
9446c35d236eSmrg    files=
9447c35d236eSmrg    rmforce=
9448c35d236eSmrg    exit_status=0
9449c35d236eSmrg
9450c35d236eSmrg    # This variable tells wrapper scripts just to set variables rather
9451c35d236eSmrg    # than running their programs.
9452c35d236eSmrg    libtool_install_magic="$magic"
9453c35d236eSmrg
9454c35d236eSmrg    for arg
9455c35d236eSmrg    do
9456c35d236eSmrg      case $arg in
94571fb744b4Smrg      -f) func_append RM " $arg"; rmforce=yes ;;
94581fb744b4Smrg      -*) func_append RM " $arg" ;;
94591fb744b4Smrg      *) func_append files " $arg" ;;
9460c35d236eSmrg      esac
9461c35d236eSmrg    done
9462c35d236eSmrg
94631fb744b4Smrg    test -z "$RM" && \
94641fb744b4Smrg      func_fatal_help "you must specify an RM program"
9465c35d236eSmrg
9466c35d236eSmrg    rmdirs=
9467c35d236eSmrg
9468c35d236eSmrg    for file in $files; do
94691fb744b4Smrg      func_dirname "$file" "" "."
94701fb744b4Smrg      dir="$func_dirname_result"
94711fb744b4Smrg      if test "X$dir" = X.; then
94721fb744b4Smrg	odir="$objdir"
9473c35d236eSmrg      else
94741fb744b4Smrg	odir="$dir/$objdir"
9475c35d236eSmrg      fi
94761fb744b4Smrg      func_basename "$file"
94771fb744b4Smrg      name="$func_basename_result"
94781fb744b4Smrg      test "$opt_mode" = uninstall && odir="$dir"
9479c35d236eSmrg
94801fb744b4Smrg      # Remember odir for removal later, being careful to avoid duplicates
94811fb744b4Smrg      if test "$opt_mode" = clean; then
9482c35d236eSmrg	case " $rmdirs " in
94831fb744b4Smrg	  *" $odir "*) ;;
94841fb744b4Smrg	  *) func_append rmdirs " $odir" ;;
9485c35d236eSmrg	esac
9486c35d236eSmrg      fi
9487c35d236eSmrg
9488c35d236eSmrg      # Don't error if the file doesn't exist and rm -f was used.
94891fb744b4Smrg      if { test -L "$file"; } >/dev/null 2>&1 ||
94901fb744b4Smrg	 { test -h "$file"; } >/dev/null 2>&1 ||
94911fb744b4Smrg	 test -f "$file"; then
9492c35d236eSmrg	:
9493c35d236eSmrg      elif test -d "$file"; then
9494c35d236eSmrg	exit_status=1
9495c35d236eSmrg	continue
9496c35d236eSmrg      elif test "$rmforce" = yes; then
9497c35d236eSmrg	continue
9498c35d236eSmrg      fi
9499c35d236eSmrg
9500c35d236eSmrg      rmfiles="$file"
9501c35d236eSmrg
9502c35d236eSmrg      case $name in
9503c35d236eSmrg      *.la)
9504c35d236eSmrg	# Possibly a libtool archive, so verify it.
95051fb744b4Smrg	if func_lalib_p "$file"; then
95061fb744b4Smrg	  func_source $dir/$name
9507c35d236eSmrg
9508c35d236eSmrg	  # Delete the libtool libraries and symlinks.
9509c35d236eSmrg	  for n in $library_names; do
95101fb744b4Smrg	    func_append rmfiles " $odir/$n"
9511c35d236eSmrg	  done
95121fb744b4Smrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
9513c35d236eSmrg
95141fb744b4Smrg	  case "$opt_mode" in
9515c35d236eSmrg	  clean)
95161fb744b4Smrg	    case " $library_names " in
9517c35d236eSmrg	    *" $dlname "*) ;;
95181fb744b4Smrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
9519c35d236eSmrg	    esac
95201fb744b4Smrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
9521c35d236eSmrg	    ;;
9522c35d236eSmrg	  uninstall)
9523c35d236eSmrg	    if test -n "$library_names"; then
9524c35d236eSmrg	      # Do each command in the postuninstall commands.
95251fb744b4Smrg	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9526c35d236eSmrg	    fi
9527c35d236eSmrg
9528c35d236eSmrg	    if test -n "$old_library"; then
9529c35d236eSmrg	      # Do each command in the old_postuninstall commands.
95301fb744b4Smrg	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9531c35d236eSmrg	    fi
9532c35d236eSmrg	    # FIXME: should reinstall the best remaining shared library.
9533c35d236eSmrg	    ;;
9534c35d236eSmrg	  esac
9535c35d236eSmrg	fi
9536c35d236eSmrg	;;
9537c35d236eSmrg
9538c35d236eSmrg      *.lo)
9539c35d236eSmrg	# Possibly a libtool object, so verify it.
95401fb744b4Smrg	if func_lalib_p "$file"; then
9541c35d236eSmrg
9542c35d236eSmrg	  # Read the .lo file
95431fb744b4Smrg	  func_source $dir/$name
9544c35d236eSmrg
9545c35d236eSmrg	  # Add PIC object to the list of files to remove.
95461fb744b4Smrg	  if test -n "$pic_object" &&
95471fb744b4Smrg	     test "$pic_object" != none; then
95481fb744b4Smrg	    func_append rmfiles " $dir/$pic_object"
9549c35d236eSmrg	  fi
9550c35d236eSmrg
9551c35d236eSmrg	  # Add non-PIC object to the list of files to remove.
95521fb744b4Smrg	  if test -n "$non_pic_object" &&
95531fb744b4Smrg	     test "$non_pic_object" != none; then
95541fb744b4Smrg	    func_append rmfiles " $dir/$non_pic_object"
9555c35d236eSmrg	  fi
9556c35d236eSmrg	fi
9557c35d236eSmrg	;;
9558c35d236eSmrg
9559c35d236eSmrg      *)
95601fb744b4Smrg	if test "$opt_mode" = clean ; then
9561c35d236eSmrg	  noexename=$name
9562c35d236eSmrg	  case $file in
9563c35d236eSmrg	  *.exe)
95641fb744b4Smrg	    func_stripname '' '.exe' "$file"
95651fb744b4Smrg	    file=$func_stripname_result
95661fb744b4Smrg	    func_stripname '' '.exe' "$name"
95671fb744b4Smrg	    noexename=$func_stripname_result
9568c35d236eSmrg	    # $file with .exe has already been added to rmfiles,
9569c35d236eSmrg	    # add $file without .exe
95701fb744b4Smrg	    func_append rmfiles " $file"
9571c35d236eSmrg	    ;;
9572c35d236eSmrg	  esac
9573c35d236eSmrg	  # Do a test to see if this is a libtool program.
95741fb744b4Smrg	  if func_ltwrapper_p "$file"; then
95751fb744b4Smrg	    if func_ltwrapper_executable_p "$file"; then
95761fb744b4Smrg	      func_ltwrapper_scriptname "$file"
95771fb744b4Smrg	      relink_command=
95781fb744b4Smrg	      func_source $func_ltwrapper_scriptname_result
95791fb744b4Smrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
95801fb744b4Smrg	    else
95811fb744b4Smrg	      relink_command=
95821fb744b4Smrg	      func_source $dir/$noexename
95831fb744b4Smrg	    fi
9584c35d236eSmrg
9585c35d236eSmrg	    # note $name still contains .exe if it was in $file originally
9586c35d236eSmrg	    # as does the version of $file that was added into $rmfiles
95871fb744b4Smrg	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
9588c35d236eSmrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
95891fb744b4Smrg	      func_append rmfiles " $odir/lt-$name"
9590c35d236eSmrg	    fi
9591c35d236eSmrg	    if test "X$noexename" != "X$name" ; then
95921fb744b4Smrg	      func_append rmfiles " $odir/lt-${noexename}.c"
9593c35d236eSmrg	    fi
9594c35d236eSmrg	  fi
9595c35d236eSmrg	fi
9596c35d236eSmrg	;;
9597c35d236eSmrg      esac
95981fb744b4Smrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
9599c35d236eSmrg    done
9600c35d236eSmrg
9601c35d236eSmrg    # Try to remove the ${objdir}s in the directories where we deleted files
9602c35d236eSmrg    for dir in $rmdirs; do
9603c35d236eSmrg      if test -d "$dir"; then
96041fb744b4Smrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
9605c35d236eSmrg      fi
9606c35d236eSmrg    done
9607c35d236eSmrg
9608c35d236eSmrg    exit $exit_status
96091fb744b4Smrg}
9610c35d236eSmrg
96111fb744b4Smrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
96121fb744b4Smrg    func_mode_uninstall ${1+"$@"}
9613f55e6a01Smrg
96141fb744b4Smrgtest -z "$opt_mode" && {
96151fb744b4Smrg  help="$generic_help"
96161fb744b4Smrg  func_fatal_help "you must specify a MODE"
96171fb744b4Smrg}
96181fb744b4Smrg
96191fb744b4Smrgtest -z "$exec_cmd" && \
96201fb744b4Smrg  func_fatal_help "invalid operation mode \`$opt_mode'"
9621c35d236eSmrg
9622c35d236eSmrgif test -n "$exec_cmd"; then
96231fb744b4Smrg  eval exec "$exec_cmd"
9624c35d236eSmrg  exit $EXIT_FAILURE
9625c35d236eSmrgfi
9626c35d236eSmrg
96271fb744b4Smrgexit $exit_status
9628518bcf38Smrg
9629c35d236eSmrg
9630c35d236eSmrg# The TAGs below are defined such that we never get into a situation
9631c35d236eSmrg# in which we disable both kinds of libraries.  Given conflicting
9632c35d236eSmrg# choices, we go for a static library, that is the most portable,
9633c35d236eSmrg# since we can't tell whether shared libraries were disabled because
9634c35d236eSmrg# the user asked for that or because the platform doesn't support
9635c35d236eSmrg# them.  This is particularly important on AIX, because we don't
9636c35d236eSmrg# support having both static and shared libraries enabled at the same
9637c35d236eSmrg# time on that platform, so we default to a shared-only configuration.
9638c35d236eSmrg# If a disable-shared tag is given, we'll fallback to a static-only
9639c35d236eSmrg# configuration.  But we'll never go from static-only to shared-only.
9640c35d236eSmrg
9641c35d236eSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
96421fb744b4Smrgbuild_libtool_libs=no
96431fb744b4Smrgbuild_old_libs=yes
9644c35d236eSmrg# ### END LIBTOOL TAG CONFIG: disable-shared
9645c35d236eSmrg
9646c35d236eSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
96471fb744b4Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
9648c35d236eSmrg# ### END LIBTOOL TAG CONFIG: disable-static
9649c35d236eSmrg
9650c35d236eSmrg# Local Variables:
9651c35d236eSmrg# mode:shell-script
9652c35d236eSmrg# sh-indentation:2
9653c35d236eSmrg# End:
96541fb744b4Smrg# vi:sw=2
96551fb744b4Smrg
9656