1968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# libtool (GNU libtool) 2.4
3968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
4968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
6968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
7968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# This is free software; see the source for copying conditions.  There is NO
8968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
10968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# GNU Libtool is free software; you can redistribute it and/or modify
11968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# it under the terms of the GNU General Public License as published by
12968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# the Free Software Foundation; either version 2 of the License, or
13968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# (at your option) any later version.
14968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
15968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# As a special exception to the GNU General Public License,
16968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# if you distribute this file as part of a program or library that
17968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# is built using GNU Libtool, you may include this file under the
18968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# same distribution terms that you use for the rest of that program.
19968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
20968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# GNU Libtool is distributed in the hope that it will be useful, but
21968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# WITHOUT ANY WARRANTY; without even the implied warranty of
22968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# General Public License for more details.
24968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
25968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# You should have received a copy of the GNU General Public License
26968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# along with GNU Libtool; see the file COPYING.  If not, a copy
27968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# can be downloaded from http://www.gnu.org/licenses/gpl.html,
28968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# or obtained by writing to the Free Software Foundation, Inc.,
29968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
31968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Usage: $progname [OPTION]... [MODE-ARG]...
32968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
33968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Provide generalized library-building support services.
34968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
35968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#       --config             show all configuration variables
36968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#       --debug              enable verbose shell tracing
37968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#   -n, --dry-run            display commands without modifying any files
38968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#       --features           display basic configuration information and exit
39968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#       --mode=MODE          use operation mode MODE
40968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#       --preserve-dup-deps  don't remove duplicate dependency libraries
41968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#       --quiet, --silent    don't print informational messages
42968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#       --no-quiet, --no-silent
43968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#                            print informational messages (default)
44968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#       --tag=TAG            use configuration variables from tag TAG
45968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#   -v, --verbose            print more informational messages than default
46968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#       --no-verbose         don't print the extra informational messages
47968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#       --version            print version information
48968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#   -h, --help, --help-all   print short, long, or detailed help message
49968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
50968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# MODE must be one of the following:
51968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
52968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#         clean              remove files from the build directory
53968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#         compile            compile a source file into a libtool object
54968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#         execute            automatically set library path, then run a program
55968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#         finish             complete the installation of libtool libraries
56968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#         install            install libraries or executables
57968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#         link               create a library or an executable
58968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#         uninstall          remove libraries from an installed directory
59968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
60968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# MODE-ARGS vary depending on the MODE.  When passed as first option,
61968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
62968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
63968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
64968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# When reporting a bug, please describe a test case to reproduce it and
65968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# include the following information:
66968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
67968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#         host-triplet:	$host
68968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#         shell:		$SHELL
69968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#         compiler:		$LTCC
70968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#         compiler flags:		$LTCFLAGS
71968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#         linker:		$LD (gnu? $with_gnu_ld)
72968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#         $progname:	(GNU libtool) 2.4 Debian-2.4-3
73968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#         automake:	$automake_version
74968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#         autoconf:	$autoconf_version
75968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
76968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Report bugs to <bug-libtool@gnu.org>.
77968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
78968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# General help using GNU software: <http://www.gnu.org/gethelp/>.
79968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
80968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldPROGRAM=libtool
81968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldPACKAGE=libtool
82968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldVERSION="2.4 Debian-2.4-3"
83968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldTIMESTAMP=""
84968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldpackage_revision=1.3293
85968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
86968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Be Bourne compatible
87968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
88968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  emulate sh
89968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  NULLCMD=:
90968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
91968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # is contrary to our usage.  Disable this feature.
92968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  alias -g '${1+"$@"}'='"$@"'
93968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  setopt NO_GLOB_SUBST
94968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldelse
95968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
96968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfi
97968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldBIN_SH=xpg4; export BIN_SH # for Tru64
98968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldDUALCASE=1; export DUALCASE # for MKS sh
99968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
100968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# A function that is used when there is no print builtin or printf.
101968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_fallback_echo ()
102968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
103968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  eval 'cat <<_LTECHO_EOF
104968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold$1
105968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold_LTECHO_EOF'
106968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
107968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
108968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# NLS nuisances: We save the old values to restore during execute mode.
109968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldlt_user_locale=
110968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldlt_safe_locale=
111968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
112968bf19396ad404e89420f5d67900fce13f4186cGilad Arnolddo
113968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  eval "if test \"\${$lt_var+set}\" = set; then
114968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold          save_$lt_var=\$$lt_var
115968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold          $lt_var=C
116968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  export $lt_var
117968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
118968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
119968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi"
120968bf19396ad404e89420f5d67900fce13f4186cGilad Arnolddone
121968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldLC_ALL=C
122968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldLANGUAGE=C
123968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldexport LANGUAGE LC_ALL
124968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
125968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold$lt_unset CDPATH
126968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
127968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
128968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
129968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# is ksh but when the shell is invoked as "sh" and the current value of
130968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# the _XPG environment variable is not equal to 1 (one), the special
131968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# positional parameter $0, within a function call, is the name of the
132968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# function.
133968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldprogpath="$0"
134968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
135968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
136968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
137968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold: ${CP="cp -f"}
138968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
139968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold: ${EGREP="/bin/grep -E"}
140968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold: ${FGREP="/bin/grep -F"}
141968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold: ${GREP="/bin/grep"}
142968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold: ${LN_S="ln -s"}
143968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold: ${MAKE="make"}
144968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold: ${MKDIR="mkdir"}
145968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold: ${MV="mv -f"}
146968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold: ${RM="rm -f"}
147968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold: ${SED="/bin/sed"}
148968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
149968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold: ${Xsed="$SED -e 1s/^X//"}
150968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
151968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Global variables:
152968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEXIT_SUCCESS=0
153968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEXIT_FAILURE=1
154968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
155968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
156968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
157968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldexit_status=$EXIT_SUCCESS
158968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
159968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Make sure IFS has a sensible default
160968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldlt_nl='
161968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold'
162968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldIFS=" 	$lt_nl"
163968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
164968bf19396ad404e89420f5d67900fce13f4186cGilad Arnolddirname="s,/[^/]*$,,"
165968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldbasename="s,^.*/,,"
166968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
167968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_dirname file append nondir_replacement
168968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
169968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# otherwise set result to NONDIR_REPLACEMENT.
170968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_dirname ()
171968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
172968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
173968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test "X$func_dirname_result" = "X${1}"; then
174968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_dirname_result="${3}"
175968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    else
176968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_dirname_result="$func_dirname_result${2}"
177968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
178968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold} # func_dirname may be replaced by extended shell implementation
179968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
180968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
181968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_basename file
182968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_basename ()
183968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
184968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
185968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold} # func_basename may be replaced by extended shell implementation
186968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
187968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
188968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_dirname_and_basename file append nondir_replacement
189968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# perform func_basename and func_dirname in a single function
190968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# call:
191968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#   dirname:  Compute the dirname of FILE.  If nonempty,
192968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#             add APPEND to the result, otherwise set result
193968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#             to NONDIR_REPLACEMENT.
194968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#             value returned in "$func_dirname_result"
195968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#   basename: Compute filename of FILE.
196968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#             value retuned in "$func_basename_result"
197968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Implementation must be kept synchronized with func_dirname
198968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# and func_basename. For efficiency, we do not delegate to
199968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# those functions but instead duplicate the functionality here.
200968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_dirname_and_basename ()
201968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
202968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Extract subdirectory from the argument.
203968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
204968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test "X$func_dirname_result" = "X${1}"; then
205968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_dirname_result="${3}"
206968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    else
207968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_dirname_result="$func_dirname_result${2}"
208968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
209968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
210968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold} # func_dirname_and_basename may be replaced by extended shell implementation
211968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
212968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
213968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_stripname prefix suffix name
214968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# strip PREFIX and SUFFIX off of NAME.
215968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# PREFIX and SUFFIX must not contain globbing or regex special
216968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# characters, hashes, percent signs, but SUFFIX may contain a leading
217968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# dot (in which case that matches only a dot).
218968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_strip_suffix prefix name
219968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_stripname ()
220968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
221968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    case ${2} in
222968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
223968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
224968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    esac
225968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold} # func_stripname may be replaced by extended shell implementation
226968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
227968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
228968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# These SED scripts presuppose an absolute path with a trailing slash.
229968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldpathcar='s,^/\([^/]*\).*$,\1,'
230968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldpathcdr='s,^/[^/]*,,'
231968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldremovedotparts=':dotsl
232968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		s@/\./@/@g
233968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		t dotsl
234968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		s,/\.$,/,'
235968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldcollapseslashes='s@/\{1,\}@/@g'
236968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfinalslash='s,/*$,/,'
237968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
238968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_normal_abspath PATH
239968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Remove doubled-up and trailing slashes, "." path components,
240968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# and cancel out any ".." path components in PATH after making
241968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# it an absolute path.
242968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#             value returned in "$func_normal_abspath_result"
243968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_normal_abspath ()
244968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
245968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # Start from root dir and reassemble the path.
246968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_normal_abspath_result=
247968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_normal_abspath_tpath=$1
248968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_normal_abspath_altnamespace=
249968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  case $func_normal_abspath_tpath in
250968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    "")
251968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Empty path, that just means $cwd.
252968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_stripname '' '/' "`pwd`"
253968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_normal_abspath_result=$func_stripname_result
254968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      return
255968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    ;;
256968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # The next three entries are used to spot a run of precisely
257968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # two leading slashes without using negated character classes;
258968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # we take advantage of case's first-match behaviour.
259968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    ///*)
260968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Unusual form of absolute path, do nothing.
261968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    ;;
262968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    //*)
263968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Not necessarily an ordinary path; POSIX reserves leading '//'
264968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # and for example Cygwin uses it to access remote file shares
265968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # over CIFS/SMB, so we conserve a leading double slash if found.
266968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_normal_abspath_altnamespace=/
267968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    ;;
268968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    /*)
269968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Absolute path, do nothing.
270968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    ;;
271968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *)
272968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Relative path, prepend $cwd.
273968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
274968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    ;;
275968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  esac
276968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # Cancel out all the simple stuff to save iterations.  We also want
277968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # the path to end with a slash for ease of parsing, so make sure
278968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # there is one (and only one) here.
279968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
280968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
281968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  while :; do
282968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Processed it all yet?
283968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test "$func_normal_abspath_tpath" = / ; then
284968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # If we ascended to the root using ".." the result may be empty now.
285968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -z "$func_normal_abspath_result" ; then
286968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        func_normal_abspath_result=/
287968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
288968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      break
289968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
290968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
291968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        -e "$pathcar"`
292968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
293968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        -e "$pathcdr"`
294968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Figure out what to do with it
295968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    case $func_normal_abspath_tcomponent in
296968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      "")
297968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        # Trailing empty path component, ignore it.
298968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      ;;
299968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      ..)
300968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        # Parent dir; strip last assembled component from result.
301968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        func_dirname "$func_normal_abspath_result"
302968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        func_normal_abspath_result=$func_dirname_result
303968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      ;;
304968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *)
305968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        # Actual path component, append it.
306968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
307968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      ;;
308968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    esac
309968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  done
310968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # Restore leading double-slash if one was found on entry.
311968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
312968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
313968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
314968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_relative_path SRCDIR DSTDIR
315968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# generates a relative path from SRCDIR to DSTDIR, with a trailing
316968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# slash if non-empty, suitable for immediately appending a filename
317968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# without needing to append a separator.
318968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#             value returned in "$func_relative_path_result"
319968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_relative_path ()
320968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
321968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_relative_path_result=
322968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_normal_abspath "$1"
323968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_relative_path_tlibdir=$func_normal_abspath_result
324968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_normal_abspath "$2"
325968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_relative_path_tbindir=$func_normal_abspath_result
326968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
327968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # Ascend the tree starting from libdir
328968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  while :; do
329968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # check if we have found a prefix of bindir
330968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    case $func_relative_path_tbindir in
331968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      $func_relative_path_tlibdir)
332968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        # found an exact match
333968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        func_relative_path_tcancelled=
334968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        break
335968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        ;;
336968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      $func_relative_path_tlibdir*)
337968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        # found a matching prefix
338968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
339968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        func_relative_path_tcancelled=$func_stripname_result
340968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        if test -z "$func_relative_path_result"; then
341968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold          func_relative_path_result=.
342968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        fi
343968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        break
344968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        ;;
345968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *)
346968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        func_dirname $func_relative_path_tlibdir
347968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        func_relative_path_tlibdir=${func_dirname_result}
348968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        if test "x$func_relative_path_tlibdir" = x ; then
349968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold          # Have to descend all the way to the root!
350968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold          func_relative_path_result=../$func_relative_path_result
351968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold          func_relative_path_tcancelled=$func_relative_path_tbindir
352968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold          break
353968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        fi
354968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        func_relative_path_result=../$func_relative_path_result
355968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        ;;
356968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    esac
357968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  done
358968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
359968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # Now calculate path; take care to avoid doubling-up slashes.
360968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_stripname '' '/' "$func_relative_path_result"
361968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_relative_path_result=$func_stripname_result
362968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_stripname '/' '/' "$func_relative_path_tcancelled"
363968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if test "x$func_stripname_result" != x ; then
364968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
365968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  fi
366968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
367968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # Normalisation. If bindir is libdir, return empty string,
368968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # else relative path ending with a slash; either way, target
369968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # file name can be directly appended.
370968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if test ! -z "$func_relative_path_result"; then
371968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_stripname './' '' "$func_relative_path_result/"
372968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_relative_path_result=$func_stripname_result
373968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  fi
374968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
375968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
376968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# The name of this program:
377968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_dirname_and_basename "$progpath"
378968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldprogname=$func_basename_result
379968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
380968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Make sure we have an absolute path for reexecution:
381968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldcase $progpath in
382968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  [\\/]*|[A-Za-z]:\\*) ;;
383968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  *[\\/]*)
384968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     progdir=$func_dirname_result
385968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     progdir=`cd "$progdir" && pwd`
386968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     progpath="$progdir/$progname"
387968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     ;;
388968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  *)
389968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     save_IFS="$IFS"
390968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     IFS=:
391968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     for progdir in $PATH; do
392968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold       IFS="$save_IFS"
393968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold       test -x "$progdir/$progname" && break
394968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     done
395968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     IFS="$save_IFS"
396968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     test -n "$progdir" || progdir=`pwd`
397968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     progpath="$progdir/$progname"
398968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     ;;
399968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldesac
400968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
401968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Sed substitution that helps us do robust quoting.  It backslashifies
402968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# metacharacters that are still active within double-quoted strings.
403968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldXsed="${SED}"' -e 1s/^X//'
404968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
405968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
406968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Same as above, but do not quote variable references.
407968bf19396ad404e89420f5d67900fce13f4186cGilad Arnolddouble_quote_subst='s/\(["`\\]\)/\\\1/g'
408968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
409968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Sed substitution that turns a string into a regex matching for the
410968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# string literally.
411968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldsed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
412968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
413968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Sed substitution that converts a w32 file name or path
414968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# which contains forward slashes, into one that contains
415968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# (escaped) backslashes.  A very naive implementation.
416968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldlt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
417968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
418968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Re-`\' parameter expansions in output of double_quote_subst that were
419968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
420968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# in input to double_quote_subst, that '$' was protected from expansion.
421968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Since each input `\' is now two `\'s, look for any number of runs of
422968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
423968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldbs='\\'
424968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldbs2='\\\\'
425968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldbs4='\\\\\\\\'
426968bf19396ad404e89420f5d67900fce13f4186cGilad Arnolddollar='\$'
427968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldsed_double_backslash="\
428968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  s/$bs4/&\\
429968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold/g
430968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  s/^$bs2$dollar/$bs&/
431968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
432968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  s/\n//g"
433968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
434968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Standard options:
435968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldopt_dry_run=false
436968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldopt_help=false
437968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldopt_quiet=false
438968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldopt_verbose=false
439968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldopt_warning=:
440968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
441968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_echo arg...
442968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Echo program name prefixed message, along with the current mode
443968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# name if it has been set yet.
444968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_echo ()
445968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
446968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
447968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
448968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
449968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_verbose arg...
450968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Echo program name prefixed message in verbose mode only.
451968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_verbose ()
452968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
453968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $opt_verbose && func_echo ${1+"$@"}
454968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
455968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # A bug in bash halts the script if the last line of a function
456968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # fails when set -e is in force, so we need another command to
457968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # work around that:
458968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    :
459968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
460968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
461968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_echo_all arg...
462968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Invoke $ECHO with all args, space-separated.
463968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_echo_all ()
464968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
465968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $ECHO "$*"
466968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
467968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
468968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_error arg...
469968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Echo program name prefixed message to standard error.
470968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_error ()
471968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
472968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
473968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
474968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
475968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_warning arg...
476968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Echo program name prefixed warning message to standard error.
477968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_warning ()
478968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
479968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
480968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
481968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # bash bug again:
482968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    :
483968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
484968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
485968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_fatal_error arg...
486968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Echo program name prefixed message to standard error, and exit.
487968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_fatal_error ()
488968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
489968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_error ${1+"$@"}
490968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    exit $EXIT_FAILURE
491968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
492968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
493968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_fatal_help arg...
494968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Echo program name prefixed message to standard error, followed by
495968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# a help hint, and exit.
496968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_fatal_help ()
497968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
498968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_error ${1+"$@"}
499968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_fatal_error "$help"
500968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
501968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldhelp="Try \`$progname --help' for more information."  ## default
502968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
503968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
504968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_grep expression filename
505968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Check whether EXPRESSION matches any line of FILENAME, without output.
506968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_grep ()
507968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
508968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $GREP "$1" "$2" >/dev/null 2>&1
509968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
510968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
511968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
512968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_mkdir_p directory-path
513968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Make sure the entire path to DIRECTORY-PATH is available.
514968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_mkdir_p ()
515968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
516968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    my_directory_path="$1"
517968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    my_dir_list=
518968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
519968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
520968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
521968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Protect directory names starting with `-'
522968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      case $my_directory_path in
523968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        -*) my_directory_path="./$my_directory_path" ;;
524968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      esac
525968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
526968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # While some portion of DIR does not yet exist...
527968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      while test ! -d "$my_directory_path"; do
528968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        # ...make a list in topmost first order.  Use a colon delimited
529968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# list incase some portion of path contains whitespace.
530968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        my_dir_list="$my_directory_path:$my_dir_list"
531968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
532968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        # If the last portion added has no slash in it, the list is done
533968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        case $my_directory_path in */*) ;; *) break ;; esac
534968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
535968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        # ...otherwise throw away the child directory and loop
536968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
537968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      done
538968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
539968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
540968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      save_mkdir_p_IFS="$IFS"; IFS=':'
541968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      for my_dir in $my_dir_list; do
542968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	IFS="$save_mkdir_p_IFS"
543968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        # mkdir can fail with a `File exist' error if two processes
544968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        # try to create one of the directories concurrently.  Don't
545968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        # stop in that case!
546968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        $MKDIR "$my_dir" 2>/dev/null || :
547968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      done
548968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      IFS="$save_mkdir_p_IFS"
549968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
550968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Bail out if we (or some other process) failed to create a directory.
551968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      test -d "$my_directory_path" || \
552968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        func_fatal_error "Failed to create \`$1'"
553968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
554968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
555968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
556968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
557968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_mktempdir [string]
558968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Make a temporary directory that won't clash with other running
559968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# libtool processes, and avoids race conditions if possible.  If
560968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# given, STRING is the basename for that directory.
561968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_mktempdir ()
562968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
563968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    my_template="${TMPDIR-/tmp}/${1-$progname}"
564968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
565968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test "$opt_dry_run" = ":"; then
566968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Return a directory name, but don't create it in dry-run mode
567968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      my_tmpdir="${my_template}-$$"
568968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    else
569968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
570968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # If mktemp works, use that first and foremost
571968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
572968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
573968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test ! -d "$my_tmpdir"; then
574968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        # Failing that, at least try and use $RANDOM to avoid a race
575968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        my_tmpdir="${my_template}-${RANDOM-0}$$"
576968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
577968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        save_mktempdir_umask=`umask`
578968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        umask 0077
579968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        $MKDIR "$my_tmpdir"
580968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        umask $save_mktempdir_umask
581968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
582968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
583968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # If we're not in dry-run mode, bomb out on failure
584968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      test -d "$my_tmpdir" || \
585968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
586968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
587968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
588968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $ECHO "$my_tmpdir"
589968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
590968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
591968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
592968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_quote_for_eval arg
593968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Aesthetically quote ARG to be evaled later.
594968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
595968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# is double-quoted, suitable for a subsequent eval, whereas
596968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
597968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# which are still active within double quotes backslashified.
598968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_quote_for_eval ()
599968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
600968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    case $1 in
601968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *[\\\`\"\$]*)
602968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
603968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *)
604968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        func_quote_for_eval_unquoted_result="$1" ;;
605968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    esac
606968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
607968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    case $func_quote_for_eval_unquoted_result in
608968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Double-quote args containing shell metacharacters to delay
609968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # word splitting, command substitution and and variable
610968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # expansion for a subsequent eval.
611968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Many Bourne shells cannot handle close brackets correctly
612968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # in scan sets, so we specify it separately.
613968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
614968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
615968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        ;;
616968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *)
617968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
618968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    esac
619968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
620968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
621968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
622968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_quote_for_expand arg
623968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Aesthetically quote ARG to be evaled later; same as above,
624968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# but do not quote variable references.
625968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_quote_for_expand ()
626968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
627968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    case $1 in
628968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *[\\\`\"]*)
629968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	my_arg=`$ECHO "$1" | $SED \
630968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
631968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *)
632968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        my_arg="$1" ;;
633968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    esac
634968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
635968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    case $my_arg in
636968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Double-quote args containing shell metacharacters to delay
637968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # word splitting and command substitution for a subsequent eval.
638968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Many Bourne shells cannot handle close brackets correctly
639968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # in scan sets, so we specify it separately.
640968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
641968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        my_arg="\"$my_arg\""
642968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        ;;
643968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    esac
644968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
645968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_quote_for_expand_result="$my_arg"
646968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
647968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
648968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
649968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_show_eval cmd [fail_exp]
650968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
651968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
652968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# is given, then evaluate it.
653968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_show_eval ()
654968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
655968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    my_cmd="$1"
656968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    my_fail_exp="${2-:}"
657968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
658968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    ${opt_silent-false} || {
659968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_quote_for_expand "$my_cmd"
660968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      eval "func_echo $func_quote_for_expand_result"
661968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    }
662968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
663968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if ${opt_dry_run-false}; then :; else
664968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      eval "$my_cmd"
665968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      my_status=$?
666968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test "$my_status" -eq 0; then :; else
667968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	eval "(exit $my_status); $my_fail_exp"
668968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
669968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
670968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
671968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
672968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
673968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_show_eval_locale cmd [fail_exp]
674968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
675968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
676968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# is given, then evaluate it.  Use the saved locale for evaluation.
677968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_show_eval_locale ()
678968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
679968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    my_cmd="$1"
680968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    my_fail_exp="${2-:}"
681968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
682968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    ${opt_silent-false} || {
683968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_quote_for_expand "$my_cmd"
684968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      eval "func_echo $func_quote_for_expand_result"
685968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    }
686968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
687968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if ${opt_dry_run-false}; then :; else
688968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      eval "$lt_user_locale
689968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    $my_cmd"
690968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      my_status=$?
691968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      eval "$lt_safe_locale"
692968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test "$my_status" -eq 0; then :; else
693968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	eval "(exit $my_status); $my_fail_exp"
694968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
695968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
696968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
697968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
698968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_tr_sh
699968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Turn $1 into a string suitable for a shell variable name.
700968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Result is stored in $func_tr_sh_result.  All characters
701968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
702968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# if $1 begins with a digit, a '_' is prepended as well.
703968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_tr_sh ()
704968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
705968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  case $1 in
706968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  [0-9]* | *[!a-zA-Z0-9_]*)
707968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
708968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    ;;
709968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  * )
710968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_tr_sh_result=$1
711968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    ;;
712968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  esac
713968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
714968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
715968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
716968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_version
717968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Echo version message to standard output and exit.
718968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_version ()
719968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
720968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $opt_debug
721968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
722968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $SED -n '/(C)/!b go
723968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	:more
724968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	/\./!{
725968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  N
726968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  s/\n# / /
727968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  b more
728968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	}
729968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	:go
730968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	/^# '$PROGRAM' (GNU /,/# warranty; / {
731968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        s/^# //
732968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	s/^# *$//
733968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
734968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        p
735968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     }' < "$progpath"
736968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     exit $?
737968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
738968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
739968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_usage
740968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Echo short help message to standard output and exit.
741968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_usage ()
742968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
743968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $opt_debug
744968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
745968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $SED -n '/^# Usage:/,/^#  *.*--help/ {
746968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        s/^# //
747968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	s/^# *$//
748968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	s/\$progname/'$progname'/
749968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	p
750968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    }' < "$progpath"
751968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    echo
752968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $ECHO "run \`$progname --help | more' for full usage"
753968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    exit $?
754968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
755968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
756968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_help [NOEXIT]
757968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Echo long help message to standard output and exit,
758968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# unless 'noexit' is passed as argument.
759968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_help ()
760968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
761968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $opt_debug
762968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
763968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $SED -n '/^# Usage:/,/# Report bugs to/ {
764968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	:print
765968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        s/^# //
766968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	s/^# *$//
767968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	s*\$progname*'$progname'*
768968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	s*\$host*'"$host"'*
769968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	s*\$SHELL*'"$SHELL"'*
770968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	s*\$LTCC*'"$LTCC"'*
771968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	s*\$LTCFLAGS*'"$LTCFLAGS"'*
772968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	s*\$LD*'"$LD"'*
773968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	s/\$with_gnu_ld/'"$with_gnu_ld"'/
774968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
775968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
776968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	p
777968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	d
778968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     }
779968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     /^# .* home page:/b print
780968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     /^# General help using/b print
781968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     ' < "$progpath"
782968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    ret=$?
783968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test -z "$1"; then
784968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      exit $ret
785968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
786968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
787968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
788968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_missing_arg argname
789968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Echo program name prefixed message to standard error and set global
790968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# exit_cmd.
791968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_missing_arg ()
792968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
793968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $opt_debug
794968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
795968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_error "missing argument for $1."
796968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    exit_cmd=exit
797968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
798968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
799968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
800968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_split_short_opt shortopt
801968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Set func_split_short_opt_name and func_split_short_opt_arg shell
802968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# variables after splitting SHORTOPT after the 2nd character.
803968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_split_short_opt ()
804968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
805968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
806968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
807968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
808968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
809968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
810968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold} # func_split_short_opt may be replaced by extended shell implementation
811968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
812968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
813968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_split_long_opt longopt
814968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Set func_split_long_opt_name and func_split_long_opt_arg shell
815968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# variables after splitting LONGOPT at the `=' sign.
816968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_split_long_opt ()
817968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
818968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
819968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    my_sed_long_arg='1s/^--[^=]*=//'
820968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
821968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
822968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
823968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold} # func_split_long_opt may be replaced by extended shell implementation
824968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
825968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldexit_cmd=:
826968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
827968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
828968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
829968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
830968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
831968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldmagic="%%%MAGIC variable%%%"
832968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldmagic_exe="%%%MAGIC EXE variable%%%"
833968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
834968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Global variables.
835968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldnonopt=
836968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldpreserve_args=
837968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldlo2o="s/\\.lo\$/.${objext}/"
838968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldo2lo="s/\\.${objext}\$/.lo/"
839968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldextracted_archives=
840968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldextracted_serial=0
841968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
842968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# If this variable is set in any of the actions, the command in it
843968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# will be execed at the end.  This prevents here-documents from being
844968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# left over by shells.
845968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldexec_cmd=
846968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
847968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_append var value
848968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Append VALUE to the end of shell variable VAR.
849968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_append ()
850968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
851968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    eval "${1}=\$${1}\${2}"
852968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold} # func_append may be replaced by extended shell implementation
853968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
854968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_append_quoted var value
855968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Quote VALUE and append to the end of shell variable VAR, separated
856968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# by a space.
857968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_append_quoted ()
858968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
859968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_quote_for_eval "${2}"
860968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
861968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold} # func_append_quoted may be replaced by extended shell implementation
862968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
863968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
864968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_arith arithmetic-term...
865968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_arith ()
866968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
867968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_arith_result=`expr "${@}"`
868968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold} # func_arith may be replaced by extended shell implementation
869968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
870968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
871968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_len string
872968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# STRING may not start with a hyphen.
873968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_len ()
874968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
875968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
876968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold} # func_len may be replaced by extended shell implementation
877968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
878968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
879968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_lo2o object
880968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_lo2o ()
881968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
882968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
883968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold} # func_lo2o may be replaced by extended shell implementation
884968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
885968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
886968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_xform libobj-or-source
887968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_xform ()
888968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
889968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
890968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold} # func_xform may be replaced by extended shell implementation
891968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
892968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
893968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_fatal_configuration arg...
894968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Echo program name prefixed message to standard error, followed by
895968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# a configuration failure hint, and exit.
896968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_fatal_configuration ()
897968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
898968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_error ${1+"$@"}
899968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_error "See the $PACKAGE documentation for more information."
900968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_fatal_error "Fatal configuration error."
901968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
902968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
903968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
904968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_config
905968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Display the configuration for all the tags in this script.
906968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_config ()
907968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
908968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    re_begincf='^# ### BEGIN LIBTOOL'
909968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    re_endcf='^# ### END LIBTOOL'
910968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
911968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Default configuration.
912968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
913968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
914968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Now print the configurations for the tags.
915968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    for tagname in $taglist; do
916968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
917968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    done
918968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
919968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    exit $?
920968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
921968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
922968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_features
923968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Display the features supported by this script.
924968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_features ()
925968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
926968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    echo "host: $host"
927968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test "$build_libtool_libs" = yes; then
928968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      echo "enable shared libraries"
929968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    else
930968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      echo "disable shared libraries"
931968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
932968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test "$build_old_libs" = yes; then
933968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      echo "enable static libraries"
934968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    else
935968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      echo "disable static libraries"
936968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
937968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
938968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    exit $?
939968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
940968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
941968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_enable_tag tagname
942968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Verify that TAGNAME is valid, and either flag an error and exit, or
943968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
944968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# variable here.
945968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_enable_tag ()
946968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
947968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # Global variable:
948968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  tagname="$1"
949968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
950968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
951968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
952968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  sed_extractcf="/$re_begincf/,/$re_endcf/p"
953968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
954968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # Validate tagname.
955968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  case $tagname in
956968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *[!-_A-Za-z0-9,/]*)
957968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_fatal_error "invalid tag name: $tagname"
958968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      ;;
959968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  esac
960968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
961968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # Don't test for the "default" C tag, as we know it's
962968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # there but not specially marked.
963968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  case $tagname in
964968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    CC) ;;
965968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *)
966968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
967968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	taglist="$taglist $tagname"
968968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
969968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Evaluate the configuration.  Be careful to quote the path
970968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# and the sed script, to avoid splitting on whitespace, but
971968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# also don't use non-portable quotes within backquotes within
972968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# quotes we have to do it in 2 steps:
973968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
974968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	eval "$extractedcf"
975968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      else
976968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_error "ignoring unknown tag $tagname"
977968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
978968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      ;;
979968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  esac
980968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
981968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
982968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_check_version_match
983968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Ensure that we are using m4 macros, and libtool script from the same
984968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# release of libtool.
985968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_check_version_match ()
986968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
987968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if test "$package_revision" != "$macro_revision"; then
988968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test "$VERSION" != "$macro_version"; then
989968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -z "$macro_version"; then
990968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        cat >&2 <<_LT_EOF
991968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
992968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold$progname: definition of this LT_INIT comes from an older release.
993968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
994968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold$progname: and run autoconf again.
995968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold_LT_EOF
996968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      else
997968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        cat >&2 <<_LT_EOF
998968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
999968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
1000968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
1001968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold$progname: and run autoconf again.
1002968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold_LT_EOF
1003968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
1004968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    else
1005968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      cat >&2 <<_LT_EOF
1006968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
1007968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold$progname: but the definition of this LT_INIT comes from revision $macro_revision.
1008968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold$progname: You should recreate aclocal.m4 with macros from revision $package_revision
1009968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold$progname: of $PACKAGE $VERSION and run autoconf again.
1010968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold_LT_EOF
1011968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
1012968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1013968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    exit $EXIT_MISMATCH
1014968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  fi
1015968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1016968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1017968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1018968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Shorthand for --mode=foo, only valid as the first argument
1019968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldcase $1 in
1020968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldclean|clea|cle|cl)
1021968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  shift; set dummy --mode clean ${1+"$@"}; shift
1022968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  ;;
1023968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldcompile|compil|compi|comp|com|co|c)
1024968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  shift; set dummy --mode compile ${1+"$@"}; shift
1025968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  ;;
1026968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldexecute|execut|execu|exec|exe|ex|e)
1027968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  shift; set dummy --mode execute ${1+"$@"}; shift
1028968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  ;;
1029968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfinish|finis|fini|fin|fi|f)
1030968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  shift; set dummy --mode finish ${1+"$@"}; shift
1031968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  ;;
1032968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldinstall|instal|insta|inst|ins|in|i)
1033968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  shift; set dummy --mode install ${1+"$@"}; shift
1034968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  ;;
1035968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldlink|lin|li|l)
1036968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  shift; set dummy --mode link ${1+"$@"}; shift
1037968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  ;;
1038968bf19396ad404e89420f5d67900fce13f4186cGilad Arnolduninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
1039968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  shift; set dummy --mode uninstall ${1+"$@"}; shift
1040968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  ;;
1041968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldesac
1042968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1043968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1044968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1045968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Option defaults:
1046968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldopt_debug=:
1047968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldopt_dry_run=false
1048968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldopt_config=false
1049968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldopt_preserve_dup_deps=false
1050968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldopt_features=false
1051968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldopt_finish=false
1052968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldopt_help=false
1053968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldopt_help_all=false
1054968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldopt_silent=:
1055968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldopt_verbose=:
1056968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldopt_silent=false
1057968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldopt_verbose=false
1058968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1059968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1060968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Parse options once, thoroughly.  This comes as soon as possible in the
1061968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# script to make things like `--version' happen as quickly as we can.
1062968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1063968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # this just eases exit handling
1064968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  while test $# -gt 0; do
1065968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    opt="$1"
1066968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    shift
1067968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    case $opt in
1068968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      --debug|-x)	opt_debug='set -x'
1069968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			func_echo "enabling shell trace mode"
1070968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			$opt_debug
1071968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			;;
1072968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      --dry-run|--dryrun|-n)
1073968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			opt_dry_run=:
1074968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			;;
1075968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      --config)
1076968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			opt_config=:
1077968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_config
1078968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			;;
1079968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      --dlopen|-dlopen)
1080968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			optarg="$1"
1081968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			opt_dlopen="${opt_dlopen+$opt_dlopen
1082968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}$optarg"
1083968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			shift
1084968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			;;
1085968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      --preserve-dup-deps)
1086968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			opt_preserve_dup_deps=:
1087968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			;;
1088968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      --features)
1089968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			opt_features=:
1090968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_features
1091968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			;;
1092968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      --finish)
1093968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			opt_finish=:
1094968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldset dummy --mode finish ${1+"$@"}; shift
1095968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			;;
1096968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      --help)
1097968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			opt_help=:
1098968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			;;
1099968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      --help-all)
1100968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			opt_help_all=:
1101968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldopt_help=': help-all'
1102968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			;;
1103968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      --mode)
1104968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			test $# = 0 && func_missing_arg $opt && break
1105968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			optarg="$1"
1106968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			opt_mode="$optarg"
1107968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldcase $optarg in
1108968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # Valid mode arguments:
1109968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  clean|compile|execute|finish|install|link|relink|uninstall) ;;
1110968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1111968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # Catch anything else as an error
1112968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  *) func_error "invalid argument for $opt"
1113968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     exit_cmd=exit
1114968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     break
1115968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     ;;
1116968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldesac
1117968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			shift
1118968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			;;
1119968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      --no-silent|--no-quiet)
1120968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			opt_silent=false
1121968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_append preserve_args " $opt"
1122968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			;;
1123968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      --no-verbose)
1124968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			opt_verbose=false
1125968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_append preserve_args " $opt"
1126968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			;;
1127968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      --silent|--quiet)
1128968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			opt_silent=:
1129968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_append preserve_args " $opt"
1130968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        opt_verbose=false
1131968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			;;
1132968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      --verbose|-v)
1133968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			opt_verbose=:
1134968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_append preserve_args " $opt"
1135968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldopt_silent=false
1136968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			;;
1137968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      --tag)
1138968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			test $# = 0 && func_missing_arg $opt && break
1139968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			optarg="$1"
1140968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			opt_tag="$optarg"
1141968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_append preserve_args " $opt $optarg"
1142968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_enable_tag "$optarg"
1143968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			shift
1144968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			;;
1145968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1146968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -\?|-h)		func_usage				;;
1147968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      --help)		func_help				;;
1148968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      --version)	func_version				;;
1149968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1150968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Separate optargs to long options:
1151968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      --*=*)
1152968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			func_split_long_opt "$opt"
1153968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
1154968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			shift
1155968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			;;
1156968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1157968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Separate non-argument short options:
1158968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -\?*|-h*|-n*|-v*)
1159968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			func_split_short_opt "$opt"
1160968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
1161968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			shift
1162968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			;;
1163968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1164968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      --)		break					;;
1165968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
1166968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
1167968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    esac
1168968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  done
1169968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1170968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # Validate options:
1171968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1172968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # save first non-option argument
1173968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if test "$#" -gt 0; then
1174968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    nonopt="$opt"
1175968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    shift
1176968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  fi
1177968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1178968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # preserve --debug
1179968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  test "$opt_debug" = : || func_append preserve_args " --debug"
1180968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1181968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  case $host in
1182968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *cygwin* | *mingw* | *pw32* | *cegcc*)
1183968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # don't eliminate duplications in $postdeps and $predeps
1184968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      opt_duplicate_compiler_generated_deps=:
1185968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      ;;
1186968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *)
1187968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
1188968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      ;;
1189968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  esac
1190968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1191968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $opt_help || {
1192968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Sanity checks first:
1193968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_check_version_match
1194968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1195968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
1196968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_fatal_configuration "not configured to build any kind of library"
1197968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
1198968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1199968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Darwin sucks
1200968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    eval std_shrext=\"$shrext_cmds\"
1201968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1202968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Only execute mode is allowed to have -dlopen flags.
1203968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
1204968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_error "unrecognized option \`-dlopen'"
1205968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      $ECHO "$help" 1>&2
1206968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      exit $EXIT_FAILURE
1207968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
1208968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1209968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Change the help message to a mode-specific one.
1210968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    generic_help="$help"
1211968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    help="Try \`$progname --help --mode=$opt_mode' for more information."
1212968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  }
1213968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1214968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1215968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # Bail if the options were screwed
1216968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $exit_cmd $EXIT_FAILURE
1217968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1218968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1219968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1220968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1221968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1222968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold## ----------- ##
1223968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold##    Main.    ##
1224968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold## ----------- ##
1225968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1226968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_lalib_p file
1227968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# True iff FILE is a libtool `.la' library or `.lo' object file.
1228968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# This function is only a basic sanity check; it will hardly flush out
1229968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# determined imposters.
1230968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_lalib_p ()
1231968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1232968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    test -f "$1" &&
1233968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      $SED -e 4q "$1" 2>/dev/null \
1234968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
1235968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1236968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1237968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_lalib_unsafe_p file
1238968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# True iff FILE is a libtool `.la' library or `.lo' object file.
1239968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# This function implements the same check as func_lalib_p without
1240968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# resorting to external programs.  To this end, it redirects stdin and
1241968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# closes it afterwards, without saving the original file descriptor.
1242968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# As a safety measure, use it only where a negative result would be
1243968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# fatal anyway.  Works if `file' does not exist.
1244968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_lalib_unsafe_p ()
1245968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1246968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    lalib_p=no
1247968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
1248968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	for lalib_p_l in 1 2 3 4
1249968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	do
1250968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    read lalib_p_line
1251968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    case "$lalib_p_line" in
1252968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
1253968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    esac
1254968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	done
1255968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	exec 0<&5 5<&-
1256968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
1257968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    test "$lalib_p" = yes
1258968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1259968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1260968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_ltwrapper_script_p file
1261968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# True iff FILE is a libtool wrapper script
1262968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# This function is only a basic sanity check; it will hardly flush out
1263968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# determined imposters.
1264968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_ltwrapper_script_p ()
1265968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1266968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_lalib_p "$1"
1267968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1268968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1269968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_ltwrapper_executable_p file
1270968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# True iff FILE is a libtool wrapper executable
1271968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# This function is only a basic sanity check; it will hardly flush out
1272968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# determined imposters.
1273968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_ltwrapper_executable_p ()
1274968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1275968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_ltwrapper_exec_suffix=
1276968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    case $1 in
1277968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *.exe) ;;
1278968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *) func_ltwrapper_exec_suffix=.exe ;;
1279968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    esac
1280968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
1281968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1282968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1283968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_ltwrapper_scriptname file
1284968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Assumes file is an ltwrapper_executable
1285968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# uses $file to determine the appropriate filename for a
1286968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# temporary ltwrapper_script.
1287968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_ltwrapper_scriptname ()
1288968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1289968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_dirname_and_basename "$1" "" "."
1290968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_stripname '' '.exe' "$func_basename_result"
1291968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
1292968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1293968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1294968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_ltwrapper_p file
1295968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# True iff FILE is a libtool wrapper script or wrapper executable
1296968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# This function is only a basic sanity check; it will hardly flush out
1297968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# determined imposters.
1298968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_ltwrapper_p ()
1299968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1300968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
1301968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1302968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1303968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1304968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_execute_cmds commands fail_cmd
1305968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Execute tilde-delimited COMMANDS.
1306968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# If FAIL_CMD is given, eval that upon failure.
1307968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# FAIL_CMD may read-access the current command in variable CMD!
1308968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_execute_cmds ()
1309968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1310968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $opt_debug
1311968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    save_ifs=$IFS; IFS='~'
1312968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    for cmd in $1; do
1313968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      IFS=$save_ifs
1314968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      eval cmd=\"$cmd\"
1315968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_show_eval "$cmd" "${2-:}"
1316968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    done
1317968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    IFS=$save_ifs
1318968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1319968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1320968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1321968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_source file
1322968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Source FILE, adding directory component if necessary.
1323968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Note that it is not necessary on cygwin/mingw to append a dot to
1324968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
1325968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# behavior happens only for exec(3), not for open(2)!  Also, sourcing
1326968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# `FILE.' does not work on cygwin managed mounts.
1327968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_source ()
1328968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1329968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $opt_debug
1330968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    case $1 in
1331968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    */* | *\\*)	. "$1" ;;
1332968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *)		. "./$1" ;;
1333968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    esac
1334968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1335968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1336968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1337968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_resolve_sysroot PATH
1338968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Replace a leading = in PATH with a sysroot.  Store the result into
1339968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_resolve_sysroot_result
1340968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_resolve_sysroot ()
1341968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1342968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_resolve_sysroot_result=$1
1343968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  case $func_resolve_sysroot_result in
1344968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  =*)
1345968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_stripname '=' '' "$func_resolve_sysroot_result"
1346968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
1347968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    ;;
1348968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  esac
1349968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1350968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1351968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_replace_sysroot PATH
1352968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# If PATH begins with the sysroot, replace it with = and
1353968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# store the result into func_replace_sysroot_result.
1354968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_replace_sysroot ()
1355968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1356968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  case "$lt_sysroot:$1" in
1357968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  ?*:"$lt_sysroot"*)
1358968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_stripname "$lt_sysroot" '' "$1"
1359968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_replace_sysroot_result="=$func_stripname_result"
1360968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    ;;
1361968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  *)
1362968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Including no sysroot.
1363968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_replace_sysroot_result=$1
1364968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    ;;
1365968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  esac
1366968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1367968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1368968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_infer_tag arg
1369968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Infer tagged configuration to use if any are available and
1370968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# if one wasn't chosen via the "--tag" command line option.
1371968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Only attempt this if the compiler in the base compile
1372968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# command doesn't match the default compiler.
1373968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# arg is usually of the form 'gcc ...'
1374968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_infer_tag ()
1375968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1376968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $opt_debug
1377968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test -n "$available_tags" && test -z "$tagname"; then
1378968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      CC_quoted=
1379968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      for arg in $CC; do
1380968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_append_quoted CC_quoted "$arg"
1381968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      done
1382968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      CC_expanded=`func_echo_all $CC`
1383968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      CC_quoted_expanded=`func_echo_all $CC_quoted`
1384968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      case $@ in
1385968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Blanks in the command may have been stripped by the calling shell,
1386968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # but not from the CC environment variable when configure was run.
1387968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1388968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
1389968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Blanks at the start of $base_compile will cause this to fail
1390968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # if we don't check for them as well.
1391968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *)
1392968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	for z in $available_tags; do
1393968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1394968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Evaluate the configuration.
1395968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1396968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    CC_quoted=
1397968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    for arg in $CC; do
1398968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # Double-quote args containing other shell metacharacters.
1399968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_append_quoted CC_quoted "$arg"
1400968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    done
1401968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    CC_expanded=`func_echo_all $CC`
1402968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    CC_quoted_expanded=`func_echo_all $CC_quoted`
1403968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    case "$@ " in
1404968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1405968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
1406968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # The compiler in the base compile command matches
1407968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # the one in the tagged configuration.
1408968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # Assume this is the tagged configuration we want.
1409968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      tagname=$z
1410968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      break
1411968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      ;;
1412968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    esac
1413968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
1414968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	done
1415968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# If $tagname still isn't set, then no tagged configuration
1416968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# was found and let the user know that the "--tag" command
1417968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# line option must be used.
1418968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -z "$tagname"; then
1419968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_echo "unable to infer tagged configuration"
1420968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_fatal_error "specify a tag with \`--tag'"
1421968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#	else
1422968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#	  func_verbose "using $tagname tagged configuration"
1423968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
1424968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
1425968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      esac
1426968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
1427968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1428968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1429968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1430968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1431968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_write_libtool_object output_name pic_name nonpic_name
1432968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Create a libtool object file (analogous to a ".la" file),
1433968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# but don't create it if we're doing a dry run.
1434968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_write_libtool_object ()
1435968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1436968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    write_libobj=${1}
1437968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test "$build_libtool_libs" = yes; then
1438968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      write_lobj=\'${2}\'
1439968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    else
1440968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      write_lobj=none
1441968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
1442968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1443968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test "$build_old_libs" = yes; then
1444968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      write_oldobj=\'${3}\'
1445968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    else
1446968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      write_oldobj=none
1447968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
1448968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1449968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $opt_dry_run || {
1450968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      cat >${write_libobj}T <<EOF
1451968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# $write_libobj - a libtool object file
1452968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1453968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
1454968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Please DO NOT delete this file!
1455968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# It is necessary for linking the library.
1456968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1457968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Name of the PIC object.
1458968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldpic_object=$write_lobj
1459968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1460968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Name of the non-PIC object
1461968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldnon_pic_object=$write_oldobj
1462968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1463968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEOF
1464968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      $MV "${write_libobj}T" "${write_libobj}"
1465968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    }
1466968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1467968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1468968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1469968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold##################################################
1470968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
1471968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold##################################################
1472968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1473968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_convert_core_file_wine_to_w32 ARG
1474968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Helper function used by file name conversion functions when $build is *nix,
1475968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# and $host is mingw, cygwin, or some other w32 environment. Relies on a
1476968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# correctly configured wine environment available, with the winepath program
1477968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# in $build's $PATH.
1478968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
1479968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# ARG is the $build file name to be converted to w32 format.
1480968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Result is available in $func_convert_core_file_wine_to_w32_result, and will
1481968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# be empty on error (or when ARG is empty)
1482968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_convert_core_file_wine_to_w32 ()
1483968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1484968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $opt_debug
1485968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_convert_core_file_wine_to_w32_result="$1"
1486968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if test -n "$1"; then
1487968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Unfortunately, winepath does not exit with a non-zero error code, so we
1488968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # are forced to check the contents of stdout. On the other hand, if the
1489968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # command is not found, the shell will set an exit code of 127 and print
1490968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # *an error message* to stdout. So we must check for both error code of
1491968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # zero AND non-empty stdout, which explains the odd construction:
1492968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
1493968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
1494968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
1495968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        $SED -e "$lt_sed_naive_backslashify"`
1496968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    else
1497968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_convert_core_file_wine_to_w32_result=
1498968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
1499968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  fi
1500968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1501968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# end: func_convert_core_file_wine_to_w32
1502968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1503968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1504968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_convert_core_path_wine_to_w32 ARG
1505968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Helper function used by path conversion functions when $build is *nix, and
1506968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
1507968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# configured wine environment available, with the winepath program in $build's
1508968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# $PATH. Assumes ARG has no leading or trailing path separator characters.
1509968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
1510968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# ARG is path to be converted from $build format to win32.
1511968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Result is available in $func_convert_core_path_wine_to_w32_result.
1512968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Unconvertible file (directory) names in ARG are skipped; if no directory names
1513968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# are convertible, then the result may be empty.
1514968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_convert_core_path_wine_to_w32 ()
1515968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1516968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $opt_debug
1517968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # unfortunately, winepath doesn't convert paths, only file names
1518968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_convert_core_path_wine_to_w32_result=""
1519968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if test -n "$1"; then
1520968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    oldIFS=$IFS
1521968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    IFS=:
1522968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    for func_convert_core_path_wine_to_w32_f in $1; do
1523968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      IFS=$oldIFS
1524968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
1525968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
1526968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        if test -z "$func_convert_core_path_wine_to_w32_result"; then
1527968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
1528968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        else
1529968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
1530968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        fi
1531968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
1532968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    done
1533968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    IFS=$oldIFS
1534968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  fi
1535968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1536968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# end: func_convert_core_path_wine_to_w32
1537968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1538968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1539968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_cygpath ARGS...
1540968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
1541968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
1542968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
1543968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# (2), returns the Cygwin file name or path in func_cygpath_result (input
1544968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# file name or path is assumed to be in w32 format, as previously converted
1545968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# from $build's *nix or MSYS format). In case (3), returns the w32 file name
1546968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# or path in func_cygpath_result (input file name or path is assumed to be in
1547968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Cygwin format). Returns an empty string on error.
1548968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
1549968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# ARGS are passed to cygpath, with the last one being the file name or path to
1550968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# be converted.
1551968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
1552968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
1553968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# environment variable; do not put it in $PATH.
1554968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_cygpath ()
1555968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1556968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $opt_debug
1557968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
1558968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
1559968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test "$?" -ne 0; then
1560968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # on failure, ensure result is empty
1561968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_cygpath_result=
1562968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
1563968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  else
1564968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_cygpath_result=
1565968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
1566968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  fi
1567968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1568968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#end: func_cygpath
1569968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1570968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1571968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_convert_core_msys_to_w32 ARG
1572968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Convert file name or path ARG from MSYS format to w32 format.  Return
1573968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# result in func_convert_core_msys_to_w32_result.
1574968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_convert_core_msys_to_w32 ()
1575968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1576968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $opt_debug
1577968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # awkward: cmd appends spaces to result
1578968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
1579968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
1580968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1581968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#end: func_convert_core_msys_to_w32
1582968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1583968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1584968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_convert_file_check ARG1 ARG2
1585968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Verify that ARG1 (a file name in $build format) was converted to $host
1586968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# format in ARG2. Otherwise, emit an error message, but continue (resetting
1587968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_to_host_file_result to ARG1).
1588968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_convert_file_check ()
1589968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1590968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $opt_debug
1591968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if test -z "$2" && test -n "$1" ; then
1592968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_error "Could not determine host file name corresponding to"
1593968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_error "  \`$1'"
1594968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_error "Continuing, but uninstalled executables may not work."
1595968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Fallback:
1596968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_to_host_file_result="$1"
1597968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  fi
1598968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1599968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# end func_convert_file_check
1600968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1601968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1602968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
1603968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Verify that FROM_PATH (a path in $build format) was converted to $host
1604968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
1605968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_to_host_file_result to a simplistic fallback value (see below).
1606968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_convert_path_check ()
1607968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1608968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $opt_debug
1609968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if test -z "$4" && test -n "$3"; then
1610968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_error "Could not determine the host path corresponding to"
1611968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_error "  \`$3'"
1612968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_error "Continuing, but uninstalled executables may not work."
1613968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Fallback.  This is a deliberately simplistic "conversion" and
1614968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # should not be "improved".  See libtool.info.
1615968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test "x$1" != "x$2"; then
1616968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      lt_replace_pathsep_chars="s|$1|$2|g"
1617968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_to_host_path_result=`echo "$3" |
1618968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        $SED -e "$lt_replace_pathsep_chars"`
1619968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    else
1620968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_to_host_path_result="$3"
1621968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
1622968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  fi
1623968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1624968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# end func_convert_path_check
1625968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1626968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1627968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
1628968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
1629968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# and appending REPL if ORIG matches BACKPAT.
1630968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_convert_path_front_back_pathsep ()
1631968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1632968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $opt_debug
1633968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  case $4 in
1634968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
1635968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    ;;
1636968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  esac
1637968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  case $4 in
1638968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $2 ) func_append func_to_host_path_result "$3"
1639968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    ;;
1640968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  esac
1641968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1642968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# end func_convert_path_front_back_pathsep
1643968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1644968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1645968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold##################################################
1646968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# $build to $host FILE NAME CONVERSION FUNCTIONS #
1647968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold##################################################
1648968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# invoked via `$to_host_file_cmd ARG'
1649968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
1650968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# In each case, ARG is the path to be converted from $build to $host format.
1651968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Result will be available in $func_to_host_file_result.
1652968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1653968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1654968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_to_host_file ARG
1655968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Converts the file name ARG from $build format to $host format. Return result
1656968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# in func_to_host_file_result.
1657968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_to_host_file ()
1658968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1659968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $opt_debug
1660968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $to_host_file_cmd "$1"
1661968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1662968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# end func_to_host_file
1663968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1664968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1665968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_to_tool_file ARG LAZY
1666968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# converts the file name ARG from $build format to toolchain format. Return
1667968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# result in func_to_tool_file_result.  If the conversion in use is listed
1668968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# in (the comma separated) LAZY, no conversion takes place.
1669968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_to_tool_file ()
1670968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1671968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $opt_debug
1672968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  case ,$2, in
1673968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *,"$to_tool_file_cmd",*)
1674968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_to_tool_file_result=$1
1675968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      ;;
1676968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *)
1677968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      $to_tool_file_cmd "$1"
1678968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_to_tool_file_result=$func_to_host_file_result
1679968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      ;;
1680968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  esac
1681968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1682968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# end func_to_tool_file
1683968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1684968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1685968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_convert_file_noop ARG
1686968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Copy ARG to func_to_host_file_result.
1687968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_convert_file_noop ()
1688968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1689968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_to_host_file_result="$1"
1690968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1691968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# end func_convert_file_noop
1692968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1693968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1694968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_convert_file_msys_to_w32 ARG
1695968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
1696968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# conversion to w32 is not available inside the cwrapper.  Returns result in
1697968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_to_host_file_result.
1698968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_convert_file_msys_to_w32 ()
1699968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1700968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $opt_debug
1701968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_to_host_file_result="$1"
1702968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if test -n "$1"; then
1703968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_convert_core_msys_to_w32 "$1"
1704968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
1705968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  fi
1706968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_convert_file_check "$1" "$func_to_host_file_result"
1707968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1708968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# end func_convert_file_msys_to_w32
1709968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1710968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1711968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_convert_file_cygwin_to_w32 ARG
1712968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Convert file name ARG from Cygwin to w32 format.  Returns result in
1713968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_to_host_file_result.
1714968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_convert_file_cygwin_to_w32 ()
1715968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1716968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $opt_debug
1717968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_to_host_file_result="$1"
1718968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if test -n "$1"; then
1719968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
1720968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # LT_CYGPATH in this case.
1721968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_to_host_file_result=`cygpath -m "$1"`
1722968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  fi
1723968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_convert_file_check "$1" "$func_to_host_file_result"
1724968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1725968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# end func_convert_file_cygwin_to_w32
1726968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1727968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1728968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_convert_file_nix_to_w32 ARG
1729968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Convert file name ARG from *nix to w32 format.  Requires a wine environment
1730968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# and a working winepath. Returns result in func_to_host_file_result.
1731968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_convert_file_nix_to_w32 ()
1732968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1733968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $opt_debug
1734968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_to_host_file_result="$1"
1735968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if test -n "$1"; then
1736968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_convert_core_file_wine_to_w32 "$1"
1737968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
1738968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  fi
1739968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_convert_file_check "$1" "$func_to_host_file_result"
1740968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1741968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# end func_convert_file_nix_to_w32
1742968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1743968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1744968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_convert_file_msys_to_cygwin ARG
1745968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1746968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Returns result in func_to_host_file_result.
1747968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_convert_file_msys_to_cygwin ()
1748968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1749968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $opt_debug
1750968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_to_host_file_result="$1"
1751968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if test -n "$1"; then
1752968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_convert_core_msys_to_w32 "$1"
1753968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_cygpath -u "$func_convert_core_msys_to_w32_result"
1754968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_to_host_file_result="$func_cygpath_result"
1755968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  fi
1756968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_convert_file_check "$1" "$func_to_host_file_result"
1757968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1758968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# end func_convert_file_msys_to_cygwin
1759968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1760968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1761968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_convert_file_nix_to_cygwin ARG
1762968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
1763968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
1764968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# in func_to_host_file_result.
1765968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_convert_file_nix_to_cygwin ()
1766968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1767968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $opt_debug
1768968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_to_host_file_result="$1"
1769968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if test -n "$1"; then
1770968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
1771968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_convert_core_file_wine_to_w32 "$1"
1772968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
1773968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_to_host_file_result="$func_cygpath_result"
1774968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  fi
1775968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_convert_file_check "$1" "$func_to_host_file_result"
1776968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1777968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# end func_convert_file_nix_to_cygwin
1778968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1779968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1780968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#############################################
1781968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# $build to $host PATH CONVERSION FUNCTIONS #
1782968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#############################################
1783968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# invoked via `$to_host_path_cmd ARG'
1784968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
1785968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# In each case, ARG is the path to be converted from $build to $host format.
1786968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# The result will be available in $func_to_host_path_result.
1787968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
1788968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Path separators are also converted from $build format to $host format.  If
1789968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# ARG begins or ends with a path separator character, it is preserved (but
1790968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# converted to $host format) on output.
1791968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
1792968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# All path conversion functions are named using the following convention:
1793968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#   file name conversion function    : func_convert_file_X_to_Y ()
1794968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#   path conversion function         : func_convert_path_X_to_Y ()
1795968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# where, for any given $build/$host combination the 'X_to_Y' value is the
1796968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# same.  If conversion functions are added for new $build/$host combinations,
1797968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# the two new functions must follow this pattern, or func_init_to_host_path_cmd
1798968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# will break.
1799968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1800968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1801968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_init_to_host_path_cmd
1802968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Ensures that function "pointer" variable $to_host_path_cmd is set to the
1803968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# appropriate value, based on the value of $to_host_file_cmd.
1804968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldto_host_path_cmd=
1805968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_init_to_host_path_cmd ()
1806968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1807968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $opt_debug
1808968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if test -z "$to_host_path_cmd"; then
1809968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
1810968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    to_host_path_cmd="func_convert_path_${func_stripname_result}"
1811968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  fi
1812968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1813968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1814968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1815968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_to_host_path ARG
1816968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Converts the path ARG from $build format to $host format. Return result
1817968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# in func_to_host_path_result.
1818968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_to_host_path ()
1819968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1820968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $opt_debug
1821968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_init_to_host_path_cmd
1822968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $to_host_path_cmd "$1"
1823968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1824968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# end func_to_host_path
1825968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1826968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1827968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_convert_path_noop ARG
1828968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Copy ARG to func_to_host_path_result.
1829968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_convert_path_noop ()
1830968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1831968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_to_host_path_result="$1"
1832968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1833968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# end func_convert_path_noop
1834968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1835968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1836968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_convert_path_msys_to_w32 ARG
1837968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
1838968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# conversion to w32 is not available inside the cwrapper.  Returns result in
1839968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_to_host_path_result.
1840968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_convert_path_msys_to_w32 ()
1841968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1842968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $opt_debug
1843968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_to_host_path_result="$1"
1844968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if test -n "$1"; then
1845968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Remove leading and trailing path separator characters from ARG.  MSYS
1846968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
1847968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # and winepath ignores them completely.
1848968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_stripname : : "$1"
1849968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_to_host_path_tmp1=$func_stripname_result
1850968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1851968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
1852968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_convert_path_check : ";" \
1853968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1854968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1855968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  fi
1856968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1857968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# end func_convert_path_msys_to_w32
1858968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1859968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1860968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_convert_path_cygwin_to_w32 ARG
1861968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Convert path ARG from Cygwin to w32 format.  Returns result in
1862968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_to_host_file_result.
1863968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_convert_path_cygwin_to_w32 ()
1864968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1865968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $opt_debug
1866968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_to_host_path_result="$1"
1867968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if test -n "$1"; then
1868968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # See func_convert_path_msys_to_w32:
1869968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_stripname : : "$1"
1870968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_to_host_path_tmp1=$func_stripname_result
1871968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
1872968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_convert_path_check : ";" \
1873968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1874968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1875968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  fi
1876968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1877968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# end func_convert_path_cygwin_to_w32
1878968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1879968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1880968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_convert_path_nix_to_w32 ARG
1881968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Convert path ARG from *nix to w32 format.  Requires a wine environment and
1882968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# a working winepath.  Returns result in func_to_host_file_result.
1883968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_convert_path_nix_to_w32 ()
1884968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1885968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $opt_debug
1886968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_to_host_path_result="$1"
1887968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if test -n "$1"; then
1888968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # See func_convert_path_msys_to_w32:
1889968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_stripname : : "$1"
1890968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_to_host_path_tmp1=$func_stripname_result
1891968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1892968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
1893968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_convert_path_check : ";" \
1894968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1895968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1896968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  fi
1897968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1898968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# end func_convert_path_nix_to_w32
1899968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1900968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1901968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_convert_path_msys_to_cygwin ARG
1902968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1903968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Returns result in func_to_host_file_result.
1904968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_convert_path_msys_to_cygwin ()
1905968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1906968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $opt_debug
1907968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_to_host_path_result="$1"
1908968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if test -n "$1"; then
1909968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # See func_convert_path_msys_to_w32:
1910968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_stripname : : "$1"
1911968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_to_host_path_tmp1=$func_stripname_result
1912968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1913968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
1914968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_to_host_path_result="$func_cygpath_result"
1915968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_convert_path_check : : \
1916968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1917968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1918968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  fi
1919968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1920968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# end func_convert_path_msys_to_cygwin
1921968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1922968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1923968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_convert_path_nix_to_cygwin ARG
1924968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
1925968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
1926968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_to_host_file_result.
1927968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_convert_path_nix_to_cygwin ()
1928968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1929968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $opt_debug
1930968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_to_host_path_result="$1"
1931968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if test -n "$1"; then
1932968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Remove leading and trailing path separator characters from
1933968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # ARG. msys behavior is inconsistent here, cygpath turns them
1934968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # into '.;' and ';.', and winepath ignores them completely.
1935968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_stripname : : "$1"
1936968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_to_host_path_tmp1=$func_stripname_result
1937968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1938968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
1939968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_to_host_path_result="$func_cygpath_result"
1940968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_convert_path_check : : \
1941968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1942968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1943968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  fi
1944968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
1945968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# end func_convert_path_nix_to_cygwin
1946968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1947968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1948968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_mode_compile arg...
1949968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_mode_compile ()
1950968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
1951968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $opt_debug
1952968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Get the compilation command and the source file.
1953968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    base_compile=
1954968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
1955968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    suppress_opt=yes
1956968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    suppress_output=
1957968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    arg_mode=normal
1958968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    libobj=
1959968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    later=
1960968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    pie_flag=
1961968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1962968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    for arg
1963968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    do
1964968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      case $arg_mode in
1965968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      arg  )
1966968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# do not "continue".  Instead, add this to base_compile
1967968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	lastarg="$arg"
1968968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	arg_mode=normal
1969968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
1970968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1971968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      target )
1972968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	libobj="$arg"
1973968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	arg_mode=normal
1974968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
1975968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
1976968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1977968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      normal )
1978968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Accept any command-line options.
1979968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $arg in
1980968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	-o)
1981968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  test -n "$libobj" && \
1982968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_fatal_error "you cannot specify \`-o' more than once"
1983968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  arg_mode=target
1984968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
1985968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
1986968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1987968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	-pie | -fpie | -fPIE)
1988968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold          func_append pie_flag " $arg"
1989968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
1990968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
1991968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1992968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	-shared | -static | -prefer-pic | -prefer-non-pic)
1993968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append later " $arg"
1994968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
1995968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
1996968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
1997968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	-no-suppress)
1998968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  suppress_opt=no
1999968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
2000968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
2001968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2002968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	-Xcompiler)
2003968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
2004968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue      #  The current "srcfile" will either be retained or
2005968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;            #  replaced later.  I would guess that would be a bug.
2006968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2007968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	-Wc,*)
2008968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_stripname '-Wc,' '' "$arg"
2009968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  args=$func_stripname_result
2010968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  lastarg=
2011968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  save_ifs="$IFS"; IFS=','
2012968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  for arg in $args; do
2013968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    IFS="$save_ifs"
2014968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append_quoted lastarg "$arg"
2015968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  done
2016968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  IFS="$save_ifs"
2017968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_stripname ' ' '' "$lastarg"
2018968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  lastarg=$func_stripname_result
2019968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2020968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Add the arguments to base_compile.
2021968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append base_compile " $lastarg"
2022968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
2023968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
2024968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2025968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*)
2026968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Accept the current argument as the source file.
2027968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # The previous "srcfile" becomes the current argument.
2028968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  #
2029968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  lastarg="$srcfile"
2030968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  srcfile="$arg"
2031968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
2032968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac  #  case $arg
2033968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
2034968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      esac    #  case $arg_mode
2035968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2036968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Aesthetically quote the previous argument.
2037968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_append_quoted base_compile "$lastarg"
2038968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    done # for arg
2039968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2040968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    case $arg_mode in
2041968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    arg)
2042968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_fatal_error "you must specify an argument for -Xcompile"
2043968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      ;;
2044968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    target)
2045968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_fatal_error "you must specify a target with \`-o'"
2046968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      ;;
2047968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *)
2048968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Get the name of the library object.
2049968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      test -z "$libobj" && {
2050968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_basename "$srcfile"
2051968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	libobj="$func_basename_result"
2052968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      }
2053968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      ;;
2054968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    esac
2055968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2056968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Recognize several different file suffixes.
2057968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # If the user specifies -o file.o, it is replaced with file.lo
2058968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    case $libobj in
2059968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *.[cCFSifmso] | \
2060968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *.ada | *.adb | *.ads | *.asm | \
2061968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
2062968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup)
2063968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_xform "$libobj"
2064968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      libobj=$func_xform_result
2065968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      ;;
2066968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    esac
2067968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2068968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    case $libobj in
2069968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
2070968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *)
2071968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_fatal_error "cannot determine name of library object from \`$libobj'"
2072968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      ;;
2073968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    esac
2074968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2075968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_infer_tag $base_compile
2076968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2077968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    for arg in $later; do
2078968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      case $arg in
2079968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -shared)
2080968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	test "$build_libtool_libs" != yes && \
2081968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_fatal_configuration "can not build a shared library"
2082968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	build_old_libs=no
2083968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
2084968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
2085968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2086968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -static)
2087968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	build_libtool_libs=no
2088968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	build_old_libs=yes
2089968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
2090968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
2091968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2092968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -prefer-pic)
2093968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	pic_mode=yes
2094968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
2095968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
2096968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2097968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -prefer-non-pic)
2098968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	pic_mode=no
2099968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
2100968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
2101968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      esac
2102968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    done
2103968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2104968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_quote_for_eval "$libobj"
2105968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    test "X$libobj" != "X$func_quote_for_eval_result" \
2106968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
2107968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      && func_warning "libobj name \`$libobj' may not contain shell special characters."
2108968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_dirname_and_basename "$obj" "/" ""
2109968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    objname="$func_basename_result"
2110968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    xdir="$func_dirname_result"
2111968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    lobj=${xdir}$objdir/$objname
2112968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2113968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    test -z "$base_compile" && \
2114968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_fatal_help "you must specify a compilation command"
2115968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2116968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Delete any leftover library objects.
2117968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test "$build_old_libs" = yes; then
2118968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      removelist="$obj $lobj $libobj ${libobj}T"
2119968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    else
2120968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      removelist="$lobj $libobj ${libobj}T"
2121968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
2122968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2123968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # On Cygwin there's no "real" PIC flag so we must build both object types
2124968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    case $host_os in
2125968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    cygwin* | mingw* | pw32* | os2* | cegcc*)
2126968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      pic_mode=default
2127968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      ;;
2128968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    esac
2129968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
2130968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # non-PIC code in shared libraries is not supported
2131968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      pic_mode=default
2132968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
2133968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2134968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Calculate the filename of the output object if compiler does
2135968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # not support -o with -c
2136968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test "$compiler_c_o" = no; then
2137968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
2138968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      lockfile="$output_obj.lock"
2139968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    else
2140968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      output_obj=
2141968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      need_locks=no
2142968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      lockfile=
2143968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
2144968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2145968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Lock this critical section if it is needed
2146968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # We use this script file to make the link, it avoids creating a new file
2147968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test "$need_locks" = yes; then
2148968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
2149968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_echo "Waiting for $lockfile to be removed"
2150968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	sleep 2
2151968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      done
2152968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    elif test "$need_locks" = warn; then
2153968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -f "$lockfile"; then
2154968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	$ECHO "\
2155968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold*** ERROR, $lockfile exists and contains:
2156968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold`cat $lockfile 2>/dev/null`
2157968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2158968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldThis indicates that another process is trying to use the same
2159968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldtemporary object file, and libtool could not work around it because
2160968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldyour compiler does not support \`-c' and \`-o' together.  If you
2161968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldrepeat this compilation, it may succeed, by chance, but you had better
2162968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldavoid parallel builds (make -j) in this platform, or get a better
2163968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldcompiler."
2164968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2165968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	$opt_dry_run || $RM $removelist
2166968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	exit $EXIT_FAILURE
2167968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
2168968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_append removelist " $output_obj"
2169968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      $ECHO "$srcfile" > "$lockfile"
2170968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
2171968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2172968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $opt_dry_run || $RM $removelist
2173968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_append removelist " $lockfile"
2174968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
2175968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2176968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
2177968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    srcfile=$func_to_tool_file_result
2178968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_quote_for_eval "$srcfile"
2179968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    qsrcfile=$func_quote_for_eval_result
2180968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2181968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Only build a PIC object if we are building libtool libraries.
2182968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test "$build_libtool_libs" = yes; then
2183968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Without this assignment, base_compile gets emptied.
2184968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fbsd_hideous_sh_bug=$base_compile
2185968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2186968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test "$pic_mode" != no; then
2187968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	command="$base_compile $qsrcfile $pic_flag"
2188968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      else
2189968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Don't build PIC code
2190968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	command="$base_compile $qsrcfile"
2191968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
2192968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2193968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_mkdir_p "$xdir$objdir"
2194968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2195968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -z "$output_obj"; then
2196968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Place PIC objects in $objdir
2197968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_append command " -o $lobj"
2198968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
2199968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2200968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_show_eval_locale "$command"	\
2201968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
2202968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2203968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test "$need_locks" = warn &&
2204968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2205968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	$ECHO "\
2206968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold*** ERROR, $lockfile contains:
2207968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold`cat $lockfile 2>/dev/null`
2208968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2209968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldbut it should contain:
2210968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold$srcfile
2211968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2212968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldThis indicates that another process is trying to use the same
2213968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldtemporary object file, and libtool could not work around it because
2214968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldyour compiler does not support \`-c' and \`-o' together.  If you
2215968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldrepeat this compilation, it may succeed, by chance, but you had better
2216968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldavoid parallel builds (make -j) in this platform, or get a better
2217968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldcompiler."
2218968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2219968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	$opt_dry_run || $RM $removelist
2220968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	exit $EXIT_FAILURE
2221968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
2222968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2223968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Just move the object if needed, then go on to compile the next one
2224968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
2225968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_show_eval '$MV "$output_obj" "$lobj"' \
2226968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2227968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
2228968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2229968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Allow error messages only from the first compilation.
2230968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test "$suppress_opt" = yes; then
2231968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	suppress_output=' >/dev/null 2>&1'
2232968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
2233968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
2234968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2235968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Only build a position-dependent object if we build old libraries.
2236968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test "$build_old_libs" = yes; then
2237968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test "$pic_mode" != yes; then
2238968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Don't build PIC code
2239968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	command="$base_compile $qsrcfile$pie_flag"
2240968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      else
2241968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	command="$base_compile $qsrcfile $pic_flag"
2242968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
2243968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test "$compiler_c_o" = yes; then
2244968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_append command " -o $obj"
2245968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
2246968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2247968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Suppress compiler output if we already did a PIC compilation.
2248968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_append command "$suppress_output"
2249968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_show_eval_locale "$command" \
2250968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
2251968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2252968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test "$need_locks" = warn &&
2253968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2254968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	$ECHO "\
2255968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold*** ERROR, $lockfile contains:
2256968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold`cat $lockfile 2>/dev/null`
2257968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2258968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldbut it should contain:
2259968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold$srcfile
2260968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2261968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldThis indicates that another process is trying to use the same
2262968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldtemporary object file, and libtool could not work around it because
2263968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldyour compiler does not support \`-c' and \`-o' together.  If you
2264968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldrepeat this compilation, it may succeed, by chance, but you had better
2265968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldavoid parallel builds (make -j) in this platform, or get a better
2266968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldcompiler."
2267968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2268968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	$opt_dry_run || $RM $removelist
2269968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	exit $EXIT_FAILURE
2270968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
2271968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2272968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Just move the object if needed
2273968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
2274968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_show_eval '$MV "$output_obj" "$obj"' \
2275968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2276968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
2277968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
2278968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2279968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $opt_dry_run || {
2280968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
2281968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2282968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Unlock the critical section if it was locked
2283968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test "$need_locks" != no; then
2284968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	removelist=$lockfile
2285968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        $RM "$lockfile"
2286968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
2287968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    }
2288968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2289968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    exit $EXIT_SUCCESS
2290968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
2291968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2292968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold$opt_help || {
2293968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
2294968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
2295968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2296968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_mode_help ()
2297968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
2298968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # We need to display help for each of the modes.
2299968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    case $opt_mode in
2300968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      "")
2301968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        # Generic help is extracted from the usage comments
2302968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        # at the start of this file.
2303968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        func_help
2304968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        ;;
2305968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2306968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      clean)
2307968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        $ECHO \
2308968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
2309968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2310968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldRemove files from the build directory.
2311968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2312968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldRM is the name of the program to use to delete files associated with each FILE
2313968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2314968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldto RM.
2315968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2316968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldIf FILE is a libtool library, object or program, all the files associated
2317968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldwith it are deleted. Otherwise, only FILE itself is deleted using RM."
2318968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        ;;
2319968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2320968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      compile)
2321968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      $ECHO \
2322968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
2323968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2324968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldCompile a source file into a libtool library object.
2325968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2326968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldThis mode accepts the following additional options:
2327968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2328968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
2329968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -no-suppress      do not suppress compiler output for multiple passes
2330968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -prefer-pic       try to build PIC objects only
2331968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -prefer-non-pic   try to build non-PIC objects only
2332968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -shared           do not build a \`.o' file suitable for static linking
2333968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -static           only build a \`.o' file suitable for static linking
2334968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -Wc,FLAG          pass FLAG directly to the compiler
2335968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2336968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
2337968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfrom the given SOURCEFILE.
2338968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2339968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldThe output file name is determined by removing the directory component from
2340968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldSOURCEFILE, then substituting the C source code suffix \`.c' with the
2341968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldlibrary object suffix, \`.lo'."
2342968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        ;;
2343968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2344968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      execute)
2345968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        $ECHO \
2346968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
2347968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2348968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldAutomatically set library path, then run a program.
2349968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2350968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldThis mode accepts the following additional options:
2351968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2352968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -dlopen FILE      add the directory containing FILE to the library path
2353968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2354968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldThis mode sets the library path environment variable according to \`-dlopen'
2355968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldflags.
2356968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2357968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldIf any of the ARGS are libtool executable wrappers, then they are translated
2358968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldinto their corresponding uninstalled binary, and any of their required library
2359968bf19396ad404e89420f5d67900fce13f4186cGilad Arnolddirectories are added to the library path.
2360968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2361968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldThen, COMMAND is executed, with ARGS as arguments."
2362968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        ;;
2363968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2364968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      finish)
2365968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        $ECHO \
2366968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
2367968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2368968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldComplete the installation of libtool libraries.
2369968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2370968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEach LIBDIR is a directory that contains libtool libraries.
2371968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2372968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldThe commands that this mode executes may require superuser privileges.  Use
2373968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldthe \`--dry-run' option if you just want to see what would be executed."
2374968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        ;;
2375968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2376968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      install)
2377968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        $ECHO \
2378968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
2379968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2380968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldInstall executables or libraries.
2381968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2382968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldINSTALL-COMMAND is the installation command.  The first component should be
2383968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldeither the \`install' or \`cp' program.
2384968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2385968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldThe following components of INSTALL-COMMAND are treated specially:
2386968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2387968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
2388968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2389968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldThe rest of the components are interpreted as arguments to that command (only
2390968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldBSD-compatible install options are recognized)."
2391968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        ;;
2392968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2393968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      link)
2394968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        $ECHO \
2395968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
2396968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2397968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldLink object files or libraries together to form another library, or to
2398968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldcreate an executable program.
2399968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2400968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldLINK-COMMAND is a command using the C compiler that you would use to create
2401968bf19396ad404e89420f5d67900fce13f4186cGilad Arnolda program from several object files.
2402968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2403968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldThe following components of LINK-COMMAND are treated specially:
2404968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2405968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -all-static       do not do any dynamic linking at all
2406968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -avoid-version    do not add a version suffix if possible
2407968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -bindir BINDIR    specify path to binaries directory (for systems where
2408968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold                    libraries must be found in the PATH setting at runtime)
2409968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
2410968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
2411968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
2412968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -export-symbols SYMFILE
2413968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold                    try to export only the symbols listed in SYMFILE
2414968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -export-symbols-regex REGEX
2415968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold                    try to export only the symbols matching REGEX
2416968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -LLIBDIR          search LIBDIR for required installed libraries
2417968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -lNAME            OUTPUT-FILE requires the installed library libNAME
2418968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -module           build a library that can dlopened
2419968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -no-fast-install  disable the fast-install mode
2420968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -no-install       link a not-installable executable
2421968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -no-undefined     declare that a library does not refer to external symbols
2422968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
2423968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -objectlist FILE  Use a list of object files found in FILE to specify objects
2424968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -precious-files-regex REGEX
2425968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold                    don't remove output files matching REGEX
2426968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -release RELEASE  specify package release information
2427968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
2428968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
2429968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -shared           only do dynamic linking of libtool libraries
2430968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -shrext SUFFIX    override the standard shared library file extension
2431968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -static           do not do any dynamic linking of uninstalled libtool libraries
2432968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -static-libtool-libs
2433968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold                    do not do any dynamic linking of libtool libraries
2434968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -version-info CURRENT[:REVISION[:AGE]]
2435968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold                    specify library version info [each variable defaults to 0]
2436968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -weak LIBNAME     declare that the target provides the LIBNAME interface
2437968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -Wc,FLAG
2438968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
2439968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -Wl,FLAG
2440968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
2441968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
2442968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2443968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldAll other options (arguments beginning with \`-') are ignored.
2444968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2445968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEvery other argument is treated as a filename.  Files ending in \`.la' are
2446968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldtreated as uninstalled libtool libraries, other files are standard or library
2447968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldobject files.
2448968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2449968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
2450968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldonly library objects (\`.lo' files) may be specified, and \`-rpath' is
2451968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldrequired, except when creating a convenience library.
2452968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2453968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
2454968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldusing \`ar' and \`ranlib', or on Windows using \`lib'.
2455968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2456968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
2457968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldis created, otherwise an executable program is created."
2458968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        ;;
2459968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2460968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      uninstall)
2461968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        $ECHO \
2462968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
2463968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2464968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldRemove libraries from an installation directory.
2465968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2466968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldRM is the name of the program to use to delete files associated with each FILE
2467968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2468968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldto RM.
2469968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2470968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldIf FILE is a libtool library, all the files associated with it are deleted.
2471968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldOtherwise, only FILE itself is deleted using RM."
2472968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        ;;
2473968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2474968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *)
2475968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        func_fatal_help "invalid operation mode \`$opt_mode'"
2476968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        ;;
2477968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    esac
2478968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2479968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    echo
2480968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $ECHO "Try \`$progname --help' for more information about other modes."
2481968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
2482968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2483968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Now that we've collected a possible --mode arg, show help if necessary
2484968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldif $opt_help; then
2485968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if test "$opt_help" = :; then
2486968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_mode_help
2487968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  else
2488968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    {
2489968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_help noexit
2490968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      for opt_mode in compile link execute install finish uninstall clean; do
2491968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_mode_help
2492968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      done
2493968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
2494968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    {
2495968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_help noexit
2496968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      for opt_mode in compile link execute install finish uninstall clean; do
2497968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	echo
2498968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_mode_help
2499968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      done
2500968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    } |
2501968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    sed '1d
2502968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      /^When reporting/,/^Report/{
2503968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	H
2504968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	d
2505968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      }
2506968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      $x
2507968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      /information about other modes/d
2508968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      /more detailed .*MODE/d
2509968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
2510968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  fi
2511968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  exit $?
2512968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfi
2513968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2514968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2515968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_mode_execute arg...
2516968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_mode_execute ()
2517968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
2518968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $opt_debug
2519968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # The first argument is the command name.
2520968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    cmd="$nonopt"
2521968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    test -z "$cmd" && \
2522968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_fatal_help "you must specify a COMMAND"
2523968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2524968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Handle -dlopen flags immediately.
2525968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    for file in $opt_dlopen; do
2526968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      test -f "$file" \
2527968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	|| func_fatal_help "\`$file' is not a file"
2528968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2529968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      dir=
2530968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      case $file in
2531968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *.la)
2532968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_resolve_sysroot "$file"
2533968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	file=$func_resolve_sysroot_result
2534968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2535968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Check to see that this really is a libtool archive.
2536968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_lalib_unsafe_p "$file" \
2537968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  || func_fatal_help "\`$lib' is not a valid libtool archive"
2538968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2539968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Read the libtool library.
2540968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	dlname=
2541968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	library_names=
2542968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_source "$file"
2543968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2544968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Skip this library if it cannot be dlopened.
2545968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -z "$dlname"; then
2546968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Warn if it was a shared library.
2547968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  test -n "$library_names" && \
2548968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_warning "\`$file' was not linked with \`-export-dynamic'"
2549968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
2550968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
2551968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2552968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_dirname "$file" "" "."
2553968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	dir="$func_dirname_result"
2554968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2555968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -f "$dir/$objdir/$dlname"; then
2556968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append dir "/$objdir"
2557968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	else
2558968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test ! -f "$dir/$dlname"; then
2559968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
2560968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
2561968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
2562968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
2563968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2564968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *.lo)
2565968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Just add the directory containing the .lo file.
2566968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_dirname "$file" "" "."
2567968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	dir="$func_dirname_result"
2568968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
2569968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2570968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *)
2571968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
2572968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
2573968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
2574968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      esac
2575968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2576968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Get the absolute pathname.
2577968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      absdir=`cd "$dir" && pwd`
2578968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      test -n "$absdir" && dir="$absdir"
2579968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2580968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Now add the directory to shlibpath_var.
2581968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if eval "test -z \"\$$shlibpath_var\""; then
2582968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	eval "$shlibpath_var=\"\$dir\""
2583968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      else
2584968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
2585968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
2586968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    done
2587968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2588968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # This variable tells wrapper scripts just to set shlibpath_var
2589968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # rather than running their programs.
2590968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    libtool_execute_magic="$magic"
2591968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2592968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Check if any of the arguments is a wrapper script.
2593968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    args=
2594968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    for file
2595968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    do
2596968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      case $file in
2597968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -* | *.la | *.lo ) ;;
2598968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *)
2599968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Do a test to see if this is really a libtool program.
2600968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if func_ltwrapper_script_p "$file"; then
2601968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_source "$file"
2602968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Transform arg to wrapped name.
2603968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  file="$progdir/$program"
2604968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	elif func_ltwrapper_executable_p "$file"; then
2605968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_ltwrapper_scriptname "$file"
2606968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_source "$func_ltwrapper_scriptname_result"
2607968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Transform arg to wrapped name.
2608968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  file="$progdir/$program"
2609968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
2610968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
2611968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      esac
2612968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Quote arguments (to preserve shell metacharacters).
2613968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_append_quoted args "$file"
2614968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    done
2615968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2616968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test "X$opt_dry_run" = Xfalse; then
2617968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$shlibpath_var"; then
2618968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Export the shlibpath_var.
2619968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	eval "export $shlibpath_var"
2620968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
2621968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2622968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Restore saved environment variables
2623968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
2624968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      do
2625968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	eval "if test \"\${save_$lt_var+set}\" = set; then
2626968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold                $lt_var=\$save_$lt_var; export $lt_var
2627968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      else
2628968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		$lt_unset $lt_var
2629968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi"
2630968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      done
2631968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2632968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Now prepare to actually exec the command.
2633968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      exec_cmd="\$cmd$args"
2634968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    else
2635968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Display what would be done.
2636968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$shlibpath_var"; then
2637968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
2638968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	echo "export $shlibpath_var"
2639968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
2640968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      $ECHO "$cmd$args"
2641968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      exit $EXIT_SUCCESS
2642968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
2643968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
2644968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2645968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldtest "$opt_mode" = execute && func_mode_execute ${1+"$@"}
2646968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2647968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2648968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_mode_finish arg...
2649968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_mode_finish ()
2650968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
2651968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $opt_debug
2652968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    libs=
2653968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    libdirs=
2654968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    admincmds=
2655968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2656968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    for opt in "$nonopt" ${1+"$@"}
2657968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    do
2658968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -d "$opt"; then
2659968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_append libdirs " $opt"
2660968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2661968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      elif test -f "$opt"; then
2662968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if func_lalib_unsafe_p "$opt"; then
2663968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append libs " $opt"
2664968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	else
2665968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_warning "\`$opt' is not a valid libtool archive"
2666968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
2667968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2668968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      else
2669968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_fatal_error "invalid argument \`$opt'"
2670968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
2671968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    done
2672968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2673968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test -n "$libs"; then
2674968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$lt_sysroot"; then
2675968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
2676968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
2677968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      else
2678968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        sysroot_cmd=
2679968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
2680968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2681968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Remove sysroot references
2682968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if $opt_dry_run; then
2683968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        for lib in $libs; do
2684968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
2685968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        done
2686968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      else
2687968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        tmpdir=`func_mktempdir`
2688968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        for lib in $libs; do
2689968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
2690968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    > $tmpdir/tmp-la
2691968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  mv -f $tmpdir/tmp-la $lib
2692968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	done
2693968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        ${RM}r "$tmpdir"
2694968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
2695968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
2696968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2697968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2698968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      for libdir in $libdirs; do
2699968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$finish_cmds"; then
2700968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Do each command in the finish commands.
2701968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
2702968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold'"$cmd"'"'
2703968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
2704968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$finish_eval"; then
2705968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Do the single finish_eval.
2706968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  eval cmds=\"$finish_eval\"
2707968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  $opt_dry_run || eval "$cmds" || func_append admincmds "
2708968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold       $cmds"
2709968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
2710968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      done
2711968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
2712968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2713968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Exit here if they wanted silent mode.
2714968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $opt_silent && exit $EXIT_SUCCESS
2715968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2716968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2717968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      echo "----------------------------------------------------------------------"
2718968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      echo "Libraries have been installed in:"
2719968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      for libdir in $libdirs; do
2720968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	$ECHO "   $libdir"
2721968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      done
2722968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      echo
2723968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      echo "If you ever happen to want to link against installed libraries"
2724968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      echo "in a given directory, LIBDIR, you must either use libtool, and"
2725968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
2726968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      echo "flag during linking and do at least one of the following:"
2727968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$shlibpath_var"; then
2728968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
2729968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	echo "     during execution"
2730968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
2731968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$runpath_var"; then
2732968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
2733968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	echo "     during linking"
2734968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
2735968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$hardcode_libdir_flag_spec"; then
2736968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	libdir=LIBDIR
2737968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	eval flag=\"$hardcode_libdir_flag_spec\"
2738968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2739968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	$ECHO "   - use the \`$flag' linker flag"
2740968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
2741968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$admincmds"; then
2742968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	$ECHO "   - have your system administrator run these commands:$admincmds"
2743968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
2744968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -f /etc/ld.so.conf; then
2745968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
2746968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
2747968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      echo
2748968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2749968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      echo "See any operating system documentation about shared libraries for"
2750968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      case $host in
2751968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	solaris2.[6789]|solaris2.1[0-9])
2752968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
2753968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  echo "pages."
2754968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
2755968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*)
2756968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
2757968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
2758968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      esac
2759968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      echo "----------------------------------------------------------------------"
2760968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
2761968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    exit $EXIT_SUCCESS
2762968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
2763968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2764968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldtest "$opt_mode" = finish && func_mode_finish ${1+"$@"}
2765968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2766968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2767968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_mode_install arg...
2768968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_mode_install ()
2769968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
2770968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $opt_debug
2771968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # There may be an optional sh(1) argument at the beginning of
2772968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # install_prog (especially on Windows NT).
2773968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
2774968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold       # Allow the use of GNU shtool's install command.
2775968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold       case $nonopt in *shtool*) :;; *) false;; esac; then
2776968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Aesthetically quote it.
2777968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_quote_for_eval "$nonopt"
2778968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      install_prog="$func_quote_for_eval_result "
2779968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      arg=$1
2780968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      shift
2781968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    else
2782968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      install_prog=
2783968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      arg=$nonopt
2784968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
2785968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2786968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # The real first argument should be the name of the installation program.
2787968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Aesthetically quote it.
2788968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_quote_for_eval "$arg"
2789968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_append install_prog "$func_quote_for_eval_result"
2790968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    install_shared_prog=$install_prog
2791968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    case " $install_prog " in
2792968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *[\\\ /]cp\ *) install_cp=: ;;
2793968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *) install_cp=false ;;
2794968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    esac
2795968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2796968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # We need to accept at least all the BSD install flags.
2797968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    dest=
2798968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    files=
2799968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    opts=
2800968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    prev=
2801968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    install_type=
2802968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    isdir=no
2803968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    stripme=
2804968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    no_mode=:
2805968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    for arg
2806968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    do
2807968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      arg2=
2808968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$dest"; then
2809968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_append files " $dest"
2810968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	dest=$arg
2811968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
2812968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
2813968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2814968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      case $arg in
2815968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -d) isdir=yes ;;
2816968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -f)
2817968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if $install_cp; then :; else
2818968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  prev=$arg
2819968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
2820968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
2821968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -g | -m | -o)
2822968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	prev=$arg
2823968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
2824968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -s)
2825968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	stripme=" -s"
2826968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
2827968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
2828968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -*)
2829968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
2830968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *)
2831968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# If the previous option needed an argument, then skip it.
2832968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$prev"; then
2833968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
2834968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    arg2=$install_override_mode
2835968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    no_mode=false
2836968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
2837968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  prev=
2838968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	else
2839968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  dest=$arg
2840968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
2841968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
2842968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
2843968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      esac
2844968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2845968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Aesthetically quote the argument.
2846968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_quote_for_eval "$arg"
2847968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_append install_prog " $func_quote_for_eval_result"
2848968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$arg2"; then
2849968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_quote_for_eval "$arg2"
2850968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
2851968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_append install_shared_prog " $func_quote_for_eval_result"
2852968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    done
2853968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2854968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    test -z "$install_prog" && \
2855968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_fatal_help "you must specify an install program"
2856968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2857968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    test -n "$prev" && \
2858968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_fatal_help "the \`$prev' option requires an argument"
2859968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2860968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test -n "$install_override_mode" && $no_mode; then
2861968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if $install_cp; then :; else
2862968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_quote_for_eval "$install_override_mode"
2863968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_append install_shared_prog " -m $func_quote_for_eval_result"
2864968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
2865968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
2866968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2867968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test -z "$files"; then
2868968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -z "$dest"; then
2869968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_fatal_help "no file or destination specified"
2870968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      else
2871968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_fatal_help "you must specify a destination"
2872968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
2873968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
2874968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2875968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Strip any trailing slash from the destination.
2876968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_stripname '' '/' "$dest"
2877968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    dest=$func_stripname_result
2878968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2879968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Check to see that the destination is a directory.
2880968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    test -d "$dest" && isdir=yes
2881968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test "$isdir" = yes; then
2882968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      destdir="$dest"
2883968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      destname=
2884968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    else
2885968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_dirname_and_basename "$dest" "" "."
2886968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      destdir="$func_dirname_result"
2887968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      destname="$func_basename_result"
2888968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2889968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Not a directory, so check to see that there is only one file specified.
2890968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      set dummy $files; shift
2891968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      test "$#" -gt 1 && \
2892968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_fatal_help "\`$dest' is not a directory"
2893968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
2894968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    case $destdir in
2895968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    [\\/]* | [A-Za-z]:[\\/]*) ;;
2896968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *)
2897968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      for file in $files; do
2898968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $file in
2899968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*.lo) ;;
2900968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*)
2901968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_fatal_help "\`$destdir' must be an absolute directory name"
2902968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
2903968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
2904968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      done
2905968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      ;;
2906968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    esac
2907968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2908968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # This variable tells wrapper scripts just to set variables rather
2909968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # than running their programs.
2910968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    libtool_install_magic="$magic"
2911968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2912968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    staticlibs=
2913968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    future_libdirs=
2914968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    current_libdirs=
2915968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    for file in $files; do
2916968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2917968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Do each installation.
2918968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      case $file in
2919968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *.$libext)
2920968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Do the static libraries later.
2921968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_append staticlibs " $file"
2922968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
2923968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2924968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *.la)
2925968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_resolve_sysroot "$file"
2926968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	file=$func_resolve_sysroot_result
2927968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2928968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Check to see that this really is a libtool archive.
2929968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_lalib_unsafe_p "$file" \
2930968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  || func_fatal_help "\`$file' is not a valid libtool archive"
2931968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2932968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	library_names=
2933968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	old_library=
2934968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	relink_command=
2935968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_source "$file"
2936968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2937968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Add the libdir to current_libdirs if it is the destination.
2938968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "X$destdir" = "X$libdir"; then
2939968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case "$current_libdirs " in
2940968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *" $libdir "*) ;;
2941968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *) func_append current_libdirs " $libdir" ;;
2942968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
2943968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	else
2944968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Note the libdir as a future libdir.
2945968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case "$future_libdirs " in
2946968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *" $libdir "*) ;;
2947968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *) func_append future_libdirs " $libdir" ;;
2948968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
2949968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
2950968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2951968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_dirname "$file" "/" ""
2952968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	dir="$func_dirname_result"
2953968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_append dir "$objdir"
2954968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2955968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$relink_command"; then
2956968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Determine the prefix the user has applied to our future dir.
2957968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
2958968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2959968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Don't allow the user to place us outside of our expected
2960968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # location b/c this prevents finding dependent libraries that
2961968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # are installed to the same prefix.
2962968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # At present, this check doesn't affect windows .dll's that
2963968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # are installed into $libdir/../bin (currently, that works fine)
2964968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # but it's something to keep an eye on.
2965968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  test "$inst_prefix_dir" = "$destdir" && \
2966968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2967968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2968968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -n "$inst_prefix_dir"; then
2969968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Stick the inst_prefix_dir data into the link command.
2970968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2971968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
2972968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
2973968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
2974968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2975968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_warning "relinking \`$file'"
2976968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_show_eval "$relink_command" \
2977968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2978968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
2979968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2980968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# See the names of the shared library.
2981968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	set dummy $library_names; shift
2982968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$1"; then
2983968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  realname="$1"
2984968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  shift
2985968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2986968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  srcname="$realname"
2987968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  test -n "$relink_command" && srcname="$realname"T
2988968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2989968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Install the shared library and build the symlinks.
2990968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
2991968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      'exit $?'
2992968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  tstripme="$stripme"
2993968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case $host_os in
2994968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  cygwin* | mingw* | pw32* | cegcc*)
2995968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    case $realname in
2996968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *.dll.a)
2997968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      tstripme=""
2998968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      ;;
2999968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    esac
3000968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
3001968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
3002968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -n "$tstripme" && test -n "$striplib"; then
3003968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
3004968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
3005968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3006968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$#" -gt 0; then
3007968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Delete the old symlinks, and create new ones.
3008968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Try `ln -sf' first, because the `ln' binary might depend on
3009968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
3010968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # so we also need to try rm && ln -s.
3011968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    for linkname
3012968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    do
3013968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      test "$linkname" != "$realname" \
3014968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
3015968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    done
3016968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
3017968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3018968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Do each command in the postinstall commands.
3019968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  lib="$destdir/$realname"
3020968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_execute_cmds "$postinstall_cmds" 'exit $?'
3021968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
3022968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3023968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Install the pseudo-library for information purposes.
3024968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_basename "$file"
3025968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	name="$func_basename_result"
3026968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	instname="$dir/$name"i
3027968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
3028968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3029968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Maybe install the static library, too.
3030968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
3031968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
3032968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3033968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *.lo)
3034968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Install (i.e. copy) a libtool object.
3035968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3036968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Figure out destination file name, if it wasn't already specified.
3037968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$destname"; then
3038968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  destfile="$destdir/$destname"
3039968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	else
3040968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_basename "$file"
3041968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  destfile="$func_basename_result"
3042968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  destfile="$destdir/$destfile"
3043968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
3044968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3045968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Deduce the name of the destination old-style object file.
3046968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $destfile in
3047968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*.lo)
3048968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_lo2o "$destfile"
3049968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  staticdest=$func_lo2o_result
3050968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
3051968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*.$objext)
3052968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  staticdest="$destfile"
3053968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  destfile=
3054968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
3055968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*)
3056968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
3057968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
3058968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
3059968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3060968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Install the libtool object if requested.
3061968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	test -n "$destfile" && \
3062968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_show_eval "$install_prog $file $destfile" 'exit $?'
3063968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3064968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Install the old object if enabled.
3065968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$build_old_libs" = yes; then
3066968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Deduce the name of the old-style object file.
3067968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_lo2o "$file"
3068968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  staticobj=$func_lo2o_result
3069968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
3070968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
3071968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	exit $EXIT_SUCCESS
3072968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
3073968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3074968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *)
3075968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Figure out destination file name, if it wasn't already specified.
3076968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$destname"; then
3077968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  destfile="$destdir/$destname"
3078968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	else
3079968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_basename "$file"
3080968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  destfile="$func_basename_result"
3081968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  destfile="$destdir/$destfile"
3082968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
3083968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3084968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# If the file is missing, and there is a .exe on the end, strip it
3085968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# because it is most likely a libtool script we actually want to
3086968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# install
3087968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	stripped_ext=""
3088968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $file in
3089968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *.exe)
3090968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test ! -f "$file"; then
3091968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_stripname '' '.exe' "$file"
3092968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      file=$func_stripname_result
3093968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      stripped_ext=".exe"
3094968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
3095968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
3096968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
3097968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3098968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Do a test to see if this is really a libtool program.
3099968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $host in
3100968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*cygwin* | *mingw*)
3101968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if func_ltwrapper_executable_p "$file"; then
3102968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_ltwrapper_scriptname "$file"
3103968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      wrapper=$func_ltwrapper_scriptname_result
3104968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    else
3105968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_stripname '' '.exe' "$file"
3106968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      wrapper=$func_stripname_result
3107968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
3108968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
3109968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*)
3110968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    wrapper=$file
3111968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
3112968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
3113968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if func_ltwrapper_script_p "$wrapper"; then
3114968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  notinst_deplibs=
3115968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  relink_command=
3116968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3117968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_source "$wrapper"
3118968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3119968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Check the variables that should have been set.
3120968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  test -z "$generated_by_libtool_version" && \
3121968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
3122968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3123968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  finalize=yes
3124968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  for lib in $notinst_deplibs; do
3125968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Check to see that each library is installed.
3126968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    libdir=
3127968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test -f "$lib"; then
3128968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_source "$lib"
3129968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
3130968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
3131968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test -n "$libdir" && test ! -f "$libfile"; then
3132968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_warning "\`$lib' has not been installed in \`$libdir'"
3133968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      finalize=no
3134968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
3135968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  done
3136968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3137968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  relink_command=
3138968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_source "$wrapper"
3139968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3140968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  outputname=
3141968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$fast_install" = no && test -n "$relink_command"; then
3142968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    $opt_dry_run || {
3143968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if test "$finalize" = yes; then
3144968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        tmpdir=`func_mktempdir`
3145968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_basename "$file$stripped_ext"
3146968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		file="$func_basename_result"
3147968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        outputname="$tmpdir/$file"
3148968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        # Replace the output file specification.
3149968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
3150968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3151968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        $opt_silent || {
3152968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	          func_quote_for_expand "$relink_command"
3153968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  eval "func_echo $func_quote_for_expand_result"
3154968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        }
3155968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        if eval "$relink_command"; then :
3156968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	          else
3157968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  func_error "error: relink \`$file' with the above command before installing it"
3158968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  $opt_dry_run || ${RM}r "$tmpdir"
3159968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  continue
3160968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        fi
3161968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        file="$outputname"
3162968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      else
3163968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        func_warning "cannot relink \`$file'"
3164968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
3165968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    }
3166968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
3167968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Install the binary that we compiled earlier.
3168968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
3169968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
3170968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
3171968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3172968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# remove .exe since cygwin /usr/bin/install will append another
3173968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# one anyway
3174968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $install_prog,$host in
3175968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*/usr/bin/install*,*cygwin*)
3176968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case $file:$destfile in
3177968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *.exe:*.exe)
3178968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # this is ok
3179968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
3180968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *.exe:*)
3181968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    destfile=$destfile.exe
3182968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
3183968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *:*.exe)
3184968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_stripname '' '.exe' "$destfile"
3185968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    destfile=$func_stripname_result
3186968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
3187968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
3188968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
3189968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
3190968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
3191968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	$opt_dry_run || if test -n "$outputname"; then
3192968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ${RM}r "$tmpdir"
3193968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
3194968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
3195968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      esac
3196968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    done
3197968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3198968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    for file in $staticlibs; do
3199968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_basename "$file"
3200968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      name="$func_basename_result"
3201968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3202968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Set up the ranlib parameters.
3203968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      oldlib="$destdir/$name"
3204968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3205968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
3206968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3207968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$stripme" && test -n "$old_striplib"; then
3208968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_show_eval "$old_striplib $oldlib" 'exit $?'
3209968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
3210968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3211968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Do each command in the postinstall commands.
3212968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
3213968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    done
3214968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3215968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    test -n "$future_libdirs" && \
3216968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_warning "remember to run \`$progname --finish$future_libdirs'"
3217968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3218968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test -n "$current_libdirs"; then
3219968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Maybe just do a dry run.
3220968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      $opt_dry_run && current_libdirs=" -n$current_libdirs"
3221968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
3222968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    else
3223968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      exit $EXIT_SUCCESS
3224968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
3225968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
3226968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3227968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldtest "$opt_mode" = install && func_mode_install ${1+"$@"}
3228968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3229968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3230968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_generate_dlsyms outputname originator pic_p
3231968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Extract symbols from dlprefiles and create ${outputname}S.o with
3232968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# a dlpreopen symbol table.
3233968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_generate_dlsyms ()
3234968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
3235968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $opt_debug
3236968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    my_outputname="$1"
3237968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    my_originator="$2"
3238968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    my_pic_p="${3-no}"
3239968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
3240968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    my_dlsyms=
3241968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3242968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
3243968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$NM" && test -n "$global_symbol_pipe"; then
3244968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	my_dlsyms="${my_outputname}S.c"
3245968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      else
3246968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_error "not configured to extract global symbols from dlpreopened files"
3247968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
3248968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
3249968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3250968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test -n "$my_dlsyms"; then
3251968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      case $my_dlsyms in
3252968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      "") ;;
3253968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *.c)
3254968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Discover the nlist of each of the dlfiles.
3255968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	nlist="$output_objdir/${my_outputname}.nm"
3256968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3257968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
3258968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3259968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Parse the name list into a source file.
3260968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_verbose "creating $output_objdir/$my_dlsyms"
3261968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3262968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
3263968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
3264968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
3265968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3266968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#ifdef __cplusplus
3267968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldextern \"C\" {
3268968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#endif
3269968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3270968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
3271968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
3272968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#endif
3273968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3274968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
3275968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
3276968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold/* DATA imports from DLLs on WIN32 con't be const, because runtime
3277968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold   relocations are performed -- see ld's documentation on pseudo-relocs.  */
3278968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define LT_DLSYM_CONST
3279968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#elif defined(__osf__)
3280968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold/* This system does not cope well with relocations in const data.  */
3281968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define LT_DLSYM_CONST
3282968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#else
3283968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define LT_DLSYM_CONST const
3284968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#endif
3285968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3286968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold/* External symbol declarations for the compiler. */\
3287968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold"
3288968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3289968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$dlself" = yes; then
3290968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_verbose "generating symbol list for \`$output'"
3291968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3292968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
3293968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3294968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Add our own program objects to the symbol list.
3295968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
3296968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  for progfile in $progfiles; do
3297968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
3298968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
3299968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
3300968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  done
3301968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3302968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -n "$exclude_expsyms"; then
3303968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    $opt_dry_run || {
3304968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
3305968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      eval '$MV "$nlist"T "$nlist"'
3306968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    }
3307968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
3308968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3309968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -n "$export_symbols_regex"; then
3310968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    $opt_dry_run || {
3311968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
3312968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      eval '$MV "$nlist"T "$nlist"'
3313968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    }
3314968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
3315968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3316968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Prepare the list of exported symbols
3317968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -z "$export_symbols"; then
3318968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    export_symbols="$output_objdir/$outputname.exp"
3319968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    $opt_dry_run || {
3320968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      $RM $export_symbols
3321968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
3322968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case $host in
3323968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *cygwin* | *mingw* | *cegcc* )
3324968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3325968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
3326968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        ;;
3327968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
3328968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    }
3329968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
3330968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    $opt_dry_run || {
3331968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
3332968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
3333968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      eval '$MV "$nlist"T "$nlist"'
3334968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case $host in
3335968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        *cygwin* | *mingw* | *cegcc* )
3336968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3337968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
3338968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	          ;;
3339968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
3340968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    }
3341968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
3342968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
3343968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3344968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	for dlprefile in $dlprefiles; do
3345968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_verbose "extracting global C symbols from \`$dlprefile'"
3346968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_basename "$dlprefile"
3347968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  name="$func_basename_result"
3348968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold          case $host in
3349968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *cygwin* | *mingw* | *cegcc* )
3350968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # if an import library, we need to obtain dlname
3351968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if func_win32_import_lib_p "$dlprefile"; then
3352968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        func_tr_sh "$dlprefile"
3353968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
3354968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        dlprefile_dlbasename=""
3355968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
3356968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	          # Use subshell, to avoid clobbering current variable values
3357968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
3358968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	          if test -n "$dlprefile_dlname" ; then
3359968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	            func_basename "$dlprefile_dlname"
3360968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	            dlprefile_dlbasename="$func_basename_result"
3361968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	          else
3362968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	            # no lafile. user explicitly requested -dlpreopen <import library>.
3363968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	            $sharedlib_from_linklib_cmd "$dlprefile"
3364968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	            dlprefile_dlbasename=$sharedlib_from_linklib_result
3365968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	          fi
3366968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        fi
3367968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        $opt_dry_run || {
3368968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	          if test -n "$dlprefile_dlbasename" ; then
3369968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
3370968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	          else
3371968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	            func_warning "Could not compute DLL name from $name"
3372968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	            eval '$ECHO ": $name " >> "$nlist"'
3373968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	          fi
3374968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3375968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
3376968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
3377968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        }
3378968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      else # not an import lib
3379968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        $opt_dry_run || {
3380968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	          eval '$ECHO ": $name " >> "$nlist"'
3381968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3382968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3383968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        }
3384968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
3385968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
3386968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *)
3387968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      $opt_dry_run || {
3388968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        eval '$ECHO ": $name " >> "$nlist"'
3389968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3390968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3391968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      }
3392968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
3393968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold          esac
3394968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	done
3395968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3396968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	$opt_dry_run || {
3397968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Make sure we have at least an empty file.
3398968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  test -f "$nlist" || : > "$nlist"
3399968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3400968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -n "$exclude_expsyms"; then
3401968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
3402968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    $MV "$nlist"T "$nlist"
3403968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
3404968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3405968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Try sorting and uniquifying the output.
3406968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if $GREP -v "^: " < "$nlist" |
3407968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if sort -k 3 </dev/null >/dev/null 2>&1; then
3408968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		sort -k 3
3409968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      else
3410968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		sort +2
3411968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi |
3412968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      uniq > "$nlist"S; then
3413968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    :
3414968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
3415968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    $GREP -v "^: " < "$nlist" > "$nlist"S
3416968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
3417968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3418968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -f "$nlist"S; then
3419968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
3420968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
3421968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
3422968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
3423968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3424968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  echo >> "$output_objdir/$my_dlsyms" "\
3425968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3426968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold/* The mapping between symbol names and symbols.  */
3427968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldtypedef struct {
3428968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  const char *name;
3429968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  void *address;
3430968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold} lt_dlsymlist;
3431968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldextern LT_DLSYM_CONST lt_dlsymlist
3432968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldlt_${my_prefix}_LTX_preloaded_symbols[];
3433968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldLT_DLSYM_CONST lt_dlsymlist
3434968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldlt_${my_prefix}_LTX_preloaded_symbols[] =
3435968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{\
3436968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  { \"$my_originator\", (void *) 0 },"
3437968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3438968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case $need_lib_prefix in
3439968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  no)
3440968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
3441968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
3442968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *)
3443968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
3444968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
3445968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
3446968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  echo >> "$output_objdir/$my_dlsyms" "\
3447968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  {0, (void *) 0}
3448968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold};
3449968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3450968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold/* This works around a problem in FreeBSD linker */
3451968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#ifdef FREEBSD_WORKAROUND
3452968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldstatic const void *lt_preloaded_setup() {
3453968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  return lt_${my_prefix}_LTX_preloaded_symbols;
3454968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
3455968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#endif
3456968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3457968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#ifdef __cplusplus
3458968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
3459968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#endif\
3460968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold"
3461968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	} # !$opt_dry_run
3462968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3463968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	pic_flag_for_symtable=
3464968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case "$compile_command " in
3465968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*" -static "*) ;;
3466968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*)
3467968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case $host in
3468968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # compiling the symbol table file with pic_flag works around
3469968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # a FreeBSD bug that causes programs to crash when -lm is
3470968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # linked before any other PIC object.  But we must not use
3471968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # pic_flag when linking with -static.  The problem exists in
3472968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
3473968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
3474968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
3475968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *-*-hpux*)
3476968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    pic_flag_for_symtable=" $pic_flag"  ;;
3477968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *)
3478968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "X$my_pic_p" != Xno; then
3479968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      pic_flag_for_symtable=" $pic_flag"
3480968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
3481968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
3482968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
3483968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
3484968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
3485968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	symtab_cflags=
3486968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	for arg in $LTCFLAGS; do
3487968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case $arg in
3488968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  -pie | -fpie | -fPIE) ;;
3489968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *) func_append symtab_cflags " $arg" ;;
3490968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
3491968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	done
3492968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3493968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Now compile the dynamic symbol file.
3494968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
3495968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3496968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Clean up the generated files.
3497968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
3498968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3499968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Transform the symbol file into the correct name.
3500968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	symfileobj="$output_objdir/${my_outputname}S.$objext"
3501968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $host in
3502968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*cygwin* | *mingw* | *cegcc* )
3503968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -f "$output_objdir/$my_outputname.def"; then
3504968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3505968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3506968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
3507968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3508968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3509968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
3510968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
3511968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*)
3512968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3513968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3514968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
3515968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
3516968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
3517968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *)
3518968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_fatal_error "unknown suffix for \`$my_dlsyms'"
3519968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
3520968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      esac
3521968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    else
3522968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # We keep going just in case the user didn't refer to
3523968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
3524968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # really was required.
3525968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3526968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Nullify the symbol file.
3527968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
3528968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
3529968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
3530968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
3531968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3532968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_win32_libid arg
3533968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# return the library type of file 'arg'
3534968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
3535968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Need a lot of goo to handle *both* DLLs and import libs
3536968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Has to be a shell function in order to 'eat' the argument
3537968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# that is supplied when $file_magic_command is called.
3538968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Despite the name, also deal with 64 bit binaries.
3539968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_win32_libid ()
3540968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
3541968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $opt_debug
3542968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  win32_libid_type="unknown"
3543968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  win32_fileres=`file -L $1 2>/dev/null`
3544968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  case $win32_fileres in
3545968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  *ar\ archive\ import\ library*) # definitely import
3546968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    win32_libid_type="x86 archive import"
3547968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    ;;
3548968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  *ar\ archive*) # could be an import, or static
3549968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
3550968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
3551968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
3552968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_to_tool_file "$1" func_convert_file_msys_to_w32
3553968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
3554968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	$SED -n -e '
3555968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    1,100{
3556968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		/ I /{
3557968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    s,.*,import,
3558968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    p
3559968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    q
3560968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		}
3561968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    }'`
3562968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      case $win32_nmres in
3563968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      import*)  win32_libid_type="x86 archive import";;
3564968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *)        win32_libid_type="x86 archive static";;
3565968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      esac
3566968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
3567968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    ;;
3568968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  *DLL*)
3569968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    win32_libid_type="x86 DLL"
3570968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    ;;
3571968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  *executable*) # but shell scripts are "executable" too...
3572968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    case $win32_fileres in
3573968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *MS\ Windows\ PE\ Intel*)
3574968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      win32_libid_type="x86 DLL"
3575968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      ;;
3576968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    esac
3577968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    ;;
3578968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  esac
3579968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $ECHO "$win32_libid_type"
3580968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
3581968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3582968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_cygming_dll_for_implib ARG
3583968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
3584968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Platform-specific function to extract the
3585968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# name of the DLL associated with the specified
3586968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# import library ARG.
3587968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Invoked by eval'ing the libtool variable
3588968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#    $sharedlib_from_linklib_cmd
3589968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Result is available in the variable
3590968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#    $sharedlib_from_linklib_result
3591968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_cygming_dll_for_implib ()
3592968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
3593968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $opt_debug
3594968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
3595968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
3596968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3597968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
3598968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
3599968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# The is the core of a fallback implementation of a
3600968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# platform-specific function to extract the name of the
3601968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# DLL associated with the specified import library LIBNAME.
3602968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
3603968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# SECTION_NAME is either .idata$6 or .idata$7, depending
3604968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# on the platform and compiler that created the implib.
3605968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
3606968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Echos the name of the DLL associated with the
3607968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# specified import library.
3608968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_cygming_dll_for_implib_fallback_core ()
3609968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
3610968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $opt_debug
3611968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
3612968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
3613968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $SED '/^Contents of section '"$match_literal"':/{
3614968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Place marker at beginning of archive member dllname section
3615968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      s/.*/====MARK====/
3616968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      p
3617968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      d
3618968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    }
3619968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # These lines can sometimes be longer than 43 characters, but
3620968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # are always uninteresting
3621968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    /:[	 ]*file format pe[i]\{,1\}-/d
3622968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    /^In archive [^:]*:/d
3623968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Ensure marker is printed
3624968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    /^====MARK====/p
3625968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Remove all lines with less than 43 characters
3626968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    /^.\{43\}/!d
3627968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # From remaining lines, remove first 43 characters
3628968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    s/^.\{43\}//' |
3629968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $SED -n '
3630968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Join marker and all lines until next marker into a single line
3631968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      /^====MARK====/ b para
3632968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      H
3633968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      $ b para
3634968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      b
3635968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      :para
3636968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      x
3637968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      s/\n//g
3638968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Remove the marker
3639968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      s/^====MARK====//
3640968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Remove trailing dots and whitespace
3641968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      s/[\. \t]*$//
3642968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Print
3643968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      /./p' |
3644968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # we now have a list, one entry per line, of the stringified
3645968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # contents of the appropriate section of all members of the
3646968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # archive which possess that section. Heuristic: eliminate
3647968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # all those which have a first or second character that is
3648968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # a '.' (that is, objdump's representation of an unprintable
3649968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # character.) This should work for all archives with less than
3650968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # 0x302f exports -- but will fail for DLLs whose name actually
3651968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # begins with a literal '.' or a single character followed by
3652968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # a '.'.
3653968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    #
3654968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Of those that remain, print the first one.
3655968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $SED -e '/^\./d;/^.\./d;q'
3656968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
3657968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3658968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_cygming_gnu_implib_p ARG
3659968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# This predicate returns with zero status (TRUE) if
3660968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# ARG is a GNU/binutils-style import library. Returns
3661968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# with nonzero status (FALSE) otherwise.
3662968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_cygming_gnu_implib_p ()
3663968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
3664968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $opt_debug
3665968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_to_tool_file "$1" func_convert_file_msys_to_w32
3666968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`
3667968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  test -n "$func_cygming_gnu_implib_tmp"
3668968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
3669968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3670968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_cygming_ms_implib_p ARG
3671968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# This predicate returns with zero status (TRUE) if
3672968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# ARG is an MS-style import library. Returns
3673968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# with nonzero status (FALSE) otherwise.
3674968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_cygming_ms_implib_p ()
3675968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
3676968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $opt_debug
3677968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_to_tool_file "$1" func_convert_file_msys_to_w32
3678968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
3679968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  test -n "$func_cygming_ms_implib_tmp"
3680968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
3681968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3682968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_cygming_dll_for_implib_fallback ARG
3683968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Platform-specific function to extract the
3684968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# name of the DLL associated with the specified
3685968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# import library ARG.
3686968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
3687968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# This fallback implementation is for use when $DLLTOOL
3688968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# does not support the --identify-strict option.
3689968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Invoked by eval'ing the libtool variable
3690968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#    $sharedlib_from_linklib_cmd
3691968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Result is available in the variable
3692968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#    $sharedlib_from_linklib_result
3693968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_cygming_dll_for_implib_fallback ()
3694968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
3695968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $opt_debug
3696968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if func_cygming_gnu_implib_p "$1" ; then
3697968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # binutils import library
3698968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
3699968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  elif func_cygming_ms_implib_p "$1" ; then
3700968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # ms-generated import library
3701968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
3702968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  else
3703968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # unknown
3704968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    sharedlib_from_linklib_result=""
3705968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  fi
3706968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
3707968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3708968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3709968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_extract_an_archive dir oldlib
3710968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_extract_an_archive ()
3711968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
3712968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $opt_debug
3713968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    f_ex_an_ar_dir="$1"; shift
3714968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    f_ex_an_ar_oldlib="$1"
3715968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test "$lock_old_archive_extraction" = yes; then
3716968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      lockfile=$f_ex_an_ar_oldlib.lock
3717968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
3718968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_echo "Waiting for $lockfile to be removed"
3719968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	sleep 2
3720968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      done
3721968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
3722968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
3723968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		   'stat=$?; rm -f "$lockfile"; exit $stat'
3724968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test "$lock_old_archive_extraction" = yes; then
3725968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      $opt_dry_run || rm -f "$lockfile"
3726968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
3727968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
3728968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     :
3729968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    else
3730968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
3731968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
3732968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
3733968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3734968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3735968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_extract_archives gentop oldlib ...
3736968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_extract_archives ()
3737968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
3738968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $opt_debug
3739968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    my_gentop="$1"; shift
3740968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    my_oldlibs=${1+"$@"}
3741968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    my_oldobjs=""
3742968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    my_xlib=""
3743968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    my_xabs=""
3744968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    my_xdir=""
3745968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3746968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    for my_xlib in $my_oldlibs; do
3747968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Extract the objects.
3748968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      case $my_xlib in
3749968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
3750968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*) my_xabs=`pwd`"/$my_xlib" ;;
3751968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      esac
3752968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_basename "$my_xlib"
3753968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      my_xlib="$func_basename_result"
3754968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      my_xlib_u=$my_xlib
3755968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      while :; do
3756968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        case " $extracted_archives " in
3757968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*" $my_xlib_u "*)
3758968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_arith $extracted_serial + 1
3759968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  extracted_serial=$func_arith_result
3760968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
3761968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*) break ;;
3762968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
3763968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      done
3764968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      extracted_archives="$extracted_archives $my_xlib_u"
3765968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      my_xdir="$my_gentop/$my_xlib_u"
3766968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3767968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_mkdir_p "$my_xdir"
3768968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3769968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      case $host in
3770968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *-darwin*)
3771968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_verbose "Extracting $my_xabs"
3772968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Do not bother doing anything if just a dry run
3773968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	$opt_dry_run || {
3774968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  darwin_orig_dir=`pwd`
3775968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  cd $my_xdir || exit $?
3776968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  darwin_archive=$my_xabs
3777968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  darwin_curdir=`pwd`
3778968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  darwin_base_archive=`basename "$darwin_archive"`
3779968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
3780968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -n "$darwin_arches"; then
3781968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
3782968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    darwin_arch=
3783968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
3784968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    for darwin_arch in  $darwin_arches ; do
3785968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3786968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
3787968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3788968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
3789968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      cd "$darwin_curdir"
3790968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
3791968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    done # $darwin_arches
3792968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
3793968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
3794968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    darwin_file=
3795968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    darwin_files=
3796968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    for darwin_file in $darwin_filelist; do
3797968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
3798968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      $LIPO -create -output "$darwin_file" $darwin_files
3799968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    done # $darwin_filelist
3800968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    $RM -rf unfat-$$
3801968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    cd "$darwin_orig_dir"
3802968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
3803968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    cd $darwin_orig_dir
3804968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_extract_an_archive "$my_xdir" "$my_xabs"
3805968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi # $darwin_arches
3806968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	} # !$opt_dry_run
3807968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
3808968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *)
3809968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        func_extract_an_archive "$my_xdir" "$my_xabs"
3810968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
3811968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      esac
3812968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
3813968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    done
3814968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3815968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_extract_archives_result="$my_oldobjs"
3816968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
3817968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3818968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3819968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_emit_wrapper [arg=no]
3820968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
3821968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Emit a libtool wrapper script on stdout.
3822968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Don't directly open a file because we may want to
3823968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# incorporate the script contents within a cygwin/mingw
3824968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# wrapper executable.  Must ONLY be called from within
3825968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_mode_link because it depends on a number of variables
3826968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# set therein.
3827968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
3828968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
3829968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# variable will take.  If 'yes', then the emitted script
3830968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# will assume that the directory in which it is stored is
3831968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# the $objdir directory.  This is a cygwin/mingw-specific
3832968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# behavior.
3833968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_emit_wrapper ()
3834968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
3835968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_emit_wrapper_arg1=${1-no}
3836968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3837968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	$ECHO "\
3838968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#! $SHELL
3839968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3840968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# $output - temporary wrapper script for $objdir/$outputname
3841968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
3842968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
3843968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# The $output program cannot be directly executed until all the libtool
3844968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# libraries that it depends on are installed.
3845968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
3846968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# This wrapper script should never be moved out of the build directory.
3847968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# If it is, it will not operate correctly.
3848968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3849968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Sed substitution that helps us do robust quoting.  It backslashifies
3850968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# metacharacters that are still active within double-quoted strings.
3851968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldsed_quote_subst='$sed_quote_subst'
3852968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3853968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Be Bourne compatible
3854968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
3855968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  emulate sh
3856968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  NULLCMD=:
3857968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
3858968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # is contrary to our usage.  Disable this feature.
3859968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  alias -g '\${1+\"\$@\"}'='\"\$@\"'
3860968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  setopt NO_GLOB_SUBST
3861968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldelse
3862968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
3863968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfi
3864968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldBIN_SH=xpg4; export BIN_SH # for Tru64
3865968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldDUALCASE=1; export DUALCASE # for MKS sh
3866968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3867968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# The HP-UX ksh and POSIX shell print the target directory to stdout
3868968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# if CDPATH is set.
3869968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
3870968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3871968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldrelink_command=\"$relink_command\"
3872968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3873968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# This environment variable determines our operation mode.
3874968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldif test \"\$libtool_install_magic\" = \"$magic\"; then
3875968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # install mode needs the following variables:
3876968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  generated_by_libtool_version='$macro_version'
3877968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  notinst_deplibs='$notinst_deplibs'
3878968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldelse
3879968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # When we are sourced in execute mode, \$file and \$ECHO are already set.
3880968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if test \"\$libtool_execute_magic\" != \"$magic\"; then
3881968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    file=\"\$0\""
3882968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3883968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
3884968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $ECHO "\
3885968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3886968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# A function that is used when there is no print builtin or printf.
3887968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_fallback_echo ()
3888968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
3889968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  eval 'cat <<_LTECHO_EOF
3890968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold\$1
3891968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold_LTECHO_EOF'
3892968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
3893968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    ECHO=\"$qECHO\"
3894968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  fi
3895968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3896968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Very basic option parsing. These options are (a) specific to
3897968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# the libtool wrapper, (b) are identical between the wrapper
3898968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# /script/ and the wrapper /executable/ which is used only on
3899968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# windows platforms, and (c) all begin with the string "--lt-"
3900968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# (application programs are unlikely to have options which match
3901968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# this pattern).
3902968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
3903968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# There are only two supported options: --lt-debug and
3904968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# --lt-dump-script. There is, deliberately, no --lt-help.
3905968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
3906968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# The first argument to this parsing function should be the
3907968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# script's $0 value, followed by "$@".
3908968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldlt_option_debug=
3909968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_parse_lt_options ()
3910968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
3911968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  lt_script_arg0=\$0
3912968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  shift
3913968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  for lt_opt
3914968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  do
3915968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    case \"\$lt_opt\" in
3916968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    --lt-debug) lt_option_debug=1 ;;
3917968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    --lt-dump-script)
3918968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
3919968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
3920968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
3921968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        cat \"\$lt_dump_D/\$lt_dump_F\"
3922968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        exit 0
3923968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      ;;
3924968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    --lt-*)
3925968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
3926968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        exit 1
3927968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      ;;
3928968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    esac
3929968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  done
3930968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3931968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # Print the debug banner immediately:
3932968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if test -n \"\$lt_option_debug\"; then
3933968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
3934968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  fi
3935968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
3936968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3937968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Used when --lt-debug. Prints its arguments to stdout
3938968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# (redirection is the responsibility of the caller)
3939968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_lt_dump_args ()
3940968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
3941968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  lt_dump_args_N=1;
3942968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  for lt_arg
3943968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  do
3944968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
3945968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
3946968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  done
3947968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
3948968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3949968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Core function for launching the target application
3950968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_exec_program_core ()
3951968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
3952968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold"
3953968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  case $host in
3954968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # Backslashes separate directories on plain windows
3955968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  *-*-mingw | *-*-os2* | *-cegcc*)
3956968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $ECHO "\
3957968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n \"\$lt_option_debug\"; then
3958968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
3959968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        func_lt_dump_args \${1+\"\$@\"} 1>&2
3960968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
3961968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
3962968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold"
3963968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    ;;
3964968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3965968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  *)
3966968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $ECHO "\
3967968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n \"\$lt_option_debug\"; then
3968968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
3969968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        func_lt_dump_args \${1+\"\$@\"} 1>&2
3970968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
3971968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      exec \"\$progdir/\$program\" \${1+\"\$@\"}
3972968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold"
3973968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    ;;
3974968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  esac
3975968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  $ECHO "\
3976968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
3977968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      exit 1
3978968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
3979968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3980968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# A function to encapsulate launching the target application
3981968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Strips options in the --lt-* namespace from \$@ and
3982968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# launches target application with the remaining arguments.
3983968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_exec_program ()
3984968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
3985968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  for lt_wr_arg
3986968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  do
3987968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    case \$lt_wr_arg in
3988968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    --lt-*) ;;
3989968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
3990968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    esac
3991968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    shift
3992968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  done
3993968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_exec_program_core \${1+\"\$@\"}
3994968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
3995968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3996968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # Parse options
3997968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
3998968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
3999968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # Find the directory that this script lives in.
4000968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
4001968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
4002968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4003968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # Follow symbolic links until we get to the real thisdir.
4004968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
4005968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  while test -n \"\$file\"; do
4006968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
4007968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4008968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # If there was a directory component, then change thisdir.
4009968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test \"x\$destdir\" != \"x\$file\"; then
4010968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      case \"\$destdir\" in
4011968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
4012968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *) thisdir=\"\$thisdir/\$destdir\" ;;
4013968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      esac
4014968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
4015968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4016968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
4017968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
4018968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  done
4019968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4020968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # Usually 'no', except on cygwin/mingw when embedded into
4021968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # the cwrapper.
4022968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
4023968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
4024968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # special case for '.'
4025968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test \"\$thisdir\" = \".\"; then
4026968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      thisdir=\`pwd\`
4027968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
4028968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # remove .libs from thisdir
4029968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    case \"\$thisdir\" in
4030968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
4031968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $objdir )   thisdir=. ;;
4032968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    esac
4033968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  fi
4034968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4035968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  # Try to get the absolute directory name.
4036968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  absdir=\`cd \"\$thisdir\" && pwd\`
4037968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  test -n \"\$absdir\" && thisdir=\"\$absdir\"
4038968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold"
4039968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4040968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$fast_install" = yes; then
4041968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  $ECHO "\
4042968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  program=lt-'$outputname'$exeext
4043968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  progdir=\"\$thisdir/$objdir\"
4044968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4045968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if test ! -f \"\$progdir/\$program\" ||
4046968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
4047968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
4048968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4049968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    file=\"\$\$-\$program\"
4050968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4051968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test ! -d \"\$progdir\"; then
4052968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      $MKDIR \"\$progdir\"
4053968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    else
4054968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      $RM \"\$progdir/\$file\"
4055968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi"
4056968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4057968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  $ECHO "\
4058968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4059968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # relink executable if necessary
4060968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test -n \"\$relink_command\"; then
4061968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
4062968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      else
4063968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	$ECHO \"\$relink_command_output\" >&2
4064968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	$RM \"\$progdir/\$file\"
4065968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	exit 1
4066968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
4067968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
4068968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4069968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
4070968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    { $RM \"\$progdir/\$program\";
4071968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
4072968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $RM \"\$progdir/\$file\"
4073968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  fi"
4074968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	else
4075968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  $ECHO "\
4076968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  program='$outputname'
4077968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  progdir=\"\$thisdir/$objdir\"
4078968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold"
4079968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
4080968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4081968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	$ECHO "\
4082968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4083968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if test -f \"\$progdir/\$program\"; then"
4084968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4085968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# fixup the dll searchpath if we need to.
4086968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	#
4087968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Fix the DLL searchpath if we need to.  Do this before prepending
4088968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# to shlibpath, because on Windows, both are PATH and uninstalled
4089968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# libraries must come first.
4090968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$dllsearchpath"; then
4091968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  $ECHO "\
4092968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Add the dll search path components to the executable PATH
4093968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    PATH=$dllsearchpath:\$PATH
4094968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold"
4095968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
4096968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4097968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Export our shlibpath_var if we have one.
4098968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4099968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  $ECHO "\
4100968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Add our own library path to $shlibpath_var
4101968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
4102968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4103968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Some systems cannot cope with colon-terminated $shlibpath_var
4104968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # The second colon is a workaround for a bug in BeOS R4 sed
4105968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
4106968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4107968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    export $shlibpath_var
4108968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold"
4109968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
4110968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4111968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	$ECHO "\
4112968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test \"\$libtool_execute_magic\" != \"$magic\"; then
4113968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Run the actual program with our arguments.
4114968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_exec_program \${1+\"\$@\"}
4115968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
4116968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  else
4117968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # The program doesn't exist.
4118968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
4119968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
4120968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
4121968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    exit 1
4122968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  fi
4123968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfi\
4124968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold"
4125968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
4126968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4127968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4128968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_emit_cwrapperexe_src
4129968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# emit the source code for a wrapper executable on stdout
4130968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Must ONLY be called from within func_mode_link because
4131968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# it depends on a number of variable set therein.
4132968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_emit_cwrapperexe_src ()
4133968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
4134968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	cat <<EOF
4135968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4136968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
4137968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
4138968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4139968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold   The $output program cannot be directly executed until all the libtool
4140968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold   libraries that it depends on are installed.
4141968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4142968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold   This wrapper executable should never be moved out of the build directory.
4143968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold   If it is, it will not operate correctly.
4144968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold*/
4145968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEOF
4146968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    cat <<"EOF"
4147968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#ifdef _MSC_VER
4148968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define _CRT_SECURE_NO_DEPRECATE 1
4149968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#endif
4150968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#include <stdio.h>
4151968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#include <stdlib.h>
4152968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#ifdef _MSC_VER
4153968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# include <direct.h>
4154968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# include <process.h>
4155968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# include <io.h>
4156968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#else
4157968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# include <unistd.h>
4158968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# include <stdint.h>
4159968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# ifdef __CYGWIN__
4160968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#  include <io.h>
4161968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# endif
4162968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#endif
4163968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#include <malloc.h>
4164968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#include <stdarg.h>
4165968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#include <assert.h>
4166968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#include <string.h>
4167968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#include <ctype.h>
4168968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#include <errno.h>
4169968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#include <fcntl.h>
4170968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#include <sys/stat.h>
4171968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4172968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold/* declarations of non-ANSI functions */
4173968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#if defined(__MINGW32__)
4174968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# ifdef __STRICT_ANSI__
4175968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldint _putenv (const char *);
4176968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# endif
4177968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#elif defined(__CYGWIN__)
4178968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# ifdef __STRICT_ANSI__
4179968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldchar *realpath (const char *, char *);
4180968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldint putenv (char *);
4181968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldint setenv (const char *, const char *, int);
4182968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# endif
4183968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold/* #elif defined (other platforms) ... */
4184968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#endif
4185968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4186968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold/* portability defines, excluding path handling macros */
4187968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#if defined(_MSC_VER)
4188968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define setmode _setmode
4189968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define stat    _stat
4190968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define chmod   _chmod
4191968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define getcwd  _getcwd
4192968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define putenv  _putenv
4193968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define S_IXUSR _S_IEXEC
4194968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# ifndef _INTPTR_T_DEFINED
4195968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#  define _INTPTR_T_DEFINED
4196968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#  define intptr_t int
4197968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# endif
4198968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#elif defined(__MINGW32__)
4199968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define setmode _setmode
4200968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define stat    _stat
4201968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define chmod   _chmod
4202968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define getcwd  _getcwd
4203968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define putenv  _putenv
4204968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#elif defined(__CYGWIN__)
4205968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define HAVE_SETENV
4206968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define FOPEN_WB "wb"
4207968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold/* #elif defined (other platforms) ... */
4208968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#endif
4209968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4210968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#if defined(PATH_MAX)
4211968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define LT_PATHMAX PATH_MAX
4212968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#elif defined(MAXPATHLEN)
4213968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define LT_PATHMAX MAXPATHLEN
4214968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#else
4215968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define LT_PATHMAX 1024
4216968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#endif
4217968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4218968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#ifndef S_IXOTH
4219968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define S_IXOTH 0
4220968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#endif
4221968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#ifndef S_IXGRP
4222968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define S_IXGRP 0
4223968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#endif
4224968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4225968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold/* path handling portability macros */
4226968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#ifndef DIR_SEPARATOR
4227968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define DIR_SEPARATOR '/'
4228968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define PATH_SEPARATOR ':'
4229968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#endif
4230968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4231968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
4232968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  defined (__OS2__)
4233968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define HAVE_DOS_BASED_FILE_SYSTEM
4234968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define FOPEN_WB "wb"
4235968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# ifndef DIR_SEPARATOR_2
4236968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#  define DIR_SEPARATOR_2 '\\'
4237968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# endif
4238968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# ifndef PATH_SEPARATOR_2
4239968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#  define PATH_SEPARATOR_2 ';'
4240968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# endif
4241968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#endif
4242968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4243968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#ifndef DIR_SEPARATOR_2
4244968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
4245968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#else /* DIR_SEPARATOR_2 */
4246968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define IS_DIR_SEPARATOR(ch) \
4247968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4248968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#endif /* DIR_SEPARATOR_2 */
4249968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4250968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#ifndef PATH_SEPARATOR_2
4251968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
4252968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#else /* PATH_SEPARATOR_2 */
4253968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
4254968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#endif /* PATH_SEPARATOR_2 */
4255968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4256968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#ifndef FOPEN_WB
4257968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define FOPEN_WB "w"
4258968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#endif
4259968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#ifndef _O_BINARY
4260968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# define _O_BINARY 0
4261968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#endif
4262968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4263968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
4264968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#define XFREE(stale) do { \
4265968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if (stale) { free ((void *) stale); stale = 0; } \
4266968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold} while (0)
4267968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4268968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#if defined(LT_DEBUGWRAPPER)
4269968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldstatic int lt_debug = 1;
4270968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#else
4271968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldstatic int lt_debug = 0;
4272968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#endif
4273968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4274968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
4275968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4276968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldvoid *xmalloc (size_t num);
4277968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldchar *xstrdup (const char *string);
4278968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldconst char *base_name (const char *name);
4279968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldchar *find_executable (const char *wrapper);
4280968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldchar *chase_symlinks (const char *pathspec);
4281968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldint make_executable (const char *path);
4282968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldint check_executable (const char *path);
4283968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldchar *strendzap (char *str, const char *pat);
4284968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
4285968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldvoid lt_fatal (const char *file, int line, const char *message, ...);
4286968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldstatic const char *nonnull (const char *s);
4287968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldstatic const char *nonempty (const char *s);
4288968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldvoid lt_setenv (const char *name, const char *value);
4289968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
4290968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldvoid lt_update_exe_path (const char *name, const char *value);
4291968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldvoid lt_update_lib_path (const char *name, const char *value);
4292968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldchar **prepare_spawn (char **argv);
4293968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldvoid lt_dump_script (FILE *f);
4294968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEOF
4295968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4296968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    cat <<EOF
4297968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldvolatile const char * MAGIC_EXE = "$magic_exe";
4298968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldconst char * LIB_PATH_VARNAME = "$shlibpath_var";
4299968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEOF
4300968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4301968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4302968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold              func_to_host_path "$temp_rpath"
4303968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      cat <<EOF
4304968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
4305968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEOF
4306968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    else
4307968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      cat <<"EOF"
4308968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldconst char * LIB_PATH_VALUE   = "";
4309968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEOF
4310968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
4311968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4312968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test -n "$dllsearchpath"; then
4313968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold              func_to_host_path "$dllsearchpath:"
4314968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      cat <<EOF
4315968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldconst char * EXE_PATH_VARNAME = "PATH";
4316968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
4317968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEOF
4318968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    else
4319968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      cat <<"EOF"
4320968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldconst char * EXE_PATH_VARNAME = "";
4321968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldconst char * EXE_PATH_VALUE   = "";
4322968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEOF
4323968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
4324968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4325968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "$fast_install" = yes; then
4326968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      cat <<EOF
4327968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
4328968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEOF
4329968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    else
4330968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      cat <<EOF
4331968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
4332968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEOF
4333968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
4334968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4335968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4336968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    cat <<"EOF"
4337968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4338968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#define LTWRAPPER_OPTION_PREFIX         "--lt-"
4339968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4340968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
4341968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
4342968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
4343968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4344968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldint
4345968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldmain (int argc, char *argv[])
4346968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
4347968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  char **newargz;
4348968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  int  newargc;
4349968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  char *tmp_pathspec;
4350968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  char *actual_cwrapper_path;
4351968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  char *actual_cwrapper_name;
4352968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  char *target_name;
4353968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  char *lt_argv_zero;
4354968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  intptr_t rval = 127;
4355968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4356968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  int i;
4357968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4358968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  program_name = (char *) xstrdup (base_name (argv[0]));
4359968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  newargz = XMALLOC (char *, argc + 1);
4360968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4361968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  /* very simple arg parsing; don't want to rely on getopt
4362968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold   * also, copy all non cwrapper options to newargz, except
4363968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold   * argz[0], which is handled differently
4364968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold   */
4365968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  newargc=0;
4366968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  for (i = 1; i < argc; i++)
4367968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    {
4368968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if (strcmp (argv[i], dumpscript_opt) == 0)
4369968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	{
4370968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEOF
4371968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    case "$host" in
4372968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *mingw* | *cygwin* )
4373968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		# make stdout use "unix" line endings
4374968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		echo "          setmode(1,_O_BINARY);"
4375968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		;;
4376968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
4377968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4378968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    cat <<"EOF"
4379968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  lt_dump_script (stdout);
4380968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  return 0;
4381968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	}
4382968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if (strcmp (argv[i], debug_opt) == 0)
4383968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	{
4384968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold          lt_debug = 1;
4385968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold          continue;
4386968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	}
4387968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
4388968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        {
4389968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
4390968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold             namespace, but it is not one of the ones we know about and
4391968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold             have already dealt with, above (inluding dump-script), then
4392968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold             report an error. Otherwise, targets might begin to believe
4393968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
4394968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold             namespace. The first time any user complains about this, we'll
4395968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
4396968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold             or a configure.ac-settable value.
4397968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold           */
4398968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold          lt_fatal (__FILE__, __LINE__,
4399968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    "unrecognized %s option: '%s'",
4400968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold                    ltwrapper_option_prefix, argv[i]);
4401968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        }
4402968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      /* otherwise ... */
4403968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      newargz[++newargc] = xstrdup (argv[i]);
4404968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    }
4405968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  newargz[++newargc] = NULL;
4406968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4407968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEOF
4408968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    cat <<EOF
4409968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  /* The GNU banner must be the first non-error debug message */
4410968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
4411968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEOF
4412968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    cat <<"EOF"
4413968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
4414968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
4415968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4416968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  tmp_pathspec = find_executable (argv[0]);
4417968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if (tmp_pathspec == NULL)
4418968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
4419968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  lt_debugprintf (__FILE__, __LINE__,
4420968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold                  "(main) found exe (before symlink chase) at: %s\n",
4421968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  tmp_pathspec);
4422968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4423968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
4424968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  lt_debugprintf (__FILE__, __LINE__,
4425968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold                  "(main) found exe (after symlink chase) at: %s\n",
4426968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  actual_cwrapper_path);
4427968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  XFREE (tmp_pathspec);
4428968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4429968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
4430968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  strendzap (actual_cwrapper_path, actual_cwrapper_name);
4431968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4432968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  /* wrapper name transforms */
4433968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  strendzap (actual_cwrapper_name, ".exe");
4434968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
4435968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  XFREE (actual_cwrapper_name);
4436968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  actual_cwrapper_name = tmp_pathspec;
4437968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  tmp_pathspec = 0;
4438968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4439968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  /* target_name transforms -- use actual target program name; might have lt- prefix */
4440968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
4441968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  strendzap (target_name, ".exe");
4442968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
4443968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  XFREE (target_name);
4444968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  target_name = tmp_pathspec;
4445968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  tmp_pathspec = 0;
4446968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4447968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  lt_debugprintf (__FILE__, __LINE__,
4448968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  "(main) libtool target name: %s\n",
4449968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  target_name);
4450968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEOF
4451968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4452968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    cat <<EOF
4453968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  newargz[0] =
4454968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    XMALLOC (char, (strlen (actual_cwrapper_path) +
4455968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
4456968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  strcpy (newargz[0], actual_cwrapper_path);
4457968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  strcat (newargz[0], "$objdir");
4458968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  strcat (newargz[0], "/");
4459968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEOF
4460968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4461968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    cat <<"EOF"
4462968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  /* stop here, and copy so we don't have to do this twice */
4463968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  tmp_pathspec = xstrdup (newargz[0]);
4464968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4465968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
4466968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  strcat (newargz[0], actual_cwrapper_name);
4467968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4468968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  /* DO want the lt- prefix here if it exists, so use target_name */
4469968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
4470968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  XFREE (tmp_pathspec);
4471968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  tmp_pathspec = NULL;
4472968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEOF
4473968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4474968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    case $host_os in
4475968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      mingw*)
4476968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    cat <<"EOF"
4477968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  {
4478968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    char* p;
4479968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    while ((p = strchr (newargz[0], '\\')) != NULL)
4480968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      {
4481968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*p = '/';
4482968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      }
4483968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
4484968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      {
4485968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*p = '/';
4486968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      }
4487968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  }
4488968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEOF
4489968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
4490968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    esac
4491968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4492968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    cat <<"EOF"
4493968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  XFREE (target_name);
4494968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  XFREE (actual_cwrapper_path);
4495968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  XFREE (actual_cwrapper_name);
4496968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4497968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
4498968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
4499968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
4500968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
4501968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     because on Windows, both *_VARNAMEs are PATH but uninstalled
4502968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     libraries must come first. */
4503968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
4504968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
4505968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4506968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
4507968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  nonnull (lt_argv_zero));
4508968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  for (i = 0; i < newargc; i++)
4509968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    {
4510968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
4511968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      i, nonnull (newargz[i]));
4512968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    }
4513968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4514968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEOF
4515968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4516968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    case $host_os in
4517968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      mingw*)
4518968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		cat <<"EOF"
4519968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  /* execv doesn't actually work on mingw as expected on unix */
4520968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  newargz = prepare_spawn (newargz);
4521968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
4522968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if (rval == -1)
4523968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    {
4524968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      /* failed to start process */
4525968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      lt_debugprintf (__FILE__, __LINE__,
4526968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      "(main) failed to launch target \"%s\": %s\n",
4527968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      lt_argv_zero, nonnull (strerror (errno)));
4528968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      return 127;
4529968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    }
4530968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  return rval;
4531968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEOF
4532968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		;;
4533968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *)
4534968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		cat <<"EOF"
4535968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  execv (lt_argv_zero, newargz);
4536968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  return rval; /* =127, but avoids unused variable warning */
4537968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEOF
4538968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		;;
4539968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    esac
4540968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4541968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    cat <<"EOF"
4542968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
4543968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4544968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldvoid *
4545968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldxmalloc (size_t num)
4546968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
4547968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  void *p = (void *) malloc (num);
4548968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if (!p)
4549968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    lt_fatal (__FILE__, __LINE__, "memory exhausted");
4550968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4551968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  return p;
4552968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
4553968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4554968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldchar *
4555968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldxstrdup (const char *string)
4556968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
4557968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
4558968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			  string) : NULL;
4559968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
4560968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4561968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldconst char *
4562968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldbase_name (const char *name)
4563968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
4564968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  const char *base;
4565968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4566968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4567968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  /* Skip over the disk name in MSDOS pathnames. */
4568968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
4569968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    name += 2;
4570968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#endif
4571968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4572968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  for (base = name; *name; name++)
4573968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if (IS_DIR_SEPARATOR (*name))
4574968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      base = name + 1;
4575968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  return base;
4576968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
4577968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4578968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldint
4579968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldcheck_executable (const char *path)
4580968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
4581968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  struct stat st;
4582968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4583968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
4584968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold                  nonempty (path));
4585968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if ((!path) || (!*path))
4586968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    return 0;
4587968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4588968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if ((stat (path, &st) >= 0)
4589968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
4590968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    return 1;
4591968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  else
4592968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    return 0;
4593968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
4594968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4595968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldint
4596968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldmake_executable (const char *path)
4597968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
4598968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  int rval = 0;
4599968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  struct stat st;
4600968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4601968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
4602968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold                  nonempty (path));
4603968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if ((!path) || (!*path))
4604968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    return 0;
4605968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4606968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if (stat (path, &st) >= 0)
4607968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    {
4608968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
4609968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    }
4610968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  return rval;
4611968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
4612968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4613968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold/* Searches for the full path of the wrapper.  Returns
4614968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold   newly allocated full path name if found, NULL otherwise
4615968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold   Does not chase symlinks, even on platforms that support them.
4616968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold*/
4617968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldchar *
4618968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfind_executable (const char *wrapper)
4619968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
4620968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  int has_slash = 0;
4621968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  const char *p;
4622968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  const char *p_next;
4623968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  /* static buffer for getcwd */
4624968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  char tmp[LT_PATHMAX + 1];
4625968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  int tmp_len;
4626968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  char *concat_name;
4627968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4628968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
4629968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold                  nonempty (wrapper));
4630968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4631968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if ((wrapper == NULL) || (*wrapper == '\0'))
4632968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    return NULL;
4633968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4634968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  /* Absolute path? */
4635968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4636968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
4637968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    {
4638968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      concat_name = xstrdup (wrapper);
4639968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if (check_executable (concat_name))
4640968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	return concat_name;
4641968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      XFREE (concat_name);
4642968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    }
4643968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  else
4644968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    {
4645968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#endif
4646968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if (IS_DIR_SEPARATOR (wrapper[0]))
4647968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	{
4648968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  concat_name = xstrdup (wrapper);
4649968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if (check_executable (concat_name))
4650968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    return concat_name;
4651968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  XFREE (concat_name);
4652968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	}
4653968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4654968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    }
4655968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#endif
4656968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4657968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  for (p = wrapper; *p; p++)
4658968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if (*p == '/')
4659968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      {
4660968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	has_slash = 1;
4661968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	break;
4662968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      }
4663968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if (!has_slash)
4664968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    {
4665968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      /* no slashes; search PATH */
4666968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      const char *path = getenv ("PATH");
4667968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if (path != NULL)
4668968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	{
4669968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  for (p = path; *p; p = p_next)
4670968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    {
4671968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      const char *q;
4672968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      size_t p_len;
4673968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      for (q = p; *q; q++)
4674968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		if (IS_PATH_SEPARATOR (*q))
4675968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  break;
4676968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      p_len = q - p;
4677968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      p_next = (*q == '\0' ? q : q + 1);
4678968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if (p_len == 0)
4679968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		{
4680968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  /* empty path: current directory */
4681968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  if (getcwd (tmp, LT_PATHMAX) == NULL)
4682968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4683968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold                              nonnull (strerror (errno)));
4684968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  tmp_len = strlen (tmp);
4685968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  concat_name =
4686968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4687968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  memcpy (concat_name, tmp, tmp_len);
4688968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  concat_name[tmp_len] = '/';
4689968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  strcpy (concat_name + tmp_len + 1, wrapper);
4690968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		}
4691968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      else
4692968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		{
4693968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  concat_name =
4694968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
4695968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  memcpy (concat_name, p, p_len);
4696968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  concat_name[p_len] = '/';
4697968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  strcpy (concat_name + p_len + 1, wrapper);
4698968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		}
4699968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if (check_executable (concat_name))
4700968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		return concat_name;
4701968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      XFREE (concat_name);
4702968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    }
4703968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	}
4704968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      /* not found in PATH; assume curdir */
4705968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    }
4706968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  /* Relative path | not found in path: prepend cwd */
4707968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if (getcwd (tmp, LT_PATHMAX) == NULL)
4708968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4709968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold              nonnull (strerror (errno)));
4710968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  tmp_len = strlen (tmp);
4711968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4712968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  memcpy (concat_name, tmp, tmp_len);
4713968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  concat_name[tmp_len] = '/';
4714968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  strcpy (concat_name + tmp_len + 1, wrapper);
4715968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4716968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if (check_executable (concat_name))
4717968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    return concat_name;
4718968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  XFREE (concat_name);
4719968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  return NULL;
4720968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
4721968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4722968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldchar *
4723968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldchase_symlinks (const char *pathspec)
4724968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
4725968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#ifndef S_ISLNK
4726968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  return xstrdup (pathspec);
4727968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#else
4728968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  char buf[LT_PATHMAX];
4729968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  struct stat s;
4730968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  char *tmp_pathspec = xstrdup (pathspec);
4731968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  char *p;
4732968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  int has_symlinks = 0;
4733968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  while (strlen (tmp_pathspec) && !has_symlinks)
4734968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    {
4735968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      lt_debugprintf (__FILE__, __LINE__,
4736968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      "checking path component for symlinks: %s\n",
4737968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      tmp_pathspec);
4738968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if (lstat (tmp_pathspec, &s) == 0)
4739968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	{
4740968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if (S_ISLNK (s.st_mode) != 0)
4741968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    {
4742968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      has_symlinks = 1;
4743968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      break;
4744968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    }
4745968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4746968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  /* search backwards for last DIR_SEPARATOR */
4747968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
4748968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4749968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    p--;
4750968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4751968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    {
4752968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      /* no more DIR_SEPARATORS left */
4753968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      break;
4754968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    }
4755968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *p = '\0';
4756968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	}
4757968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      else
4758968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	{
4759968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  lt_fatal (__FILE__, __LINE__,
4760968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    "error accessing file \"%s\": %s",
4761968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    tmp_pathspec, nonnull (strerror (errno)));
4762968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	}
4763968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    }
4764968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  XFREE (tmp_pathspec);
4765968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4766968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if (!has_symlinks)
4767968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    {
4768968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      return xstrdup (pathspec);
4769968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    }
4770968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4771968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  tmp_pathspec = realpath (pathspec, buf);
4772968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if (tmp_pathspec == 0)
4773968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    {
4774968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      lt_fatal (__FILE__, __LINE__,
4775968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		"could not follow symlinks for %s", pathspec);
4776968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    }
4777968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  return xstrdup (tmp_pathspec);
4778968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#endif
4779968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
4780968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4781968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldchar *
4782968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldstrendzap (char *str, const char *pat)
4783968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
4784968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  size_t len, patlen;
4785968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4786968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  assert (str != NULL);
4787968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  assert (pat != NULL);
4788968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4789968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  len = strlen (str);
4790968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  patlen = strlen (pat);
4791968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4792968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if (patlen <= len)
4793968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    {
4794968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      str += len - patlen;
4795968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if (strcmp (str, pat) == 0)
4796968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*str = '\0';
4797968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    }
4798968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  return str;
4799968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
4800968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4801968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldvoid
4802968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldlt_debugprintf (const char *file, int line, const char *fmt, ...)
4803968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
4804968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  va_list args;
4805968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if (lt_debug)
4806968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    {
4807968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
4808968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      va_start (args, fmt);
4809968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      (void) vfprintf (stderr, fmt, args);
4810968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      va_end (args);
4811968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    }
4812968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
4813968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4814968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldstatic void
4815968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldlt_error_core (int exit_status, const char *file,
4816968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	       int line, const char *mode,
4817968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	       const char *message, va_list ap)
4818968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
4819968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
4820968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  vfprintf (stderr, message, ap);
4821968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  fprintf (stderr, ".\n");
4822968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4823968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if (exit_status >= 0)
4824968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    exit (exit_status);
4825968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
4826968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4827968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldvoid
4828968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldlt_fatal (const char *file, int line, const char *message, ...)
4829968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
4830968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  va_list ap;
4831968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  va_start (ap, message);
4832968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
4833968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  va_end (ap);
4834968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
4835968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4836968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldstatic const char *
4837968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldnonnull (const char *s)
4838968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
4839968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  return s ? s : "(null)";
4840968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
4841968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4842968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldstatic const char *
4843968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldnonempty (const char *s)
4844968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
4845968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  return (s && !*s) ? "(empty)" : nonnull (s);
4846968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
4847968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4848968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldvoid
4849968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldlt_setenv (const char *name, const char *value)
4850968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
4851968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  lt_debugprintf (__FILE__, __LINE__,
4852968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  "(lt_setenv) setting '%s' to '%s'\n",
4853968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold                  nonnull (name), nonnull (value));
4854968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  {
4855968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#ifdef HAVE_SETENV
4856968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    /* always make a copy, for consistency with !HAVE_SETENV */
4857968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    char *str = xstrdup (value);
4858968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    setenv (name, str, 1);
4859968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#else
4860968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    int len = strlen (name) + 1 + strlen (value) + 1;
4861968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    char *str = XMALLOC (char, len);
4862968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    sprintf (str, "%s=%s", name, value);
4863968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if (putenv (str) != EXIT_SUCCESS)
4864968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      {
4865968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        XFREE (str);
4866968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      }
4867968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#endif
4868968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  }
4869968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
4870968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4871968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldchar *
4872968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldlt_extend_str (const char *orig_value, const char *add, int to_end)
4873968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
4874968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  char *new_value;
4875968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if (orig_value && *orig_value)
4876968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    {
4877968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      int orig_value_len = strlen (orig_value);
4878968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      int add_len = strlen (add);
4879968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      new_value = XMALLOC (char, add_len + orig_value_len + 1);
4880968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if (to_end)
4881968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        {
4882968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold          strcpy (new_value, orig_value);
4883968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold          strcpy (new_value + orig_value_len, add);
4884968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        }
4885968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      else
4886968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        {
4887968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold          strcpy (new_value, add);
4888968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold          strcpy (new_value + add_len, orig_value);
4889968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        }
4890968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    }
4891968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  else
4892968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    {
4893968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      new_value = xstrdup (add);
4894968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    }
4895968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  return new_value;
4896968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
4897968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4898968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldvoid
4899968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldlt_update_exe_path (const char *name, const char *value)
4900968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
4901968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  lt_debugprintf (__FILE__, __LINE__,
4902968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
4903968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold                  nonnull (name), nonnull (value));
4904968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4905968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if (name && *name && value && *value)
4906968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    {
4907968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      char *new_value = lt_extend_str (getenv (name), value, 0);
4908968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      /* some systems can't cope with a ':'-terminated path #' */
4909968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      int len = strlen (new_value);
4910968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
4911968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        {
4912968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold          new_value[len-1] = '\0';
4913968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        }
4914968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      lt_setenv (name, new_value);
4915968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      XFREE (new_value);
4916968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    }
4917968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
4918968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4919968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldvoid
4920968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldlt_update_lib_path (const char *name, const char *value)
4921968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
4922968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  lt_debugprintf (__FILE__, __LINE__,
4923968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
4924968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold                  nonnull (name), nonnull (value));
4925968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4926968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  if (name && *name && value && *value)
4927968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    {
4928968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      char *new_value = lt_extend_str (getenv (name), value, 0);
4929968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      lt_setenv (name, new_value);
4930968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      XFREE (new_value);
4931968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    }
4932968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
4933968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4934968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEOF
4935968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    case $host_os in
4936968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      mingw*)
4937968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		cat <<"EOF"
4938968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4939968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold/* Prepares an argument vector before calling spawn().
4940968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold   Note that spawn() does not by itself call the command interpreter
4941968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
4942968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
4943968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold         GetVersionEx(&v);
4944968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
4945968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      }) ? "cmd.exe" : "command.com").
4946968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold   Instead it simply concatenates the arguments, separated by ' ', and calls
4947968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
4948968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
4949968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold   special way:
4950968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold   - Space and tab are interpreted as delimiters. They are not treated as
4951968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     delimiters if they are surrounded by double quotes: "...".
4952968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold   - Unescaped double quotes are removed from the input. Their only effect is
4953968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     that within double quotes, space and tab are treated like normal
4954968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     characters.
4955968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold   - Backslashes not followed by double quotes are not special.
4956968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold   - But 2*n+1 backslashes followed by a double quote become
4957968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold     n backslashes followed by a double quote (n >= 0):
4958968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold       \" -> "
4959968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold       \\\" -> \"
4960968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold       \\\\\" -> \\"
4961968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold */
4962968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
4963968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
4964968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldchar **
4965968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldprepare_spawn (char **argv)
4966968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
4967968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  size_t argc;
4968968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  char **new_argv;
4969968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  size_t i;
4970968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4971968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  /* Count number of arguments.  */
4972968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  for (argc = 0; argv[argc] != NULL; argc++)
4973968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    ;
4974968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4975968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  /* Allocate new argument vector.  */
4976968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  new_argv = XMALLOC (char *, argc + 1);
4977968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4978968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  /* Put quoted arguments into the new argument vector.  */
4979968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  for (i = 0; i < argc; i++)
4980968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    {
4981968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      const char *string = argv[i];
4982968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4983968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if (string[0] == '\0')
4984968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	new_argv[i] = xstrdup ("\"\"");
4985968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
4986968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	{
4987968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
4988968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  size_t length;
4989968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  unsigned int backslashes;
4990968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  const char *s;
4991968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  char *quoted_string;
4992968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  char *p;
4993968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
4994968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  length = 0;
4995968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  backslashes = 0;
4996968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if (quote_around)
4997968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    length++;
4998968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  for (s = string; *s != '\0'; s++)
4999968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    {
5000968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      char c = *s;
5001968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if (c == '"')
5002968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		length += backslashes + 1;
5003968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      length++;
5004968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if (c == '\\')
5005968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		backslashes++;
5006968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      else
5007968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		backslashes = 0;
5008968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    }
5009968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if (quote_around)
5010968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    length += backslashes + 1;
5011968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5012968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  quoted_string = XMALLOC (char, length + 1);
5013968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5014968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  p = quoted_string;
5015968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  backslashes = 0;
5016968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if (quote_around)
5017968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *p++ = '"';
5018968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  for (s = string; *s != '\0'; s++)
5019968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    {
5020968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      char c = *s;
5021968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if (c == '"')
5022968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		{
5023968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  unsigned int j;
5024968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  for (j = backslashes + 1; j > 0; j--)
5025968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    *p++ = '\\';
5026968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		}
5027968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *p++ = c;
5028968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if (c == '\\')
5029968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		backslashes++;
5030968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      else
5031968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		backslashes = 0;
5032968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    }
5033968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if (quote_around)
5034968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    {
5035968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      unsigned int j;
5036968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      for (j = backslashes; j > 0; j--)
5037968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		*p++ = '\\';
5038968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *p++ = '"';
5039968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    }
5040968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *p = '\0';
5041968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5042968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  new_argv[i] = quoted_string;
5043968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	}
5044968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      else
5045968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	new_argv[i] = (char *) string;
5046968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    }
5047968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  new_argv[argc] = NULL;
5048968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5049968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  return new_argv;
5050968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
5051968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEOF
5052968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		;;
5053968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    esac
5054968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5055968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold            cat <<"EOF"
5056968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldvoid lt_dump_script (FILE* f)
5057968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
5058968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEOF
5059968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_emit_wrapper yes |
5060968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold              $SED -e 's/\([\\"]\)/\\\1/g' \
5061968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	           -e 's/^/  fputs ("/' -e 's/$/\\n", f);/'
5062968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5063968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold            cat <<"EOF"
5064968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
5065968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEOF
5066968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
5067968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# end: func_emit_cwrapperexe_src
5068968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5069968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_win32_import_lib_p ARG
5070968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# True if ARG is an import lib, as indicated by $file_magic_cmd
5071968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_win32_import_lib_p ()
5072968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
5073968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $opt_debug
5074968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
5075968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *import*) : ;;
5076968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *) false ;;
5077968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    esac
5078968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
5079968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5080968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_mode_link arg...
5081968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_mode_link ()
5082968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
5083968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $opt_debug
5084968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    case $host in
5085968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5086968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # It is impossible to link a dll without this setting, and
5087968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # we shouldn't force the makefile maintainer to figure out
5088968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # which system we are compiling for in order to pass an extra
5089968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # flag for every libtool invocation.
5090968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # allow_undefined=no
5091968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5092968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # FIXME: Unfortunately, there are problems with the above when trying
5093968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # to make a dll which has undefined symbols, in which case not
5094968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # even a static library is built.  For now, we need to specify
5095968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # -no-undefined on the libtool link line when we can be certain
5096968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # that all symbols are satisfied, otherwise we get a static library.
5097968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      allow_undefined=yes
5098968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      ;;
5099968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *)
5100968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      allow_undefined=yes
5101968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      ;;
5102968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    esac
5103968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    libtool_args=$nonopt
5104968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    base_compile="$nonopt $@"
5105968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    compile_command=$nonopt
5106968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    finalize_command=$nonopt
5107968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5108968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    compile_rpath=
5109968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    finalize_rpath=
5110968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    compile_shlibpath=
5111968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    finalize_shlibpath=
5112968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    convenience=
5113968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    old_convenience=
5114968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    deplibs=
5115968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    old_deplibs=
5116968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    compiler_flags=
5117968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    linker_flags=
5118968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    dllsearchpath=
5119968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    lib_search_path=`pwd`
5120968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    inst_prefix_dir=
5121968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    new_inherited_linker_flags=
5122968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5123968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    avoid_version=no
5124968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    bindir=
5125968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    dlfiles=
5126968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    dlprefiles=
5127968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    dlself=no
5128968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    export_dynamic=no
5129968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    export_symbols=
5130968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    export_symbols_regex=
5131968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    generated=
5132968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    libobjs=
5133968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    ltlibs=
5134968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    module=no
5135968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    no_install=no
5136968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    objs=
5137968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    non_pic_objects=
5138968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    precious_files_regex=
5139968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    prefer_static_libs=no
5140968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    preload=no
5141968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    prev=
5142968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    prevarg=
5143968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    release=
5144968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    rpath=
5145968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    xrpath=
5146968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    perm_rpath=
5147968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    temp_rpath=
5148968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    thread_safe=no
5149968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    vinfo=
5150968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    vinfo_number=no
5151968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    weak_libs=
5152968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    single_module="${wl}-single_module"
5153968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_infer_tag $base_compile
5154968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5155968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # We need to know -static, to get the right output filenames.
5156968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    for arg
5157968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    do
5158968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      case $arg in
5159968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -shared)
5160968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	test "$build_libtool_libs" != yes && \
5161968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_fatal_configuration "can not build a shared library"
5162968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	build_old_libs=no
5163968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	break
5164968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5165968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -all-static | -static | -static-libtool-libs)
5166968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $arg in
5167968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	-all-static)
5168968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
5169968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_warning "complete static linking is impossible in this configuration"
5170968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
5171968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -n "$link_static_flag"; then
5172968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    dlopen_self=$dlopen_self_static
5173968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
5174968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  prefer_static_libs=yes
5175968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
5176968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	-static)
5177968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5178968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    dlopen_self=$dlopen_self_static
5179968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
5180968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  prefer_static_libs=built
5181968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
5182968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	-static-libtool-libs)
5183968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5184968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    dlopen_self=$dlopen_self_static
5185968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
5186968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  prefer_static_libs=yes
5187968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
5188968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
5189968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	build_libtool_libs=no
5190968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	build_old_libs=yes
5191968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	break
5192968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5193968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      esac
5194968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    done
5195968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5196968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # See if our shared archives depend on static archives.
5197968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
5198968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5199968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Go through the arguments, transforming them on the way.
5200968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    while test "$#" -gt 0; do
5201968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      arg="$1"
5202968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      shift
5203968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_quote_for_eval "$arg"
5204968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      qarg=$func_quote_for_eval_unquoted_result
5205968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_append libtool_args " $func_quote_for_eval_result"
5206968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5207968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # If the previous option needs an argument, assign it.
5208968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$prev"; then
5209968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $prev in
5210968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	output)
5211968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append compile_command " @OUTPUT@"
5212968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append finalize_command " @OUTPUT@"
5213968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
5214968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
5215968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5216968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $prev in
5217968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	bindir)
5218968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  bindir="$arg"
5219968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  prev=
5220968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
5221968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
5222968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	dlfiles|dlprefiles)
5223968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$preload" = no; then
5224968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Add the symbol object into the linking commands.
5225968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append compile_command " @SYMFILE@"
5226968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append finalize_command " @SYMFILE@"
5227968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    preload=yes
5228968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
5229968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case $arg in
5230968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *.la | *.lo) ;;  # We handle these cases below.
5231968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  force)
5232968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "$dlself" = no; then
5233968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      dlself=needless
5234968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      export_dynamic=yes
5235968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
5236968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    prev=
5237968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    continue
5238968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
5239968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  self)
5240968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "$prev" = dlprefiles; then
5241968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      dlself=yes
5242968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
5243968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      dlself=yes
5244968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    else
5245968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      dlself=needless
5246968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      export_dynamic=yes
5247968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
5248968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    prev=
5249968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    continue
5250968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
5251968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *)
5252968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "$prev" = dlfiles; then
5253968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_append dlfiles " $arg"
5254968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    else
5255968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_append dlprefiles " $arg"
5256968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
5257968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    prev=
5258968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    continue
5259968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
5260968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
5261968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
5262968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	expsyms)
5263968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  export_symbols="$arg"
5264968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  test -f "$arg" \
5265968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    || func_fatal_error "symbol file \`$arg' does not exist"
5266968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  prev=
5267968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
5268968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
5269968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	expsyms_regex)
5270968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  export_symbols_regex="$arg"
5271968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  prev=
5272968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
5273968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
5274968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	framework)
5275968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case $host in
5276968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *-*-darwin*)
5277968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case "$deplibs " in
5278968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		*" $qarg.ltframework "*) ;;
5279968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		*) func_append deplibs " $qarg.ltframework" # this is fixed later
5280968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		   ;;
5281968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
5282968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      ;;
5283968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
5284968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  prev=
5285968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
5286968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
5287968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	inst_prefix)
5288968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  inst_prefix_dir="$arg"
5289968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  prev=
5290968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
5291968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
5292968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	objectlist)
5293968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -f "$arg"; then
5294968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    save_arg=$arg
5295968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    moreargs=
5296968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    for fil in `cat "$save_arg"`
5297968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    do
5298968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#	      func_append moreargs " $fil"
5299968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      arg=$fil
5300968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # A libtool-controlled object.
5301968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5302968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # Check to see that this really is a libtool object.
5303968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if func_lalib_unsafe_p "$arg"; then
5304968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		pic_object=
5305968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		non_pic_object=
5306968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5307968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		# Read the .lo file
5308968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_source "$arg"
5309968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5310968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		if test -z "$pic_object" ||
5311968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		   test -z "$non_pic_object" ||
5312968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		   test "$pic_object" = none &&
5313968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		   test "$non_pic_object" = none; then
5314968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  func_fatal_error "cannot find name of object for \`$arg'"
5315968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		fi
5316968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5317968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		# Extract subdirectory from the argument.
5318968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_dirname "$arg" "/" ""
5319968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		xdir="$func_dirname_result"
5320968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5321968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		if test "$pic_object" != none; then
5322968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  # Prepend the subdirectory the object is found in.
5323968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  pic_object="$xdir$pic_object"
5324968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5325968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  if test "$prev" = dlfiles; then
5326968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5327968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      func_append dlfiles " $pic_object"
5328968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      prev=
5329968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      continue
5330968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    else
5331968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      # If libtool objects are unsupported, then we need to preload.
5332968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      prev=dlprefiles
5333968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    fi
5334968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  fi
5335968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5336968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  # CHECK ME:  I think I busted this.  -Ossama
5337968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  if test "$prev" = dlprefiles; then
5338968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    # Preload the old-style object.
5339968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    func_append dlprefiles " $pic_object"
5340968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    prev=
5341968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  fi
5342968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5343968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  # A PIC object.
5344968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  func_append libobjs " $pic_object"
5345968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  arg="$pic_object"
5346968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		fi
5347968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5348968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		# Non-PIC object.
5349968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		if test "$non_pic_object" != none; then
5350968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  # Prepend the subdirectory the object is found in.
5351968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  non_pic_object="$xdir$non_pic_object"
5352968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5353968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  # A standard non-PIC object
5354968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  func_append non_pic_objects " $non_pic_object"
5355968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  if test -z "$pic_object" || test "$pic_object" = none ; then
5356968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    arg="$non_pic_object"
5357968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  fi
5358968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		else
5359968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  # If the PIC object exists, use it instead.
5360968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  # $xdir was prepended to $pic_object above.
5361968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  non_pic_object="$pic_object"
5362968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  func_append non_pic_objects " $non_pic_object"
5363968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		fi
5364968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      else
5365968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		# Only an error if not doing a dry-run.
5366968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		if $opt_dry_run; then
5367968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  # Extract subdirectory from the argument.
5368968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  func_dirname "$arg" "/" ""
5369968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  xdir="$func_dirname_result"
5370968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5371968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  func_lo2o "$arg"
5372968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  pic_object=$xdir$objdir/$func_lo2o_result
5373968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  non_pic_object=$xdir$func_lo2o_result
5374968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  func_append libobjs " $pic_object"
5375968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  func_append non_pic_objects " $non_pic_object"
5376968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        else
5377968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  func_fatal_error "\`$arg' is not a valid libtool object"
5378968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		fi
5379968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
5380968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    done
5381968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
5382968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_fatal_error "link input file \`$arg' does not exist"
5383968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
5384968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  arg=$save_arg
5385968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  prev=
5386968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
5387968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
5388968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	precious_regex)
5389968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  precious_files_regex="$arg"
5390968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  prev=
5391968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
5392968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
5393968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	release)
5394968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  release="-$arg"
5395968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  prev=
5396968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
5397968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
5398968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	rpath | xrpath)
5399968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # We need an absolute path.
5400968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case $arg in
5401968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  [\\/]* | [A-Za-z]:[\\/]*) ;;
5402968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *)
5403968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_fatal_error "only absolute run-paths are allowed"
5404968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
5405968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
5406968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$prev" = rpath; then
5407968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    case "$rpath " in
5408968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *" $arg "*) ;;
5409968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *) func_append rpath " $arg" ;;
5410968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    esac
5411968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
5412968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    case "$xrpath " in
5413968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *" $arg "*) ;;
5414968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *) func_append xrpath " $arg" ;;
5415968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    esac
5416968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
5417968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  prev=
5418968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
5419968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
5420968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	shrext)
5421968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  shrext_cmds="$arg"
5422968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  prev=
5423968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
5424968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
5425968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	weak)
5426968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append weak_libs " $arg"
5427968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  prev=
5428968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
5429968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
5430968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	xcclinker)
5431968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append linker_flags " $qarg"
5432968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append compiler_flags " $qarg"
5433968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  prev=
5434968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append compile_command " $qarg"
5435968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append finalize_command " $qarg"
5436968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
5437968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
5438968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	xcompiler)
5439968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append compiler_flags " $qarg"
5440968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  prev=
5441968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append compile_command " $qarg"
5442968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append finalize_command " $qarg"
5443968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
5444968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
5445968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	xlinker)
5446968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append linker_flags " $qarg"
5447968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append compiler_flags " $wl$qarg"
5448968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  prev=
5449968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append compile_command " $wl$qarg"
5450968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append finalize_command " $wl$qarg"
5451968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
5452968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
5453968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*)
5454968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  eval "$prev=\"\$arg\""
5455968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  prev=
5456968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
5457968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
5458968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
5459968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi # test -n "$prev"
5460968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5461968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      prevarg="$arg"
5462968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5463968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      case $arg in
5464968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -all-static)
5465968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$link_static_flag"; then
5466968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # See comment for -static flag below, for more details.
5467968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append compile_command " $link_static_flag"
5468968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append finalize_command " $link_static_flag"
5469968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
5470968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5471968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5472968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5473968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -allow-undefined)
5474968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# FIXME: remove this flag sometime in the future.
5475968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
5476968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5477968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5478968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -avoid-version)
5479968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	avoid_version=yes
5480968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5481968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5482968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5483968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -bindir)
5484968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	prev=bindir
5485968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5486968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5487968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5488968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -dlopen)
5489968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	prev=dlfiles
5490968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5491968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5492968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5493968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -dlpreopen)
5494968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	prev=dlprefiles
5495968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5496968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5497968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5498968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -export-dynamic)
5499968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	export_dynamic=yes
5500968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5501968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5502968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5503968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -export-symbols | -export-symbols-regex)
5504968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
5505968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_fatal_error "more than one -exported-symbols argument is not allowed"
5506968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
5507968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "X$arg" = "X-export-symbols"; then
5508968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  prev=expsyms
5509968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	else
5510968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  prev=expsyms_regex
5511968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
5512968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5513968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5514968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5515968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -framework)
5516968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	prev=framework
5517968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5518968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5519968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5520968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -inst-prefix-dir)
5521968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	prev=inst_prefix
5522968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5523968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5524968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5525968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
5526968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # so, if we see these flags be careful not to treat them like -L
5527968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -L[A-Z][A-Z]*:*)
5528968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $with_gcc/$host in
5529968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	no/*-*-irix* | /*-*-irix*)
5530968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append compile_command " $arg"
5531968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append finalize_command " $arg"
5532968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
5533968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
5534968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5535968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5536968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5537968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -L*)
5538968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_stripname "-L" '' "$arg"
5539968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -z "$func_stripname_result"; then
5540968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$#" -gt 0; then
5541968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_fatal_error "require no space between \`-L' and \`$1'"
5542968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
5543968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_fatal_error "need path for \`-L' option"
5544968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
5545968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
5546968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_resolve_sysroot "$func_stripname_result"
5547968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	dir=$func_resolve_sysroot_result
5548968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# We need an absolute path.
5549968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $dir in
5550968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	[\\/]* | [A-Za-z]:[\\/]*) ;;
5551968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*)
5552968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  absdir=`cd "$dir" && pwd`
5553968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  test -z "$absdir" && \
5554968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
5555968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  dir="$absdir"
5556968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
5557968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
5558968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case "$deplibs " in
5559968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*" -L$dir "* | *" $arg "*)
5560968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Will only happen for absolute or sysroot arguments
5561968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
5562968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*)
5563968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Preserve sysroot, but never include relative directories
5564968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case $dir in
5565968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
5566968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *) func_append deplibs " -L$dir" ;;
5567968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
5568968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append lib_search_path " $dir"
5569968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
5570968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
5571968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $host in
5572968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5573968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
5574968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case :$dllsearchpath: in
5575968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *":$dir:"*) ;;
5576968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ::) dllsearchpath=$dir;;
5577968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *) func_append dllsearchpath ":$dir";;
5578968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
5579968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case :$dllsearchpath: in
5580968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *":$testbindir:"*) ;;
5581968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ::) dllsearchpath=$testbindir;;
5582968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *) func_append dllsearchpath ":$testbindir";;
5583968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
5584968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
5585968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
5586968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5587968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5588968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5589968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -l*)
5590968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
5591968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case $host in
5592968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
5593968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # These systems don't actually have a C or math library (as such)
5594968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    continue
5595968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
5596968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *-*-os2*)
5597968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # These systems don't actually have a C library (as such)
5598968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    test "X$arg" = "X-lc" && continue
5599968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
5600968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5601968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Do not include libc due to us having libc/libc_r.
5602968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    test "X$arg" = "X-lc" && continue
5603968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
5604968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *-*-rhapsody* | *-*-darwin1.[012])
5605968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Rhapsody C and math libraries are in the System framework
5606968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append deplibs " System.ltframework"
5607968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    continue
5608968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
5609968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *-*-sco3.2v5* | *-*-sco5v6*)
5610968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Causes problems with __ctype
5611968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    test "X$arg" = "X-lc" && continue
5612968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
5613968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
5614968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Compiler inserts libc in the correct place for threads to work
5615968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    test "X$arg" = "X-lc" && continue
5616968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
5617968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
5618968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	elif test "X$arg" = "X-lc_r"; then
5619968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	 case $host in
5620968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5621968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	   # Do not include libc_r directly, use -pthread flag.
5622968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	   continue
5623968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	   ;;
5624968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	 esac
5625968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
5626968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_append deplibs " $arg"
5627968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5628968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5629968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5630968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -module)
5631968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	module=yes
5632968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5633968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5634968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5635968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Tru64 UNIX uses -model [arg] to determine the layout of C++
5636968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # classes, name mangling, and exception handling.
5637968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Darwin uses the -arch flag to determine output architecture.
5638968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -model|-arch|-isysroot|--sysroot)
5639968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_append compiler_flags " $arg"
5640968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_append compile_command " $arg"
5641968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_append finalize_command " $arg"
5642968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	prev=xcompiler
5643968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5644968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5645968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5646968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
5647968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_append compiler_flags " $arg"
5648968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_append compile_command " $arg"
5649968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_append finalize_command " $arg"
5650968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case "$new_inherited_linker_flags " in
5651968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *" $arg "*) ;;
5652968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    * ) func_append new_inherited_linker_flags " $arg" ;;
5653968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
5654968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5655968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5656968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5657968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -multi_module)
5658968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	single_module="${wl}-multi_module"
5659968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5660968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5661968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5662968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -no-fast-install)
5663968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fast_install=no
5664968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5665968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5666968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5667968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -no-install)
5668968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $host in
5669968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
5670968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # The PATH hackery in wrapper scripts is required on Windows
5671968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # and Darwin in order for the loader to find any dlls it needs.
5672968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_warning "\`-no-install' is ignored for $host"
5673968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_warning "assuming \`-no-fast-install' instead"
5674968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fast_install=no
5675968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
5676968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*) no_install=yes ;;
5677968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
5678968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5679968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5680968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5681968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -no-undefined)
5682968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	allow_undefined=no
5683968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5684968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5685968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5686968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -objectlist)
5687968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	prev=objectlist
5688968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5689968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5690968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5691968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -o) prev=output ;;
5692968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5693968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -precious-files-regex)
5694968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	prev=precious_regex
5695968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5696968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5697968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5698968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -release)
5699968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	prev=release
5700968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5701968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5702968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5703968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -rpath)
5704968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	prev=rpath
5705968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5706968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5707968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5708968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -R)
5709968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	prev=xrpath
5710968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5711968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5712968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5713968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -R*)
5714968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_stripname '-R' '' "$arg"
5715968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	dir=$func_stripname_result
5716968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# We need an absolute path.
5717968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $dir in
5718968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	[\\/]* | [A-Za-z]:[\\/]*) ;;
5719968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	=*)
5720968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_stripname '=' '' "$dir"
5721968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  dir=$lt_sysroot$func_stripname_result
5722968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
5723968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*)
5724968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_fatal_error "only absolute run-paths are allowed"
5725968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
5726968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
5727968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case "$xrpath " in
5728968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*" $dir "*) ;;
5729968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*) func_append xrpath " $dir" ;;
5730968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
5731968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5732968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5733968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5734968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -shared)
5735968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# The effects of -shared are defined in a previous loop.
5736968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5737968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5738968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5739968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -shrext)
5740968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	prev=shrext
5741968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5742968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5743968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5744968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -static | -static-libtool-libs)
5745968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# The effects of -static are defined in a previous loop.
5746968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# We used to do the same as -all-static on platforms that
5747968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# didn't have a PIC flag, but the assumption that the effects
5748968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# would be equivalent was wrong.  It would break on at least
5749968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Digital Unix and AIX.
5750968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5751968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5752968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5753968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -thread-safe)
5754968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	thread_safe=yes
5755968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5756968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5757968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5758968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -version-info)
5759968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	prev=vinfo
5760968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5761968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5762968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5763968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -version-number)
5764968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	prev=vinfo
5765968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	vinfo_number=yes
5766968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5767968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5768968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5769968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -weak)
5770968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        prev=weak
5771968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5772968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5773968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5774968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -Wc,*)
5775968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_stripname '-Wc,' '' "$arg"
5776968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	args=$func_stripname_result
5777968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	arg=
5778968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	save_ifs="$IFS"; IFS=','
5779968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	for flag in $args; do
5780968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  IFS="$save_ifs"
5781968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold          func_quote_for_eval "$flag"
5782968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append arg " $func_quote_for_eval_result"
5783968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append compiler_flags " $func_quote_for_eval_result"
5784968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	done
5785968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	IFS="$save_ifs"
5786968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_stripname ' ' '' "$arg"
5787968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	arg=$func_stripname_result
5788968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5789968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5790968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -Wl,*)
5791968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_stripname '-Wl,' '' "$arg"
5792968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	args=$func_stripname_result
5793968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	arg=
5794968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	save_ifs="$IFS"; IFS=','
5795968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	for flag in $args; do
5796968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  IFS="$save_ifs"
5797968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold          func_quote_for_eval "$flag"
5798968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append arg " $wl$func_quote_for_eval_result"
5799968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append compiler_flags " $wl$func_quote_for_eval_result"
5800968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append linker_flags " $func_quote_for_eval_result"
5801968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	done
5802968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	IFS="$save_ifs"
5803968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_stripname ' ' '' "$arg"
5804968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	arg=$func_stripname_result
5805968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5806968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5807968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -Xcompiler)
5808968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	prev=xcompiler
5809968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5810968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5811968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5812968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -Xlinker)
5813968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	prev=xlinker
5814968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5815968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5816968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5817968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -XCClinker)
5818968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	prev=xcclinker
5819968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5820968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5821968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5822968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # -msg_* for osf cc
5823968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -msg_*)
5824968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_quote_for_eval "$arg"
5825968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	arg="$func_quote_for_eval_result"
5826968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5827968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5828968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Flags to be passed through unchanged, with rationale:
5829968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
5830968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # -r[0-9][0-9]*        specify processor for the SGI compiler
5831968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
5832968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # +DA*, +DD*           enable 64-bit mode for the HP compiler
5833968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # -q*                  compiler args for the IBM compiler
5834968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
5835968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # -F/path              path to uninstalled frameworks, gcc on darwin
5836968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
5837968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # @file                GCC response files
5838968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # -tp=*                Portland pgcc target processor selection
5839968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # --sysroot=*          for sysroot support
5840968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
5841968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
5842968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
5843968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
5844968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        func_quote_for_eval "$arg"
5845968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	arg="$func_quote_for_eval_result"
5846968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        func_append compile_command " $arg"
5847968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        func_append finalize_command " $arg"
5848968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        func_append compiler_flags " $arg"
5849968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        continue
5850968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        ;;
5851968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5852968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Some other compiler flag.
5853968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -* | +*)
5854968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        func_quote_for_eval "$arg"
5855968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	arg="$func_quote_for_eval_result"
5856968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5857968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5858968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *.$objext)
5859968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# A standard object.
5860968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_append objs " $arg"
5861968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5862968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5863968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *.lo)
5864968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# A libtool-controlled object.
5865968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5866968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Check to see that this really is a libtool object.
5867968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if func_lalib_unsafe_p "$arg"; then
5868968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  pic_object=
5869968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  non_pic_object=
5870968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5871968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Read the .lo file
5872968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_source "$arg"
5873968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5874968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -z "$pic_object" ||
5875968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	     test -z "$non_pic_object" ||
5876968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	     test "$pic_object" = none &&
5877968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	     test "$non_pic_object" = none; then
5878968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_fatal_error "cannot find name of object for \`$arg'"
5879968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
5880968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5881968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Extract subdirectory from the argument.
5882968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_dirname "$arg" "/" ""
5883968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  xdir="$func_dirname_result"
5884968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5885968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$pic_object" != none; then
5886968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Prepend the subdirectory the object is found in.
5887968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    pic_object="$xdir$pic_object"
5888968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5889968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "$prev" = dlfiles; then
5890968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5891968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_append dlfiles " $pic_object"
5892968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		prev=
5893968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		continue
5894968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      else
5895968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		# If libtool objects are unsupported, then we need to preload.
5896968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		prev=dlprefiles
5897968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
5898968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
5899968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5900968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # CHECK ME:  I think I busted this.  -Ossama
5901968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "$prev" = dlprefiles; then
5902968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # Preload the old-style object.
5903968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_append dlprefiles " $pic_object"
5904968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      prev=
5905968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
5906968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5907968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # A PIC object.
5908968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append libobjs " $pic_object"
5909968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    arg="$pic_object"
5910968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
5911968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5912968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Non-PIC object.
5913968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$non_pic_object" != none; then
5914968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Prepend the subdirectory the object is found in.
5915968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    non_pic_object="$xdir$non_pic_object"
5916968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5917968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # A standard non-PIC object
5918968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append non_pic_objects " $non_pic_object"
5919968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test -z "$pic_object" || test "$pic_object" = none ; then
5920968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      arg="$non_pic_object"
5921968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
5922968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
5923968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # If the PIC object exists, use it instead.
5924968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # $xdir was prepended to $pic_object above.
5925968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    non_pic_object="$pic_object"
5926968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append non_pic_objects " $non_pic_object"
5927968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
5928968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	else
5929968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Only an error if not doing a dry-run.
5930968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if $opt_dry_run; then
5931968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Extract subdirectory from the argument.
5932968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_dirname "$arg" "/" ""
5933968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    xdir="$func_dirname_result"
5934968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5935968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_lo2o "$arg"
5936968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    pic_object=$xdir$objdir/$func_lo2o_result
5937968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    non_pic_object=$xdir$func_lo2o_result
5938968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append libobjs " $pic_object"
5939968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append non_pic_objects " $non_pic_object"
5940968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
5941968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_fatal_error "\`$arg' is not a valid libtool object"
5942968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
5943968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
5944968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5945968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5946968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *.$libext)
5947968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# An archive.
5948968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_append deplibs " $arg"
5949968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_append old_deplibs " $arg"
5950968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5951968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5952968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5953968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *.la)
5954968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# A libtool-controlled library.
5955968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5956968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_resolve_sysroot "$arg"
5957968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$prev" = dlfiles; then
5958968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # This library was specified with -dlopen.
5959968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append dlfiles " $func_resolve_sysroot_result"
5960968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  prev=
5961968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	elif test "$prev" = dlprefiles; then
5962968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # The library was specified with -dlpreopen.
5963968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append dlprefiles " $func_resolve_sysroot_result"
5964968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  prev=
5965968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	else
5966968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append deplibs " $func_resolve_sysroot_result"
5967968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
5968968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
5969968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5970968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5971968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Some other compiler argument.
5972968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *)
5973968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Unknown arguments in both finalize_command and compile_command need
5974968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# to be aesthetically quoted because they are evaled later.
5975968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_quote_for_eval "$arg"
5976968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	arg="$func_quote_for_eval_result"
5977968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
5978968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      esac # arg
5979968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5980968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Now actually substitute the argument into the commands.
5981968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$arg"; then
5982968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_append compile_command " $arg"
5983968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_append finalize_command " $arg"
5984968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
5985968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    done # argument parsing loop
5986968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5987968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    test -n "$prev" && \
5988968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_fatal_help "the \`$prevarg' option requires an argument"
5989968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5990968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
5991968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      eval arg=\"$export_dynamic_flag_spec\"
5992968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_append compile_command " $arg"
5993968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_append finalize_command " $arg"
5994968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
5995968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
5996968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    oldlibs=
5997968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # calculate the name of the file, without its directory
5998968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_basename "$output"
5999968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    outputname="$func_basename_result"
6000968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    libobjs_save="$libobjs"
6001968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6002968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test -n "$shlibpath_var"; then
6003968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # get the directories listed in $shlibpath_var
6004968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
6005968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    else
6006968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      shlib_search_path=
6007968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
6008968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
6009968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
6010968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6011968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_dirname "$output" "/" ""
6012968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    output_objdir="$func_dirname_result$objdir"
6013968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_to_tool_file "$output_objdir/"
6014968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    tool_output_objdir=$func_to_tool_file_result
6015968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Create the object directory.
6016968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_mkdir_p "$output_objdir"
6017968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6018968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Determine the type of output
6019968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    case $output in
6020968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    "")
6021968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_fatal_help "you must specify an output file"
6022968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      ;;
6023968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *.$libext) linkmode=oldlib ;;
6024968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *.lo | *.$objext) linkmode=obj ;;
6025968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *.la) linkmode=lib ;;
6026968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *) linkmode=prog ;; # Anything else should be a program.
6027968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    esac
6028968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6029968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    specialdeplibs=
6030968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6031968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    libs=
6032968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Find all interdependent deplibs by searching for libraries
6033968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # that are linked more than once (e.g. -la -lb -la)
6034968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    for deplib in $deplibs; do
6035968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if $opt_preserve_dup_deps ; then
6036968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case "$libs " in
6037968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
6038968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
6039968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
6040968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_append libs " $deplib"
6041968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    done
6042968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6043968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test "$linkmode" = lib; then
6044968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      libs="$predeps $libs $compiler_lib_search_path $postdeps"
6045968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6046968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Compute libraries that are listed more than once in $predeps
6047968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # $postdeps and mark them as special (i.e., whose duplicates are
6048968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # not to be eliminated).
6049968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      pre_post_deps=
6050968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if $opt_duplicate_compiler_generated_deps; then
6051968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	for pre_post_dep in $predeps $postdeps; do
6052968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case "$pre_post_deps " in
6053968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
6054968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
6055968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append pre_post_deps " $pre_post_dep"
6056968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	done
6057968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
6058968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      pre_post_deps=
6059968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
6060968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6061968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    deplibs=
6062968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    newdependency_libs=
6063968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    newlib_search_path=
6064968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    need_relink=no # whether we're linking any uninstalled libtool libraries
6065968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    notinst_deplibs= # not-installed libtool libraries
6066968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    notinst_path= # paths that contain not-installed libtool libraries
6067968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6068968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    case $linkmode in
6069968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    lib)
6070968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	passes="conv dlpreopen link"
6071968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	for file in $dlfiles $dlprefiles; do
6072968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case $file in
6073968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *.la) ;;
6074968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *)
6075968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
6076968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
6077968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
6078968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	done
6079968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
6080968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    prog)
6081968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	compile_deplibs=
6082968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	finalize_deplibs=
6083968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	alldeplibs=no
6084968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	newdlfiles=
6085968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	newdlprefiles=
6086968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	passes="conv scan dlopen dlpreopen link"
6087968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
6088968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *)  passes="conv"
6089968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
6090968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    esac
6091968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6092968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    for pass in $passes; do
6093968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # The preopen pass in lib mode reverses $deplibs; put it back here
6094968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # so that -L comes before libs that need it for instance...
6095968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test "$linkmode,$pass" = "lib,link"; then
6096968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	## FIXME: Find the place where the list is rebuilt in the wrong
6097968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	##        order, and fix it there properly
6098968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        tmp_deplibs=
6099968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	for deplib in $deplibs; do
6100968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  tmp_deplibs="$deplib $tmp_deplibs"
6101968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	done
6102968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	deplibs="$tmp_deplibs"
6103968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
6104968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6105968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test "$linkmode,$pass" = "lib,link" ||
6106968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	 test "$linkmode,$pass" = "prog,scan"; then
6107968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	libs="$deplibs"
6108968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	deplibs=
6109968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
6110968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test "$linkmode" = prog; then
6111968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $pass in
6112968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	dlopen) libs="$dlfiles" ;;
6113968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	dlpreopen) libs="$dlprefiles" ;;
6114968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	link)
6115968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  libs="$deplibs %DEPLIBS%"
6116968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
6117968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
6118968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
6119968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
6120968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test "$linkmode,$pass" = "lib,dlpreopen"; then
6121968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Collect and forward deplibs of preopened libtool libs
6122968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	for lib in $dlprefiles; do
6123968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Ignore non-libtool-libs
6124968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  dependency_libs=
6125968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_resolve_sysroot "$lib"
6126968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case $lib in
6127968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *.la)	func_source "$func_resolve_sysroot_result" ;;
6128968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
6129968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6130968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Collect preopened libtool deplibs, except any this library
6131968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # has declared as weak libs
6132968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  for deplib in $dependency_libs; do
6133968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_basename "$deplib"
6134968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold            deplib_base=$func_basename_result
6135968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    case " $weak_libs " in
6136968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *" $deplib_base "*) ;;
6137968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *) func_append deplibs " $deplib" ;;
6138968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    esac
6139968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  done
6140968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	done
6141968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	libs="$dlprefiles"
6142968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
6143968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test "$pass" = dlopen; then
6144968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Collect dlpreopened libraries
6145968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	save_deplibs="$deplibs"
6146968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	deplibs=
6147968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
6148968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6149968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      for deplib in $libs; do
6150968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	lib=
6151968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	found=no
6152968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $deplib in
6153968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
6154968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$linkmode,$pass" = "prog,link"; then
6155968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    compile_deplibs="$deplib $compile_deplibs"
6156968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    finalize_deplibs="$deplib $finalize_deplibs"
6157968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
6158968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append compiler_flags " $deplib"
6159968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "$linkmode" = lib ; then
6160968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		case "$new_inherited_linker_flags " in
6161968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    *" $deplib "*) ;;
6162968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6163968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		esac
6164968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
6165968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
6166968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
6167968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
6168968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	-l*)
6169968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$linkmode" != lib && test "$linkmode" != prog; then
6170968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_warning "\`-l' is ignored for archives/objects"
6171968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    continue
6172968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
6173968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_stripname '-l' '' "$deplib"
6174968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  name=$func_stripname_result
6175968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$linkmode" = lib; then
6176968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
6177968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
6178968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
6179968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
6180968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  for searchdir in $searchdirs; do
6181968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    for search_ext in .la $std_shrext .so .a; do
6182968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # Search the libtool library
6183968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      lib="$searchdir/lib${name}${search_ext}"
6184968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if test -f "$lib"; then
6185968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		if test "$search_ext" = ".la"; then
6186968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  found=yes
6187968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		else
6188968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  found=no
6189968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		fi
6190968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		break 2
6191968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
6192968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    done
6193968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  done
6194968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$found" != yes; then
6195968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # deplib doesn't seem to be a libtool library
6196968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "$linkmode,$pass" = "prog,link"; then
6197968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      compile_deplibs="$deplib $compile_deplibs"
6198968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      finalize_deplibs="$deplib $finalize_deplibs"
6199968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    else
6200968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      deplibs="$deplib $deplibs"
6201968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6202968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
6203968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    continue
6204968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else # deplib is a libtool library
6205968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
6206968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # We need to do some special things here, and not later.
6207968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6208968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case " $predeps $postdeps " in
6209968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *" $deplib "*)
6210968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		if func_lalib_p "$lib"; then
6211968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  library_names=
6212968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  old_library=
6213968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  func_source "$lib"
6214968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  for l in $old_library $library_names; do
6215968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    ll="$l"
6216968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  done
6217968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  if test "X$ll" = "X$old_library" ; then # only static version available
6218968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    found=no
6219968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    func_dirname "$lib" "" "."
6220968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    ladir="$func_dirname_result"
6221968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    lib=$ladir/$old_library
6222968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    if test "$linkmode,$pass" = "prog,link"; then
6223968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      compile_deplibs="$deplib $compile_deplibs"
6224968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      finalize_deplibs="$deplib $finalize_deplibs"
6225968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    else
6226968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      deplibs="$deplib $deplibs"
6227968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6228968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    fi
6229968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    continue
6230968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  fi
6231968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		fi
6232968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		;;
6233968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *) ;;
6234968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
6235968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
6236968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
6237968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;; # -l
6238968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*.ltframework)
6239968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$linkmode,$pass" = "prog,link"; then
6240968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    compile_deplibs="$deplib $compile_deplibs"
6241968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    finalize_deplibs="$deplib $finalize_deplibs"
6242968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
6243968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    deplibs="$deplib $deplibs"
6244968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "$linkmode" = lib ; then
6245968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		case "$new_inherited_linker_flags " in
6246968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    *" $deplib "*) ;;
6247968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6248968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		esac
6249968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
6250968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
6251968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
6252968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
6253968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	-L*)
6254968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case $linkmode in
6255968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  lib)
6256968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    deplibs="$deplib $deplibs"
6257968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    test "$pass" = conv && continue
6258968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    newdependency_libs="$deplib $newdependency_libs"
6259968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_stripname '-L' '' "$deplib"
6260968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_resolve_sysroot "$func_stripname_result"
6261968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append newlib_search_path " $func_resolve_sysroot_result"
6262968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
6263968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  prog)
6264968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "$pass" = conv; then
6265968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      deplibs="$deplib $deplibs"
6266968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      continue
6267968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
6268968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "$pass" = scan; then
6269968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      deplibs="$deplib $deplibs"
6270968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    else
6271968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      compile_deplibs="$deplib $compile_deplibs"
6272968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      finalize_deplibs="$deplib $finalize_deplibs"
6273968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
6274968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_stripname '-L' '' "$deplib"
6275968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_resolve_sysroot "$func_stripname_result"
6276968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append newlib_search_path " $func_resolve_sysroot_result"
6277968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
6278968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *)
6279968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_warning "\`-L' is ignored for archives/objects"
6280968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
6281968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac # linkmode
6282968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
6283968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;; # -L
6284968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	-R*)
6285968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$pass" = link; then
6286968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_stripname '-R' '' "$deplib"
6287968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_resolve_sysroot "$func_stripname_result"
6288968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    dir=$func_resolve_sysroot_result
6289968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Make sure the xrpath contains only unique directories.
6290968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    case "$xrpath " in
6291968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *" $dir "*) ;;
6292968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *) func_append xrpath " $dir" ;;
6293968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    esac
6294968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
6295968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  deplibs="$deplib $deplibs"
6296968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
6297968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
6298968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*.la)
6299968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_resolve_sysroot "$deplib"
6300968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  lib=$func_resolve_sysroot_result
6301968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
6302968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*.$libext)
6303968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$pass" = conv; then
6304968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    deplibs="$deplib $deplibs"
6305968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    continue
6306968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
6307968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case $linkmode in
6308968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  lib)
6309968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Linking convenience modules into shared libraries is allowed,
6310968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # but linking other static libraries is non-portable.
6311968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    case " $dlpreconveniencelibs " in
6312968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *" $deplib "*) ;;
6313968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *)
6314968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      valid_a_lib=no
6315968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case $deplibs_check_method in
6316968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		match_pattern*)
6317968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  set dummy $deplibs_check_method; shift
6318968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6319968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
6320968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    | $EGREP "$match_pattern_regex" > /dev/null; then
6321968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    valid_a_lib=yes
6322968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  fi
6323968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		;;
6324968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		pass_all)
6325968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  valid_a_lib=yes
6326968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		;;
6327968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
6328968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if test "$valid_a_lib" != yes; then
6329968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		echo
6330968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
6331968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		echo "*** I have the capability to make that library automatically link in when"
6332968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		echo "*** you link to this library.  But I can only do this if you have a"
6333968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		echo "*** shared version of the library, which you do not appear to have"
6334968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		echo "*** because the file extensions .$libext of this argument makes me believe"
6335968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		echo "*** that it is just a static archive that I should not use here."
6336968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      else
6337968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		echo
6338968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		$ECHO "*** Warning: Linking the shared library $output against the"
6339968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		$ECHO "*** static library $deplib is not portable!"
6340968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		deplibs="$deplib $deplibs"
6341968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
6342968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      ;;
6343968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    esac
6344968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    continue
6345968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
6346968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  prog)
6347968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "$pass" != link; then
6348968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      deplibs="$deplib $deplibs"
6349968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    else
6350968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      compile_deplibs="$deplib $compile_deplibs"
6351968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      finalize_deplibs="$deplib $finalize_deplibs"
6352968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
6353968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    continue
6354968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
6355968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac # linkmode
6356968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;; # *.$libext
6357968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*.lo | *.$objext)
6358968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$pass" = conv; then
6359968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    deplibs="$deplib $deplibs"
6360968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  elif test "$linkmode" = prog; then
6361968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
6362968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # If there is no dlopen support or we're linking statically,
6363968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # we need to preload.
6364968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_append newdlprefiles " $deplib"
6365968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      compile_deplibs="$deplib $compile_deplibs"
6366968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      finalize_deplibs="$deplib $finalize_deplibs"
6367968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    else
6368968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_append newdlfiles " $deplib"
6369968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
6370968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
6371968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
6372968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
6373968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	%DEPLIBS%)
6374968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  alldeplibs=yes
6375968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
6376968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
6377968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac # case $deplib
6378968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6379968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$found" = yes || test -f "$lib"; then :
6380968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	else
6381968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
6382968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
6383968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6384968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Check to see that this really is a libtool archive.
6385968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_lalib_unsafe_p "$lib" \
6386968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  || func_fatal_error "\`$lib' is not a valid libtool archive"
6387968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6388968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_dirname "$lib" "" "."
6389968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	ladir="$func_dirname_result"
6390968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6391968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	dlname=
6392968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	dlopen=
6393968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	dlpreopen=
6394968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	libdir=
6395968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	library_names=
6396968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	old_library=
6397968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	inherited_linker_flags=
6398968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# If the library was installed with an old release of libtool,
6399968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# it will not redefine variables installed, or shouldnotlink
6400968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	installed=yes
6401968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	shouldnotlink=no
6402968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	avoidtemprpath=
6403968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6404968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6405968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Read the .la file
6406968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_source "$lib"
6407968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6408968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Convert "-framework foo" to "foo.ltframework"
6409968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$inherited_linker_flags"; then
6410968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
6411968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
6412968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    case " $new_inherited_linker_flags " in
6413968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *" $tmp_inherited_linker_flag "*) ;;
6414968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
6415968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    esac
6416968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  done
6417968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
6418968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
6419968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$linkmode,$pass" = "lib,link" ||
6420968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	   test "$linkmode,$pass" = "prog,scan" ||
6421968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
6422968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  test -n "$dlopen" && func_append dlfiles " $dlopen"
6423968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
6424968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
6425968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6426968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$pass" = conv; then
6427968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Only check for convenience libraries
6428968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  deplibs="$lib $deplibs"
6429968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -z "$libdir"; then
6430968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test -z "$old_library"; then
6431968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_fatal_error "cannot find name of link library for \`$lib'"
6432968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
6433968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # It is a libtool convenience library, so add in its objects.
6434968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append convenience " $ladir/$objdir/$old_library"
6435968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append old_convenience " $ladir/$objdir/$old_library"
6436968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    tmp_libs=
6437968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    for deplib in $dependency_libs; do
6438968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      deplibs="$deplib $deplibs"
6439968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if $opt_preserve_dup_deps ; then
6440968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		case "$tmp_libs " in
6441968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		*" $deplib "*) func_append specialdeplibs " $deplib" ;;
6442968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		esac
6443968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
6444968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_append tmp_libs " $deplib"
6445968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    done
6446968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
6447968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_fatal_error "\`$lib' is not a convenience library"
6448968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
6449968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
6450968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi # $pass = conv
6451968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6452968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6453968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Get the name of the library we link against.
6454968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	linklib=
6455968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$old_library" &&
6456968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	   { test "$prefer_static_libs" = yes ||
6457968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	     test "$prefer_static_libs,$installed" = "built,no"; }; then
6458968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  linklib=$old_library
6459968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	else
6460968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  for l in $old_library $library_names; do
6461968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    linklib="$l"
6462968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  done
6463968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
6464968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -z "$linklib"; then
6465968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_fatal_error "cannot find name of link library for \`$lib'"
6466968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
6467968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6468968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# This library was specified with -dlopen.
6469968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$pass" = dlopen; then
6470968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -z "$libdir"; then
6471968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
6472968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
6473968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -z "$dlname" ||
6474968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	     test "$dlopen_support" != yes ||
6475968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	     test "$build_libtool_libs" = no; then
6476968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # If there is no dlname, no dlopen support or we're linking
6477968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # statically, we need to preload.  We also need to preload any
6478968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # dependent libraries so libltdl's deplib preloader doesn't
6479968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # bomb out in the load deplibs phase.
6480968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append dlprefiles " $lib $dependency_libs"
6481968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
6482968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append newdlfiles " $lib"
6483968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
6484968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
6485968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi # $pass = dlopen
6486968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6487968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# We need an absolute path.
6488968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $ladir in
6489968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
6490968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*)
6491968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  abs_ladir=`cd "$ladir" && pwd`
6492968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -z "$abs_ladir"; then
6493968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_warning "cannot determine absolute directory name of \`$ladir'"
6494968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_warning "passing it literally to the linker, although it might fail"
6495968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    abs_ladir="$ladir"
6496968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
6497968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
6498968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
6499968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_basename "$lib"
6500968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	laname="$func_basename_result"
6501968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6502968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Find the relevant object directory and library name.
6503968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "X$installed" = Xyes; then
6504968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6505968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_warning "library \`$lib' was moved."
6506968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    dir="$ladir"
6507968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    absdir="$abs_ladir"
6508968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    libdir="$abs_ladir"
6509968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
6510968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    dir="$lt_sysroot$libdir"
6511968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    absdir="$lt_sysroot$libdir"
6512968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
6513968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
6514968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	else
6515968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6516968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    dir="$ladir"
6517968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    absdir="$abs_ladir"
6518968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Remove this search path later
6519968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append notinst_path " $abs_ladir"
6520968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
6521968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    dir="$ladir/$objdir"
6522968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    absdir="$abs_ladir/$objdir"
6523968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Remove this search path later
6524968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append notinst_path " $abs_ladir"
6525968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
6526968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi # $installed = yes
6527968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_stripname 'lib' '.la' "$laname"
6528968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	name=$func_stripname_result
6529968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6530968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# This library was specified with -dlpreopen.
6531968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$pass" = dlpreopen; then
6532968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -z "$libdir" && test "$linkmode" = prog; then
6533968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
6534968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
6535968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case "$host" in
6536968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # special handling for platforms with PE-DLLs.
6537968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *cygwin* | *mingw* | *cegcc* )
6538968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # Linker will automatically link against shared library if both
6539968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # static and shared are present.  Therefore, ensure we extract
6540968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # symbols from the import library if a shared library is present
6541968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # (otherwise, the dlopen module name will be incorrect).  We do
6542968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # this by putting the import library name into $newdlprefiles.
6543968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # We recover the dlopen module name by 'saving' the la file
6544968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # name in a special purpose variable, and (later) extracting the
6545968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # dlname from the la file.
6546968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if test -n "$dlname"; then
6547968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        func_tr_sh "$dir/$linklib"
6548968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
6549968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        func_append newdlprefiles " $dir/$linklib"
6550968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      else
6551968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        func_append newdlprefiles " $dir/$old_library"
6552968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        # Keep a list of preopened convenience libraries to check
6553968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        # that they are being used correctly in the link pass.
6554968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        test -z "$libdir" && \
6555968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	          func_append dlpreconveniencelibs " $dir/$old_library"
6556968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
6557968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
6558968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    * )
6559968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # Prefer using a static library (so that no silly _DYNAMIC symbols
6560968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # are required to link).
6561968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if test -n "$old_library"; then
6562968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        func_append newdlprefiles " $dir/$old_library"
6563968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        # Keep a list of preopened convenience libraries to check
6564968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        # that they are being used correctly in the link pass.
6565968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        test -z "$libdir" && \
6566968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	          func_append dlpreconveniencelibs " $dir/$old_library"
6567968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # Otherwise, use the dlname, so that lt_dlopen finds it.
6568968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      elif test -n "$dlname"; then
6569968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        func_append newdlprefiles " $dir/$dlname"
6570968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      else
6571968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        func_append newdlprefiles " $dir/$linklib"
6572968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
6573968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
6574968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
6575968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi # $pass = dlpreopen
6576968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6577968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -z "$libdir"; then
6578968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Link the convenience library
6579968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$linkmode" = lib; then
6580968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    deplibs="$dir/$old_library $deplibs"
6581968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  elif test "$linkmode,$pass" = "prog,link"; then
6582968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    compile_deplibs="$dir/$old_library $compile_deplibs"
6583968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
6584968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
6585968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    deplibs="$lib $deplibs" # used for prog,scan pass
6586968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
6587968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
6588968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
6589968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6590968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6591968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$linkmode" = prog && test "$pass" != link; then
6592968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append newlib_search_path " $ladir"
6593968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  deplibs="$lib $deplibs"
6594968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6595968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  linkalldeplibs=no
6596968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
6597968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	     test "$build_libtool_libs" = no; then
6598968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    linkalldeplibs=yes
6599968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
6600968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6601968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  tmp_libs=
6602968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  for deplib in $dependency_libs; do
6603968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    case $deplib in
6604968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    -L*) func_stripname '-L' '' "$deplib"
6605968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	         func_resolve_sysroot "$func_stripname_result"
6606968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	         func_append newlib_search_path " $func_resolve_sysroot_result"
6607968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		 ;;
6608968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    esac
6609968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Need to link against all dependency_libs?
6610968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "$linkalldeplibs" = yes; then
6611968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      deplibs="$deplib $deplibs"
6612968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    else
6613968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # Need to hardcode shared library paths
6614968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # or/and link against static libraries
6615968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      newdependency_libs="$deplib $newdependency_libs"
6616968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
6617968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if $opt_preserve_dup_deps ; then
6618968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case "$tmp_libs " in
6619968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6620968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
6621968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
6622968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append tmp_libs " $deplib"
6623968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  done # for deplib
6624968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  continue
6625968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi # $linkmode = prog...
6626968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6627968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$linkmode,$pass" = "prog,link"; then
6628968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -n "$library_names" &&
6629968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	     { { test "$prefer_static_libs" = no ||
6630968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
6631968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	       test -z "$old_library"; }; then
6632968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # We need to hardcode the library path
6633968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
6634968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # Make sure the rpath contains only unique directories.
6635968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case "$temp_rpath:" in
6636968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *"$absdir:"*) ;;
6637968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *) func_append temp_rpath "$absdir:" ;;
6638968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
6639968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
6640968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6641968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Hardcode the library path.
6642968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Skip directories that are in the system default run-time
6643968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # search path.
6644968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    case " $sys_lib_dlsearch_path " in
6645968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *" $absdir "*) ;;
6646968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *)
6647968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case "$compile_rpath " in
6648968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *" $absdir "*) ;;
6649968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *) func_append compile_rpath " $absdir" ;;
6650968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
6651968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      ;;
6652968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    esac
6653968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    case " $sys_lib_dlsearch_path " in
6654968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *" $libdir "*) ;;
6655968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *)
6656968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case "$finalize_rpath " in
6657968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *" $libdir "*) ;;
6658968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *) func_append finalize_rpath " $libdir" ;;
6659968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
6660968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      ;;
6661968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    esac
6662968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi # $linkmode,$pass = prog,link...
6663968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6664968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$alldeplibs" = yes &&
6665968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	     { test "$deplibs_check_method" = pass_all ||
6666968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	       { test "$build_libtool_libs" = yes &&
6667968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		 test -n "$library_names"; }; }; then
6668968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # We only need to search for static libraries
6669968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    continue
6670968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
6671968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
6672968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6673968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	link_static=no # Whether the deplib will be linked statically
6674968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	use_static_libs=$prefer_static_libs
6675968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$use_static_libs" = built && test "$installed" = yes; then
6676968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  use_static_libs=no
6677968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
6678968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$library_names" &&
6679968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
6680968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case $host in
6681968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *cygwin* | *mingw* | *cegcc*)
6682968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # No point in relinking DLLs because paths are not encoded
6683968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_append notinst_deplibs " $lib"
6684968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      need_relink=no
6685968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
6686968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *)
6687968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "$installed" = no; then
6688968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_append notinst_deplibs " $lib"
6689968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      need_relink=yes
6690968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
6691968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
6692968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
6693968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # This is a shared library
6694968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6695968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Warn about portability, can't link against -module's on some
6696968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # systems (darwin).  Don't bleat about dlopened modules though!
6697968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  dlopenmodule=""
6698968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  for dlpremoduletest in $dlprefiles; do
6699968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "X$dlpremoduletest" = "X$lib"; then
6700968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      dlopenmodule="$dlpremoduletest"
6701968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      break
6702968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
6703968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  done
6704968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
6705968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    echo
6706968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "$linkmode" = prog; then
6707968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
6708968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    else
6709968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
6710968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
6711968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    $ECHO "*** $linklib is not portable!"
6712968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
6713968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$linkmode" = lib &&
6714968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	     test "$hardcode_into_libs" = yes; then
6715968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Hardcode the library path.
6716968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Skip directories that are in the system default run-time
6717968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # search path.
6718968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    case " $sys_lib_dlsearch_path " in
6719968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *" $absdir "*) ;;
6720968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *)
6721968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case "$compile_rpath " in
6722968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *" $absdir "*) ;;
6723968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *) func_append compile_rpath " $absdir" ;;
6724968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
6725968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      ;;
6726968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    esac
6727968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    case " $sys_lib_dlsearch_path " in
6728968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *" $libdir "*) ;;
6729968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *)
6730968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case "$finalize_rpath " in
6731968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *" $libdir "*) ;;
6732968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *) func_append finalize_rpath " $libdir" ;;
6733968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
6734968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      ;;
6735968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    esac
6736968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
6737968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6738968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -n "$old_archive_from_expsyms_cmds"; then
6739968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # figure out the soname
6740968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    set dummy $library_names
6741968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    shift
6742968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    realname="$1"
6743968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    shift
6744968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    libname=`eval "\\$ECHO \"$libname_spec\""`
6745968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # use dlname if we got it. it's perfectly good, no?
6746968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test -n "$dlname"; then
6747968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      soname="$dlname"
6748968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    elif test -n "$soname_spec"; then
6749968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # bleh windows
6750968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case $host in
6751968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *cygwin* | mingw* | *cegcc*)
6752968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        func_arith $current - $age
6753968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		major=$func_arith_result
6754968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		versuffix="-$major"
6755968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		;;
6756968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
6757968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      eval soname=\"$soname_spec\"
6758968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    else
6759968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      soname="$realname"
6760968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
6761968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6762968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Make a new name for the extract_expsyms_cmds to use
6763968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    soroot="$soname"
6764968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_basename "$soroot"
6765968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    soname="$func_basename_result"
6766968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_stripname 'lib' '.dll' "$soname"
6767968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    newlib=libimp-$func_stripname_result.a
6768968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6769968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # If the library has no export list, then create one now
6770968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test -f "$output_objdir/$soname-def"; then :
6771968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    else
6772968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_verbose "extracting exported symbol list from \`$soname'"
6773968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
6774968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
6775968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6776968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Create $newlib
6777968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test -f "$output_objdir/$newlib"; then :; else
6778968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_verbose "generating import library for \`$soname'"
6779968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
6780968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
6781968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # make sure the library variables are pointing to the new library
6782968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    dir=$output_objdir
6783968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    linklib=$newlib
6784968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi # test -n "$old_archive_from_expsyms_cmds"
6785968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6786968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
6787968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    add_shlibpath=
6788968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    add_dir=
6789968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    add=
6790968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    lib_linked=yes
6791968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    case $hardcode_action in
6792968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    immediate | unsupported)
6793968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if test "$hardcode_direct" = no; then
6794968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		add="$dir/$linklib"
6795968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		case $host in
6796968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
6797968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
6798968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
6799968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    *-*-unixware7*) add_dir="-L$dir" ;;
6800968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  *-*-darwin* )
6801968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    # if the lib is a (non-dlopened) module then we can not
6802968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    # link against it, someone is ignoring the earlier warnings
6803968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    if /usr/bin/file -L $add 2> /dev/null |
6804968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			 $GREP ": [^:]* bundle" >/dev/null ; then
6805968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      if test "X$dlopenmodule" != "X$lib"; then
6806968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
6807968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			if test -z "$old_library" ; then
6808968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			  echo
6809968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			  echo "*** And there doesn't seem to be a static archive available"
6810968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			  echo "*** The link will probably fail, sorry"
6811968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			else
6812968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			  add="$dir/$old_library"
6813968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			fi
6814968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      elif test -n "$old_library"; then
6815968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			add="$dir/$old_library"
6816968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      fi
6817968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    fi
6818968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		esac
6819968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      elif test "$hardcode_minus_L" = no; then
6820968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		case $host in
6821968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		*-*-sunos*) add_shlibpath="$dir" ;;
6822968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		esac
6823968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		add_dir="-L$dir"
6824968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		add="-l$name"
6825968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      elif test "$hardcode_shlibpath_var" = no; then
6826968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		add_shlibpath="$dir"
6827968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		add="-l$name"
6828968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      else
6829968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		lib_linked=no
6830968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
6831968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      ;;
6832968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    relink)
6833968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if test "$hardcode_direct" = yes &&
6834968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	         test "$hardcode_direct_absolute" = no; then
6835968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		add="$dir/$linklib"
6836968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      elif test "$hardcode_minus_L" = yes; then
6837968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		add_dir="-L$dir"
6838968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		# Try looking first in the location we're being installed to.
6839968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		if test -n "$inst_prefix_dir"; then
6840968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  case $libdir in
6841968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    [\\/]*)
6842968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      func_append add_dir " -L$inst_prefix_dir$libdir"
6843968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      ;;
6844968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  esac
6845968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		fi
6846968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		add="-l$name"
6847968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      elif test "$hardcode_shlibpath_var" = yes; then
6848968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		add_shlibpath="$dir"
6849968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		add="-l$name"
6850968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      else
6851968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		lib_linked=no
6852968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
6853968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      ;;
6854968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *) lib_linked=no ;;
6855968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    esac
6856968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6857968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "$lib_linked" != yes; then
6858968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_fatal_configuration "unsupported hardcode properties"
6859968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
6860968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6861968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test -n "$add_shlibpath"; then
6862968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case :$compile_shlibpath: in
6863968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *":$add_shlibpath:"*) ;;
6864968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
6865968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
6866968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
6867968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "$linkmode" = prog; then
6868968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
6869968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
6870968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    else
6871968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6872968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      test -n "$add" && deplibs="$add $deplibs"
6873968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if test "$hardcode_direct" != yes &&
6874968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		 test "$hardcode_minus_L" != yes &&
6875968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		 test "$hardcode_shlibpath_var" = yes; then
6876968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		case :$finalize_shlibpath: in
6877968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		*":$libdir:"*) ;;
6878968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		*) func_append finalize_shlibpath "$libdir:" ;;
6879968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		esac
6880968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
6881968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
6882968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
6883968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6884968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
6885968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    add_shlibpath=
6886968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    add_dir=
6887968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    add=
6888968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Finalize command for both is simple: just hardcode it.
6889968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "$hardcode_direct" = yes &&
6890968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	       test "$hardcode_direct_absolute" = no; then
6891968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      add="$libdir/$linklib"
6892968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    elif test "$hardcode_minus_L" = yes; then
6893968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      add_dir="-L$libdir"
6894968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      add="-l$name"
6895968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    elif test "$hardcode_shlibpath_var" = yes; then
6896968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case :$finalize_shlibpath: in
6897968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *":$libdir:"*) ;;
6898968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *) func_append finalize_shlibpath "$libdir:" ;;
6899968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
6900968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      add="-l$name"
6901968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    elif test "$hardcode_automatic" = yes; then
6902968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if test -n "$inst_prefix_dir" &&
6903968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
6904968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		add="$inst_prefix_dir$libdir/$linklib"
6905968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      else
6906968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		add="$libdir/$linklib"
6907968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
6908968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    else
6909968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # We cannot seem to hardcode it, guess we'll fake it.
6910968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      add_dir="-L$libdir"
6911968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # Try looking first in the location we're being installed to.
6912968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if test -n "$inst_prefix_dir"; then
6913968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		case $libdir in
6914968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  [\\/]*)
6915968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    func_append add_dir " -L$inst_prefix_dir$libdir"
6916968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    ;;
6917968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		esac
6918968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
6919968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      add="-l$name"
6920968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
6921968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6922968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "$linkmode" = prog; then
6923968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
6924968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
6925968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    else
6926968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6927968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      test -n "$add" && deplibs="$add $deplibs"
6928968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
6929968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
6930968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	elif test "$linkmode" = prog; then
6931968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Here we assume that one of hardcode_direct or hardcode_minus_L
6932968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # is not unsupported.  This is valid on all known static and
6933968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # shared platforms.
6934968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$hardcode_direct" != unsupported; then
6935968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    test -n "$old_library" && linklib="$old_library"
6936968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    compile_deplibs="$dir/$linklib $compile_deplibs"
6937968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
6938968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
6939968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    compile_deplibs="-l$name -L$dir $compile_deplibs"
6940968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
6941968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
6942968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	elif test "$build_libtool_libs" = yes; then
6943968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Not a shared library
6944968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$deplibs_check_method" != pass_all; then
6945968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # We're trying link a shared library against a static one
6946968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # but the system doesn't support it.
6947968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6948968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Just print a warning and add the library to dependency_libs so
6949968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # that the program can be linked against the static library.
6950968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    echo
6951968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
6952968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    echo "*** I have the capability to make that library automatically link in when"
6953968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    echo "*** you link to this library.  But I can only do this if you have a"
6954968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    echo "*** shared version of the library, which you do not appear to have."
6955968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "$module" = yes; then
6956968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      echo "*** But as you try to build a module library, libtool will still create "
6957968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      echo "*** a static module, that should work as long as the dlopening application"
6958968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
6959968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if test -z "$global_symbol_pipe"; then
6960968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		echo
6961968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		echo "*** However, this would only work if libtool was able to extract symbol"
6962968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
6963968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		echo "*** not find such a program.  So, this module is probably useless."
6964968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		echo "*** \`nm' from GNU binutils and a full rebuild may help."
6965968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
6966968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if test "$build_old_libs" = no; then
6967968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		build_libtool_libs=module
6968968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		build_old_libs=yes
6969968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      else
6970968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		build_libtool_libs=no
6971968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
6972968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
6973968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
6974968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    deplibs="$dir/$old_library $deplibs"
6975968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    link_static=yes
6976968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
6977968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi # link shared/static library?
6978968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
6979968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$linkmode" = lib; then
6980968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -n "$dependency_libs" &&
6981968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	     { test "$hardcode_into_libs" != yes ||
6982968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	       test "$build_old_libs" = yes ||
6983968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	       test "$link_static" = yes; }; then
6984968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Extract -R from dependency_libs
6985968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    temp_deplibs=
6986968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    for libdir in $dependency_libs; do
6987968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case $libdir in
6988968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      -R*) func_stripname '-R' '' "$libdir"
6989968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	           temp_xrpath=$func_stripname_result
6990968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		   case " $xrpath " in
6991968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		   *" $temp_xrpath "*) ;;
6992968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		   *) func_append xrpath " $temp_xrpath";;
6993968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		   esac;;
6994968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *) func_append temp_deplibs " $libdir";;
6995968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
6996968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    done
6997968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    dependency_libs="$temp_deplibs"
6998968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
6999968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7000968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append newlib_search_path " $absdir"
7001968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Link against this library
7002968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
7003968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # ... and its dependency_libs
7004968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  tmp_libs=
7005968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  for deplib in $dependency_libs; do
7006968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    newdependency_libs="$deplib $newdependency_libs"
7007968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    case $deplib in
7008968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold              -L*) func_stripname '-L' '' "$deplib"
7009968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold                   func_resolve_sysroot "$func_stripname_result";;
7010968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold              *) func_resolve_sysroot "$deplib" ;;
7011968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold            esac
7012968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if $opt_preserve_dup_deps ; then
7013968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case "$tmp_libs " in
7014968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *" $func_resolve_sysroot_result "*)
7015968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
7016968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
7017968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
7018968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append tmp_libs " $func_resolve_sysroot_result"
7019968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  done
7020968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7021968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$link_all_deplibs" != no; then
7022968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Add the search paths of all dependency libraries
7023968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    for deplib in $dependency_libs; do
7024968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      path=
7025968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case $deplib in
7026968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      -L*) path="$deplib" ;;
7027968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *.la)
7028968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        func_resolve_sysroot "$deplib"
7029968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        deplib=$func_resolve_sysroot_result
7030968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        func_dirname "$deplib" "" "."
7031968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		dir=$func_dirname_result
7032968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		# We need an absolute path.
7033968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		case $dir in
7034968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
7035968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		*)
7036968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  absdir=`cd "$dir" && pwd`
7037968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  if test -z "$absdir"; then
7038968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    func_warning "cannot determine absolute directory name of \`$dir'"
7039968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    absdir="$dir"
7040968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  fi
7041968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  ;;
7042968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		esac
7043968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		if $GREP "^installed=no" $deplib > /dev/null; then
7044968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		case $host in
7045968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		*-*-darwin*)
7046968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  depdepl=
7047968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
7048968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  if test -n "$deplibrary_names" ; then
7049968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    for tmp in $deplibrary_names ; do
7050968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      depdepl=$tmp
7051968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    done
7052968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    if test -f "$absdir/$objdir/$depdepl" ; then
7053968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      depdepl="$absdir/$objdir/$depdepl"
7054968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
7055968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold                      if test -z "$darwin_install_name"; then
7056968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
7057968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold                      fi
7058968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
7059968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
7060968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      path=
7061968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    fi
7062968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  fi
7063968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  ;;
7064968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		*)
7065968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  path="-L$absdir/$objdir"
7066968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  ;;
7067968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		esac
7068968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		else
7069968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
7070968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  test -z "$libdir" && \
7071968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    func_fatal_error "\`$deplib' is not a valid libtool archive"
7072968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  test "$absdir" != "$libdir" && \
7073968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    func_warning "\`$deplib' seems to be moved"
7074968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7075968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  path="-L$absdir"
7076968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		fi
7077968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		;;
7078968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
7079968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case " $deplibs " in
7080968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *" $path "*) ;;
7081968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *) deplibs="$path $deplibs" ;;
7082968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
7083968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    done
7084968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi # link_all_deplibs != no
7085968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi # linkmode = lib
7086968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      done # for deplib in $libs
7087968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test "$pass" = link; then
7088968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$linkmode" = "prog"; then
7089968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
7090968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
7091968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	else
7092968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7093968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
7094968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
7095968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      dependency_libs="$newdependency_libs"
7096968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test "$pass" = dlpreopen; then
7097968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Link the dlpreopened libraries before other libraries
7098968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	for deplib in $save_deplibs; do
7099968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  deplibs="$deplib $deplibs"
7100968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	done
7101968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
7102968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test "$pass" != dlopen; then
7103968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$pass" != conv; then
7104968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Make sure lib_search_path contains only unique directories.
7105968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  lib_search_path=
7106968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  for dir in $newlib_search_path; do
7107968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    case "$lib_search_path " in
7108968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *" $dir "*) ;;
7109968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *) func_append lib_search_path " $dir" ;;
7110968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    esac
7111968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  done
7112968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  newlib_search_path=
7113968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
7114968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7115968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$linkmode,$pass" != "prog,link"; then
7116968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  vars="deplibs"
7117968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	else
7118968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  vars="compile_deplibs finalize_deplibs"
7119968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
7120968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	for var in $vars dependency_libs; do
7121968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Add libraries to $var in reverse order
7122968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  eval tmp_libs=\"\$$var\"
7123968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  new_libs=
7124968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  for deplib in $tmp_libs; do
7125968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # FIXME: Pedantically, this is the right thing to do, so
7126968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    #        that some nasty dependency loop isn't accidentally
7127968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    #        broken:
7128968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    #new_libs="$deplib $new_libs"
7129968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Pragmatically, this seems to cause very few problems in
7130968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # practice:
7131968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    case $deplib in
7132968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    -L*) new_libs="$deplib $new_libs" ;;
7133968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    -R*) ;;
7134968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *)
7135968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # And here is the reason: when a library appears more
7136968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # than once as an explicit dependence of a library, or
7137968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # is implicitly linked in more than once by the
7138968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # compiler, it is considered special, and multiple
7139968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # occurrences thereof are not removed.  Compare this
7140968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # with having the same library being listed as a
7141968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # dependency of multiple other libraries: in this case,
7142968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # we know (pedantically, we assume) the library does not
7143968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # need to be listed more than once, so we keep only the
7144968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # last copy.  This is not always right, but it is rare
7145968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # enough that we require users that really mean to play
7146968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # such unportable linking tricks to link the library
7147968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # using -Wl,-lname, so that libtool does not consider it
7148968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # for duplicate removal.
7149968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case " $specialdeplibs " in
7150968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
7151968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *)
7152968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		case " $new_libs " in
7153968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		*" $deplib "*) ;;
7154968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		*) new_libs="$deplib $new_libs" ;;
7155968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		esac
7156968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		;;
7157968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
7158968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      ;;
7159968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    esac
7160968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  done
7161968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  tmp_libs=
7162968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  for deplib in $new_libs; do
7163968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    case $deplib in
7164968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    -L*)
7165968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case " $tmp_libs " in
7166968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *" $deplib "*) ;;
7167968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *) func_append tmp_libs " $deplib" ;;
7168968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
7169968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      ;;
7170968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *) func_append tmp_libs " $deplib" ;;
7171968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    esac
7172968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  done
7173968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  eval $var=\"$tmp_libs\"
7174968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	done # for var
7175968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
7176968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Last step: remove runtime libs from dependency_libs
7177968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # (they stay in deplibs)
7178968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      tmp_libs=
7179968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      for i in $dependency_libs ; do
7180968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case " $predeps $postdeps $compiler_lib_search_path " in
7181968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*" $i "*)
7182968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  i=""
7183968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
7184968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
7185968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$i" ; then
7186968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append tmp_libs " $i"
7187968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
7188968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      done
7189968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      dependency_libs=$tmp_libs
7190968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    done # for pass
7191968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test "$linkmode" = prog; then
7192968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      dlfiles="$newdlfiles"
7193968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
7194968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    if test "$linkmode" = prog || test "$linkmode" = lib; then
7195968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      dlprefiles="$newdlprefiles"
7196968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    fi
7197968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7198968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    case $linkmode in
7199968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    oldlib)
7200968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
7201968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_warning "\`-dlopen' is ignored for archives"
7202968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
7203968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7204968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      case " $deplibs" in
7205968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *\ -l* | *\ -L*)
7206968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_warning "\`-l' and \`-L' are ignored for archives" ;;
7207968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      esac
7208968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7209968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      test -n "$rpath" && \
7210968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_warning "\`-rpath' is ignored for archives"
7211968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7212968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      test -n "$xrpath" && \
7213968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_warning "\`-R' is ignored for archives"
7214968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7215968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      test -n "$vinfo" && \
7216968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_warning "\`-version-info/-version-number' is ignored for archives"
7217968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7218968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      test -n "$release" && \
7219968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_warning "\`-release' is ignored for archives"
7220968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7221968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      test -n "$export_symbols$export_symbols_regex" && \
7222968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_warning "\`-export-symbols' is ignored for archives"
7223968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7224968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Now set the variables for building old libraries.
7225968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      build_libtool_libs=no
7226968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      oldlibs="$output"
7227968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_append objs "$old_deplibs"
7228968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      ;;
7229968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7230968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    lib)
7231968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Make sure we only generate libraries of the form `libNAME.la'.
7232968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      case $outputname in
7233968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      lib*)
7234968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_stripname 'lib' '.la' "$outputname"
7235968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	name=$func_stripname_result
7236968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	eval shared_ext=\"$shrext_cmds\"
7237968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	eval libname=\"$libname_spec\"
7238968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
7239968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *)
7240968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	test "$module" = no && \
7241968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
7242968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7243968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$need_lib_prefix" != no; then
7244968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Add the "lib" prefix for modules if required
7245968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_stripname '' '.la' "$outputname"
7246968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  name=$func_stripname_result
7247968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  eval shared_ext=\"$shrext_cmds\"
7248968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  eval libname=\"$libname_spec\"
7249968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	else
7250968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_stripname '' '.la' "$outputname"
7251968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  libname=$func_stripname_result
7252968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
7253968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
7254968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      esac
7255968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7256968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$objs"; then
7257968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$deplibs_check_method" != pass_all; then
7258968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
7259968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	else
7260968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  echo
7261968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
7262968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  $ECHO "*** objects $objs is not portable!"
7263968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append libobjs " $objs"
7264968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
7265968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
7266968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7267968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      test "$dlself" != no && \
7268968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_warning "\`-dlopen self' is ignored for libtool libraries"
7269968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7270968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      set dummy $rpath
7271968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      shift
7272968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      test "$#" -gt 1 && \
7273968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_warning "ignoring multiple \`-rpath's for a libtool library"
7274968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7275968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      install_libdir="$1"
7276968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7277968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      oldlibs=
7278968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -z "$rpath"; then
7279968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$build_libtool_libs" = yes; then
7280968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Building a libtool convenience library.
7281968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Some compilers have problems with a `.al' extension so
7282968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # convenience libraries should have the same extension an
7283968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # archive normally would.
7284968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
7285968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  build_libtool_libs=convenience
7286968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  build_old_libs=yes
7287968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
7288968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7289968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	test -n "$vinfo" && \
7290968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
7291968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7292968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	test -n "$release" && \
7293968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_warning "\`-release' is ignored for convenience libraries"
7294968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      else
7295968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7296968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Parse the version information argument.
7297968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	save_ifs="$IFS"; IFS=':'
7298968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	set dummy $vinfo 0 0 0
7299968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	shift
7300968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	IFS="$save_ifs"
7301968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7302968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	test -n "$7" && \
7303968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_fatal_help "too many parameters to \`-version-info'"
7304968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7305968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# convert absolute version numbers to libtool ages
7306968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# this retains compatibility with .la files and attempts
7307968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# to make the code below a bit more comprehensible
7308968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7309968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $vinfo_number in
7310968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	yes)
7311968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  number_major="$1"
7312968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  number_minor="$2"
7313968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  number_revision="$3"
7314968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  #
7315968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # There are really only two kinds -- those that
7316968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # use the current revision as the major version
7317968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # and those that subtract age and use age as
7318968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # a minor version.  But, then there is irix
7319968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # which has an extra 1 added just for fun
7320968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  #
7321968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case $version_type in
7322968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  darwin|linux|osf|windows|none)
7323968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_arith $number_major + $number_minor
7324968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    current=$func_arith_result
7325968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    age="$number_minor"
7326968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    revision="$number_revision"
7327968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
7328968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  freebsd-aout|freebsd-elf|qnx|sunos)
7329968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    current="$number_major"
7330968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    revision="$number_minor"
7331968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    age="0"
7332968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
7333968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  irix|nonstopux)
7334968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_arith $number_major + $number_minor
7335968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    current=$func_arith_result
7336968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    age="$number_minor"
7337968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    revision="$number_minor"
7338968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    lt_irix_increment=no
7339968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
7340968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *)
7341968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_fatal_configuration "$modename: unknown library version type \`$version_type'"
7342968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
7343968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
7344968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
7345968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	no)
7346968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  current="$1"
7347968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  revision="$2"
7348968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  age="$3"
7349968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
7350968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
7351968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7352968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Check that each of the things are valid numbers.
7353968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $current in
7354968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	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]) ;;
7355968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*)
7356968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_error "CURRENT \`$current' must be a nonnegative integer"
7357968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_fatal_error "\`$vinfo' is not valid version information"
7358968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
7359968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
7360968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7361968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $revision in
7362968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	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]) ;;
7363968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*)
7364968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_error "REVISION \`$revision' must be a nonnegative integer"
7365968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_fatal_error "\`$vinfo' is not valid version information"
7366968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
7367968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
7368968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7369968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $age in
7370968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	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]) ;;
7371968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*)
7372968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_error "AGE \`$age' must be a nonnegative integer"
7373968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_fatal_error "\`$vinfo' is not valid version information"
7374968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
7375968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
7376968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7377968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$age" -gt "$current"; then
7378968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
7379968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_fatal_error "\`$vinfo' is not valid version information"
7380968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
7381968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7382968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Calculate the version variables.
7383968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	major=
7384968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	versuffix=
7385968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	verstring=
7386968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $version_type in
7387968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	none) ;;
7388968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7389968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	darwin)
7390968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Like Linux, but with the current version available in
7391968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # verstring for coding it into the library header
7392968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_arith $current - $age
7393968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  major=.$func_arith_result
7394968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  versuffix="$major.$age.$revision"
7395968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Darwin ld doesn't like 0 for these options...
7396968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_arith $current + 1
7397968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  minor_current=$func_arith_result
7398968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
7399968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
7400968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
7401968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7402968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	freebsd-aout)
7403968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  major=".$current"
7404968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  versuffix=".$current.$revision";
7405968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
7406968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7407968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	freebsd-elf)
7408968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  major=".$current"
7409968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  versuffix=".$current"
7410968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
7411968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7412968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	irix | nonstopux)
7413968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "X$lt_irix_increment" = "Xno"; then
7414968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_arith $current - $age
7415968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
7416968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_arith $current - $age + 1
7417968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
7418968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  major=$func_arith_result
7419968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7420968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case $version_type in
7421968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    nonstopux) verstring_prefix=nonstopux ;;
7422968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *)         verstring_prefix=sgi ;;
7423968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
7424968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  verstring="$verstring_prefix$major.$revision"
7425968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7426968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Add in all the interfaces that we are compatible with.
7427968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  loop=$revision
7428968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  while test "$loop" -ne 0; do
7429968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_arith $revision - $loop
7430968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    iface=$func_arith_result
7431968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_arith $loop - 1
7432968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    loop=$func_arith_result
7433968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    verstring="$verstring_prefix$major.$iface:$verstring"
7434968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  done
7435968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7436968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Before this point, $major must not contain `.'.
7437968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  major=.$major
7438968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  versuffix="$major.$revision"
7439968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
7440968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7441968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	linux)
7442968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_arith $current - $age
7443968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  major=.$func_arith_result
7444968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  versuffix="$major.$age.$revision"
7445968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
7446968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7447968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	osf)
7448968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_arith $current - $age
7449968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  major=.$func_arith_result
7450968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  versuffix=".$current.$age.$revision"
7451968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  verstring="$current.$age.$revision"
7452968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7453968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Add in all the interfaces that we are compatible with.
7454968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  loop=$age
7455968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  while test "$loop" -ne 0; do
7456968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_arith $current - $loop
7457968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    iface=$func_arith_result
7458968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_arith $loop - 1
7459968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    loop=$func_arith_result
7460968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    verstring="$verstring:${iface}.0"
7461968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  done
7462968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7463968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Make executables depend on our current version.
7464968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append verstring ":${current}.0"
7465968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
7466968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7467968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	qnx)
7468968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  major=".$current"
7469968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  versuffix=".$current"
7470968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
7471968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7472968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	sunos)
7473968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  major=".$current"
7474968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  versuffix=".$current.$revision"
7475968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
7476968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7477968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	windows)
7478968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Use '-' rather than '.', since we only want one
7479968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # extension on DOS 8.3 filesystems.
7480968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_arith $current - $age
7481968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  major=$func_arith_result
7482968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  versuffix="-$major"
7483968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
7484968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7485968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*)
7486968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_fatal_configuration "unknown library version type \`$version_type'"
7487968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
7488968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
7489968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7490968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Clear the version info if we defaulted, and they specified a release.
7491968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -z "$vinfo" && test -n "$release"; then
7492968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  major=
7493968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case $version_type in
7494968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  darwin)
7495968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # we can't check for "0.0" in archive_cmds due to quoting
7496968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # problems, so we reset it completely
7497968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    verstring=
7498968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
7499968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *)
7500968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    verstring="0.0"
7501968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
7502968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
7503968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$need_version" = no; then
7504968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    versuffix=
7505968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
7506968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    versuffix=".0.0"
7507968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
7508968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
7509968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7510968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Remove version info from name if versioning should be avoided
7511968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$avoid_version" = yes && test "$need_version" = no; then
7512968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  major=
7513968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  versuffix=
7514968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  verstring=""
7515968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
7516968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7517968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Check to see if the archive will have undefined symbols.
7518968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$allow_undefined" = yes; then
7519968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$allow_undefined_flag" = unsupported; then
7520968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_warning "undefined symbols not allowed in $host shared libraries"
7521968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    build_libtool_libs=no
7522968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    build_old_libs=yes
7523968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
7524968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	else
7525968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Don't allow undefined symbols.
7526968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  allow_undefined_flag="$no_undefined_flag"
7527968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
7528968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7529968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
7530968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7531968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_generate_dlsyms "$libname" "$libname" "yes"
7532968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_append libobjs " $symfileobj"
7533968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      test "X$libobjs" = "X " && libobjs=
7534968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7535968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test "$opt_mode" != relink; then
7536968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Remove our outputs, but don't remove object files since they
7537968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# may have been created when compiling PIC objects.
7538968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	removelist=
7539968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	tempremovelist=`$ECHO "$output_objdir/*"`
7540968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	for p in $tempremovelist; do
7541968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case $p in
7542968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *.$objext | *.gcno)
7543968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	       ;;
7544968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
7545968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	       if test "X$precious_files_regex" != "X"; then
7546968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
7547968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		 then
7548968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		   continue
7549968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		 fi
7550968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	       fi
7551968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	       func_append removelist " $p"
7552968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	       ;;
7553968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *) ;;
7554968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
7555968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	done
7556968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	test -n "$removelist" && \
7557968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_show_eval "${RM}r \$removelist"
7558968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
7559968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7560968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Now set the variables for building old libraries.
7561968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
7562968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_append oldlibs " $output_objdir/$libname.$libext"
7563968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7564968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Transform .lo files to .o files.
7565968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
7566968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
7567968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7568968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Eliminate all temporary directories.
7569968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      #for path in $notinst_path; do
7570968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
7571968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
7572968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
7573968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      #done
7574968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7575968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$xrpath"; then
7576968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# If the user specified any rpath flags, then add them.
7577968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	temp_xrpath=
7578968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	for libdir in $xrpath; do
7579968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_replace_sysroot "$libdir"
7580968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append temp_xrpath " -R$func_replace_sysroot_result"
7581968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case "$finalize_rpath " in
7582968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *" $libdir "*) ;;
7583968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *) func_append finalize_rpath " $libdir" ;;
7584968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
7585968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	done
7586968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
7587968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  dependency_libs="$temp_xrpath $dependency_libs"
7588968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
7589968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
7590968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7591968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Make sure dlfiles contains only unique files that won't be dlpreopened
7592968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      old_dlfiles="$dlfiles"
7593968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      dlfiles=
7594968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      for lib in $old_dlfiles; do
7595968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case " $dlprefiles $dlfiles " in
7596968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*" $lib "*) ;;
7597968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*) func_append dlfiles " $lib" ;;
7598968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
7599968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      done
7600968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7601968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Make sure dlprefiles contains only unique files
7602968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      old_dlprefiles="$dlprefiles"
7603968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      dlprefiles=
7604968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      for lib in $old_dlprefiles; do
7605968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case "$dlprefiles " in
7606968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*" $lib "*) ;;
7607968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*) func_append dlprefiles " $lib" ;;
7608968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
7609968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      done
7610968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7611968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test "$build_libtool_libs" = yes; then
7612968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$rpath"; then
7613968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case $host in
7614968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
7615968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # these systems don't actually have a c library (as such)!
7616968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
7617968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *-*-rhapsody* | *-*-darwin1.[012])
7618968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Rhapsody C library is in the System framework
7619968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append deplibs " System.ltframework"
7620968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
7621968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *-*-netbsd*)
7622968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Don't link with libc until the a.out ld.so is fixed.
7623968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
7624968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
7625968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Do not include libc due to us having libc/libc_r.
7626968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
7627968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *-*-sco3.2v5* | *-*-sco5v6*)
7628968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Causes problems with __ctype
7629968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
7630968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
7631968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Compiler inserts libc in the correct place for threads to work
7632968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
7633968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *)
7634968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Add libc to deplibs on all other systems if necessary.
7635968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "$build_libtool_need_lc" = "yes"; then
7636968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_append deplibs " -lc"
7637968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
7638968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
7639968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
7640968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
7641968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7642968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Transform deplibs into only deplibs that can be linked in shared.
7643968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	name_save=$name
7644968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	libname_save=$libname
7645968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	release_save=$release
7646968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	versuffix_save=$versuffix
7647968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	major_save=$major
7648968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# I'm not sure if I'm treating the release correctly.  I think
7649968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# release should show up in the -l (ie -lgmp5) so we don't want to
7650968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# add it in twice.  Is that correct?
7651968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	release=""
7652968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	versuffix=""
7653968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	major=""
7654968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	newdeplibs=
7655968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	droppeddeps=no
7656968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $deplibs_check_method in
7657968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	pass_all)
7658968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Don't check for shared/static.  Everything works.
7659968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # This might be a little naive.  We might want to check
7660968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # whether the library exists or not.  But this is on
7661968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # osf3 & osf4 and I'm not really sure... Just
7662968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # implementing what was already the behavior.
7663968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  newdeplibs=$deplibs
7664968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
7665968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	test_compile)
7666968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # This code stresses the "libraries are programs" paradigm to its
7667968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # limits. Maybe even breaks it.  We compile a program, linking it
7668968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # against the deplibs as a proxy for the library.  Then we can check
7669968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # whether they linked in statically or dynamically with ldd.
7670968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  $opt_dry_run || $RM conftest.c
7671968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  cat > conftest.c <<EOF
7672968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  int main() { return 0; }
7673968bf19396ad404e89420f5d67900fce13f4186cGilad ArnoldEOF
7674968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  $opt_dry_run || $RM conftest
7675968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
7676968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ldd_output=`ldd conftest`
7677968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    for i in $deplibs; do
7678968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case $i in
7679968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      -l*)
7680968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_stripname -l '' "$i"
7681968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		name=$func_stripname_result
7682968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7683968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  case " $predeps $postdeps " in
7684968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  *" $i "*)
7685968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    func_append newdeplibs " $i"
7686968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    i=""
7687968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    ;;
7688968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  esac
7689968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		fi
7690968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		if test -n "$i" ; then
7691968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  libname=`eval "\\$ECHO \"$libname_spec\""`
7692968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7693968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  set dummy $deplib_matches; shift
7694968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  deplib_match=$1
7695968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7696968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    func_append newdeplibs " $i"
7697968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  else
7698968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    droppeddeps=yes
7699968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    echo
7700968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7701968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    echo "*** I have the capability to make that library automatically link in when"
7702968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    echo "*** you link to this library.  But I can only do this if you have a"
7703968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    echo "*** shared version of the library, which I believe you do not have"
7704968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    echo "*** because a test_compile did reveal that the linker did not use it for"
7705968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
7706968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  fi
7707968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		fi
7708968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		;;
7709968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *)
7710968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_append newdeplibs " $i"
7711968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		;;
7712968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
7713968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    done
7714968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
7715968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Error occurred in the first compile.  Let's try to salvage
7716968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # the situation: Compile a separate program for each library.
7717968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    for i in $deplibs; do
7718968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case $i in
7719968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      -l*)
7720968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_stripname -l '' "$i"
7721968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		name=$func_stripname_result
7722968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		$opt_dry_run || $RM conftest
7723968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
7724968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  ldd_output=`ldd conftest`
7725968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7726968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    case " $predeps $postdeps " in
7727968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    *" $i "*)
7728968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      func_append newdeplibs " $i"
7729968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      i=""
7730968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      ;;
7731968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    esac
7732968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  fi
7733968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  if test -n "$i" ; then
7734968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    libname=`eval "\\$ECHO \"$libname_spec\""`
7735968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7736968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    set dummy $deplib_matches; shift
7737968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    deplib_match=$1
7738968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7739968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      func_append newdeplibs " $i"
7740968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    else
7741968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      droppeddeps=yes
7742968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      echo
7743968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7744968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      echo "*** I have the capability to make that library automatically link in when"
7745968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      echo "*** you link to this library.  But I can only do this if you have a"
7746968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      echo "*** shared version of the library, which you do not appear to have"
7747968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      echo "*** because a test_compile did reveal that the linker did not use this one"
7748968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
7749968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    fi
7750968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  fi
7751968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		else
7752968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  droppeddeps=yes
7753968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  echo
7754968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
7755968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  echo "*** make it link in!  You will probably need to install it or some"
7756968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  echo "*** library that it depends on before this library will be fully"
7757968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  echo "*** functional.  Installing it before continuing would be even better."
7758968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		fi
7759968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		;;
7760968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *)
7761968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_append newdeplibs " $i"
7762968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		;;
7763968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
7764968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    done
7765968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
7766968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
7767968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	file_magic*)
7768968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  set dummy $deplibs_check_method; shift
7769968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7770968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  for a_deplib in $deplibs; do
7771968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    case $a_deplib in
7772968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    -l*)
7773968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_stripname -l '' "$a_deplib"
7774968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      name=$func_stripname_result
7775968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7776968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		case " $predeps $postdeps " in
7777968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		*" $a_deplib "*)
7778968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  func_append newdeplibs " $a_deplib"
7779968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  a_deplib=""
7780968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  ;;
7781968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		esac
7782968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
7783968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if test -n "$a_deplib" ; then
7784968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		libname=`eval "\\$ECHO \"$libname_spec\""`
7785968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		if test -n "$file_magic_glob"; then
7786968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
7787968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		else
7788968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  libnameglob=$libname
7789968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		fi
7790968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
7791968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7792968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  if test "$want_nocaseglob" = yes; then
7793968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    shopt -s nocaseglob
7794968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7795968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    $nocaseglob
7796968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  else
7797968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7798968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  fi
7799968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  for potent_lib in $potential_libs; do
7800968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      # Follow soft links.
7801968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      if ls -lLd "$potent_lib" 2>/dev/null |
7802968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			 $GREP " -> " >/dev/null; then
7803968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			continue
7804968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      fi
7805968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      # The statement above tries to avoid entering an
7806968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      # endless loop below, in case of cyclic links.
7807968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      # We might still enter an endless loop, since a link
7808968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      # loop can be closed while we follow links,
7809968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      # but so what?
7810968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      potlib="$potent_lib"
7811968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      while test -h "$potlib" 2>/dev/null; do
7812968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
7813968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			case $potliblink in
7814968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
7815968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
7816968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			esac
7817968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      done
7818968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
7819968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			 $SED -e 10q |
7820968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			 $EGREP "$file_magic_regex" > /dev/null; then
7821968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			func_append newdeplibs " $a_deplib"
7822968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			a_deplib=""
7823968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold			break 2
7824968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      fi
7825968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  done
7826968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		done
7827968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
7828968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if test -n "$a_deplib" ; then
7829968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		droppeddeps=yes
7830968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		echo
7831968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7832968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		echo "*** I have the capability to make that library automatically link in when"
7833968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		echo "*** you link to this library.  But I can only do this if you have a"
7834968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		echo "*** shared version of the library, which you do not appear to have"
7835968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		echo "*** because I did check the linker path looking for a file starting"
7836968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		if test -z "$potlib" ; then
7837968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
7838968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		else
7839968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7840968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  $ECHO "*** using a file magic. Last file checked: $potlib"
7841968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		fi
7842968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
7843968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      ;;
7844968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *)
7845968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # Add a -L argument.
7846968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_append newdeplibs " $a_deplib"
7847968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      ;;
7848968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    esac
7849968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  done # Gone through all deplibs.
7850968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
7851968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	match_pattern*)
7852968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  set dummy $deplibs_check_method; shift
7853968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7854968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  for a_deplib in $deplibs; do
7855968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    case $a_deplib in
7856968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    -l*)
7857968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_stripname -l '' "$a_deplib"
7858968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      name=$func_stripname_result
7859968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7860968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		case " $predeps $postdeps " in
7861968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		*" $a_deplib "*)
7862968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  func_append newdeplibs " $a_deplib"
7863968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  a_deplib=""
7864968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  ;;
7865968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		esac
7866968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
7867968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if test -n "$a_deplib" ; then
7868968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		libname=`eval "\\$ECHO \"$libname_spec\""`
7869968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7870968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
7871968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  for potent_lib in $potential_libs; do
7872968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    potlib="$potent_lib" # see symlink-check above in file_magic test
7873968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
7874968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		       $EGREP "$match_pattern_regex" > /dev/null; then
7875968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      func_append newdeplibs " $a_deplib"
7876968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      a_deplib=""
7877968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      break 2
7878968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    fi
7879968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  done
7880968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		done
7881968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
7882968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if test -n "$a_deplib" ; then
7883968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		droppeddeps=yes
7884968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		echo
7885968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7886968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		echo "*** I have the capability to make that library automatically link in when"
7887968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		echo "*** you link to this library.  But I can only do this if you have a"
7888968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		echo "*** shared version of the library, which you do not appear to have"
7889968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		echo "*** because I did check the linker path looking for a file starting"
7890968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		if test -z "$potlib" ; then
7891968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
7892968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		else
7893968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7894968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
7895968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		fi
7896968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
7897968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      ;;
7898968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *)
7899968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # Add a -L argument.
7900968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_append newdeplibs " $a_deplib"
7901968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      ;;
7902968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    esac
7903968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  done # Gone through all deplibs.
7904968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
7905968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	none | unknown | *)
7906968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  newdeplibs=""
7907968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
7908968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7909968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    for i in $predeps $postdeps ; do
7910968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # can't use Xsed below, because $i might contain '/'
7911968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
7912968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    done
7913968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
7914968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case $tmp_deplibs in
7915968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *[!\	\ ]*)
7916968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    echo
7917968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "X$deplibs_check_method" = "Xnone"; then
7918968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      echo "*** Warning: inter-library dependencies are not supported in this platform."
7919968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    else
7920968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      echo "*** Warning: inter-library dependencies are not known to be supported."
7921968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
7922968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    echo "*** All declared inter-library dependencies are being dropped."
7923968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    droppeddeps=yes
7924968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
7925968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
7926968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
7927968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
7928968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	versuffix=$versuffix_save
7929968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	major=$major_save
7930968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	release=$release_save
7931968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	libname=$libname_save
7932968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	name=$name_save
7933968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7934968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $host in
7935968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*-*-rhapsody* | *-*-darwin1.[012])
7936968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # On Rhapsody replace the C library with the System framework
7937968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
7938968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
7939968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
7940968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7941968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$droppeddeps" = yes; then
7942968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$module" = yes; then
7943968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    echo
7944968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    echo "*** Warning: libtool could not satisfy all declared inter-library"
7945968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
7946968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    echo "*** a static module, that should work as long as the dlopening"
7947968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    echo "*** application is linked with the -dlopen flag."
7948968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test -z "$global_symbol_pipe"; then
7949968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      echo
7950968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      echo "*** However, this would only work if libtool was able to extract symbol"
7951968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
7952968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      echo "*** not find such a program.  So, this module is probably useless."
7953968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
7954968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
7955968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "$build_old_libs" = no; then
7956968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      oldlibs="$output_objdir/$libname.$libext"
7957968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      build_libtool_libs=module
7958968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      build_old_libs=yes
7959968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    else
7960968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      build_libtool_libs=no
7961968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
7962968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
7963968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    echo "*** The inter-library dependencies that have been dropped here will be"
7964968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    echo "*** automatically added whenever a program is linked with this library"
7965968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    echo "*** or is declared to -dlopen it."
7966968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7967968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "$allow_undefined" = no; then
7968968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      echo
7969968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      echo "*** Since this library must not contain undefined symbols,"
7970968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      echo "*** because either the platform does not support them or"
7971968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      echo "*** it was explicitly requested with -no-undefined,"
7972968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      echo "*** libtool will only create a static version of it."
7973968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if test "$build_old_libs" = no; then
7974968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		oldlibs="$output_objdir/$libname.$libext"
7975968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		build_libtool_libs=module
7976968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		build_old_libs=yes
7977968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      else
7978968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		build_libtool_libs=no
7979968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
7980968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
7981968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
7982968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
7983968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Done checking deplibs!
7984968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	deplibs=$newdeplibs
7985968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
7986968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
7987968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      case $host in
7988968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*-*-darwin*)
7989968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7990968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7991968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7992968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
7993968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      esac
7994968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
7995968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # move library search paths that coincide with paths to not yet
7996968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # installed libraries to the beginning of the library search list
7997968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      new_libs=
7998968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      for path in $notinst_path; do
7999968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case " $new_libs " in
8000968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*" -L$path/$objdir "*) ;;
8001968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*)
8002968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case " $deplibs " in
8003968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *" -L$path/$objdir "*)
8004968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append new_libs " -L$path/$objdir" ;;
8005968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
8006968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
8007968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
8008968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      done
8009968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      for deplib in $deplibs; do
8010968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $deplib in
8011968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	-L*)
8012968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case " $new_libs " in
8013968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *" $deplib "*) ;;
8014968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *) func_append new_libs " $deplib" ;;
8015968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
8016968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
8017968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*) func_append new_libs " $deplib" ;;
8018968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
8019968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      done
8020968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      deplibs="$new_libs"
8021968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8022968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # All the library-specific variables (install_libdir is set above).
8023968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      library_names=
8024968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      old_library=
8025968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      dlname=
8026968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8027968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Test again, we may have decided not to build it any more
8028968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test "$build_libtool_libs" = yes; then
8029968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$hardcode_into_libs" = yes; then
8030968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Hardcode the library paths
8031968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  hardcode_libdirs=
8032968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  dep_rpath=
8033968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  rpath="$finalize_rpath"
8034968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
8035968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  for libdir in $rpath; do
8036968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test -n "$hardcode_libdir_flag_spec"; then
8037968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if test -n "$hardcode_libdir_separator"; then
8038968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_replace_sysroot "$libdir"
8039968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		libdir=$func_replace_sysroot_result
8040968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		if test -z "$hardcode_libdirs"; then
8041968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  hardcode_libdirs="$libdir"
8042968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		else
8043968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  # Just accumulate the unique libdirs.
8044968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8045968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8046968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    ;;
8047968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  *)
8048968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8049968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    ;;
8050968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  esac
8051968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		fi
8052968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      else
8053968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		eval flag=\"$hardcode_libdir_flag_spec\"
8054968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_append dep_rpath " $flag"
8055968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
8056968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    elif test -n "$runpath_var"; then
8057968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case "$perm_rpath " in
8058968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *" $libdir "*) ;;
8059968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *) func_apped perm_rpath " $libdir" ;;
8060968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
8061968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
8062968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  done
8063968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Substitute the hardcoded libdirs into the rpath.
8064968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -n "$hardcode_libdir_separator" &&
8065968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	     test -n "$hardcode_libdirs"; then
8066968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    libdir="$hardcode_libdirs"
8067968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test -n "$hardcode_libdir_flag_spec_ld"; then
8068968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
8069968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    else
8070968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
8071968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
8072968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
8073968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
8074968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # We should set the runpath_var.
8075968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    rpath=
8076968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    for dir in $perm_rpath; do
8077968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_append rpath "$dir:"
8078968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    done
8079968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
8080968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
8081968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
8082968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
8083968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8084968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	shlibpath="$finalize_shlibpath"
8085968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
8086968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$shlibpath"; then
8087968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
8088968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
8089968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8090968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Get the real and link names of the library.
8091968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	eval shared_ext=\"$shrext_cmds\"
8092968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	eval library_names=\"$library_names_spec\"
8093968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	set dummy $library_names
8094968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	shift
8095968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	realname="$1"
8096968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	shift
8097968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8098968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$soname_spec"; then
8099968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  eval soname=\"$soname_spec\"
8100968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	else
8101968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  soname="$realname"
8102968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
8103968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -z "$dlname"; then
8104968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  dlname=$soname
8105968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
8106968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8107968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	lib="$output_objdir/$realname"
8108968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	linknames=
8109968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	for link
8110968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	do
8111968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append linknames " $link"
8112968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	done
8113968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8114968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Use standard objects if they are pic
8115968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
8116968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	test "X$libobjs" = "X " && libobjs=
8117968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8118968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	delfiles=
8119968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8120968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
8121968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  export_symbols="$output_objdir/$libname.uexp"
8122968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append delfiles " $export_symbols"
8123968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
8124968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8125968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	orig_export_symbols=
8126968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $host_os in
8127968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	cygwin* | mingw* | cegcc*)
8128968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
8129968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # exporting using user supplied symfile
8130968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
8131968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # and it's NOT already a .def file. Must figure out
8132968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # which of the given symbols are data symbols and tag
8133968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # them as such. So, trigger use of export_symbols_cmds.
8134968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # export_symbols gets reassigned inside the "prepare
8135968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # the list of exported symbols" if statement, so the
8136968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # include_expsyms logic still works.
8137968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      orig_export_symbols="$export_symbols"
8138968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      export_symbols=
8139968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      always_export_symbols=yes
8140968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
8141968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
8142968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
8143968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
8144968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8145968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Prepare the list of exported symbols
8146968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -z "$export_symbols"; then
8147968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
8148968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_verbose "generating symbol list for \`$libname.la'"
8149968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    export_symbols="$output_objdir/$libname.exp"
8150968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    $opt_dry_run || $RM $export_symbols
8151968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    cmds=$export_symbols_cmds
8152968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    save_ifs="$IFS"; IFS='~'
8153968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    for cmd1 in $cmds; do
8154968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      IFS="$save_ifs"
8155968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # Take the normal branch if the nm_file_list_spec branch
8156968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # doesn't work or if tool conversion is not needed.
8157968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case $nm_file_list_spec~$to_tool_file_cmd in
8158968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
8159968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  try_normal_branch=yes
8160968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  eval cmd=\"$cmd1\"
8161968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  func_len " $cmd"
8162968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  len=$func_len_result
8163968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  ;;
8164968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		*)
8165968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  try_normal_branch=no
8166968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  ;;
8167968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
8168968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if test "$try_normal_branch" = yes \
8169968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		 && { test "$len" -lt "$max_cmd_len" \
8170968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		      || test "$max_cmd_len" -le -1; }
8171968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      then
8172968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_show_eval "$cmd" 'exit $?'
8173968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		skipped_export=false
8174968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      elif test -n "$nm_file_list_spec"; then
8175968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_basename "$output"
8176968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		output_la=$func_basename_result
8177968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		save_libobjs=$libobjs
8178968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		save_output=$output
8179968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		output=${output_objdir}/${output_la}.nm
8180968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_to_tool_file "$output"
8181968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		libobjs=$nm_file_list_spec$func_to_tool_file_result
8182968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_append delfiles " $output"
8183968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_verbose "creating $NM input file list: $output"
8184968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		for obj in $save_libobjs; do
8185968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  func_to_tool_file "$obj"
8186968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  $ECHO "$func_to_tool_file_result"
8187968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		done > "$output"
8188968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		eval cmd=\"$cmd1\"
8189968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_show_eval "$cmd" 'exit $?'
8190968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		output=$save_output
8191968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		libobjs=$save_libobjs
8192968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		skipped_export=false
8193968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      else
8194968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		# The command line is too long to execute in one step.
8195968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_verbose "using reloadable object file for export list..."
8196968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		skipped_export=:
8197968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		# Break out early, otherwise skipped_export may be
8198968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		# set to false by a later but shorter cmd.
8199968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		break
8200968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
8201968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    done
8202968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    IFS="$save_ifs"
8203968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
8204968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8205968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8206968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
8207968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
8208968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
8209968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8210968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8211968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  tmp_export_symbols="$export_symbols"
8212968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8213968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8214968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
8215968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8216968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
8217968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # The given exports_symbols file has to be filtered, so filter it.
8218968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8219968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
8220968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # 's' commands which not all seds can handle. GNU sed should be fine
8221968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # though. Also, the filter scales superlinearly with the number of
8222968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # global variables. join(1) would be nice here, but unfortunately
8223968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # isn't a blessed tool.
8224968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8225968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8226968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  export_symbols=$output_objdir/$libname.def
8227968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8228968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
8229968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8230968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	tmp_deplibs=
8231968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	for test_deplib in $deplibs; do
8232968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case " $convenience " in
8233968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *" $test_deplib "*) ;;
8234968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *)
8235968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append tmp_deplibs " $test_deplib"
8236968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
8237968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
8238968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	done
8239968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	deplibs="$tmp_deplibs"
8240968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8241968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$convenience"; then
8242968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -n "$whole_archive_flag_spec" &&
8243968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    test "$compiler_needs_object" = yes &&
8244968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    test -z "$libobjs"; then
8245968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # extract the archives, so we have objects to list.
8246968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # TODO: could optimize this to just extract one archive.
8247968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    whole_archive_flag_spec=
8248968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
8249968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -n "$whole_archive_flag_spec"; then
8250968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    save_libobjs=$libobjs
8251968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8252968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    test "X$libobjs" = "X " && libobjs=
8253968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
8254968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    gentop="$output_objdir/${outputname}x"
8255968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append generated " $gentop"
8256968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8257968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_extract_archives $gentop $convenience
8258968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append libobjs " $func_extract_archives_result"
8259968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    test "X$libobjs" = "X " && libobjs=
8260968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
8261968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
8262968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8263968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
8264968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  eval flag=\"$thread_safe_flag_spec\"
8265968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append linker_flags " $flag"
8266968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
8267968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8268968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Make a backup of the uninstalled library when relinking
8269968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$opt_mode" = relink; then
8270968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
8271968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
8272968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8273968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Do each of the archive commands.
8274968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$module" = yes && test -n "$module_cmds" ; then
8275968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8276968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    eval test_cmds=\"$module_expsym_cmds\"
8277968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    cmds=$module_expsym_cmds
8278968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
8279968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    eval test_cmds=\"$module_cmds\"
8280968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    cmds=$module_cmds
8281968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
8282968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	else
8283968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8284968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    eval test_cmds=\"$archive_expsym_cmds\"
8285968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    cmds=$archive_expsym_cmds
8286968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
8287968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    eval test_cmds=\"$archive_cmds\"
8288968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    cmds=$archive_cmds
8289968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
8290968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
8291968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8292968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "X$skipped_export" != "X:" &&
8293968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	   func_len " $test_cmds" &&
8294968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	   len=$func_len_result &&
8295968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
8296968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  :
8297968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	else
8298968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # The command line is too long to link in one step, link piecewise
8299968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # or, if using GNU ld and skipped_export is not :, use a linker
8300968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # script.
8301968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8302968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Save the value of $output and $libobjs because we want to
8303968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # use them later.  If we have whole_archive_flag_spec, we
8304968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # want to use save_libobjs as it was before
8305968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # whole_archive_flag_spec was expanded, because we can't
8306968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # assume the linker understands whole_archive_flag_spec.
8307968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # This may have to be revisited, in case too many
8308968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # convenience libraries get linked in and end up exceeding
8309968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # the spec.
8310968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
8311968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    save_libobjs=$libobjs
8312968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
8313968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  save_output=$output
8314968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_basename "$output"
8315968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  output_la=$func_basename_result
8316968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8317968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Clear the reloadable object creation command queue and
8318968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # initialize k to one.
8319968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  test_cmds=
8320968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  concat_cmds=
8321968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  objlist=
8322968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  last_robj=
8323968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  k=1
8324968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8325968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
8326968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    output=${output_objdir}/${output_la}.lnkscript
8327968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_verbose "creating GNU ld script: $output"
8328968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    echo 'INPUT (' > $output
8329968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    for obj in $save_libobjs
8330968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    do
8331968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_to_tool_file "$obj"
8332968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      $ECHO "$func_to_tool_file_result" >> $output
8333968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    done
8334968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    echo ')' >> $output
8335968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append delfiles " $output"
8336968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_to_tool_file "$output"
8337968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    output=$func_to_tool_file_result
8338968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
8339968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    output=${output_objdir}/${output_la}.lnk
8340968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_verbose "creating linker input file list: $output"
8341968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    : > $output
8342968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    set x $save_libobjs
8343968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    shift
8344968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    firstobj=
8345968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "$compiler_needs_object" = yes; then
8346968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      firstobj="$1 "
8347968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      shift
8348968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
8349968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    for obj
8350968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    do
8351968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_to_tool_file "$obj"
8352968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      $ECHO "$func_to_tool_file_result" >> $output
8353968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    done
8354968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append delfiles " $output"
8355968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_to_tool_file "$output"
8356968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
8357968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
8358968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test -n "$save_libobjs"; then
8359968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_verbose "creating reloadable object files..."
8360968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      output=$output_objdir/$output_la-${k}.$objext
8361968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      eval test_cmds=\"$reload_cmds\"
8362968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_len " $test_cmds"
8363968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      len0=$func_len_result
8364968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      len=$len0
8365968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8366968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # Loop over the list of objects to be linked.
8367968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      for obj in $save_libobjs
8368968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      do
8369968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_len " $obj"
8370968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_arith $len + $func_len_result
8371968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		len=$func_arith_result
8372968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		if test "X$objlist" = X ||
8373968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		   test "$len" -lt "$max_cmd_len"; then
8374968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  func_append objlist " $obj"
8375968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		else
8376968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  # The command $test_cmds is almost too long, add a
8377968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  # command to the queue.
8378968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  if test "$k" -eq 1 ; then
8379968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    # The first file doesn't have a previous command to add.
8380968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    reload_objs=$objlist
8381968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    eval concat_cmds=\"$reload_cmds\"
8382968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  else
8383968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    # All subsequent reloadable object files will link in
8384968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    # the last one created.
8385968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    reload_objs="$objlist $last_robj"
8386968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
8387968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  fi
8388968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  last_robj=$output_objdir/$output_la-${k}.$objext
8389968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  func_arith $k + 1
8390968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  k=$func_arith_result
8391968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  output=$output_objdir/$output_la-${k}.$objext
8392968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  objlist=" $obj"
8393968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  func_len " $last_robj"
8394968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  func_arith $len0 + $func_len_result
8395968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  len=$func_arith_result
8396968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		fi
8397968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      done
8398968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # Handle the remaining objects by creating one last
8399968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # reloadable object file.  All subsequent reloadable object
8400968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # files will link in the last one created.
8401968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8402968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      reload_objs="$objlist $last_robj"
8403968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
8404968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if test -n "$last_robj"; then
8405968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
8406968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
8407968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_append delfiles " $output"
8408968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8409968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    else
8410968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      output=
8411968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
8412968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8413968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if ${skipped_export-false}; then
8414968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_verbose "generating symbol list for \`$libname.la'"
8415968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      export_symbols="$output_objdir/$libname.exp"
8416968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      $opt_dry_run || $RM $export_symbols
8417968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      libobjs=$output
8418968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # Append the command to create the export file.
8419968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8420968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
8421968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if test -n "$last_robj"; then
8422968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
8423968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
8424968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
8425968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8426968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    test -n "$save_libobjs" &&
8427968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_verbose "creating a temporary reloadable object file: $output"
8428968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8429968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Loop through the commands generated above and execute them.
8430968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    save_ifs="$IFS"; IFS='~'
8431968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    for cmd in $concat_cmds; do
8432968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      IFS="$save_ifs"
8433968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      $opt_silent || {
8434968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  func_quote_for_expand "$cmd"
8435968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  eval "func_echo $func_quote_for_expand_result"
8436968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      }
8437968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      $opt_dry_run || eval "$cmd" || {
8438968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		lt_exit=$?
8439968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8440968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		# Restore the uninstalled library and exit
8441968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		if test "$opt_mode" = relink; then
8442968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  ( cd "$output_objdir" && \
8443968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    $RM "${realname}T" && \
8444968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		    $MV "${realname}U" "$realname" )
8445968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		fi
8446968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8447968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		exit $lt_exit
8448968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      }
8449968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    done
8450968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    IFS="$save_ifs"
8451968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8452968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
8453968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8454968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8455968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
8456968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
8457968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8458968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold          if ${skipped_export-false}; then
8459968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
8460968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      tmp_export_symbols="$export_symbols"
8461968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8462968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8463968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
8464968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8465968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test -n "$orig_export_symbols"; then
8466968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # The given exports_symbols file has to be filtered, so filter it.
8467968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8468968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
8469968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # 's' commands which not all seds can handle. GNU sed should be fine
8470968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # though. Also, the filter scales superlinearly with the number of
8471968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # global variables. join(1) would be nice here, but unfortunately
8472968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # isn't a blessed tool.
8473968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8474968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8475968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      export_symbols=$output_objdir/$libname.def
8476968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8477968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
8478968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
8479968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8480968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  libobjs=$output
8481968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Restore the value of output.
8482968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  output=$save_output
8483968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8484968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
8485968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8486968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    test "X$libobjs" = "X " && libobjs=
8487968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
8488968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Expand the library linking commands again to reset the
8489968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # value of $libobjs for piecewise linking.
8490968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8491968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Do each of the archive commands.
8492968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$module" = yes && test -n "$module_cmds" ; then
8493968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8494968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      cmds=$module_expsym_cmds
8495968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    else
8496968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      cmds=$module_cmds
8497968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
8498968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
8499968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8500968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      cmds=$archive_expsym_cmds
8501968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    else
8502968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      cmds=$archive_cmds
8503968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
8504968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
8505968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
8506968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8507968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$delfiles"; then
8508968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Append the command to remove temporary files to $cmds.
8509968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  eval cmds=\"\$cmds~\$RM $delfiles\"
8510968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
8511968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8512968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Add any objects from preloaded convenience libraries
8513968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$dlprefiles"; then
8514968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  gentop="$output_objdir/${outputname}x"
8515968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append generated " $gentop"
8516968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8517968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_extract_archives $gentop $dlprefiles
8518968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append libobjs " $func_extract_archives_result"
8519968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  test "X$libobjs" = "X " && libobjs=
8520968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
8521968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8522968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	save_ifs="$IFS"; IFS='~'
8523968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	for cmd in $cmds; do
8524968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  IFS="$save_ifs"
8525968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  eval cmd=\"$cmd\"
8526968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  $opt_silent || {
8527968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_quote_for_expand "$cmd"
8528968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    eval "func_echo $func_quote_for_expand_result"
8529968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  }
8530968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  $opt_dry_run || eval "$cmd" || {
8531968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    lt_exit=$?
8532968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8533968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Restore the uninstalled library and exit
8534968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "$opt_mode" = relink; then
8535968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      ( cd "$output_objdir" && \
8536968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        $RM "${realname}T" && \
8537968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		$MV "${realname}U" "$realname" )
8538968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
8539968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8540968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    exit $lt_exit
8541968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  }
8542968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	done
8543968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	IFS="$save_ifs"
8544968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8545968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Restore the uninstalled library and exit
8546968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$opt_mode" = relink; then
8547968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
8548968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8549968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -n "$convenience"; then
8550968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test -z "$whole_archive_flag_spec"; then
8551968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_show_eval '${RM}r "$gentop"'
8552968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
8553968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
8554968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8555968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  exit $EXIT_SUCCESS
8556968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
8557968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8558968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Create links to the real library.
8559968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	for linkname in $linknames; do
8560968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$realname" != "$linkname"; then
8561968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
8562968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
8563968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	done
8564968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8565968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# If -module or -export-dynamic was specified, set the dlname.
8566968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$module" = yes || test "$export_dynamic" = yes; then
8567968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # On all known operating systems, these are identical.
8568968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  dlname="$soname"
8569968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
8570968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
8571968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      ;;
8572968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8573968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    obj)
8574968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
8575968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_warning "\`-dlopen' is ignored for objects"
8576968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
8577968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8578968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      case " $deplibs" in
8579968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *\ -l* | *\ -L*)
8580968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_warning "\`-l' and \`-L' are ignored for objects" ;;
8581968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      esac
8582968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8583968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      test -n "$rpath" && \
8584968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_warning "\`-rpath' is ignored for objects"
8585968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8586968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      test -n "$xrpath" && \
8587968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_warning "\`-R' is ignored for objects"
8588968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8589968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      test -n "$vinfo" && \
8590968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_warning "\`-version-info' is ignored for objects"
8591968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8592968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      test -n "$release" && \
8593968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_warning "\`-release' is ignored for objects"
8594968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8595968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      case $output in
8596968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *.lo)
8597968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	test -n "$objs$old_deplibs" && \
8598968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
8599968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8600968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	libobj=$output
8601968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_lo2o "$libobj"
8602968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	obj=$func_lo2o_result
8603968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
8604968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *)
8605968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	libobj=
8606968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	obj="$output"
8607968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
8608968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      esac
8609968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8610968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Delete the old objects.
8611968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      $opt_dry_run || $RM $obj $libobj
8612968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8613968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Objects from convenience libraries.  This assumes
8614968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # single-version convenience libraries.  Whenever we create
8615968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # different ones for PIC/non-PIC, this we'll have to duplicate
8616968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # the extraction.
8617968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      reload_conv_objs=
8618968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      gentop=
8619968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # reload_cmds runs $LD directly, so let us get rid of
8620968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # -Wl from whole_archive_flag_spec and hope we can get by with
8621968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # turning comma into space..
8622968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      wl=
8623968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8624968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$convenience"; then
8625968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$whole_archive_flag_spec"; then
8626968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
8627968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
8628968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	else
8629968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  gentop="$output_objdir/${obj}x"
8630968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append generated " $gentop"
8631968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8632968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_extract_archives $gentop $convenience
8633968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  reload_conv_objs="$reload_objs $func_extract_archives_result"
8634968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
8635968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
8636968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8637968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # If we're not building shared, we need to use non_pic_objs
8638968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
8639968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8640968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Create the old-style object.
8641968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
8642968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8643968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      output="$obj"
8644968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_execute_cmds "$reload_cmds" 'exit $?'
8645968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8646968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Exit if we aren't doing a library object file.
8647968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -z "$libobj"; then
8648968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$gentop"; then
8649968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_show_eval '${RM}r "$gentop"'
8650968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
8651968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8652968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	exit $EXIT_SUCCESS
8653968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
8654968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8655968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test "$build_libtool_libs" != yes; then
8656968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$gentop"; then
8657968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_show_eval '${RM}r "$gentop"'
8658968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
8659968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8660968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Create an invalid libtool object if no PIC, so that we don't
8661968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# accidentally link it into a program.
8662968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# $show "echo timestamp > $libobj"
8663968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
8664968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	exit $EXIT_SUCCESS
8665968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
8666968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8667968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$pic_flag" || test "$pic_mode" != default; then
8668968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Only do commands if we really have different PIC objects.
8669968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	reload_objs="$libobjs $reload_conv_objs"
8670968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	output="$libobj"
8671968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_execute_cmds "$reload_cmds" 'exit $?'
8672968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
8673968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8674968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$gentop"; then
8675968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_show_eval '${RM}r "$gentop"'
8676968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
8677968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8678968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      exit $EXIT_SUCCESS
8679968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      ;;
8680968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8681968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    prog)
8682968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      case $host in
8683968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*cygwin*) func_stripname '' '.exe' "$output"
8684968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	          output=$func_stripname_result.exe;;
8685968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      esac
8686968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      test -n "$vinfo" && \
8687968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_warning "\`-version-info' is ignored for programs"
8688968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8689968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      test -n "$release" && \
8690968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_warning "\`-release' is ignored for programs"
8691968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8692968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      test "$preload" = yes \
8693968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        && test "$dlopen_support" = unknown \
8694968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	&& test "$dlopen_self" = unknown \
8695968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	&& test "$dlopen_self_static" = unknown && \
8696968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
8697968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8698968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      case $host in
8699968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *-*-rhapsody* | *-*-darwin1.[012])
8700968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# On Rhapsody replace the C library is the System framework
8701968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
8702968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
8703968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
8704968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      esac
8705968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8706968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      case $host in
8707968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *-*-darwin*)
8708968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Don't allow lazy linking, it breaks C++ global constructors
8709968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# But is supposedly fixed on 10.4 or later (yay!).
8710968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$tagname" = CXX ; then
8711968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
8712968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    10.[0123])
8713968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_append compile_command " ${wl}-bind_at_load"
8714968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_append finalize_command " ${wl}-bind_at_load"
8715968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
8716968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
8717968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
8718968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
8719968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8720968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8721968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
8722968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      esac
8723968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8724968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8725968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # move library search paths that coincide with paths to not yet
8726968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # installed libraries to the beginning of the library search list
8727968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      new_libs=
8728968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      for path in $notinst_path; do
8729968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case " $new_libs " in
8730968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*" -L$path/$objdir "*) ;;
8731968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*)
8732968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case " $compile_deplibs " in
8733968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *" -L$path/$objdir "*)
8734968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append new_libs " -L$path/$objdir" ;;
8735968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
8736968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
8737968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
8738968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      done
8739968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      for deplib in $compile_deplibs; do
8740968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $deplib in
8741968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	-L*)
8742968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case " $new_libs " in
8743968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *" $deplib "*) ;;
8744968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *) func_append new_libs " $deplib" ;;
8745968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
8746968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
8747968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*) func_append new_libs " $deplib" ;;
8748968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
8749968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      done
8750968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      compile_deplibs="$new_libs"
8751968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8752968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8753968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_append compile_command " $compile_deplibs"
8754968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_append finalize_command " $finalize_deplibs"
8755968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8756968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$rpath$xrpath"; then
8757968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# If the user specified any rpath flags, then add them.
8758968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	for libdir in $rpath $xrpath; do
8759968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # This is the magic to use -rpath.
8760968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case "$finalize_rpath " in
8761968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *" $libdir "*) ;;
8762968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *) func_append finalize_rpath " $libdir" ;;
8763968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
8764968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	done
8765968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
8766968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8767968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Now hardcode the library paths
8768968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      rpath=
8769968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      hardcode_libdirs=
8770968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      for libdir in $compile_rpath $finalize_rpath; do
8771968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$hardcode_libdir_flag_spec"; then
8772968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -n "$hardcode_libdir_separator"; then
8773968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test -z "$hardcode_libdirs"; then
8774968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      hardcode_libdirs="$libdir"
8775968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    else
8776968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # Just accumulate the unique libdirs.
8777968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8778968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8779968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		;;
8780968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *)
8781968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8782968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		;;
8783968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
8784968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
8785968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
8786968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    eval flag=\"$hardcode_libdir_flag_spec\"
8787968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append rpath " $flag"
8788968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
8789968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	elif test -n "$runpath_var"; then
8790968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case "$perm_rpath " in
8791968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *" $libdir "*) ;;
8792968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *) func_append perm_rpath " $libdir" ;;
8793968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
8794968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
8795968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $host in
8796968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
8797968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
8798968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case :$dllsearchpath: in
8799968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *":$libdir:"*) ;;
8800968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ::) dllsearchpath=$libdir;;
8801968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *) func_append dllsearchpath ":$libdir";;
8802968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
8803968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case :$dllsearchpath: in
8804968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *":$testbindir:"*) ;;
8805968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ::) dllsearchpath=$testbindir;;
8806968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *) func_append dllsearchpath ":$testbindir";;
8807968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
8808968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
8809968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
8810968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      done
8811968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Substitute the hardcoded libdirs into the rpath.
8812968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$hardcode_libdir_separator" &&
8813968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	 test -n "$hardcode_libdirs"; then
8814968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	libdir="$hardcode_libdirs"
8815968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	eval rpath=\" $hardcode_libdir_flag_spec\"
8816968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
8817968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      compile_rpath="$rpath"
8818968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8819968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      rpath=
8820968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      hardcode_libdirs=
8821968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      for libdir in $finalize_rpath; do
8822968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$hardcode_libdir_flag_spec"; then
8823968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -n "$hardcode_libdir_separator"; then
8824968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test -z "$hardcode_libdirs"; then
8825968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      hardcode_libdirs="$libdir"
8826968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    else
8827968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # Just accumulate the unique libdirs.
8828968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8829968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8830968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		;;
8831968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *)
8832968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8833968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		;;
8834968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
8835968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
8836968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
8837968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    eval flag=\"$hardcode_libdir_flag_spec\"
8838968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append rpath " $flag"
8839968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
8840968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	elif test -n "$runpath_var"; then
8841968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case "$finalize_perm_rpath " in
8842968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *" $libdir "*) ;;
8843968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *) func_append finalize_perm_rpath " $libdir" ;;
8844968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
8845968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
8846968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      done
8847968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Substitute the hardcoded libdirs into the rpath.
8848968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$hardcode_libdir_separator" &&
8849968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	 test -n "$hardcode_libdirs"; then
8850968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	libdir="$hardcode_libdirs"
8851968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	eval rpath=\" $hardcode_libdir_flag_spec\"
8852968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
8853968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      finalize_rpath="$rpath"
8854968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8855968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$libobjs" && test "$build_old_libs" = yes; then
8856968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Transform all the library objects into standard objects.
8857968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8858968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8859968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
8860968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8861968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
8862968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8863968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # template prelinking step
8864968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$prelink_cmds"; then
8865968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_execute_cmds "$prelink_cmds" 'exit $?'
8866968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
8867968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8868968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      wrappers_required=yes
8869968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      case $host in
8870968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *cegcc* | *mingw32ce*)
8871968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
8872968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        wrappers_required=no
8873968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        ;;
8874968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *cygwin* | *mingw* )
8875968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        if test "$build_libtool_libs" != yes; then
8876968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold          wrappers_required=no
8877968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        fi
8878968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        ;;
8879968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *)
8880968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
8881968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold          wrappers_required=no
8882968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        fi
8883968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold        ;;
8884968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      esac
8885968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test "$wrappers_required" = no; then
8886968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Replace the output file specification.
8887968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8888968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	link_command="$compile_command$compile_rpath"
8889968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8890968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# We have no uninstalled library dependencies, so finalize right now.
8891968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	exit_status=0
8892968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_show_eval "$link_command" 'exit_status=$?'
8893968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8894968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$postlink_cmds"; then
8895968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_to_tool_file "$output"
8896968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8897968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_execute_cmds "$postlink_cmds" 'exit $?'
8898968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
8899968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8900968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Delete the generated files.
8901968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -f "$output_objdir/${outputname}S.${objext}"; then
8902968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
8903968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
8904968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8905968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	exit $exit_status
8906968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
8907968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8908968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$compile_shlibpath$finalize_shlibpath"; then
8909968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
8910968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
8911968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$finalize_shlibpath"; then
8912968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
8913968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
8914968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8915968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      compile_var=
8916968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      finalize_var=
8917968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$runpath_var"; then
8918968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$perm_rpath"; then
8919968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # We should set the runpath_var.
8920968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  rpath=
8921968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  for dir in $perm_rpath; do
8922968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append rpath "$dir:"
8923968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  done
8924968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
8925968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
8926968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$finalize_perm_rpath"; then
8927968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # We should set the runpath_var.
8928968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  rpath=
8929968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  for dir in $finalize_perm_rpath; do
8930968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append rpath "$dir:"
8931968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  done
8932968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
8933968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
8934968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
8935968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8936968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test "$no_install" = yes; then
8937968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# We don't need to create a wrapper script.
8938968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	link_command="$compile_var$compile_command$compile_rpath"
8939968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Replace the output file specification.
8940968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8941968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Delete the old output file.
8942968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	$opt_dry_run || $RM $output
8943968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Link the executable and exit
8944968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_show_eval "$link_command" 'exit $?'
8945968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8946968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$postlink_cmds"; then
8947968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_to_tool_file "$output"
8948968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8949968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_execute_cmds "$postlink_cmds" 'exit $?'
8950968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
8951968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8952968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	exit $EXIT_SUCCESS
8953968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
8954968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8955968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test "$hardcode_action" = relink; then
8956968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Fast installation is not supported
8957968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	link_command="$compile_var$compile_command$compile_rpath"
8958968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	relink_command="$finalize_var$finalize_command$finalize_rpath"
8959968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8960968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_warning "this platform does not like uninstalled shared libraries"
8961968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_warning "\`$output' will be relinked during installation"
8962968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      else
8963968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$fast_install" != no; then
8964968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  link_command="$finalize_var$compile_command$finalize_rpath"
8965968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$fast_install" = yes; then
8966968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
8967968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
8968968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # fast_install is set to needless
8969968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    relink_command=
8970968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
8971968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	else
8972968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  link_command="$compile_var$compile_command$compile_rpath"
8973968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  relink_command="$finalize_var$finalize_command$finalize_rpath"
8974968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
8975968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
8976968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8977968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Replace the output file specification.
8978968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
8979968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8980968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Delete the old output files.
8981968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
8982968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8983968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_show_eval "$link_command" 'exit $?'
8984968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8985968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$postlink_cmds"; then
8986968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_to_tool_file "$output_objdir/$outputname"
8987968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8988968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_execute_cmds "$postlink_cmds" 'exit $?'
8989968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
8990968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8991968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Now create the wrapper script.
8992968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_verbose "creating $output"
8993968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
8994968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Quote the relink command for shipping.
8995968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$relink_command"; then
8996968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Preserve any variables that may affect compiler behavior
8997968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	for var in $variables_saved_for_relink; do
8998968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if eval test -z \"\${$var+set}\"; then
8999968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9000968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  elif eval var_value=\$$var; test -z "$var_value"; then
9001968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    relink_command="$var=; export $var; $relink_command"
9002968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
9003968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_quote_for_eval "$var_value"
9004968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9005968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
9006968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	done
9007968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	relink_command="(cd `pwd`; $relink_command)"
9008968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9009968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
9010968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9011968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Only actually do things if not in dry run mode.
9012968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      $opt_dry_run || {
9013968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# win32 will think the script is a binary if it has
9014968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# a .exe suffix, so we strip it off here.
9015968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $output in
9016968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *.exe) func_stripname '' '.exe' "$output"
9017968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	         output=$func_stripname_result ;;
9018968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
9019968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# test for cygwin because mv fails w/o .exe extensions
9020968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $host in
9021968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *cygwin*)
9022968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    exeext=.exe
9023968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_stripname '' '.exe' "$outputname"
9024968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    outputname=$func_stripname_result ;;
9025968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *) exeext= ;;
9026968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
9027968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case $host in
9028968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *cygwin* | *mingw* )
9029968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_dirname_and_basename "$output" "" "."
9030968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    output_name=$func_basename_result
9031968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    output_path=$func_dirname_result
9032968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
9033968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    cwrapper="$output_path/$output_name.exe"
9034968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    $RM $cwrappersource $cwrapper
9035968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
9036968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9037968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_emit_cwrapperexe_src > $cwrappersource
9038968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9039968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # The wrapper executable is built using the $host compiler,
9040968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # because it contains $host paths and files. If cross-
9041968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # compiling, it, like the target executable, must be
9042968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # executed on the $host or under an emulation environment.
9043968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    $opt_dry_run || {
9044968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
9045968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      $STRIP $cwrapper
9046968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    }
9047968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9048968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Now, create the wrapper script for func_source use:
9049968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_ltwrapper_scriptname $cwrapper
9050968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    $RM $func_ltwrapper_scriptname_result
9051968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
9052968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    $opt_dry_run || {
9053968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # note: this script will not be executed, so do not chmod.
9054968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if test "x$build" = "x$host" ; then
9055968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
9056968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      else
9057968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_emit_wrapper no > $func_ltwrapper_scriptname_result
9058968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
9059968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    }
9060968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
9061968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  * )
9062968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    $RM $output
9063968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
9064968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9065968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_emit_wrapper no > $output
9066968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    chmod +x $output
9067968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  ;;
9068968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
9069968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      }
9070968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      exit $EXIT_SUCCESS
9071968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      ;;
9072968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    esac
9073968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9074968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # See if we need to build an old-fashioned archive.
9075968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    for oldlib in $oldlibs; do
9076968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9077968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test "$build_libtool_libs" = convenience; then
9078968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	oldobjs="$libobjs_save $symfileobj"
9079968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	addlibs="$convenience"
9080968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	build_libtool_libs=no
9081968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      else
9082968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$build_libtool_libs" = module; then
9083968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  oldobjs="$libobjs_save"
9084968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  build_libtool_libs=no
9085968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	else
9086968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  oldobjs="$old_deplibs $non_pic_objects"
9087968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$preload" = yes && test -f "$symfileobj"; then
9088968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append oldobjs " $symfileobj"
9089968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
9090968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
9091968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	addlibs="$old_convenience"
9092968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
9093968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9094968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$addlibs"; then
9095968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	gentop="$output_objdir/${outputname}x"
9096968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_append generated " $gentop"
9097968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9098968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_extract_archives $gentop $addlibs
9099968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_append oldobjs " $func_extract_archives_result"
9100968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
9101968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9102968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Do each command in the archive commands.
9103968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
9104968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	cmds=$old_archive_from_new_cmds
9105968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      else
9106968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9107968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Add any objects from preloaded convenience libraries
9108968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test -n "$dlprefiles"; then
9109968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  gentop="$output_objdir/${outputname}x"
9110968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append generated " $gentop"
9111968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9112968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_extract_archives $gentop $dlprefiles
9113968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append oldobjs " $func_extract_archives_result"
9114968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
9115968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9116968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# POSIX demands no paths to be encoded in archives.  We have
9117968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# to avoid creating archives with duplicate basenames if we
9118968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# might have to extract them afterwards, e.g., when creating a
9119968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# static archive out of a convenience library, or when linking
9120968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# the entirety of a libtool archive into another (currently
9121968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# not supported by libtool).
9122968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if (for obj in $oldobjs
9123968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    do
9124968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_basename "$obj"
9125968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      $ECHO "$func_basename_result"
9126968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    done | sort | sort -uc >/dev/null 2>&1); then
9127968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  :
9128968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	else
9129968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  echo "copying selected object files to avoid basename conflicts..."
9130968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  gentop="$output_objdir/${outputname}x"
9131968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_append generated " $gentop"
9132968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_mkdir_p "$gentop"
9133968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  save_oldobjs=$oldobjs
9134968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  oldobjs=
9135968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  counter=1
9136968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  for obj in $save_oldobjs
9137968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  do
9138968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_basename "$obj"
9139968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    objbase="$func_basename_result"
9140968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    case " $oldobjs " in
9141968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    " ") oldobjs=$obj ;;
9142968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *[\ /]"$objbase "*)
9143968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      while :; do
9144968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		# Make sure we don't pick an alternate name that also
9145968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		# overlaps.
9146968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		newobj=lt$counter-$objbase
9147968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_arith $counter + 1
9148968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		counter=$func_arith_result
9149968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		case " $oldobjs " in
9150968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		*[\ /]"$newobj "*) ;;
9151968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
9152968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		esac
9153968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      done
9154968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
9155968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_append oldobjs " $gentop/$newobj"
9156968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      ;;
9157968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *) func_append oldobjs " $obj" ;;
9158968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    esac
9159968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  done
9160968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
9161968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	eval cmds=\"$old_archive_cmds\"
9162968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9163968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_len " $cmds"
9164968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	len=$func_len_result
9165968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
9166968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  cmds=$old_archive_cmds
9167968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	elif test -n "$archiver_list_spec"; then
9168968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_verbose "using command file archive linking..."
9169968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  for obj in $oldobjs
9170968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  do
9171968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_to_tool_file "$obj"
9172968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    $ECHO "$func_to_tool_file_result"
9173968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  done > $output_objdir/$libname.libcmd
9174968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_to_tool_file "$output_objdir/$libname.libcmd"
9175968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
9176968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  cmds=$old_archive_cmds
9177968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	else
9178968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # the command line is too long to link in one step, link in parts
9179968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_verbose "using piecewise archive linking..."
9180968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  save_RANLIB=$RANLIB
9181968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  RANLIB=:
9182968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  objlist=
9183968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  concat_cmds=
9184968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  save_oldobjs=$oldobjs
9185968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  oldobjs=
9186968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Is there a better way of finding the last object in the list?
9187968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  for obj in $save_oldobjs
9188968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  do
9189968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    last_oldobj=$obj
9190968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  done
9191968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  eval test_cmds=\"$old_archive_cmds\"
9192968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_len " $test_cmds"
9193968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  len0=$func_len_result
9194968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  len=$len0
9195968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  for obj in $save_oldobjs
9196968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  do
9197968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_len " $obj"
9198968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_arith $len + $func_len_result
9199968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    len=$func_arith_result
9200968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append objlist " $obj"
9201968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "$len" -lt "$max_cmd_len"; then
9202968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      :
9203968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    else
9204968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # the above command should be used before it gets too long
9205968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      oldobjs=$objlist
9206968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if test "$obj" = "$last_oldobj" ; then
9207968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		RANLIB=$save_RANLIB
9208968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
9209968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9210968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
9211968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      objlist=
9212968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      len=$len0
9213968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
9214968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  done
9215968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  RANLIB=$save_RANLIB
9216968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  oldobjs=$objlist
9217968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "X$oldobjs" = "X" ; then
9218968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    eval cmds=\"\$concat_cmds\"
9219968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
9220968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
9221968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
9222968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
9223968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
9224968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_execute_cmds "$cmds" 'exit $?'
9225968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    done
9226968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9227968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    test -n "$generated" && \
9228968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_show_eval "${RM}r$generated"
9229968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9230968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Now create the libtool archive.
9231968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    case $output in
9232968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    *.la)
9233968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      old_library=
9234968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      test "$build_old_libs" = yes && old_library="$libname.$libext"
9235968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_verbose "creating $output"
9236968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9237968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Preserve any variables that may affect compiler behavior
9238968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      for var in $variables_saved_for_relink; do
9239968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if eval test -z \"\${$var+set}\"; then
9240968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9241968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	elif eval var_value=\$$var; test -z "$var_value"; then
9242968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  relink_command="$var=; export $var; $relink_command"
9243968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	else
9244968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_quote_for_eval "$var_value"
9245968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9246968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
9247968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      done
9248968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Quote the link command for shipping.
9249968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
9250968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9251968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test "$hardcode_automatic" = yes ; then
9252968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	relink_command=
9253968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
9254968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9255968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Only create the output if not a dry run.
9256968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      $opt_dry_run || {
9257968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	for installed in no yes; do
9258968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$installed" = yes; then
9259968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test -z "$install_libdir"; then
9260968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      break
9261968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
9262968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    output="$output_objdir/$outputname"i
9263968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # Replace all uninstalled libtool libraries with the installed ones
9264968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    newdependency_libs=
9265968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    for deplib in $dependency_libs; do
9266968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case $deplib in
9267968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *.la)
9268968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_basename "$deplib"
9269968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		name="$func_basename_result"
9270968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
9271968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		test -z "$libdir" && \
9272968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  func_fatal_error "\`$deplib' is not a valid libtool archive"
9273968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
9274968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		;;
9275968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      -L*)
9276968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_stripname -L '' "$deplib"
9277968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_replace_sysroot "$func_stripname_result"
9278968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_append newdependency_libs " -L$func_replace_sysroot_result"
9279968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		;;
9280968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      -R*)
9281968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_stripname -R '' "$deplib"
9282968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_replace_sysroot "$func_stripname_result"
9283968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_append newdependency_libs " -R$func_replace_sysroot_result"
9284968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		;;
9285968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *) func_append newdependency_libs " $deplib" ;;
9286968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
9287968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    done
9288968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    dependency_libs="$newdependency_libs"
9289968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    newdlfiles=
9290968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9291968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    for lib in $dlfiles; do
9292968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case $lib in
9293968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *.la)
9294968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	        func_basename "$lib"
9295968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		name="$func_basename_result"
9296968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9297968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		test -z "$libdir" && \
9298968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  func_fatal_error "\`$lib' is not a valid libtool archive"
9299968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
9300968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		;;
9301968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *) func_append newdlfiles " $lib" ;;
9302968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
9303968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    done
9304968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    dlfiles="$newdlfiles"
9305968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    newdlprefiles=
9306968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    for lib in $dlprefiles; do
9307968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case $lib in
9308968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      *.la)
9309968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		# Only pass preopened files to the pseudo-archive (for
9310968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		# eventual linking with the app. that links it) if we
9311968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		# didn't already link the preopened objects directly into
9312968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		# the library:
9313968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_basename "$lib"
9314968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		name="$func_basename_result"
9315968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9316968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		test -z "$libdir" && \
9317968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		  func_fatal_error "\`$lib' is not a valid libtool archive"
9318968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
9319968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		;;
9320968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
9321968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    done
9322968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    dlprefiles="$newdlprefiles"
9323968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  else
9324968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    newdlfiles=
9325968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    for lib in $dlfiles; do
9326968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case $lib in
9327968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9328968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		*) abs=`pwd`"/$lib" ;;
9329968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
9330968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_append newdlfiles " $abs"
9331968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    done
9332968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    dlfiles="$newdlfiles"
9333968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    newdlprefiles=
9334968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    for lib in $dlprefiles; do
9335968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      case $lib in
9336968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9337968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		*) abs=`pwd`"/$lib" ;;
9338968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      esac
9339968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_append newdlprefiles " $abs"
9340968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    done
9341968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    dlprefiles="$newdlprefiles"
9342968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
9343968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  $RM $output
9344968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # place dlname in correct position for cygwin
9345968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # In fact, it would be nice if we could use this code for all target
9346968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # systems that can't hard-code library paths into their executables
9347968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # and that have no shared library path variable independent of PATH,
9348968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # but it turns out we can't easily determine that from inspecting
9349968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # libtool variables, so we have to hard-code the OSs to which it
9350968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # applies here; at the moment, that means platforms that use the PE
9351968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # object format with DLL files.  See the long comment at the top of
9352968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # tests/bindir.at for full details.
9353968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  tdlname=$dlname
9354968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case $host,$output,$installed,$module,$dlname in
9355968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
9356968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # If a -bindir argument was supplied, place the dll there.
9357968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      if test "x$bindir" != x ;
9358968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      then
9359968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		func_relative_path "$install_libdir" "$bindir"
9360968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		tdlname=$func_relative_path_result$dlname
9361968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      else
9362968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		# Otherwise fall back on heuristic.
9363968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold		tdlname=../bin/$dlname
9364968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      fi
9365968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      ;;
9366968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
9367968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  $ECHO > $output "\
9368968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# $outputname - a libtool library file
9369968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
9370968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#
9371968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Please DO NOT delete this file!
9372968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# It is necessary for linking the library.
9373968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9374968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# The name that we can dlopen(3).
9375968bf19396ad404e89420f5d67900fce13f4186cGilad Arnolddlname='$tdlname'
9376968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9377968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Names of this library.
9378968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldlibrary_names='$library_names'
9379968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9380968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# The name of the static archive.
9381968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldold_library='$old_library'
9382968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9383968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Linker flags that can not go in dependency_libs.
9384968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldinherited_linker_flags='$new_inherited_linker_flags'
9385968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9386968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Libraries that this one depends upon.
9387968bf19396ad404e89420f5d67900fce13f4186cGilad Arnolddependency_libs='$dependency_libs'
9388968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9389968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Names of additional weak libraries provided by this library
9390968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldweak_library_names='$weak_libs'
9391968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9392968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Version information for $libname.
9393968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldcurrent=$current
9394968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldage=$age
9395968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldrevision=$revision
9396968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9397968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Is this an already installed library?
9398968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldinstalled=$installed
9399968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9400968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Should we warn about portability when linking against -modules?
9401968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldshouldnotlink=$module
9402968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9403968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Files to dlopen/dlpreopen
9404968bf19396ad404e89420f5d67900fce13f4186cGilad Arnolddlopen='$dlfiles'
9405968bf19396ad404e89420f5d67900fce13f4186cGilad Arnolddlpreopen='$dlprefiles'
9406968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9407968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Directory that this library needs to be installed in:
9408968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldlibdir='$install_libdir'"
9409968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test "$installed" = no && test "$need_relink" = yes; then
9410968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    $ECHO >> $output "\
9411968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldrelink_command=\"$relink_command\""
9412968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
9413968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	done
9414968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      }
9415968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9416968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Do a symbolic link so that the libtool archive can be found in
9417968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # LD_LIBRARY_PATH before the program is installed.
9418968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
9419968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      ;;
9420968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    esac
9421968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    exit $EXIT_SUCCESS
9422968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
9423968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9424968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
9425968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_mode_link ${1+"$@"}
9426968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9427968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9428968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# func_mode_uninstall arg...
9429968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfunc_mode_uninstall ()
9430968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{
9431968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    $opt_debug
9432968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    RM="$nonopt"
9433968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    files=
9434968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    rmforce=
9435968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    exit_status=0
9436968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9437968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # This variable tells wrapper scripts just to set variables rather
9438968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # than running their programs.
9439968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    libtool_install_magic="$magic"
9440968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9441968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    for arg
9442968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    do
9443968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      case $arg in
9444968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -f) func_append RM " $arg"; rmforce=yes ;;
9445968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      -*) func_append RM " $arg" ;;
9446968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *) func_append files " $arg" ;;
9447968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      esac
9448968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    done
9449968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9450968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    test -z "$RM" && \
9451968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_fatal_help "you must specify an RM program"
9452968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9453968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    rmdirs=
9454968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9455968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    for file in $files; do
9456968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_dirname "$file" "" "."
9457968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      dir="$func_dirname_result"
9458968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test "X$dir" = X.; then
9459968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	odir="$objdir"
9460968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      else
9461968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	odir="$dir/$objdir"
9462968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
9463968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_basename "$file"
9464968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      name="$func_basename_result"
9465968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      test "$opt_mode" = uninstall && odir="$dir"
9466968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9467968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Remember odir for removal later, being careful to avoid duplicates
9468968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test "$opt_mode" = clean; then
9469968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	case " $rmdirs " in
9470968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *" $odir "*) ;;
9471968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *) func_append rmdirs " $odir" ;;
9472968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	esac
9473968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
9474968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9475968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      # Don't error if the file doesn't exist and rm -f was used.
9476968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if { test -L "$file"; } >/dev/null 2>&1 ||
9477968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	 { test -h "$file"; } >/dev/null 2>&1 ||
9478968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	 test -f "$file"; then
9479968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	:
9480968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      elif test -d "$file"; then
9481968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	exit_status=1
9482968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
9483968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      elif test "$rmforce" = yes; then
9484968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	continue
9485968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
9486968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9487968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      rmfiles="$file"
9488968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9489968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      case $name in
9490968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *.la)
9491968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Possibly a libtool archive, so verify it.
9492968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if func_lalib_p "$file"; then
9493968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_source $dir/$name
9494968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9495968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Delete the libtool libraries and symlinks.
9496968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  for n in $library_names; do
9497968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append rmfiles " $odir/$n"
9498968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  done
9499968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
9500968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9501968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case "$opt_mode" in
9502968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  clean)
9503968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    case " $library_names " in
9504968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *" $dlname "*) ;;
9505968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
9506968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    esac
9507968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
9508968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
9509968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  uninstall)
9510968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test -n "$library_names"; then
9511968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # Do each command in the postuninstall commands.
9512968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9513968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
9514968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9515968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test -n "$old_library"; then
9516968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      # Do each command in the old_postuninstall commands.
9517968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9518968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
9519968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # FIXME: should reinstall the best remaining shared library.
9520968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
9521968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
9522968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
9523968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
9524968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9525968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *.lo)
9526968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	# Possibly a libtool object, so verify it.
9527968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if func_lalib_p "$file"; then
9528968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9529968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Read the .lo file
9530968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  func_source $dir/$name
9531968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9532968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Add PIC object to the list of files to remove.
9533968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -n "$pic_object" &&
9534968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	     test "$pic_object" != none; then
9535968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append rmfiles " $dir/$pic_object"
9536968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
9537968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9538968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Add non-PIC object to the list of files to remove.
9539968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if test -n "$non_pic_object" &&
9540968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	     test "$non_pic_object" != none; then
9541968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append rmfiles " $dir/$non_pic_object"
9542968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
9543968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
9544968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
9545968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9546968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      *)
9547968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	if test "$opt_mode" = clean ; then
9548968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  noexename=$name
9549968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  case $file in
9550968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  *.exe)
9551968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_stripname '' '.exe' "$file"
9552968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    file=$func_stripname_result
9553968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_stripname '' '.exe' "$name"
9554968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    noexename=$func_stripname_result
9555968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # $file with .exe has already been added to rmfiles,
9556968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # add $file without .exe
9557968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append rmfiles " $file"
9558968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    ;;
9559968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  esac
9560968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  # Do a test to see if this is a libtool program.
9561968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  if func_ltwrapper_p "$file"; then
9562968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if func_ltwrapper_executable_p "$file"; then
9563968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_ltwrapper_scriptname "$file"
9564968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      relink_command=
9565968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_source $func_ltwrapper_scriptname_result
9566968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_append rmfiles " $func_ltwrapper_scriptname_result"
9567968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    else
9568968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      relink_command=
9569968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_source $dir/$noexename
9570968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
9571968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9572968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # note $name still contains .exe if it was in $file originally
9573968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    # as does the version of $file that was added into $rmfiles
9574968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
9575968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "$fast_install" = yes && test -n "$relink_command"; then
9576968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_append rmfiles " $odir/lt-$name"
9577968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
9578968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    if test "X$noexename" != "X$name" ; then
9579968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	      func_append rmfiles " $odir/lt-${noexename}.c"
9580968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	    fi
9581968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	  fi
9582968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	fi
9583968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	;;
9584968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      esac
9585968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      func_show_eval "$RM $rmfiles" 'exit_status=1'
9586968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    done
9587968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9588968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    # Try to remove the ${objdir}s in the directories where we deleted files
9589968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    for dir in $rmdirs; do
9590968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      if test -d "$dir"; then
9591968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold	func_show_eval "rmdir $dir >/dev/null 2>&1"
9592968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold      fi
9593968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    done
9594968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9595968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    exit $exit_status
9596968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
9597968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9598968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
9599968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    func_mode_uninstall ${1+"$@"}
9600968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9601968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldtest -z "$opt_mode" && {
9602968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  help="$generic_help"
9603968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_fatal_help "you must specify a MODE"
9604968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold}
9605968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9606968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldtest -z "$exec_cmd" && \
9607968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  func_fatal_help "invalid operation mode \`$opt_mode'"
9608968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9609968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldif test -n "$exec_cmd"; then
9610968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  eval exec "$exec_cmd"
9611968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  exit $EXIT_FAILURE
9612968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldfi
9613968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9614968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldexit $exit_status
9615968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9616968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9617968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# The TAGs below are defined such that we never get into a situation
9618968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# in which we disable both kinds of libraries.  Given conflicting
9619968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# choices, we go for a static library, that is the most portable,
9620968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# since we can't tell whether shared libraries were disabled because
9621968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# the user asked for that or because the platform doesn't support
9622968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# them.  This is particularly important on AIX, because we don't
9623968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# support having both static and shared libraries enabled at the same
9624968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# time on that platform, so we default to a shared-only configuration.
9625968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# If a disable-shared tag is given, we'll fallback to a static-only
9626968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# configuration.  But we'll never go from static-only to shared-only.
9627968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9628968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
9629968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldbuild_libtool_libs=no
9630968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldbuild_old_libs=yes
9631968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# ### END LIBTOOL TAG CONFIG: disable-shared
9632968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9633968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# ### BEGIN LIBTOOL TAG CONFIG: disable-static
9634968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
9635968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# ### END LIBTOOL TAG CONFIG: disable-static
9636968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9637968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# Local Variables:
9638968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# mode:shell-script
9639968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# sh-indentation:2
9640968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# End:
9641968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold# vi:sw=2
9642968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
9643