1e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Generated from ltmain.m4sh.
2e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# ltmain.sh (GNU libtool) 2.2.6
4e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
5e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc.
7e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# This is free software; see the source for copying conditions.  There is NO
8e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
10e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# GNU Libtool is free software; you can redistribute it and/or modify
11e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# it under the terms of the GNU General Public License as published by
12e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# the Free Software Foundation; either version 2 of the License, or
13e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# (at your option) any later version.
14e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#
15e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# As a special exception to the GNU General Public License,
16e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# if you distribute this file as part of a program or library that
17e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# is built using GNU Libtool, you may include this file under the
18e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# same distribution terms that you use for the rest of that program.
19e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#
20e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# GNU Libtool is distributed in the hope that it will be useful, but
21e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# WITHOUT ANY WARRANTY; without even the implied warranty of
22e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# General Public License for more details.
24e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#
25e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# You should have received a copy of the GNU General Public License
26e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# along with GNU Libtool; see the file COPYING.  If not, a copy
27e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# can be downloaded from http://www.gnu.org/licenses/gpl.html,
28e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# or obtained by writing to the Free Software Foundation, Inc.,
29e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
31e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Usage: $progname [OPTION]... [MODE-ARG]...
32e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#
33e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Provide generalized library-building support services.
34e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#
35e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#     --config             show all configuration variables
36e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#     --debug              enable verbose shell tracing
37e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# -n, --dry-run            display commands without modifying any files
38e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#     --features           display basic configuration information and exit
39e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#     --mode=MODE          use operation mode MODE
40e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#     --preserve-dup-deps  don't remove duplicate dependency libraries
41e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#     --quiet, --silent    don't print informational messages
42e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#     --tag=TAG            use configuration variables from tag TAG
43e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# -v, --verbose            print informational messages (default)
44e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#     --version            print version information
45e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# -h, --help               print short or long help message
46e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#
47e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# MODE must be one of the following:
48e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#
49e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#       clean              remove files from the build directory
50e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#       compile            compile a source file into a libtool object
51e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#       execute            automatically set library path, then run a program
52e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#       finish             complete the installation of libtool libraries
53e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#       install            install libraries or executables
54e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#       link               create a library or an executable
55e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#       uninstall          remove libraries from an installed directory
56e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#
57e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# MODE-ARGS vary depending on the MODE.
58e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
59e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#
60e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# When reporting a bug, please describe a test case to reproduce it and
61e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# include the following information:
62e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#
63e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#       host-triplet:	$host
64e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#       shell:		$SHELL
65e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#       compiler:		$LTCC
66e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#       compiler flags:		$LTCFLAGS
67e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#       linker:		$LD (gnu? $with_gnu_ld)
68e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#       $progname:		(GNU libtool) 2.2.6
69e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#       automake:		$automake_version
70e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#       autoconf:		$autoconf_version
71e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#
72e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Report bugs to <bug-libtool@gnu.org>.
73e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
74e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevPROGRAM=ltmain.sh
75e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevPACKAGE=libtool
76e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevVERSION=2.2.6
77e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevTIMESTAMP=""
78e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevpackage_revision=1.3012
79e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
80e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Be Bourne compatible
81e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
82e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  emulate sh
83e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  NULLCMD=:
84e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
85e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # is contrary to our usage.  Disable this feature.
86e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  alias -g '${1+"$@"}'='"$@"'
87e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  setopt NO_GLOB_SUBST
88e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevelse
89e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
90e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfi
91e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevBIN_SH=xpg4; export BIN_SH # for Tru64
92e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevDUALCASE=1; export DUALCASE # for MKS sh
93e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
94e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# NLS nuisances: We save the old values to restore during execute mode.
95e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Only set LANG and LC_ALL to C if already set.
96e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# These must not be set unconditionally because not all systems understand
97e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# e.g. LANG=C (notably SCO).
98e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevlt_user_locale=
99e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevlt_safe_locale=
100e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
101e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevdo
102e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  eval "if test \"\${$lt_var+set}\" = set; then
103e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          save_$lt_var=\$$lt_var
104e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          $lt_var=C
105e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  export $lt_var
106e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
107e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
108e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi"
109e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevdone
110e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
111e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev$lt_unset CDPATH
112e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
113e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
114e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
115e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
116e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
117e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev: ${CP="cp -f"}
118e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev: ${ECHO="echo"}
119e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev: ${EGREP="/usr/bin/grep -E"}
120e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev: ${FGREP="/usr/bin/grep -F"}
121e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev: ${GREP="/usr/bin/grep"}
122e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev: ${LN_S="ln -s"}
123e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev: ${MAKE="make"}
124e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev: ${MKDIR="mkdir"}
125e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev: ${MV="mv -f"}
126e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev: ${RM="rm -f"}
127e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev: ${SED="/opt/local/bin/gsed"}
128e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
129e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev: ${Xsed="$SED -e 1s/^X//"}
130e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
131e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Global variables:
132e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevEXIT_SUCCESS=0
133e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevEXIT_FAILURE=1
134e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
135e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
136e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
137e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevexit_status=$EXIT_SUCCESS
138e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
139e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Make sure IFS has a sensible default
140e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevlt_nl='
141e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev'
142e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevIFS=" 	$lt_nl"
143e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
144e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevdirname="s,/[^/]*$,,"
145e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevbasename="s,^.*/,,"
146e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
147e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_dirname_and_basename file append nondir_replacement
148e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# perform func_basename and func_dirname in a single function
149e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# call:
150e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#   dirname:  Compute the dirname of FILE.  If nonempty,
151e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#             add APPEND to the result, otherwise set result
152e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#             to NONDIR_REPLACEMENT.
153e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#             value returned in "$func_dirname_result"
154e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#   basename: Compute filename of FILE.
155e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#             value retuned in "$func_basename_result"
156e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Implementation must be kept synchronized with func_dirname
157e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# and func_basename. For efficiency, we do not delegate to
158e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# those functions but instead duplicate the functionality here.
159e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_dirname_and_basename ()
160e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
161e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # Extract subdirectory from the argument.
162e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
163e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if test "X$func_dirname_result" = "X${1}"; then
164e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_dirname_result="${3}"
165e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  else
166e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_dirname_result="$func_dirname_result${2}"
167e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  fi
168e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
169e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
170e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
171e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Generated shell functions inserted here.
172e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
173e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
174e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# is ksh but when the shell is invoked as "sh" and the current value of
175e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# the _XPG environment variable is not equal to 1 (one), the special
176e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# positional parameter $0, within a function call, is the name of the
177e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# function.
178e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevprogpath="$0"
179e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
180e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# The name of this program:
181e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# In the unlikely event $progname began with a '-', it would play havoc with
182e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_echo (imagine progname=-n), so we prepend ./ in that case:
183e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_dirname_and_basename "$progpath"
184e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevprogname=$func_basename_result
185e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevcase $progname in
186e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -*) progname=./$progname ;;
187e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevesac
188e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
189e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Make sure we have an absolute path for reexecution:
190e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevcase $progpath in
191e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  [\\/]*|[A-Za-z]:\\*) ;;
192e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  *[\\/]*)
193e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev     progdir=$func_dirname_result
194e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev     progdir=`cd "$progdir" && pwd`
195e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev     progpath="$progdir/$progname"
196e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev     ;;
197e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  *)
198e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev     save_IFS="$IFS"
199e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev     IFS=:
200e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev     for progdir in $PATH; do
201e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev       IFS="$save_IFS"
202e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev       test -x "$progdir/$progname" && break
203e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev     done
204e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev     IFS="$save_IFS"
205e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev     test -n "$progdir" || progdir=`pwd`
206e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev     progpath="$progdir/$progname"
207e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev     ;;
208e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevesac
209e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
210e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Sed substitution that helps us do robust quoting.  It backslashifies
211e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# metacharacters that are still active within double-quoted strings.
212e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevXsed="${SED}"' -e 1s/^X//'
213e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
214e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
215e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Same as above, but do not quote variable references.
216e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
217e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
218e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Re-`\' parameter expansions in output of double_quote_subst that were
219e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
220e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# in input to double_quote_subst, that '$' was protected from expansion.
221e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Since each input `\' is now two `\'s, look for any number of runs of
222e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
223e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevbs='\\'
224e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevbs2='\\\\'
225e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevbs4='\\\\\\\\'
226e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevdollar='\$'
227e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevsed_double_backslash="\
228e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  s/$bs4/&\\
229e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev/g
230e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  s/^$bs2$dollar/$bs&/
231e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
232e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  s/\n//g"
233e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
234e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Standard options:
235e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevopt_dry_run=false
236e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevopt_help=false
237e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevopt_quiet=false
238e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevopt_verbose=false
239e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevopt_warning=:
240e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
241e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_echo arg...
242e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Echo program name prefixed message, along with the current mode
243e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# name if it has been set yet.
244e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_echo ()
245e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
246e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $ECHO "$progname${mode+: }$mode: $*"
247e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
248e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
249e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_verbose arg...
250e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Echo program name prefixed message in verbose mode only.
251e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_verbose ()
252e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
253e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $opt_verbose && func_echo ${1+"$@"}
254e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
255e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # A bug in bash halts the script if the last line of a function
256e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # fails when set -e is in force, so we need another command to
257e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # work around that:
258e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    :
259e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
260e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
261e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_error arg...
262e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Echo program name prefixed message to standard error.
263e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_error ()
264e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
265e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
266e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
267e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
268e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_warning arg...
269e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Echo program name prefixed warning message to standard error.
270e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_warning ()
271e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
272e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
273e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
274e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # bash bug again:
275e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    :
276e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
277e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
278e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_fatal_error arg...
279e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Echo program name prefixed message to standard error, and exit.
280e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_fatal_error ()
281e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
282e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_error ${1+"$@"}
283e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    exit $EXIT_FAILURE
284e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
285e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
286e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_fatal_help arg...
287e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Echo program name prefixed message to standard error, followed by
288e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# a help hint, and exit.
289e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_fatal_help ()
290e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
291e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_error ${1+"$@"}
292e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_fatal_error "$help"
293e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
294e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevhelp="Try \`$progname --help' for more information."  ## default
295e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
296e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
297e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_grep expression filename
298e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Check whether EXPRESSION matches any line of FILENAME, without output.
299e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_grep ()
300e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
301e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $GREP "$1" "$2" >/dev/null 2>&1
302e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
303e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
304e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
305e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_mkdir_p directory-path
306e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Make sure the entire path to DIRECTORY-PATH is available.
307e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_mkdir_p ()
308e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
309e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    my_directory_path="$1"
310e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    my_dir_list=
311e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
312e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
313e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
314e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Protect directory names starting with `-'
315e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      case $my_directory_path in
316e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        -*) my_directory_path="./$my_directory_path" ;;
317e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      esac
318e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
319e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # While some portion of DIR does not yet exist...
320e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      while test ! -d "$my_directory_path"; do
321e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        # ...make a list in topmost first order.  Use a colon delimited
322e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# list incase some portion of path contains whitespace.
323e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        my_dir_list="$my_directory_path:$my_dir_list"
324e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
325e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        # If the last portion added has no slash in it, the list is done
326e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        case $my_directory_path in */*) ;; *) break ;; esac
327e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
328e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        # ...otherwise throw away the child directory and loop
329e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"`
330e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      done
331e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'`
332e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
333e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      save_mkdir_p_IFS="$IFS"; IFS=':'
334e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      for my_dir in $my_dir_list; do
335e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	IFS="$save_mkdir_p_IFS"
336e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        # mkdir can fail with a `File exist' error if two processes
337e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        # try to create one of the directories concurrently.  Don't
338e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        # stop in that case!
339e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        $MKDIR "$my_dir" 2>/dev/null || :
340e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      done
341e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      IFS="$save_mkdir_p_IFS"
342e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
343e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Bail out if we (or some other process) failed to create a directory.
344e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      test -d "$my_directory_path" || \
345e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        func_fatal_error "Failed to create \`$1'"
346e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
347e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
348e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
349e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
350e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_mktempdir [string]
351e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Make a temporary directory that won't clash with other running
352e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# libtool processes, and avoids race conditions if possible.  If
353e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# given, STRING is the basename for that directory.
354e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_mktempdir ()
355e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
356e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    my_template="${TMPDIR-/tmp}/${1-$progname}"
357e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
358e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test "$opt_dry_run" = ":"; then
359e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Return a directory name, but don't create it in dry-run mode
360e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      my_tmpdir="${my_template}-$$"
361e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    else
362e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
363e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # If mktemp works, use that first and foremost
364e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
365e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
366e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test ! -d "$my_tmpdir"; then
367e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        # Failing that, at least try and use $RANDOM to avoid a race
368e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        my_tmpdir="${my_template}-${RANDOM-0}$$"
369e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
370e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        save_mktempdir_umask=`umask`
371e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        umask 0077
372e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        $MKDIR "$my_tmpdir"
373e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        umask $save_mktempdir_umask
374e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
375e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
376e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # If we're not in dry-run mode, bomb out on failure
377e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      test -d "$my_tmpdir" || \
378e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
379e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
380e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
381e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $ECHO "X$my_tmpdir" | $Xsed
382e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
383e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
384e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
385e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_quote_for_eval arg
386e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Aesthetically quote ARG to be evaled later.
387e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
388e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# is double-quoted, suitable for a subsequent eval, whereas
389e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
390e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# which are still active within double quotes backslashified.
391e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_quote_for_eval ()
392e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
393e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    case $1 in
394e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *[\\\`\"\$]*)
395e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;;
396e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *)
397e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        func_quote_for_eval_unquoted_result="$1" ;;
398e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    esac
399e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
400e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    case $func_quote_for_eval_unquoted_result in
401e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Double-quote args containing shell metacharacters to delay
402e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # word splitting, command substitution and and variable
403e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # expansion for a subsequent eval.
404e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Many Bourne shells cannot handle close brackets correctly
405e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # in scan sets, so we specify it separately.
406e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
407e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
408e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        ;;
409e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *)
410e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
411e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    esac
412e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
413e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
414e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
415e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_quote_for_expand arg
416e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Aesthetically quote ARG to be evaled later; same as above,
417e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# but do not quote variable references.
418e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_quote_for_expand ()
419e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
420e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    case $1 in
421e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *[\\\`\"]*)
422e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	my_arg=`$ECHO "X$1" | $Xsed \
423e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
424e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *)
425e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        my_arg="$1" ;;
426e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    esac
427e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
428e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    case $my_arg in
429e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Double-quote args containing shell metacharacters to delay
430e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # word splitting and command substitution for a subsequent eval.
431e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Many Bourne shells cannot handle close brackets correctly
432e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # in scan sets, so we specify it separately.
433e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
434e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        my_arg="\"$my_arg\""
435e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        ;;
436e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    esac
437e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
438e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_quote_for_expand_result="$my_arg"
439e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
440e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
441e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
442e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_show_eval cmd [fail_exp]
443e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
444e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
445e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# is given, then evaluate it.
446e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_show_eval ()
447e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
448e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    my_cmd="$1"
449e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    my_fail_exp="${2-:}"
450e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
451e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    ${opt_silent-false} || {
452e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_quote_for_expand "$my_cmd"
453e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      eval "func_echo $func_quote_for_expand_result"
454e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    }
455e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
456e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if ${opt_dry_run-false}; then :; else
457e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      eval "$my_cmd"
458e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      my_status=$?
459e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "$my_status" -eq 0; then :; else
460e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	eval "(exit $my_status); $my_fail_exp"
461e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
462e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
463e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
464e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
465e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
466e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_show_eval_locale cmd [fail_exp]
467e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
468e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
469e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# is given, then evaluate it.  Use the saved locale for evaluation.
470e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_show_eval_locale ()
471e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
472e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    my_cmd="$1"
473e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    my_fail_exp="${2-:}"
474e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
475e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    ${opt_silent-false} || {
476e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_quote_for_expand "$my_cmd"
477e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      eval "func_echo $func_quote_for_expand_result"
478e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    }
479e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
480e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if ${opt_dry_run-false}; then :; else
481e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      eval "$lt_user_locale
482e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $my_cmd"
483e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      my_status=$?
484e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      eval "$lt_safe_locale"
485e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "$my_status" -eq 0; then :; else
486e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	eval "(exit $my_status); $my_fail_exp"
487e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
488e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
489e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
490e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
491e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
492e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
493e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
494e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
495e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_version
496e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Echo version message to standard output and exit.
497e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_version ()
498e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
499e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / {
500e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        s/^# //
501e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	s/^# *$//
502e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
503e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        p
504e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev     }' < "$progpath"
505e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev     exit $?
506e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
507e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
508e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_usage
509e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Echo short help message to standard output and exit.
510e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_usage ()
511e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
512e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $SED -n '/^# Usage:/,/# -h/ {
513e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        s/^# //
514e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	s/^# *$//
515e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	s/\$progname/'$progname'/
516e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	p
517e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    }' < "$progpath"
518e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $ECHO
519e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $ECHO "run \`$progname --help | more' for full usage"
520e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    exit $?
521e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
522e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
523e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_help
524e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Echo long help message to standard output and exit.
525e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_help ()
526e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
527e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $SED -n '/^# Usage:/,/# Report bugs to/ {
528e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        s/^# //
529e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	s/^# *$//
530e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	s*\$progname*'$progname'*
531e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	s*\$host*'"$host"'*
532e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	s*\$SHELL*'"$SHELL"'*
533e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	s*\$LTCC*'"$LTCC"'*
534e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	s*\$LTCFLAGS*'"$LTCFLAGS"'*
535e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	s*\$LD*'"$LD"'*
536e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	s/\$with_gnu_ld/'"$with_gnu_ld"'/
537e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
538e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
539e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	p
540e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev     }' < "$progpath"
541e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    exit $?
542e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
543e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
544e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_missing_arg argname
545e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Echo program name prefixed message to standard error and set global
546e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# exit_cmd.
547e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_missing_arg ()
548e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
549e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_error "missing argument for $1"
550e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    exit_cmd=exit
551e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
552e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
553e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevexit_cmd=:
554e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
555e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
556e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
557e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
558e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
559e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Check that we have a working $ECHO.
560e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevif test "X$1" = X--no-reexec; then
561e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # Discard the --no-reexec flag, and continue.
562e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  shift
563e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevelif test "X$1" = X--fallback-echo; then
564e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # Avoid inline document here, it may be left over
565e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  :
566e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevelif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then
567e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # Yippee, $ECHO works!
568e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  :
569e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevelse
570e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # Restart under the correct shell, and then maybe $ECHO will work.
571e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
572e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfi
573e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Same for EGREP, and just to be sure, do LTCC as well
574e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevif test "x$EGREP" = x ; then
575e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    EGREP=egrep
576e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfi
577e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevif test "x$LTCC" = x ; then
578e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    LTCC=${CC-gcc}
579e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfi
580e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
581e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevif test "X$1" = X--fallback-echo; then
582e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # used as fallback echo
583e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  shift
584e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  cat <<EOF
585e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev$*
586e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevEOF
587e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  exit $EXIT_SUCCESS
588e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfi
589e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
590e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevmagic="%%%MAGIC variable%%%"
591e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevmagic_exe="%%%MAGIC EXE variable%%%"
592e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
593e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Global variables.
594e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# $mode is unset
595e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevnonopt=
596e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevexecute_dlfiles=
597e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevpreserve_args=
598e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevlo2o="s/\\.lo\$/.${objext}/"
599e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevo2lo="s/\\.${objext}\$/.lo/"
600e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevextracted_archives=
601e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevextracted_serial=0
602e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
603e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevopt_dry_run=false
604e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevopt_duplicate_deps=false
605e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevopt_silent=false
606e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevopt_debug=:
607e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
608e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# If this variable is set in any of the actions, the command in it
609e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# will be execed at the end.  This prevents here-documents from being
610e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# left over by shells.
611e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevexec_cmd=
612e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
613e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_fatal_configuration arg...
614e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Echo program name prefixed message to standard error, followed by
615e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# a configuration failure hint, and exit.
616e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_fatal_configuration ()
617e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
618e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_error ${1+"$@"}
619e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_error "See the $PACKAGE documentation for more information."
620e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_fatal_error "Fatal configuration error."
621e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
622e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
623e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
624e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_config
625e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Display the configuration for all the tags in this script.
626e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_config ()
627e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
628e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    re_begincf='^# ### BEGIN LIBTOOL'
629e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    re_endcf='^# ### END LIBTOOL'
630e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
631e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # Default configuration.
632e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
633e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
634e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # Now print the configurations for the tags.
635e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    for tagname in $taglist; do
636e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
637e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    done
638e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
639e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    exit $?
640e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
641e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
642e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_features
643e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Display the features supported by this script.
644e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_features ()
645e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
646e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $ECHO "host: $host"
647e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test "$build_libtool_libs" = yes; then
648e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      $ECHO "enable shared libraries"
649e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    else
650e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      $ECHO "disable shared libraries"
651e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
652e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test "$build_old_libs" = yes; then
653e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      $ECHO "enable static libraries"
654e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    else
655e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      $ECHO "disable static libraries"
656e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
657e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
658e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    exit $?
659e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
660e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
661e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_enable_tag tagname
662e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Verify that TAGNAME is valid, and either flag an error and exit, or
663e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
664e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# variable here.
665e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_enable_tag ()
666e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
667e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # Global variable:
668e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  tagname="$1"
669e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
670e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
671e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
672e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  sed_extractcf="/$re_begincf/,/$re_endcf/p"
673e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
674e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # Validate tagname.
675e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  case $tagname in
676e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    *[!-_A-Za-z0-9,/]*)
677e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_fatal_error "invalid tag name: $tagname"
678e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      ;;
679e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  esac
680e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
681e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # Don't test for the "default" C tag, as we know it's
682e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # there but not specially marked.
683e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  case $tagname in
684e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    CC) ;;
685e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    *)
686e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
687e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	taglist="$taglist $tagname"
688e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
689e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Evaluate the configuration.  Be careful to quote the path
690e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# and the sed script, to avoid splitting on whitespace, but
691e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# also don't use non-portable quotes within backquotes within
692e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# quotes we have to do it in 2 steps:
693e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
694e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	eval "$extractedcf"
695e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      else
696e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_error "ignoring unknown tag $tagname"
697e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
698e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      ;;
699e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  esac
700e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
701e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
702e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Parse options once, thoroughly.  This comes as soon as possible in
703e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# the script to make things like `libtool --version' happen quickly.
704e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
705e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
706e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # Shorthand for --mode=foo, only valid as the first argument
707e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  case $1 in
708e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  clean|clea|cle|cl)
709e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    shift; set dummy --mode clean ${1+"$@"}; shift
710e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    ;;
711e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  compile|compil|compi|comp|com|co|c)
712e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    shift; set dummy --mode compile ${1+"$@"}; shift
713e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    ;;
714e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  execute|execut|execu|exec|exe|ex|e)
715e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    shift; set dummy --mode execute ${1+"$@"}; shift
716e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    ;;
717e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  finish|finis|fini|fin|fi|f)
718e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    shift; set dummy --mode finish ${1+"$@"}; shift
719e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    ;;
720e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  install|instal|insta|inst|ins|in|i)
721e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    shift; set dummy --mode install ${1+"$@"}; shift
722e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    ;;
723e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  link|lin|li|l)
724e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    shift; set dummy --mode link ${1+"$@"}; shift
725e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    ;;
726e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
727e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    shift; set dummy --mode uninstall ${1+"$@"}; shift
728e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    ;;
729e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  esac
730e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
731e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # Parse non-mode specific arguments:
732e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  while test "$#" -gt 0; do
733e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    opt="$1"
734e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    shift
735e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
736e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    case $opt in
737e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      --config)		func_config					;;
738e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
739e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      --debug)		preserve_args="$preserve_args $opt"
740e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			func_echo "enabling shell trace mode"
741e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			opt_debug='set -x'
742e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			$opt_debug
743e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			;;
744e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
745e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -dlopen)		test "$#" -eq 0 && func_missing_arg "$opt" && break
746e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			execute_dlfiles="$execute_dlfiles $1"
747e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			shift
748e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			;;
749e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
750e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      --dry-run | -n)	opt_dry_run=:					;;
751e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      --features)       func_features					;;
752e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      --finish)		mode="finish"					;;
753e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
754e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      --mode)		test "$#" -eq 0 && func_missing_arg "$opt" && break
755e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			case $1 in
756e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			  # Valid mode arguments:
757e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			  clean)	;;
758e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			  compile)	;;
759e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			  execute)	;;
760e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			  finish)	;;
761e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			  install)	;;
762e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			  link)		;;
763e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			  relink)	;;
764e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			  uninstall)	;;
765e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
766e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			  # Catch anything else as an error
767e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			  *) func_error "invalid argument for $opt"
768e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			     exit_cmd=exit
769e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			     break
770e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			     ;;
771e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		        esac
772e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
773e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			mode="$1"
774e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			shift
775e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			;;
776e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
777e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      --preserve-dup-deps)
778e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			opt_duplicate_deps=:				;;
779e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
780e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      --quiet|--silent)	preserve_args="$preserve_args $opt"
781e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			opt_silent=:
782e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			;;
783e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
784e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      --verbose| -v)	preserve_args="$preserve_args $opt"
785e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			opt_silent=false
786e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			;;
787e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
788e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      --tag)		test "$#" -eq 0 && func_missing_arg "$opt" && break
789e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			preserve_args="$preserve_args $opt $1"
790e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			func_enable_tag "$1"	# tagname is set here
791e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			shift
792e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			;;
793e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
794e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Separate optargs to long options:
795e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -dlopen=*|--mode=*|--tag=*)
796e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			func_opt_split "$opt"
797e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
798e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			shift
799e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			;;
800e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
801e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -\?|-h)		func_usage					;;
802e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      --help)		opt_help=:					;;
803e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      --version)	func_version					;;
804e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
805e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -*)		func_fatal_help "unrecognized option \`$opt'"	;;
806e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
807e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *)		nonopt="$opt"
808e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			break
809e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			;;
810e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    esac
811e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  done
812e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
813e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
814e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  case $host in
815e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    *cygwin* | *mingw* | *pw32* | *cegcc*)
816e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # don't eliminate duplications in $postdeps and $predeps
817e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      opt_duplicate_compiler_generated_deps=:
818e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      ;;
819e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    *)
820e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
821e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      ;;
822e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  esac
823e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
824e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # Having warned about all mis-specified options, bail out if
825e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # anything was wrong.
826e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  $exit_cmd $EXIT_FAILURE
827e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
828e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
829e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_check_version_match
830e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Ensure that we are using m4 macros, and libtool script from the same
831e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# release of libtool.
832e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_check_version_match ()
833e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
834e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if test "$package_revision" != "$macro_revision"; then
835e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test "$VERSION" != "$macro_version"; then
836e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -z "$macro_version"; then
837e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        cat >&2 <<_LT_EOF
838e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
839e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev$progname: definition of this LT_INIT comes from an older release.
840e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
841e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev$progname: and run autoconf again.
842e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev_LT_EOF
843e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      else
844e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        cat >&2 <<_LT_EOF
845e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
846e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
847e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
848e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev$progname: and run autoconf again.
849e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev_LT_EOF
850e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
851e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    else
852e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      cat >&2 <<_LT_EOF
853e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
854e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev$progname: but the definition of this LT_INIT comes from revision $macro_revision.
855e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev$progname: You should recreate aclocal.m4 with macros from revision $package_revision
856e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev$progname: of $PACKAGE $VERSION and run autoconf again.
857e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev_LT_EOF
858e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
859e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
860e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    exit $EXIT_MISMATCH
861e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  fi
862e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
863e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
864e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
865e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev## ----------- ##
866e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev##    Main.    ##
867e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev## ----------- ##
868e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
869e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev$opt_help || {
870e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # Sanity checks first:
871e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  func_check_version_match
872e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
873e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
874e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_fatal_configuration "not configured to build any kind of library"
875e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  fi
876e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
877e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  test -z "$mode" && func_fatal_error "error: you must specify a MODE."
878e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
879e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
880e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # Darwin sucks
881e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  eval std_shrext=\"$shrext_cmds\"
882e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
883e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
884e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # Only execute mode is allowed to have -dlopen flags.
885e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if test -n "$execute_dlfiles" && test "$mode" != execute; then
886e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_error "unrecognized option \`-dlopen'"
887e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $ECHO "$help" 1>&2
888e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    exit $EXIT_FAILURE
889e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  fi
890e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
891e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # Change the help message to a mode-specific one.
892e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  generic_help="$help"
893e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  help="Try \`$progname --help --mode=$mode' for more information."
894e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
895e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
896e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
897e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_lalib_p file
898e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# True iff FILE is a libtool `.la' library or `.lo' object file.
899e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# This function is only a basic sanity check; it will hardly flush out
900e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# determined imposters.
901e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_lalib_p ()
902e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
903e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    test -f "$1" &&
904e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      $SED -e 4q "$1" 2>/dev/null \
905e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
906e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
907e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
908e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_lalib_unsafe_p file
909e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# True iff FILE is a libtool `.la' library or `.lo' object file.
910e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# This function implements the same check as func_lalib_p without
911e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# resorting to external programs.  To this end, it redirects stdin and
912e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# closes it afterwards, without saving the original file descriptor.
913e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# As a safety measure, use it only where a negative result would be
914e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# fatal anyway.  Works if `file' does not exist.
915e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_lalib_unsafe_p ()
916e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
917e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    lalib_p=no
918e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
919e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	for lalib_p_l in 1 2 3 4
920e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	do
921e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    read lalib_p_line
922e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    case "$lalib_p_line" in
923e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
924e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    esac
925e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	done
926e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	exec 0<&5 5<&-
927e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
928e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    test "$lalib_p" = yes
929e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
930e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
931e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_ltwrapper_script_p file
932e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# True iff FILE is a libtool wrapper script
933e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# This function is only a basic sanity check; it will hardly flush out
934e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# determined imposters.
935e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_ltwrapper_script_p ()
936e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
937e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_lalib_p "$1"
938e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
939e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
940e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_ltwrapper_executable_p file
941e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# True iff FILE is a libtool wrapper executable
942e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# This function is only a basic sanity check; it will hardly flush out
943e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# determined imposters.
944e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_ltwrapper_executable_p ()
945e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
946e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_ltwrapper_exec_suffix=
947e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    case $1 in
948e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    *.exe) ;;
949e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    *) func_ltwrapper_exec_suffix=.exe ;;
950e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    esac
951e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
952e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
953e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
954e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_ltwrapper_scriptname file
955e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Assumes file is an ltwrapper_executable
956e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# uses $file to determine the appropriate filename for a
957e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# temporary ltwrapper_script.
958e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_ltwrapper_scriptname ()
959e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
960e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_ltwrapper_scriptname_result=""
961e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if func_ltwrapper_executable_p "$1"; then
962e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_dirname_and_basename "$1" "" "."
963e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_stripname '' '.exe' "$func_basename_result"
964e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
965e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
966e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
967e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
968e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_ltwrapper_p file
969e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# True iff FILE is a libtool wrapper script or wrapper executable
970e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# This function is only a basic sanity check; it will hardly flush out
971e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# determined imposters.
972e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_ltwrapper_p ()
973e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
974e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
975e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
976e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
977e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
978e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_execute_cmds commands fail_cmd
979e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Execute tilde-delimited COMMANDS.
980e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# If FAIL_CMD is given, eval that upon failure.
981e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# FAIL_CMD may read-access the current command in variable CMD!
982e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_execute_cmds ()
983e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
984e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $opt_debug
985e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    save_ifs=$IFS; IFS='~'
986e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    for cmd in $1; do
987e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      IFS=$save_ifs
988e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      eval cmd=\"$cmd\"
989e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_show_eval "$cmd" "${2-:}"
990e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    done
991e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    IFS=$save_ifs
992e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
993e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
994e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
995e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_source file
996e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Source FILE, adding directory component if necessary.
997e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Note that it is not necessary on cygwin/mingw to append a dot to
998e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
999e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# behavior happens only for exec(3), not for open(2)!  Also, sourcing
1000e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# `FILE.' does not work on cygwin managed mounts.
1001e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_source ()
1002e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
1003e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $opt_debug
1004e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    case $1 in
1005e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    */* | *\\*)	. "$1" ;;
1006e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    *)		. "./$1" ;;
1007e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    esac
1008e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
1009e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1010e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1011e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_infer_tag arg
1012e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Infer tagged configuration to use if any are available and
1013e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# if one wasn't chosen via the "--tag" command line option.
1014e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Only attempt this if the compiler in the base compile
1015e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# command doesn't match the default compiler.
1016e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# arg is usually of the form 'gcc ...'
1017e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_infer_tag ()
1018e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
1019e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $opt_debug
1020e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test -n "$available_tags" && test -z "$tagname"; then
1021e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      CC_quoted=
1022e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      for arg in $CC; do
1023e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        func_quote_for_eval "$arg"
1024e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	CC_quoted="$CC_quoted $func_quote_for_eval_result"
1025e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      done
1026e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      case $@ in
1027e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Blanks in the command may have been stripped by the calling shell,
1028e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # but not from the CC environment variable when configure was run.
1029e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;;
1030e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Blanks at the start of $base_compile will cause this to fail
1031e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # if we don't check for them as well.
1032e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *)
1033e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	for z in $available_tags; do
1034e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1035e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Evaluate the configuration.
1036e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1037e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    CC_quoted=
1038e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    for arg in $CC; do
1039e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # Double-quote args containing other shell metacharacters.
1040e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_quote_for_eval "$arg"
1041e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      CC_quoted="$CC_quoted $func_quote_for_eval_result"
1042e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    done
1043e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    case "$@ " in
1044e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*)
1045e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # The compiler in the base compile command matches
1046e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # the one in the tagged configuration.
1047e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # Assume this is the tagged configuration we want.
1048e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      tagname=$z
1049e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      break
1050e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      ;;
1051e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    esac
1052e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
1053e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	done
1054e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# If $tagname still isn't set, then no tagged configuration
1055e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# was found and let the user know that the "--tag" command
1056e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# line option must be used.
1057e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -z "$tagname"; then
1058e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_echo "unable to infer tagged configuration"
1059e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_fatal_error "specify a tag with \`--tag'"
1060e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#	else
1061e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#	  func_verbose "using $tagname tagged configuration"
1062e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
1063e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
1064e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      esac
1065e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
1066e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
1067e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1068e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1069e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1070e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_write_libtool_object output_name pic_name nonpic_name
1071e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Create a libtool object file (analogous to a ".la" file),
1072e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# but don't create it if we're doing a dry run.
1073e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_write_libtool_object ()
1074e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
1075e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    write_libobj=${1}
1076e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test "$build_libtool_libs" = yes; then
1077e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      write_lobj=\'${2}\'
1078e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    else
1079e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      write_lobj=none
1080e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
1081e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1082e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test "$build_old_libs" = yes; then
1083e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      write_oldobj=\'${3}\'
1084e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    else
1085e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      write_oldobj=none
1086e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
1087e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1088e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $opt_dry_run || {
1089e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      cat >${write_libobj}T <<EOF
1090e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# $write_libobj - a libtool object file
1091e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1092e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#
1093e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Please DO NOT delete this file!
1094e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# It is necessary for linking the library.
1095e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1096e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Name of the PIC object.
1097e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevpic_object=$write_lobj
1098e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1099e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Name of the non-PIC object
1100e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevnon_pic_object=$write_oldobj
1101e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1102e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevEOF
1103e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      $MV "${write_libobj}T" "${write_libobj}"
1104e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    }
1105e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
1106e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1107e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_mode_compile arg...
1108e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_mode_compile ()
1109e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
1110e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $opt_debug
1111e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # Get the compilation command and the source file.
1112e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    base_compile=
1113e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
1114e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    suppress_opt=yes
1115e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    suppress_output=
1116e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    arg_mode=normal
1117e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    libobj=
1118e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    later=
1119e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    pie_flag=
1120e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1121e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    for arg
1122e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    do
1123e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      case $arg_mode in
1124e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      arg  )
1125e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# do not "continue".  Instead, add this to base_compile
1126e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	lastarg="$arg"
1127e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	arg_mode=normal
1128e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
1129e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1130e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      target )
1131e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	libobj="$arg"
1132e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	arg_mode=normal
1133e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
1134e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
1135e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1136e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      normal )
1137e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Accept any command-line options.
1138e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $arg in
1139e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	-o)
1140e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  test -n "$libobj" && \
1141e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_fatal_error "you cannot specify \`-o' more than once"
1142e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  arg_mode=target
1143e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
1144e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
1145e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1146e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	-pie | -fpie | -fPIE)
1147e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          pie_flag="$pie_flag $arg"
1148e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
1149e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
1150e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1151e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	-shared | -static | -prefer-pic | -prefer-non-pic)
1152e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  later="$later $arg"
1153e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
1154e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
1155e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1156e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	-no-suppress)
1157e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  suppress_opt=no
1158e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
1159e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
1160e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1161e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	-Xcompiler)
1162e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
1163e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue      #  The current "srcfile" will either be retained or
1164e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;            #  replaced later.  I would guess that would be a bug.
1165e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1166e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	-Wc,*)
1167e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_stripname '-Wc,' '' "$arg"
1168e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  args=$func_stripname_result
1169e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  lastarg=
1170e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  save_ifs="$IFS"; IFS=','
1171e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  for arg in $args; do
1172e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    IFS="$save_ifs"
1173e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_quote_for_eval "$arg"
1174e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    lastarg="$lastarg $func_quote_for_eval_result"
1175e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  done
1176e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  IFS="$save_ifs"
1177e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_stripname ' ' '' "$lastarg"
1178e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  lastarg=$func_stripname_result
1179e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1180e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Add the arguments to base_compile.
1181e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  base_compile="$base_compile $lastarg"
1182e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
1183e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
1184e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1185e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*)
1186e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Accept the current argument as the source file.
1187e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # The previous "srcfile" becomes the current argument.
1188e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  #
1189e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  lastarg="$srcfile"
1190e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  srcfile="$arg"
1191e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
1192e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac  #  case $arg
1193e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
1194e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      esac    #  case $arg_mode
1195e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1196e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Aesthetically quote the previous argument.
1197e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_quote_for_eval "$lastarg"
1198e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      base_compile="$base_compile $func_quote_for_eval_result"
1199e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    done # for arg
1200e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1201e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    case $arg_mode in
1202e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    arg)
1203e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_fatal_error "you must specify an argument for -Xcompile"
1204e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      ;;
1205e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    target)
1206e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_fatal_error "you must specify a target with \`-o'"
1207e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      ;;
1208e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    *)
1209e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Get the name of the library object.
1210e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      test -z "$libobj" && {
1211e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_basename "$srcfile"
1212e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	libobj="$func_basename_result"
1213e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      }
1214e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      ;;
1215e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    esac
1216e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1217e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # Recognize several different file suffixes.
1218e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # If the user specifies -o file.o, it is replaced with file.lo
1219e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    case $libobj in
1220e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    *.[cCFSifmso] | \
1221e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    *.ada | *.adb | *.ads | *.asm | \
1222e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
1223e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    *.[fF][09]? | *.for | *.java | *.obj | *.sx)
1224e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_xform "$libobj"
1225e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      libobj=$func_xform_result
1226e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      ;;
1227e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    esac
1228e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1229e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    case $libobj in
1230e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
1231e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    *)
1232e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_fatal_error "cannot determine name of library object from \`$libobj'"
1233e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      ;;
1234e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    esac
1235e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1236e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_infer_tag $base_compile
1237e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1238e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    for arg in $later; do
1239e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      case $arg in
1240e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -shared)
1241e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	test "$build_libtool_libs" != yes && \
1242e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_fatal_configuration "can not build a shared library"
1243e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	build_old_libs=no
1244e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
1245e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
1246e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1247e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -static)
1248e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	build_libtool_libs=no
1249e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	build_old_libs=yes
1250e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
1251e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
1252e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1253e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -prefer-pic)
1254e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	pic_mode=yes
1255e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
1256e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
1257e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1258e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -prefer-non-pic)
1259e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	pic_mode=no
1260e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
1261e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
1262e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      esac
1263e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    done
1264e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1265e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_quote_for_eval "$libobj"
1266e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    test "X$libobj" != "X$func_quote_for_eval_result" \
1267e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
1268e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      && func_warning "libobj name \`$libobj' may not contain shell special characters."
1269e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_dirname_and_basename "$obj" "/" ""
1270e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    objname="$func_basename_result"
1271e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    xdir="$func_dirname_result"
1272e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    lobj=${xdir}$objdir/$objname
1273e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1274e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    test -z "$base_compile" && \
1275e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_fatal_help "you must specify a compilation command"
1276e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1277e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # Delete any leftover library objects.
1278e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test "$build_old_libs" = yes; then
1279e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      removelist="$obj $lobj $libobj ${libobj}T"
1280e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    else
1281e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      removelist="$lobj $libobj ${libobj}T"
1282e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
1283e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1284e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # On Cygwin there's no "real" PIC flag so we must build both object types
1285e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    case $host_os in
1286e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    cygwin* | mingw* | pw32* | os2* | cegcc*)
1287e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      pic_mode=default
1288e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      ;;
1289e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    esac
1290e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
1291e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # non-PIC code in shared libraries is not supported
1292e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      pic_mode=default
1293e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
1294e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1295e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # Calculate the filename of the output object if compiler does
1296e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # not support -o with -c
1297e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test "$compiler_c_o" = no; then
1298e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
1299e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      lockfile="$output_obj.lock"
1300e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    else
1301e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      output_obj=
1302e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      need_locks=no
1303e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      lockfile=
1304e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
1305e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1306e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # Lock this critical section if it is needed
1307e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # We use this script file to make the link, it avoids creating a new file
1308e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test "$need_locks" = yes; then
1309e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
1310e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_echo "Waiting for $lockfile to be removed"
1311e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	sleep 2
1312e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      done
1313e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    elif test "$need_locks" = warn; then
1314e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -f "$lockfile"; then
1315e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	$ECHO "\
1316e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev*** ERROR, $lockfile exists and contains:
1317e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev`cat $lockfile 2>/dev/null`
1318e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1319e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevThis indicates that another process is trying to use the same
1320e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevtemporary object file, and libtool could not work around it because
1321e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevyour compiler does not support \`-c' and \`-o' together.  If you
1322e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevrepeat this compilation, it may succeed, by chance, but you had better
1323e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevavoid parallel builds (make -j) in this platform, or get a better
1324e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevcompiler."
1325e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1326e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	$opt_dry_run || $RM $removelist
1327e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	exit $EXIT_FAILURE
1328e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
1329e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      removelist="$removelist $output_obj"
1330e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      $ECHO "$srcfile" > "$lockfile"
1331e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
1332e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1333e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $opt_dry_run || $RM $removelist
1334e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    removelist="$removelist $lockfile"
1335e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
1336e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1337e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test -n "$fix_srcfile_path"; then
1338e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      eval srcfile=\"$fix_srcfile_path\"
1339e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
1340e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_quote_for_eval "$srcfile"
1341e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    qsrcfile=$func_quote_for_eval_result
1342e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1343e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # Only build a PIC object if we are building libtool libraries.
1344e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test "$build_libtool_libs" = yes; then
1345e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Without this assignment, base_compile gets emptied.
1346e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fbsd_hideous_sh_bug=$base_compile
1347e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1348e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "$pic_mode" != no; then
1349e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	command="$base_compile $qsrcfile $pic_flag"
1350e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      else
1351e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Don't build PIC code
1352e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	command="$base_compile $qsrcfile"
1353e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
1354e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1355e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_mkdir_p "$xdir$objdir"
1356e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1357e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -z "$output_obj"; then
1358e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Place PIC objects in $objdir
1359e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	command="$command -o $lobj"
1360e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
1361e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1362e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_show_eval_locale "$command"	\
1363e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
1364e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1365e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "$need_locks" = warn &&
1366e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1367e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	$ECHO "\
1368e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev*** ERROR, $lockfile contains:
1369e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev`cat $lockfile 2>/dev/null`
1370e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1371e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevbut it should contain:
1372e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev$srcfile
1373e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1374e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevThis indicates that another process is trying to use the same
1375e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevtemporary object file, and libtool could not work around it because
1376e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevyour compiler does not support \`-c' and \`-o' together.  If you
1377e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevrepeat this compilation, it may succeed, by chance, but you had better
1378e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevavoid parallel builds (make -j) in this platform, or get a better
1379e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevcompiler."
1380e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1381e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	$opt_dry_run || $RM $removelist
1382e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	exit $EXIT_FAILURE
1383e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
1384e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1385e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Just move the object if needed, then go on to compile the next one
1386e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
1387e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_show_eval '$MV "$output_obj" "$lobj"' \
1388e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
1389e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
1390e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1391e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Allow error messages only from the first compilation.
1392e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "$suppress_opt" = yes; then
1393e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	suppress_output=' >/dev/null 2>&1'
1394e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
1395e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
1396e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1397e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # Only build a position-dependent object if we build old libraries.
1398e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test "$build_old_libs" = yes; then
1399e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "$pic_mode" != yes; then
1400e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Don't build PIC code
1401e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	command="$base_compile $qsrcfile$pie_flag"
1402e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      else
1403e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	command="$base_compile $qsrcfile $pic_flag"
1404e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
1405e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "$compiler_c_o" = yes; then
1406e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	command="$command -o $obj"
1407e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
1408e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1409e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Suppress compiler output if we already did a PIC compilation.
1410e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      command="$command$suppress_output"
1411e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_show_eval_locale "$command" \
1412e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
1413e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1414e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "$need_locks" = warn &&
1415e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1416e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	$ECHO "\
1417e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev*** ERROR, $lockfile contains:
1418e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev`cat $lockfile 2>/dev/null`
1419e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1420e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevbut it should contain:
1421e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev$srcfile
1422e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1423e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevThis indicates that another process is trying to use the same
1424e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevtemporary object file, and libtool could not work around it because
1425e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevyour compiler does not support \`-c' and \`-o' together.  If you
1426e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevrepeat this compilation, it may succeed, by chance, but you had better
1427e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevavoid parallel builds (make -j) in this platform, or get a better
1428e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevcompiler."
1429e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1430e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	$opt_dry_run || $RM $removelist
1431e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	exit $EXIT_FAILURE
1432e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
1433e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1434e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Just move the object if needed
1435e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
1436e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_show_eval '$MV "$output_obj" "$obj"' \
1437e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
1438e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
1439e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
1440e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1441e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $opt_dry_run || {
1442e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
1443e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1444e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Unlock the critical section if it was locked
1445e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "$need_locks" != no; then
1446e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	removelist=$lockfile
1447e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        $RM "$lockfile"
1448e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
1449e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    }
1450e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1451e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    exit $EXIT_SUCCESS
1452e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
1453e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1454e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev$opt_help || {
1455e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevtest "$mode" = compile && func_mode_compile ${1+"$@"}
1456e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
1457e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1458e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_mode_help ()
1459e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
1460e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # We need to display help for each of the modes.
1461e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    case $mode in
1462e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      "")
1463e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        # Generic help is extracted from the usage comments
1464e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        # at the start of this file.
1465e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        func_help
1466e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        ;;
1467e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1468e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      clean)
1469e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        $ECHO \
1470e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
1471e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1472e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevRemove files from the build directory.
1473e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1474e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevRM is the name of the program to use to delete files associated with each FILE
1475e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
1476e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevto RM.
1477e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1478e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevIf FILE is a libtool library, object or program, all the files associated
1479e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevwith it are deleted. Otherwise, only FILE itself is deleted using RM."
1480e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        ;;
1481e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1482e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      compile)
1483e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      $ECHO \
1484e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
1485e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1486e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevCompile a source file into a libtool library object.
1487e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1488e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevThis mode accepts the following additional options:
1489e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1490e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
1491e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -no-suppress      do not suppress compiler output for multiple passes
1492e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -prefer-pic       try to building PIC objects only
1493e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -prefer-non-pic   try to building non-PIC objects only
1494e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -shared           do not build a \`.o' file suitable for static linking
1495e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -static           only build a \`.o' file suitable for static linking
1496e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1497e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
1498e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfrom the given SOURCEFILE.
1499e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1500e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevThe output file name is determined by removing the directory component from
1501e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevSOURCEFILE, then substituting the C source code suffix \`.c' with the
1502e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevlibrary object suffix, \`.lo'."
1503e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        ;;
1504e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1505e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      execute)
1506e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        $ECHO \
1507e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
1508e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1509e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevAutomatically set library path, then run a program.
1510e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1511e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevThis mode accepts the following additional options:
1512e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1513e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -dlopen FILE      add the directory containing FILE to the library path
1514e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1515e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevThis mode sets the library path environment variable according to \`-dlopen'
1516e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevflags.
1517e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1518e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevIf any of the ARGS are libtool executable wrappers, then they are translated
1519e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevinto their corresponding uninstalled binary, and any of their required library
1520e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevdirectories are added to the library path.
1521e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1522e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevThen, COMMAND is executed, with ARGS as arguments."
1523e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        ;;
1524e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1525e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      finish)
1526e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        $ECHO \
1527e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
1528e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1529e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevComplete the installation of libtool libraries.
1530e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1531e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevEach LIBDIR is a directory that contains libtool libraries.
1532e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1533e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevThe commands that this mode executes may require superuser privileges.  Use
1534e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevthe \`--dry-run' option if you just want to see what would be executed."
1535e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        ;;
1536e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1537e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      install)
1538e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        $ECHO \
1539e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
1540e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1541e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevInstall executables or libraries.
1542e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1543e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevINSTALL-COMMAND is the installation command.  The first component should be
1544e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulisheveither the \`install' or \`cp' program.
1545e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1546e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevThe following components of INSTALL-COMMAND are treated specially:
1547e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1548e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -inst-prefix PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
1549e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1550e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevThe rest of the components are interpreted as arguments to that command (only
1551e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevBSD-compatible install options are recognized)."
1552e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        ;;
1553e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1554e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      link)
1555e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        $ECHO \
1556e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
1557e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1558e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevLink object files or libraries together to form another library, or to
1559e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevcreate an executable program.
1560e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1561e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevLINK-COMMAND is a command using the C compiler that you would use to create
1562e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulisheva program from several object files.
1563e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1564e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevThe following components of LINK-COMMAND are treated specially:
1565e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1566e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -all-static       do not do any dynamic linking at all
1567e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -avoid-version    do not add a version suffix if possible
1568e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
1569e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
1570e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
1571e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -export-symbols SYMFILE
1572e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev                    try to export only the symbols listed in SYMFILE
1573e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -export-symbols-regex REGEX
1574e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev                    try to export only the symbols matching REGEX
1575e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -LLIBDIR          search LIBDIR for required installed libraries
1576e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -lNAME            OUTPUT-FILE requires the installed library libNAME
1577e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -module           build a library that can dlopened
1578e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -no-fast-install  disable the fast-install mode
1579e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -no-install       link a not-installable executable
1580e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -no-undefined     declare that a library does not refer to external symbols
1581e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
1582e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -objectlist FILE  Use a list of object files found in FILE to specify objects
1583e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -precious-files-regex REGEX
1584e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev                    don't remove output files matching REGEX
1585e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -release RELEASE  specify package release information
1586e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
1587e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
1588e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -shared           only do dynamic linking of libtool libraries
1589e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -shrext SUFFIX    override the standard shared library file extension
1590e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -static           do not do any dynamic linking of uninstalled libtool libraries
1591e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -static-libtool-libs
1592e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev                    do not do any dynamic linking of libtool libraries
1593e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -version-info CURRENT[:REVISION[:AGE]]
1594e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev                    specify library version info [each variable defaults to 0]
1595e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  -weak LIBNAME     declare that the target provides the LIBNAME interface
1596e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1597e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevAll other options (arguments beginning with \`-') are ignored.
1598e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1599e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevEvery other argument is treated as a filename.  Files ending in \`.la' are
1600e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevtreated as uninstalled libtool libraries, other files are standard or library
1601e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevobject files.
1602e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1603e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
1604e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevonly library objects (\`.lo' files) may be specified, and \`-rpath' is
1605e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevrequired, except when creating a convenience library.
1606e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1607e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
1608e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevusing \`ar' and \`ranlib', or on Windows using \`lib'.
1609e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1610e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
1611e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevis created, otherwise an executable program is created."
1612e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        ;;
1613e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1614e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      uninstall)
1615e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        $ECHO \
1616e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
1617e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1618e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevRemove libraries from an installation directory.
1619e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1620e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevRM is the name of the program to use to delete files associated with each FILE
1621e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
1622e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevto RM.
1623e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1624e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevIf FILE is a libtool library, all the files associated with it are deleted.
1625e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevOtherwise, only FILE itself is deleted using RM."
1626e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        ;;
1627e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1628e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *)
1629e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        func_fatal_help "invalid operation mode \`$mode'"
1630e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        ;;
1631e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    esac
1632e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1633e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $ECHO
1634e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $ECHO "Try \`$progname --help' for more information about other modes."
1635e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1636e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    exit $?
1637e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
1638e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1639e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # Now that we've collected a possible --mode arg, show help if necessary
1640e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  $opt_help && func_mode_help
1641e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1642e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1643e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_mode_execute arg...
1644e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_mode_execute ()
1645e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
1646e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $opt_debug
1647e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # The first argument is the command name.
1648e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    cmd="$nonopt"
1649e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    test -z "$cmd" && \
1650e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_fatal_help "you must specify a COMMAND"
1651e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1652e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # Handle -dlopen flags immediately.
1653e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    for file in $execute_dlfiles; do
1654e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      test -f "$file" \
1655e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	|| func_fatal_help "\`$file' is not a file"
1656e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1657e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      dir=
1658e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      case $file in
1659e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *.la)
1660e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Check to see that this really is a libtool archive.
1661e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_lalib_unsafe_p "$file" \
1662e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  || func_fatal_help "\`$lib' is not a valid libtool archive"
1663e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1664e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Read the libtool library.
1665e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	dlname=
1666e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	library_names=
1667e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_source "$file"
1668e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1669e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Skip this library if it cannot be dlopened.
1670e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -z "$dlname"; then
1671e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Warn if it was a shared library.
1672e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  test -n "$library_names" && \
1673e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_warning "\`$file' was not linked with \`-export-dynamic'"
1674e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
1675e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
1676e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1677e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_dirname "$file" "" "."
1678e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	dir="$func_dirname_result"
1679e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1680e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -f "$dir/$objdir/$dlname"; then
1681e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  dir="$dir/$objdir"
1682e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	else
1683e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test ! -f "$dir/$dlname"; then
1684e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
1685e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
1686e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
1687e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
1688e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1689e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *.lo)
1690e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Just add the directory containing the .lo file.
1691e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_dirname "$file" "" "."
1692e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	dir="$func_dirname_result"
1693e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
1694e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1695e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *)
1696e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
1697e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
1698e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
1699e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      esac
1700e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1701e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Get the absolute pathname.
1702e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      absdir=`cd "$dir" && pwd`
1703e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      test -n "$absdir" && dir="$absdir"
1704e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1705e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Now add the directory to shlibpath_var.
1706e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if eval "test -z \"\$$shlibpath_var\""; then
1707e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	eval "$shlibpath_var=\"\$dir\""
1708e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      else
1709e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
1710e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
1711e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    done
1712e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1713e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # This variable tells wrapper scripts just to set shlibpath_var
1714e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # rather than running their programs.
1715e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    libtool_execute_magic="$magic"
1716e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1717e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # Check if any of the arguments is a wrapper script.
1718e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    args=
1719e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    for file
1720e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    do
1721e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      case $file in
1722e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -*) ;;
1723e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *)
1724e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Do a test to see if this is really a libtool program.
1725e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if func_ltwrapper_script_p "$file"; then
1726e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_source "$file"
1727e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Transform arg to wrapped name.
1728e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  file="$progdir/$program"
1729e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	elif func_ltwrapper_executable_p "$file"; then
1730e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_ltwrapper_scriptname "$file"
1731e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_source "$func_ltwrapper_scriptname_result"
1732e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Transform arg to wrapped name.
1733e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  file="$progdir/$program"
1734e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
1735e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
1736e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      esac
1737e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Quote arguments (to preserve shell metacharacters).
1738e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_quote_for_eval "$file"
1739e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      args="$args $func_quote_for_eval_result"
1740e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    done
1741e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1742e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test "X$opt_dry_run" = Xfalse; then
1743e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -n "$shlibpath_var"; then
1744e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Export the shlibpath_var.
1745e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	eval "export $shlibpath_var"
1746e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
1747e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1748e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Restore saved environment variables
1749e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
1750e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      do
1751e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	eval "if test \"\${save_$lt_var+set}\" = set; then
1752e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev                $lt_var=\$save_$lt_var; export $lt_var
1753e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      else
1754e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$lt_unset $lt_var
1755e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      fi"
1756e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      done
1757e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1758e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Now prepare to actually exec the command.
1759e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      exec_cmd="\$cmd$args"
1760e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    else
1761e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Display what would be done.
1762e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -n "$shlibpath_var"; then
1763e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
1764e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	$ECHO "export $shlibpath_var"
1765e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
1766e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      $ECHO "$cmd$args"
1767e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      exit $EXIT_SUCCESS
1768e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
1769e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
1770e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1771e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevtest "$mode" = execute && func_mode_execute ${1+"$@"}
1772e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1773e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1774e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_mode_finish arg...
1775e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_mode_finish ()
1776e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
1777e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $opt_debug
1778e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    libdirs="$nonopt"
1779e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    admincmds=
1780e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1781e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
1782e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      for dir
1783e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      do
1784e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	libdirs="$libdirs $dir"
1785e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      done
1786e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1787e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      for libdir in $libdirs; do
1788e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$finish_cmds"; then
1789e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Do each command in the finish commands.
1790e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
1791e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev'"$cmd"'"'
1792e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
1793e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$finish_eval"; then
1794e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Do the single finish_eval.
1795e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  eval cmds=\"$finish_eval\"
1796e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  $opt_dry_run || eval "$cmds" || admincmds="$admincmds
1797e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev       $cmds"
1798e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
1799e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      done
1800e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
1801e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1802e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # Exit here if they wanted silent mode.
1803e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $opt_silent && exit $EXIT_SUCCESS
1804e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1805e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $ECHO "X----------------------------------------------------------------------" | $Xsed
1806e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $ECHO "Libraries have been installed in:"
1807e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    for libdir in $libdirs; do
1808e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      $ECHO "   $libdir"
1809e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    done
1810e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $ECHO
1811e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $ECHO "If you ever happen to want to link against installed libraries"
1812e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $ECHO "in a given directory, LIBDIR, you must either use libtool, and"
1813e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'"
1814e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $ECHO "flag during linking and do at least one of the following:"
1815e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test -n "$shlibpath_var"; then
1816e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      $ECHO "   - add LIBDIR to the \`$shlibpath_var' environment variable"
1817e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      $ECHO "     during execution"
1818e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
1819e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test -n "$runpath_var"; then
1820e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      $ECHO "   - add LIBDIR to the \`$runpath_var' environment variable"
1821e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      $ECHO "     during linking"
1822e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
1823e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test -n "$hardcode_libdir_flag_spec"; then
1824e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      libdir=LIBDIR
1825e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      eval flag=\"$hardcode_libdir_flag_spec\"
1826e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1827e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      $ECHO "   - use the \`$flag' linker flag"
1828e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
1829e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test -n "$admincmds"; then
1830e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      $ECHO "   - have your system administrator run these commands:$admincmds"
1831e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
1832e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test -f /etc/ld.so.conf; then
1833e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      $ECHO "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
1834e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
1835e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $ECHO
1836e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1837e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $ECHO "See any operating system documentation about shared libraries for"
1838e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    case $host in
1839e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      solaris2.[6789]|solaris2.1[0-9])
1840e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual"
1841e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	$ECHO "pages."
1842e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
1843e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *)
1844e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        $ECHO "more information, such as the ld(1) and ld.so(8) manual pages."
1845e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        ;;
1846e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    esac
1847e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $ECHO "X----------------------------------------------------------------------" | $Xsed
1848e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    exit $EXIT_SUCCESS
1849e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
1850e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1851e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevtest "$mode" = finish && func_mode_finish ${1+"$@"}
1852e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1853e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1854e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_mode_install arg...
1855e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_mode_install ()
1856e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
1857e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $opt_debug
1858e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # There may be an optional sh(1) argument at the beginning of
1859e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # install_prog (especially on Windows NT).
1860e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
1861e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev       # Allow the use of GNU shtool's install command.
1862e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev       $ECHO "X$nonopt" | $GREP shtool >/dev/null; then
1863e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Aesthetically quote it.
1864e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_quote_for_eval "$nonopt"
1865e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      install_prog="$func_quote_for_eval_result "
1866e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      arg=$1
1867e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      shift
1868e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    else
1869e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      install_prog=
1870e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      arg=$nonopt
1871e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
1872e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1873e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # The real first argument should be the name of the installation program.
1874e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # Aesthetically quote it.
1875e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_quote_for_eval "$arg"
1876e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    install_prog="$install_prog$func_quote_for_eval_result"
1877e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1878e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # We need to accept at least all the BSD install flags.
1879e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    dest=
1880e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    files=
1881e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    opts=
1882e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    prev=
1883e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    install_type=
1884e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    isdir=no
1885e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    stripme=
1886e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    for arg
1887e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    do
1888e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -n "$dest"; then
1889e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	files="$files $dest"
1890e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	dest=$arg
1891e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
1892e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
1893e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1894e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      case $arg in
1895e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -d) isdir=yes ;;
1896e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -f)
1897e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case " $install_prog " in
1898e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*[\\\ /]cp\ *) ;;
1899e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*) prev=$arg ;;
1900e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
1901e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
1902e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -g | -m | -o)
1903e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	prev=$arg
1904e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
1905e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -s)
1906e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	stripme=" -s"
1907e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
1908e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
1909e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -*)
1910e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
1911e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *)
1912e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# If the previous option needed an argument, then skip it.
1913e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$prev"; then
1914e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  prev=
1915e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	else
1916e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  dest=$arg
1917e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
1918e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
1919e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
1920e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      esac
1921e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1922e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Aesthetically quote the argument.
1923e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_quote_for_eval "$arg"
1924e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      install_prog="$install_prog $func_quote_for_eval_result"
1925e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    done
1926e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1927e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    test -z "$install_prog" && \
1928e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_fatal_help "you must specify an install program"
1929e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1930e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    test -n "$prev" && \
1931e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_fatal_help "the \`$prev' option requires an argument"
1932e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1933e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test -z "$files"; then
1934e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -z "$dest"; then
1935e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_fatal_help "no file or destination specified"
1936e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      else
1937e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_fatal_help "you must specify a destination"
1938e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
1939e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
1940e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1941e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # Strip any trailing slash from the destination.
1942e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_stripname '' '/' "$dest"
1943e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    dest=$func_stripname_result
1944e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1945e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # Check to see that the destination is a directory.
1946e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    test -d "$dest" && isdir=yes
1947e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test "$isdir" = yes; then
1948e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      destdir="$dest"
1949e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      destname=
1950e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    else
1951e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_dirname_and_basename "$dest" "" "."
1952e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      destdir="$func_dirname_result"
1953e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      destname="$func_basename_result"
1954e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1955e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Not a directory, so check to see that there is only one file specified.
1956e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      set dummy $files; shift
1957e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      test "$#" -gt 1 && \
1958e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_fatal_help "\`$dest' is not a directory"
1959e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
1960e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    case $destdir in
1961e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    [\\/]* | [A-Za-z]:[\\/]*) ;;
1962e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    *)
1963e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      for file in $files; do
1964e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $file in
1965e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*.lo) ;;
1966e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*)
1967e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_fatal_help "\`$destdir' must be an absolute directory name"
1968e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
1969e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
1970e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      done
1971e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      ;;
1972e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    esac
1973e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1974e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # This variable tells wrapper scripts just to set variables rather
1975e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # than running their programs.
1976e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    libtool_install_magic="$magic"
1977e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1978e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    staticlibs=
1979e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    future_libdirs=
1980e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    current_libdirs=
1981e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    for file in $files; do
1982e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1983e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Do each installation.
1984e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      case $file in
1985e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *.$libext)
1986e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Do the static libraries later.
1987e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	staticlibs="$staticlibs $file"
1988e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
1989e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1990e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *.la)
1991e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Check to see that this really is a libtool archive.
1992e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_lalib_unsafe_p "$file" \
1993e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  || func_fatal_help "\`$file' is not a valid libtool archive"
1994e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
1995e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	library_names=
1996e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	old_library=
1997e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	relink_command=
1998e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_source "$file"
1999e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2000e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Add the libdir to current_libdirs if it is the destination.
2001e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "X$destdir" = "X$libdir"; then
2002e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case "$current_libdirs " in
2003e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *" $libdir "*) ;;
2004e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *) current_libdirs="$current_libdirs $libdir" ;;
2005e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
2006e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	else
2007e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Note the libdir as a future libdir.
2008e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case "$future_libdirs " in
2009e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *" $libdir "*) ;;
2010e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *) future_libdirs="$future_libdirs $libdir" ;;
2011e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
2012e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
2013e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2014e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_dirname "$file" "/" ""
2015e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	dir="$func_dirname_result"
2016e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	dir="$dir$objdir"
2017e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2018e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$relink_command"; then
2019e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Determine the prefix the user has applied to our future dir.
2020e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"`
2021e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2022e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Don't allow the user to place us outside of our expected
2023e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # location b/c this prevents finding dependent libraries that
2024e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # are installed to the same prefix.
2025e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # At present, this check doesn't affect windows .dll's that
2026e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # are installed into $libdir/../bin (currently, that works fine)
2027e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # but it's something to keep an eye on.
2028e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  test "$inst_prefix_dir" = "$destdir" && \
2029e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2030e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2031e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -n "$inst_prefix_dir"; then
2032e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Stick the inst_prefix_dir data into the link command.
2033e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2034e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
2035e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"`
2036e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
2037e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2038e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_warning "relinking \`$file'"
2039e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_show_eval "$relink_command" \
2040e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2041e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
2042e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2043e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# See the names of the shared library.
2044e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	set dummy $library_names; shift
2045e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$1"; then
2046e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  realname="$1"
2047e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  shift
2048e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2049e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  srcname="$realname"
2050e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  test -n "$relink_command" && srcname="$realname"T
2051e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2052e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Install the shared library and build the symlinks.
2053e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \
2054e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      'exit $?'
2055e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  tstripme="$stripme"
2056e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case $host_os in
2057e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  cygwin* | mingw* | pw32* | cegcc*)
2058e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    case $realname in
2059e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *.dll.a)
2060e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      tstripme=""
2061e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      ;;
2062e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    esac
2063e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
2064e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
2065e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -n "$tstripme" && test -n "$striplib"; then
2066e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
2067e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
2068e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2069e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$#" -gt 0; then
2070e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Delete the old symlinks, and create new ones.
2071e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Try `ln -sf' first, because the `ln' binary might depend on
2072e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
2073e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # so we also need to try rm && ln -s.
2074e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    for linkname
2075e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    do
2076e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      test "$linkname" != "$realname" \
2077e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
2078e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    done
2079e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
2080e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2081e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Do each command in the postinstall commands.
2082e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  lib="$destdir/$realname"
2083e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_execute_cmds "$postinstall_cmds" 'exit $?'
2084e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
2085e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2086e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Install the pseudo-library for information purposes.
2087e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_basename "$file"
2088e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	name="$func_basename_result"
2089e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	instname="$dir/$name"i
2090e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
2091e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2092e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Maybe install the static library, too.
2093e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
2094e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
2095e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2096e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *.lo)
2097e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Install (i.e. copy) a libtool object.
2098e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2099e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Figure out destination file name, if it wasn't already specified.
2100e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$destname"; then
2101e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  destfile="$destdir/$destname"
2102e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	else
2103e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_basename "$file"
2104e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  destfile="$func_basename_result"
2105e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  destfile="$destdir/$destfile"
2106e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
2107e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2108e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Deduce the name of the destination old-style object file.
2109e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $destfile in
2110e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*.lo)
2111e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_lo2o "$destfile"
2112e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  staticdest=$func_lo2o_result
2113e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
2114e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*.$objext)
2115e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  staticdest="$destfile"
2116e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  destfile=
2117e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
2118e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*)
2119e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
2120e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
2121e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
2122e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2123e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Install the libtool object if requested.
2124e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	test -n "$destfile" && \
2125e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_show_eval "$install_prog $file $destfile" 'exit $?'
2126e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2127e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Install the old object if enabled.
2128e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$build_old_libs" = yes; then
2129e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Deduce the name of the old-style object file.
2130e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_lo2o "$file"
2131e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  staticobj=$func_lo2o_result
2132e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
2133e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
2134e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	exit $EXIT_SUCCESS
2135e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
2136e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2137e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *)
2138e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Figure out destination file name, if it wasn't already specified.
2139e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$destname"; then
2140e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  destfile="$destdir/$destname"
2141e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	else
2142e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_basename "$file"
2143e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  destfile="$func_basename_result"
2144e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  destfile="$destdir/$destfile"
2145e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
2146e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2147e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# If the file is missing, and there is a .exe on the end, strip it
2148e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# because it is most likely a libtool script we actually want to
2149e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# install
2150e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	stripped_ext=""
2151e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $file in
2152e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *.exe)
2153e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test ! -f "$file"; then
2154e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_stripname '' '.exe' "$file"
2155e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      file=$func_stripname_result
2156e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      stripped_ext=".exe"
2157e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
2158e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
2159e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
2160e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2161e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Do a test to see if this is really a libtool program.
2162e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $host in
2163e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*cygwin* | *mingw*)
2164e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if func_ltwrapper_executable_p "$file"; then
2165e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_ltwrapper_scriptname "$file"
2166e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      wrapper=$func_ltwrapper_scriptname_result
2167e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    else
2168e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_stripname '' '.exe' "$file"
2169e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      wrapper=$func_stripname_result
2170e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
2171e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
2172e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*)
2173e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    wrapper=$file
2174e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
2175e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
2176e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if func_ltwrapper_script_p "$wrapper"; then
2177e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  notinst_deplibs=
2178e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  relink_command=
2179e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2180e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_source "$wrapper"
2181e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2182e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Check the variables that should have been set.
2183e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  test -z "$generated_by_libtool_version" && \
2184e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
2185e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2186e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  finalize=yes
2187e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  for lib in $notinst_deplibs; do
2188e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Check to see that each library is installed.
2189e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    libdir=
2190e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test -f "$lib"; then
2191e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_source "$lib"
2192e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
2193e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
2194e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test -n "$libdir" && test ! -f "$libfile"; then
2195e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_warning "\`$lib' has not been installed in \`$libdir'"
2196e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      finalize=no
2197e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
2198e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  done
2199e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2200e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  relink_command=
2201e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_source "$wrapper"
2202e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2203e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  outputname=
2204e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$fast_install" = no && test -n "$relink_command"; then
2205e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $opt_dry_run || {
2206e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      if test "$finalize" = yes; then
2207e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	        tmpdir=`func_mktempdir`
2208e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		func_basename "$file$stripped_ext"
2209e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		file="$func_basename_result"
2210e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	        outputname="$tmpdir/$file"
2211e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	        # Replace the output file specification.
2212e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	        relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
2213e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2214e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	        $opt_silent || {
2215e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	          func_quote_for_expand "$relink_command"
2216e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  eval "func_echo $func_quote_for_expand_result"
2217e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	        }
2218e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	        if eval "$relink_command"; then :
2219e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	          else
2220e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  func_error "error: relink \`$file' with the above command before installing it"
2221e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  $opt_dry_run || ${RM}r "$tmpdir"
2222e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  continue
2223e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	        fi
2224e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	        file="$outputname"
2225e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      else
2226e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	        func_warning "cannot relink \`$file'"
2227e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      fi
2228e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    }
2229e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
2230e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Install the binary that we compiled earlier.
2231e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
2232e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
2233e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
2234e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2235e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# remove .exe since cygwin /usr/bin/install will append another
2236e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# one anyway
2237e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $install_prog,$host in
2238e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*/usr/bin/install*,*cygwin*)
2239e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case $file:$destfile in
2240e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *.exe:*.exe)
2241e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # this is ok
2242e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
2243e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *.exe:*)
2244e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    destfile=$destfile.exe
2245e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
2246e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *:*.exe)
2247e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_stripname '' '.exe' "$destfile"
2248e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    destfile=$func_stripname_result
2249e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
2250e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
2251e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
2252e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
2253e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
2254e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	$opt_dry_run || if test -n "$outputname"; then
2255e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ${RM}r "$tmpdir"
2256e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
2257e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
2258e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      esac
2259e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    done
2260e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2261e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    for file in $staticlibs; do
2262e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_basename "$file"
2263e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      name="$func_basename_result"
2264e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2265e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Set up the ranlib parameters.
2266e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      oldlib="$destdir/$name"
2267e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2268e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
2269e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2270e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -n "$stripme" && test -n "$old_striplib"; then
2271e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_show_eval "$old_striplib $oldlib" 'exit $?'
2272e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
2273e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2274e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Do each command in the postinstall commands.
2275e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
2276e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    done
2277e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2278e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    test -n "$future_libdirs" && \
2279e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_warning "remember to run \`$progname --finish$future_libdirs'"
2280e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2281e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test -n "$current_libdirs"; then
2282e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Maybe just do a dry run.
2283e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      $opt_dry_run && current_libdirs=" -n$current_libdirs"
2284e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
2285e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    else
2286e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      exit $EXIT_SUCCESS
2287e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
2288e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
2289e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2290e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevtest "$mode" = install && func_mode_install ${1+"$@"}
2291e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2292e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2293e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_generate_dlsyms outputname originator pic_p
2294e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Extract symbols from dlprefiles and create ${outputname}S.o with
2295e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# a dlpreopen symbol table.
2296e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_generate_dlsyms ()
2297e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
2298e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $opt_debug
2299e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    my_outputname="$1"
2300e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    my_originator="$2"
2301e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    my_pic_p="${3-no}"
2302e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
2303e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    my_dlsyms=
2304e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2305e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
2306e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -n "$NM" && test -n "$global_symbol_pipe"; then
2307e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	my_dlsyms="${my_outputname}S.c"
2308e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      else
2309e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_error "not configured to extract global symbols from dlpreopened files"
2310e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
2311e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
2312e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2313e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test -n "$my_dlsyms"; then
2314e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      case $my_dlsyms in
2315e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      "") ;;
2316e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *.c)
2317e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Discover the nlist of each of the dlfiles.
2318e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	nlist="$output_objdir/${my_outputname}.nm"
2319e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2320e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
2321e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2322e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Parse the name list into a source file.
2323e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_verbose "creating $output_objdir/$my_dlsyms"
2324e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2325e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
2326e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
2327e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
2328e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2329e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#ifdef __cplusplus
2330e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevextern \"C\" {
2331e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#endif
2332e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2333e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev/* External symbol declarations for the compiler. */\
2334e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev"
2335e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2336e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$dlself" = yes; then
2337e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_verbose "generating symbol list for \`$output'"
2338e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2339e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
2340e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2341e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Add our own program objects to the symbol list.
2342e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
2343e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  for progfile in $progfiles; do
2344e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_verbose "extracting global C symbols from \`$progfile'"
2345e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
2346e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  done
2347e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2348e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -n "$exclude_expsyms"; then
2349e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $opt_dry_run || {
2350e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
2351e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      eval '$MV "$nlist"T "$nlist"'
2352e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    }
2353e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
2354e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2355e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -n "$export_symbols_regex"; then
2356e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $opt_dry_run || {
2357e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
2358e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      eval '$MV "$nlist"T "$nlist"'
2359e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    }
2360e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
2361e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2362e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Prepare the list of exported symbols
2363e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -z "$export_symbols"; then
2364e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    export_symbols="$output_objdir/$outputname.exp"
2365e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $opt_dry_run || {
2366e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $RM $export_symbols
2367e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
2368e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case $host in
2369e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *cygwin* | *mingw* | *cegcc* )
2370e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
2371e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
2372e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	        ;;
2373e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
2374e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    }
2375e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
2376e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $opt_dry_run || {
2377e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
2378e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
2379e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      eval '$MV "$nlist"T "$nlist"'
2380e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case $host in
2381e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	        *cygwin | *mingw* | *cegcc* )
2382e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
2383e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
2384e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	          ;;
2385e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
2386e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    }
2387e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
2388e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
2389e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2390e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	for dlprefile in $dlprefiles; do
2391e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_verbose "extracting global C symbols from \`$dlprefile'"
2392e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_basename "$dlprefile"
2393e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  name="$func_basename_result"
2394e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  $opt_dry_run || {
2395e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    eval '$ECHO ": $name " >> "$nlist"'
2396e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
2397e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  }
2398e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	done
2399e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2400e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	$opt_dry_run || {
2401e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Make sure we have at least an empty file.
2402e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  test -f "$nlist" || : > "$nlist"
2403e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2404e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -n "$exclude_expsyms"; then
2405e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
2406e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $MV "$nlist"T "$nlist"
2407e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
2408e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2409e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Try sorting and uniquifying the output.
2410e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if $GREP -v "^: " < "$nlist" |
2411e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      if sort -k 3 </dev/null >/dev/null 2>&1; then
2412e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		sort -k 3
2413e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      else
2414e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		sort +2
2415e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      fi |
2416e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      uniq > "$nlist"S; then
2417e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    :
2418e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
2419e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $GREP -v "^: " < "$nlist" > "$nlist"S
2420e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
2421e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2422e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -f "$nlist"S; then
2423e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
2424e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
2425e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms"
2426e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
2427e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2428e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  $ECHO >> "$output_objdir/$my_dlsyms" "\
2429e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2430e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev/* The mapping between symbol names and symbols.  */
2431e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevtypedef struct {
2432e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  const char *name;
2433e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  void *address;
2434e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev} lt_dlsymlist;
2435e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev"
2436e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case $host in
2437e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *cygwin* | *mingw* | *cegcc* )
2438e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $ECHO >> "$output_objdir/$my_dlsyms" "\
2439e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev/* DATA imports from DLLs on WIN32 con't be const, because
2440e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev   runtime relocations are performed -- see ld's documentation
2441e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev   on pseudo-relocs.  */"
2442e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    lt_dlsym_const= ;;
2443e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *osf5*)
2444e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    echo >> "$output_objdir/$my_dlsyms" "\
2445e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev/* This system does not cope well with relocations in const data */"
2446e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    lt_dlsym_const= ;;
2447e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *)
2448e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    lt_dlsym_const=const ;;
2449e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
2450e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2451e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  $ECHO >> "$output_objdir/$my_dlsyms" "\
2452e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevextern $lt_dlsym_const lt_dlsymlist
2453e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevlt_${my_prefix}_LTX_preloaded_symbols[];
2454e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev$lt_dlsym_const lt_dlsymlist
2455e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevlt_${my_prefix}_LTX_preloaded_symbols[] =
2456e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{\
2457e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  { \"$my_originator\", (void *) 0 },"
2458e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2459e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case $need_lib_prefix in
2460e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  no)
2461e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
2462e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
2463e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *)
2464e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
2465e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
2466e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
2467e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  $ECHO >> "$output_objdir/$my_dlsyms" "\
2468e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  {0, (void *) 0}
2469e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev};
2470e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2471e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev/* This works around a problem in FreeBSD linker */
2472e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#ifdef FREEBSD_WORKAROUND
2473e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevstatic const void *lt_preloaded_setup() {
2474e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  return lt_${my_prefix}_LTX_preloaded_symbols;
2475e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
2476e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#endif
2477e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2478e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#ifdef __cplusplus
2479e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
2480e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#endif\
2481e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev"
2482e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	} # !$opt_dry_run
2483e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2484e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	pic_flag_for_symtable=
2485e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case "$compile_command " in
2486e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*" -static "*) ;;
2487e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*)
2488e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case $host in
2489e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # compiling the symbol table file with pic_flag works around
2490e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # a FreeBSD bug that causes programs to crash when -lm is
2491e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # linked before any other PIC object.  But we must not use
2492e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # pic_flag when linking with -static.  The problem exists in
2493e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
2494e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
2495e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
2496e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *-*-hpux*)
2497e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    pic_flag_for_symtable=" $pic_flag"  ;;
2498e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *)
2499e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "X$my_pic_p" != Xno; then
2500e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      pic_flag_for_symtable=" $pic_flag"
2501e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
2502e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
2503e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
2504e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
2505e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
2506e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	symtab_cflags=
2507e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	for arg in $LTCFLAGS; do
2508e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case $arg in
2509e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  -pie | -fpie | -fPIE) ;;
2510e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *) symtab_cflags="$symtab_cflags $arg" ;;
2511e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
2512e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	done
2513e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2514e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Now compile the dynamic symbol file.
2515e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
2516e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2517e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Clean up the generated files.
2518e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
2519e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2520e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Transform the symbol file into the correct name.
2521e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	symfileobj="$output_objdir/${my_outputname}S.$objext"
2522e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $host in
2523e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*cygwin* | *mingw* | *cegcc* )
2524e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -f "$output_objdir/$my_outputname.def"; then
2525e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
2526e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
2527e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
2528e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2529e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2530e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
2531e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
2532e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*)
2533e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2534e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2535e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
2536e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
2537e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
2538e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *)
2539e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_fatal_error "unknown suffix for \`$my_dlsyms'"
2540e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
2541e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      esac
2542e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    else
2543e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # We keep going just in case the user didn't refer to
2544e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
2545e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # really was required.
2546e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2547e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Nullify the symbol file.
2548e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
2549e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
2550e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
2551e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
2552e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2553e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_win32_libid arg
2554e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# return the library type of file 'arg'
2555e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#
2556e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Need a lot of goo to handle *both* DLLs and import libs
2557e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Has to be a shell function in order to 'eat' the argument
2558e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# that is supplied when $file_magic_command is called.
2559e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_win32_libid ()
2560e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
2561e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  $opt_debug
2562e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  win32_libid_type="unknown"
2563e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  win32_fileres=`file -L $1 2>/dev/null`
2564e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  case $win32_fileres in
2565e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  *ar\ archive\ import\ library*) # definitely import
2566e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    win32_libid_type="x86 archive import"
2567e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    ;;
2568e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  *ar\ archive*) # could be an import, or static
2569e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
2570e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev       $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
2571e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      win32_nmres=`eval $NM -f posix -A $1 |
2572e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	$SED -n -e '
2573e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    1,100{
2574e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		/ I /{
2575e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    s,.*,import,
2576e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    p
2577e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    q
2578e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		}
2579e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    }'`
2580e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      case $win32_nmres in
2581e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      import*)  win32_libid_type="x86 archive import";;
2582e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *)        win32_libid_type="x86 archive static";;
2583e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      esac
2584e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
2585e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    ;;
2586e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  *DLL*)
2587e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    win32_libid_type="x86 DLL"
2588e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    ;;
2589e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  *executable*) # but shell scripts are "executable" too...
2590e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    case $win32_fileres in
2591e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    *MS\ Windows\ PE\ Intel*)
2592e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      win32_libid_type="x86 DLL"
2593e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      ;;
2594e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    esac
2595e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    ;;
2596e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  esac
2597e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  $ECHO "$win32_libid_type"
2598e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
2599e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2600e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2601e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2602e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_extract_an_archive dir oldlib
2603e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_extract_an_archive ()
2604e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
2605e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $opt_debug
2606e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    f_ex_an_ar_dir="$1"; shift
2607e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    f_ex_an_ar_oldlib="$1"
2608e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?'
2609e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
2610e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev     :
2611e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    else
2612e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
2613e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
2614e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
2615e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2616e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2617e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_extract_archives gentop oldlib ...
2618e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_extract_archives ()
2619e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
2620e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $opt_debug
2621e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    my_gentop="$1"; shift
2622e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    my_oldlibs=${1+"$@"}
2623e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    my_oldobjs=""
2624e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    my_xlib=""
2625e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    my_xabs=""
2626e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    my_xdir=""
2627e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2628e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    for my_xlib in $my_oldlibs; do
2629e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Extract the objects.
2630e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      case $my_xlib in
2631e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
2632e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*) my_xabs=`pwd`"/$my_xlib" ;;
2633e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      esac
2634e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_basename "$my_xlib"
2635e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      my_xlib="$func_basename_result"
2636e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      my_xlib_u=$my_xlib
2637e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      while :; do
2638e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        case " $extracted_archives " in
2639e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*" $my_xlib_u "*)
2640e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_arith $extracted_serial + 1
2641e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  extracted_serial=$func_arith_result
2642e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
2643e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*) break ;;
2644e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
2645e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      done
2646e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      extracted_archives="$extracted_archives $my_xlib_u"
2647e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      my_xdir="$my_gentop/$my_xlib_u"
2648e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2649e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_mkdir_p "$my_xdir"
2650e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2651e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      case $host in
2652e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *-darwin*)
2653e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_verbose "Extracting $my_xabs"
2654e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Do not bother doing anything if just a dry run
2655e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	$opt_dry_run || {
2656e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  darwin_orig_dir=`pwd`
2657e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  cd $my_xdir || exit $?
2658e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  darwin_archive=$my_xabs
2659e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  darwin_curdir=`pwd`
2660e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  darwin_base_archive=`basename "$darwin_archive"`
2661e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
2662e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -n "$darwin_arches"; then
2663e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
2664e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    darwin_arch=
2665e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
2666e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    for darwin_arch in  $darwin_arches ; do
2667e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
2668e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
2669e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
2670e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
2671e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      cd "$darwin_curdir"
2672e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
2673e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    done # $darwin_arches
2674e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
2675e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
2676e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    darwin_file=
2677e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    darwin_files=
2678e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    for darwin_file in $darwin_filelist; do
2679e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
2680e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $LIPO -create -output "$darwin_file" $darwin_files
2681e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    done # $darwin_filelist
2682e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $RM -rf unfat-$$
2683e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    cd "$darwin_orig_dir"
2684e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
2685e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    cd $darwin_orig_dir
2686e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_extract_an_archive "$my_xdir" "$my_xabs"
2687e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi # $darwin_arches
2688e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	} # !$opt_dry_run
2689e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
2690e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *)
2691e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        func_extract_an_archive "$my_xdir" "$my_xabs"
2692e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
2693e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      esac
2694e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
2695e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    done
2696e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2697e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_extract_archives_result="$my_oldobjs"
2698e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
2699e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2700e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2701e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2702e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_emit_wrapper_part1 [arg=no]
2703e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#
2704e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Emit the first part of a libtool wrapper script on stdout.
2705e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# For more information, see the description associated with
2706e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_emit_wrapper(), below.
2707e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_emit_wrapper_part1 ()
2708e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
2709e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_emit_wrapper_part1_arg1=no
2710e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$1" ; then
2711e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_emit_wrapper_part1_arg1=$1
2712e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
2713e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2714e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	$ECHO "\
2715e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#! $SHELL
2716e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2717e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# $output - temporary wrapper script for $objdir/$outputname
2718e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
2719e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#
2720e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# The $output program cannot be directly executed until all the libtool
2721e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# libraries that it depends on are installed.
2722e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#
2723e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# This wrapper script should never be moved out of the build directory.
2724e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# If it is, it will not operate correctly.
2725e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2726e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Sed substitution that helps us do robust quoting.  It backslashifies
2727e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# metacharacters that are still active within double-quoted strings.
2728e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevXsed='${SED} -e 1s/^X//'
2729e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevsed_quote_subst='$sed_quote_subst'
2730e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2731e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Be Bourne compatible
2732e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
2733e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  emulate sh
2734e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  NULLCMD=:
2735e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
2736e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # is contrary to our usage.  Disable this feature.
2737e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  alias -g '\${1+\"\$@\"}'='\"\$@\"'
2738e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  setopt NO_GLOB_SUBST
2739e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevelse
2740e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
2741e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfi
2742e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevBIN_SH=xpg4; export BIN_SH # for Tru64
2743e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevDUALCASE=1; export DUALCASE # for MKS sh
2744e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2745e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# The HP-UX ksh and POSIX shell print the target directory to stdout
2746e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# if CDPATH is set.
2747e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
2748e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2749e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevrelink_command=\"$relink_command\"
2750e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2751e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# This environment variable determines our operation mode.
2752e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevif test \"\$libtool_install_magic\" = \"$magic\"; then
2753e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # install mode needs the following variables:
2754e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  generated_by_libtool_version='$macro_version'
2755e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  notinst_deplibs='$notinst_deplibs'
2756e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevelse
2757e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # When we are sourced in execute mode, \$file and \$ECHO are already set.
2758e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if test \"\$libtool_execute_magic\" != \"$magic\"; then
2759e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    ECHO=\"$qecho\"
2760e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    file=\"\$0\"
2761e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # Make sure echo works.
2762e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test \"X\$1\" = X--no-reexec; then
2763e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Discard the --no-reexec flag, and continue.
2764e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      shift
2765e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then
2766e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Yippee, \$ECHO works!
2767e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      :
2768e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    else
2769e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Restart under the correct shell, and then maybe \$ECHO will work.
2770e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
2771e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
2772e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  fi\
2773e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev"
2774e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	$ECHO "\
2775e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2776e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # Find the directory that this script lives in.
2777e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
2778e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
2779e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2780e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # Follow symbolic links until we get to the real thisdir.
2781e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
2782e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  while test -n \"\$file\"; do
2783e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
2784e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2785e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # If there was a directory component, then change thisdir.
2786e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test \"x\$destdir\" != \"x\$file\"; then
2787e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      case \"\$destdir\" in
2788e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
2789e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *) thisdir=\"\$thisdir/\$destdir\" ;;
2790e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      esac
2791e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
2792e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2793e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
2794e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
2795e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  done
2796e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev"
2797e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
2798e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# end: func_emit_wrapper_part1
2799e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2800e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_emit_wrapper_part2 [arg=no]
2801e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#
2802e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Emit the second part of a libtool wrapper script on stdout.
2803e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# For more information, see the description associated with
2804e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_emit_wrapper(), below.
2805e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_emit_wrapper_part2 ()
2806e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
2807e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_emit_wrapper_part2_arg1=no
2808e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$1" ; then
2809e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_emit_wrapper_part2_arg1=$1
2810e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
2811e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2812e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	$ECHO "\
2813e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2814e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # Usually 'no', except on cygwin/mingw when embedded into
2815e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # the cwrapper.
2816e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_part2_arg1
2817e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
2818e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # special case for '.'
2819e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test \"\$thisdir\" = \".\"; then
2820e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      thisdir=\`pwd\`
2821e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
2822e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # remove .libs from thisdir
2823e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    case \"\$thisdir\" in
2824e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;;
2825e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $objdir )   thisdir=. ;;
2826e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    esac
2827e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  fi
2828e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2829e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  # Try to get the absolute directory name.
2830e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  absdir=\`cd \"\$thisdir\" && pwd\`
2831e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  test -n \"\$absdir\" && thisdir=\"\$absdir\"
2832e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev"
2833e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2834e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$fast_install" = yes; then
2835e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  $ECHO "\
2836e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  program=lt-'$outputname'$exeext
2837e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  progdir=\"\$thisdir/$objdir\"
2838e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2839e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if test ! -f \"\$progdir/\$program\" ||
2840e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
2841e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
2842e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2843e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    file=\"\$\$-\$program\"
2844e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2845e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test ! -d \"\$progdir\"; then
2846e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      $MKDIR \"\$progdir\"
2847e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    else
2848e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      $RM \"\$progdir/\$file\"
2849e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi"
2850e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2851e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  $ECHO "\
2852e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2853e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # relink executable if necessary
2854e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test -n \"\$relink_command\"; then
2855e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
2856e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      else
2857e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	$ECHO \"\$relink_command_output\" >&2
2858e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	$RM \"\$progdir/\$file\"
2859e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	exit 1
2860e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
2861e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
2862e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2863e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
2864e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    { $RM \"\$progdir/\$program\";
2865e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
2866e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $RM \"\$progdir/\$file\"
2867e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  fi"
2868e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	else
2869e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  $ECHO "\
2870e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  program='$outputname'
2871e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  progdir=\"\$thisdir/$objdir\"
2872e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev"
2873e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
2874e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2875e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	$ECHO "\
2876e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2877e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if test -f \"\$progdir/\$program\"; then"
2878e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2879e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Export our shlibpath_var if we have one.
2880e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
2881e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  $ECHO "\
2882e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # Add our own library path to $shlibpath_var
2883e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
2884e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2885e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # Some systems cannot cope with colon-terminated $shlibpath_var
2886e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # The second colon is a workaround for a bug in BeOS R4 sed
2887e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
2888e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2889e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    export $shlibpath_var
2890e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev"
2891e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
2892e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2893e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# fixup the dll searchpath if we need to.
2894e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$dllsearchpath"; then
2895e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  $ECHO "\
2896e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # Add the dll search path components to the executable PATH
2897e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    PATH=$dllsearchpath:\$PATH
2898e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev"
2899e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
2900e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2901e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	$ECHO "\
2902e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test \"\$libtool_execute_magic\" != \"$magic\"; then
2903e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Run the actual program with our arguments.
2904e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev"
2905e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $host in
2906e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Backslashes separate directories on plain windows
2907e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*-*-mingw | *-*-os2* | *-cegcc*)
2908e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  $ECHO "\
2909e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
2910e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev"
2911e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
2912e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2913e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*)
2914e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  $ECHO "\
2915e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      exec \"\$progdir/\$program\" \${1+\"\$@\"}
2916e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev"
2917e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
2918e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
2919e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	$ECHO "\
2920e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
2921e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      exit 1
2922e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
2923e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  else
2924e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # The program doesn't exist.
2925e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
2926e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
2927e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
2928e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    exit 1
2929e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  fi
2930e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfi\
2931e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev"
2932e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
2933e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# end: func_emit_wrapper_part2
2934e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2935e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2936e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_emit_wrapper [arg=no]
2937e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#
2938e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Emit a libtool wrapper script on stdout.
2939e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Don't directly open a file because we may want to
2940e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# incorporate the script contents within a cygwin/mingw
2941e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# wrapper executable.  Must ONLY be called from within
2942e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_mode_link because it depends on a number of variables
2943e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# set therein.
2944e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#
2945e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
2946e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# variable will take.  If 'yes', then the emitted script
2947e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# will assume that the directory in which it is stored is
2948e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# the $objdir directory.  This is a cygwin/mingw-specific
2949e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# behavior.
2950e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_emit_wrapper ()
2951e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
2952e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_emit_wrapper_arg1=no
2953e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$1" ; then
2954e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_emit_wrapper_arg1=$1
2955e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
2956e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2957e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# split this up so that func_emit_cwrapperexe_src
2958e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# can call each part independently.
2959e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_emit_wrapper_part1 "${func_emit_wrapper_arg1}"
2960e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_emit_wrapper_part2 "${func_emit_wrapper_arg1}"
2961e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
2962e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2963e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
2964e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_to_host_path arg
2965e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#
2966e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Convert paths to host format when used with build tools.
2967e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Intended for use with "native" mingw (where libtool itself
2968e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# is running under the msys shell), or in the following cross-
2969e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# build environments:
2970e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#    $build          $host
2971e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#    mingw (msys)    mingw  [e.g. native]
2972e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#    cygwin          mingw
2973e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#    *nix + wine     mingw
2974e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# where wine is equipped with the `winepath' executable.
2975e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# In the native mingw case, the (msys) shell automatically
2976e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# converts paths for any non-msys applications it launches,
2977e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# but that facility isn't available from inside the cwrapper.
2978e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Similar accommodations are necessary for $host mingw and
2979e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# $build cygwin.  Calling this function does no harm for other
2980e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# $host/$build combinations not listed above.
2981e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#
2982e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# ARG is the path (on $build) that should be converted to
2983e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# the proper representation for $host. The result is stored
2984e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# in $func_to_host_path_result.
2985e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_to_host_path ()
2986e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
2987e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  func_to_host_path_result="$1"
2988e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if test -n "$1" ; then
2989e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    case $host in
2990e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *mingw* )
2991e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
2992e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        case $build in
2993e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          *mingw* ) # actually, msys
2994e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            # awkward: cmd appends spaces to result
2995e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            lt_sed_strip_trailing_spaces="s/[ ]*\$//"
2996e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            func_to_host_path_tmp1=`( cmd //c echo "$1" |\
2997e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev              $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
2998e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
2999e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev              $SED -e "$lt_sed_naive_backslashify"`
3000e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            ;;
3001e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          *cygwin* )
3002e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            func_to_host_path_tmp1=`cygpath -w "$1"`
3003e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
3004e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev              $SED -e "$lt_sed_naive_backslashify"`
3005e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            ;;
3006e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          * )
3007e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            # Unfortunately, winepath does not exit with a non-zero
3008e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            # error code, so we are forced to check the contents of
3009e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            # stdout. On the other hand, if the command is not
3010e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            # found, the shell will set an exit code of 127 and print
3011e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            # *an error message* to stdout. So we must check for both
3012e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            # error code of zero AND non-empty stdout, which explains
3013e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            # the odd construction:
3014e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null`
3015e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then
3016e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev              func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
3017e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev                $SED -e "$lt_sed_naive_backslashify"`
3018e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            else
3019e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev              # Allow warning below.
3020e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev              func_to_host_path_result=""
3021e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            fi
3022e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            ;;
3023e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        esac
3024e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        if test -z "$func_to_host_path_result" ; then
3025e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          func_error "Could not determine host path corresponding to"
3026e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          func_error "  '$1'"
3027e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          func_error "Continuing, but uninstalled executables may not work."
3028e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          # Fallback:
3029e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          func_to_host_path_result="$1"
3030e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        fi
3031e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        ;;
3032e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    esac
3033e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  fi
3034e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
3035e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# end: func_to_host_path
3036e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3037e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_to_host_pathlist arg
3038e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#
3039e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Convert pathlists to host format when used with build tools.
3040e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# See func_to_host_path(), above. This function supports the
3041e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# following $build/$host combinations (but does no harm for
3042e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# combinations not listed here):
3043e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#    $build          $host
3044e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#    mingw (msys)    mingw  [e.g. native]
3045e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#    cygwin          mingw
3046e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#    *nix + wine     mingw
3047e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#
3048e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Path separators are also converted from $build format to
3049e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# $host format. If ARG begins or ends with a path separator
3050e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# character, it is preserved (but converted to $host format)
3051e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# on output.
3052e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#
3053e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# ARG is a pathlist (on $build) that should be converted to
3054e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# the proper representation on $host. The result is stored
3055e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# in $func_to_host_pathlist_result.
3056e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_to_host_pathlist ()
3057e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
3058e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  func_to_host_pathlist_result="$1"
3059e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if test -n "$1" ; then
3060e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    case $host in
3061e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *mingw* )
3062e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
3063e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        # Remove leading and trailing path separator characters from
3064e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        # ARG. msys behavior is inconsistent here, cygpath turns them
3065e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        # into '.;' and ';.', and winepath ignores them completely.
3066e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        func_to_host_pathlist_tmp2="$1"
3067e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        # Once set for this call, this variable should not be
3068e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        # reassigned. It is used in tha fallback case.
3069e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        func_to_host_pathlist_tmp1=`echo "$func_to_host_pathlist_tmp2" |\
3070e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          $SED -e 's|^:*||' -e 's|:*$||'`
3071e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        case $build in
3072e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          *mingw* ) # Actually, msys.
3073e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            # Awkward: cmd appends spaces to result.
3074e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            lt_sed_strip_trailing_spaces="s/[ ]*\$//"
3075e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            func_to_host_pathlist_tmp2=`( cmd //c echo "$func_to_host_pathlist_tmp1" |\
3076e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev              $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
3077e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
3078e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev              $SED -e "$lt_sed_naive_backslashify"`
3079e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            ;;
3080e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          *cygwin* )
3081e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            func_to_host_pathlist_tmp2=`cygpath -w -p "$func_to_host_pathlist_tmp1"`
3082e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
3083e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev              $SED -e "$lt_sed_naive_backslashify"`
3084e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            ;;
3085e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          * )
3086e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            # unfortunately, winepath doesn't convert pathlists
3087e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            func_to_host_pathlist_result=""
3088e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            func_to_host_pathlist_oldIFS=$IFS
3089e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            IFS=:
3090e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do
3091e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev              IFS=$func_to_host_pathlist_oldIFS
3092e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev              if test -n "$func_to_host_pathlist_f" ; then
3093e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev                func_to_host_path "$func_to_host_pathlist_f"
3094e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev                if test -n "$func_to_host_path_result" ; then
3095e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev                  if test -z "$func_to_host_pathlist_result" ; then
3096e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev                    func_to_host_pathlist_result="$func_to_host_path_result"
3097e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev                  else
3098e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev                    func_to_host_pathlist_result="$func_to_host_pathlist_result;$func_to_host_path_result"
3099e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev                  fi
3100e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev                fi
3101e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev              fi
3102e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev              IFS=:
3103e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            done
3104e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            IFS=$func_to_host_pathlist_oldIFS
3105e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            ;;
3106e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        esac
3107e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        if test -z "$func_to_host_pathlist_result" ; then
3108e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          func_error "Could not determine the host path(s) corresponding to"
3109e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          func_error "  '$1'"
3110e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          func_error "Continuing, but uninstalled executables may not work."
3111e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          # Fallback. This may break if $1 contains DOS-style drive
3112e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          # specifications. The fix is not to complicate the expression
3113e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          # below, but for the user to provide a working wine installation
3114e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          # with winepath so that path translation in the cross-to-mingw
3115e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          # case works properly.
3116e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          lt_replace_pathsep_nix_to_dos="s|:|;|g"
3117e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\
3118e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            $SED -e "$lt_replace_pathsep_nix_to_dos"`
3119e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        fi
3120e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        # Now, add the leading and trailing path separators back
3121e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        case "$1" in
3122e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result"
3123e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            ;;
3124e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        esac
3125e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        case "$1" in
3126e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          *: ) func_to_host_pathlist_result="$func_to_host_pathlist_result;"
3127e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            ;;
3128e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        esac
3129e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        ;;
3130e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    esac
3131e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  fi
3132e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
3133e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# end: func_to_host_pathlist
3134e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3135e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_emit_cwrapperexe_src
3136e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# emit the source code for a wrapper executable on stdout
3137e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Must ONLY be called from within func_mode_link because
3138e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# it depends on a number of variable set therein.
3139e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_emit_cwrapperexe_src ()
3140e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
3141e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	cat <<EOF
3142e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3143e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
3144e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
3145e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3146e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev   The $output program cannot be directly executed until all the libtool
3147e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev   libraries that it depends on are installed.
3148e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3149e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev   This wrapper executable should never be moved out of the build directory.
3150e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev   If it is, it will not operate correctly.
3151e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3152e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev   Currently, it simply execs the wrapper *script* "$SHELL $output",
3153e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev   but could eventually absorb all of the scripts functionality and
3154e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev   exec $objdir/$outputname directly.
3155e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev*/
3156e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevEOF
3157e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    cat <<"EOF"
3158e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#include <stdio.h>
3159e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#include <stdlib.h>
3160e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#ifdef _MSC_VER
3161e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# include <direct.h>
3162e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# include <process.h>
3163e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# include <io.h>
3164e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# define setmode _setmode
3165e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#else
3166e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# include <unistd.h>
3167e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# include <stdint.h>
3168e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# ifdef __CYGWIN__
3169e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#  include <io.h>
3170e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#  define HAVE_SETENV
3171e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#  ifdef __STRICT_ANSI__
3172e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevchar *realpath (const char *, char *);
3173e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevint putenv (char *);
3174e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevint setenv (const char *, const char *, int);
3175e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#  endif
3176e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# endif
3177e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#endif
3178e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#include <malloc.h>
3179e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#include <stdarg.h>
3180e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#include <assert.h>
3181e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#include <string.h>
3182e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#include <ctype.h>
3183e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#include <errno.h>
3184e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#include <fcntl.h>
3185e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#include <sys/stat.h>
3186e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3187e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#if defined(PATH_MAX)
3188e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# define LT_PATHMAX PATH_MAX
3189e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#elif defined(MAXPATHLEN)
3190e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# define LT_PATHMAX MAXPATHLEN
3191e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#else
3192e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# define LT_PATHMAX 1024
3193e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#endif
3194e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3195e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#ifndef S_IXOTH
3196e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# define S_IXOTH 0
3197e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#endif
3198e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#ifndef S_IXGRP
3199e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# define S_IXGRP 0
3200e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#endif
3201e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3202e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#ifdef _MSC_VER
3203e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# define S_IXUSR _S_IEXEC
3204e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# define stat _stat
3205e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# ifndef _INTPTR_T_DEFINED
3206e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#  define intptr_t int
3207e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# endif
3208e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#endif
3209e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3210e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#ifndef DIR_SEPARATOR
3211e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# define DIR_SEPARATOR '/'
3212e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# define PATH_SEPARATOR ':'
3213e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#endif
3214e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3215e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
3216e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  defined (__OS2__)
3217e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# define HAVE_DOS_BASED_FILE_SYSTEM
3218e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# define FOPEN_WB "wb"
3219e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# ifndef DIR_SEPARATOR_2
3220e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#  define DIR_SEPARATOR_2 '\\'
3221e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# endif
3222e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# ifndef PATH_SEPARATOR_2
3223e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#  define PATH_SEPARATOR_2 ';'
3224e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# endif
3225e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#endif
3226e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3227e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#ifndef DIR_SEPARATOR_2
3228e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
3229e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#else /* DIR_SEPARATOR_2 */
3230e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# define IS_DIR_SEPARATOR(ch) \
3231e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
3232e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#endif /* DIR_SEPARATOR_2 */
3233e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3234e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#ifndef PATH_SEPARATOR_2
3235e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
3236e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#else /* PATH_SEPARATOR_2 */
3237e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
3238e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#endif /* PATH_SEPARATOR_2 */
3239e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3240e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#ifdef __CYGWIN__
3241e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# define FOPEN_WB "wb"
3242e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#endif
3243e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3244e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#ifndef FOPEN_WB
3245e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# define FOPEN_WB "w"
3246e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#endif
3247e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#ifndef _O_BINARY
3248e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# define _O_BINARY 0
3249e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#endif
3250e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3251e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
3252e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#define XFREE(stale) do { \
3253e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if (stale) { free ((void *) stale); stale = 0; } \
3254e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev} while (0)
3255e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3256e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#undef LTWRAPPER_DEBUGPRINTF
3257e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#if defined DEBUGWRAPPER
3258e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args
3259e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevstatic void
3260e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevltwrapper_debugprintf (const char *fmt, ...)
3261e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
3262e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    va_list args;
3263e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    va_start (args, fmt);
3264e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    (void) vfprintf (stderr, fmt, args);
3265e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    va_end (args);
3266e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
3267e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#else
3268e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# define LTWRAPPER_DEBUGPRINTF(args)
3269e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#endif
3270e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3271e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevconst char *program_name = NULL;
3272e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3273e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevvoid *xmalloc (size_t num);
3274e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevchar *xstrdup (const char *string);
3275e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevconst char *base_name (const char *name);
3276e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevchar *find_executable (const char *wrapper);
3277e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevchar *chase_symlinks (const char *pathspec);
3278e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevint make_executable (const char *path);
3279e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevint check_executable (const char *path);
3280e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevchar *strendzap (char *str, const char *pat);
3281e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevvoid lt_fatal (const char *message, ...);
3282e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevvoid lt_setenv (const char *name, const char *value);
3283e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
3284e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevvoid lt_opt_process_env_set (const char *arg);
3285e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevvoid lt_opt_process_env_prepend (const char *arg);
3286e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevvoid lt_opt_process_env_append (const char *arg);
3287e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevint lt_split_name_value (const char *arg, char** name, char** value);
3288e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevvoid lt_update_exe_path (const char *name, const char *value);
3289e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevvoid lt_update_lib_path (const char *name, const char *value);
3290e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3291e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevstatic const char *script_text_part1 =
3292e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevEOF
3293e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3294e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_emit_wrapper_part1 yes |
3295e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	        $SED -e 's/\([\\"]\)/\\\1/g' \
3296e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	             -e 's/^/  "/' -e 's/$/\\n"/'
3297e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    echo ";"
3298e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    cat <<EOF
3299e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3300e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevstatic const char *script_text_part2 =
3301e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevEOF
3302e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_emit_wrapper_part2 yes |
3303e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	        $SED -e 's/\([\\"]\)/\\\1/g' \
3304e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	             -e 's/^/  "/' -e 's/$/\\n"/'
3305e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    echo ";"
3306e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3307e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    cat <<EOF
3308e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevconst char * MAGIC_EXE = "$magic_exe";
3309e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevconst char * LIB_PATH_VARNAME = "$shlibpath_var";
3310e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevEOF
3311e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3312e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
3313e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev              func_to_host_pathlist "$temp_rpath"
3314e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      cat <<EOF
3315e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevconst char * LIB_PATH_VALUE   = "$func_to_host_pathlist_result";
3316e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevEOF
3317e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    else
3318e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      cat <<"EOF"
3319e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevconst char * LIB_PATH_VALUE   = "";
3320e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevEOF
3321e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
3322e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3323e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test -n "$dllsearchpath"; then
3324e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev              func_to_host_pathlist "$dllsearchpath:"
3325e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      cat <<EOF
3326e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevconst char * EXE_PATH_VARNAME = "PATH";
3327e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevconst char * EXE_PATH_VALUE   = "$func_to_host_pathlist_result";
3328e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevEOF
3329e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    else
3330e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      cat <<"EOF"
3331e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevconst char * EXE_PATH_VARNAME = "";
3332e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevconst char * EXE_PATH_VALUE   = "";
3333e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevEOF
3334e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
3335e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3336e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "$fast_install" = yes; then
3337e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      cat <<EOF
3338e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
3339e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevEOF
3340e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    else
3341e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      cat <<EOF
3342e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
3343e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevEOF
3344e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
3345e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3346e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3347e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    cat <<"EOF"
3348e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3349e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#define LTWRAPPER_OPTION_PREFIX         "--lt-"
3350e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#define LTWRAPPER_OPTION_PREFIX_LENGTH  5
3351e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3352e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevstatic const size_t opt_prefix_len         = LTWRAPPER_OPTION_PREFIX_LENGTH;
3353e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
3354e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3355e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
3356e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3357e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevstatic const size_t env_set_opt_len     = LTWRAPPER_OPTION_PREFIX_LENGTH + 7;
3358e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevstatic const char *env_set_opt          = LTWRAPPER_OPTION_PREFIX "env-set";
3359e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  /* argument is putenv-style "foo=bar", value of foo is set to bar */
3360e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3361e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevstatic const size_t env_prepend_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 11;
3362e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevstatic const char *env_prepend_opt      = LTWRAPPER_OPTION_PREFIX "env-prepend";
3363e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  /* argument is putenv-style "foo=bar", new value of foo is bar${foo} */
3364e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3365e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevstatic const size_t env_append_opt_len  = LTWRAPPER_OPTION_PREFIX_LENGTH + 10;
3366e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevstatic const char *env_append_opt       = LTWRAPPER_OPTION_PREFIX "env-append";
3367e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  /* argument is putenv-style "foo=bar", new value of foo is ${foo}bar */
3368e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3369e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevint
3370e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevmain (int argc, char *argv[])
3371e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
3372e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  char **newargz;
3373e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  int  newargc;
3374e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  char *tmp_pathspec;
3375e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  char *actual_cwrapper_path;
3376e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  char *actual_cwrapper_name;
3377e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  char *target_name;
3378e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  char *lt_argv_zero;
3379e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  intptr_t rval = 127;
3380e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3381e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  int i;
3382e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3383e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  program_name = (char *) xstrdup (base_name (argv[0]));
3384e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  LTWRAPPER_DEBUGPRINTF (("(main) argv[0]      : %s\n", argv[0]));
3385e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  LTWRAPPER_DEBUGPRINTF (("(main) program_name : %s\n", program_name));
3386e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3387e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  /* very simple arg parsing; don't want to rely on getopt */
3388e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  for (i = 1; i < argc; i++)
3389e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    {
3390e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if (strcmp (argv[i], dumpscript_opt) == 0)
3391e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	{
3392e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevEOF
3393e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    case "$host" in
3394e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *mingw* | *cygwin* )
3395e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		# make stdout use "unix" line endings
3396e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		echo "          setmode(1,_O_BINARY);"
3397e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		;;
3398e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
3399e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3400e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    cat <<"EOF"
3401e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  printf ("%s", script_text_part1);
3402e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  printf ("%s", script_text_part2);
3403e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  return 0;
3404e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	}
3405e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    }
3406e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3407e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  newargz = XMALLOC (char *, argc + 1);
3408e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  tmp_pathspec = find_executable (argv[0]);
3409e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if (tmp_pathspec == NULL)
3410e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    lt_fatal ("Couldn't find %s", argv[0]);
3411e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  LTWRAPPER_DEBUGPRINTF (("(main) found exe (before symlink chase) at : %s\n",
3412e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			  tmp_pathspec));
3413e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3414e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
3415e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  LTWRAPPER_DEBUGPRINTF (("(main) found exe (after symlink chase) at : %s\n",
3416e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			  actual_cwrapper_path));
3417e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  XFREE (tmp_pathspec);
3418e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3419e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  actual_cwrapper_name = xstrdup( base_name (actual_cwrapper_path));
3420e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  strendzap (actual_cwrapper_path, actual_cwrapper_name);
3421e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3422e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  /* wrapper name transforms */
3423e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  strendzap (actual_cwrapper_name, ".exe");
3424e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
3425e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  XFREE (actual_cwrapper_name);
3426e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  actual_cwrapper_name = tmp_pathspec;
3427e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  tmp_pathspec = 0;
3428e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3429e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  /* target_name transforms -- use actual target program name; might have lt- prefix */
3430e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
3431e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  strendzap (target_name, ".exe");
3432e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
3433e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  XFREE (target_name);
3434e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  target_name = tmp_pathspec;
3435e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  tmp_pathspec = 0;
3436e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3437e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  LTWRAPPER_DEBUGPRINTF (("(main) libtool target name: %s\n",
3438e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			  target_name));
3439e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevEOF
3440e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3441e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    cat <<EOF
3442e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  newargz[0] =
3443e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    XMALLOC (char, (strlen (actual_cwrapper_path) +
3444e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
3445e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  strcpy (newargz[0], actual_cwrapper_path);
3446e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  strcat (newargz[0], "$objdir");
3447e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  strcat (newargz[0], "/");
3448e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevEOF
3449e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3450e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    cat <<"EOF"
3451e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  /* stop here, and copy so we don't have to do this twice */
3452e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  tmp_pathspec = xstrdup (newargz[0]);
3453e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3454e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
3455e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  strcat (newargz[0], actual_cwrapper_name);
3456e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3457e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  /* DO want the lt- prefix here if it exists, so use target_name */
3458e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
3459e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  XFREE (tmp_pathspec);
3460e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  tmp_pathspec = NULL;
3461e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevEOF
3462e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3463e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    case $host_os in
3464e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      mingw*)
3465e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    cat <<"EOF"
3466e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  {
3467e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    char* p;
3468e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    while ((p = strchr (newargz[0], '\\')) != NULL)
3469e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      {
3470e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*p = '/';
3471e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      }
3472e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
3473e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      {
3474e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*p = '/';
3475e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      }
3476e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  }
3477e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevEOF
3478e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
3479e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    esac
3480e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3481e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    cat <<"EOF"
3482e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  XFREE (target_name);
3483e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  XFREE (actual_cwrapper_path);
3484e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  XFREE (actual_cwrapper_name);
3485e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3486e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
3487e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
3488e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
3489e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
3490e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3491e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  newargc=0;
3492e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  for (i = 1; i < argc; i++)
3493e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    {
3494e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if (strncmp (argv[i], env_set_opt, env_set_opt_len) == 0)
3495e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        {
3496e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          if (argv[i][env_set_opt_len] == '=')
3497e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            {
3498e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev              const char *p = argv[i] + env_set_opt_len + 1;
3499e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev              lt_opt_process_env_set (p);
3500e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            }
3501e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          else if (argv[i][env_set_opt_len] == '\0' && i + 1 < argc)
3502e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            {
3503e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev              lt_opt_process_env_set (argv[++i]); /* don't copy */
3504e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            }
3505e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          else
3506e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            lt_fatal ("%s missing required argument", env_set_opt);
3507e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          continue;
3508e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        }
3509e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if (strncmp (argv[i], env_prepend_opt, env_prepend_opt_len) == 0)
3510e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        {
3511e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          if (argv[i][env_prepend_opt_len] == '=')
3512e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            {
3513e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev              const char *p = argv[i] + env_prepend_opt_len + 1;
3514e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev              lt_opt_process_env_prepend (p);
3515e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            }
3516e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          else if (argv[i][env_prepend_opt_len] == '\0' && i + 1 < argc)
3517e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            {
3518e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev              lt_opt_process_env_prepend (argv[++i]); /* don't copy */
3519e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            }
3520e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          else
3521e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            lt_fatal ("%s missing required argument", env_prepend_opt);
3522e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          continue;
3523e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        }
3524e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if (strncmp (argv[i], env_append_opt, env_append_opt_len) == 0)
3525e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        {
3526e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          if (argv[i][env_append_opt_len] == '=')
3527e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            {
3528e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev              const char *p = argv[i] + env_append_opt_len + 1;
3529e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev              lt_opt_process_env_append (p);
3530e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            }
3531e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          else if (argv[i][env_append_opt_len] == '\0' && i + 1 < argc)
3532e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            {
3533e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev              lt_opt_process_env_append (argv[++i]); /* don't copy */
3534e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            }
3535e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          else
3536e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            lt_fatal ("%s missing required argument", env_append_opt);
3537e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          continue;
3538e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        }
3539e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if (strncmp (argv[i], ltwrapper_option_prefix, opt_prefix_len) == 0)
3540e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        {
3541e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
3542e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev             namespace, but it is not one of the ones we know about and
3543e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev             have already dealt with, above (inluding dump-script), then
3544e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev             report an error. Otherwise, targets might begin to believe
3545e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
3546e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev             namespace. The first time any user complains about this, we'll
3547e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
3548e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev             or a configure.ac-settable value.
3549e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev           */
3550e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          lt_fatal ("Unrecognized option in %s namespace: '%s'",
3551e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev                    ltwrapper_option_prefix, argv[i]);
3552e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        }
3553e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      /* otherwise ... */
3554e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      newargz[++newargc] = xstrdup (argv[i]);
3555e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    }
3556e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  newargz[++newargc] = NULL;
3557e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3558e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  LTWRAPPER_DEBUGPRINTF     (("(main) lt_argv_zero : %s\n", (lt_argv_zero ? lt_argv_zero : "<NULL>")));
3559e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  for (i = 0; i < newargc; i++)
3560e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    {
3561e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d]   : %s\n", i, (newargz[i] ? newargz[i] : "<NULL>")));
3562e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    }
3563e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3564e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevEOF
3565e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3566e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    case $host_os in
3567e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      mingw*)
3568e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		cat <<"EOF"
3569e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  /* execv doesn't actually work on mingw as expected on unix */
3570e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
3571e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if (rval == -1)
3572e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    {
3573e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      /* failed to start process */
3574e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno));
3575e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      return 127;
3576e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    }
3577e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  return rval;
3578e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevEOF
3579e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		;;
3580e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *)
3581e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		cat <<"EOF"
3582e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  execv (lt_argv_zero, newargz);
3583e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  return rval; /* =127, but avoids unused variable warning */
3584e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevEOF
3585e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		;;
3586e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    esac
3587e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3588e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    cat <<"EOF"
3589e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
3590e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3591e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevvoid *
3592e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevxmalloc (size_t num)
3593e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
3594e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  void *p = (void *) malloc (num);
3595e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if (!p)
3596e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    lt_fatal ("Memory exhausted");
3597e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3598e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  return p;
3599e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
3600e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3601e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevchar *
3602e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevxstrdup (const char *string)
3603e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
3604e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
3605e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			  string) : NULL;
3606e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
3607e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3608e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevconst char *
3609e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevbase_name (const char *name)
3610e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
3611e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  const char *base;
3612e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3613e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3614e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  /* Skip over the disk name in MSDOS pathnames. */
3615e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
3616e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    name += 2;
3617e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#endif
3618e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3619e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  for (base = name; *name; name++)
3620e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if (IS_DIR_SEPARATOR (*name))
3621e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      base = name + 1;
3622e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  return base;
3623e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
3624e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3625e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevint
3626e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevcheck_executable (const char *path)
3627e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
3628e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  struct stat st;
3629e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3630e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  LTWRAPPER_DEBUGPRINTF (("(check_executable)  : %s\n",
3631e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			  path ? (*path ? path : "EMPTY!") : "NULL!"));
3632e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if ((!path) || (!*path))
3633e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    return 0;
3634e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3635e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if ((stat (path, &st) >= 0)
3636e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
3637e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    return 1;
3638e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  else
3639e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    return 0;
3640e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
3641e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3642e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevint
3643e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevmake_executable (const char *path)
3644e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
3645e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  int rval = 0;
3646e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  struct stat st;
3647e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3648e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  LTWRAPPER_DEBUGPRINTF (("(make_executable)   : %s\n",
3649e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			  path ? (*path ? path : "EMPTY!") : "NULL!"));
3650e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if ((!path) || (!*path))
3651e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    return 0;
3652e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3653e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if (stat (path, &st) >= 0)
3654e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    {
3655e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
3656e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    }
3657e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  return rval;
3658e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
3659e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3660e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev/* Searches for the full path of the wrapper.  Returns
3661e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev   newly allocated full path name if found, NULL otherwise
3662e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev   Does not chase symlinks, even on platforms that support them.
3663e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev*/
3664e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevchar *
3665e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfind_executable (const char *wrapper)
3666e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
3667e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  int has_slash = 0;
3668e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  const char *p;
3669e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  const char *p_next;
3670e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  /* static buffer for getcwd */
3671e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  char tmp[LT_PATHMAX + 1];
3672e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  int tmp_len;
3673e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  char *concat_name;
3674e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3675e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  LTWRAPPER_DEBUGPRINTF (("(find_executable)   : %s\n",
3676e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			  wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"));
3677e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3678e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if ((wrapper == NULL) || (*wrapper == '\0'))
3679e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    return NULL;
3680e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3681e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  /* Absolute path? */
3682e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3683e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
3684e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    {
3685e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      concat_name = xstrdup (wrapper);
3686e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if (check_executable (concat_name))
3687e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	return concat_name;
3688e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      XFREE (concat_name);
3689e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    }
3690e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  else
3691e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    {
3692e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#endif
3693e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if (IS_DIR_SEPARATOR (wrapper[0]))
3694e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	{
3695e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  concat_name = xstrdup (wrapper);
3696e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if (check_executable (concat_name))
3697e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    return concat_name;
3698e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  XFREE (concat_name);
3699e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	}
3700e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3701e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    }
3702e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#endif
3703e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3704e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  for (p = wrapper; *p; p++)
3705e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if (*p == '/')
3706e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      {
3707e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	has_slash = 1;
3708e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	break;
3709e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      }
3710e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if (!has_slash)
3711e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    {
3712e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      /* no slashes; search PATH */
3713e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      const char *path = getenv ("PATH");
3714e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if (path != NULL)
3715e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	{
3716e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  for (p = path; *p; p = p_next)
3717e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    {
3718e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      const char *q;
3719e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      size_t p_len;
3720e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      for (q = p; *q; q++)
3721e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		if (IS_PATH_SEPARATOR (*q))
3722e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  break;
3723e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      p_len = q - p;
3724e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      p_next = (*q == '\0' ? q : q + 1);
3725e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      if (p_len == 0)
3726e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		{
3727e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  /* empty path: current directory */
3728e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  if (getcwd (tmp, LT_PATHMAX) == NULL)
3729e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    lt_fatal ("getcwd failed");
3730e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  tmp_len = strlen (tmp);
3731e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  concat_name =
3732e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
3733e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  memcpy (concat_name, tmp, tmp_len);
3734e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  concat_name[tmp_len] = '/';
3735e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  strcpy (concat_name + tmp_len + 1, wrapper);
3736e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		}
3737e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      else
3738e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		{
3739e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  concat_name =
3740e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
3741e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  memcpy (concat_name, p, p_len);
3742e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  concat_name[p_len] = '/';
3743e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  strcpy (concat_name + p_len + 1, wrapper);
3744e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		}
3745e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      if (check_executable (concat_name))
3746e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		return concat_name;
3747e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      XFREE (concat_name);
3748e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    }
3749e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	}
3750e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      /* not found in PATH; assume curdir */
3751e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    }
3752e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  /* Relative path | not found in path: prepend cwd */
3753e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if (getcwd (tmp, LT_PATHMAX) == NULL)
3754e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    lt_fatal ("getcwd failed");
3755e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  tmp_len = strlen (tmp);
3756e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
3757e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  memcpy (concat_name, tmp, tmp_len);
3758e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  concat_name[tmp_len] = '/';
3759e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  strcpy (concat_name + tmp_len + 1, wrapper);
3760e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3761e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if (check_executable (concat_name))
3762e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    return concat_name;
3763e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  XFREE (concat_name);
3764e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  return NULL;
3765e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
3766e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3767e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevchar *
3768e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevchase_symlinks (const char *pathspec)
3769e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
3770e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#ifndef S_ISLNK
3771e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  return xstrdup (pathspec);
3772e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#else
3773e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  char buf[LT_PATHMAX];
3774e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  struct stat s;
3775e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  char *tmp_pathspec = xstrdup (pathspec);
3776e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  char *p;
3777e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  int has_symlinks = 0;
3778e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  while (strlen (tmp_pathspec) && !has_symlinks)
3779e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    {
3780e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n",
3781e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			      tmp_pathspec));
3782e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if (lstat (tmp_pathspec, &s) == 0)
3783e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	{
3784e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if (S_ISLNK (s.st_mode) != 0)
3785e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    {
3786e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      has_symlinks = 1;
3787e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      break;
3788e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    }
3789e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3790e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  /* search backwards for last DIR_SEPARATOR */
3791e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
3792e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
3793e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    p--;
3794e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
3795e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    {
3796e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      /* no more DIR_SEPARATORS left */
3797e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      break;
3798e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    }
3799e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *p = '\0';
3800e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	}
3801e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      else
3802e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	{
3803e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  char *errstr = strerror (errno);
3804e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr);
3805e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	}
3806e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    }
3807e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  XFREE (tmp_pathspec);
3808e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3809e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if (!has_symlinks)
3810e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    {
3811e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      return xstrdup (pathspec);
3812e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    }
3813e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3814e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  tmp_pathspec = realpath (pathspec, buf);
3815e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if (tmp_pathspec == 0)
3816e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    {
3817e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      lt_fatal ("Could not follow symlinks for %s", pathspec);
3818e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    }
3819e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  return xstrdup (tmp_pathspec);
3820e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#endif
3821e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
3822e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3823e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevchar *
3824e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevstrendzap (char *str, const char *pat)
3825e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
3826e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  size_t len, patlen;
3827e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3828e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  assert (str != NULL);
3829e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  assert (pat != NULL);
3830e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3831e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  len = strlen (str);
3832e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  patlen = strlen (pat);
3833e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3834e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if (patlen <= len)
3835e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    {
3836e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      str += len - patlen;
3837e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if (strcmp (str, pat) == 0)
3838e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*str = '\0';
3839e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    }
3840e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  return str;
3841e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
3842e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3843e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevstatic void
3844e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevlt_error_core (int exit_status, const char *mode,
3845e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	       const char *message, va_list ap)
3846e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
3847e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  fprintf (stderr, "%s: %s: ", program_name, mode);
3848e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  vfprintf (stderr, message, ap);
3849e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  fprintf (stderr, ".\n");
3850e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3851e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if (exit_status >= 0)
3852e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    exit (exit_status);
3853e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
3854e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3855e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevvoid
3856e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevlt_fatal (const char *message, ...)
3857e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
3858e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  va_list ap;
3859e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  va_start (ap, message);
3860e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
3861e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  va_end (ap);
3862e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
3863e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3864e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevvoid
3865e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevlt_setenv (const char *name, const char *value)
3866e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
3867e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  LTWRAPPER_DEBUGPRINTF (("(lt_setenv) setting '%s' to '%s'\n",
3868e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev                          (name ? name : "<NULL>"),
3869e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev                          (value ? value : "<NULL>")));
3870e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  {
3871e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#ifdef HAVE_SETENV
3872e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    /* always make a copy, for consistency with !HAVE_SETENV */
3873e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    char *str = xstrdup (value);
3874e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    setenv (name, str, 1);
3875e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#else
3876e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    int len = strlen (name) + 1 + strlen (value) + 1;
3877e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    char *str = XMALLOC (char, len);
3878e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    sprintf (str, "%s=%s", name, value);
3879e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if (putenv (str) != EXIT_SUCCESS)
3880e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      {
3881e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        XFREE (str);
3882e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      }
3883e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#endif
3884e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  }
3885e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
3886e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3887e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevchar *
3888e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevlt_extend_str (const char *orig_value, const char *add, int to_end)
3889e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
3890e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  char *new_value;
3891e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if (orig_value && *orig_value)
3892e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    {
3893e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      int orig_value_len = strlen (orig_value);
3894e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      int add_len = strlen (add);
3895e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      new_value = XMALLOC (char, add_len + orig_value_len + 1);
3896e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if (to_end)
3897e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        {
3898e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          strcpy (new_value, orig_value);
3899e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          strcpy (new_value + orig_value_len, add);
3900e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        }
3901e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      else
3902e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        {
3903e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          strcpy (new_value, add);
3904e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          strcpy (new_value + add_len, orig_value);
3905e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        }
3906e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    }
3907e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  else
3908e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    {
3909e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      new_value = xstrdup (add);
3910e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    }
3911e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  return new_value;
3912e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
3913e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3914e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevint
3915e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevlt_split_name_value (const char *arg, char** name, char** value)
3916e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
3917e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  const char *p;
3918e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  int len;
3919e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if (!arg || !*arg)
3920e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    return 1;
3921e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3922e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  p = strchr (arg, (int)'=');
3923e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3924e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if (!p)
3925e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    return 1;
3926e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3927e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  *value = xstrdup (++p);
3928e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3929e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  len = strlen (arg) - strlen (*value);
3930e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  *name = XMALLOC (char, len);
3931e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  strncpy (*name, arg, len-1);
3932e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  (*name)[len - 1] = '\0';
3933e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3934e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  return 0;
3935e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
3936e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3937e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevvoid
3938e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevlt_opt_process_env_set (const char *arg)
3939e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
3940e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  char *name = NULL;
3941e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  char *value = NULL;
3942e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3943e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if (lt_split_name_value (arg, &name, &value) != 0)
3944e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    {
3945e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      XFREE (name);
3946e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      XFREE (value);
3947e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      lt_fatal ("bad argument for %s: '%s'", env_set_opt, arg);
3948e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    }
3949e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3950e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  lt_setenv (name, value);
3951e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  XFREE (name);
3952e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  XFREE (value);
3953e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
3954e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3955e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevvoid
3956e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevlt_opt_process_env_prepend (const char *arg)
3957e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
3958e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  char *name = NULL;
3959e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  char *value = NULL;
3960e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  char *new_value = NULL;
3961e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3962e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if (lt_split_name_value (arg, &name, &value) != 0)
3963e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    {
3964e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      XFREE (name);
3965e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      XFREE (value);
3966e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      lt_fatal ("bad argument for %s: '%s'", env_prepend_opt, arg);
3967e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    }
3968e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3969e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  new_value = lt_extend_str (getenv (name), value, 0);
3970e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  lt_setenv (name, new_value);
3971e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  XFREE (new_value);
3972e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  XFREE (name);
3973e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  XFREE (value);
3974e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
3975e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3976e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevvoid
3977e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevlt_opt_process_env_append (const char *arg)
3978e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
3979e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  char *name = NULL;
3980e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  char *value = NULL;
3981e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  char *new_value = NULL;
3982e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3983e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if (lt_split_name_value (arg, &name, &value) != 0)
3984e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    {
3985e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      XFREE (name);
3986e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      XFREE (value);
3987e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      lt_fatal ("bad argument for %s: '%s'", env_append_opt, arg);
3988e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    }
3989e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3990e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  new_value = lt_extend_str (getenv (name), value, 1);
3991e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  lt_setenv (name, new_value);
3992e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  XFREE (new_value);
3993e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  XFREE (name);
3994e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  XFREE (value);
3995e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
3996e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
3997e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevvoid
3998e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevlt_update_exe_path (const char *name, const char *value)
3999e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
4000e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  LTWRAPPER_DEBUGPRINTF (("(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
4001e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev                          (name ? name : "<NULL>"),
4002e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev                          (value ? value : "<NULL>")));
4003e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4004e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if (name && *name && value && *value)
4005e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    {
4006e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      char *new_value = lt_extend_str (getenv (name), value, 0);
4007e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      /* some systems can't cope with a ':'-terminated path #' */
4008e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      int len = strlen (new_value);
4009e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
4010e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        {
4011e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          new_value[len-1] = '\0';
4012e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        }
4013e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      lt_setenv (name, new_value);
4014e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      XFREE (new_value);
4015e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    }
4016e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
4017e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4018e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevvoid
4019e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevlt_update_lib_path (const char *name, const char *value)
4020e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
4021e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  LTWRAPPER_DEBUGPRINTF (("(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
4022e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev                          (name ? name : "<NULL>"),
4023e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev                          (value ? value : "<NULL>")));
4024e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4025e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  if (name && *name && value && *value)
4026e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    {
4027e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      char *new_value = lt_extend_str (getenv (name), value, 0);
4028e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      lt_setenv (name, new_value);
4029e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      XFREE (new_value);
4030e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    }
4031e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
4032e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4033e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4034e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevEOF
4035e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
4036e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# end: func_emit_cwrapperexe_src
4037e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4038e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_mode_link arg...
4039e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_mode_link ()
4040e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
4041e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $opt_debug
4042e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    case $host in
4043e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
4044e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # It is impossible to link a dll without this setting, and
4045e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # we shouldn't force the makefile maintainer to figure out
4046e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # which system we are compiling for in order to pass an extra
4047e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # flag for every libtool invocation.
4048e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # allow_undefined=no
4049e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4050e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # FIXME: Unfortunately, there are problems with the above when trying
4051e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # to make a dll which has undefined symbols, in which case not
4052e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # even a static library is built.  For now, we need to specify
4053e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # -no-undefined on the libtool link line when we can be certain
4054e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # that all symbols are satisfied, otherwise we get a static library.
4055e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      allow_undefined=yes
4056e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      ;;
4057e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    *)
4058e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      allow_undefined=yes
4059e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      ;;
4060e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    esac
4061e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    libtool_args=$nonopt
4062e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    base_compile="$nonopt $@"
4063e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    compile_command=$nonopt
4064e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    finalize_command=$nonopt
4065e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4066e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    compile_rpath=
4067e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    finalize_rpath=
4068e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    compile_shlibpath=
4069e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    finalize_shlibpath=
4070e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    convenience=
4071e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    old_convenience=
4072e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    deplibs=
4073e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    old_deplibs=
4074e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    compiler_flags=
4075e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    linker_flags=
4076e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    dllsearchpath=
4077e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    lib_search_path=`pwd`
4078e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    inst_prefix_dir=
4079e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    new_inherited_linker_flags=
4080e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4081e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    avoid_version=no
4082e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    dlfiles=
4083e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    dlprefiles=
4084e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    dlself=no
4085e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    export_dynamic=no
4086e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    export_symbols=
4087e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    export_symbols_regex=
4088e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    generated=
4089e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    libobjs=
4090e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    ltlibs=
4091e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    module=no
4092e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    no_install=no
4093e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    objs=
4094e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    non_pic_objects=
4095e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    precious_files_regex=
4096e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    prefer_static_libs=no
4097e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    preload=no
4098e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    prev=
4099e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    prevarg=
4100e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    release=
4101e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    rpath=
4102e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    xrpath=
4103e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    perm_rpath=
4104e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    temp_rpath=
4105e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    thread_safe=no
4106e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    vinfo=
4107e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    vinfo_number=no
4108e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    weak_libs=
4109e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    single_module="${wl}-single_module"
4110e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_infer_tag $base_compile
4111e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4112e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # We need to know -static, to get the right output filenames.
4113e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    for arg
4114e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    do
4115e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      case $arg in
4116e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -shared)
4117e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	test "$build_libtool_libs" != yes && \
4118e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_fatal_configuration "can not build a shared library"
4119e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	build_old_libs=no
4120e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	break
4121e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4122e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -all-static | -static | -static-libtool-libs)
4123e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $arg in
4124e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	-all-static)
4125e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
4126e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_warning "complete static linking is impossible in this configuration"
4127e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
4128e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -n "$link_static_flag"; then
4129e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    dlopen_self=$dlopen_self_static
4130e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
4131e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  prefer_static_libs=yes
4132e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
4133e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	-static)
4134e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
4135e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    dlopen_self=$dlopen_self_static
4136e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
4137e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  prefer_static_libs=built
4138e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
4139e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	-static-libtool-libs)
4140e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
4141e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    dlopen_self=$dlopen_self_static
4142e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
4143e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  prefer_static_libs=yes
4144e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
4145e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
4146e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	build_libtool_libs=no
4147e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	build_old_libs=yes
4148e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	break
4149e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4150e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      esac
4151e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    done
4152e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4153e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # See if our shared archives depend on static archives.
4154e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
4155e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4156e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # Go through the arguments, transforming them on the way.
4157e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    while test "$#" -gt 0; do
4158e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      arg="$1"
4159e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      shift
4160e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_quote_for_eval "$arg"
4161e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      qarg=$func_quote_for_eval_unquoted_result
4162e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_append libtool_args " $func_quote_for_eval_result"
4163e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4164e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # If the previous option needs an argument, assign it.
4165e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -n "$prev"; then
4166e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $prev in
4167e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	output)
4168e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_append compile_command " @OUTPUT@"
4169e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_append finalize_command " @OUTPUT@"
4170e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
4171e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
4172e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4173e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $prev in
4174e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	dlfiles|dlprefiles)
4175e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$preload" = no; then
4176e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Add the symbol object into the linking commands.
4177e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_append compile_command " @SYMFILE@"
4178e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_append finalize_command " @SYMFILE@"
4179e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    preload=yes
4180e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
4181e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case $arg in
4182e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *.la | *.lo) ;;  # We handle these cases below.
4183e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  force)
4184e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "$dlself" = no; then
4185e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      dlself=needless
4186e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      export_dynamic=yes
4187e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
4188e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    prev=
4189e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    continue
4190e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
4191e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  self)
4192e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "$prev" = dlprefiles; then
4193e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      dlself=yes
4194e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
4195e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      dlself=yes
4196e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    else
4197e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      dlself=needless
4198e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      export_dynamic=yes
4199e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
4200e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    prev=
4201e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    continue
4202e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
4203e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *)
4204e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "$prev" = dlfiles; then
4205e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      dlfiles="$dlfiles $arg"
4206e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    else
4207e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      dlprefiles="$dlprefiles $arg"
4208e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
4209e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    prev=
4210e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    continue
4211e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
4212e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
4213e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
4214e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	expsyms)
4215e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  export_symbols="$arg"
4216e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  test -f "$arg" \
4217e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    || func_fatal_error "symbol file \`$arg' does not exist"
4218e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  prev=
4219e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
4220e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
4221e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	expsyms_regex)
4222e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  export_symbols_regex="$arg"
4223e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  prev=
4224e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
4225e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
4226e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	framework)
4227e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case $host in
4228e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *-*-darwin*)
4229e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case "$deplibs " in
4230e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		*" $qarg.ltframework "*) ;;
4231e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		*) deplibs="$deplibs $qarg.ltframework" # this is fixed later
4232e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		   ;;
4233e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
4234e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      ;;
4235e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
4236e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  prev=
4237e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
4238e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
4239e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	inst_prefix)
4240e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  inst_prefix_dir="$arg"
4241e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  prev=
4242e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
4243e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
4244e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	objectlist)
4245e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -f "$arg"; then
4246e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    save_arg=$arg
4247e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    moreargs=
4248e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    for fil in `cat "$save_arg"`
4249e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    do
4250e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#	      moreargs="$moreargs $fil"
4251e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      arg=$fil
4252e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # A libtool-controlled object.
4253e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4254e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # Check to see that this really is a libtool object.
4255e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      if func_lalib_unsafe_p "$arg"; then
4256e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		pic_object=
4257e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		non_pic_object=
4258e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4259e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		# Read the .lo file
4260e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		func_source "$arg"
4261e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4262e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		if test -z "$pic_object" ||
4263e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		   test -z "$non_pic_object" ||
4264e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		   test "$pic_object" = none &&
4265e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		   test "$non_pic_object" = none; then
4266e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  func_fatal_error "cannot find name of object for \`$arg'"
4267e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		fi
4268e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4269e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		# Extract subdirectory from the argument.
4270e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		func_dirname "$arg" "/" ""
4271e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		xdir="$func_dirname_result"
4272e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4273e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		if test "$pic_object" != none; then
4274e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  # Prepend the subdirectory the object is found in.
4275e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  pic_object="$xdir$pic_object"
4276e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4277e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  if test "$prev" = dlfiles; then
4278e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
4279e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      dlfiles="$dlfiles $pic_object"
4280e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      prev=
4281e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      continue
4282e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    else
4283e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      # If libtool objects are unsupported, then we need to preload.
4284e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      prev=dlprefiles
4285e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    fi
4286e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  fi
4287e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4288e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  # CHECK ME:  I think I busted this.  -Ossama
4289e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  if test "$prev" = dlprefiles; then
4290e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    # Preload the old-style object.
4291e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    dlprefiles="$dlprefiles $pic_object"
4292e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    prev=
4293e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  fi
4294e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4295e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  # A PIC object.
4296e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  func_append libobjs " $pic_object"
4297e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  arg="$pic_object"
4298e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		fi
4299e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4300e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		# Non-PIC object.
4301e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		if test "$non_pic_object" != none; then
4302e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  # Prepend the subdirectory the object is found in.
4303e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  non_pic_object="$xdir$non_pic_object"
4304e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4305e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  # A standard non-PIC object
4306e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  func_append non_pic_objects " $non_pic_object"
4307e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  if test -z "$pic_object" || test "$pic_object" = none ; then
4308e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    arg="$non_pic_object"
4309e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  fi
4310e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		else
4311e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  # If the PIC object exists, use it instead.
4312e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  # $xdir was prepended to $pic_object above.
4313e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  non_pic_object="$pic_object"
4314e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  func_append non_pic_objects " $non_pic_object"
4315e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		fi
4316e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      else
4317e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		# Only an error if not doing a dry-run.
4318e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		if $opt_dry_run; then
4319e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  # Extract subdirectory from the argument.
4320e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  func_dirname "$arg" "/" ""
4321e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  xdir="$func_dirname_result"
4322e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4323e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  func_lo2o "$arg"
4324e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  pic_object=$xdir$objdir/$func_lo2o_result
4325e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  non_pic_object=$xdir$func_lo2o_result
4326e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  func_append libobjs " $pic_object"
4327e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  func_append non_pic_objects " $non_pic_object"
4328e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	        else
4329e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  func_fatal_error "\`$arg' is not a valid libtool object"
4330e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		fi
4331e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      fi
4332e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    done
4333e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
4334e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_fatal_error "link input file \`$arg' does not exist"
4335e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
4336e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  arg=$save_arg
4337e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  prev=
4338e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
4339e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
4340e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	precious_regex)
4341e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  precious_files_regex="$arg"
4342e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  prev=
4343e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
4344e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
4345e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	release)
4346e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  release="-$arg"
4347e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  prev=
4348e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
4349e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
4350e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	rpath | xrpath)
4351e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # We need an absolute path.
4352e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case $arg in
4353e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  [\\/]* | [A-Za-z]:[\\/]*) ;;
4354e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *)
4355e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_fatal_error "only absolute run-paths are allowed"
4356e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
4357e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
4358e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$prev" = rpath; then
4359e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    case "$rpath " in
4360e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *" $arg "*) ;;
4361e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *) rpath="$rpath $arg" ;;
4362e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    esac
4363e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
4364e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    case "$xrpath " in
4365e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *" $arg "*) ;;
4366e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *) xrpath="$xrpath $arg" ;;
4367e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    esac
4368e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
4369e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  prev=
4370e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
4371e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
4372e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	shrext)
4373e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  shrext_cmds="$arg"
4374e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  prev=
4375e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
4376e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
4377e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	weak)
4378e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  weak_libs="$weak_libs $arg"
4379e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  prev=
4380e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
4381e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
4382e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	xcclinker)
4383e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  linker_flags="$linker_flags $qarg"
4384e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  compiler_flags="$compiler_flags $qarg"
4385e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  prev=
4386e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_append compile_command " $qarg"
4387e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_append finalize_command " $qarg"
4388e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
4389e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
4390e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	xcompiler)
4391e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  compiler_flags="$compiler_flags $qarg"
4392e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  prev=
4393e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_append compile_command " $qarg"
4394e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_append finalize_command " $qarg"
4395e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
4396e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
4397e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	xlinker)
4398e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  linker_flags="$linker_flags $qarg"
4399e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  compiler_flags="$compiler_flags $wl$qarg"
4400e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  prev=
4401e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_append compile_command " $wl$qarg"
4402e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_append finalize_command " $wl$qarg"
4403e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
4404e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
4405e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*)
4406e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  eval "$prev=\"\$arg\""
4407e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  prev=
4408e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
4409e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
4410e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
4411e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi # test -n "$prev"
4412e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4413e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      prevarg="$arg"
4414e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4415e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      case $arg in
4416e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -all-static)
4417e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$link_static_flag"; then
4418e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # See comment for -static flag below, for more details.
4419e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_append compile_command " $link_static_flag"
4420e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_append finalize_command " $link_static_flag"
4421e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
4422e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4423e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4424e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4425e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -allow-undefined)
4426e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# FIXME: remove this flag sometime in the future.
4427e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
4428e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4429e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4430e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -avoid-version)
4431e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	avoid_version=yes
4432e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4433e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4434e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4435e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -dlopen)
4436e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	prev=dlfiles
4437e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4438e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4439e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4440e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -dlpreopen)
4441e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	prev=dlprefiles
4442e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4443e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4444e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4445e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -export-dynamic)
4446e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	export_dynamic=yes
4447e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4448e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4449e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4450e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -export-symbols | -export-symbols-regex)
4451e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
4452e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_fatal_error "more than one -exported-symbols argument is not allowed"
4453e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
4454e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "X$arg" = "X-export-symbols"; then
4455e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  prev=expsyms
4456e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	else
4457e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  prev=expsyms_regex
4458e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
4459e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4460e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4461e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4462e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -framework)
4463e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	prev=framework
4464e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4465e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4466e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4467e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -inst-prefix-dir)
4468e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	prev=inst_prefix
4469e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4470e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4471e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4472e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
4473e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # so, if we see these flags be careful not to treat them like -L
4474e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -L[A-Z][A-Z]*:*)
4475e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $with_gcc/$host in
4476e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	no/*-*-irix* | /*-*-irix*)
4477e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_append compile_command " $arg"
4478e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_append finalize_command " $arg"
4479e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
4480e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
4481e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4482e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4483e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4484e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -L*)
4485e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_stripname '-L' '' "$arg"
4486e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	dir=$func_stripname_result
4487e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -z "$dir"; then
4488e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$#" -gt 0; then
4489e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_fatal_error "require no space between \`-L' and \`$1'"
4490e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
4491e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_fatal_error "need path for \`-L' option"
4492e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
4493e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
4494e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# We need an absolute path.
4495e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $dir in
4496e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	[\\/]* | [A-Za-z]:[\\/]*) ;;
4497e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*)
4498e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  absdir=`cd "$dir" && pwd`
4499e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  test -z "$absdir" && \
4500e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
4501e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  dir="$absdir"
4502e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
4503e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
4504e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case "$deplibs " in
4505e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*" -L$dir "*) ;;
4506e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*)
4507e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  deplibs="$deplibs -L$dir"
4508e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  lib_search_path="$lib_search_path $dir"
4509e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
4510e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
4511e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $host in
4512e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
4513e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'`
4514e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case :$dllsearchpath: in
4515e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *":$dir:"*) ;;
4516e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ::) dllsearchpath=$dir;;
4517e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *) dllsearchpath="$dllsearchpath:$dir";;
4518e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
4519e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case :$dllsearchpath: in
4520e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *":$testbindir:"*) ;;
4521e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ::) dllsearchpath=$testbindir;;
4522e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *) dllsearchpath="$dllsearchpath:$testbindir";;
4523e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
4524e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
4525e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
4526e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4527e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4528e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4529e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -l*)
4530e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
4531e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case $host in
4532e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc*)
4533e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # These systems don't actually have a C or math library (as such)
4534e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    continue
4535e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
4536e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *-*-os2*)
4537e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # These systems don't actually have a C library (as such)
4538e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    test "X$arg" = "X-lc" && continue
4539e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
4540e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
4541e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Do not include libc due to us having libc/libc_r.
4542e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    test "X$arg" = "X-lc" && continue
4543e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
4544e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *-*-rhapsody* | *-*-darwin1.[012])
4545e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Rhapsody C and math libraries are in the System framework
4546e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    deplibs="$deplibs System.ltframework"
4547e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    continue
4548e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
4549e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *-*-sco3.2v5* | *-*-sco5v6*)
4550e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Causes problems with __ctype
4551e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    test "X$arg" = "X-lc" && continue
4552e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
4553e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
4554e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Compiler inserts libc in the correct place for threads to work
4555e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    test "X$arg" = "X-lc" && continue
4556e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
4557e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
4558e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	elif test "X$arg" = "X-lc_r"; then
4559e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	 case $host in
4560e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
4561e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	   # Do not include libc_r directly, use -pthread flag.
4562e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	   continue
4563e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	   ;;
4564e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	 esac
4565e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
4566e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	deplibs="$deplibs $arg"
4567e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4568e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4569e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4570e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -module)
4571e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	module=yes
4572e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4573e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4574e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4575e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Tru64 UNIX uses -model [arg] to determine the layout of C++
4576e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # classes, name mangling, and exception handling.
4577e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Darwin uses the -arch flag to determine output architecture.
4578e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -model|-arch|-isysroot)
4579e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	compiler_flags="$compiler_flags $arg"
4580e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_append compile_command " $arg"
4581e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_append finalize_command " $arg"
4582e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	prev=xcompiler
4583e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4584e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4585e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4586e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
4587e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	compiler_flags="$compiler_flags $arg"
4588e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_append compile_command " $arg"
4589e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_append finalize_command " $arg"
4590e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case "$new_inherited_linker_flags " in
4591e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *" $arg "*) ;;
4592e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
4593e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
4594e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4595e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4596e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4597e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -multi_module)
4598e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	single_module="${wl}-multi_module"
4599e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4600e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4601e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4602e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -no-fast-install)
4603e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fast_install=no
4604e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4605e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4606e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4607e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -no-install)
4608e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $host in
4609e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
4610e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # The PATH hackery in wrapper scripts is required on Windows
4611e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # and Darwin in order for the loader to find any dlls it needs.
4612e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_warning "\`-no-install' is ignored for $host"
4613e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_warning "assuming \`-no-fast-install' instead"
4614e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fast_install=no
4615e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
4616e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*) no_install=yes ;;
4617e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
4618e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4619e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4620e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4621e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -no-undefined)
4622e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	allow_undefined=no
4623e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4624e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4625e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4626e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -objectlist)
4627e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	prev=objectlist
4628e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4629e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4630e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4631e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -o) prev=output ;;
4632e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4633e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -precious-files-regex)
4634e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	prev=precious_regex
4635e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4636e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4637e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4638e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -release)
4639e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	prev=release
4640e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4641e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4642e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4643e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -rpath)
4644e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	prev=rpath
4645e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4646e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4647e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4648e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -R)
4649e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	prev=xrpath
4650e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4651e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4652e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4653e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -R*)
4654e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_stripname '-R' '' "$arg"
4655e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	dir=$func_stripname_result
4656e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# We need an absolute path.
4657e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $dir in
4658e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	[\\/]* | [A-Za-z]:[\\/]*) ;;
4659e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*)
4660e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_fatal_error "only absolute run-paths are allowed"
4661e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
4662e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
4663e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case "$xrpath " in
4664e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*" $dir "*) ;;
4665e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*) xrpath="$xrpath $dir" ;;
4666e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
4667e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4668e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4669e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4670e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -shared)
4671e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# The effects of -shared are defined in a previous loop.
4672e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4673e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4674e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4675e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -shrext)
4676e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	prev=shrext
4677e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4678e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4679e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4680e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -static | -static-libtool-libs)
4681e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# The effects of -static are defined in a previous loop.
4682e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# We used to do the same as -all-static on platforms that
4683e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# didn't have a PIC flag, but the assumption that the effects
4684e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# would be equivalent was wrong.  It would break on at least
4685e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Digital Unix and AIX.
4686e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4687e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4688e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4689e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -thread-safe)
4690e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	thread_safe=yes
4691e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4692e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4693e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4694e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -version-info)
4695e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	prev=vinfo
4696e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4697e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4698e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4699e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -version-number)
4700e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	prev=vinfo
4701e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	vinfo_number=yes
4702e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4703e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4704e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4705e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -weak)
4706e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        prev=weak
4707e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4708e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4709e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4710e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -Wc,*)
4711e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_stripname '-Wc,' '' "$arg"
4712e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	args=$func_stripname_result
4713e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	arg=
4714e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	save_ifs="$IFS"; IFS=','
4715e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	for flag in $args; do
4716e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  IFS="$save_ifs"
4717e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          func_quote_for_eval "$flag"
4718e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  arg="$arg $wl$func_quote_for_eval_result"
4719e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  compiler_flags="$compiler_flags $func_quote_for_eval_result"
4720e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	done
4721e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	IFS="$save_ifs"
4722e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_stripname ' ' '' "$arg"
4723e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	arg=$func_stripname_result
4724e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4725e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4726e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -Wl,*)
4727e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_stripname '-Wl,' '' "$arg"
4728e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	args=$func_stripname_result
4729e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	arg=
4730e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	save_ifs="$IFS"; IFS=','
4731e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	for flag in $args; do
4732e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  IFS="$save_ifs"
4733e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          func_quote_for_eval "$flag"
4734e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  arg="$arg $wl$func_quote_for_eval_result"
4735e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
4736e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  linker_flags="$linker_flags $func_quote_for_eval_result"
4737e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	done
4738e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	IFS="$save_ifs"
4739e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_stripname ' ' '' "$arg"
4740e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	arg=$func_stripname_result
4741e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4742e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4743e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -Xcompiler)
4744e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	prev=xcompiler
4745e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4746e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4747e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4748e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -Xlinker)
4749e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	prev=xlinker
4750e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4751e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4752e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4753e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -XCClinker)
4754e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	prev=xcclinker
4755e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4756e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4757e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4758e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # -msg_* for osf cc
4759e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -msg_*)
4760e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_quote_for_eval "$arg"
4761e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	arg="$func_quote_for_eval_result"
4762e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4763e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4764e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
4765e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # -r[0-9][0-9]* specifies the processor on the SGI compiler
4766e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
4767e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # +DA*, +DD* enable 64-bit mode on the HP compiler
4768e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # -q* pass through compiler args for the IBM compiler
4769e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # -m*, -t[45]*, -txscale* pass through architecture-specific
4770e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # compiler args for GCC
4771e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # -F/path gives path to uninstalled frameworks, gcc on darwin
4772e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
4773e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # @file GCC response files
4774e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
4775e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
4776e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        func_quote_for_eval "$arg"
4777e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	arg="$func_quote_for_eval_result"
4778e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        func_append compile_command " $arg"
4779e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        func_append finalize_command " $arg"
4780e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        compiler_flags="$compiler_flags $arg"
4781e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        continue
4782e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        ;;
4783e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4784e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Some other compiler flag.
4785e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -* | +*)
4786e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        func_quote_for_eval "$arg"
4787e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	arg="$func_quote_for_eval_result"
4788e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4789e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4790e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *.$objext)
4791e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# A standard object.
4792e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	objs="$objs $arg"
4793e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4794e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4795e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *.lo)
4796e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# A libtool-controlled object.
4797e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4798e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Check to see that this really is a libtool object.
4799e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if func_lalib_unsafe_p "$arg"; then
4800e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  pic_object=
4801e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  non_pic_object=
4802e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4803e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Read the .lo file
4804e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_source "$arg"
4805e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4806e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -z "$pic_object" ||
4807e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	     test -z "$non_pic_object" ||
4808e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	     test "$pic_object" = none &&
4809e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	     test "$non_pic_object" = none; then
4810e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_fatal_error "cannot find name of object for \`$arg'"
4811e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
4812e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4813e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Extract subdirectory from the argument.
4814e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_dirname "$arg" "/" ""
4815e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  xdir="$func_dirname_result"
4816e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4817e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$pic_object" != none; then
4818e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Prepend the subdirectory the object is found in.
4819e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    pic_object="$xdir$pic_object"
4820e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4821e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "$prev" = dlfiles; then
4822e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
4823e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		dlfiles="$dlfiles $pic_object"
4824e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		prev=
4825e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		continue
4826e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      else
4827e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		# If libtool objects are unsupported, then we need to preload.
4828e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		prev=dlprefiles
4829e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      fi
4830e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
4831e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4832e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # CHECK ME:  I think I busted this.  -Ossama
4833e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "$prev" = dlprefiles; then
4834e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # Preload the old-style object.
4835e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      dlprefiles="$dlprefiles $pic_object"
4836e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      prev=
4837e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
4838e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4839e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # A PIC object.
4840e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_append libobjs " $pic_object"
4841e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    arg="$pic_object"
4842e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
4843e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4844e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Non-PIC object.
4845e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$non_pic_object" != none; then
4846e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Prepend the subdirectory the object is found in.
4847e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    non_pic_object="$xdir$non_pic_object"
4848e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4849e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # A standard non-PIC object
4850e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_append non_pic_objects " $non_pic_object"
4851e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test -z "$pic_object" || test "$pic_object" = none ; then
4852e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      arg="$non_pic_object"
4853e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
4854e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
4855e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # If the PIC object exists, use it instead.
4856e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # $xdir was prepended to $pic_object above.
4857e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    non_pic_object="$pic_object"
4858e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_append non_pic_objects " $non_pic_object"
4859e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
4860e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	else
4861e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Only an error if not doing a dry-run.
4862e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if $opt_dry_run; then
4863e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Extract subdirectory from the argument.
4864e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_dirname "$arg" "/" ""
4865e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    xdir="$func_dirname_result"
4866e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4867e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_lo2o "$arg"
4868e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    pic_object=$xdir$objdir/$func_lo2o_result
4869e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    non_pic_object=$xdir$func_lo2o_result
4870e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_append libobjs " $pic_object"
4871e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_append non_pic_objects " $non_pic_object"
4872e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
4873e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_fatal_error "\`$arg' is not a valid libtool object"
4874e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
4875e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
4876e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4877e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4878e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *.$libext)
4879e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# An archive.
4880e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	deplibs="$deplibs $arg"
4881e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	old_deplibs="$old_deplibs $arg"
4882e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4883e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4884e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4885e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *.la)
4886e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# A libtool-controlled library.
4887e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4888e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$prev" = dlfiles; then
4889e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # This library was specified with -dlopen.
4890e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  dlfiles="$dlfiles $arg"
4891e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  prev=
4892e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	elif test "$prev" = dlprefiles; then
4893e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # The library was specified with -dlpreopen.
4894e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  dlprefiles="$dlprefiles $arg"
4895e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  prev=
4896e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	else
4897e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  deplibs="$deplibs $arg"
4898e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
4899e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
4900e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4901e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4902e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Some other compiler argument.
4903e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *)
4904e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Unknown arguments in both finalize_command and compile_command need
4905e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# to be aesthetically quoted because they are evaled later.
4906e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_quote_for_eval "$arg"
4907e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	arg="$func_quote_for_eval_result"
4908e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
4909e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      esac # arg
4910e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4911e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Now actually substitute the argument into the commands.
4912e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -n "$arg"; then
4913e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_append compile_command " $arg"
4914e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_append finalize_command " $arg"
4915e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
4916e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    done # argument parsing loop
4917e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4918e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    test -n "$prev" && \
4919e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_fatal_help "the \`$prevarg' option requires an argument"
4920e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4921e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
4922e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      eval arg=\"$export_dynamic_flag_spec\"
4923e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_append compile_command " $arg"
4924e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_append finalize_command " $arg"
4925e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
4926e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4927e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    oldlibs=
4928e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # calculate the name of the file, without its directory
4929e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_basename "$output"
4930e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    outputname="$func_basename_result"
4931e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    libobjs_save="$libobjs"
4932e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4933e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test -n "$shlibpath_var"; then
4934e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # get the directories listed in $shlibpath_var
4935e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
4936e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    else
4937e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      shlib_search_path=
4938e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
4939e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
4940e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
4941e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4942e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_dirname "$output" "/" ""
4943e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    output_objdir="$func_dirname_result$objdir"
4944e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # Create the object directory.
4945e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_mkdir_p "$output_objdir"
4946e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4947e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # Determine the type of output
4948e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    case $output in
4949e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    "")
4950e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_fatal_help "you must specify an output file"
4951e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      ;;
4952e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    *.$libext) linkmode=oldlib ;;
4953e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    *.lo | *.$objext) linkmode=obj ;;
4954e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    *.la) linkmode=lib ;;
4955e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    *) linkmode=prog ;; # Anything else should be a program.
4956e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    esac
4957e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4958e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    specialdeplibs=
4959e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4960e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    libs=
4961e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # Find all interdependent deplibs by searching for libraries
4962e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # that are linked more than once (e.g. -la -lb -la)
4963e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    for deplib in $deplibs; do
4964e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if $opt_duplicate_deps ; then
4965e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case "$libs " in
4966e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
4967e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
4968e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
4969e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      libs="$libs $deplib"
4970e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    done
4971e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4972e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test "$linkmode" = lib; then
4973e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      libs="$predeps $libs $compiler_lib_search_path $postdeps"
4974e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4975e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Compute libraries that are listed more than once in $predeps
4976e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # $postdeps and mark them as special (i.e., whose duplicates are
4977e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # not to be eliminated).
4978e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      pre_post_deps=
4979e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if $opt_duplicate_compiler_generated_deps; then
4980e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	for pre_post_dep in $predeps $postdeps; do
4981e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case "$pre_post_deps " in
4982e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
4983e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
4984e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  pre_post_deps="$pre_post_deps $pre_post_dep"
4985e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	done
4986e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
4987e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      pre_post_deps=
4988e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
4989e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4990e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    deplibs=
4991e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    newdependency_libs=
4992e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    newlib_search_path=
4993e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    need_relink=no # whether we're linking any uninstalled libtool libraries
4994e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    notinst_deplibs= # not-installed libtool libraries
4995e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    notinst_path= # paths that contain not-installed libtool libraries
4996e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
4997e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    case $linkmode in
4998e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    lib)
4999e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	passes="conv dlpreopen link"
5000e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	for file in $dlfiles $dlprefiles; do
5001e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case $file in
5002e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *.la) ;;
5003e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *)
5004e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
5005e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
5006e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
5007e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	done
5008e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
5009e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    prog)
5010e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	compile_deplibs=
5011e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	finalize_deplibs=
5012e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	alldeplibs=no
5013e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	newdlfiles=
5014e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	newdlprefiles=
5015e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	passes="conv scan dlopen dlpreopen link"
5016e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
5017e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    *)  passes="conv"
5018e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
5019e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    esac
5020e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5021e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    for pass in $passes; do
5022e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # The preopen pass in lib mode reverses $deplibs; put it back here
5023e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # so that -L comes before libs that need it for instance...
5024e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "$linkmode,$pass" = "lib,link"; then
5025e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	## FIXME: Find the place where the list is rebuilt in the wrong
5026e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	##        order, and fix it there properly
5027e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        tmp_deplibs=
5028e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	for deplib in $deplibs; do
5029e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  tmp_deplibs="$deplib $tmp_deplibs"
5030e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	done
5031e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	deplibs="$tmp_deplibs"
5032e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
5033e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5034e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "$linkmode,$pass" = "lib,link" ||
5035e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	 test "$linkmode,$pass" = "prog,scan"; then
5036e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	libs="$deplibs"
5037e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	deplibs=
5038e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
5039e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "$linkmode" = prog; then
5040e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $pass in
5041e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	dlopen) libs="$dlfiles" ;;
5042e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	dlpreopen) libs="$dlprefiles" ;;
5043e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
5044e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
5045e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
5046e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "$linkmode,$pass" = "lib,dlpreopen"; then
5047e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Collect and forward deplibs of preopened libtool libs
5048e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	for lib in $dlprefiles; do
5049e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Ignore non-libtool-libs
5050e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  dependency_libs=
5051e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case $lib in
5052e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *.la)	func_source "$lib" ;;
5053e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
5054e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5055e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Collect preopened libtool deplibs, except any this library
5056e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # has declared as weak libs
5057e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  for deplib in $dependency_libs; do
5058e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev            deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"`
5059e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    case " $weak_libs " in
5060e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *" $deplib_base "*) ;;
5061e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *) deplibs="$deplibs $deplib" ;;
5062e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    esac
5063e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  done
5064e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	done
5065e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	libs="$dlprefiles"
5066e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
5067e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "$pass" = dlopen; then
5068e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Collect dlpreopened libraries
5069e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	save_deplibs="$deplibs"
5070e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	deplibs=
5071e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
5072e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5073e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      for deplib in $libs; do
5074e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	lib=
5075e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	found=no
5076e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $deplib in
5077e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
5078e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$linkmode,$pass" = "prog,link"; then
5079e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    compile_deplibs="$deplib $compile_deplibs"
5080e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    finalize_deplibs="$deplib $finalize_deplibs"
5081e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
5082e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    compiler_flags="$compiler_flags $deplib"
5083e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "$linkmode" = lib ; then
5084e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		case "$new_inherited_linker_flags " in
5085e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    *" $deplib "*) ;;
5086e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
5087e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		esac
5088e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
5089e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
5090e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
5091e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
5092e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	-l*)
5093e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$linkmode" != lib && test "$linkmode" != prog; then
5094e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_warning "\`-l' is ignored for archives/objects"
5095e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    continue
5096e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
5097e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_stripname '-l' '' "$deplib"
5098e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  name=$func_stripname_result
5099e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$linkmode" = lib; then
5100e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
5101e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
5102e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
5103e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
5104e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  for searchdir in $searchdirs; do
5105e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    for search_ext in .la $std_shrext .so .a; do
5106e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # Search the libtool library
5107e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      lib="$searchdir/lib${name}${search_ext}"
5108e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      if test -f "$lib"; then
5109e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		if test "$search_ext" = ".la"; then
5110e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  found=yes
5111e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		else
5112e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  found=no
5113e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		fi
5114e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		break 2
5115e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      fi
5116e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    done
5117e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  done
5118e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$found" != yes; then
5119e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # deplib doesn't seem to be a libtool library
5120e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "$linkmode,$pass" = "prog,link"; then
5121e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      compile_deplibs="$deplib $compile_deplibs"
5122e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      finalize_deplibs="$deplib $finalize_deplibs"
5123e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    else
5124e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      deplibs="$deplib $deplibs"
5125e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
5126e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
5127e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    continue
5128e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else # deplib is a libtool library
5129e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
5130e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # We need to do some special things here, and not later.
5131e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
5132e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case " $predeps $postdeps " in
5133e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *" $deplib "*)
5134e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		if func_lalib_p "$lib"; then
5135e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  library_names=
5136e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  old_library=
5137e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  func_source "$lib"
5138e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  for l in $old_library $library_names; do
5139e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    ll="$l"
5140e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  done
5141e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  if test "X$ll" = "X$old_library" ; then # only static version available
5142e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    found=no
5143e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    func_dirname "$lib" "" "."
5144e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    ladir="$func_dirname_result"
5145e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    lib=$ladir/$old_library
5146e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    if test "$linkmode,$pass" = "prog,link"; then
5147e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      compile_deplibs="$deplib $compile_deplibs"
5148e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      finalize_deplibs="$deplib $finalize_deplibs"
5149e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    else
5150e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      deplibs="$deplib $deplibs"
5151e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
5152e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    fi
5153e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    continue
5154e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  fi
5155e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		fi
5156e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		;;
5157e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *) ;;
5158e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
5159e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
5160e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
5161e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;; # -l
5162e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*.ltframework)
5163e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$linkmode,$pass" = "prog,link"; then
5164e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    compile_deplibs="$deplib $compile_deplibs"
5165e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    finalize_deplibs="$deplib $finalize_deplibs"
5166e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
5167e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    deplibs="$deplib $deplibs"
5168e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "$linkmode" = lib ; then
5169e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		case "$new_inherited_linker_flags " in
5170e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    *" $deplib "*) ;;
5171e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
5172e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		esac
5173e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
5174e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
5175e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
5176e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
5177e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	-L*)
5178e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case $linkmode in
5179e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  lib)
5180e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    deplibs="$deplib $deplibs"
5181e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    test "$pass" = conv && continue
5182e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    newdependency_libs="$deplib $newdependency_libs"
5183e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_stripname '-L' '' "$deplib"
5184e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    newlib_search_path="$newlib_search_path $func_stripname_result"
5185e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
5186e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  prog)
5187e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "$pass" = conv; then
5188e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      deplibs="$deplib $deplibs"
5189e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      continue
5190e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
5191e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "$pass" = scan; then
5192e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      deplibs="$deplib $deplibs"
5193e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    else
5194e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      compile_deplibs="$deplib $compile_deplibs"
5195e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      finalize_deplibs="$deplib $finalize_deplibs"
5196e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
5197e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_stripname '-L' '' "$deplib"
5198e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    newlib_search_path="$newlib_search_path $func_stripname_result"
5199e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
5200e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *)
5201e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_warning "\`-L' is ignored for archives/objects"
5202e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
5203e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac # linkmode
5204e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
5205e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;; # -L
5206e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	-R*)
5207e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$pass" = link; then
5208e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_stripname '-R' '' "$deplib"
5209e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    dir=$func_stripname_result
5210e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Make sure the xrpath contains only unique directories.
5211e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    case "$xrpath " in
5212e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *" $dir "*) ;;
5213e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *) xrpath="$xrpath $dir" ;;
5214e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    esac
5215e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
5216e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  deplibs="$deplib $deplibs"
5217e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
5218e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
5219e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*.la) lib="$deplib" ;;
5220e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*.$libext)
5221e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$pass" = conv; then
5222e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    deplibs="$deplib $deplibs"
5223e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    continue
5224e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
5225e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case $linkmode in
5226e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  lib)
5227e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Linking convenience modules into shared libraries is allowed,
5228e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # but linking other static libraries is non-portable.
5229e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    case " $dlpreconveniencelibs " in
5230e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *" $deplib "*) ;;
5231e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *)
5232e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      valid_a_lib=no
5233e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case $deplibs_check_method in
5234e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		match_pattern*)
5235e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  set dummy $deplibs_check_method; shift
5236e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
5237e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \
5238e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    | $EGREP "$match_pattern_regex" > /dev/null; then
5239e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    valid_a_lib=yes
5240e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  fi
5241e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		;;
5242e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		pass_all)
5243e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  valid_a_lib=yes
5244e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		;;
5245e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
5246e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      if test "$valid_a_lib" != yes; then
5247e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$ECHO
5248e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
5249e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$ECHO "*** I have the capability to make that library automatically link in when"
5250e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$ECHO "*** you link to this library.  But I can only do this if you have a"
5251e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$ECHO "*** shared version of the library, which you do not appear to have"
5252e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$ECHO "*** because the file extensions .$libext of this argument makes me believe"
5253e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$ECHO "*** that it is just a static archive that I should not use here."
5254e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      else
5255e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$ECHO
5256e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$ECHO "*** Warning: Linking the shared library $output against the"
5257e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$ECHO "*** static library $deplib is not portable!"
5258e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		deplibs="$deplib $deplibs"
5259e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      fi
5260e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      ;;
5261e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    esac
5262e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    continue
5263e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
5264e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  prog)
5265e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "$pass" != link; then
5266e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      deplibs="$deplib $deplibs"
5267e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    else
5268e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      compile_deplibs="$deplib $compile_deplibs"
5269e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      finalize_deplibs="$deplib $finalize_deplibs"
5270e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
5271e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    continue
5272e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
5273e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac # linkmode
5274e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;; # *.$libext
5275e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*.lo | *.$objext)
5276e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$pass" = conv; then
5277e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    deplibs="$deplib $deplibs"
5278e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  elif test "$linkmode" = prog; then
5279e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
5280e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # If there is no dlopen support or we're linking statically,
5281e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # we need to preload.
5282e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      newdlprefiles="$newdlprefiles $deplib"
5283e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      compile_deplibs="$deplib $compile_deplibs"
5284e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      finalize_deplibs="$deplib $finalize_deplibs"
5285e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    else
5286e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      newdlfiles="$newdlfiles $deplib"
5287e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
5288e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
5289e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
5290e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
5291e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	%DEPLIBS%)
5292e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  alldeplibs=yes
5293e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
5294e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
5295e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac # case $deplib
5296e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5297e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$found" = yes || test -f "$lib"; then :
5298e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	else
5299e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
5300e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
5301e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5302e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Check to see that this really is a libtool archive.
5303e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_lalib_unsafe_p "$lib" \
5304e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  || func_fatal_error "\`$lib' is not a valid libtool archive"
5305e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5306e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_dirname "$lib" "" "."
5307e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	ladir="$func_dirname_result"
5308e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5309e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	dlname=
5310e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	dlopen=
5311e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	dlpreopen=
5312e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	libdir=
5313e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	library_names=
5314e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	old_library=
5315e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	inherited_linker_flags=
5316e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# If the library was installed with an old release of libtool,
5317e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# it will not redefine variables installed, or shouldnotlink
5318e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	installed=yes
5319e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	shouldnotlink=no
5320e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	avoidtemprpath=
5321e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5322e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5323e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Read the .la file
5324e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_source "$lib"
5325e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5326e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Convert "-framework foo" to "foo.ltframework"
5327e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$inherited_linker_flags"; then
5328e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'`
5329e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
5330e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    case " $new_inherited_linker_flags " in
5331e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *" $tmp_inherited_linker_flag "*) ;;
5332e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
5333e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    esac
5334e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  done
5335e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
5336e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
5337e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$linkmode,$pass" = "lib,link" ||
5338e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	   test "$linkmode,$pass" = "prog,scan" ||
5339e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
5340e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
5341e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
5342e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
5343e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5344e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$pass" = conv; then
5345e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Only check for convenience libraries
5346e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  deplibs="$lib $deplibs"
5347e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -z "$libdir"; then
5348e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test -z "$old_library"; then
5349e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_fatal_error "cannot find name of link library for \`$lib'"
5350e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
5351e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # It is a libtool convenience library, so add in its objects.
5352e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    convenience="$convenience $ladir/$objdir/$old_library"
5353e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
5354e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
5355e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_fatal_error "\`$lib' is not a convenience library"
5356e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
5357e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  tmp_libs=
5358e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  for deplib in $dependency_libs; do
5359e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    deplibs="$deplib $deplibs"
5360e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if $opt_duplicate_deps ; then
5361e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case "$tmp_libs " in
5362e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5363e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
5364e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
5365e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    tmp_libs="$tmp_libs $deplib"
5366e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  done
5367e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
5368e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi # $pass = conv
5369e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5370e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5371e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Get the name of the library we link against.
5372e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	linklib=
5373e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	for l in $old_library $library_names; do
5374e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  linklib="$l"
5375e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	done
5376e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -z "$linklib"; then
5377e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_fatal_error "cannot find name of link library for \`$lib'"
5378e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
5379e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5380e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# This library was specified with -dlopen.
5381e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$pass" = dlopen; then
5382e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -z "$libdir"; then
5383e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
5384e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
5385e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -z "$dlname" ||
5386e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	     test "$dlopen_support" != yes ||
5387e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	     test "$build_libtool_libs" = no; then
5388e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # If there is no dlname, no dlopen support or we're linking
5389e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # statically, we need to preload.  We also need to preload any
5390e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # dependent libraries so libltdl's deplib preloader doesn't
5391e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # bomb out in the load deplibs phase.
5392e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    dlprefiles="$dlprefiles $lib $dependency_libs"
5393e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
5394e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    newdlfiles="$newdlfiles $lib"
5395e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
5396e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
5397e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi # $pass = dlopen
5398e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5399e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# We need an absolute path.
5400e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $ladir in
5401e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
5402e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*)
5403e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  abs_ladir=`cd "$ladir" && pwd`
5404e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -z "$abs_ladir"; then
5405e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_warning "cannot determine absolute directory name of \`$ladir'"
5406e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_warning "passing it literally to the linker, although it might fail"
5407e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    abs_ladir="$ladir"
5408e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
5409e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
5410e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
5411e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_basename "$lib"
5412e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	laname="$func_basename_result"
5413e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5414e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Find the relevant object directory and library name.
5415e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "X$installed" = Xyes; then
5416e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
5417e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_warning "library \`$lib' was moved."
5418e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    dir="$ladir"
5419e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    absdir="$abs_ladir"
5420e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    libdir="$abs_ladir"
5421e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
5422e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    dir="$libdir"
5423e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    absdir="$libdir"
5424e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
5425e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
5426e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	else
5427e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
5428e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    dir="$ladir"
5429e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    absdir="$abs_ladir"
5430e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Remove this search path later
5431e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    notinst_path="$notinst_path $abs_ladir"
5432e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
5433e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    dir="$ladir/$objdir"
5434e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    absdir="$abs_ladir/$objdir"
5435e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Remove this search path later
5436e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    notinst_path="$notinst_path $abs_ladir"
5437e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
5438e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi # $installed = yes
5439e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_stripname 'lib' '.la' "$laname"
5440e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	name=$func_stripname_result
5441e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5442e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# This library was specified with -dlpreopen.
5443e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$pass" = dlpreopen; then
5444e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -z "$libdir" && test "$linkmode" = prog; then
5445e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
5446e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
5447e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Prefer using a static library (so that no silly _DYNAMIC symbols
5448e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # are required to link).
5449e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -n "$old_library"; then
5450e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    newdlprefiles="$newdlprefiles $dir/$old_library"
5451e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Keep a list of preopened convenience libraries to check
5452e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # that they are being used correctly in the link pass.
5453e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    test -z "$libdir" && \
5454e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
5455e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Otherwise, use the dlname, so that lt_dlopen finds it.
5456e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  elif test -n "$dlname"; then
5457e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    newdlprefiles="$newdlprefiles $dir/$dlname"
5458e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
5459e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    newdlprefiles="$newdlprefiles $dir/$linklib"
5460e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
5461e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi # $pass = dlpreopen
5462e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5463e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -z "$libdir"; then
5464e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Link the convenience library
5465e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$linkmode" = lib; then
5466e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    deplibs="$dir/$old_library $deplibs"
5467e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  elif test "$linkmode,$pass" = "prog,link"; then
5468e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    compile_deplibs="$dir/$old_library $compile_deplibs"
5469e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
5470e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
5471e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    deplibs="$lib $deplibs" # used for prog,scan pass
5472e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
5473e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
5474e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
5475e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5476e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5477e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$linkmode" = prog && test "$pass" != link; then
5478e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  newlib_search_path="$newlib_search_path $ladir"
5479e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  deplibs="$lib $deplibs"
5480e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5481e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  linkalldeplibs=no
5482e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
5483e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	     test "$build_libtool_libs" = no; then
5484e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    linkalldeplibs=yes
5485e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
5486e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5487e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  tmp_libs=
5488e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  for deplib in $dependency_libs; do
5489e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    case $deplib in
5490e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    -L*) func_stripname '-L' '' "$deplib"
5491e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	         newlib_search_path="$newlib_search_path $func_stripname_result"
5492e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		 ;;
5493e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    esac
5494e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Need to link against all dependency_libs?
5495e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "$linkalldeplibs" = yes; then
5496e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      deplibs="$deplib $deplibs"
5497e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    else
5498e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # Need to hardcode shared library paths
5499e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # or/and link against static libraries
5500e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      newdependency_libs="$deplib $newdependency_libs"
5501e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
5502e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if $opt_duplicate_deps ; then
5503e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case "$tmp_libs " in
5504e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5505e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
5506e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
5507e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    tmp_libs="$tmp_libs $deplib"
5508e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  done # for deplib
5509e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  continue
5510e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi # $linkmode = prog...
5511e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5512e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$linkmode,$pass" = "prog,link"; then
5513e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -n "$library_names" &&
5514e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	     { { test "$prefer_static_libs" = no ||
5515e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
5516e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	       test -z "$old_library"; }; then
5517e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # We need to hardcode the library path
5518e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
5519e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # Make sure the rpath contains only unique directories.
5520e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case "$temp_rpath:" in
5521e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *"$absdir:"*) ;;
5522e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *) temp_rpath="$temp_rpath$absdir:" ;;
5523e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
5524e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
5525e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5526e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Hardcode the library path.
5527e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Skip directories that are in the system default run-time
5528e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # search path.
5529e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    case " $sys_lib_dlsearch_path " in
5530e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *" $absdir "*) ;;
5531e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *)
5532e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case "$compile_rpath " in
5533e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *" $absdir "*) ;;
5534e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *) compile_rpath="$compile_rpath $absdir"
5535e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
5536e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      ;;
5537e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    esac
5538e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    case " $sys_lib_dlsearch_path " in
5539e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *" $libdir "*) ;;
5540e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *)
5541e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case "$finalize_rpath " in
5542e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *" $libdir "*) ;;
5543e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *) finalize_rpath="$finalize_rpath $libdir"
5544e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
5545e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      ;;
5546e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    esac
5547e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi # $linkmode,$pass = prog,link...
5548e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5549e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$alldeplibs" = yes &&
5550e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	     { test "$deplibs_check_method" = pass_all ||
5551e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	       { test "$build_libtool_libs" = yes &&
5552e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		 test -n "$library_names"; }; }; then
5553e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # We only need to search for static libraries
5554e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    continue
5555e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
5556e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
5557e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5558e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	link_static=no # Whether the deplib will be linked statically
5559e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	use_static_libs=$prefer_static_libs
5560e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$use_static_libs" = built && test "$installed" = yes; then
5561e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  use_static_libs=no
5562e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
5563e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$library_names" &&
5564e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
5565e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case $host in
5566e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *cygwin* | *mingw* | *cegcc*)
5567e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # No point in relinking DLLs because paths are not encoded
5568e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      notinst_deplibs="$notinst_deplibs $lib"
5569e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      need_relink=no
5570e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
5571e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *)
5572e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "$installed" = no; then
5573e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      notinst_deplibs="$notinst_deplibs $lib"
5574e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      need_relink=yes
5575e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
5576e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
5577e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
5578e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # This is a shared library
5579e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5580e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Warn about portability, can't link against -module's on some
5581e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # systems (darwin).  Don't bleat about dlopened modules though!
5582e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  dlopenmodule=""
5583e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  for dlpremoduletest in $dlprefiles; do
5584e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "X$dlpremoduletest" = "X$lib"; then
5585e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      dlopenmodule="$dlpremoduletest"
5586e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      break
5587e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
5588e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  done
5589e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
5590e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $ECHO
5591e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "$linkmode" = prog; then
5592e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
5593e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    else
5594e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
5595e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
5596e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $ECHO "*** $linklib is not portable!"
5597e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
5598e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$linkmode" = lib &&
5599e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	     test "$hardcode_into_libs" = yes; then
5600e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Hardcode the library path.
5601e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Skip directories that are in the system default run-time
5602e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # search path.
5603e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    case " $sys_lib_dlsearch_path " in
5604e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *" $absdir "*) ;;
5605e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *)
5606e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case "$compile_rpath " in
5607e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *" $absdir "*) ;;
5608e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *) compile_rpath="$compile_rpath $absdir"
5609e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
5610e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      ;;
5611e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    esac
5612e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    case " $sys_lib_dlsearch_path " in
5613e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *" $libdir "*) ;;
5614e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *)
5615e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case "$finalize_rpath " in
5616e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *" $libdir "*) ;;
5617e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *) finalize_rpath="$finalize_rpath $libdir"
5618e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
5619e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      ;;
5620e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    esac
5621e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
5622e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5623e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -n "$old_archive_from_expsyms_cmds"; then
5624e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # figure out the soname
5625e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    set dummy $library_names
5626e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    shift
5627e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    realname="$1"
5628e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    shift
5629e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    libname=`eval "\\$ECHO \"$libname_spec\""`
5630e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # use dlname if we got it. it's perfectly good, no?
5631e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test -n "$dlname"; then
5632e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      soname="$dlname"
5633e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    elif test -n "$soname_spec"; then
5634e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # bleh windows
5635e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case $host in
5636e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *cygwin* | mingw* | *cegcc*)
5637e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	        func_arith $current - $age
5638e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		major=$func_arith_result
5639e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		versuffix="-$major"
5640e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		;;
5641e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
5642e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      eval soname=\"$soname_spec\"
5643e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    else
5644e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      soname="$realname"
5645e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
5646e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5647e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Make a new name for the extract_expsyms_cmds to use
5648e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    soroot="$soname"
5649e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_basename "$soroot"
5650e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    soname="$func_basename_result"
5651e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_stripname 'lib' '.dll' "$soname"
5652e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    newlib=libimp-$func_stripname_result.a
5653e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5654e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # If the library has no export list, then create one now
5655e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test -f "$output_objdir/$soname-def"; then :
5656e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    else
5657e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_verbose "extracting exported symbol list from \`$soname'"
5658e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
5659e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
5660e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5661e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Create $newlib
5662e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test -f "$output_objdir/$newlib"; then :; else
5663e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_verbose "generating import library for \`$soname'"
5664e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
5665e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
5666e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # make sure the library variables are pointing to the new library
5667e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    dir=$output_objdir
5668e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    linklib=$newlib
5669e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi # test -n "$old_archive_from_expsyms_cmds"
5670e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5671e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$linkmode" = prog || test "$mode" != relink; then
5672e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    add_shlibpath=
5673e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    add_dir=
5674e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    add=
5675e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    lib_linked=yes
5676e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    case $hardcode_action in
5677e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    immediate | unsupported)
5678e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      if test "$hardcode_direct" = no; then
5679e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		add="$dir/$linklib"
5680e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		case $host in
5681e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
5682e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
5683e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
5684e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    *-*-unixware7*) add_dir="-L$dir" ;;
5685e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  *-*-darwin* )
5686e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    # if the lib is a (non-dlopened) module then we can not
5687e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    # link against it, someone is ignoring the earlier warnings
5688e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    if /usr/bin/file -L $add 2> /dev/null |
5689e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			 $GREP ": [^:]* bundle" >/dev/null ; then
5690e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      if test "X$dlopenmodule" != "X$lib"; then
5691e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
5692e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			if test -z "$old_library" ; then
5693e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			  $ECHO
5694e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			  $ECHO "*** And there doesn't seem to be a static archive available"
5695e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			  $ECHO "*** The link will probably fail, sorry"
5696e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			else
5697e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			  add="$dir/$old_library"
5698e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			fi
5699e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      elif test -n "$old_library"; then
5700e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			add="$dir/$old_library"
5701e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      fi
5702e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    fi
5703e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		esac
5704e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      elif test "$hardcode_minus_L" = no; then
5705e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		case $host in
5706e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		*-*-sunos*) add_shlibpath="$dir" ;;
5707e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		esac
5708e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		add_dir="-L$dir"
5709e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		add="-l$name"
5710e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      elif test "$hardcode_shlibpath_var" = no; then
5711e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		add_shlibpath="$dir"
5712e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		add="-l$name"
5713e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      else
5714e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		lib_linked=no
5715e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      fi
5716e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      ;;
5717e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    relink)
5718e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      if test "$hardcode_direct" = yes &&
5719e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	         test "$hardcode_direct_absolute" = no; then
5720e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		add="$dir/$linklib"
5721e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      elif test "$hardcode_minus_L" = yes; then
5722e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		add_dir="-L$dir"
5723e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		# Try looking first in the location we're being installed to.
5724e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		if test -n "$inst_prefix_dir"; then
5725e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  case $libdir in
5726e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    [\\/]*)
5727e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
5728e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      ;;
5729e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  esac
5730e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		fi
5731e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		add="-l$name"
5732e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      elif test "$hardcode_shlibpath_var" = yes; then
5733e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		add_shlibpath="$dir"
5734e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		add="-l$name"
5735e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      else
5736e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		lib_linked=no
5737e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      fi
5738e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      ;;
5739e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *) lib_linked=no ;;
5740e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    esac
5741e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5742e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "$lib_linked" != yes; then
5743e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_fatal_configuration "unsupported hardcode properties"
5744e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
5745e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5746e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test -n "$add_shlibpath"; then
5747e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case :$compile_shlibpath: in
5748e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *":$add_shlibpath:"*) ;;
5749e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
5750e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
5751e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
5752e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "$linkmode" = prog; then
5753e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
5754e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
5755e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    else
5756e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
5757e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      test -n "$add" && deplibs="$add $deplibs"
5758e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      if test "$hardcode_direct" != yes &&
5759e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		 test "$hardcode_minus_L" != yes &&
5760e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		 test "$hardcode_shlibpath_var" = yes; then
5761e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		case :$finalize_shlibpath: in
5762e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		*":$libdir:"*) ;;
5763e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
5764e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		esac
5765e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      fi
5766e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
5767e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
5768e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5769e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$linkmode" = prog || test "$mode" = relink; then
5770e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    add_shlibpath=
5771e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    add_dir=
5772e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    add=
5773e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Finalize command for both is simple: just hardcode it.
5774e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "$hardcode_direct" = yes &&
5775e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	       test "$hardcode_direct_absolute" = no; then
5776e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      add="$libdir/$linklib"
5777e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    elif test "$hardcode_minus_L" = yes; then
5778e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      add_dir="-L$libdir"
5779e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      add="-l$name"
5780e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    elif test "$hardcode_shlibpath_var" = yes; then
5781e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case :$finalize_shlibpath: in
5782e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *":$libdir:"*) ;;
5783e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
5784e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
5785e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      add="-l$name"
5786e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    elif test "$hardcode_automatic" = yes; then
5787e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      if test -n "$inst_prefix_dir" &&
5788e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
5789e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		add="$inst_prefix_dir$libdir/$linklib"
5790e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      else
5791e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		add="$libdir/$linklib"
5792e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      fi
5793e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    else
5794e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # We cannot seem to hardcode it, guess we'll fake it.
5795e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      add_dir="-L$libdir"
5796e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # Try looking first in the location we're being installed to.
5797e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      if test -n "$inst_prefix_dir"; then
5798e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		case $libdir in
5799e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  [\\/]*)
5800e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
5801e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    ;;
5802e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		esac
5803e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      fi
5804e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      add="-l$name"
5805e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
5806e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5807e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "$linkmode" = prog; then
5808e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
5809e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
5810e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    else
5811e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
5812e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      test -n "$add" && deplibs="$add $deplibs"
5813e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
5814e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
5815e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	elif test "$linkmode" = prog; then
5816e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Here we assume that one of hardcode_direct or hardcode_minus_L
5817e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # is not unsupported.  This is valid on all known static and
5818e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # shared platforms.
5819e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$hardcode_direct" != unsupported; then
5820e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    test -n "$old_library" && linklib="$old_library"
5821e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    compile_deplibs="$dir/$linklib $compile_deplibs"
5822e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
5823e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
5824e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    compile_deplibs="-l$name -L$dir $compile_deplibs"
5825e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
5826e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
5827e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	elif test "$build_libtool_libs" = yes; then
5828e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Not a shared library
5829e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$deplibs_check_method" != pass_all; then
5830e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # We're trying link a shared library against a static one
5831e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # but the system doesn't support it.
5832e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5833e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Just print a warning and add the library to dependency_libs so
5834e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # that the program can be linked against the static library.
5835e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $ECHO
5836e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
5837e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $ECHO "*** I have the capability to make that library automatically link in when"
5838e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $ECHO "*** you link to this library.  But I can only do this if you have a"
5839e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $ECHO "*** shared version of the library, which you do not appear to have."
5840e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "$module" = yes; then
5841e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $ECHO "*** But as you try to build a module library, libtool will still create "
5842e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $ECHO "*** a static module, that should work as long as the dlopening application"
5843e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime."
5844e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      if test -z "$global_symbol_pipe"; then
5845e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$ECHO
5846e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$ECHO "*** However, this would only work if libtool was able to extract symbol"
5847e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
5848e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$ECHO "*** not find such a program.  So, this module is probably useless."
5849e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
5850e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      fi
5851e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      if test "$build_old_libs" = no; then
5852e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		build_libtool_libs=module
5853e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		build_old_libs=yes
5854e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      else
5855e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		build_libtool_libs=no
5856e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      fi
5857e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
5858e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
5859e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    deplibs="$dir/$old_library $deplibs"
5860e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    link_static=yes
5861e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
5862e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi # link shared/static library?
5863e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5864e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$linkmode" = lib; then
5865e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -n "$dependency_libs" &&
5866e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	     { test "$hardcode_into_libs" != yes ||
5867e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	       test "$build_old_libs" = yes ||
5868e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	       test "$link_static" = yes; }; then
5869e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Extract -R from dependency_libs
5870e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    temp_deplibs=
5871e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    for libdir in $dependency_libs; do
5872e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case $libdir in
5873e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      -R*) func_stripname '-R' '' "$libdir"
5874e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	           temp_xrpath=$func_stripname_result
5875e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		   case " $xrpath " in
5876e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		   *" $temp_xrpath "*) ;;
5877e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		   *) xrpath="$xrpath $temp_xrpath";;
5878e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		   esac;;
5879e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *) temp_deplibs="$temp_deplibs $libdir";;
5880e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
5881e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    done
5882e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    dependency_libs="$temp_deplibs"
5883e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
5884e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5885e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  newlib_search_path="$newlib_search_path $absdir"
5886e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Link against this library
5887e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
5888e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # ... and its dependency_libs
5889e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  tmp_libs=
5890e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  for deplib in $dependency_libs; do
5891e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    newdependency_libs="$deplib $newdependency_libs"
5892e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if $opt_duplicate_deps ; then
5893e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case "$tmp_libs " in
5894e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5895e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
5896e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
5897e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    tmp_libs="$tmp_libs $deplib"
5898e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  done
5899e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5900e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$link_all_deplibs" != no; then
5901e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Add the search paths of all dependency libraries
5902e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    for deplib in $dependency_libs; do
5903e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case $deplib in
5904e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      -L*) path="$deplib" ;;
5905e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *.la)
5906e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	        func_dirname "$deplib" "" "."
5907e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		dir="$func_dirname_result"
5908e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		# We need an absolute path.
5909e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		case $dir in
5910e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
5911e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		*)
5912e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  absdir=`cd "$dir" && pwd`
5913e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  if test -z "$absdir"; then
5914e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    func_warning "cannot determine absolute directory name of \`$dir'"
5915e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    absdir="$dir"
5916e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  fi
5917e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  ;;
5918e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		esac
5919e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		if $GREP "^installed=no" $deplib > /dev/null; then
5920e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		case $host in
5921e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		*-*-darwin*)
5922e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  depdepl=
5923e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
5924e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  if test -n "$deplibrary_names" ; then
5925e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    for tmp in $deplibrary_names ; do
5926e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      depdepl=$tmp
5927e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    done
5928e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    if test -f "$absdir/$objdir/$depdepl" ; then
5929e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      depdepl="$absdir/$objdir/$depdepl"
5930e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
5931e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev                      if test -z "$darwin_install_name"; then
5932e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
5933e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev                      fi
5934e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
5935e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
5936e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      path=
5937e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    fi
5938e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  fi
5939e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  ;;
5940e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		*)
5941e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  path="-L$absdir/$objdir"
5942e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  ;;
5943e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		esac
5944e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		else
5945e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
5946e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  test -z "$libdir" && \
5947e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    func_fatal_error "\`$deplib' is not a valid libtool archive"
5948e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  test "$absdir" != "$libdir" && \
5949e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    func_warning "\`$deplib' seems to be moved"
5950e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5951e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  path="-L$absdir"
5952e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		fi
5953e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		;;
5954e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
5955e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case " $deplibs " in
5956e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *" $path "*) ;;
5957e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *) deplibs="$path $deplibs" ;;
5958e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
5959e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    done
5960e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi # link_all_deplibs != no
5961e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi # linkmode = lib
5962e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      done # for deplib in $libs
5963e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "$pass" = link; then
5964e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$linkmode" = "prog"; then
5965e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
5966e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
5967e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	else
5968e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
5969e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
5970e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
5971e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      dependency_libs="$newdependency_libs"
5972e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "$pass" = dlpreopen; then
5973e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Link the dlpreopened libraries before other libraries
5974e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	for deplib in $save_deplibs; do
5975e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  deplibs="$deplib $deplibs"
5976e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	done
5977e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
5978e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "$pass" != dlopen; then
5979e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$pass" != conv; then
5980e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Make sure lib_search_path contains only unique directories.
5981e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  lib_search_path=
5982e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  for dir in $newlib_search_path; do
5983e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    case "$lib_search_path " in
5984e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *" $dir "*) ;;
5985e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *) lib_search_path="$lib_search_path $dir" ;;
5986e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    esac
5987e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  done
5988e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  newlib_search_path=
5989e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
5990e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
5991e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$linkmode,$pass" != "prog,link"; then
5992e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  vars="deplibs"
5993e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	else
5994e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  vars="compile_deplibs finalize_deplibs"
5995e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
5996e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	for var in $vars dependency_libs; do
5997e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Add libraries to $var in reverse order
5998e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  eval tmp_libs=\"\$$var\"
5999e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  new_libs=
6000e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  for deplib in $tmp_libs; do
6001e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # FIXME: Pedantically, this is the right thing to do, so
6002e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    #        that some nasty dependency loop isn't accidentally
6003e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    #        broken:
6004e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    #new_libs="$deplib $new_libs"
6005e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Pragmatically, this seems to cause very few problems in
6006e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # practice:
6007e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    case $deplib in
6008e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    -L*) new_libs="$deplib $new_libs" ;;
6009e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    -R*) ;;
6010e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *)
6011e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # And here is the reason: when a library appears more
6012e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # than once as an explicit dependence of a library, or
6013e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # is implicitly linked in more than once by the
6014e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # compiler, it is considered special, and multiple
6015e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # occurrences thereof are not removed.  Compare this
6016e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # with having the same library being listed as a
6017e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # dependency of multiple other libraries: in this case,
6018e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # we know (pedantically, we assume) the library does not
6019e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # need to be listed more than once, so we keep only the
6020e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # last copy.  This is not always right, but it is rare
6021e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # enough that we require users that really mean to play
6022e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # such unportable linking tricks to link the library
6023e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # using -Wl,-lname, so that libtool does not consider it
6024e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # for duplicate removal.
6025e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case " $specialdeplibs " in
6026e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
6027e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *)
6028e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		case " $new_libs " in
6029e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		*" $deplib "*) ;;
6030e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		*) new_libs="$deplib $new_libs" ;;
6031e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		esac
6032e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		;;
6033e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
6034e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      ;;
6035e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    esac
6036e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  done
6037e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  tmp_libs=
6038e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  for deplib in $new_libs; do
6039e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    case $deplib in
6040e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    -L*)
6041e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case " $tmp_libs " in
6042e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *" $deplib "*) ;;
6043e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *) tmp_libs="$tmp_libs $deplib" ;;
6044e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
6045e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      ;;
6046e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *) tmp_libs="$tmp_libs $deplib" ;;
6047e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    esac
6048e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  done
6049e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  eval $var=\"$tmp_libs\"
6050e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	done # for var
6051e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
6052e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Last step: remove runtime libs from dependency_libs
6053e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # (they stay in deplibs)
6054e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      tmp_libs=
6055e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      for i in $dependency_libs ; do
6056e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case " $predeps $postdeps $compiler_lib_search_path " in
6057e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*" $i "*)
6058e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  i=""
6059e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
6060e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
6061e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$i" ; then
6062e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  tmp_libs="$tmp_libs $i"
6063e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
6064e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      done
6065e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      dependency_libs=$tmp_libs
6066e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    done # for pass
6067e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test "$linkmode" = prog; then
6068e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      dlfiles="$newdlfiles"
6069e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
6070e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    if test "$linkmode" = prog || test "$linkmode" = lib; then
6071e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      dlprefiles="$newdlprefiles"
6072e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    fi
6073e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6074e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    case $linkmode in
6075e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    oldlib)
6076e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
6077e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_warning "\`-dlopen' is ignored for archives"
6078e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
6079e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6080e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      case " $deplibs" in
6081e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *\ -l* | *\ -L*)
6082e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_warning "\`-l' and \`-L' are ignored for archives" ;;
6083e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      esac
6084e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6085e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      test -n "$rpath" && \
6086e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_warning "\`-rpath' is ignored for archives"
6087e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6088e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      test -n "$xrpath" && \
6089e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_warning "\`-R' is ignored for archives"
6090e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6091e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      test -n "$vinfo" && \
6092e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_warning "\`-version-info/-version-number' is ignored for archives"
6093e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6094e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      test -n "$release" && \
6095e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_warning "\`-release' is ignored for archives"
6096e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6097e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      test -n "$export_symbols$export_symbols_regex" && \
6098e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_warning "\`-export-symbols' is ignored for archives"
6099e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6100e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Now set the variables for building old libraries.
6101e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      build_libtool_libs=no
6102e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      oldlibs="$output"
6103e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      objs="$objs$old_deplibs"
6104e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      ;;
6105e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6106e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    lib)
6107e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Make sure we only generate libraries of the form `libNAME.la'.
6108e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      case $outputname in
6109e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      lib*)
6110e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_stripname 'lib' '.la' "$outputname"
6111e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	name=$func_stripname_result
6112e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	eval shared_ext=\"$shrext_cmds\"
6113e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	eval libname=\"$libname_spec\"
6114e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
6115e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *)
6116e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	test "$module" = no && \
6117e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
6118e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6119e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$need_lib_prefix" != no; then
6120e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Add the "lib" prefix for modules if required
6121e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_stripname '' '.la' "$outputname"
6122e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  name=$func_stripname_result
6123e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  eval shared_ext=\"$shrext_cmds\"
6124e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  eval libname=\"$libname_spec\"
6125e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	else
6126e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_stripname '' '.la' "$outputname"
6127e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  libname=$func_stripname_result
6128e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
6129e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
6130e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      esac
6131e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6132e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -n "$objs"; then
6133e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$deplibs_check_method" != pass_all; then
6134e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
6135e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	else
6136e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  $ECHO
6137e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
6138e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  $ECHO "*** objects $objs is not portable!"
6139e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  libobjs="$libobjs $objs"
6140e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
6141e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
6142e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6143e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      test "$dlself" != no && \
6144e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_warning "\`-dlopen self' is ignored for libtool libraries"
6145e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6146e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      set dummy $rpath
6147e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      shift
6148e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      test "$#" -gt 1 && \
6149e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_warning "ignoring multiple \`-rpath's for a libtool library"
6150e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6151e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      install_libdir="$1"
6152e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6153e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      oldlibs=
6154e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -z "$rpath"; then
6155e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$build_libtool_libs" = yes; then
6156e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Building a libtool convenience library.
6157e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Some compilers have problems with a `.al' extension so
6158e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # convenience libraries should have the same extension an
6159e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # archive normally would.
6160e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
6161e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  build_libtool_libs=convenience
6162e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  build_old_libs=yes
6163e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
6164e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6165e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	test -n "$vinfo" && \
6166e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
6167e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6168e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	test -n "$release" && \
6169e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_warning "\`-release' is ignored for convenience libraries"
6170e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      else
6171e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6172e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Parse the version information argument.
6173e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	save_ifs="$IFS"; IFS=':'
6174e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	set dummy $vinfo 0 0 0
6175e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	shift
6176e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	IFS="$save_ifs"
6177e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6178e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	test -n "$7" && \
6179e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_fatal_help "too many parameters to \`-version-info'"
6180e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6181e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# convert absolute version numbers to libtool ages
6182e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# this retains compatibility with .la files and attempts
6183e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# to make the code below a bit more comprehensible
6184e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6185e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $vinfo_number in
6186e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	yes)
6187e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  number_major="$1"
6188e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  number_minor="$2"
6189e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  number_revision="$3"
6190e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  #
6191e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # There are really only two kinds -- those that
6192e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # use the current revision as the major version
6193e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # and those that subtract age and use age as
6194e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # a minor version.  But, then there is irix
6195e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # which has an extra 1 added just for fun
6196e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  #
6197e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case $version_type in
6198e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  darwin|linux|osf|windows|none)
6199e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_arith $number_major + $number_minor
6200e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    current=$func_arith_result
6201e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    age="$number_minor"
6202e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    revision="$number_revision"
6203e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
6204e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  freebsd-aout|freebsd-elf|sunos)
6205e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    current="$number_major"
6206e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    revision="$number_minor"
6207e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    age="0"
6208e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
6209e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  irix|nonstopux)
6210e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_arith $number_major + $number_minor
6211e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    current=$func_arith_result
6212e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    age="$number_minor"
6213e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    revision="$number_minor"
6214e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    lt_irix_increment=no
6215e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
6216e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
6217e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
6218e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	no)
6219e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  current="$1"
6220e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  revision="$2"
6221e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  age="$3"
6222e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
6223e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
6224e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6225e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Check that each of the things are valid numbers.
6226e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $current in
6227e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	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]) ;;
6228e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*)
6229e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_error "CURRENT \`$current' must be a nonnegative integer"
6230e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_fatal_error "\`$vinfo' is not valid version information"
6231e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
6232e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
6233e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6234e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $revision in
6235e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	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]) ;;
6236e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*)
6237e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_error "REVISION \`$revision' must be a nonnegative integer"
6238e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_fatal_error "\`$vinfo' is not valid version information"
6239e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
6240e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
6241e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6242e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $age in
6243e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	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]) ;;
6244e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*)
6245e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_error "AGE \`$age' must be a nonnegative integer"
6246e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_fatal_error "\`$vinfo' is not valid version information"
6247e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
6248e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
6249e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6250e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$age" -gt "$current"; then
6251e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
6252e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_fatal_error "\`$vinfo' is not valid version information"
6253e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
6254e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6255e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Calculate the version variables.
6256e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	major=
6257e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	versuffix=
6258e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	verstring=
6259e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $version_type in
6260e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	none) ;;
6261e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6262e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	darwin)
6263e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Like Linux, but with the current version available in
6264e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # verstring for coding it into the library header
6265e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_arith $current - $age
6266e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  major=.$func_arith_result
6267e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  versuffix="$major.$age.$revision"
6268e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Darwin ld doesn't like 0 for these options...
6269e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_arith $current + 1
6270e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  minor_current=$func_arith_result
6271e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
6272e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
6273e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
6274e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6275e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	freebsd-aout)
6276e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  major=".$current"
6277e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  versuffix=".$current.$revision";
6278e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
6279e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6280e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	freebsd-elf)
6281e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  major=".$current"
6282e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  versuffix=".$current"
6283e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
6284e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6285e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	irix | nonstopux)
6286e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "X$lt_irix_increment" = "Xno"; then
6287e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_arith $current - $age
6288e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
6289e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_arith $current - $age + 1
6290e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
6291e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  major=$func_arith_result
6292e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6293e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case $version_type in
6294e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    nonstopux) verstring_prefix=nonstopux ;;
6295e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *)         verstring_prefix=sgi ;;
6296e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
6297e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  verstring="$verstring_prefix$major.$revision"
6298e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6299e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Add in all the interfaces that we are compatible with.
6300e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  loop=$revision
6301e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  while test "$loop" -ne 0; do
6302e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_arith $revision - $loop
6303e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    iface=$func_arith_result
6304e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_arith $loop - 1
6305e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    loop=$func_arith_result
6306e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    verstring="$verstring_prefix$major.$iface:$verstring"
6307e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  done
6308e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6309e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Before this point, $major must not contain `.'.
6310e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  major=.$major
6311e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  versuffix="$major.$revision"
6312e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
6313e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6314e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	linux)
6315e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_arith $current - $age
6316e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  major=.$func_arith_result
6317e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  versuffix="$major.$age.$revision"
6318e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
6319e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6320e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	osf)
6321e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_arith $current - $age
6322e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  major=.$func_arith_result
6323e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  versuffix=".$current.$age.$revision"
6324e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  verstring="$current.$age.$revision"
6325e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6326e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Add in all the interfaces that we are compatible with.
6327e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  loop=$age
6328e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  while test "$loop" -ne 0; do
6329e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_arith $current - $loop
6330e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    iface=$func_arith_result
6331e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_arith $loop - 1
6332e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    loop=$func_arith_result
6333e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    verstring="$verstring:${iface}.0"
6334e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  done
6335e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6336e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Make executables depend on our current version.
6337e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  verstring="$verstring:${current}.0"
6338e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
6339e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6340e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	qnx)
6341e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  major=".$current"
6342e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  versuffix=".$current"
6343e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
6344e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6345e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	sunos)
6346e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  major=".$current"
6347e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  versuffix=".$current.$revision"
6348e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
6349e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6350e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	windows)
6351e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Use '-' rather than '.', since we only want one
6352e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # extension on DOS 8.3 filesystems.
6353e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_arith $current - $age
6354e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  major=$func_arith_result
6355e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  versuffix="-$major"
6356e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
6357e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6358e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*)
6359e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_fatal_configuration "unknown library version type \`$version_type'"
6360e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
6361e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
6362e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6363e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Clear the version info if we defaulted, and they specified a release.
6364e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -z "$vinfo" && test -n "$release"; then
6365e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  major=
6366e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case $version_type in
6367e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  darwin)
6368e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # we can't check for "0.0" in archive_cmds due to quoting
6369e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # problems, so we reset it completely
6370e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    verstring=
6371e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
6372e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *)
6373e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    verstring="0.0"
6374e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
6375e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
6376e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$need_version" = no; then
6377e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    versuffix=
6378e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
6379e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    versuffix=".0.0"
6380e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
6381e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
6382e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6383e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Remove version info from name if versioning should be avoided
6384e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$avoid_version" = yes && test "$need_version" = no; then
6385e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  major=
6386e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  versuffix=
6387e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  verstring=""
6388e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
6389e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6390e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Check to see if the archive will have undefined symbols.
6391e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$allow_undefined" = yes; then
6392e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$allow_undefined_flag" = unsupported; then
6393e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_warning "undefined symbols not allowed in $host shared libraries"
6394e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    build_libtool_libs=no
6395e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    build_old_libs=yes
6396e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
6397e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	else
6398e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Don't allow undefined symbols.
6399e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  allow_undefined_flag="$no_undefined_flag"
6400e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
6401e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6402e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
6403e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6404e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_generate_dlsyms "$libname" "$libname" "yes"
6405e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      libobjs="$libobjs $symfileobj"
6406e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      test "X$libobjs" = "X " && libobjs=
6407e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6408e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "$mode" != relink; then
6409e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Remove our outputs, but don't remove object files since they
6410e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# may have been created when compiling PIC objects.
6411e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	removelist=
6412e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	tempremovelist=`$ECHO "$output_objdir/*"`
6413e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	for p in $tempremovelist; do
6414e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case $p in
6415e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *.$objext | *.gcno)
6416e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	       ;;
6417e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
6418e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	       if test "X$precious_files_regex" != "X"; then
6419e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
6420e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		 then
6421e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		   continue
6422e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		 fi
6423e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	       fi
6424e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	       removelist="$removelist $p"
6425e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	       ;;
6426e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *) ;;
6427e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
6428e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	done
6429e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	test -n "$removelist" && \
6430e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_show_eval "${RM}r \$removelist"
6431e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
6432e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6433e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Now set the variables for building old libraries.
6434e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
6435e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	oldlibs="$oldlibs $output_objdir/$libname.$libext"
6436e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6437e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Transform .lo files to .o files.
6438e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
6439e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
6440e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6441e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Eliminate all temporary directories.
6442e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      #for path in $notinst_path; do
6443e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      #	lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"`
6444e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      #	deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"`
6445e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      #	dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"`
6446e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      #done
6447e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6448e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -n "$xrpath"; then
6449e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# If the user specified any rpath flags, then add them.
6450e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	temp_xrpath=
6451e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	for libdir in $xrpath; do
6452e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  temp_xrpath="$temp_xrpath -R$libdir"
6453e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case "$finalize_rpath " in
6454e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *" $libdir "*) ;;
6455e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *) finalize_rpath="$finalize_rpath $libdir" ;;
6456e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
6457e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	done
6458e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
6459e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  dependency_libs="$temp_xrpath $dependency_libs"
6460e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
6461e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
6462e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6463e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Make sure dlfiles contains only unique files that won't be dlpreopened
6464e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      old_dlfiles="$dlfiles"
6465e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      dlfiles=
6466e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      for lib in $old_dlfiles; do
6467e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case " $dlprefiles $dlfiles " in
6468e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*" $lib "*) ;;
6469e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*) dlfiles="$dlfiles $lib" ;;
6470e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
6471e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      done
6472e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6473e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Make sure dlprefiles contains only unique files
6474e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      old_dlprefiles="$dlprefiles"
6475e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      dlprefiles=
6476e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      for lib in $old_dlprefiles; do
6477e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case "$dlprefiles " in
6478e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*" $lib "*) ;;
6479e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*) dlprefiles="$dlprefiles $lib" ;;
6480e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
6481e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      done
6482e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6483e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "$build_libtool_libs" = yes; then
6484e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$rpath"; then
6485e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case $host in
6486e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc*)
6487e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # these systems don't actually have a c library (as such)!
6488e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
6489e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *-*-rhapsody* | *-*-darwin1.[012])
6490e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Rhapsody C library is in the System framework
6491e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    deplibs="$deplibs System.ltframework"
6492e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
6493e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *-*-netbsd*)
6494e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Don't link with libc until the a.out ld.so is fixed.
6495e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
6496e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
6497e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Do not include libc due to us having libc/libc_r.
6498e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
6499e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *-*-sco3.2v5* | *-*-sco5v6*)
6500e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Causes problems with __ctype
6501e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
6502e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
6503e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Compiler inserts libc in the correct place for threads to work
6504e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
6505e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *)
6506e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Add libc to deplibs on all other systems if necessary.
6507e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "$build_libtool_need_lc" = "yes"; then
6508e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      deplibs="$deplibs -lc"
6509e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
6510e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
6511e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
6512e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
6513e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6514e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Transform deplibs into only deplibs that can be linked in shared.
6515e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	name_save=$name
6516e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	libname_save=$libname
6517e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	release_save=$release
6518e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	versuffix_save=$versuffix
6519e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	major_save=$major
6520e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# I'm not sure if I'm treating the release correctly.  I think
6521e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# release should show up in the -l (ie -lgmp5) so we don't want to
6522e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# add it in twice.  Is that correct?
6523e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	release=""
6524e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	versuffix=""
6525e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	major=""
6526e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	newdeplibs=
6527e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	droppeddeps=no
6528e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $deplibs_check_method in
6529e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	pass_all)
6530e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Don't check for shared/static.  Everything works.
6531e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # This might be a little naive.  We might want to check
6532e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # whether the library exists or not.  But this is on
6533e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # osf3 & osf4 and I'm not really sure... Just
6534e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # implementing what was already the behavior.
6535e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  newdeplibs=$deplibs
6536e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
6537e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	test_compile)
6538e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # This code stresses the "libraries are programs" paradigm to its
6539e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # limits. Maybe even breaks it.  We compile a program, linking it
6540e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # against the deplibs as a proxy for the library.  Then we can check
6541e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # whether they linked in statically or dynamically with ldd.
6542e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  $opt_dry_run || $RM conftest.c
6543e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  cat > conftest.c <<EOF
6544e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  int main() { return 0; }
6545e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor GoulishevEOF
6546e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  $opt_dry_run || $RM conftest
6547e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
6548e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ldd_output=`ldd conftest`
6549e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    for i in $deplibs; do
6550e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case $i in
6551e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      -l*)
6552e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		func_stripname -l '' "$i"
6553e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		name=$func_stripname_result
6554e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6555e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  case " $predeps $postdeps " in
6556e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  *" $i "*)
6557e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    newdeplibs="$newdeplibs $i"
6558e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    i=""
6559e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    ;;
6560e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  esac
6561e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		fi
6562e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		if test -n "$i" ; then
6563e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  libname=`eval "\\$ECHO \"$libname_spec\""`
6564e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
6565e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  set dummy $deplib_matches; shift
6566e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  deplib_match=$1
6567e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
6568e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    newdeplibs="$newdeplibs $i"
6569e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  else
6570e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    droppeddeps=yes
6571e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    $ECHO
6572e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
6573e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    $ECHO "*** I have the capability to make that library automatically link in when"
6574e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    $ECHO "*** you link to this library.  But I can only do this if you have a"
6575e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    $ECHO "*** shared version of the library, which I believe you do not have"
6576e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    $ECHO "*** because a test_compile did reveal that the linker did not use it for"
6577e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    $ECHO "*** its dynamic dependency list that programs get resolved with at runtime."
6578e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  fi
6579e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		fi
6580e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		;;
6581e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *)
6582e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		newdeplibs="$newdeplibs $i"
6583e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		;;
6584e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
6585e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    done
6586e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
6587e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Error occurred in the first compile.  Let's try to salvage
6588e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # the situation: Compile a separate program for each library.
6589e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    for i in $deplibs; do
6590e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case $i in
6591e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      -l*)
6592e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		func_stripname -l '' "$i"
6593e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		name=$func_stripname_result
6594e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$opt_dry_run || $RM conftest
6595e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
6596e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  ldd_output=`ldd conftest`
6597e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6598e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    case " $predeps $postdeps " in
6599e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    *" $i "*)
6600e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      newdeplibs="$newdeplibs $i"
6601e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      i=""
6602e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      ;;
6603e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    esac
6604e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  fi
6605e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  if test -n "$i" ; then
6606e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    libname=`eval "\\$ECHO \"$libname_spec\""`
6607e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
6608e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    set dummy $deplib_matches; shift
6609e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    deplib_match=$1
6610e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
6611e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      newdeplibs="$newdeplibs $i"
6612e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    else
6613e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      droppeddeps=yes
6614e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      $ECHO
6615e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
6616e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      $ECHO "*** I have the capability to make that library automatically link in when"
6617e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      $ECHO "*** you link to this library.  But I can only do this if you have a"
6618e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      $ECHO "*** shared version of the library, which you do not appear to have"
6619e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      $ECHO "*** because a test_compile did reveal that the linker did not use this one"
6620e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      $ECHO "*** as a dynamic dependency that programs can get resolved with at runtime."
6621e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    fi
6622e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  fi
6623e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		else
6624e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  droppeddeps=yes
6625e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  $ECHO
6626e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
6627e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  $ECHO "*** make it link in!  You will probably need to install it or some"
6628e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  $ECHO "*** library that it depends on before this library will be fully"
6629e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  $ECHO "*** functional.  Installing it before continuing would be even better."
6630e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		fi
6631e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		;;
6632e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *)
6633e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		newdeplibs="$newdeplibs $i"
6634e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		;;
6635e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
6636e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    done
6637e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
6638e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
6639e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	file_magic*)
6640e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  set dummy $deplibs_check_method; shift
6641e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6642e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  for a_deplib in $deplibs; do
6643e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    case $a_deplib in
6644e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    -l*)
6645e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_stripname -l '' "$a_deplib"
6646e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      name=$func_stripname_result
6647e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6648e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		case " $predeps $postdeps " in
6649e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		*" $a_deplib "*)
6650e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  newdeplibs="$newdeplibs $a_deplib"
6651e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  a_deplib=""
6652e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  ;;
6653e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		esac
6654e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      fi
6655e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      if test -n "$a_deplib" ; then
6656e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		libname=`eval "\\$ECHO \"$libname_spec\""`
6657e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
6658e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
6659e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  for potent_lib in $potential_libs; do
6660e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      # Follow soft links.
6661e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      if ls -lLd "$potent_lib" 2>/dev/null |
6662e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			 $GREP " -> " >/dev/null; then
6663e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			continue
6664e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      fi
6665e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      # The statement above tries to avoid entering an
6666e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      # endless loop below, in case of cyclic links.
6667e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      # We might still enter an endless loop, since a link
6668e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      # loop can be closed while we follow links,
6669e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      # but so what?
6670e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      potlib="$potent_lib"
6671e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      while test -h "$potlib" 2>/dev/null; do
6672e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
6673e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			case $potliblink in
6674e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
6675e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			*) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
6676e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			esac
6677e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      done
6678e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
6679e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			 $SED -e 10q |
6680e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			 $EGREP "$file_magic_regex" > /dev/null; then
6681e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			newdeplibs="$newdeplibs $a_deplib"
6682e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			a_deplib=""
6683e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			break 2
6684e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      fi
6685e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  done
6686e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		done
6687e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      fi
6688e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      if test -n "$a_deplib" ; then
6689e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		droppeddeps=yes
6690e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$ECHO
6691e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
6692e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$ECHO "*** I have the capability to make that library automatically link in when"
6693e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$ECHO "*** you link to this library.  But I can only do this if you have a"
6694e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$ECHO "*** shared version of the library, which you do not appear to have"
6695e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$ECHO "*** because I did check the linker path looking for a file starting"
6696e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		if test -z "$potlib" ; then
6697e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
6698e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		else
6699e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  $ECHO "*** with $libname and none of the candidates passed a file format test"
6700e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  $ECHO "*** using a file magic. Last file checked: $potlib"
6701e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		fi
6702e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      fi
6703e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      ;;
6704e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *)
6705e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # Add a -L argument.
6706e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      newdeplibs="$newdeplibs $a_deplib"
6707e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      ;;
6708e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    esac
6709e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  done # Gone through all deplibs.
6710e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
6711e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	match_pattern*)
6712e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  set dummy $deplibs_check_method; shift
6713e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6714e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  for a_deplib in $deplibs; do
6715e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    case $a_deplib in
6716e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    -l*)
6717e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_stripname -l '' "$a_deplib"
6718e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      name=$func_stripname_result
6719e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6720e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		case " $predeps $postdeps " in
6721e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		*" $a_deplib "*)
6722e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  newdeplibs="$newdeplibs $a_deplib"
6723e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  a_deplib=""
6724e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  ;;
6725e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		esac
6726e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      fi
6727e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      if test -n "$a_deplib" ; then
6728e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		libname=`eval "\\$ECHO \"$libname_spec\""`
6729e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
6730e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
6731e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  for potent_lib in $potential_libs; do
6732e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    potlib="$potent_lib" # see symlink-check above in file_magic test
6733e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \
6734e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		       $EGREP "$match_pattern_regex" > /dev/null; then
6735e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      newdeplibs="$newdeplibs $a_deplib"
6736e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      a_deplib=""
6737e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		      break 2
6738e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    fi
6739e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  done
6740e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		done
6741e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      fi
6742e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      if test -n "$a_deplib" ; then
6743e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		droppeddeps=yes
6744e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$ECHO
6745e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
6746e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$ECHO "*** I have the capability to make that library automatically link in when"
6747e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$ECHO "*** you link to this library.  But I can only do this if you have a"
6748e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$ECHO "*** shared version of the library, which you do not appear to have"
6749e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$ECHO "*** because I did check the linker path looking for a file starting"
6750e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		if test -z "$potlib" ; then
6751e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
6752e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		else
6753e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  $ECHO "*** with $libname and none of the candidates passed a file format test"
6754e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
6755e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		fi
6756e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      fi
6757e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      ;;
6758e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *)
6759e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # Add a -L argument.
6760e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      newdeplibs="$newdeplibs $a_deplib"
6761e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      ;;
6762e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    esac
6763e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  done # Gone through all deplibs.
6764e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
6765e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	none | unknown | *)
6766e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  newdeplibs=""
6767e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \
6768e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'`
6769e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6770e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    for i in $predeps $postdeps ; do
6771e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # can't use Xsed below, because $i might contain '/'
6772e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"`
6773e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    done
6774e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
6775e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[	 ]//g' |
6776e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	     $GREP . >/dev/null; then
6777e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $ECHO
6778e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "X$deplibs_check_method" = "Xnone"; then
6779e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $ECHO "*** Warning: inter-library dependencies are not supported in this platform."
6780e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    else
6781e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $ECHO "*** Warning: inter-library dependencies are not known to be supported."
6782e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
6783e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $ECHO "*** All declared inter-library dependencies are being dropped."
6784e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    droppeddeps=yes
6785e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
6786e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
6787e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
6788e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	versuffix=$versuffix_save
6789e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	major=$major_save
6790e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	release=$release_save
6791e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	libname=$libname_save
6792e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	name=$name_save
6793e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6794e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $host in
6795e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*-*-rhapsody* | *-*-darwin1.[012])
6796e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # On Rhapsody replace the C library with the System framework
6797e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
6798e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
6799e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
6800e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6801e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$droppeddeps" = yes; then
6802e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$module" = yes; then
6803e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $ECHO
6804e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $ECHO "*** Warning: libtool could not satisfy all declared inter-library"
6805e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
6806e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $ECHO "*** a static module, that should work as long as the dlopening"
6807e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $ECHO "*** application is linked with the -dlopen flag."
6808e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test -z "$global_symbol_pipe"; then
6809e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $ECHO
6810e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $ECHO "*** However, this would only work if libtool was able to extract symbol"
6811e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
6812e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $ECHO "*** not find such a program.  So, this module is probably useless."
6813e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
6814e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
6815e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "$build_old_libs" = no; then
6816e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      oldlibs="$output_objdir/$libname.$libext"
6817e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      build_libtool_libs=module
6818e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      build_old_libs=yes
6819e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    else
6820e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      build_libtool_libs=no
6821e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
6822e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
6823e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $ECHO "*** The inter-library dependencies that have been dropped here will be"
6824e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $ECHO "*** automatically added whenever a program is linked with this library"
6825e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $ECHO "*** or is declared to -dlopen it."
6826e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6827e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "$allow_undefined" = no; then
6828e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $ECHO
6829e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $ECHO "*** Since this library must not contain undefined symbols,"
6830e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $ECHO "*** because either the platform does not support them or"
6831e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $ECHO "*** it was explicitly requested with -no-undefined,"
6832e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $ECHO "*** libtool will only create a static version of it."
6833e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      if test "$build_old_libs" = no; then
6834e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		oldlibs="$output_objdir/$libname.$libext"
6835e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		build_libtool_libs=module
6836e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		build_old_libs=yes
6837e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      else
6838e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		build_libtool_libs=no
6839e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      fi
6840e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
6841e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
6842e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
6843e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Done checking deplibs!
6844e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	deplibs=$newdeplibs
6845e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
6846e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
6847e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      case $host in
6848e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*-*-darwin*)
6849e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6850e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6851e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6852e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
6853e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      esac
6854e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6855e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # move library search paths that coincide with paths to not yet
6856e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # installed libraries to the beginning of the library search list
6857e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      new_libs=
6858e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      for path in $notinst_path; do
6859e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case " $new_libs " in
6860e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*" -L$path/$objdir "*) ;;
6861e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*)
6862e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case " $deplibs " in
6863e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *" -L$path/$objdir "*)
6864e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    new_libs="$new_libs -L$path/$objdir" ;;
6865e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
6866e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
6867e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
6868e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      done
6869e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      for deplib in $deplibs; do
6870e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $deplib in
6871e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	-L*)
6872e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case " $new_libs " in
6873e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *" $deplib "*) ;;
6874e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *) new_libs="$new_libs $deplib" ;;
6875e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
6876e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
6877e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*) new_libs="$new_libs $deplib" ;;
6878e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
6879e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      done
6880e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      deplibs="$new_libs"
6881e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6882e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # All the library-specific variables (install_libdir is set above).
6883e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      library_names=
6884e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      old_library=
6885e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      dlname=
6886e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6887e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Test again, we may have decided not to build it any more
6888e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "$build_libtool_libs" = yes; then
6889e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$hardcode_into_libs" = yes; then
6890e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Hardcode the library paths
6891e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  hardcode_libdirs=
6892e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  dep_rpath=
6893e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  rpath="$finalize_rpath"
6894e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  test "$mode" != relink && rpath="$compile_rpath$rpath"
6895e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  for libdir in $rpath; do
6896e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test -n "$hardcode_libdir_flag_spec"; then
6897e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      if test -n "$hardcode_libdir_separator"; then
6898e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		if test -z "$hardcode_libdirs"; then
6899e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  hardcode_libdirs="$libdir"
6900e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		else
6901e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  # Just accumulate the unique libdirs.
6902e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
6903e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
6904e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    ;;
6905e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  *)
6906e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
6907e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    ;;
6908e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  esac
6909e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		fi
6910e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      else
6911e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		eval flag=\"$hardcode_libdir_flag_spec\"
6912e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		dep_rpath="$dep_rpath $flag"
6913e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      fi
6914e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    elif test -n "$runpath_var"; then
6915e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case "$perm_rpath " in
6916e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *" $libdir "*) ;;
6917e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *) perm_rpath="$perm_rpath $libdir" ;;
6918e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
6919e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
6920e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  done
6921e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Substitute the hardcoded libdirs into the rpath.
6922e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -n "$hardcode_libdir_separator" &&
6923e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	     test -n "$hardcode_libdirs"; then
6924e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    libdir="$hardcode_libdirs"
6925e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test -n "$hardcode_libdir_flag_spec_ld"; then
6926e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
6927e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    else
6928e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
6929e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
6930e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
6931e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
6932e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # We should set the runpath_var.
6933e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    rpath=
6934e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    for dir in $perm_rpath; do
6935e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      rpath="$rpath$dir:"
6936e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    done
6937e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
6938e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
6939e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
6940e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
6941e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6942e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	shlibpath="$finalize_shlibpath"
6943e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
6944e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$shlibpath"; then
6945e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
6946e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
6947e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6948e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Get the real and link names of the library.
6949e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	eval shared_ext=\"$shrext_cmds\"
6950e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	eval library_names=\"$library_names_spec\"
6951e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	set dummy $library_names
6952e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	shift
6953e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	realname="$1"
6954e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	shift
6955e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6956e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$soname_spec"; then
6957e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  eval soname=\"$soname_spec\"
6958e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	else
6959e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  soname="$realname"
6960e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
6961e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -z "$dlname"; then
6962e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  dlname=$soname
6963e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
6964e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6965e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	lib="$output_objdir/$realname"
6966e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	linknames=
6967e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	for link
6968e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	do
6969e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  linknames="$linknames $link"
6970e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	done
6971e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6972e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Use standard objects if they are pic
6973e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
6974e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	test "X$libobjs" = "X " && libobjs=
6975e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6976e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	delfiles=
6977e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$export_symbols" && test -n "$include_expsyms"; then
6978e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
6979e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  export_symbols="$output_objdir/$libname.uexp"
6980e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  delfiles="$delfiles $export_symbols"
6981e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
6982e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
6983e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	orig_export_symbols=
6984e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $host_os in
6985e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	cygwin* | mingw* | cegcc*)
6986e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
6987e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # exporting using user supplied symfile
6988e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
6989e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # and it's NOT already a .def file. Must figure out
6990e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # which of the given symbols are data symbols and tag
6991e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # them as such. So, trigger use of export_symbols_cmds.
6992e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # export_symbols gets reassigned inside the "prepare
6993e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # the list of exported symbols" if statement, so the
6994e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # include_expsyms logic still works.
6995e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      orig_export_symbols="$export_symbols"
6996e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      export_symbols=
6997e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      always_export_symbols=yes
6998e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
6999e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
7000e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
7001e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
7002e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7003e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Prepare the list of exported symbols
7004e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -z "$export_symbols"; then
7005e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
7006e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_verbose "generating symbol list for \`$libname.la'"
7007e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    export_symbols="$output_objdir/$libname.exp"
7008e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $opt_dry_run || $RM $export_symbols
7009e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    cmds=$export_symbols_cmds
7010e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    save_ifs="$IFS"; IFS='~'
7011e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    for cmd in $cmds; do
7012e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      IFS="$save_ifs"
7013e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      eval cmd=\"$cmd\"
7014e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_len " $cmd"
7015e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      len=$func_len_result
7016e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
7017e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		func_show_eval "$cmd" 'exit $?'
7018e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		skipped_export=false
7019e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      else
7020e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		# The command line is too long to execute in one step.
7021e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		func_verbose "using reloadable object file for export list..."
7022e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		skipped_export=:
7023e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		# Break out early, otherwise skipped_export may be
7024e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		# set to false by a later but shorter cmd.
7025e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		break
7026e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      fi
7027e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    done
7028e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    IFS="$save_ifs"
7029e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
7030e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
7031e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
7032e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
7033e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
7034e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
7035e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7036e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$export_symbols" && test -n "$include_expsyms"; then
7037e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  tmp_export_symbols="$export_symbols"
7038e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
7039e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
7040e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
7041e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7042e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
7043e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # The given exports_symbols file has to be filtered, so filter it.
7044e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
7045e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
7046e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # 's' commands which not all seds can handle. GNU sed should be fine
7047e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # though. Also, the filter scales superlinearly with the number of
7048e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # global variables. join(1) would be nice here, but unfortunately
7049e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # isn't a blessed tool.
7050e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
7051e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
7052e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  export_symbols=$output_objdir/$libname.def
7053e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
7054e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
7055e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7056e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	tmp_deplibs=
7057e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	for test_deplib in $deplibs; do
7058e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case " $convenience " in
7059e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *" $test_deplib "*) ;;
7060e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *)
7061e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    tmp_deplibs="$tmp_deplibs $test_deplib"
7062e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
7063e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
7064e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	done
7065e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	deplibs="$tmp_deplibs"
7066e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7067e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$convenience"; then
7068e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -n "$whole_archive_flag_spec" &&
7069e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    test "$compiler_needs_object" = yes &&
7070e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    test -z "$libobjs"; then
7071e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # extract the archives, so we have objects to list.
7072e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # TODO: could optimize this to just extract one archive.
7073e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    whole_archive_flag_spec=
7074e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
7075e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -n "$whole_archive_flag_spec"; then
7076e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    save_libobjs=$libobjs
7077e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
7078e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    test "X$libobjs" = "X " && libobjs=
7079e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
7080e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    gentop="$output_objdir/${outputname}x"
7081e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    generated="$generated $gentop"
7082e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7083e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_extract_archives $gentop $convenience
7084e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    libobjs="$libobjs $func_extract_archives_result"
7085e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    test "X$libobjs" = "X " && libobjs=
7086e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
7087e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
7088e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7089e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
7090e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  eval flag=\"$thread_safe_flag_spec\"
7091e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  linker_flags="$linker_flags $flag"
7092e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
7093e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7094e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Make a backup of the uninstalled library when relinking
7095e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$mode" = relink; then
7096e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
7097e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
7098e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7099e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Do each of the archive commands.
7100e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$module" = yes && test -n "$module_cmds" ; then
7101e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
7102e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    eval test_cmds=\"$module_expsym_cmds\"
7103e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    cmds=$module_expsym_cmds
7104e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
7105e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    eval test_cmds=\"$module_cmds\"
7106e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    cmds=$module_cmds
7107e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
7108e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	else
7109e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
7110e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    eval test_cmds=\"$archive_expsym_cmds\"
7111e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    cmds=$archive_expsym_cmds
7112e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
7113e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    eval test_cmds=\"$archive_cmds\"
7114e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    cmds=$archive_cmds
7115e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
7116e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
7117e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7118e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "X$skipped_export" != "X:" &&
7119e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	   func_len " $test_cmds" &&
7120e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	   len=$func_len_result &&
7121e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
7122e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  :
7123e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	else
7124e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # The command line is too long to link in one step, link piecewise
7125e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # or, if using GNU ld and skipped_export is not :, use a linker
7126e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # script.
7127e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7128e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Save the value of $output and $libobjs because we want to
7129e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # use them later.  If we have whole_archive_flag_spec, we
7130e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # want to use save_libobjs as it was before
7131e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # whole_archive_flag_spec was expanded, because we can't
7132e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # assume the linker understands whole_archive_flag_spec.
7133e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # This may have to be revisited, in case too many
7134e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # convenience libraries get linked in and end up exceeding
7135e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # the spec.
7136e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
7137e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    save_libobjs=$libobjs
7138e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
7139e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  save_output=$output
7140e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  output_la=`$ECHO "X$output" | $Xsed -e "$basename"`
7141e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7142e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Clear the reloadable object creation command queue and
7143e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # initialize k to one.
7144e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  test_cmds=
7145e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  concat_cmds=
7146e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  objlist=
7147e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  last_robj=
7148e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  k=1
7149e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7150e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
7151e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    output=${output_objdir}/${output_la}.lnkscript
7152e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_verbose "creating GNU ld script: $output"
7153e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $ECHO 'INPUT (' > $output
7154e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    for obj in $save_libobjs
7155e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    do
7156e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $ECHO "$obj" >> $output
7157e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    done
7158e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $ECHO ')' >> $output
7159e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    delfiles="$delfiles $output"
7160e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
7161e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    output=${output_objdir}/${output_la}.lnk
7162e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_verbose "creating linker input file list: $output"
7163e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    : > $output
7164e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    set x $save_libobjs
7165e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    shift
7166e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    firstobj=
7167e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "$compiler_needs_object" = yes; then
7168e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      firstobj="$1 "
7169e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      shift
7170e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
7171e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    for obj
7172e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    do
7173e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $ECHO "$obj" >> $output
7174e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    done
7175e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    delfiles="$delfiles $output"
7176e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    output=$firstobj\"$file_list_spec$output\"
7177e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
7178e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test -n "$save_libobjs"; then
7179e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_verbose "creating reloadable object files..."
7180e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      output=$output_objdir/$output_la-${k}.$objext
7181e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      eval test_cmds=\"$reload_cmds\"
7182e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_len " $test_cmds"
7183e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      len0=$func_len_result
7184e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      len=$len0
7185e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7186e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # Loop over the list of objects to be linked.
7187e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      for obj in $save_libobjs
7188e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      do
7189e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		func_len " $obj"
7190e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		func_arith $len + $func_len_result
7191e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		len=$func_arith_result
7192e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		if test "X$objlist" = X ||
7193e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		   test "$len" -lt "$max_cmd_len"; then
7194e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  func_append objlist " $obj"
7195e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		else
7196e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  # The command $test_cmds is almost too long, add a
7197e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  # command to the queue.
7198e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  if test "$k" -eq 1 ; then
7199e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    # The first file doesn't have a previous command to add.
7200e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
7201e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  else
7202e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    # All subsequent reloadable object files will link in
7203e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    # the last one created.
7204e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\"
7205e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  fi
7206e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  last_robj=$output_objdir/$output_la-${k}.$objext
7207e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  func_arith $k + 1
7208e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  k=$func_arith_result
7209e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  output=$output_objdir/$output_la-${k}.$objext
7210e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  objlist=$obj
7211e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  func_len " $last_robj"
7212e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  func_arith $len0 + $func_len_result
7213e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  len=$func_arith_result
7214e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		fi
7215e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      done
7216e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # Handle the remaining objects by creating one last
7217e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # reloadable object file.  All subsequent reloadable object
7218e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # files will link in the last one created.
7219e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
7220e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
7221e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      if test -n "$last_robj"; then
7222e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
7223e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      fi
7224e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      delfiles="$delfiles $output"
7225e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7226e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    else
7227e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      output=
7228e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
7229e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7230e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if ${skipped_export-false}; then
7231e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_verbose "generating symbol list for \`$libname.la'"
7232e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      export_symbols="$output_objdir/$libname.exp"
7233e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $opt_dry_run || $RM $export_symbols
7234e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      libobjs=$output
7235e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # Append the command to create the export file.
7236e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
7237e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
7238e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      if test -n "$last_robj"; then
7239e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
7240e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      fi
7241e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
7242e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7243e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    test -n "$save_libobjs" &&
7244e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_verbose "creating a temporary reloadable object file: $output"
7245e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7246e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Loop through the commands generated above and execute them.
7247e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    save_ifs="$IFS"; IFS='~'
7248e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    for cmd in $concat_cmds; do
7249e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      IFS="$save_ifs"
7250e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $opt_silent || {
7251e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  func_quote_for_expand "$cmd"
7252e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  eval "func_echo $func_quote_for_expand_result"
7253e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      }
7254e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $opt_dry_run || eval "$cmd" || {
7255e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		lt_exit=$?
7256e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7257e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		# Restore the uninstalled library and exit
7258e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		if test "$mode" = relink; then
7259e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  ( cd "$output_objdir" && \
7260e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    $RM "${realname}T" && \
7261e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    $MV "${realname}U" "$realname" )
7262e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		fi
7263e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7264e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		exit $lt_exit
7265e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      }
7266e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    done
7267e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    IFS="$save_ifs"
7268e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7269e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
7270e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
7271e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
7272e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
7273e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
7274e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7275e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          if ${skipped_export-false}; then
7276e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
7277e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      tmp_export_symbols="$export_symbols"
7278e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
7279e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
7280e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
7281e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7282e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test -n "$orig_export_symbols"; then
7283e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # The given exports_symbols file has to be filtered, so filter it.
7284e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
7285e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
7286e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # 's' commands which not all seds can handle. GNU sed should be fine
7287e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # though. Also, the filter scales superlinearly with the number of
7288e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # global variables. join(1) would be nice here, but unfortunately
7289e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # isn't a blessed tool.
7290e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
7291e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
7292e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      export_symbols=$output_objdir/$libname.def
7293e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
7294e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
7295e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
7296e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7297e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  libobjs=$output
7298e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Restore the value of output.
7299e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  output=$save_output
7300e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7301e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
7302e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
7303e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    test "X$libobjs" = "X " && libobjs=
7304e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
7305e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Expand the library linking commands again to reset the
7306e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # value of $libobjs for piecewise linking.
7307e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7308e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Do each of the archive commands.
7309e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$module" = yes && test -n "$module_cmds" ; then
7310e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
7311e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      cmds=$module_expsym_cmds
7312e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    else
7313e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      cmds=$module_cmds
7314e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
7315e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
7316e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
7317e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      cmds=$archive_expsym_cmds
7318e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    else
7319e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      cmds=$archive_cmds
7320e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
7321e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
7322e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
7323e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7324e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$delfiles"; then
7325e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Append the command to remove temporary files to $cmds.
7326e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  eval cmds=\"\$cmds~\$RM $delfiles\"
7327e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
7328e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7329e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Add any objects from preloaded convenience libraries
7330e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$dlprefiles"; then
7331e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  gentop="$output_objdir/${outputname}x"
7332e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  generated="$generated $gentop"
7333e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7334e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_extract_archives $gentop $dlprefiles
7335e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  libobjs="$libobjs $func_extract_archives_result"
7336e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  test "X$libobjs" = "X " && libobjs=
7337e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
7338e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7339e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	save_ifs="$IFS"; IFS='~'
7340e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	for cmd in $cmds; do
7341e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  IFS="$save_ifs"
7342e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  eval cmd=\"$cmd\"
7343e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  $opt_silent || {
7344e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_quote_for_expand "$cmd"
7345e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    eval "func_echo $func_quote_for_expand_result"
7346e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  }
7347e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  $opt_dry_run || eval "$cmd" || {
7348e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    lt_exit=$?
7349e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7350e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Restore the uninstalled library and exit
7351e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "$mode" = relink; then
7352e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      ( cd "$output_objdir" && \
7353e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	        $RM "${realname}T" && \
7354e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$MV "${realname}U" "$realname" )
7355e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
7356e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7357e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    exit $lt_exit
7358e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  }
7359e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	done
7360e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	IFS="$save_ifs"
7361e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7362e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Restore the uninstalled library and exit
7363e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$mode" = relink; then
7364e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
7365e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7366e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -n "$convenience"; then
7367e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test -z "$whole_archive_flag_spec"; then
7368e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_show_eval '${RM}r "$gentop"'
7369e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
7370e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
7371e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7372e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  exit $EXIT_SUCCESS
7373e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
7374e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7375e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Create links to the real library.
7376e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	for linkname in $linknames; do
7377e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$realname" != "$linkname"; then
7378e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
7379e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
7380e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	done
7381e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7382e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# If -module or -export-dynamic was specified, set the dlname.
7383e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$module" = yes || test "$export_dynamic" = yes; then
7384e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # On all known operating systems, these are identical.
7385e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  dlname="$soname"
7386e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
7387e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
7388e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      ;;
7389e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7390e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    obj)
7391e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
7392e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_warning "\`-dlopen' is ignored for objects"
7393e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
7394e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7395e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      case " $deplibs" in
7396e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *\ -l* | *\ -L*)
7397e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_warning "\`-l' and \`-L' are ignored for objects" ;;
7398e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      esac
7399e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7400e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      test -n "$rpath" && \
7401e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_warning "\`-rpath' is ignored for objects"
7402e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7403e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      test -n "$xrpath" && \
7404e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_warning "\`-R' is ignored for objects"
7405e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7406e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      test -n "$vinfo" && \
7407e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_warning "\`-version-info' is ignored for objects"
7408e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7409e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      test -n "$release" && \
7410e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_warning "\`-release' is ignored for objects"
7411e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7412e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      case $output in
7413e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *.lo)
7414e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	test -n "$objs$old_deplibs" && \
7415e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
7416e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7417e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	libobj=$output
7418e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_lo2o "$libobj"
7419e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	obj=$func_lo2o_result
7420e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
7421e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *)
7422e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	libobj=
7423e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	obj="$output"
7424e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
7425e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      esac
7426e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7427e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Delete the old objects.
7428e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      $opt_dry_run || $RM $obj $libobj
7429e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7430e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Objects from convenience libraries.  This assumes
7431e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # single-version convenience libraries.  Whenever we create
7432e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # different ones for PIC/non-PIC, this we'll have to duplicate
7433e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # the extraction.
7434e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      reload_conv_objs=
7435e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      gentop=
7436e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # reload_cmds runs $LD directly, so let us get rid of
7437e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # -Wl from whole_archive_flag_spec and hope we can get by with
7438e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # turning comma into space..
7439e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      wl=
7440e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7441e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -n "$convenience"; then
7442e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$whole_archive_flag_spec"; then
7443e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
7444e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
7445e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	else
7446e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  gentop="$output_objdir/${obj}x"
7447e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  generated="$generated $gentop"
7448e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7449e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_extract_archives $gentop $convenience
7450e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  reload_conv_objs="$reload_objs $func_extract_archives_result"
7451e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
7452e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
7453e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7454e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Create the old-style object.
7455e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      reload_objs="$objs$old_deplibs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
7456e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7457e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      output="$obj"
7458e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_execute_cmds "$reload_cmds" 'exit $?'
7459e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7460e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Exit if we aren't doing a library object file.
7461e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -z "$libobj"; then
7462e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$gentop"; then
7463e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_show_eval '${RM}r "$gentop"'
7464e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
7465e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7466e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	exit $EXIT_SUCCESS
7467e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
7468e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7469e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "$build_libtool_libs" != yes; then
7470e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$gentop"; then
7471e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_show_eval '${RM}r "$gentop"'
7472e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
7473e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7474e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Create an invalid libtool object if no PIC, so that we don't
7475e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# accidentally link it into a program.
7476e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# $show "echo timestamp > $libobj"
7477e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
7478e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	exit $EXIT_SUCCESS
7479e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
7480e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7481e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -n "$pic_flag" || test "$pic_mode" != default; then
7482e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Only do commands if we really have different PIC objects.
7483e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	reload_objs="$libobjs $reload_conv_objs"
7484e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	output="$libobj"
7485e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_execute_cmds "$reload_cmds" 'exit $?'
7486e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
7487e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7488e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -n "$gentop"; then
7489e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_show_eval '${RM}r "$gentop"'
7490e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
7491e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7492e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      exit $EXIT_SUCCESS
7493e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      ;;
7494e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7495e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    prog)
7496e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      case $host in
7497e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*cygwin*) func_stripname '' '.exe' "$output"
7498e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	          output=$func_stripname_result.exe;;
7499e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      esac
7500e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      test -n "$vinfo" && \
7501e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_warning "\`-version-info' is ignored for programs"
7502e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7503e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      test -n "$release" && \
7504e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_warning "\`-release' is ignored for programs"
7505e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7506e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      test "$preload" = yes \
7507e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        && test "$dlopen_support" = unknown \
7508e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	&& test "$dlopen_self" = unknown \
7509e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	&& test "$dlopen_self_static" = unknown && \
7510e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
7511e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7512e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      case $host in
7513e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *-*-rhapsody* | *-*-darwin1.[012])
7514e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# On Rhapsody replace the C library is the System framework
7515e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
7516e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
7517e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
7518e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      esac
7519e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7520e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      case $host in
7521e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *-*-darwin*)
7522e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Don't allow lazy linking, it breaks C++ global constructors
7523e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# But is supposedly fixed on 10.4 or later (yay!).
7524e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$tagname" = CXX ; then
7525e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
7526e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    10.[0123])
7527e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      compile_command="$compile_command ${wl}-bind_at_load"
7528e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      finalize_command="$finalize_command ${wl}-bind_at_load"
7529e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
7530e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
7531e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
7532e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
7533e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
7534e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
7535e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
7536e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      esac
7537e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7538e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7539e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # move library search paths that coincide with paths to not yet
7540e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # installed libraries to the beginning of the library search list
7541e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      new_libs=
7542e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      for path in $notinst_path; do
7543e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case " $new_libs " in
7544e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*" -L$path/$objdir "*) ;;
7545e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*)
7546e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case " $compile_deplibs " in
7547e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *" -L$path/$objdir "*)
7548e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    new_libs="$new_libs -L$path/$objdir" ;;
7549e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
7550e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
7551e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
7552e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      done
7553e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      for deplib in $compile_deplibs; do
7554e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $deplib in
7555e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	-L*)
7556e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case " $new_libs " in
7557e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *" $deplib "*) ;;
7558e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *) new_libs="$new_libs $deplib" ;;
7559e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
7560e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
7561e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*) new_libs="$new_libs $deplib" ;;
7562e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
7563e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      done
7564e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      compile_deplibs="$new_libs"
7565e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7566e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7567e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      compile_command="$compile_command $compile_deplibs"
7568e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      finalize_command="$finalize_command $finalize_deplibs"
7569e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7570e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -n "$rpath$xrpath"; then
7571e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# If the user specified any rpath flags, then add them.
7572e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	for libdir in $rpath $xrpath; do
7573e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # This is the magic to use -rpath.
7574e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case "$finalize_rpath " in
7575e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *" $libdir "*) ;;
7576e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *) finalize_rpath="$finalize_rpath $libdir" ;;
7577e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
7578e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	done
7579e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
7580e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7581e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Now hardcode the library paths
7582e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      rpath=
7583e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      hardcode_libdirs=
7584e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      for libdir in $compile_rpath $finalize_rpath; do
7585e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$hardcode_libdir_flag_spec"; then
7586e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -n "$hardcode_libdir_separator"; then
7587e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test -z "$hardcode_libdirs"; then
7588e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      hardcode_libdirs="$libdir"
7589e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    else
7590e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # Just accumulate the unique libdirs.
7591e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
7592e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
7593e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		;;
7594e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *)
7595e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
7596e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		;;
7597e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
7598e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
7599e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
7600e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    eval flag=\"$hardcode_libdir_flag_spec\"
7601e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    rpath="$rpath $flag"
7602e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
7603e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	elif test -n "$runpath_var"; then
7604e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case "$perm_rpath " in
7605e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *" $libdir "*) ;;
7606e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *) perm_rpath="$perm_rpath $libdir" ;;
7607e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
7608e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
7609e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $host in
7610e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
7611e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
7612e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case :$dllsearchpath: in
7613e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *":$libdir:"*) ;;
7614e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ::) dllsearchpath=$libdir;;
7615e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *) dllsearchpath="$dllsearchpath:$libdir";;
7616e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
7617e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case :$dllsearchpath: in
7618e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *":$testbindir:"*) ;;
7619e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ::) dllsearchpath=$testbindir;;
7620e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *) dllsearchpath="$dllsearchpath:$testbindir";;
7621e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
7622e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
7623e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
7624e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      done
7625e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Substitute the hardcoded libdirs into the rpath.
7626e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -n "$hardcode_libdir_separator" &&
7627e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	 test -n "$hardcode_libdirs"; then
7628e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	libdir="$hardcode_libdirs"
7629e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	eval rpath=\" $hardcode_libdir_flag_spec\"
7630e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
7631e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      compile_rpath="$rpath"
7632e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7633e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      rpath=
7634e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      hardcode_libdirs=
7635e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      for libdir in $finalize_rpath; do
7636e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$hardcode_libdir_flag_spec"; then
7637e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -n "$hardcode_libdir_separator"; then
7638e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test -z "$hardcode_libdirs"; then
7639e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      hardcode_libdirs="$libdir"
7640e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    else
7641e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # Just accumulate the unique libdirs.
7642e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
7643e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
7644e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		;;
7645e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *)
7646e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
7647e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		;;
7648e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
7649e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
7650e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
7651e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    eval flag=\"$hardcode_libdir_flag_spec\"
7652e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    rpath="$rpath $flag"
7653e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
7654e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	elif test -n "$runpath_var"; then
7655e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case "$finalize_perm_rpath " in
7656e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *" $libdir "*) ;;
7657e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
7658e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
7659e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
7660e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      done
7661e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Substitute the hardcoded libdirs into the rpath.
7662e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -n "$hardcode_libdir_separator" &&
7663e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	 test -n "$hardcode_libdirs"; then
7664e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	libdir="$hardcode_libdirs"
7665e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	eval rpath=\" $hardcode_libdir_flag_spec\"
7666e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
7667e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      finalize_rpath="$rpath"
7668e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7669e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -n "$libobjs" && test "$build_old_libs" = yes; then
7670e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Transform all the library objects into standard objects.
7671e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
7672e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
7673e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
7674e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7675e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
7676e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7677e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # template prelinking step
7678e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -n "$prelink_cmds"; then
7679e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_execute_cmds "$prelink_cmds" 'exit $?'
7680e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
7681e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7682e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      wrappers_required=yes
7683e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      case $host in
7684e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *cygwin* | *mingw* )
7685e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        if test "$build_libtool_libs" != yes; then
7686e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          wrappers_required=no
7687e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        fi
7688e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        ;;
7689e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *cegcc)
7690e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        # Disable wrappers for cegcc, we are cross compiling anyway.
7691e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        wrappers_required=no
7692e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        ;;
7693e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *)
7694e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
7695e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev          wrappers_required=no
7696e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        fi
7697e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev        ;;
7698e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      esac
7699e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "$wrappers_required" = no; then
7700e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Replace the output file specification.
7701e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
7702e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	link_command="$compile_command$compile_rpath"
7703e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7704e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# We have no uninstalled library dependencies, so finalize right now.
7705e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	exit_status=0
7706e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_show_eval "$link_command" 'exit_status=$?'
7707e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7708e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Delete the generated files.
7709e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -f "$output_objdir/${outputname}S.${objext}"; then
7710e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
7711e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
7712e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7713e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	exit $exit_status
7714e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
7715e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7716e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -n "$compile_shlibpath$finalize_shlibpath"; then
7717e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
7718e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
7719e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -n "$finalize_shlibpath"; then
7720e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
7721e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
7722e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7723e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      compile_var=
7724e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      finalize_var=
7725e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -n "$runpath_var"; then
7726e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$perm_rpath"; then
7727e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # We should set the runpath_var.
7728e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  rpath=
7729e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  for dir in $perm_rpath; do
7730e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    rpath="$rpath$dir:"
7731e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  done
7732e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
7733e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
7734e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$finalize_perm_rpath"; then
7735e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # We should set the runpath_var.
7736e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  rpath=
7737e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  for dir in $finalize_perm_rpath; do
7738e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    rpath="$rpath$dir:"
7739e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  done
7740e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
7741e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
7742e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
7743e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7744e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "$no_install" = yes; then
7745e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# We don't need to create a wrapper script.
7746e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	link_command="$compile_var$compile_command$compile_rpath"
7747e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Replace the output file specification.
7748e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
7749e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Delete the old output file.
7750e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	$opt_dry_run || $RM $output
7751e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Link the executable and exit
7752e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_show_eval "$link_command" 'exit $?'
7753e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	exit $EXIT_SUCCESS
7754e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
7755e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7756e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "$hardcode_action" = relink; then
7757e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Fast installation is not supported
7758e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	link_command="$compile_var$compile_command$compile_rpath"
7759e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	relink_command="$finalize_var$finalize_command$finalize_rpath"
7760e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7761e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_warning "this platform does not like uninstalled shared libraries"
7762e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_warning "\`$output' will be relinked during installation"
7763e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      else
7764e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$fast_install" != no; then
7765e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  link_command="$finalize_var$compile_command$finalize_rpath"
7766e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$fast_install" = yes; then
7767e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
7768e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
7769e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # fast_install is set to needless
7770e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    relink_command=
7771e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
7772e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	else
7773e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  link_command="$compile_var$compile_command$compile_rpath"
7774e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  relink_command="$finalize_var$finalize_command$finalize_rpath"
7775e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
7776e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
7777e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7778e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Replace the output file specification.
7779e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
7780e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7781e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Delete the old output files.
7782e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
7783e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7784e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_show_eval "$link_command" 'exit $?'
7785e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7786e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Now create the wrapper script.
7787e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_verbose "creating $output"
7788e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7789e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Quote the relink command for shipping.
7790e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -n "$relink_command"; then
7791e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Preserve any variables that may affect compiler behavior
7792e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	for var in $variables_saved_for_relink; do
7793e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if eval test -z \"\${$var+set}\"; then
7794e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
7795e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  elif eval var_value=\$$var; test -z "$var_value"; then
7796e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    relink_command="$var=; export $var; $relink_command"
7797e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
7798e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_quote_for_eval "$var_value"
7799e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
7800e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
7801e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	done
7802e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	relink_command="(cd `pwd`; $relink_command)"
7803e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
7804e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
7805e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7806e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Quote $ECHO for shipping.
7807e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then
7808e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $progpath in
7809e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
7810e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
7811e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
7812e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"`
7813e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      else
7814e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"`
7815e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
7816e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7817e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Only actually do things if not in dry run mode.
7818e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      $opt_dry_run || {
7819e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# win32 will think the script is a binary if it has
7820e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# a .exe suffix, so we strip it off here.
7821e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $output in
7822e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *.exe) func_stripname '' '.exe' "$output"
7823e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	         output=$func_stripname_result ;;
7824e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
7825e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# test for cygwin because mv fails w/o .exe extensions
7826e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $host in
7827e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *cygwin*)
7828e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    exeext=.exe
7829e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_stripname '' '.exe' "$outputname"
7830e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    outputname=$func_stripname_result ;;
7831e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *) exeext= ;;
7832e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
7833e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case $host in
7834e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *cygwin* | *mingw* )
7835e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_dirname_and_basename "$output" "" "."
7836e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    output_name=$func_basename_result
7837e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    output_path=$func_dirname_result
7838e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
7839e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    cwrapper="$output_path/$output_name.exe"
7840e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $RM $cwrappersource $cwrapper
7841e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
7842e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7843e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_emit_cwrapperexe_src > $cwrappersource
7844e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7845e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # The wrapper executable is built using the $host compiler,
7846e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # because it contains $host paths and files. If cross-
7847e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # compiling, it, like the target executable, must be
7848e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # executed on the $host or under an emulation environment.
7849e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $opt_dry_run || {
7850e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
7851e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $STRIP $cwrapper
7852e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    }
7853e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7854e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Now, create the wrapper script for func_source use:
7855e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_ltwrapper_scriptname $cwrapper
7856e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $RM $func_ltwrapper_scriptname_result
7857e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
7858e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $opt_dry_run || {
7859e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # note: this script will not be executed, so do not chmod.
7860e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      if test "x$build" = "x$host" ; then
7861e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
7862e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      else
7863e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		func_emit_wrapper no > $func_ltwrapper_scriptname_result
7864e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      fi
7865e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    }
7866e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
7867e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  * )
7868e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $RM $output
7869e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
7870e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7871e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_emit_wrapper no > $output
7872e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    chmod +x $output
7873e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  ;;
7874e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
7875e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      }
7876e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      exit $EXIT_SUCCESS
7877e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      ;;
7878e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    esac
7879e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7880e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # See if we need to build an old-fashioned archive.
7881e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    for oldlib in $oldlibs; do
7882e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7883e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "$build_libtool_libs" = convenience; then
7884e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	oldobjs="$libobjs_save $symfileobj"
7885e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	addlibs="$convenience"
7886e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	build_libtool_libs=no
7887e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      else
7888e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$build_libtool_libs" = module; then
7889e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  oldobjs="$libobjs_save"
7890e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  build_libtool_libs=no
7891e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	else
7892e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  oldobjs="$old_deplibs $non_pic_objects"
7893e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$preload" = yes && test -f "$symfileobj"; then
7894e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    oldobjs="$oldobjs $symfileobj"
7895e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
7896e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
7897e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	addlibs="$old_convenience"
7898e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
7899e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7900e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -n "$addlibs"; then
7901e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	gentop="$output_objdir/${outputname}x"
7902e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	generated="$generated $gentop"
7903e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7904e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_extract_archives $gentop $addlibs
7905e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	oldobjs="$oldobjs $func_extract_archives_result"
7906e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
7907e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7908e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Do each command in the archive commands.
7909e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
7910e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	cmds=$old_archive_from_new_cmds
7911e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      else
7912e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7913e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Add any objects from preloaded convenience libraries
7914e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test -n "$dlprefiles"; then
7915e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  gentop="$output_objdir/${outputname}x"
7916e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  generated="$generated $gentop"
7917e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7918e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_extract_archives $gentop $dlprefiles
7919e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  oldobjs="$oldobjs $func_extract_archives_result"
7920e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
7921e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7922e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# POSIX demands no paths to be encoded in archives.  We have
7923e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# to avoid creating archives with duplicate basenames if we
7924e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# might have to extract them afterwards, e.g., when creating a
7925e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# static archive out of a convenience library, or when linking
7926e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# the entirety of a libtool archive into another (currently
7927e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# not supported by libtool).
7928e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if (for obj in $oldobjs
7929e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    do
7930e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_basename "$obj"
7931e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      $ECHO "$func_basename_result"
7932e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    done | sort | sort -uc >/dev/null 2>&1); then
7933e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  :
7934e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	else
7935e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  $ECHO "copying selected object files to avoid basename conflicts..."
7936e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  gentop="$output_objdir/${outputname}x"
7937e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  generated="$generated $gentop"
7938e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_mkdir_p "$gentop"
7939e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  save_oldobjs=$oldobjs
7940e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  oldobjs=
7941e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  counter=1
7942e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  for obj in $save_oldobjs
7943e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  do
7944e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_basename "$obj"
7945e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    objbase="$func_basename_result"
7946e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    case " $oldobjs " in
7947e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    " ") oldobjs=$obj ;;
7948e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *[\ /]"$objbase "*)
7949e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      while :; do
7950e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		# Make sure we don't pick an alternate name that also
7951e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		# overlaps.
7952e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		newobj=lt$counter-$objbase
7953e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		func_arith $counter + 1
7954e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		counter=$func_arith_result
7955e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		case " $oldobjs " in
7956e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		*[\ /]"$newobj "*) ;;
7957e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
7958e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		esac
7959e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      done
7960e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
7961e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      oldobjs="$oldobjs $gentop/$newobj"
7962e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      ;;
7963e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *) oldobjs="$oldobjs $obj" ;;
7964e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    esac
7965e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  done
7966e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
7967e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	eval cmds=\"$old_archive_cmds\"
7968e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
7969e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_len " $cmds"
7970e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	len=$func_len_result
7971e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
7972e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  cmds=$old_archive_cmds
7973e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	else
7974e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # the command line is too long to link in one step, link in parts
7975e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_verbose "using piecewise archive linking..."
7976e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  save_RANLIB=$RANLIB
7977e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  RANLIB=:
7978e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  objlist=
7979e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  concat_cmds=
7980e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  save_oldobjs=$oldobjs
7981e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  oldobjs=
7982e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Is there a better way of finding the last object in the list?
7983e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  for obj in $save_oldobjs
7984e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  do
7985e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    last_oldobj=$obj
7986e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  done
7987e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  eval test_cmds=\"$old_archive_cmds\"
7988e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_len " $test_cmds"
7989e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  len0=$func_len_result
7990e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  len=$len0
7991e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  for obj in $save_oldobjs
7992e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  do
7993e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_len " $obj"
7994e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_arith $len + $func_len_result
7995e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    len=$func_arith_result
7996e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_append objlist " $obj"
7997e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "$len" -lt "$max_cmd_len"; then
7998e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      :
7999e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    else
8000e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # the above command should be used before it gets too long
8001e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      oldobjs=$objlist
8002e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      if test "$obj" = "$last_oldobj" ; then
8003e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		RANLIB=$save_RANLIB
8004e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      fi
8005e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8006e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
8007e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      objlist=
8008e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      len=$len0
8009e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
8010e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  done
8011e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  RANLIB=$save_RANLIB
8012e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  oldobjs=$objlist
8013e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "X$oldobjs" = "X" ; then
8014e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    eval cmds=\"\$concat_cmds\"
8015e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
8016e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
8017e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
8018e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
8019e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
8020e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_execute_cmds "$cmds" 'exit $?'
8021e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    done
8022e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8023e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    test -n "$generated" && \
8024e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_show_eval "${RM}r$generated"
8025e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8026e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # Now create the libtool archive.
8027e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    case $output in
8028e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    *.la)
8029e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      old_library=
8030e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      test "$build_old_libs" = yes && old_library="$libname.$libext"
8031e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_verbose "creating $output"
8032e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8033e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Preserve any variables that may affect compiler behavior
8034e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      for var in $variables_saved_for_relink; do
8035e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if eval test -z \"\${$var+set}\"; then
8036e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
8037e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	elif eval var_value=\$$var; test -z "$var_value"; then
8038e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  relink_command="$var=; export $var; $relink_command"
8039e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	else
8040e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_quote_for_eval "$var_value"
8041e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
8042e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
8043e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      done
8044e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Quote the link command for shipping.
8045e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
8046e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
8047e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "$hardcode_automatic" = yes ; then
8048e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	relink_command=
8049e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
8050e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8051e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Only create the output if not a dry run.
8052e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      $opt_dry_run || {
8053e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	for installed in no yes; do
8054e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$installed" = yes; then
8055e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test -z "$install_libdir"; then
8056e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      break
8057e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
8058e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    output="$output_objdir/$outputname"i
8059e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # Replace all uninstalled libtool libraries with the installed ones
8060e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    newdependency_libs=
8061e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    for deplib in $dependency_libs; do
8062e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case $deplib in
8063e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *.la)
8064e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		func_basename "$deplib"
8065e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		name="$func_basename_result"
8066e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
8067e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		test -z "$libdir" && \
8068e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  func_fatal_error "\`$deplib' is not a valid libtool archive"
8069e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		if test "x$EGREP" = x ; then
8070e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			EGREP=egrep
8071e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		fi
8072e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		# We do not want portage's install root ($D) present.  Check only for
8073e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		# this if the .la is being installed.
8074e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		if test "$installed" = yes && test "$D"; then
8075e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  eval mynewdependency_lib=`echo "$libdir/$name" |sed -e "s:$D:/:g" -e 's:/\+:/:g'`
8076e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		else
8077e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  mynewdependency_lib="$libdir/$name"
8078e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		fi
8079e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		# Do not add duplicates
8080e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		if test "$mynewdependency_lib"; then
8081e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  my_little_ninja_foo_1=`echo $newdependency_libs |$EGREP -e "$mynewdependency_lib"`
8082e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  if test -z "$my_little_ninja_foo_1"; then
8083e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    newdependency_libs="$newdependency_libs $mynewdependency_lib"
8084e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  fi
8085e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		fi
8086e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		;;
8087e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  *)
8088e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		if test "$installed" = yes; then
8089e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  # Rather use S=WORKDIR if our version of portage supports it.
8090e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  # This is because some ebuild (gcc) do not use $S as buildroot.
8091e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  if test "$PWORKDIR"; then
8092e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    S="$PWORKDIR"
8093e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  fi
8094e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  # We do not want portage's build root ($S) present.
8095e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  my_little_ninja_foo_2=`echo $deplib |$EGREP -e "$S"`
8096e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  # We do not want portage's install root ($D) present.
8097e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  my_little_ninja_foo_3=`echo $deplib |$EGREP -e "$D"`
8098e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  if test -n "$my_little_ninja_foo_2" && test "$S"; then
8099e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    mynewdependency_lib=""
8100e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  elif test -n "$my_little_ninja_foo_3" && test "$D"; then
8101e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    eval mynewdependency_lib=`echo "$deplib" |sed -e "s:$D:/:g" -e 's:/\+:/:g'`
8102e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  else
8103e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		    mynewdependency_lib="$deplib"
8104e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  fi
8105e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		else
8106e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  mynewdependency_lib="$deplib"
8107e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		fi
8108e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		# Do not add duplicates
8109e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		if test "$mynewdependency_lib"; then
8110e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  my_little_ninja_foo_4=`echo $newdependency_libs |$EGREP -e "$mynewdependency_lib"`
8111e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  if test -z "$my_little_ninja_foo_4"; then
8112e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev			newdependency_libs="$newdependency_libs $mynewdependency_lib"
8113e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  fi
8114e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		fi
8115e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		;;
8116e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
8117e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    done
8118e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    dependency_libs="$newdependency_libs"
8119e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    newdlfiles=
8120e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8121e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    for lib in $dlfiles; do
8122e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case $lib in
8123e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *.la)
8124e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	        func_basename "$lib"
8125e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		name="$func_basename_result"
8126e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
8127e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		test -z "$libdir" && \
8128e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  func_fatal_error "\`$lib' is not a valid libtool archive"
8129e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		newdlfiles="$newdlfiles $libdir/$name"
8130e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		;;
8131e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *) newdlfiles="$newdlfiles $lib" ;;
8132e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
8133e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    done
8134e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    dlfiles="$newdlfiles"
8135e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    newdlprefiles=
8136e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    for lib in $dlprefiles; do
8137e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case $lib in
8138e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      *.la)
8139e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		# Only pass preopened files to the pseudo-archive (for
8140e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		# eventual linking with the app. that links it) if we
8141e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		# didn't already link the preopened objects directly into
8142e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		# the library:
8143e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		func_basename "$lib"
8144e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		name="$func_basename_result"
8145e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
8146e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		test -z "$libdir" && \
8147e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		  func_fatal_error "\`$lib' is not a valid libtool archive"
8148e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		newdlprefiles="$newdlprefiles $libdir/$name"
8149e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		;;
8150e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
8151e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    done
8152e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    dlprefiles="$newdlprefiles"
8153e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  else
8154e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    newdlfiles=
8155e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    for lib in $dlfiles; do
8156e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case $lib in
8157e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
8158e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		*) abs=`pwd`"/$lib" ;;
8159e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
8160e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      newdlfiles="$newdlfiles $abs"
8161e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    done
8162e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    dlfiles="$newdlfiles"
8163e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    newdlprefiles=
8164e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    for lib in $dlprefiles; do
8165e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      case $lib in
8166e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
8167e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev		*) abs=`pwd`"/$lib" ;;
8168e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      esac
8169e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      newdlprefiles="$newdlprefiles $abs"
8170e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    done
8171e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    dlprefiles="$newdlprefiles"
8172e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
8173e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  $RM $output
8174e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # place dlname in correct position for cygwin
8175e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  tdlname=$dlname
8176e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case $host,$output,$installed,$module,$dlname in
8177e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
8178e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
8179e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Do not add duplicates
8180e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$installed" = yes && test "$D"; then
8181e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    install_libdir=`echo "$install_libdir" |sed -e "s:$D:/:g" -e 's:/\+:/:g'`
8182e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
8183e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  $ECHO > $output "\
8184e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# $outputname - a libtool library file
8185e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
8186e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev#
8187e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Please DO NOT delete this file!
8188e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# It is necessary for linking the library.
8189e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8190e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# The name that we can dlopen(3).
8191e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevdlname='$tdlname'
8192e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8193e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Names of this library.
8194e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevlibrary_names='$library_names'
8195e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8196e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# The name of the static archive.
8197e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevold_library='$old_library'
8198e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8199e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Linker flags that can not go in dependency_libs.
8200e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevinherited_linker_flags='$new_inherited_linker_flags'
8201e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8202e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Libraries that this one depends upon.
8203e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevdependency_libs='$dependency_libs'
8204e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8205e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Names of additional weak libraries provided by this library
8206e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevweak_library_names='$weak_libs'
8207e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8208e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Version information for $libname.
8209e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevcurrent=$current
8210e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevage=$age
8211e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevrevision=$revision
8212e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8213e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Is this an already installed library?
8214e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevinstalled=$installed
8215e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8216e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Should we warn about portability when linking against -modules?
8217e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevshouldnotlink=$module
8218e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8219e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Files to dlopen/dlpreopen
8220e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevdlopen='$dlfiles'
8221e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevdlpreopen='$dlprefiles'
8222e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8223e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Directory that this library needs to be installed in:
8224e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevlibdir='$install_libdir'"
8225e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test "$installed" = no && test "$need_relink" = yes; then
8226e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    $ECHO >> $output "\
8227e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevrelink_command=\"$relink_command\""
8228e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
8229e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	done
8230e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      }
8231e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8232e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Do a symbolic link so that the libtool archive can be found in
8233e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # LD_LIBRARY_PATH before the program is installed.
8234e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
8235e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      ;;
8236e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    esac
8237e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    exit $EXIT_SUCCESS
8238e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
8239e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8240e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{ test "$mode" = link || test "$mode" = relink; } &&
8241e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_mode_link ${1+"$@"}
8242e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8243e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8244e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# func_mode_uninstall arg...
8245e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfunc_mode_uninstall ()
8246e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{
8247e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    $opt_debug
8248e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    RM="$nonopt"
8249e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    files=
8250e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    rmforce=
8251e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    exit_status=0
8252e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8253e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # This variable tells wrapper scripts just to set variables rather
8254e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # than running their programs.
8255e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    libtool_install_magic="$magic"
8256e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8257e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    for arg
8258e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    do
8259e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      case $arg in
8260e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -f) RM="$RM $arg"; rmforce=yes ;;
8261e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      -*) RM="$RM $arg" ;;
8262e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *) files="$files $arg" ;;
8263e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      esac
8264e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    done
8265e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8266e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    test -z "$RM" && \
8267e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_fatal_help "you must specify an RM program"
8268e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8269e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    rmdirs=
8270e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8271e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    origobjdir="$objdir"
8272e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    for file in $files; do
8273e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_dirname "$file" "" "."
8274e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      dir="$func_dirname_result"
8275e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "X$dir" = X.; then
8276e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	objdir="$origobjdir"
8277e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      else
8278e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	objdir="$dir/$origobjdir"
8279e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
8280e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_basename "$file"
8281e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      name="$func_basename_result"
8282e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      test "$mode" = uninstall && objdir="$dir"
8283e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8284e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Remember objdir for removal later, being careful to avoid duplicates
8285e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test "$mode" = clean; then
8286e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	case " $rmdirs " in
8287e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *" $objdir "*) ;;
8288e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *) rmdirs="$rmdirs $objdir" ;;
8289e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	esac
8290e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
8291e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8292e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      # Don't error if the file doesn't exist and rm -f was used.
8293e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if { test -L "$file"; } >/dev/null 2>&1 ||
8294e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	 { test -h "$file"; } >/dev/null 2>&1 ||
8295e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	 test -f "$file"; then
8296e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	:
8297e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      elif test -d "$file"; then
8298e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	exit_status=1
8299e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
8300e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      elif test "$rmforce" = yes; then
8301e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	continue
8302e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
8303e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8304e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      rmfiles="$file"
8305e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8306e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      case $name in
8307e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *.la)
8308e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Possibly a libtool archive, so verify it.
8309e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if func_lalib_p "$file"; then
8310e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_source $dir/$name
8311e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8312e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Delete the libtool libraries and symlinks.
8313e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  for n in $library_names; do
8314e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    rmfiles="$rmfiles $objdir/$n"
8315e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  done
8316e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
8317e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8318e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case "$mode" in
8319e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  clean)
8320e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    case "  $library_names " in
8321e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # "  " in the beginning catches empty $dlname
8322e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *" $dlname "*) ;;
8323e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
8324e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    esac
8325e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
8326e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
8327e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  uninstall)
8328e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test -n "$library_names"; then
8329e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # Do each command in the postuninstall commands.
8330e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
8331e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
8332e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8333e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test -n "$old_library"; then
8334e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      # Do each command in the old_postuninstall commands.
8335e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
8336e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
8337e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # FIXME: should reinstall the best remaining shared library.
8338e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
8339e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
8340e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
8341e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
8342e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8343e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *.lo)
8344e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	# Possibly a libtool object, so verify it.
8345e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if func_lalib_p "$file"; then
8346e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8347e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Read the .lo file
8348e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  func_source $dir/$name
8349e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8350e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Add PIC object to the list of files to remove.
8351e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -n "$pic_object" &&
8352e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	     test "$pic_object" != none; then
8353e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    rmfiles="$rmfiles $dir/$pic_object"
8354e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
8355e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8356e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Add non-PIC object to the list of files to remove.
8357e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if test -n "$non_pic_object" &&
8358e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	     test "$non_pic_object" != none; then
8359e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    rmfiles="$rmfiles $dir/$non_pic_object"
8360e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
8361e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
8362e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
8363e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8364e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      *)
8365e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	if test "$mode" = clean ; then
8366e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  noexename=$name
8367e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  case $file in
8368e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  *.exe)
8369e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_stripname '' '.exe' "$file"
8370e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    file=$func_stripname_result
8371e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    func_stripname '' '.exe' "$name"
8372e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    noexename=$func_stripname_result
8373e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # $file with .exe has already been added to rmfiles,
8374e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # add $file without .exe
8375e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    rmfiles="$rmfiles $file"
8376e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    ;;
8377e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  esac
8378e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  # Do a test to see if this is a libtool program.
8379e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  if func_ltwrapper_p "$file"; then
8380e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if func_ltwrapper_executable_p "$file"; then
8381e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_ltwrapper_scriptname "$file"
8382e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      relink_command=
8383e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_source $func_ltwrapper_scriptname_result
8384e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      rmfiles="$rmfiles $func_ltwrapper_scriptname_result"
8385e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    else
8386e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      relink_command=
8387e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      func_source $dir/$noexename
8388e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
8389e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8390e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # note $name still contains .exe if it was in $file originally
8391e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    # as does the version of $file that was added into $rmfiles
8392e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
8393e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "$fast_install" = yes && test -n "$relink_command"; then
8394e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      rmfiles="$rmfiles $objdir/lt-$name"
8395e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
8396e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    if test "X$noexename" != "X$name" ; then
8397e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
8398e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	    fi
8399e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	  fi
8400e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	fi
8401e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	;;
8402e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      esac
8403e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      func_show_eval "$RM $rmfiles" 'exit_status=1'
8404e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    done
8405e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    objdir="$origobjdir"
8406e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8407e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    # Try to remove the ${objdir}s in the directories where we deleted files
8408e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    for dir in $rmdirs; do
8409e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      if test -d "$dir"; then
8410e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev	func_show_eval "rmdir $dir >/dev/null 2>&1"
8411e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev      fi
8412e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    done
8413e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8414e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    exit $exit_status
8415e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
8416e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8417e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev{ test "$mode" = uninstall || test "$mode" = clean; } &&
8418e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev    func_mode_uninstall ${1+"$@"}
8419e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8420e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevtest -z "$mode" && {
8421e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  help="$generic_help"
8422e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  func_fatal_help "you must specify a MODE"
8423e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev}
8424e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8425e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevtest -z "$exec_cmd" && \
8426e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  func_fatal_help "invalid operation mode \`$mode'"
8427e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8428e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevif test -n "$exec_cmd"; then
8429e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  eval exec "$exec_cmd"
8430e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev  exit $EXIT_FAILURE
8431e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevfi
8432e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8433e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevexit $exit_status
8434e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8435e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8436e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# The TAGs below are defined such that we never get into a situation
8437e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# in which we disable both kinds of libraries.  Given conflicting
8438e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# choices, we go for a static library, that is the most portable,
8439e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# since we can't tell whether shared libraries were disabled because
8440e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# the user asked for that or because the platform doesn't support
8441e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# them.  This is particularly important on AIX, because we don't
8442e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# support having both static and shared libraries enabled at the same
8443e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# time on that platform, so we default to a shared-only configuration.
8444e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# If a disable-shared tag is given, we'll fallback to a static-only
8445e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# configuration.  But we'll never go from static-only to shared-only.
8446e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8447e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
8448e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevbuild_libtool_libs=no
8449e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevbuild_old_libs=yes
8450e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# ### END LIBTOOL TAG CONFIG: disable-shared
8451e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8452e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# ### BEGIN LIBTOOL TAG CONFIG: disable-static
8453e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishevbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
8454e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# ### END LIBTOOL TAG CONFIG: disable-static
8455e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8456e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# Local Variables:
8457e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# mode:shell-script
8458e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# sh-indentation:2
8459e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# End:
8460e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev# vi:sw=2
8461e9a683104ef3f40d38459c0ca62a2d46f20b0714Yavor Goulishev
8462