ltmain.sh revision 2e2dd055
1a966c04fSmrg# ltmain.sh - Provide generalized library-building support services.
2a966c04fSmrg# NOTE: Changing this file will not affect anything until you rerun configure.
3a966c04fSmrg#
42e2dd055Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
52e2dd055Smrg# 2007, 2008  Free Software Foundation, Inc.
6a966c04fSmrg# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
7a966c04fSmrg#
8a966c04fSmrg# This program is free software; you can redistribute it and/or modify
9a966c04fSmrg# it under the terms of the GNU General Public License as published by
10a966c04fSmrg# the Free Software Foundation; either version 2 of the License, or
11a966c04fSmrg# (at your option) any later version.
12a966c04fSmrg#
13a966c04fSmrg# This program is distributed in the hope that it will be useful, but
14a966c04fSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
15a966c04fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16a966c04fSmrg# General Public License for more details.
17a966c04fSmrg#
18a966c04fSmrg# You should have received a copy of the GNU General Public License
19a966c04fSmrg# along with this program; if not, write to the Free Software
20a966c04fSmrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21a966c04fSmrg#
22a966c04fSmrg# As a special exception to the GNU General Public License, if you
23a966c04fSmrg# distribute this file as part of a program that contains a
24a966c04fSmrg# configuration script generated by Autoconf, you may include it under
25a966c04fSmrg# the same distribution terms that you use for the rest of that program.
26a966c04fSmrg
27a966c04fSmrgbasename="s,^.*/,,g"
28a966c04fSmrg
29a966c04fSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
30a966c04fSmrg# is ksh but when the shell is invoked as "sh" and the current value of
31a966c04fSmrg# the _XPG environment variable is not equal to 1 (one), the special
32a966c04fSmrg# positional parameter $0, within a function call, is the name of the
33a966c04fSmrg# function.
34a966c04fSmrgprogpath="$0"
35a966c04fSmrg
36a966c04fSmrg# The name of this program:
37a966c04fSmrgprogname=`echo "$progpath" | $SED $basename`
38a966c04fSmrgmodename="$progname"
39a966c04fSmrg
40a966c04fSmrg# Global variables:
41a966c04fSmrgEXIT_SUCCESS=0
42a966c04fSmrgEXIT_FAILURE=1
43a966c04fSmrg
44a966c04fSmrgPROGRAM=ltmain.sh
45a966c04fSmrgPACKAGE=libtool
462e2dd055SmrgVERSION=1.5.26
472e2dd055SmrgTIMESTAMP=" (1.1220.2.492 2008/01/30 06:40:56)"
482e2dd055Smrg
492e2dd055Smrg# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE).
502e2dd055Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
512e2dd055Smrg  emulate sh
522e2dd055Smrg  NULLCMD=:
532e2dd055Smrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
542e2dd055Smrg  # is contrary to our usage.  Disable this feature.
552e2dd055Smrg  alias -g '${1+"$@"}'='"$@"'
56a966c04fSmrg  setopt NO_GLOB_SUBST
572e2dd055Smrgelse
582e2dd055Smrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
59a966c04fSmrgfi
602e2dd055SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
612e2dd055SmrgDUALCASE=1; export DUALCASE # for MKS sh
62a966c04fSmrg
63a966c04fSmrg# Check that we have a working $echo.
64a966c04fSmrgif test "X$1" = X--no-reexec; then
65a966c04fSmrg  # Discard the --no-reexec flag, and continue.
66a966c04fSmrg  shift
67a966c04fSmrgelif test "X$1" = X--fallback-echo; then
68a966c04fSmrg  # Avoid inline document here, it may be left over
69a966c04fSmrg  :
70a966c04fSmrgelif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
71a966c04fSmrg  # Yippee, $echo works!
72a966c04fSmrg  :
73a966c04fSmrgelse
74a966c04fSmrg  # Restart under the correct shell, and then maybe $echo will work.
75a966c04fSmrg  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
76a966c04fSmrgfi
77a966c04fSmrg
78a966c04fSmrgif test "X$1" = X--fallback-echo; then
79a966c04fSmrg  # used as fallback echo
80a966c04fSmrg  shift
81a966c04fSmrg  cat <<EOF
82a966c04fSmrg$*
83a966c04fSmrgEOF
84a966c04fSmrg  exit $EXIT_SUCCESS
85a966c04fSmrgfi
86a966c04fSmrg
87a966c04fSmrgdefault_mode=
88a966c04fSmrghelp="Try \`$progname --help' for more information."
89a966c04fSmrgmagic="%%%MAGIC variable%%%"
90a966c04fSmrgmkdir="mkdir"
91a966c04fSmrgmv="mv -f"
92a966c04fSmrgrm="rm -f"
93a966c04fSmrg
94a966c04fSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
95a966c04fSmrg# metacharacters that are still active within double-quoted strings.
96a966c04fSmrgXsed="${SED}"' -e 1s/^X//'
97a966c04fSmrgsed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
98a966c04fSmrg# test EBCDIC or ASCII
99a966c04fSmrgcase `echo X|tr X '\101'` in
100a966c04fSmrg A) # ASCII based system
101a966c04fSmrg    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
102a966c04fSmrg  SP2NL='tr \040 \012'
103a966c04fSmrg  NL2SP='tr \015\012 \040\040'
104a966c04fSmrg  ;;
105a966c04fSmrg *) # EBCDIC based system
106a966c04fSmrg  SP2NL='tr \100 \n'
107a966c04fSmrg  NL2SP='tr \r\n \100\100'
108a966c04fSmrg  ;;
109a966c04fSmrgesac
110a966c04fSmrg
111a966c04fSmrg# NLS nuisances.
112a966c04fSmrg# Only set LANG and LC_ALL to C if already set.
113a966c04fSmrg# These must not be set unconditionally because not all systems understand
114a966c04fSmrg# e.g. LANG=C (notably SCO).
115a966c04fSmrg# We save the old values to restore during execute mode.
1162e2dd055Smrglt_env=
1172e2dd055Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
1182e2dd055Smrgdo
1192e2dd055Smrg  eval "if test \"\${$lt_var+set}\" = set; then
1202e2dd055Smrg	  save_$lt_var=\$$lt_var
1212e2dd055Smrg	  lt_env=\"$lt_var=\$$lt_var \$lt_env\"
1222e2dd055Smrg	  $lt_var=C
1232e2dd055Smrg	  export $lt_var
1242e2dd055Smrg	fi"
1252e2dd055Smrgdone
1262e2dd055Smrg
1272e2dd055Smrgif test -n "$lt_env"; then
1282e2dd055Smrg  lt_env="env $lt_env"
129a966c04fSmrgfi
130a966c04fSmrg
131a966c04fSmrg# Make sure IFS has a sensible default
132a966c04fSmrglt_nl='
133a966c04fSmrg'
134a966c04fSmrgIFS=" 	$lt_nl"
135a966c04fSmrg
136a966c04fSmrgif test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
137a966c04fSmrg  $echo "$modename: not configured to build any kind of library" 1>&2
138a966c04fSmrg  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
139a966c04fSmrg  exit $EXIT_FAILURE
140a966c04fSmrgfi
141a966c04fSmrg
142a966c04fSmrg# Global variables.
143a966c04fSmrgmode=$default_mode
144a966c04fSmrgnonopt=
145a966c04fSmrgprev=
146a966c04fSmrgprevopt=
147a966c04fSmrgrun=
148a966c04fSmrgshow="$echo"
149a966c04fSmrgshow_help=
150a966c04fSmrgexecute_dlfiles=
151a966c04fSmrgduplicate_deps=no
152a966c04fSmrgpreserve_args=
153a966c04fSmrglo2o="s/\\.lo\$/.${objext}/"
154a966c04fSmrgo2lo="s/\\.${objext}\$/.lo/"
1552e2dd055Smrgextracted_archives=
1562e2dd055Smrgextracted_serial=0
157a966c04fSmrg
158a966c04fSmrg#####################################
159a966c04fSmrg# Shell function definitions:
160a966c04fSmrg# This seems to be the best place for them
161a966c04fSmrg
162a966c04fSmrg# func_mktempdir [string]
163a966c04fSmrg# Make a temporary directory that won't clash with other running
164a966c04fSmrg# libtool processes, and avoids race conditions if possible.  If
165a966c04fSmrg# given, STRING is the basename for that directory.
166a966c04fSmrgfunc_mktempdir ()
167a966c04fSmrg{
168a966c04fSmrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
169a966c04fSmrg
170a966c04fSmrg    if test "$run" = ":"; then
171a966c04fSmrg      # Return a directory name, but don't create it in dry-run mode
172a966c04fSmrg      my_tmpdir="${my_template}-$$"
173a966c04fSmrg    else
174a966c04fSmrg
175a966c04fSmrg      # If mktemp works, use that first and foremost
176a966c04fSmrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
177a966c04fSmrg
178a966c04fSmrg      if test ! -d "$my_tmpdir"; then
179a966c04fSmrg	# Failing that, at least try and use $RANDOM to avoid a race
180a966c04fSmrg	my_tmpdir="${my_template}-${RANDOM-0}$$"
181a966c04fSmrg
182a966c04fSmrg	save_mktempdir_umask=`umask`
183a966c04fSmrg	umask 0077
184a966c04fSmrg	$mkdir "$my_tmpdir"
185a966c04fSmrg	umask $save_mktempdir_umask
186a966c04fSmrg      fi
187a966c04fSmrg
188a966c04fSmrg      # If we're not in dry-run mode, bomb out on failure
189a966c04fSmrg      test -d "$my_tmpdir" || {
190a966c04fSmrg        $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
191a966c04fSmrg	exit $EXIT_FAILURE
192a966c04fSmrg      }
193a966c04fSmrg    fi
194a966c04fSmrg
195a966c04fSmrg    $echo "X$my_tmpdir" | $Xsed
196a966c04fSmrg}
197a966c04fSmrg
198a966c04fSmrg
199a966c04fSmrg# func_win32_libid arg
200a966c04fSmrg# return the library type of file 'arg'
201a966c04fSmrg#
202a966c04fSmrg# Need a lot of goo to handle *both* DLLs and import libs
203a966c04fSmrg# Has to be a shell function in order to 'eat' the argument
204a966c04fSmrg# that is supplied when $file_magic_command is called.
205a966c04fSmrgfunc_win32_libid ()
206a966c04fSmrg{
207a966c04fSmrg  win32_libid_type="unknown"
208a966c04fSmrg  win32_fileres=`file -L $1 2>/dev/null`
209a966c04fSmrg  case $win32_fileres in
210a966c04fSmrg  *ar\ archive\ import\ library*) # definitely import
211a966c04fSmrg    win32_libid_type="x86 archive import"
212a966c04fSmrg    ;;
213a966c04fSmrg  *ar\ archive*) # could be an import, or static
214a966c04fSmrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
215a966c04fSmrg      $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
216a966c04fSmrg      win32_nmres=`eval $NM -f posix -A $1 | \
2172e2dd055Smrg	$SED -n -e '1,100{
2182e2dd055Smrg		/ I /{
2192e2dd055Smrg			s,.*,import,
2202e2dd055Smrg			p
2212e2dd055Smrg			q
2222e2dd055Smrg			}
2232e2dd055Smrg		}'`
224a966c04fSmrg      case $win32_nmres in
225a966c04fSmrg      import*)  win32_libid_type="x86 archive import";;
226a966c04fSmrg      *)        win32_libid_type="x86 archive static";;
227a966c04fSmrg      esac
228a966c04fSmrg    fi
229a966c04fSmrg    ;;
230a966c04fSmrg  *DLL*)
231a966c04fSmrg    win32_libid_type="x86 DLL"
232a966c04fSmrg    ;;
233a966c04fSmrg  *executable*) # but shell scripts are "executable" too...
234a966c04fSmrg    case $win32_fileres in
235a966c04fSmrg    *MS\ Windows\ PE\ Intel*)
236a966c04fSmrg      win32_libid_type="x86 DLL"
237a966c04fSmrg      ;;
238a966c04fSmrg    esac
239a966c04fSmrg    ;;
240a966c04fSmrg  esac
241a966c04fSmrg  $echo $win32_libid_type
242a966c04fSmrg}
243a966c04fSmrg
244a966c04fSmrg
245a966c04fSmrg# func_infer_tag arg
246a966c04fSmrg# Infer tagged configuration to use if any are available and
247a966c04fSmrg# if one wasn't chosen via the "--tag" command line option.
248a966c04fSmrg# Only attempt this if the compiler in the base compile
249a966c04fSmrg# command doesn't match the default compiler.
250a966c04fSmrg# arg is usually of the form 'gcc ...'
251a966c04fSmrgfunc_infer_tag ()
252a966c04fSmrg{
253a966c04fSmrg    if test -n "$available_tags" && test -z "$tagname"; then
254a966c04fSmrg      CC_quoted=
255a966c04fSmrg      for arg in $CC; do
256a966c04fSmrg	case $arg in
257a966c04fSmrg	  *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
258a966c04fSmrg	  arg="\"$arg\""
259a966c04fSmrg	  ;;
260a966c04fSmrg	esac
261a966c04fSmrg	CC_quoted="$CC_quoted $arg"
262a966c04fSmrg      done
263a966c04fSmrg      case $@ in
264a966c04fSmrg      # Blanks in the command may have been stripped by the calling shell,
265a966c04fSmrg      # but not from the CC environment variable when configure was run.
266a966c04fSmrg      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
267a966c04fSmrg      # Blanks at the start of $base_compile will cause this to fail
268a966c04fSmrg      # if we don't check for them as well.
269a966c04fSmrg      *)
270a966c04fSmrg	for z in $available_tags; do
271a966c04fSmrg	  if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
272a966c04fSmrg	    # Evaluate the configuration.
273a966c04fSmrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
274a966c04fSmrg	    CC_quoted=
275a966c04fSmrg	    for arg in $CC; do
276a966c04fSmrg	    # Double-quote args containing other shell metacharacters.
277a966c04fSmrg	    case $arg in
278a966c04fSmrg	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
279a966c04fSmrg	      arg="\"$arg\""
280a966c04fSmrg	      ;;
281a966c04fSmrg	    esac
282a966c04fSmrg	    CC_quoted="$CC_quoted $arg"
283a966c04fSmrg	  done
284a966c04fSmrg	    case "$@ " in
285a966c04fSmrg	      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
286a966c04fSmrg	      # The compiler in the base compile command matches
287a966c04fSmrg	      # the one in the tagged configuration.
288a966c04fSmrg	      # Assume this is the tagged configuration we want.
289a966c04fSmrg	      tagname=$z
290a966c04fSmrg	      break
291a966c04fSmrg	      ;;
292a966c04fSmrg	    esac
293a966c04fSmrg	  fi
294a966c04fSmrg	done
295a966c04fSmrg	# If $tagname still isn't set, then no tagged configuration
296a966c04fSmrg	# was found and let the user know that the "--tag" command
297a966c04fSmrg	# line option must be used.
298a966c04fSmrg	if test -z "$tagname"; then
299a966c04fSmrg	  $echo "$modename: unable to infer tagged configuration"
300a966c04fSmrg	  $echo "$modename: specify a tag with \`--tag'" 1>&2
301a966c04fSmrg	  exit $EXIT_FAILURE
302a966c04fSmrg#        else
303a966c04fSmrg#          $echo "$modename: using $tagname tagged configuration"
304a966c04fSmrg	fi
305a966c04fSmrg	;;
306a966c04fSmrg      esac
307a966c04fSmrg    fi
308a966c04fSmrg}
309a966c04fSmrg
310a966c04fSmrg
311a966c04fSmrg# func_extract_an_archive dir oldlib
312a966c04fSmrgfunc_extract_an_archive ()
313a966c04fSmrg{
314a966c04fSmrg    f_ex_an_ar_dir="$1"; shift
315a966c04fSmrg    f_ex_an_ar_oldlib="$1"
316a966c04fSmrg
317a966c04fSmrg    $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
318a966c04fSmrg    $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
319a966c04fSmrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
320a966c04fSmrg     :
321a966c04fSmrg    else
322a966c04fSmrg      $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
323a966c04fSmrg      exit $EXIT_FAILURE
324a966c04fSmrg    fi
325a966c04fSmrg}
326a966c04fSmrg
327a966c04fSmrg# func_extract_archives gentop oldlib ...
328a966c04fSmrgfunc_extract_archives ()
329a966c04fSmrg{
330a966c04fSmrg    my_gentop="$1"; shift
331a966c04fSmrg    my_oldlibs=${1+"$@"}
332a966c04fSmrg    my_oldobjs=""
333a966c04fSmrg    my_xlib=""
334a966c04fSmrg    my_xabs=""
335a966c04fSmrg    my_xdir=""
336a966c04fSmrg    my_status=""
337a966c04fSmrg
338a966c04fSmrg    $show "${rm}r $my_gentop"
339a966c04fSmrg    $run ${rm}r "$my_gentop"
340a966c04fSmrg    $show "$mkdir $my_gentop"
341a966c04fSmrg    $run $mkdir "$my_gentop"
342a966c04fSmrg    my_status=$?
343a966c04fSmrg    if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
344a966c04fSmrg      exit $my_status
345a966c04fSmrg    fi
346a966c04fSmrg
347a966c04fSmrg    for my_xlib in $my_oldlibs; do
348a966c04fSmrg      # Extract the objects.
349a966c04fSmrg      case $my_xlib in
350a966c04fSmrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
351a966c04fSmrg	*) my_xabs=`pwd`"/$my_xlib" ;;
352a966c04fSmrg      esac
353a966c04fSmrg      my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
3542e2dd055Smrg      my_xlib_u=$my_xlib
3552e2dd055Smrg      while :; do
3562e2dd055Smrg        case " $extracted_archives " in
3572e2dd055Smrg	*" $my_xlib_u "*)
3582e2dd055Smrg	  extracted_serial=`expr $extracted_serial + 1`
3592e2dd055Smrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
3602e2dd055Smrg	*) break ;;
3612e2dd055Smrg	esac
3622e2dd055Smrg      done
3632e2dd055Smrg      extracted_archives="$extracted_archives $my_xlib_u"
3642e2dd055Smrg      my_xdir="$my_gentop/$my_xlib_u"
365a966c04fSmrg
366a966c04fSmrg      $show "${rm}r $my_xdir"
367a966c04fSmrg      $run ${rm}r "$my_xdir"
368a966c04fSmrg      $show "$mkdir $my_xdir"
369a966c04fSmrg      $run $mkdir "$my_xdir"
370a966c04fSmrg      exit_status=$?
371a966c04fSmrg      if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
372a966c04fSmrg	exit $exit_status
373a966c04fSmrg      fi
374a966c04fSmrg      case $host in
375a966c04fSmrg      *-darwin*)
376a966c04fSmrg	$show "Extracting $my_xabs"
377a966c04fSmrg	# Do not bother doing anything if just a dry run
378a966c04fSmrg	if test -z "$run"; then
379a966c04fSmrg	  darwin_orig_dir=`pwd`
380a966c04fSmrg	  cd $my_xdir || exit $?
381a966c04fSmrg	  darwin_archive=$my_xabs
382a966c04fSmrg	  darwin_curdir=`pwd`
383a966c04fSmrg	  darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
384a966c04fSmrg	  darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
385a966c04fSmrg	  if test -n "$darwin_arches"; then 
386a966c04fSmrg	    darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
387a966c04fSmrg	    darwin_arch=
388a966c04fSmrg	    $show "$darwin_base_archive has multiple architectures $darwin_arches"
389a966c04fSmrg	    for darwin_arch in  $darwin_arches ; do
390a966c04fSmrg	      mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
391a966c04fSmrg	      lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
392a966c04fSmrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
393a966c04fSmrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
394a966c04fSmrg	      cd "$darwin_curdir"
395a966c04fSmrg	      $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
396a966c04fSmrg	    done # $darwin_arches
397a966c04fSmrg      ## Okay now we have a bunch of thin objects, gotta fatten them up :)
398a966c04fSmrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
399a966c04fSmrg	    darwin_file=
400a966c04fSmrg	    darwin_files=
401a966c04fSmrg	    for darwin_file in $darwin_filelist; do
402a966c04fSmrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
403a966c04fSmrg	      lipo -create -output "$darwin_file" $darwin_files
404a966c04fSmrg	    done # $darwin_filelist
405a966c04fSmrg	    ${rm}r unfat-$$
406a966c04fSmrg	    cd "$darwin_orig_dir"
407a966c04fSmrg	  else
408a966c04fSmrg	    cd "$darwin_orig_dir"
409a966c04fSmrg 	    func_extract_an_archive "$my_xdir" "$my_xabs"
410a966c04fSmrg	  fi # $darwin_arches
411a966c04fSmrg	fi # $run
412a966c04fSmrg	;;
413a966c04fSmrg      *)
414a966c04fSmrg        func_extract_an_archive "$my_xdir" "$my_xabs"
415a966c04fSmrg        ;;
416a966c04fSmrg      esac
417a966c04fSmrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
418a966c04fSmrg    done
419a966c04fSmrg    func_extract_archives_result="$my_oldobjs"
420a966c04fSmrg}
421a966c04fSmrg# End of Shell function definitions
422a966c04fSmrg#####################################
423a966c04fSmrg
424a966c04fSmrg# Darwin sucks
425a966c04fSmrgeval std_shrext=\"$shrext_cmds\"
426a966c04fSmrg
427a966c04fSmrgdisable_libs=no
428a966c04fSmrg
429a966c04fSmrg# Parse our command line options once, thoroughly.
430a966c04fSmrgwhile test "$#" -gt 0
431a966c04fSmrgdo
432a966c04fSmrg  arg="$1"
433a966c04fSmrg  shift
434a966c04fSmrg
435a966c04fSmrg  case $arg in
436a966c04fSmrg  -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
437a966c04fSmrg  *) optarg= ;;
438a966c04fSmrg  esac
439a966c04fSmrg
440a966c04fSmrg  # If the previous option needs an argument, assign it.
441a966c04fSmrg  if test -n "$prev"; then
442a966c04fSmrg    case $prev in
443a966c04fSmrg    execute_dlfiles)
444a966c04fSmrg      execute_dlfiles="$execute_dlfiles $arg"
445a966c04fSmrg      ;;
446a966c04fSmrg    tag)
447a966c04fSmrg      tagname="$arg"
448a966c04fSmrg      preserve_args="${preserve_args}=$arg"
449a966c04fSmrg
450a966c04fSmrg      # Check whether tagname contains only valid characters
451a966c04fSmrg      case $tagname in
452a966c04fSmrg      *[!-_A-Za-z0-9,/]*)
453a966c04fSmrg	$echo "$progname: invalid tag name: $tagname" 1>&2
454a966c04fSmrg	exit $EXIT_FAILURE
455a966c04fSmrg	;;
456a966c04fSmrg      esac
457a966c04fSmrg
458a966c04fSmrg      case $tagname in
459a966c04fSmrg      CC)
460a966c04fSmrg	# Don't test for the "default" C tag, as we know, it's there, but
461a966c04fSmrg	# not specially marked.
462a966c04fSmrg	;;
463a966c04fSmrg      *)
464a966c04fSmrg	if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
465a966c04fSmrg	  taglist="$taglist $tagname"
466a966c04fSmrg	  # Evaluate the configuration.
467a966c04fSmrg	  eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
468a966c04fSmrg	else
469a966c04fSmrg	  $echo "$progname: ignoring unknown tag $tagname" 1>&2
470a966c04fSmrg	fi
471a966c04fSmrg	;;
472a966c04fSmrg      esac
473a966c04fSmrg      ;;
474a966c04fSmrg    *)
475a966c04fSmrg      eval "$prev=\$arg"
476a966c04fSmrg      ;;
477a966c04fSmrg    esac
478a966c04fSmrg
479a966c04fSmrg    prev=
480a966c04fSmrg    prevopt=
481a966c04fSmrg    continue
482a966c04fSmrg  fi
483a966c04fSmrg
484a966c04fSmrg  # Have we seen a non-optional argument yet?
485a966c04fSmrg  case $arg in
486a966c04fSmrg  --help)
487a966c04fSmrg    show_help=yes
488a966c04fSmrg    ;;
489a966c04fSmrg
490a966c04fSmrg  --version)
4912e2dd055Smrg    echo "\
4922e2dd055Smrg$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP
4932e2dd055Smrg
4942e2dd055SmrgCopyright (C) 2008  Free Software Foundation, Inc.
4952e2dd055SmrgThis is free software; see the source for copying conditions.  There is NO
4962e2dd055Smrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
497a966c04fSmrg    exit $?
498a966c04fSmrg    ;;
499a966c04fSmrg
500a966c04fSmrg  --config)
501a966c04fSmrg    ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
502a966c04fSmrg    # Now print the configurations for the tags.
503a966c04fSmrg    for tagname in $taglist; do
504a966c04fSmrg      ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
505a966c04fSmrg    done
506a966c04fSmrg    exit $?
507a966c04fSmrg    ;;
508a966c04fSmrg
509a966c04fSmrg  --debug)
510a966c04fSmrg    $echo "$progname: enabling shell trace mode"
511a966c04fSmrg    set -x
512a966c04fSmrg    preserve_args="$preserve_args $arg"
513a966c04fSmrg    ;;
514a966c04fSmrg
515a966c04fSmrg  --dry-run | -n)
516a966c04fSmrg    run=:
517a966c04fSmrg    ;;
518a966c04fSmrg
519a966c04fSmrg  --features)
520a966c04fSmrg    $echo "host: $host"
521a966c04fSmrg    if test "$build_libtool_libs" = yes; then
522a966c04fSmrg      $echo "enable shared libraries"
523a966c04fSmrg    else
524a966c04fSmrg      $echo "disable shared libraries"
525a966c04fSmrg    fi
526a966c04fSmrg    if test "$build_old_libs" = yes; then
527a966c04fSmrg      $echo "enable static libraries"
528a966c04fSmrg    else
529a966c04fSmrg      $echo "disable static libraries"
530a966c04fSmrg    fi
531a966c04fSmrg    exit $?
532a966c04fSmrg    ;;
533a966c04fSmrg
534a966c04fSmrg  --finish) mode="finish" ;;
535a966c04fSmrg
536a966c04fSmrg  --mode) prevopt="--mode" prev=mode ;;
537a966c04fSmrg  --mode=*) mode="$optarg" ;;
538a966c04fSmrg
539a966c04fSmrg  --preserve-dup-deps) duplicate_deps="yes" ;;
540a966c04fSmrg
541a966c04fSmrg  --quiet | --silent)
542a966c04fSmrg    show=:
543a966c04fSmrg    preserve_args="$preserve_args $arg"
544a966c04fSmrg    ;;
545a966c04fSmrg
546a966c04fSmrg  --tag)
547a966c04fSmrg    prevopt="--tag"
548a966c04fSmrg    prev=tag
549a966c04fSmrg    preserve_args="$preserve_args --tag"
550a966c04fSmrg    ;;
551a966c04fSmrg  --tag=*)
552a966c04fSmrg    set tag "$optarg" ${1+"$@"}
553a966c04fSmrg    shift
554a966c04fSmrg    prev=tag
555a966c04fSmrg    preserve_args="$preserve_args --tag"
556a966c04fSmrg    ;;
557a966c04fSmrg
558a966c04fSmrg  -dlopen)
559a966c04fSmrg    prevopt="-dlopen"
560a966c04fSmrg    prev=execute_dlfiles
561a966c04fSmrg    ;;
562a966c04fSmrg
563a966c04fSmrg  -*)
564a966c04fSmrg    $echo "$modename: unrecognized option \`$arg'" 1>&2
565a966c04fSmrg    $echo "$help" 1>&2
566a966c04fSmrg    exit $EXIT_FAILURE
567a966c04fSmrg    ;;
568a966c04fSmrg
569a966c04fSmrg  *)
570a966c04fSmrg    nonopt="$arg"
571a966c04fSmrg    break
572a966c04fSmrg    ;;
573a966c04fSmrg  esac
574a966c04fSmrgdone
575a966c04fSmrg
576a966c04fSmrgif test -n "$prevopt"; then
577a966c04fSmrg  $echo "$modename: option \`$prevopt' requires an argument" 1>&2
578a966c04fSmrg  $echo "$help" 1>&2
579a966c04fSmrg  exit $EXIT_FAILURE
580a966c04fSmrgfi
581a966c04fSmrg
582a966c04fSmrgcase $disable_libs in
583a966c04fSmrgno) 
584a966c04fSmrg  ;;
585a966c04fSmrgshared)
586a966c04fSmrg  build_libtool_libs=no
587a966c04fSmrg  build_old_libs=yes
588a966c04fSmrg  ;;
589a966c04fSmrgstatic)
590a966c04fSmrg  build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
591a966c04fSmrg  ;;
592a966c04fSmrgesac
593a966c04fSmrg
594a966c04fSmrg# If this variable is set in any of the actions, the command in it
595a966c04fSmrg# will be execed at the end.  This prevents here-documents from being
596a966c04fSmrg# left over by shells.
597a966c04fSmrgexec_cmd=
598a966c04fSmrg
599a966c04fSmrgif test -z "$show_help"; then
600a966c04fSmrg
601a966c04fSmrg  # Infer the operation mode.
602a966c04fSmrg  if test -z "$mode"; then
603a966c04fSmrg    $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
604a966c04fSmrg    $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
605a966c04fSmrg    case $nonopt in
606a966c04fSmrg    *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
607a966c04fSmrg      mode=link
608a966c04fSmrg      for arg
609a966c04fSmrg      do
610a966c04fSmrg	case $arg in
611a966c04fSmrg	-c)
612a966c04fSmrg	   mode=compile
613a966c04fSmrg	   break
614a966c04fSmrg	   ;;
615a966c04fSmrg	esac
616a966c04fSmrg      done
617a966c04fSmrg      ;;
618a966c04fSmrg    *db | *dbx | *strace | *truss)
619a966c04fSmrg      mode=execute
620a966c04fSmrg      ;;
621a966c04fSmrg    *install*|cp|mv)
622a966c04fSmrg      mode=install
623a966c04fSmrg      ;;
624a966c04fSmrg    *rm)
625a966c04fSmrg      mode=uninstall
626a966c04fSmrg      ;;
627a966c04fSmrg    *)
628a966c04fSmrg      # If we have no mode, but dlfiles were specified, then do execute mode.
629a966c04fSmrg      test -n "$execute_dlfiles" && mode=execute
630a966c04fSmrg
631a966c04fSmrg      # Just use the default operation mode.
632a966c04fSmrg      if test -z "$mode"; then
633a966c04fSmrg	if test -n "$nonopt"; then
634a966c04fSmrg	  $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
635a966c04fSmrg	else
636a966c04fSmrg	  $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
637a966c04fSmrg	fi
638a966c04fSmrg      fi
639a966c04fSmrg      ;;
640a966c04fSmrg    esac
641a966c04fSmrg  fi
642a966c04fSmrg
643a966c04fSmrg  # Only execute mode is allowed to have -dlopen flags.
644a966c04fSmrg  if test -n "$execute_dlfiles" && test "$mode" != execute; then
645a966c04fSmrg    $echo "$modename: unrecognized option \`-dlopen'" 1>&2
646a966c04fSmrg    $echo "$help" 1>&2
647a966c04fSmrg    exit $EXIT_FAILURE
648a966c04fSmrg  fi
649a966c04fSmrg
650a966c04fSmrg  # Change the help message to a mode-specific one.
651a966c04fSmrg  generic_help="$help"
652a966c04fSmrg  help="Try \`$modename --help --mode=$mode' for more information."
653a966c04fSmrg
654a966c04fSmrg  # These modes are in order of execution frequency so that they run quickly.
655a966c04fSmrg  case $mode in
656a966c04fSmrg  # libtool compile mode
657a966c04fSmrg  compile)
658a966c04fSmrg    modename="$modename: compile"
659a966c04fSmrg    # Get the compilation command and the source file.
660a966c04fSmrg    base_compile=
661a966c04fSmrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
662a966c04fSmrg    suppress_opt=yes
663a966c04fSmrg    suppress_output=
664a966c04fSmrg    arg_mode=normal
665a966c04fSmrg    libobj=
666a966c04fSmrg    later=
667a966c04fSmrg
668a966c04fSmrg    for arg
669a966c04fSmrg    do
670a966c04fSmrg      case $arg_mode in
671a966c04fSmrg      arg  )
672a966c04fSmrg	# do not "continue".  Instead, add this to base_compile
673a966c04fSmrg	lastarg="$arg"
674a966c04fSmrg	arg_mode=normal
675a966c04fSmrg	;;
676a966c04fSmrg
677a966c04fSmrg      target )
678a966c04fSmrg	libobj="$arg"
679a966c04fSmrg	arg_mode=normal
680a966c04fSmrg	continue
681a966c04fSmrg	;;
682a966c04fSmrg
683a966c04fSmrg      normal )
684a966c04fSmrg	# Accept any command-line options.
685a966c04fSmrg	case $arg in
686a966c04fSmrg	-o)
687a966c04fSmrg	  if test -n "$libobj" ; then
688a966c04fSmrg	    $echo "$modename: you cannot specify \`-o' more than once" 1>&2
689a966c04fSmrg	    exit $EXIT_FAILURE
690a966c04fSmrg	  fi
691a966c04fSmrg	  arg_mode=target
692a966c04fSmrg	  continue
693a966c04fSmrg	  ;;
694a966c04fSmrg
695a966c04fSmrg	-static | -prefer-pic | -prefer-non-pic)
696a966c04fSmrg	  later="$later $arg"
697a966c04fSmrg	  continue
698a966c04fSmrg	  ;;
699a966c04fSmrg
700a966c04fSmrg	-no-suppress)
701a966c04fSmrg	  suppress_opt=no
702a966c04fSmrg	  continue
703a966c04fSmrg	  ;;
704a966c04fSmrg
705a966c04fSmrg	-Xcompiler)
706a966c04fSmrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
707a966c04fSmrg	  continue      #  The current "srcfile" will either be retained or
708a966c04fSmrg	  ;;            #  replaced later.  I would guess that would be a bug.
709a966c04fSmrg
710a966c04fSmrg	-Wc,*)
711a966c04fSmrg	  args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
712a966c04fSmrg	  lastarg=
713a966c04fSmrg	  save_ifs="$IFS"; IFS=','
714a966c04fSmrg 	  for arg in $args; do
715a966c04fSmrg	    IFS="$save_ifs"
716a966c04fSmrg
717a966c04fSmrg	    # Double-quote args containing other shell metacharacters.
718a966c04fSmrg	    # Many Bourne shells cannot handle close brackets correctly
719a966c04fSmrg	    # in scan sets, so we specify it separately.
720a966c04fSmrg	    case $arg in
721a966c04fSmrg	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
722a966c04fSmrg	      arg="\"$arg\""
723a966c04fSmrg	      ;;
724a966c04fSmrg	    esac
725a966c04fSmrg	    lastarg="$lastarg $arg"
726a966c04fSmrg	  done
727a966c04fSmrg	  IFS="$save_ifs"
728a966c04fSmrg	  lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
729a966c04fSmrg
730a966c04fSmrg	  # Add the arguments to base_compile.
731a966c04fSmrg	  base_compile="$base_compile $lastarg"
732a966c04fSmrg	  continue
733a966c04fSmrg	  ;;
734a966c04fSmrg
735a966c04fSmrg	* )
736a966c04fSmrg	  # Accept the current argument as the source file.
737a966c04fSmrg	  # The previous "srcfile" becomes the current argument.
738a966c04fSmrg	  #
739a966c04fSmrg	  lastarg="$srcfile"
740a966c04fSmrg	  srcfile="$arg"
741a966c04fSmrg	  ;;
742a966c04fSmrg	esac  #  case $arg
743a966c04fSmrg	;;
744a966c04fSmrg      esac    #  case $arg_mode
745a966c04fSmrg
746a966c04fSmrg      # Aesthetically quote the previous argument.
747a966c04fSmrg      lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
748a966c04fSmrg
749a966c04fSmrg      case $lastarg in
750a966c04fSmrg      # Double-quote args containing other shell metacharacters.
751a966c04fSmrg      # Many Bourne shells cannot handle close brackets correctly
752a966c04fSmrg      # in scan sets, and some SunOS ksh mistreat backslash-escaping
753a966c04fSmrg      # in scan sets (worked around with variable expansion),
754a966c04fSmrg      # and furthermore cannot handle '|' '&' '(' ')' in scan sets 
755a966c04fSmrg      # at all, so we specify them separately.
756a966c04fSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
757a966c04fSmrg	lastarg="\"$lastarg\""
758a966c04fSmrg	;;
759a966c04fSmrg      esac
760a966c04fSmrg
761a966c04fSmrg      base_compile="$base_compile $lastarg"
762a966c04fSmrg    done # for arg
763a966c04fSmrg
764a966c04fSmrg    case $arg_mode in
765a966c04fSmrg    arg)
766a966c04fSmrg      $echo "$modename: you must specify an argument for -Xcompile"
767a966c04fSmrg      exit $EXIT_FAILURE
768a966c04fSmrg      ;;
769a966c04fSmrg    target)
770a966c04fSmrg      $echo "$modename: you must specify a target with \`-o'" 1>&2
771a966c04fSmrg      exit $EXIT_FAILURE
772a966c04fSmrg      ;;
773a966c04fSmrg    *)
774a966c04fSmrg      # Get the name of the library object.
775a966c04fSmrg      [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
776a966c04fSmrg      ;;
777a966c04fSmrg    esac
778a966c04fSmrg
779a966c04fSmrg    # Recognize several different file suffixes.
780a966c04fSmrg    # If the user specifies -o file.o, it is replaced with file.lo
781a966c04fSmrg    xform='[cCFSifmso]'
782a966c04fSmrg    case $libobj in
783a966c04fSmrg    *.ada) xform=ada ;;
784a966c04fSmrg    *.adb) xform=adb ;;
785a966c04fSmrg    *.ads) xform=ads ;;
786a966c04fSmrg    *.asm) xform=asm ;;
787a966c04fSmrg    *.c++) xform=c++ ;;
788a966c04fSmrg    *.cc) xform=cc ;;
789a966c04fSmrg    *.ii) xform=ii ;;
790a966c04fSmrg    *.class) xform=class ;;
791a966c04fSmrg    *.cpp) xform=cpp ;;
792a966c04fSmrg    *.cxx) xform=cxx ;;
7932e2dd055Smrg    *.[fF][09]?) xform=[fF][09]. ;;
794a966c04fSmrg    *.for) xform=for ;;
795a966c04fSmrg    *.java) xform=java ;;
7962e2dd055Smrg    *.obj) xform=obj ;;
7972e2dd055Smrg    *.sx) xform=sx ;;
798a966c04fSmrg    esac
799a966c04fSmrg
800a966c04fSmrg    libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
801a966c04fSmrg
802a966c04fSmrg    case $libobj in
803a966c04fSmrg    *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
804a966c04fSmrg    *)
805a966c04fSmrg      $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
806a966c04fSmrg      exit $EXIT_FAILURE
807a966c04fSmrg      ;;
808a966c04fSmrg    esac
809a966c04fSmrg
810a966c04fSmrg    func_infer_tag $base_compile
811a966c04fSmrg
812a966c04fSmrg    for arg in $later; do
813a966c04fSmrg      case $arg in
814a966c04fSmrg      -static)
815a966c04fSmrg	build_old_libs=yes
816a966c04fSmrg	continue
817a966c04fSmrg	;;
818a966c04fSmrg
819a966c04fSmrg      -prefer-pic)
820a966c04fSmrg	pic_mode=yes
821a966c04fSmrg	continue
822a966c04fSmrg	;;
823a966c04fSmrg
824a966c04fSmrg      -prefer-non-pic)
825a966c04fSmrg	pic_mode=no
826a966c04fSmrg	continue
827a966c04fSmrg	;;
828a966c04fSmrg      esac
829a966c04fSmrg    done
830a966c04fSmrg
831a966c04fSmrg    qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
832a966c04fSmrg    case $qlibobj in
833a966c04fSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
834a966c04fSmrg	qlibobj="\"$qlibobj\"" ;;
835a966c04fSmrg    esac
836a966c04fSmrg    test "X$libobj" != "X$qlibobj" \
837a966c04fSmrg	&& $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' 	&()|`$[]' \
838a966c04fSmrg	&& $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
839a966c04fSmrg    objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
840a966c04fSmrg    xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
841a966c04fSmrg    if test "X$xdir" = "X$obj"; then
842a966c04fSmrg      xdir=
843a966c04fSmrg    else
844a966c04fSmrg      xdir=$xdir/
845a966c04fSmrg    fi
846a966c04fSmrg    lobj=${xdir}$objdir/$objname
847a966c04fSmrg
848a966c04fSmrg    if test -z "$base_compile"; then
849a966c04fSmrg      $echo "$modename: you must specify a compilation command" 1>&2
850a966c04fSmrg      $echo "$help" 1>&2
851a966c04fSmrg      exit $EXIT_FAILURE
852a966c04fSmrg    fi
853a966c04fSmrg
854a966c04fSmrg    # Delete any leftover library objects.
855a966c04fSmrg    if test "$build_old_libs" = yes; then
856a966c04fSmrg      removelist="$obj $lobj $libobj ${libobj}T"
857a966c04fSmrg    else
858a966c04fSmrg      removelist="$lobj $libobj ${libobj}T"
859a966c04fSmrg    fi
860a966c04fSmrg
861a966c04fSmrg    $run $rm $removelist
862a966c04fSmrg    trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
863a966c04fSmrg
864a966c04fSmrg    # On Cygwin there's no "real" PIC flag so we must build both object types
865a966c04fSmrg    case $host_os in
866a966c04fSmrg    cygwin* | mingw* | pw32* | os2*)
867a966c04fSmrg      pic_mode=default
868a966c04fSmrg      ;;
869a966c04fSmrg    esac
870a966c04fSmrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
871a966c04fSmrg      # non-PIC code in shared libraries is not supported
872a966c04fSmrg      pic_mode=default
873a966c04fSmrg    fi
874a966c04fSmrg
875a966c04fSmrg    # Calculate the filename of the output object if compiler does
876a966c04fSmrg    # not support -o with -c
877a966c04fSmrg    if test "$compiler_c_o" = no; then
878a966c04fSmrg      output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
879a966c04fSmrg      lockfile="$output_obj.lock"
880a966c04fSmrg      removelist="$removelist $output_obj $lockfile"
881a966c04fSmrg      trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
882a966c04fSmrg    else
883a966c04fSmrg      output_obj=
884a966c04fSmrg      need_locks=no
885a966c04fSmrg      lockfile=
886a966c04fSmrg    fi
887a966c04fSmrg
888a966c04fSmrg    # Lock this critical section if it is needed
889a966c04fSmrg    # We use this script file to make the link, it avoids creating a new file
890a966c04fSmrg    if test "$need_locks" = yes; then
891a966c04fSmrg      until $run ln "$progpath" "$lockfile" 2>/dev/null; do
892a966c04fSmrg	$show "Waiting for $lockfile to be removed"
893a966c04fSmrg	sleep 2
894a966c04fSmrg      done
895a966c04fSmrg    elif test "$need_locks" = warn; then
896a966c04fSmrg      if test -f "$lockfile"; then
897a966c04fSmrg	$echo "\
898a966c04fSmrg*** ERROR, $lockfile exists and contains:
899a966c04fSmrg`cat $lockfile 2>/dev/null`
900a966c04fSmrg
901a966c04fSmrgThis indicates that another process is trying to use the same
902a966c04fSmrgtemporary object file, and libtool could not work around it because
903a966c04fSmrgyour compiler does not support \`-c' and \`-o' together.  If you
904a966c04fSmrgrepeat this compilation, it may succeed, by chance, but you had better
905a966c04fSmrgavoid parallel builds (make -j) in this platform, or get a better
906a966c04fSmrgcompiler."
907a966c04fSmrg
908a966c04fSmrg	$run $rm $removelist
909a966c04fSmrg	exit $EXIT_FAILURE
910a966c04fSmrg      fi
911a966c04fSmrg      $echo "$srcfile" > "$lockfile"
912a966c04fSmrg    fi
913a966c04fSmrg
914a966c04fSmrg    if test -n "$fix_srcfile_path"; then
915a966c04fSmrg      eval srcfile=\"$fix_srcfile_path\"
916a966c04fSmrg    fi
917a966c04fSmrg    qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"`
918a966c04fSmrg    case $qsrcfile in
919a966c04fSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
920a966c04fSmrg      qsrcfile="\"$qsrcfile\"" ;;
921a966c04fSmrg    esac
922a966c04fSmrg
923a966c04fSmrg    $run $rm "$libobj" "${libobj}T"
924a966c04fSmrg
925a966c04fSmrg    # Create a libtool object file (analogous to a ".la" file),
926a966c04fSmrg    # but don't create it if we're doing a dry run.
927a966c04fSmrg    test -z "$run" && cat > ${libobj}T <<EOF
928a966c04fSmrg# $libobj - a libtool object file
929a966c04fSmrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
930a966c04fSmrg#
931a966c04fSmrg# Please DO NOT delete this file!
932a966c04fSmrg# It is necessary for linking the library.
933a966c04fSmrg
934a966c04fSmrg# Name of the PIC object.
935a966c04fSmrgEOF
936a966c04fSmrg
937a966c04fSmrg    # Only build a PIC object if we are building libtool libraries.
938a966c04fSmrg    if test "$build_libtool_libs" = yes; then
939a966c04fSmrg      # Without this assignment, base_compile gets emptied.
940a966c04fSmrg      fbsd_hideous_sh_bug=$base_compile
941a966c04fSmrg
942a966c04fSmrg      if test "$pic_mode" != no; then
943a966c04fSmrg	command="$base_compile $qsrcfile $pic_flag"
944a966c04fSmrg      else
945a966c04fSmrg	# Don't build PIC code
946a966c04fSmrg	command="$base_compile $qsrcfile"
947a966c04fSmrg      fi
948a966c04fSmrg
949a966c04fSmrg      if test ! -d "${xdir}$objdir"; then
950a966c04fSmrg	$show "$mkdir ${xdir}$objdir"
951a966c04fSmrg	$run $mkdir ${xdir}$objdir
952a966c04fSmrg	exit_status=$?
953a966c04fSmrg	if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
954a966c04fSmrg	  exit $exit_status
955a966c04fSmrg	fi
956a966c04fSmrg      fi
957a966c04fSmrg
958a966c04fSmrg      if test -z "$output_obj"; then
959a966c04fSmrg	# Place PIC objects in $objdir
960a966c04fSmrg	command="$command -o $lobj"
961a966c04fSmrg      fi
962a966c04fSmrg
963a966c04fSmrg      $run $rm "$lobj" "$output_obj"
964a966c04fSmrg
965a966c04fSmrg      $show "$command"
9662e2dd055Smrg      if $run eval $lt_env "$command"; then :
967a966c04fSmrg      else
968a966c04fSmrg	test -n "$output_obj" && $run $rm $removelist
969a966c04fSmrg	exit $EXIT_FAILURE
970a966c04fSmrg      fi
971a966c04fSmrg
972a966c04fSmrg      if test "$need_locks" = warn &&
973a966c04fSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
974a966c04fSmrg	$echo "\
975a966c04fSmrg*** ERROR, $lockfile contains:
976a966c04fSmrg`cat $lockfile 2>/dev/null`
977a966c04fSmrg
978a966c04fSmrgbut it should contain:
979a966c04fSmrg$srcfile
980a966c04fSmrg
981a966c04fSmrgThis indicates that another process is trying to use the same
982a966c04fSmrgtemporary object file, and libtool could not work around it because
983a966c04fSmrgyour compiler does not support \`-c' and \`-o' together.  If you
984a966c04fSmrgrepeat this compilation, it may succeed, by chance, but you had better
985a966c04fSmrgavoid parallel builds (make -j) in this platform, or get a better
986a966c04fSmrgcompiler."
987a966c04fSmrg
988a966c04fSmrg	$run $rm $removelist
989a966c04fSmrg	exit $EXIT_FAILURE
990a966c04fSmrg      fi
991a966c04fSmrg
992a966c04fSmrg      # Just move the object if needed, then go on to compile the next one
993a966c04fSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
994a966c04fSmrg	$show "$mv $output_obj $lobj"
995a966c04fSmrg	if $run $mv $output_obj $lobj; then :
996a966c04fSmrg	else
997a966c04fSmrg	  error=$?
998a966c04fSmrg	  $run $rm $removelist
999a966c04fSmrg	  exit $error
1000a966c04fSmrg	fi
1001a966c04fSmrg      fi
1002a966c04fSmrg
1003a966c04fSmrg      # Append the name of the PIC object to the libtool object file.
1004a966c04fSmrg      test -z "$run" && cat >> ${libobj}T <<EOF
1005a966c04fSmrgpic_object='$objdir/$objname'
1006a966c04fSmrg
1007a966c04fSmrgEOF
1008a966c04fSmrg
1009a966c04fSmrg      # Allow error messages only from the first compilation.
1010a966c04fSmrg      if test "$suppress_opt" = yes; then
1011a966c04fSmrg        suppress_output=' >/dev/null 2>&1'
1012a966c04fSmrg      fi
1013a966c04fSmrg    else
1014a966c04fSmrg      # No PIC object so indicate it doesn't exist in the libtool
1015a966c04fSmrg      # object file.
1016a966c04fSmrg      test -z "$run" && cat >> ${libobj}T <<EOF
1017a966c04fSmrgpic_object=none
1018a966c04fSmrg
1019a966c04fSmrgEOF
1020a966c04fSmrg    fi
1021a966c04fSmrg
1022a966c04fSmrg    # Only build a position-dependent object if we build old libraries.
1023a966c04fSmrg    if test "$build_old_libs" = yes; then
1024a966c04fSmrg      if test "$pic_mode" != yes; then
1025a966c04fSmrg	# Don't build PIC code
1026a966c04fSmrg	command="$base_compile $qsrcfile"
1027a966c04fSmrg      else
1028a966c04fSmrg	command="$base_compile $qsrcfile $pic_flag"
1029a966c04fSmrg      fi
1030a966c04fSmrg      if test "$compiler_c_o" = yes; then
1031a966c04fSmrg	command="$command -o $obj"
1032a966c04fSmrg      fi
1033a966c04fSmrg
1034a966c04fSmrg      # Suppress compiler output if we already did a PIC compilation.
1035a966c04fSmrg      command="$command$suppress_output"
1036a966c04fSmrg      $run $rm "$obj" "$output_obj"
1037a966c04fSmrg      $show "$command"
10382e2dd055Smrg      if $run eval $lt_env "$command"; then :
1039a966c04fSmrg      else
1040a966c04fSmrg	$run $rm $removelist
1041a966c04fSmrg	exit $EXIT_FAILURE
1042a966c04fSmrg      fi
1043a966c04fSmrg
1044a966c04fSmrg      if test "$need_locks" = warn &&
1045a966c04fSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1046a966c04fSmrg	$echo "\
1047a966c04fSmrg*** ERROR, $lockfile contains:
1048a966c04fSmrg`cat $lockfile 2>/dev/null`
1049a966c04fSmrg
1050a966c04fSmrgbut it should contain:
1051a966c04fSmrg$srcfile
1052a966c04fSmrg
1053a966c04fSmrgThis indicates that another process is trying to use the same
1054a966c04fSmrgtemporary object file, and libtool could not work around it because
1055a966c04fSmrgyour compiler does not support \`-c' and \`-o' together.  If you
1056a966c04fSmrgrepeat this compilation, it may succeed, by chance, but you had better
1057a966c04fSmrgavoid parallel builds (make -j) in this platform, or get a better
1058a966c04fSmrgcompiler."
1059a966c04fSmrg
1060a966c04fSmrg	$run $rm $removelist
1061a966c04fSmrg	exit $EXIT_FAILURE
1062a966c04fSmrg      fi
1063a966c04fSmrg
1064a966c04fSmrg      # Just move the object if needed
1065a966c04fSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
1066a966c04fSmrg	$show "$mv $output_obj $obj"
1067a966c04fSmrg	if $run $mv $output_obj $obj; then :
1068a966c04fSmrg	else
1069a966c04fSmrg	  error=$?
1070a966c04fSmrg	  $run $rm $removelist
1071a966c04fSmrg	  exit $error
1072a966c04fSmrg	fi
1073a966c04fSmrg      fi
1074a966c04fSmrg
1075a966c04fSmrg      # Append the name of the non-PIC object the libtool object file.
1076a966c04fSmrg      # Only append if the libtool object file exists.
1077a966c04fSmrg      test -z "$run" && cat >> ${libobj}T <<EOF
1078a966c04fSmrg# Name of the non-PIC object.
1079a966c04fSmrgnon_pic_object='$objname'
1080a966c04fSmrg
1081a966c04fSmrgEOF
1082a966c04fSmrg    else
1083a966c04fSmrg      # Append the name of the non-PIC object the libtool object file.
1084a966c04fSmrg      # Only append if the libtool object file exists.
1085a966c04fSmrg      test -z "$run" && cat >> ${libobj}T <<EOF
1086a966c04fSmrg# Name of the non-PIC object.
1087a966c04fSmrgnon_pic_object=none
1088a966c04fSmrg
1089a966c04fSmrgEOF
1090a966c04fSmrg    fi
1091a966c04fSmrg
1092a966c04fSmrg    $run $mv "${libobj}T" "${libobj}"
1093a966c04fSmrg
1094a966c04fSmrg    # Unlock the critical section if it was locked
1095a966c04fSmrg    if test "$need_locks" != no; then
1096a966c04fSmrg      $run $rm "$lockfile"
1097a966c04fSmrg    fi
1098a966c04fSmrg
1099a966c04fSmrg    exit $EXIT_SUCCESS
1100a966c04fSmrg    ;;
1101a966c04fSmrg
1102a966c04fSmrg  # libtool link mode
1103a966c04fSmrg  link | relink)
1104a966c04fSmrg    modename="$modename: link"
1105a966c04fSmrg    case $host in
1106a966c04fSmrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
1107a966c04fSmrg      # It is impossible to link a dll without this setting, and
1108a966c04fSmrg      # we shouldn't force the makefile maintainer to figure out
1109a966c04fSmrg      # which system we are compiling for in order to pass an extra
1110a966c04fSmrg      # flag for every libtool invocation.
1111a966c04fSmrg      # allow_undefined=no
1112a966c04fSmrg
1113a966c04fSmrg      # FIXME: Unfortunately, there are problems with the above when trying
1114a966c04fSmrg      # to make a dll which has undefined symbols, in which case not
1115a966c04fSmrg      # even a static library is built.  For now, we need to specify
1116a966c04fSmrg      # -no-undefined on the libtool link line when we can be certain
1117a966c04fSmrg      # that all symbols are satisfied, otherwise we get a static library.
1118a966c04fSmrg      allow_undefined=yes
1119a966c04fSmrg      ;;
1120a966c04fSmrg    *)
1121a966c04fSmrg      allow_undefined=yes
1122a966c04fSmrg      ;;
1123a966c04fSmrg    esac
1124a966c04fSmrg    libtool_args="$nonopt"
1125a966c04fSmrg    base_compile="$nonopt $@"
1126a966c04fSmrg    compile_command="$nonopt"
1127a966c04fSmrg    finalize_command="$nonopt"
1128a966c04fSmrg
1129a966c04fSmrg    compile_rpath=
1130a966c04fSmrg    finalize_rpath=
1131a966c04fSmrg    compile_shlibpath=
1132a966c04fSmrg    finalize_shlibpath=
1133a966c04fSmrg    convenience=
1134a966c04fSmrg    old_convenience=
1135a966c04fSmrg    deplibs=
1136a966c04fSmrg    old_deplibs=
1137a966c04fSmrg    compiler_flags=
1138a966c04fSmrg    linker_flags=
1139a966c04fSmrg    dllsearchpath=
1140a966c04fSmrg    lib_search_path=`pwd`
1141a966c04fSmrg    inst_prefix_dir=
1142a966c04fSmrg
1143a966c04fSmrg    avoid_version=no
1144a966c04fSmrg    dlfiles=
1145a966c04fSmrg    dlprefiles=
1146a966c04fSmrg    dlself=no
1147a966c04fSmrg    export_dynamic=no
1148a966c04fSmrg    export_symbols=
1149a966c04fSmrg    export_symbols_regex=
1150a966c04fSmrg    generated=
1151a966c04fSmrg    libobjs=
1152a966c04fSmrg    ltlibs=
1153a966c04fSmrg    module=no
1154a966c04fSmrg    no_install=no
1155a966c04fSmrg    objs=
1156a966c04fSmrg    non_pic_objects=
1157a966c04fSmrg    notinst_path= # paths that contain not-installed libtool libraries
1158a966c04fSmrg    precious_files_regex=
1159a966c04fSmrg    prefer_static_libs=no
1160a966c04fSmrg    preload=no
1161a966c04fSmrg    prev=
1162a966c04fSmrg    prevarg=
1163a966c04fSmrg    release=
1164a966c04fSmrg    rpath=
1165a966c04fSmrg    xrpath=
1166a966c04fSmrg    perm_rpath=
1167a966c04fSmrg    temp_rpath=
1168a966c04fSmrg    thread_safe=no
1169a966c04fSmrg    vinfo=
1170a966c04fSmrg    vinfo_number=no
11712e2dd055Smrg    single_module="${wl}-single_module"
1172a966c04fSmrg
1173a966c04fSmrg    func_infer_tag $base_compile
1174a966c04fSmrg
1175a966c04fSmrg    # We need to know -static, to get the right output filenames.
1176a966c04fSmrg    for arg
1177a966c04fSmrg    do
1178a966c04fSmrg      case $arg in
11792e2dd055Smrg      -all-static | -static | -static-libtool-libs)
11802e2dd055Smrg	case $arg in
11812e2dd055Smrg	-all-static)
1182a966c04fSmrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
1183a966c04fSmrg	    $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
1184a966c04fSmrg	  fi
1185a966c04fSmrg	  if test -n "$link_static_flag"; then
1186a966c04fSmrg	    dlopen_self=$dlopen_self_static
1187a966c04fSmrg	  fi
1188a966c04fSmrg	  prefer_static_libs=yes
11892e2dd055Smrg	  ;;
11902e2dd055Smrg	-static)
1191a966c04fSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
1192a966c04fSmrg	    dlopen_self=$dlopen_self_static
1193a966c04fSmrg	  fi
1194a966c04fSmrg	  prefer_static_libs=built
11952e2dd055Smrg	  ;;
11962e2dd055Smrg	-static-libtool-libs)
11972e2dd055Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
11982e2dd055Smrg	    dlopen_self=$dlopen_self_static
11992e2dd055Smrg	  fi
12002e2dd055Smrg	  prefer_static_libs=yes
12012e2dd055Smrg	  ;;
12022e2dd055Smrg	esac
1203a966c04fSmrg	build_libtool_libs=no
1204a966c04fSmrg	build_old_libs=yes
1205a966c04fSmrg	break
1206a966c04fSmrg	;;
1207a966c04fSmrg      esac
1208a966c04fSmrg    done
1209a966c04fSmrg
1210a966c04fSmrg    # See if our shared archives depend on static archives.
1211a966c04fSmrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
1212a966c04fSmrg
1213a966c04fSmrg    # Go through the arguments, transforming them on the way.
1214a966c04fSmrg    while test "$#" -gt 0; do
1215a966c04fSmrg      arg="$1"
1216a966c04fSmrg      shift
1217a966c04fSmrg      case $arg in
1218a966c04fSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1219a966c04fSmrg	qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
1220a966c04fSmrg	;;
1221a966c04fSmrg      *) qarg=$arg ;;
1222a966c04fSmrg      esac
1223a966c04fSmrg      libtool_args="$libtool_args $qarg"
1224a966c04fSmrg
1225a966c04fSmrg      # If the previous option needs an argument, assign it.
1226a966c04fSmrg      if test -n "$prev"; then
1227a966c04fSmrg	case $prev in
1228a966c04fSmrg	output)
1229a966c04fSmrg	  compile_command="$compile_command @OUTPUT@"
1230a966c04fSmrg	  finalize_command="$finalize_command @OUTPUT@"
1231a966c04fSmrg	  ;;
1232a966c04fSmrg	esac
1233a966c04fSmrg
1234a966c04fSmrg	case $prev in
1235a966c04fSmrg	dlfiles|dlprefiles)
1236a966c04fSmrg	  if test "$preload" = no; then
1237a966c04fSmrg	    # Add the symbol object into the linking commands.
1238a966c04fSmrg	    compile_command="$compile_command @SYMFILE@"
1239a966c04fSmrg	    finalize_command="$finalize_command @SYMFILE@"
1240a966c04fSmrg	    preload=yes
1241a966c04fSmrg	  fi
1242a966c04fSmrg	  case $arg in
1243a966c04fSmrg	  *.la | *.lo) ;;  # We handle these cases below.
1244a966c04fSmrg	  force)
1245a966c04fSmrg	    if test "$dlself" = no; then
1246a966c04fSmrg	      dlself=needless
1247a966c04fSmrg	      export_dynamic=yes
1248a966c04fSmrg	    fi
1249a966c04fSmrg	    prev=
1250a966c04fSmrg	    continue
1251a966c04fSmrg	    ;;
1252a966c04fSmrg	  self)
1253a966c04fSmrg	    if test "$prev" = dlprefiles; then
1254a966c04fSmrg	      dlself=yes
1255a966c04fSmrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
1256a966c04fSmrg	      dlself=yes
1257a966c04fSmrg	    else
1258a966c04fSmrg	      dlself=needless
1259a966c04fSmrg	      export_dynamic=yes
1260a966c04fSmrg	    fi
1261a966c04fSmrg	    prev=
1262a966c04fSmrg	    continue
1263a966c04fSmrg	    ;;
1264a966c04fSmrg	  *)
1265a966c04fSmrg	    if test "$prev" = dlfiles; then
1266a966c04fSmrg	      dlfiles="$dlfiles $arg"
1267a966c04fSmrg	    else
1268a966c04fSmrg	      dlprefiles="$dlprefiles $arg"
1269a966c04fSmrg	    fi
1270a966c04fSmrg	    prev=
1271a966c04fSmrg	    continue
1272a966c04fSmrg	    ;;
1273a966c04fSmrg	  esac
1274a966c04fSmrg	  ;;
1275a966c04fSmrg	expsyms)
1276a966c04fSmrg	  export_symbols="$arg"
1277a966c04fSmrg	  if test ! -f "$arg"; then
1278a966c04fSmrg	    $echo "$modename: symbol file \`$arg' does not exist"
1279a966c04fSmrg	    exit $EXIT_FAILURE
1280a966c04fSmrg	  fi
1281a966c04fSmrg	  prev=
1282a966c04fSmrg	  continue
1283a966c04fSmrg	  ;;
1284a966c04fSmrg	expsyms_regex)
1285a966c04fSmrg	  export_symbols_regex="$arg"
1286a966c04fSmrg	  prev=
1287a966c04fSmrg	  continue
1288a966c04fSmrg	  ;;
1289a966c04fSmrg	inst_prefix)
1290a966c04fSmrg	  inst_prefix_dir="$arg"
1291a966c04fSmrg	  prev=
1292a966c04fSmrg	  continue
1293a966c04fSmrg	  ;;
1294a966c04fSmrg	precious_regex)
1295a966c04fSmrg	  precious_files_regex="$arg"
1296a966c04fSmrg	  prev=
1297a966c04fSmrg	  continue
1298a966c04fSmrg	  ;;
1299a966c04fSmrg	release)
1300a966c04fSmrg	  release="-$arg"
1301a966c04fSmrg	  prev=
1302a966c04fSmrg	  continue
1303a966c04fSmrg	  ;;
1304a966c04fSmrg	objectlist)
1305a966c04fSmrg	  if test -f "$arg"; then
1306a966c04fSmrg	    save_arg=$arg
1307a966c04fSmrg	    moreargs=
1308a966c04fSmrg	    for fil in `cat $save_arg`
1309a966c04fSmrg	    do
1310a966c04fSmrg#	      moreargs="$moreargs $fil"
1311a966c04fSmrg	      arg=$fil
1312a966c04fSmrg	      # A libtool-controlled object.
1313a966c04fSmrg
1314a966c04fSmrg	      # Check to see that this really is a libtool object.
1315a966c04fSmrg	      if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
1316a966c04fSmrg		pic_object=
1317a966c04fSmrg		non_pic_object=
1318a966c04fSmrg
1319a966c04fSmrg		# Read the .lo file
1320a966c04fSmrg		# If there is no directory component, then add one.
1321a966c04fSmrg		case $arg in
1322a966c04fSmrg		*/* | *\\*) . $arg ;;
1323a966c04fSmrg		*) . ./$arg ;;
1324a966c04fSmrg		esac
1325a966c04fSmrg
1326a966c04fSmrg		if test -z "$pic_object" || \
1327a966c04fSmrg		   test -z "$non_pic_object" ||
1328a966c04fSmrg		   test "$pic_object" = none && \
1329a966c04fSmrg		   test "$non_pic_object" = none; then
1330a966c04fSmrg		  $echo "$modename: cannot find name of object for \`$arg'" 1>&2
1331a966c04fSmrg		  exit $EXIT_FAILURE
1332a966c04fSmrg		fi
1333a966c04fSmrg
1334a966c04fSmrg		# Extract subdirectory from the argument.
1335a966c04fSmrg		xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1336a966c04fSmrg		if test "X$xdir" = "X$arg"; then
1337a966c04fSmrg		  xdir=
1338a966c04fSmrg		else
1339a966c04fSmrg		  xdir="$xdir/"
1340a966c04fSmrg		fi
1341a966c04fSmrg
1342a966c04fSmrg		if test "$pic_object" != none; then
1343a966c04fSmrg		  # Prepend the subdirectory the object is found in.
1344a966c04fSmrg		  pic_object="$xdir$pic_object"
1345a966c04fSmrg
1346a966c04fSmrg		  if test "$prev" = dlfiles; then
1347a966c04fSmrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
1348a966c04fSmrg		      dlfiles="$dlfiles $pic_object"
1349a966c04fSmrg		      prev=
1350a966c04fSmrg		      continue
1351a966c04fSmrg		    else
1352a966c04fSmrg		      # If libtool objects are unsupported, then we need to preload.
1353a966c04fSmrg		      prev=dlprefiles
1354a966c04fSmrg		    fi
1355a966c04fSmrg		  fi
1356a966c04fSmrg
1357a966c04fSmrg		  # CHECK ME:  I think I busted this.  -Ossama
1358a966c04fSmrg		  if test "$prev" = dlprefiles; then
1359a966c04fSmrg		    # Preload the old-style object.
1360a966c04fSmrg		    dlprefiles="$dlprefiles $pic_object"
1361a966c04fSmrg		    prev=
1362a966c04fSmrg		  fi
1363a966c04fSmrg
1364a966c04fSmrg		  # A PIC object.
1365a966c04fSmrg		  libobjs="$libobjs $pic_object"
1366a966c04fSmrg		  arg="$pic_object"
1367a966c04fSmrg		fi
1368a966c04fSmrg
1369a966c04fSmrg		# Non-PIC object.
1370a966c04fSmrg		if test "$non_pic_object" != none; then
1371a966c04fSmrg		  # Prepend the subdirectory the object is found in.
1372a966c04fSmrg		  non_pic_object="$xdir$non_pic_object"
1373a966c04fSmrg
1374a966c04fSmrg		  # A standard non-PIC object
1375a966c04fSmrg		  non_pic_objects="$non_pic_objects $non_pic_object"
1376a966c04fSmrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
1377a966c04fSmrg		    arg="$non_pic_object"
1378a966c04fSmrg		  fi
1379a966c04fSmrg		else
1380a966c04fSmrg		  # If the PIC object exists, use it instead.
1381a966c04fSmrg		  # $xdir was prepended to $pic_object above.
1382a966c04fSmrg		  non_pic_object="$pic_object"
1383a966c04fSmrg		  non_pic_objects="$non_pic_objects $non_pic_object"
1384a966c04fSmrg		fi
1385a966c04fSmrg	      else
1386a966c04fSmrg		# Only an error if not doing a dry-run.
1387a966c04fSmrg		if test -z "$run"; then
1388a966c04fSmrg		  $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
1389a966c04fSmrg		  exit $EXIT_FAILURE
1390a966c04fSmrg		else
1391a966c04fSmrg		  # Dry-run case.
1392a966c04fSmrg
1393a966c04fSmrg		  # Extract subdirectory from the argument.
1394a966c04fSmrg		  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1395a966c04fSmrg		  if test "X$xdir" = "X$arg"; then
1396a966c04fSmrg		    xdir=
1397a966c04fSmrg		  else
1398a966c04fSmrg		    xdir="$xdir/"
1399a966c04fSmrg		  fi
1400a966c04fSmrg
1401a966c04fSmrg		  pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
1402a966c04fSmrg		  non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
1403a966c04fSmrg		  libobjs="$libobjs $pic_object"
1404a966c04fSmrg		  non_pic_objects="$non_pic_objects $non_pic_object"
1405a966c04fSmrg		fi
1406a966c04fSmrg	      fi
1407a966c04fSmrg	    done
1408a966c04fSmrg	  else
1409a966c04fSmrg	    $echo "$modename: link input file \`$save_arg' does not exist"
1410a966c04fSmrg	    exit $EXIT_FAILURE
1411a966c04fSmrg	  fi
1412a966c04fSmrg	  arg=$save_arg
1413a966c04fSmrg	  prev=
1414a966c04fSmrg	  continue
1415a966c04fSmrg	  ;;
1416a966c04fSmrg	rpath | xrpath)
1417a966c04fSmrg	  # We need an absolute path.
1418a966c04fSmrg	  case $arg in
1419a966c04fSmrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
1420a966c04fSmrg	  *)
1421a966c04fSmrg	    $echo "$modename: only absolute run-paths are allowed" 1>&2
1422a966c04fSmrg	    exit $EXIT_FAILURE
1423a966c04fSmrg	    ;;
1424a966c04fSmrg	  esac
1425a966c04fSmrg	  if test "$prev" = rpath; then
1426a966c04fSmrg	    case "$rpath " in
1427a966c04fSmrg	    *" $arg "*) ;;
1428a966c04fSmrg	    *) rpath="$rpath $arg" ;;
1429a966c04fSmrg	    esac
1430a966c04fSmrg	  else
1431a966c04fSmrg	    case "$xrpath " in
1432a966c04fSmrg	    *" $arg "*) ;;
1433a966c04fSmrg	    *) xrpath="$xrpath $arg" ;;
1434a966c04fSmrg	    esac
1435a966c04fSmrg	  fi
1436a966c04fSmrg	  prev=
1437a966c04fSmrg	  continue
1438a966c04fSmrg	  ;;
1439a966c04fSmrg	xcompiler)
1440a966c04fSmrg	  compiler_flags="$compiler_flags $qarg"
1441a966c04fSmrg	  prev=
1442a966c04fSmrg	  compile_command="$compile_command $qarg"
1443a966c04fSmrg	  finalize_command="$finalize_command $qarg"
1444a966c04fSmrg	  continue
1445a966c04fSmrg	  ;;
1446a966c04fSmrg	xlinker)
1447a966c04fSmrg	  linker_flags="$linker_flags $qarg"
1448a966c04fSmrg	  compiler_flags="$compiler_flags $wl$qarg"
1449a966c04fSmrg	  prev=
1450a966c04fSmrg	  compile_command="$compile_command $wl$qarg"
1451a966c04fSmrg	  finalize_command="$finalize_command $wl$qarg"
1452a966c04fSmrg	  continue
1453a966c04fSmrg	  ;;
1454a966c04fSmrg	xcclinker)
1455a966c04fSmrg	  linker_flags="$linker_flags $qarg"
1456a966c04fSmrg	  compiler_flags="$compiler_flags $qarg"
1457a966c04fSmrg	  prev=
1458a966c04fSmrg	  compile_command="$compile_command $qarg"
1459a966c04fSmrg	  finalize_command="$finalize_command $qarg"
1460a966c04fSmrg	  continue
1461a966c04fSmrg	  ;;
1462a966c04fSmrg	shrext)
1463a966c04fSmrg  	  shrext_cmds="$arg"
1464a966c04fSmrg	  prev=
1465a966c04fSmrg	  continue
1466a966c04fSmrg	  ;;
1467a966c04fSmrg	darwin_framework|darwin_framework_skip)
1468a966c04fSmrg	  test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg"
1469a966c04fSmrg	  compile_command="$compile_command $arg"
1470a966c04fSmrg	  finalize_command="$finalize_command $arg"
1471a966c04fSmrg	  prev=
1472a966c04fSmrg	  continue
1473a966c04fSmrg	  ;;
1474a966c04fSmrg	*)
1475a966c04fSmrg	  eval "$prev=\"\$arg\""
1476a966c04fSmrg	  prev=
1477a966c04fSmrg	  continue
1478a966c04fSmrg	  ;;
1479a966c04fSmrg	esac
1480a966c04fSmrg      fi # test -n "$prev"
1481a966c04fSmrg
1482a966c04fSmrg      prevarg="$arg"
1483a966c04fSmrg
1484a966c04fSmrg      case $arg in
1485a966c04fSmrg      -all-static)
1486a966c04fSmrg	if test -n "$link_static_flag"; then
1487a966c04fSmrg	  compile_command="$compile_command $link_static_flag"
1488a966c04fSmrg	  finalize_command="$finalize_command $link_static_flag"
1489a966c04fSmrg	fi
1490a966c04fSmrg	continue
1491a966c04fSmrg	;;
1492a966c04fSmrg
1493a966c04fSmrg      -allow-undefined)
1494a966c04fSmrg	# FIXME: remove this flag sometime in the future.
1495a966c04fSmrg	$echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
1496a966c04fSmrg	continue
1497a966c04fSmrg	;;
1498a966c04fSmrg
1499a966c04fSmrg      -avoid-version)
1500a966c04fSmrg	avoid_version=yes
1501a966c04fSmrg	continue
1502a966c04fSmrg	;;
1503a966c04fSmrg
1504a966c04fSmrg      -dlopen)
1505a966c04fSmrg	prev=dlfiles
1506a966c04fSmrg	continue
1507a966c04fSmrg	;;
1508a966c04fSmrg
1509a966c04fSmrg      -dlpreopen)
1510a966c04fSmrg	prev=dlprefiles
1511a966c04fSmrg	continue
1512a966c04fSmrg	;;
1513a966c04fSmrg
1514a966c04fSmrg      -export-dynamic)
1515a966c04fSmrg	export_dynamic=yes
1516a966c04fSmrg	continue
1517a966c04fSmrg	;;
1518a966c04fSmrg
1519a966c04fSmrg      -export-symbols | -export-symbols-regex)
1520a966c04fSmrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
1521a966c04fSmrg	  $echo "$modename: more than one -exported-symbols argument is not allowed"
1522a966c04fSmrg	  exit $EXIT_FAILURE
1523a966c04fSmrg	fi
1524a966c04fSmrg	if test "X$arg" = "X-export-symbols"; then
1525a966c04fSmrg	  prev=expsyms
1526a966c04fSmrg	else
1527a966c04fSmrg	  prev=expsyms_regex
1528a966c04fSmrg	fi
1529a966c04fSmrg	continue
1530a966c04fSmrg	;;
1531a966c04fSmrg
1532a966c04fSmrg      -framework|-arch|-isysroot)
1533a966c04fSmrg	case " $CC " in
1534a966c04fSmrg	  *" ${arg} ${1} "* | *" ${arg}	${1} "*) 
1535a966c04fSmrg		prev=darwin_framework_skip ;;
1536a966c04fSmrg	  *) compiler_flags="$compiler_flags $arg"
1537a966c04fSmrg	     prev=darwin_framework ;;
1538a966c04fSmrg	esac
1539a966c04fSmrg	compile_command="$compile_command $arg"
1540a966c04fSmrg	finalize_command="$finalize_command $arg"
1541a966c04fSmrg	continue
1542a966c04fSmrg	;;
1543a966c04fSmrg
1544a966c04fSmrg      -inst-prefix-dir)
1545a966c04fSmrg	prev=inst_prefix
1546a966c04fSmrg	continue
1547a966c04fSmrg	;;
1548a966c04fSmrg
1549a966c04fSmrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
1550a966c04fSmrg      # so, if we see these flags be careful not to treat them like -L
1551a966c04fSmrg      -L[A-Z][A-Z]*:*)
1552a966c04fSmrg	case $with_gcc/$host in
1553a966c04fSmrg	no/*-*-irix* | /*-*-irix*)
1554a966c04fSmrg	  compile_command="$compile_command $arg"
1555a966c04fSmrg	  finalize_command="$finalize_command $arg"
1556a966c04fSmrg	  ;;
1557a966c04fSmrg	esac
1558a966c04fSmrg	continue
1559a966c04fSmrg	;;
1560a966c04fSmrg
1561a966c04fSmrg      -L*)
1562a966c04fSmrg	dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
1563a966c04fSmrg	# We need an absolute path.
1564a966c04fSmrg	case $dir in
1565a966c04fSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
1566a966c04fSmrg	*)
1567a966c04fSmrg	  absdir=`cd "$dir" && pwd`
1568a966c04fSmrg	  if test -z "$absdir"; then
1569a966c04fSmrg	    $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
1570a966c04fSmrg	    absdir="$dir"
1571a966c04fSmrg	    notinst_path="$notinst_path $dir"
1572a966c04fSmrg	  fi
1573a966c04fSmrg	  dir="$absdir"
1574a966c04fSmrg	  ;;
1575a966c04fSmrg	esac
1576a966c04fSmrg	case "$deplibs " in
1577a966c04fSmrg	*" -L$dir "*) ;;
1578a966c04fSmrg	*)
1579a966c04fSmrg	  deplibs="$deplibs -L$dir"
1580a966c04fSmrg	  lib_search_path="$lib_search_path $dir"
1581a966c04fSmrg	  ;;
1582a966c04fSmrg	esac
1583a966c04fSmrg	case $host in
1584a966c04fSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
1585a966c04fSmrg	  testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'`
1586a966c04fSmrg	  case :$dllsearchpath: in
1587a966c04fSmrg	  *":$dir:"*) ;;
1588a966c04fSmrg	  *) dllsearchpath="$dllsearchpath:$dir";;
1589a966c04fSmrg	  esac
1590a966c04fSmrg	  case :$dllsearchpath: in
1591a966c04fSmrg	  *":$testbindir:"*) ;;
1592a966c04fSmrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
1593a966c04fSmrg	  esac
1594a966c04fSmrg	  ;;
1595a966c04fSmrg	esac
1596a966c04fSmrg	continue
1597a966c04fSmrg	;;
1598a966c04fSmrg
1599a966c04fSmrg      -l*)
1600a966c04fSmrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
1601a966c04fSmrg	  case $host in
1602a966c04fSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
1603a966c04fSmrg	    # These systems don't actually have a C or math library (as such)
1604a966c04fSmrg	    continue
1605a966c04fSmrg	    ;;
1606a966c04fSmrg	  *-*-os2*)
1607a966c04fSmrg	    # These systems don't actually have a C library (as such)
1608a966c04fSmrg	    test "X$arg" = "X-lc" && continue
1609a966c04fSmrg	    ;;
1610a966c04fSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
1611a966c04fSmrg	    # Do not include libc due to us having libc/libc_r.
1612a966c04fSmrg	    test "X$arg" = "X-lc" && continue
1613a966c04fSmrg	    ;;
1614a966c04fSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
1615a966c04fSmrg	    # Rhapsody C and math libraries are in the System framework
1616a966c04fSmrg	    deplibs="$deplibs -framework System"
1617a966c04fSmrg	    continue
1618a966c04fSmrg	    ;;
1619a966c04fSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
1620a966c04fSmrg	    # Causes problems with __ctype
1621a966c04fSmrg	    test "X$arg" = "X-lc" && continue
1622a966c04fSmrg	    ;;
1623a966c04fSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
1624a966c04fSmrg	    # Compiler inserts libc in the correct place for threads to work
1625a966c04fSmrg	    test "X$arg" = "X-lc" && continue
1626a966c04fSmrg	    ;;
1627a966c04fSmrg	  esac
1628a966c04fSmrg	elif test "X$arg" = "X-lc_r"; then
1629a966c04fSmrg	 case $host in
1630a966c04fSmrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
1631a966c04fSmrg	   # Do not include libc_r directly, use -pthread flag.
1632a966c04fSmrg	   continue
1633a966c04fSmrg	   ;;
1634a966c04fSmrg	 esac
1635a966c04fSmrg	fi
1636a966c04fSmrg	deplibs="$deplibs $arg"
1637a966c04fSmrg	continue
1638a966c04fSmrg	;;
1639a966c04fSmrg
1640a966c04fSmrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
1641a966c04fSmrg      # classes, name mangling, and exception handling.
1642a966c04fSmrg      -model)
1643a966c04fSmrg	compile_command="$compile_command $arg"
1644a966c04fSmrg	compiler_flags="$compiler_flags $arg"
1645a966c04fSmrg	finalize_command="$finalize_command $arg"
1646a966c04fSmrg	prev=xcompiler
1647a966c04fSmrg	continue
1648a966c04fSmrg	;;
1649a966c04fSmrg
16502e2dd055Smrg     -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
1651a966c04fSmrg	compiler_flags="$compiler_flags $arg"
1652a966c04fSmrg	compile_command="$compile_command $arg"
1653a966c04fSmrg	finalize_command="$finalize_command $arg"
1654a966c04fSmrg	continue
1655a966c04fSmrg	;;
1656a966c04fSmrg
16572e2dd055Smrg      -multi_module)
16582e2dd055Smrg	single_module="${wl}-multi_module"
16592e2dd055Smrg	continue
16602e2dd055Smrg	;;
16612e2dd055Smrg
1662a966c04fSmrg      -module)
1663a966c04fSmrg	module=yes
1664a966c04fSmrg	continue
1665a966c04fSmrg	;;
1666a966c04fSmrg
1667a966c04fSmrg      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
1668a966c04fSmrg      # -r[0-9][0-9]* specifies the processor on the SGI compiler
1669a966c04fSmrg      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
1670a966c04fSmrg      # +DA*, +DD* enable 64-bit mode on the HP compiler
1671a966c04fSmrg      # -q* pass through compiler args for the IBM compiler
1672a966c04fSmrg      # -m* pass through architecture-specific compiler args for GCC
1673a966c04fSmrg      # -m*, -t[45]*, -txscale* pass through architecture-specific
1674a966c04fSmrg      # compiler args for GCC
16752e2dd055Smrg      # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
16762e2dd055Smrg      # -F/path gives path to uninstalled frameworks, gcc on darwin
1677a966c04fSmrg      # @file GCC response files
16782e2dd055Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
16792e2dd055Smrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
1680a966c04fSmrg
1681a966c04fSmrg	# Unknown arguments in both finalize_command and compile_command need
1682a966c04fSmrg	# to be aesthetically quoted because they are evaled later.
1683a966c04fSmrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1684a966c04fSmrg	case $arg in
1685a966c04fSmrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1686a966c04fSmrg	  arg="\"$arg\""
1687a966c04fSmrg	  ;;
1688a966c04fSmrg	esac
1689a966c04fSmrg        compile_command="$compile_command $arg"
1690a966c04fSmrg        finalize_command="$finalize_command $arg"
1691a966c04fSmrg        compiler_flags="$compiler_flags $arg"
1692a966c04fSmrg        continue
1693a966c04fSmrg        ;;
1694a966c04fSmrg
1695a966c04fSmrg      -shrext)
1696a966c04fSmrg	prev=shrext
1697a966c04fSmrg	continue
1698a966c04fSmrg	;;
1699a966c04fSmrg
1700a966c04fSmrg      -no-fast-install)
1701a966c04fSmrg	fast_install=no
1702a966c04fSmrg	continue
1703a966c04fSmrg	;;
1704a966c04fSmrg
1705a966c04fSmrg      -no-install)
1706a966c04fSmrg	case $host in
17072e2dd055Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin*)
1708a966c04fSmrg	  # The PATH hackery in wrapper scripts is required on Windows
17092e2dd055Smrg	  # and Darwin in order for the loader to find any dlls it needs.
1710a966c04fSmrg	  $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
1711a966c04fSmrg	  $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
1712a966c04fSmrg	  fast_install=no
1713a966c04fSmrg	  ;;
1714a966c04fSmrg	*) no_install=yes ;;
1715a966c04fSmrg	esac
1716a966c04fSmrg	continue
1717a966c04fSmrg	;;
1718a966c04fSmrg
1719a966c04fSmrg      -no-undefined)
1720a966c04fSmrg	allow_undefined=no
1721a966c04fSmrg	continue
1722a966c04fSmrg	;;
1723a966c04fSmrg
1724a966c04fSmrg      -objectlist)
1725a966c04fSmrg	prev=objectlist
1726a966c04fSmrg	continue
1727a966c04fSmrg	;;
1728a966c04fSmrg
1729a966c04fSmrg      -o) prev=output ;;
1730a966c04fSmrg
1731a966c04fSmrg      -precious-files-regex)
1732a966c04fSmrg	prev=precious_regex
1733a966c04fSmrg	continue
1734a966c04fSmrg	;;
1735a966c04fSmrg
1736a966c04fSmrg      -release)
1737a966c04fSmrg	prev=release
1738a966c04fSmrg	continue
1739a966c04fSmrg	;;
1740a966c04fSmrg
1741a966c04fSmrg      -rpath)
1742a966c04fSmrg	prev=rpath
1743a966c04fSmrg	continue
1744a966c04fSmrg	;;
1745a966c04fSmrg
1746a966c04fSmrg      -R)
1747a966c04fSmrg	prev=xrpath
1748a966c04fSmrg	continue
1749a966c04fSmrg	;;
1750a966c04fSmrg
1751a966c04fSmrg      -R*)
1752a966c04fSmrg	dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
1753a966c04fSmrg	# We need an absolute path.
1754a966c04fSmrg	case $dir in
1755a966c04fSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
1756a966c04fSmrg	*)
1757a966c04fSmrg	  $echo "$modename: only absolute run-paths are allowed" 1>&2
1758a966c04fSmrg	  exit $EXIT_FAILURE
1759a966c04fSmrg	  ;;
1760a966c04fSmrg	esac
1761a966c04fSmrg	case "$xrpath " in
1762a966c04fSmrg	*" $dir "*) ;;
1763a966c04fSmrg	*) xrpath="$xrpath $dir" ;;
1764a966c04fSmrg	esac
1765a966c04fSmrg	continue
1766a966c04fSmrg	;;
1767a966c04fSmrg
17682e2dd055Smrg      -static | -static-libtool-libs)
1769a966c04fSmrg	# The effects of -static are defined in a previous loop.
1770a966c04fSmrg	# We used to do the same as -all-static on platforms that
1771a966c04fSmrg	# didn't have a PIC flag, but the assumption that the effects
1772a966c04fSmrg	# would be equivalent was wrong.  It would break on at least
1773a966c04fSmrg	# Digital Unix and AIX.
1774a966c04fSmrg	continue
1775a966c04fSmrg	;;
1776a966c04fSmrg
1777a966c04fSmrg      -thread-safe)
1778a966c04fSmrg	thread_safe=yes
1779a966c04fSmrg	continue
1780a966c04fSmrg	;;
1781a966c04fSmrg
1782a966c04fSmrg      -version-info)
1783a966c04fSmrg	prev=vinfo
1784a966c04fSmrg	continue
1785a966c04fSmrg	;;
1786a966c04fSmrg      -version-number)
1787a966c04fSmrg	prev=vinfo
1788a966c04fSmrg	vinfo_number=yes
1789a966c04fSmrg	continue
1790a966c04fSmrg	;;
1791a966c04fSmrg
1792a966c04fSmrg      -Wc,*)
1793a966c04fSmrg	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
1794a966c04fSmrg	arg=
1795a966c04fSmrg	save_ifs="$IFS"; IFS=','
1796a966c04fSmrg	for flag in $args; do
1797a966c04fSmrg	  IFS="$save_ifs"
1798a966c04fSmrg	  case $flag in
1799a966c04fSmrg	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1800a966c04fSmrg	    flag="\"$flag\""
1801a966c04fSmrg	    ;;
1802a966c04fSmrg	  esac
1803a966c04fSmrg	  arg="$arg $wl$flag"
1804a966c04fSmrg	  compiler_flags="$compiler_flags $flag"
1805a966c04fSmrg	done
1806a966c04fSmrg	IFS="$save_ifs"
1807a966c04fSmrg	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
1808a966c04fSmrg	;;
1809a966c04fSmrg
1810a966c04fSmrg      -Wl,*)
1811a966c04fSmrg	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
1812a966c04fSmrg	arg=
1813a966c04fSmrg	save_ifs="$IFS"; IFS=','
1814a966c04fSmrg	for flag in $args; do
1815a966c04fSmrg	  IFS="$save_ifs"
1816a966c04fSmrg	  case $flag in
1817a966c04fSmrg	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1818a966c04fSmrg	    flag="\"$flag\""
1819a966c04fSmrg	    ;;
1820a966c04fSmrg	  esac
1821a966c04fSmrg	  arg="$arg $wl$flag"
1822a966c04fSmrg	  compiler_flags="$compiler_flags $wl$flag"
1823a966c04fSmrg	  linker_flags="$linker_flags $flag"
1824a966c04fSmrg	done
1825a966c04fSmrg	IFS="$save_ifs"
1826a966c04fSmrg	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
1827a966c04fSmrg	;;
1828a966c04fSmrg
1829a966c04fSmrg      -Xcompiler)
1830a966c04fSmrg	prev=xcompiler
1831a966c04fSmrg	continue
1832a966c04fSmrg	;;
1833a966c04fSmrg
1834a966c04fSmrg      -Xlinker)
1835a966c04fSmrg	prev=xlinker
1836a966c04fSmrg	continue
1837a966c04fSmrg	;;
1838a966c04fSmrg
1839a966c04fSmrg      -XCClinker)
1840a966c04fSmrg	prev=xcclinker
1841a966c04fSmrg	continue
1842a966c04fSmrg	;;
1843a966c04fSmrg
1844a966c04fSmrg      # Some other compiler flag.
1845a966c04fSmrg      -* | +*)
1846a966c04fSmrg	# Unknown arguments in both finalize_command and compile_command need
1847a966c04fSmrg	# to be aesthetically quoted because they are evaled later.
1848a966c04fSmrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1849a966c04fSmrg	case $arg in
1850a966c04fSmrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1851a966c04fSmrg	  arg="\"$arg\""
1852a966c04fSmrg	  ;;
1853a966c04fSmrg	esac
1854a966c04fSmrg	;;
1855a966c04fSmrg
1856a966c04fSmrg      *.$objext)
1857a966c04fSmrg	# A standard object.
1858a966c04fSmrg	objs="$objs $arg"
1859a966c04fSmrg	;;
1860a966c04fSmrg
1861a966c04fSmrg      *.lo)
1862a966c04fSmrg	# A libtool-controlled object.
1863a966c04fSmrg
1864a966c04fSmrg	# Check to see that this really is a libtool object.
1865a966c04fSmrg	if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
1866a966c04fSmrg	  pic_object=
1867a966c04fSmrg	  non_pic_object=
1868a966c04fSmrg
1869a966c04fSmrg	  # Read the .lo file
1870a966c04fSmrg	  # If there is no directory component, then add one.
1871a966c04fSmrg	  case $arg in
1872a966c04fSmrg	  */* | *\\*) . $arg ;;
1873a966c04fSmrg	  *) . ./$arg ;;
1874a966c04fSmrg	  esac
1875a966c04fSmrg
1876a966c04fSmrg	  if test -z "$pic_object" || \
1877a966c04fSmrg	     test -z "$non_pic_object" ||
1878a966c04fSmrg	     test "$pic_object" = none && \
1879a966c04fSmrg	     test "$non_pic_object" = none; then
1880a966c04fSmrg	    $echo "$modename: cannot find name of object for \`$arg'" 1>&2
1881a966c04fSmrg	    exit $EXIT_FAILURE
1882a966c04fSmrg	  fi
1883a966c04fSmrg
1884a966c04fSmrg	  # Extract subdirectory from the argument.
1885a966c04fSmrg	  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1886a966c04fSmrg	  if test "X$xdir" = "X$arg"; then
1887a966c04fSmrg	    xdir=
1888a966c04fSmrg 	  else
1889a966c04fSmrg	    xdir="$xdir/"
1890a966c04fSmrg	  fi
1891a966c04fSmrg
1892a966c04fSmrg	  if test "$pic_object" != none; then
1893a966c04fSmrg	    # Prepend the subdirectory the object is found in.
1894a966c04fSmrg	    pic_object="$xdir$pic_object"
1895a966c04fSmrg
1896a966c04fSmrg	    if test "$prev" = dlfiles; then
1897a966c04fSmrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
1898a966c04fSmrg		dlfiles="$dlfiles $pic_object"
1899a966c04fSmrg		prev=
1900a966c04fSmrg		continue
1901a966c04fSmrg	      else
1902a966c04fSmrg		# If libtool objects are unsupported, then we need to preload.
1903a966c04fSmrg		prev=dlprefiles
1904a966c04fSmrg	      fi
1905a966c04fSmrg	    fi
1906a966c04fSmrg
1907a966c04fSmrg	    # CHECK ME:  I think I busted this.  -Ossama
1908a966c04fSmrg	    if test "$prev" = dlprefiles; then
1909a966c04fSmrg	      # Preload the old-style object.
1910a966c04fSmrg	      dlprefiles="$dlprefiles $pic_object"
1911a966c04fSmrg	      prev=
1912a966c04fSmrg	    fi
1913a966c04fSmrg
1914a966c04fSmrg	    # A PIC object.
1915a966c04fSmrg	    libobjs="$libobjs $pic_object"
1916a966c04fSmrg	    arg="$pic_object"
1917a966c04fSmrg	  fi
1918a966c04fSmrg
1919a966c04fSmrg	  # Non-PIC object.
1920a966c04fSmrg	  if test "$non_pic_object" != none; then
1921a966c04fSmrg	    # Prepend the subdirectory the object is found in.
1922a966c04fSmrg	    non_pic_object="$xdir$non_pic_object"
1923a966c04fSmrg
1924a966c04fSmrg	    # A standard non-PIC object
1925a966c04fSmrg	    non_pic_objects="$non_pic_objects $non_pic_object"
1926a966c04fSmrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
1927a966c04fSmrg	      arg="$non_pic_object"
1928a966c04fSmrg	    fi
1929a966c04fSmrg	  else
1930a966c04fSmrg	    # If the PIC object exists, use it instead.
1931a966c04fSmrg	    # $xdir was prepended to $pic_object above.
1932a966c04fSmrg	    non_pic_object="$pic_object"
1933a966c04fSmrg	    non_pic_objects="$non_pic_objects $non_pic_object"
1934a966c04fSmrg	  fi
1935a966c04fSmrg	else
1936a966c04fSmrg	  # Only an error if not doing a dry-run.
1937a966c04fSmrg	  if test -z "$run"; then
1938a966c04fSmrg	    $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
1939a966c04fSmrg	    exit $EXIT_FAILURE
1940a966c04fSmrg	  else
1941a966c04fSmrg	    # Dry-run case.
1942a966c04fSmrg
1943a966c04fSmrg	    # Extract subdirectory from the argument.
1944a966c04fSmrg	    xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1945a966c04fSmrg	    if test "X$xdir" = "X$arg"; then
1946a966c04fSmrg	      xdir=
1947a966c04fSmrg	    else
1948a966c04fSmrg	      xdir="$xdir/"
1949a966c04fSmrg	    fi
1950a966c04fSmrg
1951a966c04fSmrg	    pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
1952a966c04fSmrg	    non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
1953a966c04fSmrg	    libobjs="$libobjs $pic_object"
1954a966c04fSmrg	    non_pic_objects="$non_pic_objects $non_pic_object"
1955a966c04fSmrg	  fi
1956a966c04fSmrg	fi
1957a966c04fSmrg	;;
1958a966c04fSmrg
1959a966c04fSmrg      *.$libext)
1960a966c04fSmrg	# An archive.
1961a966c04fSmrg	deplibs="$deplibs $arg"
1962a966c04fSmrg	old_deplibs="$old_deplibs $arg"
1963a966c04fSmrg	continue
1964a966c04fSmrg	;;
1965a966c04fSmrg
1966a966c04fSmrg      *.la)
1967a966c04fSmrg	# A libtool-controlled library.
1968a966c04fSmrg
1969a966c04fSmrg	if test "$prev" = dlfiles; then
1970a966c04fSmrg	  # This library was specified with -dlopen.
1971a966c04fSmrg	  dlfiles="$dlfiles $arg"
1972a966c04fSmrg	  prev=
1973a966c04fSmrg	elif test "$prev" = dlprefiles; then
1974a966c04fSmrg	  # The library was specified with -dlpreopen.
1975a966c04fSmrg	  dlprefiles="$dlprefiles $arg"
1976a966c04fSmrg	  prev=
1977a966c04fSmrg	else
1978a966c04fSmrg	  deplibs="$deplibs $arg"
1979a966c04fSmrg	fi
1980a966c04fSmrg	continue
1981a966c04fSmrg	;;
1982a966c04fSmrg
1983a966c04fSmrg      # Some other compiler argument.
1984a966c04fSmrg      *)
1985a966c04fSmrg	# Unknown arguments in both finalize_command and compile_command need
1986a966c04fSmrg	# to be aesthetically quoted because they are evaled later.
1987a966c04fSmrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1988a966c04fSmrg	case $arg in
1989a966c04fSmrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1990a966c04fSmrg	  arg="\"$arg\""
1991a966c04fSmrg	  ;;
1992a966c04fSmrg	esac
1993a966c04fSmrg	;;
1994a966c04fSmrg      esac # arg
1995a966c04fSmrg
1996a966c04fSmrg      # Now actually substitute the argument into the commands.
1997a966c04fSmrg      if test -n "$arg"; then
1998a966c04fSmrg	compile_command="$compile_command $arg"
1999a966c04fSmrg	finalize_command="$finalize_command $arg"
2000a966c04fSmrg      fi
2001a966c04fSmrg    done # argument parsing loop
2002a966c04fSmrg
2003a966c04fSmrg    if test -n "$prev"; then
2004a966c04fSmrg      $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
2005a966c04fSmrg      $echo "$help" 1>&2
2006a966c04fSmrg      exit $EXIT_FAILURE
2007a966c04fSmrg    fi
2008a966c04fSmrg
2009a966c04fSmrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
2010a966c04fSmrg      eval arg=\"$export_dynamic_flag_spec\"
2011a966c04fSmrg      compile_command="$compile_command $arg"
2012a966c04fSmrg      finalize_command="$finalize_command $arg"
2013a966c04fSmrg    fi
2014a966c04fSmrg
2015a966c04fSmrg    oldlibs=
2016a966c04fSmrg    # calculate the name of the file, without its directory
2017a966c04fSmrg    outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
2018a966c04fSmrg    libobjs_save="$libobjs"
2019a966c04fSmrg
2020a966c04fSmrg    if test -n "$shlibpath_var"; then
2021a966c04fSmrg      # get the directories listed in $shlibpath_var
2022a966c04fSmrg      eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
2023a966c04fSmrg    else
2024a966c04fSmrg      shlib_search_path=
2025a966c04fSmrg    fi
2026a966c04fSmrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
2027a966c04fSmrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
2028a966c04fSmrg
2029a966c04fSmrg    output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
2030a966c04fSmrg    if test "X$output_objdir" = "X$output"; then
2031a966c04fSmrg      output_objdir="$objdir"
2032a966c04fSmrg    else
2033a966c04fSmrg      output_objdir="$output_objdir/$objdir"
2034a966c04fSmrg    fi
2035a966c04fSmrg    # Create the object directory.
2036a966c04fSmrg    if test ! -d "$output_objdir"; then
2037a966c04fSmrg      $show "$mkdir $output_objdir"
2038a966c04fSmrg      $run $mkdir $output_objdir
2039a966c04fSmrg      exit_status=$?
2040a966c04fSmrg      if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then
2041a966c04fSmrg	exit $exit_status
2042a966c04fSmrg      fi
2043a966c04fSmrg    fi
2044a966c04fSmrg
2045a966c04fSmrg    # Determine the type of output
2046a966c04fSmrg    case $output in
2047a966c04fSmrg    "")
2048a966c04fSmrg      $echo "$modename: you must specify an output file" 1>&2
2049a966c04fSmrg      $echo "$help" 1>&2
2050a966c04fSmrg      exit $EXIT_FAILURE
2051a966c04fSmrg      ;;
2052a966c04fSmrg    *.$libext) linkmode=oldlib ;;
2053a966c04fSmrg    *.lo | *.$objext) linkmode=obj ;;
2054a966c04fSmrg    *.la) linkmode=lib ;;
2055a966c04fSmrg    *) linkmode=prog ;; # Anything else should be a program.
2056a966c04fSmrg    esac
2057a966c04fSmrg
2058a966c04fSmrg    case $host in
2059a966c04fSmrg    *cygwin* | *mingw* | *pw32*)
2060a966c04fSmrg      # don't eliminate duplications in $postdeps and $predeps
2061a966c04fSmrg      duplicate_compiler_generated_deps=yes
2062a966c04fSmrg      ;;
2063a966c04fSmrg    *)
2064a966c04fSmrg      duplicate_compiler_generated_deps=$duplicate_deps
2065a966c04fSmrg      ;;
2066a966c04fSmrg    esac
2067a966c04fSmrg    specialdeplibs=
2068a966c04fSmrg
2069a966c04fSmrg    libs=
2070a966c04fSmrg    # Find all interdependent deplibs by searching for libraries
2071a966c04fSmrg    # that are linked more than once (e.g. -la -lb -la)
2072a966c04fSmrg    for deplib in $deplibs; do
2073a966c04fSmrg      if test "X$duplicate_deps" = "Xyes" ; then
2074a966c04fSmrg	case "$libs " in
2075a966c04fSmrg	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2076a966c04fSmrg	esac
2077a966c04fSmrg      fi
2078a966c04fSmrg      libs="$libs $deplib"
2079a966c04fSmrg    done
2080a966c04fSmrg
2081a966c04fSmrg    if test "$linkmode" = lib; then
2082a966c04fSmrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
2083a966c04fSmrg
2084a966c04fSmrg      # Compute libraries that are listed more than once in $predeps
2085a966c04fSmrg      # $postdeps and mark them as special (i.e., whose duplicates are
2086a966c04fSmrg      # not to be eliminated).
2087a966c04fSmrg      pre_post_deps=
2088a966c04fSmrg      if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
2089a966c04fSmrg	for pre_post_dep in $predeps $postdeps; do
2090a966c04fSmrg	  case "$pre_post_deps " in
2091a966c04fSmrg	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
2092a966c04fSmrg	  esac
2093a966c04fSmrg	  pre_post_deps="$pre_post_deps $pre_post_dep"
2094a966c04fSmrg	done
2095a966c04fSmrg      fi
2096a966c04fSmrg      pre_post_deps=
2097a966c04fSmrg    fi
2098a966c04fSmrg
2099a966c04fSmrg    deplibs=
2100a966c04fSmrg    newdependency_libs=
2101a966c04fSmrg    newlib_search_path=
2102a966c04fSmrg    need_relink=no # whether we're linking any uninstalled libtool libraries
2103a966c04fSmrg    notinst_deplibs= # not-installed libtool libraries
2104a966c04fSmrg    case $linkmode in
2105a966c04fSmrg    lib)
2106a966c04fSmrg	passes="conv link"
2107a966c04fSmrg	for file in $dlfiles $dlprefiles; do
2108a966c04fSmrg	  case $file in
2109a966c04fSmrg	  *.la) ;;
2110a966c04fSmrg	  *)
2111a966c04fSmrg	    $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
2112a966c04fSmrg	    exit $EXIT_FAILURE
2113a966c04fSmrg	    ;;
2114a966c04fSmrg	  esac
2115a966c04fSmrg	done
2116a966c04fSmrg	;;
2117a966c04fSmrg    prog)
2118a966c04fSmrg	compile_deplibs=
2119a966c04fSmrg	finalize_deplibs=
2120a966c04fSmrg	alldeplibs=no
2121a966c04fSmrg	newdlfiles=
2122a966c04fSmrg	newdlprefiles=
2123a966c04fSmrg	passes="conv scan dlopen dlpreopen link"
2124a966c04fSmrg	;;
2125a966c04fSmrg    *)  passes="conv"
2126a966c04fSmrg	;;
2127a966c04fSmrg    esac
2128a966c04fSmrg    for pass in $passes; do
2129a966c04fSmrg      if test "$linkmode,$pass" = "lib,link" ||
2130a966c04fSmrg	 test "$linkmode,$pass" = "prog,scan"; then
2131a966c04fSmrg	libs="$deplibs"
2132a966c04fSmrg	deplibs=
2133a966c04fSmrg      fi
2134a966c04fSmrg      if test "$linkmode" = prog; then
2135a966c04fSmrg	case $pass in
2136a966c04fSmrg	dlopen) libs="$dlfiles" ;;
2137a966c04fSmrg	dlpreopen) libs="$dlprefiles" ;;
2138a966c04fSmrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
2139a966c04fSmrg	esac
2140a966c04fSmrg      fi
2141a966c04fSmrg      if test "$pass" = dlopen; then
2142a966c04fSmrg	# Collect dlpreopened libraries
2143a966c04fSmrg	save_deplibs="$deplibs"
2144a966c04fSmrg	deplibs=
2145a966c04fSmrg      fi
2146a966c04fSmrg      for deplib in $libs; do
2147a966c04fSmrg	lib=
2148a966c04fSmrg	found=no
2149a966c04fSmrg	case $deplib in
21502e2dd055Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
2151a966c04fSmrg	  if test "$linkmode,$pass" = "prog,link"; then
2152a966c04fSmrg	    compile_deplibs="$deplib $compile_deplibs"
2153a966c04fSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
2154a966c04fSmrg	  else
2155a966c04fSmrg	    compiler_flags="$compiler_flags $deplib"
2156a966c04fSmrg	  fi
2157a966c04fSmrg	  continue
2158a966c04fSmrg	  ;;
2159a966c04fSmrg	-l*)
2160a966c04fSmrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
2161a966c04fSmrg	    $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
2162a966c04fSmrg	    continue
2163a966c04fSmrg	  fi
2164a966c04fSmrg	  name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
21652e2dd055Smrg	  if test "$linkmode" = lib; then
21662e2dd055Smrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
21672e2dd055Smrg	  else
21682e2dd055Smrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
21692e2dd055Smrg	  fi
21702e2dd055Smrg	  for searchdir in $searchdirs; do
2171a966c04fSmrg	    for search_ext in .la $std_shrext .so .a; do
2172a966c04fSmrg	      # Search the libtool library
2173a966c04fSmrg	      lib="$searchdir/lib${name}${search_ext}"
2174a966c04fSmrg	      if test -f "$lib"; then
2175a966c04fSmrg		if test "$search_ext" = ".la"; then
2176a966c04fSmrg		  found=yes
2177a966c04fSmrg		else
2178a966c04fSmrg		  found=no
2179a966c04fSmrg		fi
2180a966c04fSmrg		break 2
2181a966c04fSmrg	      fi
2182a966c04fSmrg	    done
2183a966c04fSmrg	  done
2184a966c04fSmrg	  if test "$found" != yes; then
2185a966c04fSmrg	    # deplib doesn't seem to be a libtool library
2186a966c04fSmrg	    if test "$linkmode,$pass" = "prog,link"; then
2187a966c04fSmrg	      compile_deplibs="$deplib $compile_deplibs"
2188a966c04fSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
2189a966c04fSmrg	    else
2190a966c04fSmrg	      deplibs="$deplib $deplibs"
2191a966c04fSmrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
2192a966c04fSmrg	    fi
2193a966c04fSmrg	    continue
2194a966c04fSmrg	  else # deplib is a libtool library
2195a966c04fSmrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
2196a966c04fSmrg	    # We need to do some special things here, and not later.
2197a966c04fSmrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
2198a966c04fSmrg	      case " $predeps $postdeps " in
2199a966c04fSmrg	      *" $deplib "*)
2200a966c04fSmrg		if (${SED} -e '2q' $lib |
2201a966c04fSmrg                    grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
2202a966c04fSmrg		  library_names=
2203a966c04fSmrg		  old_library=
2204a966c04fSmrg		  case $lib in
2205a966c04fSmrg		  */* | *\\*) . $lib ;;
2206a966c04fSmrg		  *) . ./$lib ;;
2207a966c04fSmrg		  esac
2208a966c04fSmrg		  for l in $old_library $library_names; do
2209a966c04fSmrg		    ll="$l"
2210a966c04fSmrg		  done
2211a966c04fSmrg		  if test "X$ll" = "X$old_library" ; then # only static version available
2212a966c04fSmrg		    found=no
2213a966c04fSmrg		    ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
2214a966c04fSmrg		    test "X$ladir" = "X$lib" && ladir="."
2215a966c04fSmrg		    lib=$ladir/$old_library
2216a966c04fSmrg		    if test "$linkmode,$pass" = "prog,link"; then
2217a966c04fSmrg		      compile_deplibs="$deplib $compile_deplibs"
2218a966c04fSmrg		      finalize_deplibs="$deplib $finalize_deplibs"
2219a966c04fSmrg		    else
2220a966c04fSmrg		      deplibs="$deplib $deplibs"
2221a966c04fSmrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
2222a966c04fSmrg		    fi
2223a966c04fSmrg		    continue
2224a966c04fSmrg		  fi
2225a966c04fSmrg		fi
2226a966c04fSmrg	        ;;
2227a966c04fSmrg	      *) ;;
2228a966c04fSmrg	      esac
2229a966c04fSmrg	    fi
2230a966c04fSmrg	  fi
2231a966c04fSmrg	  ;; # -l
2232a966c04fSmrg	-L*)
2233a966c04fSmrg	  case $linkmode in
2234a966c04fSmrg	  lib)
2235a966c04fSmrg	    deplibs="$deplib $deplibs"
2236a966c04fSmrg	    test "$pass" = conv && continue
2237a966c04fSmrg	    newdependency_libs="$deplib $newdependency_libs"
2238a966c04fSmrg	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
2239a966c04fSmrg	    ;;
2240a966c04fSmrg	  prog)
2241a966c04fSmrg	    if test "$pass" = conv; then
2242a966c04fSmrg	      deplibs="$deplib $deplibs"
2243a966c04fSmrg	      continue
2244a966c04fSmrg	    fi
2245a966c04fSmrg	    if test "$pass" = scan; then
2246a966c04fSmrg	      deplibs="$deplib $deplibs"
2247a966c04fSmrg	    else
2248a966c04fSmrg	      compile_deplibs="$deplib $compile_deplibs"
2249a966c04fSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
2250a966c04fSmrg	    fi
2251a966c04fSmrg	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
2252a966c04fSmrg	    ;;
2253a966c04fSmrg	  *)
2254a966c04fSmrg	    $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
2255a966c04fSmrg	    ;;
2256a966c04fSmrg	  esac # linkmode
2257a966c04fSmrg	  continue
2258a966c04fSmrg	  ;; # -L
2259a966c04fSmrg	-R*)
2260a966c04fSmrg	  if test "$pass" = link; then
2261a966c04fSmrg	    dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
2262a966c04fSmrg	    # Make sure the xrpath contains only unique directories.
2263a966c04fSmrg	    case "$xrpath " in
2264a966c04fSmrg	    *" $dir "*) ;;
2265a966c04fSmrg	    *) xrpath="$xrpath $dir" ;;
2266a966c04fSmrg	    esac
2267a966c04fSmrg	  fi
2268a966c04fSmrg	  deplibs="$deplib $deplibs"
2269a966c04fSmrg	  continue
2270a966c04fSmrg	  ;;
2271a966c04fSmrg	*.la) lib="$deplib" ;;
2272a966c04fSmrg	*.$libext)
2273a966c04fSmrg	  if test "$pass" = conv; then
2274a966c04fSmrg	    deplibs="$deplib $deplibs"
2275a966c04fSmrg	    continue
2276a966c04fSmrg	  fi
2277a966c04fSmrg	  case $linkmode in
2278a966c04fSmrg	  lib)
2279a966c04fSmrg	    valid_a_lib=no
2280a966c04fSmrg	    case $deplibs_check_method in
2281a966c04fSmrg	      match_pattern*)
2282a966c04fSmrg		set dummy $deplibs_check_method
2283a966c04fSmrg	        match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
2284a966c04fSmrg		if eval $echo \"$deplib\" 2>/dev/null \
2285a966c04fSmrg		    | $SED 10q \
2286a966c04fSmrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
2287a966c04fSmrg		  valid_a_lib=yes
2288a966c04fSmrg		fi
2289a966c04fSmrg		;;
2290a966c04fSmrg	      pass_all)
2291a966c04fSmrg		valid_a_lib=yes
2292a966c04fSmrg		;;
2293a966c04fSmrg            esac
2294a966c04fSmrg	    if test "$valid_a_lib" != yes; then
2295a966c04fSmrg	      $echo
2296a966c04fSmrg	      $echo "*** Warning: Trying to link with static lib archive $deplib."
2297a966c04fSmrg	      $echo "*** I have the capability to make that library automatically link in when"
2298a966c04fSmrg	      $echo "*** you link to this library.  But I can only do this if you have a"
2299a966c04fSmrg	      $echo "*** shared version of the library, which you do not appear to have"
2300a966c04fSmrg	      $echo "*** because the file extensions .$libext of this argument makes me believe"
2301a966c04fSmrg	      $echo "*** that it is just a static archive that I should not used here."
2302a966c04fSmrg	    else
2303a966c04fSmrg	      $echo
2304a966c04fSmrg	      $echo "*** Warning: Linking the shared library $output against the"
2305a966c04fSmrg	      $echo "*** static library $deplib is not portable!"
2306a966c04fSmrg	      deplibs="$deplib $deplibs"
2307a966c04fSmrg	    fi
2308a966c04fSmrg	    continue
2309a966c04fSmrg	    ;;
2310a966c04fSmrg	  prog)
2311a966c04fSmrg	    if test "$pass" != link; then
2312a966c04fSmrg	      deplibs="$deplib $deplibs"
2313a966c04fSmrg	    else
2314a966c04fSmrg	      compile_deplibs="$deplib $compile_deplibs"
2315a966c04fSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
2316a966c04fSmrg	    fi
2317a966c04fSmrg	    continue
2318a966c04fSmrg	    ;;
2319a966c04fSmrg	  esac # linkmode
2320a966c04fSmrg	  ;; # *.$libext
2321a966c04fSmrg	*.lo | *.$objext)
2322a966c04fSmrg	  if test "$pass" = conv; then
2323a966c04fSmrg	    deplibs="$deplib $deplibs"
2324a966c04fSmrg	  elif test "$linkmode" = prog; then
2325a966c04fSmrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
2326a966c04fSmrg	      # If there is no dlopen support or we're linking statically,
2327a966c04fSmrg	      # we need to preload.
2328a966c04fSmrg	      newdlprefiles="$newdlprefiles $deplib"
2329a966c04fSmrg	      compile_deplibs="$deplib $compile_deplibs"
2330a966c04fSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
2331a966c04fSmrg	    else
2332a966c04fSmrg	      newdlfiles="$newdlfiles $deplib"
2333a966c04fSmrg	    fi
2334a966c04fSmrg	  fi
2335a966c04fSmrg	  continue
2336a966c04fSmrg	  ;;
2337a966c04fSmrg	%DEPLIBS%)
2338a966c04fSmrg	  alldeplibs=yes
2339a966c04fSmrg	  continue
2340a966c04fSmrg	  ;;
2341a966c04fSmrg	esac # case $deplib
2342a966c04fSmrg	if test "$found" = yes || test -f "$lib"; then :
2343a966c04fSmrg	else
2344a966c04fSmrg	  $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2
2345a966c04fSmrg	  exit $EXIT_FAILURE
2346a966c04fSmrg	fi
2347a966c04fSmrg
2348a966c04fSmrg	# Check to see that this really is a libtool archive.
2349a966c04fSmrg	if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
2350a966c04fSmrg	else
2351a966c04fSmrg	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
2352a966c04fSmrg	  exit $EXIT_FAILURE
2353a966c04fSmrg	fi
2354a966c04fSmrg
2355a966c04fSmrg	ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
2356a966c04fSmrg	test "X$ladir" = "X$lib" && ladir="."
2357a966c04fSmrg
2358a966c04fSmrg	dlname=
2359a966c04fSmrg	dlopen=
2360a966c04fSmrg	dlpreopen=
2361a966c04fSmrg	libdir=
2362a966c04fSmrg	library_names=
2363a966c04fSmrg	old_library=
2364a966c04fSmrg	# If the library was installed with an old release of libtool,
2365a966c04fSmrg	# it will not redefine variables installed, or shouldnotlink
2366a966c04fSmrg	installed=yes
2367a966c04fSmrg	shouldnotlink=no
2368a966c04fSmrg	avoidtemprpath=
2369a966c04fSmrg
2370a966c04fSmrg
2371a966c04fSmrg	# Read the .la file
2372a966c04fSmrg	case $lib in
2373a966c04fSmrg	*/* | *\\*) . $lib ;;
2374a966c04fSmrg	*) . ./$lib ;;
2375a966c04fSmrg	esac
2376a966c04fSmrg
2377a966c04fSmrg	if test "$linkmode,$pass" = "lib,link" ||
2378a966c04fSmrg	   test "$linkmode,$pass" = "prog,scan" ||
2379a966c04fSmrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
2380a966c04fSmrg	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
2381a966c04fSmrg	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
2382a966c04fSmrg	fi
2383a966c04fSmrg
2384a966c04fSmrg	if test "$pass" = conv; then
2385a966c04fSmrg	  # Only check for convenience libraries
2386a966c04fSmrg	  deplibs="$lib $deplibs"
2387a966c04fSmrg	  if test -z "$libdir"; then
2388a966c04fSmrg	    if test -z "$old_library"; then
2389a966c04fSmrg	      $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
2390a966c04fSmrg	      exit $EXIT_FAILURE
2391a966c04fSmrg	    fi
2392a966c04fSmrg	    # It is a libtool convenience library, so add in its objects.
2393a966c04fSmrg	    convenience="$convenience $ladir/$objdir/$old_library"
2394a966c04fSmrg	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
2395a966c04fSmrg	    tmp_libs=
2396a966c04fSmrg	    for deplib in $dependency_libs; do
2397a966c04fSmrg	      deplibs="$deplib $deplibs"
2398a966c04fSmrg              if test "X$duplicate_deps" = "Xyes" ; then
2399a966c04fSmrg	        case "$tmp_libs " in
2400a966c04fSmrg	        *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2401a966c04fSmrg	        esac
2402a966c04fSmrg              fi
2403a966c04fSmrg	      tmp_libs="$tmp_libs $deplib"
2404a966c04fSmrg	    done
2405a966c04fSmrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
2406a966c04fSmrg	    $echo "$modename: \`$lib' is not a convenience library" 1>&2
2407a966c04fSmrg	    exit $EXIT_FAILURE
2408a966c04fSmrg	  fi
2409a966c04fSmrg	  continue
2410a966c04fSmrg	fi # $pass = conv
2411a966c04fSmrg
2412a966c04fSmrg
2413a966c04fSmrg	# Get the name of the library we link against.
2414a966c04fSmrg	linklib=
2415a966c04fSmrg	for l in $old_library $library_names; do
2416a966c04fSmrg	  linklib="$l"
2417a966c04fSmrg	done
2418a966c04fSmrg	if test -z "$linklib"; then
2419a966c04fSmrg	  $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
2420a966c04fSmrg	  exit $EXIT_FAILURE
2421a966c04fSmrg	fi
2422a966c04fSmrg
2423a966c04fSmrg	# This library was specified with -dlopen.
2424a966c04fSmrg	if test "$pass" = dlopen; then
2425a966c04fSmrg	  if test -z "$libdir"; then
2426a966c04fSmrg	    $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
2427a966c04fSmrg	    exit $EXIT_FAILURE
2428a966c04fSmrg	  fi
2429a966c04fSmrg	  if test -z "$dlname" ||
2430a966c04fSmrg	     test "$dlopen_support" != yes ||
2431a966c04fSmrg	     test "$build_libtool_libs" = no; then
2432a966c04fSmrg	    # If there is no dlname, no dlopen support or we're linking
2433a966c04fSmrg	    # statically, we need to preload.  We also need to preload any
2434a966c04fSmrg	    # dependent libraries so libltdl's deplib preloader doesn't
2435a966c04fSmrg	    # bomb out in the load deplibs phase.
2436a966c04fSmrg	    dlprefiles="$dlprefiles $lib $dependency_libs"
2437a966c04fSmrg	  else
2438a966c04fSmrg	    newdlfiles="$newdlfiles $lib"
2439a966c04fSmrg	  fi
2440a966c04fSmrg	  continue
2441a966c04fSmrg	fi # $pass = dlopen
2442a966c04fSmrg
2443a966c04fSmrg	# We need an absolute path.
2444a966c04fSmrg	case $ladir in
2445a966c04fSmrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
2446a966c04fSmrg	*)
2447a966c04fSmrg	  abs_ladir=`cd "$ladir" && pwd`
2448a966c04fSmrg	  if test -z "$abs_ladir"; then
2449a966c04fSmrg	    $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2
2450a966c04fSmrg	    $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
2451a966c04fSmrg	    abs_ladir="$ladir"
2452a966c04fSmrg	  fi
2453a966c04fSmrg	  ;;
2454a966c04fSmrg	esac
2455a966c04fSmrg	laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
2456a966c04fSmrg
2457a966c04fSmrg	# Find the relevant object directory and library name.
2458a966c04fSmrg	if test "X$installed" = Xyes; then
2459a966c04fSmrg	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
2460a966c04fSmrg	    $echo "$modename: warning: library \`$lib' was moved." 1>&2
2461a966c04fSmrg	    dir="$ladir"
2462a966c04fSmrg	    absdir="$abs_ladir"
2463a966c04fSmrg	    libdir="$abs_ladir"
2464a966c04fSmrg	  else
2465a966c04fSmrg	    dir="$libdir"
2466a966c04fSmrg	    absdir="$libdir"
2467a966c04fSmrg	  fi
2468a966c04fSmrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
2469a966c04fSmrg	else
2470a966c04fSmrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
2471a966c04fSmrg	    dir="$ladir"
2472a966c04fSmrg	    absdir="$abs_ladir"
2473a966c04fSmrg	    # Remove this search path later
2474a966c04fSmrg	    notinst_path="$notinst_path $abs_ladir"
2475a966c04fSmrg	  else
2476a966c04fSmrg	    dir="$ladir/$objdir"
2477a966c04fSmrg	    absdir="$abs_ladir/$objdir"
2478a966c04fSmrg	    # Remove this search path later
2479a966c04fSmrg	    notinst_path="$notinst_path $abs_ladir"
2480a966c04fSmrg	  fi
2481a966c04fSmrg	fi # $installed = yes
2482a966c04fSmrg	name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
2483a966c04fSmrg
2484a966c04fSmrg	# This library was specified with -dlpreopen.
2485a966c04fSmrg	if test "$pass" = dlpreopen; then
2486a966c04fSmrg	  if test -z "$libdir"; then
2487a966c04fSmrg	    $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
2488a966c04fSmrg	    exit $EXIT_FAILURE
2489a966c04fSmrg	  fi
2490a966c04fSmrg	  # Prefer using a static library (so that no silly _DYNAMIC symbols
2491a966c04fSmrg	  # are required to link).
2492a966c04fSmrg	  if test -n "$old_library"; then
2493a966c04fSmrg	    newdlprefiles="$newdlprefiles $dir/$old_library"
2494a966c04fSmrg	  # Otherwise, use the dlname, so that lt_dlopen finds it.
2495a966c04fSmrg	  elif test -n "$dlname"; then
2496a966c04fSmrg	    newdlprefiles="$newdlprefiles $dir/$dlname"
2497a966c04fSmrg	  else
2498a966c04fSmrg	    newdlprefiles="$newdlprefiles $dir/$linklib"
2499a966c04fSmrg	  fi
2500a966c04fSmrg	fi # $pass = dlpreopen
2501a966c04fSmrg
2502a966c04fSmrg	if test -z "$libdir"; then
2503a966c04fSmrg	  # Link the convenience library
2504a966c04fSmrg	  if test "$linkmode" = lib; then
2505a966c04fSmrg	    deplibs="$dir/$old_library $deplibs"
2506a966c04fSmrg	  elif test "$linkmode,$pass" = "prog,link"; then
2507a966c04fSmrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
2508a966c04fSmrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
2509a966c04fSmrg	  else
2510a966c04fSmrg	    deplibs="$lib $deplibs" # used for prog,scan pass
2511a966c04fSmrg	  fi
2512a966c04fSmrg	  continue
2513a966c04fSmrg	fi
2514a966c04fSmrg
2515a966c04fSmrg
2516a966c04fSmrg	if test "$linkmode" = prog && test "$pass" != link; then
2517a966c04fSmrg	  newlib_search_path="$newlib_search_path $ladir"
2518a966c04fSmrg	  deplibs="$lib $deplibs"
2519a966c04fSmrg
2520a966c04fSmrg	  linkalldeplibs=no
2521a966c04fSmrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
2522a966c04fSmrg	     test "$build_libtool_libs" = no; then
2523a966c04fSmrg	    linkalldeplibs=yes
2524a966c04fSmrg	  fi
2525a966c04fSmrg
2526a966c04fSmrg	  tmp_libs=
2527a966c04fSmrg	  for deplib in $dependency_libs; do
2528a966c04fSmrg	    case $deplib in
2529a966c04fSmrg	    -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
2530a966c04fSmrg	    esac
2531a966c04fSmrg	    # Need to link against all dependency_libs?
2532a966c04fSmrg	    if test "$linkalldeplibs" = yes; then
2533a966c04fSmrg	      deplibs="$deplib $deplibs"
2534a966c04fSmrg	    else
2535a966c04fSmrg	      # Need to hardcode shared library paths
2536a966c04fSmrg	      # or/and link against static libraries
2537a966c04fSmrg	      newdependency_libs="$deplib $newdependency_libs"
2538a966c04fSmrg	    fi
2539a966c04fSmrg	    if test "X$duplicate_deps" = "Xyes" ; then
2540a966c04fSmrg	      case "$tmp_libs " in
2541a966c04fSmrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2542a966c04fSmrg	      esac
2543a966c04fSmrg	    fi
2544a966c04fSmrg	    tmp_libs="$tmp_libs $deplib"
2545a966c04fSmrg	  done # for deplib
2546a966c04fSmrg	  continue
2547a966c04fSmrg	fi # $linkmode = prog...
2548a966c04fSmrg
2549a966c04fSmrg	if test "$linkmode,$pass" = "prog,link"; then
2550a966c04fSmrg	  if test -n "$library_names" &&
25512e2dd055Smrg	     { { test "$prefer_static_libs" = no ||
25522e2dd055Smrg		 test "$prefer_static_libs,$installed" = "built,yes"; } ||
25532e2dd055Smrg	       test -z "$old_library"; }; then
2554a966c04fSmrg	    # We need to hardcode the library path
2555a966c04fSmrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
2556a966c04fSmrg	      # Make sure the rpath contains only unique directories.
2557a966c04fSmrg	      case "$temp_rpath " in
2558a966c04fSmrg	      *" $dir "*) ;;
2559a966c04fSmrg	      *" $absdir "*) ;;
2560a966c04fSmrg	      *) temp_rpath="$temp_rpath $absdir" ;;
2561a966c04fSmrg	      esac
2562a966c04fSmrg	    fi
2563a966c04fSmrg
2564a966c04fSmrg	    # Hardcode the library path.
2565a966c04fSmrg	    # Skip directories that are in the system default run-time
2566a966c04fSmrg	    # search path.
2567a966c04fSmrg	    case " $sys_lib_dlsearch_path " in
2568a966c04fSmrg	    *" $absdir "*) ;;
2569a966c04fSmrg	    *)
2570a966c04fSmrg	      case "$compile_rpath " in
2571a966c04fSmrg	      *" $absdir "*) ;;
2572a966c04fSmrg	      *) compile_rpath="$compile_rpath $absdir"
2573a966c04fSmrg	      esac
2574a966c04fSmrg	      ;;
2575a966c04fSmrg	    esac
2576a966c04fSmrg	    case " $sys_lib_dlsearch_path " in
2577a966c04fSmrg	    *" $libdir "*) ;;
2578a966c04fSmrg	    *)
2579a966c04fSmrg	      case "$finalize_rpath " in
2580a966c04fSmrg	      *" $libdir "*) ;;
2581a966c04fSmrg	      *) finalize_rpath="$finalize_rpath $libdir"
2582a966c04fSmrg	      esac
2583a966c04fSmrg	      ;;
2584a966c04fSmrg	    esac
2585a966c04fSmrg	  fi # $linkmode,$pass = prog,link...
2586a966c04fSmrg
2587a966c04fSmrg	  if test "$alldeplibs" = yes &&
2588a966c04fSmrg	     { test "$deplibs_check_method" = pass_all ||
2589a966c04fSmrg	       { test "$build_libtool_libs" = yes &&
2590a966c04fSmrg		 test -n "$library_names"; }; }; then
2591a966c04fSmrg	    # We only need to search for static libraries
2592a966c04fSmrg	    continue
2593a966c04fSmrg	  fi
2594a966c04fSmrg	fi
2595a966c04fSmrg
2596a966c04fSmrg	link_static=no # Whether the deplib will be linked statically
2597a966c04fSmrg	use_static_libs=$prefer_static_libs
2598a966c04fSmrg	if test "$use_static_libs" = built && test "$installed" = yes ; then
2599a966c04fSmrg	  use_static_libs=no
2600a966c04fSmrg	fi
2601a966c04fSmrg	if test -n "$library_names" &&
2602a966c04fSmrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
2603a966c04fSmrg	  if test "$installed" = no; then
2604a966c04fSmrg	    notinst_deplibs="$notinst_deplibs $lib"
2605a966c04fSmrg	    need_relink=yes
2606a966c04fSmrg	  fi
2607a966c04fSmrg	  # This is a shared library
2608a966c04fSmrg
2609a966c04fSmrg	  # Warn about portability, can't link against -module's on
2610a966c04fSmrg	  # some systems (darwin)
2611a966c04fSmrg	  if test "$shouldnotlink" = yes && test "$pass" = link ; then
2612a966c04fSmrg	    $echo
2613a966c04fSmrg	    if test "$linkmode" = prog; then
2614a966c04fSmrg	      $echo "*** Warning: Linking the executable $output against the loadable module"
2615a966c04fSmrg	    else
2616a966c04fSmrg	      $echo "*** Warning: Linking the shared library $output against the loadable module"
2617a966c04fSmrg	    fi
2618a966c04fSmrg	    $echo "*** $linklib is not portable!"
2619a966c04fSmrg	  fi
2620a966c04fSmrg	  if test "$linkmode" = lib &&
2621a966c04fSmrg	     test "$hardcode_into_libs" = yes; then
2622a966c04fSmrg	    # Hardcode the library path.
2623a966c04fSmrg	    # Skip directories that are in the system default run-time
2624a966c04fSmrg	    # search path.
2625a966c04fSmrg	    case " $sys_lib_dlsearch_path " in
2626a966c04fSmrg	    *" $absdir "*) ;;
2627a966c04fSmrg	    *)
2628a966c04fSmrg	      case "$compile_rpath " in
2629a966c04fSmrg	      *" $absdir "*) ;;
2630a966c04fSmrg	      *) compile_rpath="$compile_rpath $absdir"
2631a966c04fSmrg	      esac
2632a966c04fSmrg	      ;;
2633a966c04fSmrg	    esac
2634a966c04fSmrg	    case " $sys_lib_dlsearch_path " in
2635a966c04fSmrg	    *" $libdir "*) ;;
2636a966c04fSmrg	    *)
2637a966c04fSmrg	      case "$finalize_rpath " in
2638a966c04fSmrg	      *" $libdir "*) ;;
2639a966c04fSmrg	      *) finalize_rpath="$finalize_rpath $libdir"
2640a966c04fSmrg	      esac
2641a966c04fSmrg	      ;;
2642a966c04fSmrg	    esac
2643a966c04fSmrg	  fi
2644a966c04fSmrg
2645a966c04fSmrg	  if test -n "$old_archive_from_expsyms_cmds"; then
2646a966c04fSmrg	    # figure out the soname
2647a966c04fSmrg	    set dummy $library_names
2648a966c04fSmrg	    realname="$2"
2649a966c04fSmrg	    shift; shift
2650a966c04fSmrg	    libname=`eval \\$echo \"$libname_spec\"`
2651a966c04fSmrg	    # use dlname if we got it. it's perfectly good, no?
2652a966c04fSmrg	    if test -n "$dlname"; then
2653a966c04fSmrg	      soname="$dlname"
2654a966c04fSmrg	    elif test -n "$soname_spec"; then
2655a966c04fSmrg	      # bleh windows
2656a966c04fSmrg	      case $host in
2657a966c04fSmrg	      *cygwin* | mingw*)
2658a966c04fSmrg		major=`expr $current - $age`
2659a966c04fSmrg		versuffix="-$major"
2660a966c04fSmrg		;;
2661a966c04fSmrg	      esac
2662a966c04fSmrg	      eval soname=\"$soname_spec\"
2663a966c04fSmrg	    else
2664a966c04fSmrg	      soname="$realname"
2665a966c04fSmrg	    fi
2666a966c04fSmrg
2667a966c04fSmrg	    # Make a new name for the extract_expsyms_cmds to use
2668a966c04fSmrg	    soroot="$soname"
2669a966c04fSmrg	    soname=`$echo $soroot | ${SED} -e 's/^.*\///'`
2670a966c04fSmrg	    newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
2671a966c04fSmrg
2672a966c04fSmrg	    # If the library has no export list, then create one now
2673a966c04fSmrg	    if test -f "$output_objdir/$soname-def"; then :
2674a966c04fSmrg	    else
2675a966c04fSmrg	      $show "extracting exported symbol list from \`$soname'"
2676a966c04fSmrg	      save_ifs="$IFS"; IFS='~'
2677a966c04fSmrg	      cmds=$extract_expsyms_cmds
2678a966c04fSmrg	      for cmd in $cmds; do
2679a966c04fSmrg		IFS="$save_ifs"
2680a966c04fSmrg		eval cmd=\"$cmd\"
2681a966c04fSmrg		$show "$cmd"
2682a966c04fSmrg		$run eval "$cmd" || exit $?
2683a966c04fSmrg	      done
2684a966c04fSmrg	      IFS="$save_ifs"
2685a966c04fSmrg	    fi
2686a966c04fSmrg
2687a966c04fSmrg	    # Create $newlib
2688a966c04fSmrg	    if test -f "$output_objdir/$newlib"; then :; else
2689a966c04fSmrg	      $show "generating import library for \`$soname'"
2690a966c04fSmrg	      save_ifs="$IFS"; IFS='~'
2691a966c04fSmrg	      cmds=$old_archive_from_expsyms_cmds
2692a966c04fSmrg	      for cmd in $cmds; do
2693a966c04fSmrg		IFS="$save_ifs"
2694a966c04fSmrg		eval cmd=\"$cmd\"
2695a966c04fSmrg		$show "$cmd"
2696a966c04fSmrg		$run eval "$cmd" || exit $?
2697a966c04fSmrg	      done
2698a966c04fSmrg	      IFS="$save_ifs"
2699a966c04fSmrg	    fi
2700a966c04fSmrg	    # make sure the library variables are pointing to the new library
2701a966c04fSmrg	    dir=$output_objdir
2702a966c04fSmrg	    linklib=$newlib
2703a966c04fSmrg	  fi # test -n "$old_archive_from_expsyms_cmds"
2704a966c04fSmrg
2705a966c04fSmrg	  if test "$linkmode" = prog || test "$mode" != relink; then
2706a966c04fSmrg	    add_shlibpath=
2707a966c04fSmrg	    add_dir=
2708a966c04fSmrg	    add=
2709a966c04fSmrg	    lib_linked=yes
2710a966c04fSmrg	    case $hardcode_action in
2711a966c04fSmrg	    immediate | unsupported)
2712a966c04fSmrg	      if test "$hardcode_direct" = no; then
2713a966c04fSmrg		add="$dir/$linklib"
2714a966c04fSmrg		case $host in
2715a966c04fSmrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
2716a966c04fSmrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
2717a966c04fSmrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
2718a966c04fSmrg		    *-*-unixware7*) add_dir="-L$dir" ;;
2719a966c04fSmrg		  *-*-darwin* )
2720a966c04fSmrg		    # if the lib is a module then we can not link against
2721a966c04fSmrg		    # it, someone is ignoring the new warnings I added
2722a966c04fSmrg		    if /usr/bin/file -L $add 2> /dev/null |
2723a966c04fSmrg                      $EGREP ": [^:]* bundle" >/dev/null ; then
2724a966c04fSmrg		      $echo "** Warning, lib $linklib is a module, not a shared library"
2725a966c04fSmrg		      if test -z "$old_library" ; then
2726a966c04fSmrg		        $echo
2727a966c04fSmrg		        $echo "** And there doesn't seem to be a static archive available"
2728a966c04fSmrg		        $echo "** The link will probably fail, sorry"
2729a966c04fSmrg		      else
2730a966c04fSmrg		        add="$dir/$old_library"
2731a966c04fSmrg		      fi
2732a966c04fSmrg		    fi
2733a966c04fSmrg		esac
2734a966c04fSmrg	      elif test "$hardcode_minus_L" = no; then
2735a966c04fSmrg		case $host in
2736a966c04fSmrg		*-*-sunos*) add_shlibpath="$dir" ;;
2737a966c04fSmrg		esac
2738a966c04fSmrg		add_dir="-L$dir"
2739a966c04fSmrg		add="-l$name"
2740a966c04fSmrg	      elif test "$hardcode_shlibpath_var" = no; then
2741a966c04fSmrg		add_shlibpath="$dir"
2742a966c04fSmrg		add="-l$name"
2743a966c04fSmrg	      else
2744a966c04fSmrg		lib_linked=no
2745a966c04fSmrg	      fi
2746a966c04fSmrg	      ;;
2747a966c04fSmrg	    relink)
2748a966c04fSmrg	      if test "$hardcode_direct" = yes; then
2749a966c04fSmrg		add="$dir/$linklib"
2750a966c04fSmrg	      elif test "$hardcode_minus_L" = yes; then
2751a966c04fSmrg		add_dir="-L$dir"
2752a966c04fSmrg		# Try looking first in the location we're being installed to.
2753a966c04fSmrg		if test -n "$inst_prefix_dir"; then
2754a966c04fSmrg		  case $libdir in
2755a966c04fSmrg		    [\\/]*)
2756a966c04fSmrg		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
2757a966c04fSmrg		      ;;
2758a966c04fSmrg		  esac
2759a966c04fSmrg		fi
2760a966c04fSmrg		add="-l$name"
2761a966c04fSmrg	      elif test "$hardcode_shlibpath_var" = yes; then
2762a966c04fSmrg		add_shlibpath="$dir"
2763a966c04fSmrg		add="-l$name"
2764a966c04fSmrg	      else
2765a966c04fSmrg		lib_linked=no
2766a966c04fSmrg	      fi
2767a966c04fSmrg	      ;;
2768a966c04fSmrg	    *) lib_linked=no ;;
2769a966c04fSmrg	    esac
2770a966c04fSmrg
2771a966c04fSmrg	    if test "$lib_linked" != yes; then
2772a966c04fSmrg	      $echo "$modename: configuration error: unsupported hardcode properties"
2773a966c04fSmrg	      exit $EXIT_FAILURE
2774a966c04fSmrg	    fi
2775a966c04fSmrg
2776a966c04fSmrg	    if test -n "$add_shlibpath"; then
2777a966c04fSmrg	      case :$compile_shlibpath: in
2778a966c04fSmrg	      *":$add_shlibpath:"*) ;;
2779a966c04fSmrg	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
2780a966c04fSmrg	      esac
2781a966c04fSmrg	    fi
2782a966c04fSmrg	    if test "$linkmode" = prog; then
2783a966c04fSmrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
2784a966c04fSmrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
2785a966c04fSmrg	    else
2786a966c04fSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
2787a966c04fSmrg	      test -n "$add" && deplibs="$add $deplibs"
2788a966c04fSmrg	      if test "$hardcode_direct" != yes && \
2789a966c04fSmrg		 test "$hardcode_minus_L" != yes && \
2790a966c04fSmrg		 test "$hardcode_shlibpath_var" = yes; then
2791a966c04fSmrg		case :$finalize_shlibpath: in
2792a966c04fSmrg		*":$libdir:"*) ;;
2793a966c04fSmrg		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
2794a966c04fSmrg		esac
2795a966c04fSmrg	      fi
2796a966c04fSmrg	    fi
2797a966c04fSmrg	  fi
2798a966c04fSmrg
2799a966c04fSmrg	  if test "$linkmode" = prog || test "$mode" = relink; then
2800a966c04fSmrg	    add_shlibpath=
2801a966c04fSmrg	    add_dir=
2802a966c04fSmrg	    add=
2803a966c04fSmrg	    # Finalize command for both is simple: just hardcode it.
2804a966c04fSmrg	    if test "$hardcode_direct" = yes; then
2805a966c04fSmrg	      add="$libdir/$linklib"
2806a966c04fSmrg	    elif test "$hardcode_minus_L" = yes; then
2807a966c04fSmrg	      add_dir="-L$libdir"
2808a966c04fSmrg	      add="-l$name"
2809a966c04fSmrg	    elif test "$hardcode_shlibpath_var" = yes; then
2810a966c04fSmrg	      case :$finalize_shlibpath: in
2811a966c04fSmrg	      *":$libdir:"*) ;;
2812a966c04fSmrg	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
2813a966c04fSmrg	      esac
2814a966c04fSmrg	      add="-l$name"
2815a966c04fSmrg	    elif test "$hardcode_automatic" = yes; then
2816a966c04fSmrg	      if test -n "$inst_prefix_dir" &&
2817a966c04fSmrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
2818a966c04fSmrg	        add="$inst_prefix_dir$libdir/$linklib"
2819a966c04fSmrg	      else
2820a966c04fSmrg	        add="$libdir/$linklib"
2821a966c04fSmrg	      fi
2822a966c04fSmrg	    else
2823a966c04fSmrg	      # We cannot seem to hardcode it, guess we'll fake it.
2824a966c04fSmrg	      add_dir="-L$libdir"
2825a966c04fSmrg	      # Try looking first in the location we're being installed to.
2826a966c04fSmrg	      if test -n "$inst_prefix_dir"; then
2827a966c04fSmrg		case $libdir in
2828a966c04fSmrg		  [\\/]*)
2829a966c04fSmrg		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
2830a966c04fSmrg		    ;;
2831a966c04fSmrg		esac
2832a966c04fSmrg	      fi
2833a966c04fSmrg	      add="-l$name"
2834a966c04fSmrg	    fi
2835a966c04fSmrg
2836a966c04fSmrg	    if test "$linkmode" = prog; then
2837a966c04fSmrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
2838a966c04fSmrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
2839a966c04fSmrg	    else
2840a966c04fSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
2841a966c04fSmrg	      test -n "$add" && deplibs="$add $deplibs"
2842a966c04fSmrg	    fi
2843a966c04fSmrg	  fi
2844a966c04fSmrg	elif test "$linkmode" = prog; then
2845a966c04fSmrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
2846a966c04fSmrg	  # is not unsupported.  This is valid on all known static and
2847a966c04fSmrg	  # shared platforms.
2848a966c04fSmrg	  if test "$hardcode_direct" != unsupported; then
2849a966c04fSmrg	    test -n "$old_library" && linklib="$old_library"
2850a966c04fSmrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
2851a966c04fSmrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
2852a966c04fSmrg	  else
2853a966c04fSmrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
2854a966c04fSmrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
2855a966c04fSmrg	  fi
2856a966c04fSmrg	elif test "$build_libtool_libs" = yes; then
2857a966c04fSmrg	  # Not a shared library
2858a966c04fSmrg	  if test "$deplibs_check_method" != pass_all; then
2859a966c04fSmrg	    # We're trying link a shared library against a static one
2860a966c04fSmrg	    # but the system doesn't support it.
2861a966c04fSmrg
2862a966c04fSmrg	    # Just print a warning and add the library to dependency_libs so
2863a966c04fSmrg	    # that the program can be linked against the static library.
2864a966c04fSmrg	    $echo
2865a966c04fSmrg	    $echo "*** Warning: This system can not link to static lib archive $lib."
2866a966c04fSmrg	    $echo "*** I have the capability to make that library automatically link in when"
2867a966c04fSmrg	    $echo "*** you link to this library.  But I can only do this if you have a"
2868a966c04fSmrg	    $echo "*** shared version of the library, which you do not appear to have."
2869a966c04fSmrg	    if test "$module" = yes; then
2870a966c04fSmrg	      $echo "*** But as you try to build a module library, libtool will still create "
2871a966c04fSmrg	      $echo "*** a static module, that should work as long as the dlopening application"
2872a966c04fSmrg	      $echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
2873a966c04fSmrg	      if test -z "$global_symbol_pipe"; then
2874a966c04fSmrg		$echo
2875a966c04fSmrg		$echo "*** However, this would only work if libtool was able to extract symbol"
2876a966c04fSmrg		$echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
2877a966c04fSmrg		$echo "*** not find such a program.  So, this module is probably useless."
2878a966c04fSmrg		$echo "*** \`nm' from GNU binutils and a full rebuild may help."
2879a966c04fSmrg	      fi
2880a966c04fSmrg	      if test "$build_old_libs" = no; then
2881a966c04fSmrg		build_libtool_libs=module
2882a966c04fSmrg		build_old_libs=yes
2883a966c04fSmrg	      else
2884a966c04fSmrg		build_libtool_libs=no
2885a966c04fSmrg	      fi
2886a966c04fSmrg	    fi
2887a966c04fSmrg	  else
2888a966c04fSmrg	    deplibs="$dir/$old_library $deplibs"
2889a966c04fSmrg	    link_static=yes
2890a966c04fSmrg	  fi
2891a966c04fSmrg	fi # link shared/static library?
2892a966c04fSmrg
2893a966c04fSmrg	if test "$linkmode" = lib; then
2894a966c04fSmrg	  if test -n "$dependency_libs" &&
2895a966c04fSmrg	     { test "$hardcode_into_libs" != yes ||
2896a966c04fSmrg	       test "$build_old_libs" = yes ||
2897a966c04fSmrg	       test "$link_static" = yes; }; then
2898a966c04fSmrg	    # Extract -R from dependency_libs
2899a966c04fSmrg	    temp_deplibs=
2900a966c04fSmrg	    for libdir in $dependency_libs; do
2901a966c04fSmrg	      case $libdir in
2902a966c04fSmrg	      -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'`
2903a966c04fSmrg		   case " $xrpath " in
2904a966c04fSmrg		   *" $temp_xrpath "*) ;;
2905a966c04fSmrg		   *) xrpath="$xrpath $temp_xrpath";;
2906a966c04fSmrg		   esac;;
2907a966c04fSmrg	      *) temp_deplibs="$temp_deplibs $libdir";;
2908a966c04fSmrg	      esac
2909a966c04fSmrg	    done
2910a966c04fSmrg	    dependency_libs="$temp_deplibs"
2911a966c04fSmrg	  fi
2912a966c04fSmrg
2913a966c04fSmrg	  newlib_search_path="$newlib_search_path $absdir"
2914a966c04fSmrg	  # Link against this library
2915a966c04fSmrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
2916a966c04fSmrg	  # ... and its dependency_libs
2917a966c04fSmrg	  tmp_libs=
2918a966c04fSmrg	  for deplib in $dependency_libs; do
2919a966c04fSmrg	    newdependency_libs="$deplib $newdependency_libs"
2920a966c04fSmrg	    if test "X$duplicate_deps" = "Xyes" ; then
2921a966c04fSmrg	      case "$tmp_libs " in
2922a966c04fSmrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2923a966c04fSmrg	      esac
2924a966c04fSmrg	    fi
2925a966c04fSmrg	    tmp_libs="$tmp_libs $deplib"
2926a966c04fSmrg	  done
2927a966c04fSmrg
2928a966c04fSmrg	  if test "$link_all_deplibs" != no; then
2929a966c04fSmrg	    # Add the search paths of all dependency libraries
2930a966c04fSmrg	    for deplib in $dependency_libs; do
2931a966c04fSmrg	      case $deplib in
2932a966c04fSmrg	      -L*) path="$deplib" ;;
2933a966c04fSmrg	      *.la)
2934a966c04fSmrg		dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
2935a966c04fSmrg		test "X$dir" = "X$deplib" && dir="."
2936a966c04fSmrg		# We need an absolute path.
2937a966c04fSmrg		case $dir in
2938a966c04fSmrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
2939a966c04fSmrg		*)
2940a966c04fSmrg		  absdir=`cd "$dir" && pwd`
2941a966c04fSmrg		  if test -z "$absdir"; then
2942a966c04fSmrg		    $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
2943a966c04fSmrg		    absdir="$dir"
2944a966c04fSmrg		  fi
2945a966c04fSmrg		  ;;
2946a966c04fSmrg		esac
2947a966c04fSmrg		if grep "^installed=no" $deplib > /dev/null; then
2948a966c04fSmrg		  path="$absdir/$objdir"
2949a966c04fSmrg		else
2950a966c04fSmrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
2951a966c04fSmrg		  if test -z "$libdir"; then
2952a966c04fSmrg		    $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
2953a966c04fSmrg		    exit $EXIT_FAILURE
2954a966c04fSmrg		  fi
2955a966c04fSmrg		  if test "$absdir" != "$libdir"; then
2956a966c04fSmrg		    $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
2957a966c04fSmrg		  fi
2958a966c04fSmrg		  path="$absdir"
2959a966c04fSmrg		fi
2960a966c04fSmrg		depdepl=
2961a966c04fSmrg		case $host in
2962a966c04fSmrg		*-*-darwin*)
2963a966c04fSmrg		  # we do not want to link against static libs,
2964a966c04fSmrg		  # but need to link against shared
2965a966c04fSmrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
29662e2dd055Smrg		  eval deplibdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
2967a966c04fSmrg		  if test -n "$deplibrary_names" ; then
2968a966c04fSmrg		    for tmp in $deplibrary_names ; do
2969a966c04fSmrg		      depdepl=$tmp
2970a966c04fSmrg		    done
29712e2dd055Smrg		    if test -f "$deplibdir/$depdepl" ; then
29722e2dd055Smrg		      depdepl="$deplibdir/$depdepl"
29732e2dd055Smrg	      	    elif test -f "$path/$depdepl" ; then
2974a966c04fSmrg		      depdepl="$path/$depdepl"
29752e2dd055Smrg		    else
29762e2dd055Smrg		      # Can't find it, oh well...
29772e2dd055Smrg		      depdepl=
2978a966c04fSmrg		    fi
2979a966c04fSmrg		    # do not add paths which are already there
2980a966c04fSmrg		    case " $newlib_search_path " in
2981a966c04fSmrg		    *" $path "*) ;;
2982a966c04fSmrg		    *) newlib_search_path="$newlib_search_path $path";;
2983a966c04fSmrg		    esac
2984a966c04fSmrg		  fi
2985a966c04fSmrg		  path=""
2986a966c04fSmrg		  ;;
2987a966c04fSmrg		*)
2988a966c04fSmrg		  path="-L$path"
2989a966c04fSmrg		  ;;
2990a966c04fSmrg		esac
2991a966c04fSmrg		;;
2992a966c04fSmrg	      -l*)
2993a966c04fSmrg		case $host in
2994a966c04fSmrg		*-*-darwin*)
2995a966c04fSmrg		  # Again, we only want to link against shared libraries
2996a966c04fSmrg		  eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
2997a966c04fSmrg		  for tmp in $newlib_search_path ; do
2998a966c04fSmrg		    if test -f "$tmp/lib$tmp_libs.dylib" ; then
2999a966c04fSmrg		      eval depdepl="$tmp/lib$tmp_libs.dylib"
3000a966c04fSmrg		      break
3001a966c04fSmrg		    fi
3002a966c04fSmrg		  done
3003a966c04fSmrg		  path=""
3004a966c04fSmrg		  ;;
3005a966c04fSmrg		*) continue ;;
3006a966c04fSmrg		esac
3007a966c04fSmrg		;;
3008a966c04fSmrg	      *) continue ;;
3009a966c04fSmrg	      esac
3010a966c04fSmrg	      case " $deplibs " in
3011a966c04fSmrg	      *" $path "*) ;;
3012a966c04fSmrg	      *) deplibs="$path $deplibs" ;;
3013a966c04fSmrg	      esac
3014a966c04fSmrg	      case " $deplibs " in
3015a966c04fSmrg	      *" $depdepl "*) ;;
3016a966c04fSmrg	      *) deplibs="$depdepl $deplibs" ;;
3017a966c04fSmrg	      esac
3018a966c04fSmrg	    done
3019a966c04fSmrg	  fi # link_all_deplibs != no
3020a966c04fSmrg	fi # linkmode = lib
3021a966c04fSmrg      done # for deplib in $libs
3022a966c04fSmrg      dependency_libs="$newdependency_libs"
3023a966c04fSmrg      if test "$pass" = dlpreopen; then
3024a966c04fSmrg	# Link the dlpreopened libraries before other libraries
3025a966c04fSmrg	for deplib in $save_deplibs; do
3026a966c04fSmrg	  deplibs="$deplib $deplibs"
3027a966c04fSmrg	done
3028a966c04fSmrg      fi
3029a966c04fSmrg      if test "$pass" != dlopen; then
3030a966c04fSmrg	if test "$pass" != conv; then
3031a966c04fSmrg	  # Make sure lib_search_path contains only unique directories.
3032a966c04fSmrg	  lib_search_path=
3033a966c04fSmrg	  for dir in $newlib_search_path; do
3034a966c04fSmrg	    case "$lib_search_path " in
3035a966c04fSmrg	    *" $dir "*) ;;
3036a966c04fSmrg	    *) lib_search_path="$lib_search_path $dir" ;;
3037a966c04fSmrg	    esac
3038a966c04fSmrg	  done
3039a966c04fSmrg	  newlib_search_path=
3040a966c04fSmrg	fi
3041a966c04fSmrg
3042a966c04fSmrg	if test "$linkmode,$pass" != "prog,link"; then
3043a966c04fSmrg	  vars="deplibs"
3044a966c04fSmrg	else
3045a966c04fSmrg	  vars="compile_deplibs finalize_deplibs"
3046a966c04fSmrg	fi
3047a966c04fSmrg	for var in $vars dependency_libs; do
3048a966c04fSmrg	  # Add libraries to $var in reverse order
3049a966c04fSmrg	  eval tmp_libs=\"\$$var\"
3050a966c04fSmrg	  new_libs=
3051a966c04fSmrg	  for deplib in $tmp_libs; do
3052a966c04fSmrg	    # FIXME: Pedantically, this is the right thing to do, so
3053a966c04fSmrg	    #        that some nasty dependency loop isn't accidentally
3054a966c04fSmrg	    #        broken:
3055a966c04fSmrg	    #new_libs="$deplib $new_libs"
3056a966c04fSmrg	    # Pragmatically, this seems to cause very few problems in
3057a966c04fSmrg	    # practice:
3058a966c04fSmrg	    case $deplib in
3059a966c04fSmrg	    -L*) new_libs="$deplib $new_libs" ;;
3060a966c04fSmrg	    -R*) ;;
3061a966c04fSmrg	    *)
3062a966c04fSmrg	      # And here is the reason: when a library appears more
3063a966c04fSmrg	      # than once as an explicit dependence of a library, or
3064a966c04fSmrg	      # is implicitly linked in more than once by the
3065a966c04fSmrg	      # compiler, it is considered special, and multiple
3066a966c04fSmrg	      # occurrences thereof are not removed.  Compare this
3067a966c04fSmrg	      # with having the same library being listed as a
3068a966c04fSmrg	      # dependency of multiple other libraries: in this case,
3069a966c04fSmrg	      # we know (pedantically, we assume) the library does not
3070a966c04fSmrg	      # need to be listed more than once, so we keep only the
3071a966c04fSmrg	      # last copy.  This is not always right, but it is rare
3072a966c04fSmrg	      # enough that we require users that really mean to play
3073a966c04fSmrg	      # such unportable linking tricks to link the library
3074a966c04fSmrg	      # using -Wl,-lname, so that libtool does not consider it
3075a966c04fSmrg	      # for duplicate removal.
3076a966c04fSmrg	      case " $specialdeplibs " in
3077a966c04fSmrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
3078a966c04fSmrg	      *)
3079a966c04fSmrg		case " $new_libs " in
3080a966c04fSmrg		*" $deplib "*) ;;
3081a966c04fSmrg		*) new_libs="$deplib $new_libs" ;;
3082a966c04fSmrg		esac
3083a966c04fSmrg		;;
3084a966c04fSmrg	      esac
3085a966c04fSmrg	      ;;
3086a966c04fSmrg	    esac
3087a966c04fSmrg	  done
3088a966c04fSmrg	  tmp_libs=
3089a966c04fSmrg	  for deplib in $new_libs; do
3090a966c04fSmrg	    case $deplib in
3091a966c04fSmrg	    -L*)
3092a966c04fSmrg	      case " $tmp_libs " in
3093a966c04fSmrg	      *" $deplib "*) ;;
3094a966c04fSmrg	      *) tmp_libs="$tmp_libs $deplib" ;;
3095a966c04fSmrg	      esac
3096a966c04fSmrg	      ;;
3097a966c04fSmrg	    *) tmp_libs="$tmp_libs $deplib" ;;
3098a966c04fSmrg	    esac
3099a966c04fSmrg	  done
3100a966c04fSmrg	  eval $var=\"$tmp_libs\"
3101a966c04fSmrg	done # for var
3102a966c04fSmrg      fi
3103a966c04fSmrg      # Last step: remove runtime libs from dependency_libs
3104a966c04fSmrg      # (they stay in deplibs)
3105a966c04fSmrg      tmp_libs=
3106a966c04fSmrg      for i in $dependency_libs ; do
3107a966c04fSmrg	case " $predeps $postdeps $compiler_lib_search_path " in
3108a966c04fSmrg	*" $i "*)
3109a966c04fSmrg	  i=""
3110a966c04fSmrg	  ;;
3111a966c04fSmrg	esac
3112a966c04fSmrg	if test -n "$i" ; then
3113a966c04fSmrg	  tmp_libs="$tmp_libs $i"
3114a966c04fSmrg	fi
3115a966c04fSmrg      done
3116a966c04fSmrg      dependency_libs=$tmp_libs
3117a966c04fSmrg    done # for pass
3118a966c04fSmrg    if test "$linkmode" = prog; then
3119a966c04fSmrg      dlfiles="$newdlfiles"
3120a966c04fSmrg      dlprefiles="$newdlprefiles"
3121a966c04fSmrg    fi
3122a966c04fSmrg
3123a966c04fSmrg    case $linkmode in
3124a966c04fSmrg    oldlib)
31252e2dd055Smrg      case " $deplibs" in
31262e2dd055Smrg      *\ -l* | *\ -L*)
31272e2dd055Smrg	$echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2 ;;
31282e2dd055Smrg      esac
3129a966c04fSmrg
3130a966c04fSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
3131a966c04fSmrg	$echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
3132a966c04fSmrg      fi
3133a966c04fSmrg
3134a966c04fSmrg      if test -n "$rpath"; then
3135a966c04fSmrg	$echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
3136a966c04fSmrg      fi
3137a966c04fSmrg
3138a966c04fSmrg      if test -n "$xrpath"; then
3139a966c04fSmrg	$echo "$modename: warning: \`-R' is ignored for archives" 1>&2
3140a966c04fSmrg      fi
3141a966c04fSmrg
3142a966c04fSmrg      if test -n "$vinfo"; then
3143a966c04fSmrg	$echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2
3144a966c04fSmrg      fi
3145a966c04fSmrg
3146a966c04fSmrg      if test -n "$release"; then
3147a966c04fSmrg	$echo "$modename: warning: \`-release' is ignored for archives" 1>&2
3148a966c04fSmrg      fi
3149a966c04fSmrg
3150a966c04fSmrg      if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
3151a966c04fSmrg	$echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
3152a966c04fSmrg      fi
3153a966c04fSmrg
3154a966c04fSmrg      # Now set the variables for building old libraries.
3155a966c04fSmrg      build_libtool_libs=no
3156a966c04fSmrg      oldlibs="$output"
3157a966c04fSmrg      objs="$objs$old_deplibs"
3158a966c04fSmrg      ;;
3159a966c04fSmrg
3160a966c04fSmrg    lib)
3161a966c04fSmrg      # Make sure we only generate libraries of the form `libNAME.la'.
3162a966c04fSmrg      case $outputname in
3163a966c04fSmrg      lib*)
3164a966c04fSmrg	name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
3165a966c04fSmrg	eval shared_ext=\"$shrext_cmds\"
3166a966c04fSmrg	eval libname=\"$libname_spec\"
3167a966c04fSmrg	;;
3168a966c04fSmrg      *)
3169a966c04fSmrg	if test "$module" = no; then
3170a966c04fSmrg	  $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
3171a966c04fSmrg	  $echo "$help" 1>&2
3172a966c04fSmrg	  exit $EXIT_FAILURE
3173a966c04fSmrg	fi
3174a966c04fSmrg	if test "$need_lib_prefix" != no; then
3175a966c04fSmrg	  # Add the "lib" prefix for modules if required
3176a966c04fSmrg	  name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
3177a966c04fSmrg	  eval shared_ext=\"$shrext_cmds\"
3178a966c04fSmrg	  eval libname=\"$libname_spec\"
3179a966c04fSmrg	else
3180a966c04fSmrg	  libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
3181a966c04fSmrg	fi
3182a966c04fSmrg	;;
3183a966c04fSmrg      esac
3184a966c04fSmrg
3185a966c04fSmrg      if test -n "$objs"; then
3186a966c04fSmrg	if test "$deplibs_check_method" != pass_all; then
3187a966c04fSmrg	  $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
3188a966c04fSmrg	  exit $EXIT_FAILURE
3189a966c04fSmrg	else
3190a966c04fSmrg	  $echo
3191a966c04fSmrg	  $echo "*** Warning: Linking the shared library $output against the non-libtool"
3192a966c04fSmrg	  $echo "*** objects $objs is not portable!"
3193a966c04fSmrg	  libobjs="$libobjs $objs"
3194a966c04fSmrg	fi
3195a966c04fSmrg      fi
3196a966c04fSmrg
3197a966c04fSmrg      if test "$dlself" != no; then
3198a966c04fSmrg	$echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2
3199a966c04fSmrg      fi
3200a966c04fSmrg
3201a966c04fSmrg      set dummy $rpath
3202a966c04fSmrg      if test "$#" -gt 2; then
3203a966c04fSmrg	$echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
3204a966c04fSmrg      fi
3205a966c04fSmrg      install_libdir="$2"
3206a966c04fSmrg
3207a966c04fSmrg      oldlibs=
3208a966c04fSmrg      if test -z "$rpath"; then
3209a966c04fSmrg	if test "$build_libtool_libs" = yes; then
3210a966c04fSmrg	  # Building a libtool convenience library.
3211a966c04fSmrg	  # Some compilers have problems with a `.al' extension so
3212a966c04fSmrg	  # convenience libraries should have the same extension an
3213a966c04fSmrg	  # archive normally would.
3214a966c04fSmrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
3215a966c04fSmrg	  build_libtool_libs=convenience
3216a966c04fSmrg	  build_old_libs=yes
3217a966c04fSmrg	fi
3218a966c04fSmrg
3219a966c04fSmrg	if test -n "$vinfo"; then
3220a966c04fSmrg	  $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2
3221a966c04fSmrg	fi
3222a966c04fSmrg
3223a966c04fSmrg	if test -n "$release"; then
3224a966c04fSmrg	  $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
3225a966c04fSmrg	fi
3226a966c04fSmrg      else
3227a966c04fSmrg
3228a966c04fSmrg	# Parse the version information argument.
3229a966c04fSmrg	save_ifs="$IFS"; IFS=':'
3230a966c04fSmrg	set dummy $vinfo 0 0 0
3231a966c04fSmrg	IFS="$save_ifs"
3232a966c04fSmrg
3233a966c04fSmrg	if test -n "$8"; then
3234a966c04fSmrg	  $echo "$modename: too many parameters to \`-version-info'" 1>&2
3235a966c04fSmrg	  $echo "$help" 1>&2
3236a966c04fSmrg	  exit $EXIT_FAILURE
3237a966c04fSmrg	fi
3238a966c04fSmrg
3239a966c04fSmrg	# convert absolute version numbers to libtool ages
3240a966c04fSmrg	# this retains compatibility with .la files and attempts
3241a966c04fSmrg	# to make the code below a bit more comprehensible
3242a966c04fSmrg
3243a966c04fSmrg	case $vinfo_number in
3244a966c04fSmrg	yes)
3245a966c04fSmrg	  number_major="$2"
3246a966c04fSmrg	  number_minor="$3"
3247a966c04fSmrg	  number_revision="$4"
3248a966c04fSmrg	  #
3249a966c04fSmrg	  # There are really only two kinds -- those that
3250a966c04fSmrg	  # use the current revision as the major version
3251a966c04fSmrg	  # and those that subtract age and use age as
3252a966c04fSmrg	  # a minor version.  But, then there is irix
3253a966c04fSmrg	  # which has an extra 1 added just for fun
3254a966c04fSmrg	  #
3255a966c04fSmrg	  case $version_type in
32562e2dd055Smrg	  darwin|linux|osf|windows|none)
3257a966c04fSmrg	    current=`expr $number_major + $number_minor`
3258a966c04fSmrg	    age="$number_minor"
3259a966c04fSmrg	    revision="$number_revision"
3260a966c04fSmrg	    ;;
3261a966c04fSmrg	  freebsd-aout|freebsd-elf|sunos)
3262a966c04fSmrg	    current="$number_major"
3263a966c04fSmrg	    revision="$number_minor"
3264a966c04fSmrg	    age="0"
3265a966c04fSmrg	    ;;
3266a966c04fSmrg	  irix|nonstopux)
32672e2dd055Smrg	    current=`expr $number_major + $number_minor`
3268a966c04fSmrg	    age="$number_minor"
3269a966c04fSmrg	    revision="$number_minor"
32702e2dd055Smrg	    lt_irix_increment=no
3271a966c04fSmrg	    ;;
3272a966c04fSmrg	  esac
3273a966c04fSmrg	  ;;
3274a966c04fSmrg	no)
3275a966c04fSmrg	  current="$2"
3276a966c04fSmrg	  revision="$3"
3277a966c04fSmrg	  age="$4"
3278a966c04fSmrg	  ;;
3279a966c04fSmrg	esac
3280a966c04fSmrg
3281a966c04fSmrg	# Check that each of the things are valid numbers.
3282a966c04fSmrg	case $current in
3283a966c04fSmrg	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]) ;;
3284a966c04fSmrg	*)
3285a966c04fSmrg	  $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2
3286a966c04fSmrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3287a966c04fSmrg	  exit $EXIT_FAILURE
3288a966c04fSmrg	  ;;
3289a966c04fSmrg	esac
3290a966c04fSmrg
3291a966c04fSmrg	case $revision in
3292a966c04fSmrg	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]) ;;
3293a966c04fSmrg	*)
3294a966c04fSmrg	  $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2
3295a966c04fSmrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3296a966c04fSmrg	  exit $EXIT_FAILURE
3297a966c04fSmrg	  ;;
3298a966c04fSmrg	esac
3299a966c04fSmrg
3300a966c04fSmrg	case $age in
3301a966c04fSmrg	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]) ;;
3302a966c04fSmrg	*)
3303a966c04fSmrg	  $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2
3304a966c04fSmrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3305a966c04fSmrg	  exit $EXIT_FAILURE
3306a966c04fSmrg	  ;;
3307a966c04fSmrg	esac
3308a966c04fSmrg
3309a966c04fSmrg	if test "$age" -gt "$current"; then
3310a966c04fSmrg	  $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
3311a966c04fSmrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3312a966c04fSmrg	  exit $EXIT_FAILURE
3313a966c04fSmrg	fi
3314a966c04fSmrg
3315a966c04fSmrg	# Calculate the version variables.
3316a966c04fSmrg	major=
3317a966c04fSmrg	versuffix=
3318a966c04fSmrg	verstring=
3319a966c04fSmrg	case $version_type in
3320a966c04fSmrg	none) ;;
3321a966c04fSmrg
3322a966c04fSmrg	darwin)
3323a966c04fSmrg	  # Like Linux, but with the current version available in
3324a966c04fSmrg	  # verstring for coding it into the library header
3325a966c04fSmrg	  major=.`expr $current - $age`
3326a966c04fSmrg	  versuffix="$major.$age.$revision"
3327a966c04fSmrg	  # Darwin ld doesn't like 0 for these options...
3328a966c04fSmrg	  minor_current=`expr $current + 1`
33292e2dd055Smrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
33302e2dd055Smrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
3331a966c04fSmrg	  ;;
3332a966c04fSmrg
3333a966c04fSmrg	freebsd-aout)
3334a966c04fSmrg	  major=".$current"
3335a966c04fSmrg	  versuffix=".$current.$revision";
3336a966c04fSmrg	  ;;
3337a966c04fSmrg
3338a966c04fSmrg	freebsd-elf)
3339a966c04fSmrg	  major=".$current"
3340a966c04fSmrg	  versuffix=".$current";
3341a966c04fSmrg	  ;;
3342a966c04fSmrg
3343a966c04fSmrg	irix | nonstopux)
33442e2dd055Smrg	  if test "X$lt_irix_increment" = "Xno"; then
33452e2dd055Smrg	    major=`expr $current - $age`
33462e2dd055Smrg	  else
33472e2dd055Smrg	    major=`expr $current - $age + 1`
33482e2dd055Smrg	  fi
3349a966c04fSmrg	  case $version_type in
3350a966c04fSmrg	    nonstopux) verstring_prefix=nonstopux ;;
3351a966c04fSmrg	    *)         verstring_prefix=sgi ;;
3352a966c04fSmrg	  esac
3353a966c04fSmrg	  verstring="$verstring_prefix$major.$revision"
3354a966c04fSmrg
3355a966c04fSmrg	  # Add in all the interfaces that we are compatible with.
3356a966c04fSmrg	  loop=$revision
3357a966c04fSmrg	  while test "$loop" -ne 0; do
3358a966c04fSmrg	    iface=`expr $revision - $loop`
3359a966c04fSmrg	    loop=`expr $loop - 1`
3360a966c04fSmrg	    verstring="$verstring_prefix$major.$iface:$verstring"
3361a966c04fSmrg	  done
3362a966c04fSmrg
3363a966c04fSmrg	  # Before this point, $major must not contain `.'.
3364a966c04fSmrg	  major=.$major
3365a966c04fSmrg	  versuffix="$major.$revision"
3366a966c04fSmrg	  ;;
3367a966c04fSmrg
3368a966c04fSmrg	linux)
3369a966c04fSmrg	  major=.`expr $current - $age`
3370a966c04fSmrg	  versuffix="$major.$age.$revision"
3371a966c04fSmrg	  ;;
3372a966c04fSmrg
3373a966c04fSmrg	osf)
3374a966c04fSmrg	  major=.`expr $current - $age`
3375a966c04fSmrg	  versuffix=".$current.$age.$revision"
3376a966c04fSmrg	  verstring="$current.$age.$revision"
3377a966c04fSmrg
3378a966c04fSmrg	  # Add in all the interfaces that we are compatible with.
3379a966c04fSmrg	  loop=$age
3380a966c04fSmrg	  while test "$loop" -ne 0; do
3381a966c04fSmrg	    iface=`expr $current - $loop`
3382a966c04fSmrg	    loop=`expr $loop - 1`
3383a966c04fSmrg	    verstring="$verstring:${iface}.0"
3384a966c04fSmrg	  done
3385a966c04fSmrg
3386a966c04fSmrg	  # Make executables depend on our current version.
3387a966c04fSmrg	  verstring="$verstring:${current}.0"
3388a966c04fSmrg	  ;;
3389a966c04fSmrg
3390a966c04fSmrg	sunos)
3391a966c04fSmrg	  major=".$current"
3392a966c04fSmrg	  versuffix=".$current.$revision"
3393a966c04fSmrg	  ;;
3394a966c04fSmrg
3395a966c04fSmrg	windows)
3396a966c04fSmrg	  # Use '-' rather than '.', since we only want one
3397a966c04fSmrg	  # extension on DOS 8.3 filesystems.
3398a966c04fSmrg	  major=`expr $current - $age`
3399a966c04fSmrg	  versuffix="-$major"
3400a966c04fSmrg	  ;;
3401a966c04fSmrg
3402a966c04fSmrg	*)
3403a966c04fSmrg	  $echo "$modename: unknown library version type \`$version_type'" 1>&2
3404a966c04fSmrg	  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
3405a966c04fSmrg	  exit $EXIT_FAILURE
3406a966c04fSmrg	  ;;
3407a966c04fSmrg	esac
3408a966c04fSmrg
3409a966c04fSmrg	# Clear the version info if we defaulted, and they specified a release.
3410a966c04fSmrg	if test -z "$vinfo" && test -n "$release"; then
3411a966c04fSmrg	  major=
3412a966c04fSmrg	  case $version_type in
3413a966c04fSmrg	  darwin)
3414a966c04fSmrg	    # we can't check for "0.0" in archive_cmds due to quoting
3415a966c04fSmrg	    # problems, so we reset it completely
3416a966c04fSmrg	    verstring=
3417a966c04fSmrg	    ;;
3418a966c04fSmrg	  *)
3419a966c04fSmrg	    verstring="0.0"
3420a966c04fSmrg	    ;;
3421a966c04fSmrg	  esac
3422a966c04fSmrg	  if test "$need_version" = no; then
3423a966c04fSmrg	    versuffix=
3424a966c04fSmrg	  else
3425a966c04fSmrg	    versuffix=".0.0"
3426a966c04fSmrg	  fi
3427a966c04fSmrg	fi
3428a966c04fSmrg
3429a966c04fSmrg	# Remove version info from name if versioning should be avoided
3430a966c04fSmrg	if test "$avoid_version" = yes && test "$need_version" = no; then
3431a966c04fSmrg	  major=
3432a966c04fSmrg	  versuffix=
3433a966c04fSmrg	  verstring=""
3434a966c04fSmrg	fi
3435a966c04fSmrg
3436a966c04fSmrg	# Check to see if the archive will have undefined symbols.
3437a966c04fSmrg	if test "$allow_undefined" = yes; then
3438a966c04fSmrg	  if test "$allow_undefined_flag" = unsupported; then
3439a966c04fSmrg	    $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
3440a966c04fSmrg	    build_libtool_libs=no
3441a966c04fSmrg	    build_old_libs=yes
3442a966c04fSmrg	  fi
3443a966c04fSmrg	else
3444a966c04fSmrg	  # Don't allow undefined symbols.
3445a966c04fSmrg	  allow_undefined_flag="$no_undefined_flag"
3446a966c04fSmrg	fi
3447a966c04fSmrg      fi
3448a966c04fSmrg
3449a966c04fSmrg      if test "$mode" != relink; then
3450a966c04fSmrg	# Remove our outputs, but don't remove object files since they
3451a966c04fSmrg	# may have been created when compiling PIC objects.
3452a966c04fSmrg	removelist=
3453a966c04fSmrg	tempremovelist=`$echo "$output_objdir/*"`
3454a966c04fSmrg	for p in $tempremovelist; do
3455a966c04fSmrg	  case $p in
3456a966c04fSmrg	    *.$objext)
3457a966c04fSmrg	       ;;
3458a966c04fSmrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
3459a966c04fSmrg	       if test "X$precious_files_regex" != "X"; then
3460a966c04fSmrg	         if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
3461a966c04fSmrg	         then
3462a966c04fSmrg		   continue
3463a966c04fSmrg		 fi
3464a966c04fSmrg	       fi
3465a966c04fSmrg	       removelist="$removelist $p"
3466a966c04fSmrg	       ;;
3467a966c04fSmrg	    *) ;;
3468a966c04fSmrg	  esac
3469a966c04fSmrg	done
3470a966c04fSmrg	if test -n "$removelist"; then
3471a966c04fSmrg	  $show "${rm}r $removelist"
3472a966c04fSmrg	  $run ${rm}r $removelist
3473a966c04fSmrg	fi
3474a966c04fSmrg      fi
3475a966c04fSmrg
3476a966c04fSmrg      # Now set the variables for building old libraries.
3477a966c04fSmrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
3478a966c04fSmrg	oldlibs="$oldlibs $output_objdir/$libname.$libext"
3479a966c04fSmrg
3480a966c04fSmrg	# Transform .lo files to .o files.
3481a966c04fSmrg	oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
3482a966c04fSmrg      fi
3483a966c04fSmrg
3484a966c04fSmrg      # Eliminate all temporary directories.
34852e2dd055Smrg      #for path in $notinst_path; do
34862e2dd055Smrg      #	lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
34872e2dd055Smrg      #	deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
34882e2dd055Smrg      #	dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
34892e2dd055Smrg      #done
3490a966c04fSmrg
3491a966c04fSmrg      if test -n "$xrpath"; then
3492a966c04fSmrg	# If the user specified any rpath flags, then add them.
3493a966c04fSmrg	temp_xrpath=
3494a966c04fSmrg	for libdir in $xrpath; do
3495a966c04fSmrg	  temp_xrpath="$temp_xrpath -R$libdir"
3496a966c04fSmrg	  case "$finalize_rpath " in
3497a966c04fSmrg	  *" $libdir "*) ;;
3498a966c04fSmrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
3499a966c04fSmrg	  esac
3500a966c04fSmrg	done
3501a966c04fSmrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
3502a966c04fSmrg	  dependency_libs="$temp_xrpath $dependency_libs"
3503a966c04fSmrg	fi
3504a966c04fSmrg      fi
3505a966c04fSmrg
3506a966c04fSmrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
3507a966c04fSmrg      old_dlfiles="$dlfiles"
3508a966c04fSmrg      dlfiles=
3509a966c04fSmrg      for lib in $old_dlfiles; do
3510a966c04fSmrg	case " $dlprefiles $dlfiles " in
3511a966c04fSmrg	*" $lib "*) ;;
3512a966c04fSmrg	*) dlfiles="$dlfiles $lib" ;;
3513a966c04fSmrg	esac
3514a966c04fSmrg      done
3515a966c04fSmrg
3516a966c04fSmrg      # Make sure dlprefiles contains only unique files
3517a966c04fSmrg      old_dlprefiles="$dlprefiles"
3518a966c04fSmrg      dlprefiles=
3519a966c04fSmrg      for lib in $old_dlprefiles; do
3520a966c04fSmrg	case "$dlprefiles " in
3521a966c04fSmrg	*" $lib "*) ;;
3522a966c04fSmrg	*) dlprefiles="$dlprefiles $lib" ;;
3523a966c04fSmrg	esac
3524a966c04fSmrg      done
3525a966c04fSmrg
3526a966c04fSmrg      if test "$build_libtool_libs" = yes; then
3527a966c04fSmrg	if test -n "$rpath"; then
3528a966c04fSmrg	  case $host in
3529a966c04fSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
3530a966c04fSmrg	    # these systems don't actually have a c library (as such)!
3531a966c04fSmrg	    ;;
3532a966c04fSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
3533a966c04fSmrg	    # Rhapsody C library is in the System framework
3534a966c04fSmrg	    deplibs="$deplibs -framework System"
3535a966c04fSmrg	    ;;
3536a966c04fSmrg	  *-*-netbsd*)
3537a966c04fSmrg	    # Don't link with libc until the a.out ld.so is fixed.
3538a966c04fSmrg	    ;;
3539a966c04fSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
3540a966c04fSmrg	    # Do not include libc due to us having libc/libc_r.
3541a966c04fSmrg	    ;;
3542a966c04fSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
3543a966c04fSmrg	    # Causes problems with __ctype
3544a966c04fSmrg	    ;;
3545a966c04fSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
3546a966c04fSmrg	    # Compiler inserts libc in the correct place for threads to work
3547a966c04fSmrg	    ;;
3548a966c04fSmrg 	  *)
3549a966c04fSmrg	    # Add libc to deplibs on all other systems if necessary.
3550a966c04fSmrg	    if test "$build_libtool_need_lc" = "yes"; then
3551a966c04fSmrg	      deplibs="$deplibs -lc"
3552a966c04fSmrg	    fi
3553a966c04fSmrg	    ;;
3554a966c04fSmrg	  esac
3555a966c04fSmrg	fi
3556a966c04fSmrg
3557a966c04fSmrg	# Transform deplibs into only deplibs that can be linked in shared.
3558a966c04fSmrg	name_save=$name
3559a966c04fSmrg	libname_save=$libname
3560a966c04fSmrg	release_save=$release
3561a966c04fSmrg	versuffix_save=$versuffix
3562a966c04fSmrg	major_save=$major
3563a966c04fSmrg	# I'm not sure if I'm treating the release correctly.  I think
3564a966c04fSmrg	# release should show up in the -l (ie -lgmp5) so we don't want to
3565a966c04fSmrg	# add it in twice.  Is that correct?
3566a966c04fSmrg	release=""
3567a966c04fSmrg	versuffix=""
3568a966c04fSmrg	major=""
3569a966c04fSmrg	newdeplibs=
3570a966c04fSmrg	droppeddeps=no
3571a966c04fSmrg	case $deplibs_check_method in
3572a966c04fSmrg	pass_all)
3573a966c04fSmrg	  # Don't check for shared/static.  Everything works.
3574a966c04fSmrg	  # This might be a little naive.  We might want to check
3575a966c04fSmrg	  # whether the library exists or not.  But this is on
3576a966c04fSmrg	  # osf3 & osf4 and I'm not really sure... Just
3577a966c04fSmrg	  # implementing what was already the behavior.
3578a966c04fSmrg	  newdeplibs=$deplibs
3579a966c04fSmrg	  ;;
3580a966c04fSmrg	test_compile)
3581a966c04fSmrg	  # This code stresses the "libraries are programs" paradigm to its
3582a966c04fSmrg	  # limits. Maybe even breaks it.  We compile a program, linking it
3583a966c04fSmrg	  # against the deplibs as a proxy for the library.  Then we can check
3584a966c04fSmrg	  # whether they linked in statically or dynamically with ldd.
3585a966c04fSmrg	  $rm conftest.c
3586a966c04fSmrg	  cat > conftest.c <<EOF
3587a966c04fSmrg	  int main() { return 0; }
3588a966c04fSmrgEOF
3589a966c04fSmrg	  $rm conftest
35902e2dd055Smrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
3591a966c04fSmrg	    ldd_output=`ldd conftest`
3592a966c04fSmrg	    for i in $deplibs; do
3593a966c04fSmrg	      name=`expr $i : '-l\(.*\)'`
3594a966c04fSmrg	      # If $name is empty we are operating on a -L argument.
35952e2dd055Smrg              if test "$name" != "" && test "$name" != "0"; then
3596a966c04fSmrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3597a966c04fSmrg		  case " $predeps $postdeps " in
3598a966c04fSmrg		  *" $i "*)
3599a966c04fSmrg		    newdeplibs="$newdeplibs $i"
3600a966c04fSmrg		    i=""
3601a966c04fSmrg		    ;;
3602a966c04fSmrg		  esac
3603a966c04fSmrg	        fi
3604a966c04fSmrg		if test -n "$i" ; then
3605a966c04fSmrg		  libname=`eval \\$echo \"$libname_spec\"`
3606a966c04fSmrg		  deplib_matches=`eval \\$echo \"$library_names_spec\"`
3607a966c04fSmrg		  set dummy $deplib_matches
3608a966c04fSmrg		  deplib_match=$2
3609a966c04fSmrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
3610a966c04fSmrg		    newdeplibs="$newdeplibs $i"
3611a966c04fSmrg		  else
3612a966c04fSmrg		    droppeddeps=yes
3613a966c04fSmrg		    $echo
3614a966c04fSmrg		    $echo "*** Warning: dynamic linker does not accept needed library $i."
3615a966c04fSmrg		    $echo "*** I have the capability to make that library automatically link in when"
3616a966c04fSmrg		    $echo "*** you link to this library.  But I can only do this if you have a"
3617a966c04fSmrg		    $echo "*** shared version of the library, which I believe you do not have"
3618a966c04fSmrg		    $echo "*** because a test_compile did reveal that the linker did not use it for"
3619a966c04fSmrg		    $echo "*** its dynamic dependency list that programs get resolved with at runtime."
3620a966c04fSmrg		  fi
3621a966c04fSmrg		fi
3622a966c04fSmrg	      else
3623a966c04fSmrg		newdeplibs="$newdeplibs $i"
3624a966c04fSmrg	      fi
3625a966c04fSmrg	    done
3626a966c04fSmrg	  else
3627a966c04fSmrg	    # Error occurred in the first compile.  Let's try to salvage
3628a966c04fSmrg	    # the situation: Compile a separate program for each library.
3629a966c04fSmrg	    for i in $deplibs; do
3630a966c04fSmrg	      name=`expr $i : '-l\(.*\)'`
3631a966c04fSmrg	      # If $name is empty we are operating on a -L argument.
3632a966c04fSmrg              if test "$name" != "" && test "$name" != "0"; then
3633a966c04fSmrg		$rm conftest
36342e2dd055Smrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
3635a966c04fSmrg		  ldd_output=`ldd conftest`
3636a966c04fSmrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3637a966c04fSmrg		    case " $predeps $postdeps " in
3638a966c04fSmrg		    *" $i "*)
3639a966c04fSmrg		      newdeplibs="$newdeplibs $i"
3640a966c04fSmrg		      i=""
3641a966c04fSmrg		      ;;
3642a966c04fSmrg		    esac
3643a966c04fSmrg		  fi
3644a966c04fSmrg		  if test -n "$i" ; then
3645a966c04fSmrg		    libname=`eval \\$echo \"$libname_spec\"`
3646a966c04fSmrg		    deplib_matches=`eval \\$echo \"$library_names_spec\"`
3647a966c04fSmrg		    set dummy $deplib_matches
3648a966c04fSmrg		    deplib_match=$2
3649a966c04fSmrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
3650a966c04fSmrg		      newdeplibs="$newdeplibs $i"
3651a966c04fSmrg		    else
3652a966c04fSmrg		      droppeddeps=yes
3653a966c04fSmrg		      $echo
3654a966c04fSmrg		      $echo "*** Warning: dynamic linker does not accept needed library $i."
3655a966c04fSmrg		      $echo "*** I have the capability to make that library automatically link in when"
3656a966c04fSmrg		      $echo "*** you link to this library.  But I can only do this if you have a"
3657a966c04fSmrg		      $echo "*** shared version of the library, which you do not appear to have"
3658a966c04fSmrg		      $echo "*** because a test_compile did reveal that the linker did not use this one"
3659a966c04fSmrg		      $echo "*** as a dynamic dependency that programs can get resolved with at runtime."
3660a966c04fSmrg		    fi
3661a966c04fSmrg		  fi
3662a966c04fSmrg		else
3663a966c04fSmrg		  droppeddeps=yes
3664a966c04fSmrg		  $echo
3665a966c04fSmrg		  $echo "*** Warning!  Library $i is needed by this library but I was not able to"
36662e2dd055Smrg		  $echo "*** make it link in!  You will probably need to install it or some"
3667a966c04fSmrg		  $echo "*** library that it depends on before this library will be fully"
3668a966c04fSmrg		  $echo "*** functional.  Installing it before continuing would be even better."
3669a966c04fSmrg		fi
3670a966c04fSmrg	      else
3671a966c04fSmrg		newdeplibs="$newdeplibs $i"
3672a966c04fSmrg	      fi
3673a966c04fSmrg	    done
3674a966c04fSmrg	  fi
3675a966c04fSmrg	  ;;
3676a966c04fSmrg	file_magic*)
3677a966c04fSmrg	  set dummy $deplibs_check_method
3678a966c04fSmrg	  file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
3679a966c04fSmrg	  for a_deplib in $deplibs; do
3680a966c04fSmrg	    name=`expr $a_deplib : '-l\(.*\)'`
3681a966c04fSmrg	    # If $name is empty we are operating on a -L argument.
3682a966c04fSmrg            if test "$name" != "" && test  "$name" != "0"; then
3683a966c04fSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3684a966c04fSmrg		case " $predeps $postdeps " in
3685a966c04fSmrg		*" $a_deplib "*)
3686a966c04fSmrg		  newdeplibs="$newdeplibs $a_deplib"
3687a966c04fSmrg		  a_deplib=""
3688a966c04fSmrg		  ;;
3689a966c04fSmrg		esac
3690a966c04fSmrg	      fi
3691a966c04fSmrg	      if test -n "$a_deplib" ; then
3692a966c04fSmrg		libname=`eval \\$echo \"$libname_spec\"`
3693a966c04fSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
3694a966c04fSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
3695a966c04fSmrg		  for potent_lib in $potential_libs; do
3696a966c04fSmrg		      # Follow soft links.
3697a966c04fSmrg		      if ls -lLd "$potent_lib" 2>/dev/null \
3698a966c04fSmrg			 | grep " -> " >/dev/null; then
3699a966c04fSmrg			continue
3700a966c04fSmrg		      fi
3701a966c04fSmrg		      # The statement above tries to avoid entering an
3702a966c04fSmrg		      # endless loop below, in case of cyclic links.
3703a966c04fSmrg		      # We might still enter an endless loop, since a link
3704a966c04fSmrg		      # loop can be closed while we follow links,
3705a966c04fSmrg		      # but so what?
3706a966c04fSmrg		      potlib="$potent_lib"
3707a966c04fSmrg		      while test -h "$potlib" 2>/dev/null; do
3708a966c04fSmrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
3709a966c04fSmrg			case $potliblink in
3710a966c04fSmrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
3711a966c04fSmrg			*) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
3712a966c04fSmrg			esac
3713a966c04fSmrg		      done
3714a966c04fSmrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
3715a966c04fSmrg			 | ${SED} 10q \
3716a966c04fSmrg			 | $EGREP "$file_magic_regex" > /dev/null; then
3717a966c04fSmrg			newdeplibs="$newdeplibs $a_deplib"
3718a966c04fSmrg			a_deplib=""
3719a966c04fSmrg			break 2
3720a966c04fSmrg		      fi
3721a966c04fSmrg		  done
3722a966c04fSmrg		done
3723a966c04fSmrg	      fi
3724a966c04fSmrg	      if test -n "$a_deplib" ; then
3725a966c04fSmrg		droppeddeps=yes
3726a966c04fSmrg		$echo
3727a966c04fSmrg		$echo "*** Warning: linker path does not have real file for library $a_deplib."
3728a966c04fSmrg		$echo "*** I have the capability to make that library automatically link in when"
3729a966c04fSmrg		$echo "*** you link to this library.  But I can only do this if you have a"
3730a966c04fSmrg		$echo "*** shared version of the library, which you do not appear to have"
3731a966c04fSmrg		$echo "*** because I did check the linker path looking for a file starting"
3732a966c04fSmrg		if test -z "$potlib" ; then
3733a966c04fSmrg		  $echo "*** with $libname but no candidates were found. (...for file magic test)"
3734a966c04fSmrg		else
3735a966c04fSmrg		  $echo "*** with $libname and none of the candidates passed a file format test"
3736a966c04fSmrg		  $echo "*** using a file magic. Last file checked: $potlib"
3737a966c04fSmrg		fi
3738a966c04fSmrg	      fi
3739a966c04fSmrg	    else
3740a966c04fSmrg	      # Add a -L argument.
3741a966c04fSmrg	      newdeplibs="$newdeplibs $a_deplib"
3742a966c04fSmrg	    fi
3743a966c04fSmrg	  done # Gone through all deplibs.
3744a966c04fSmrg	  ;;
3745a966c04fSmrg	match_pattern*)
3746a966c04fSmrg	  set dummy $deplibs_check_method
3747a966c04fSmrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
3748a966c04fSmrg	  for a_deplib in $deplibs; do
3749a966c04fSmrg	    name=`expr $a_deplib : '-l\(.*\)'`
3750a966c04fSmrg	    # If $name is empty we are operating on a -L argument.
3751a966c04fSmrg	    if test -n "$name" && test "$name" != "0"; then
3752a966c04fSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3753a966c04fSmrg		case " $predeps $postdeps " in
3754a966c04fSmrg		*" $a_deplib "*)
3755a966c04fSmrg		  newdeplibs="$newdeplibs $a_deplib"
3756a966c04fSmrg		  a_deplib=""
3757a966c04fSmrg		  ;;
3758a966c04fSmrg		esac
3759a966c04fSmrg	      fi
3760a966c04fSmrg	      if test -n "$a_deplib" ; then
3761a966c04fSmrg		libname=`eval \\$echo \"$libname_spec\"`
3762a966c04fSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
3763a966c04fSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
3764a966c04fSmrg		  for potent_lib in $potential_libs; do
3765a966c04fSmrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
3766a966c04fSmrg		    if eval $echo \"$potent_lib\" 2>/dev/null \
3767a966c04fSmrg		        | ${SED} 10q \
3768a966c04fSmrg		        | $EGREP "$match_pattern_regex" > /dev/null; then
3769a966c04fSmrg		      newdeplibs="$newdeplibs $a_deplib"
3770a966c04fSmrg		      a_deplib=""
3771a966c04fSmrg		      break 2
3772a966c04fSmrg		    fi
3773a966c04fSmrg		  done
3774a966c04fSmrg		done
3775a966c04fSmrg	      fi
3776a966c04fSmrg	      if test -n "$a_deplib" ; then
3777a966c04fSmrg		droppeddeps=yes
3778a966c04fSmrg		$echo
3779a966c04fSmrg		$echo "*** Warning: linker path does not have real file for library $a_deplib."
3780a966c04fSmrg		$echo "*** I have the capability to make that library automatically link in when"
3781a966c04fSmrg		$echo "*** you link to this library.  But I can only do this if you have a"
3782a966c04fSmrg		$echo "*** shared version of the library, which you do not appear to have"
3783a966c04fSmrg		$echo "*** because I did check the linker path looking for a file starting"
3784a966c04fSmrg		if test -z "$potlib" ; then
3785a966c04fSmrg		  $echo "*** with $libname but no candidates were found. (...for regex pattern test)"
3786a966c04fSmrg		else
3787a966c04fSmrg		  $echo "*** with $libname and none of the candidates passed a file format test"
3788a966c04fSmrg		  $echo "*** using a regex pattern. Last file checked: $potlib"
3789a966c04fSmrg		fi
3790a966c04fSmrg	      fi
3791a966c04fSmrg	    else
3792a966c04fSmrg	      # Add a -L argument.
3793a966c04fSmrg	      newdeplibs="$newdeplibs $a_deplib"
3794a966c04fSmrg	    fi
3795a966c04fSmrg	  done # Gone through all deplibs.
3796a966c04fSmrg	  ;;
3797a966c04fSmrg	none | unknown | *)
3798a966c04fSmrg	  newdeplibs=""
3799a966c04fSmrg	  tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
3800a966c04fSmrg	    -e 's/ -[LR][^ ]*//g'`
3801a966c04fSmrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3802a966c04fSmrg	    for i in $predeps $postdeps ; do
3803a966c04fSmrg	      # can't use Xsed below, because $i might contain '/'
3804a966c04fSmrg	      tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"`
3805a966c04fSmrg	    done
3806a966c04fSmrg	  fi
3807a966c04fSmrg	  if $echo "X $tmp_deplibs" | $Xsed -e 's/[ 	]//g' \
3808a966c04fSmrg	    | grep . >/dev/null; then
3809a966c04fSmrg	    $echo
3810a966c04fSmrg	    if test "X$deplibs_check_method" = "Xnone"; then
3811a966c04fSmrg	      $echo "*** Warning: inter-library dependencies are not supported in this platform."
3812a966c04fSmrg	    else
3813a966c04fSmrg	      $echo "*** Warning: inter-library dependencies are not known to be supported."
3814a966c04fSmrg	    fi
3815a966c04fSmrg	    $echo "*** All declared inter-library dependencies are being dropped."
3816a966c04fSmrg	    droppeddeps=yes
3817a966c04fSmrg	  fi
3818a966c04fSmrg	  ;;
3819a966c04fSmrg	esac
3820a966c04fSmrg	versuffix=$versuffix_save
3821a966c04fSmrg	major=$major_save
3822a966c04fSmrg	release=$release_save
3823a966c04fSmrg	libname=$libname_save
3824a966c04fSmrg	name=$name_save
3825a966c04fSmrg
3826a966c04fSmrg	case $host in
3827a966c04fSmrg	*-*-rhapsody* | *-*-darwin1.[012])
3828a966c04fSmrg	  # On Rhapsody replace the C library is the System framework
3829a966c04fSmrg	  newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'`
3830a966c04fSmrg	  ;;
3831a966c04fSmrg	esac
3832a966c04fSmrg
3833a966c04fSmrg	if test "$droppeddeps" = yes; then
3834a966c04fSmrg	  if test "$module" = yes; then
3835a966c04fSmrg	    $echo
3836a966c04fSmrg	    $echo "*** Warning: libtool could not satisfy all declared inter-library"
3837a966c04fSmrg	    $echo "*** dependencies of module $libname.  Therefore, libtool will create"
3838a966c04fSmrg	    $echo "*** a static module, that should work as long as the dlopening"
3839a966c04fSmrg	    $echo "*** application is linked with the -dlopen flag."
3840a966c04fSmrg	    if test -z "$global_symbol_pipe"; then
3841a966c04fSmrg	      $echo
3842a966c04fSmrg	      $echo "*** However, this would only work if libtool was able to extract symbol"
3843a966c04fSmrg	      $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
3844a966c04fSmrg	      $echo "*** not find such a program.  So, this module is probably useless."
3845a966c04fSmrg	      $echo "*** \`nm' from GNU binutils and a full rebuild may help."
3846a966c04fSmrg	    fi
3847a966c04fSmrg	    if test "$build_old_libs" = no; then
3848a966c04fSmrg	      oldlibs="$output_objdir/$libname.$libext"
3849a966c04fSmrg	      build_libtool_libs=module
3850a966c04fSmrg	      build_old_libs=yes
3851a966c04fSmrg	    else
3852a966c04fSmrg	      build_libtool_libs=no
3853a966c04fSmrg	    fi
3854a966c04fSmrg	  else
3855a966c04fSmrg	    $echo "*** The inter-library dependencies that have been dropped here will be"
3856a966c04fSmrg	    $echo "*** automatically added whenever a program is linked with this library"
3857a966c04fSmrg	    $echo "*** or is declared to -dlopen it."
3858a966c04fSmrg
3859a966c04fSmrg	    if test "$allow_undefined" = no; then
3860a966c04fSmrg	      $echo
3861a966c04fSmrg	      $echo "*** Since this library must not contain undefined symbols,"
3862a966c04fSmrg	      $echo "*** because either the platform does not support them or"
3863a966c04fSmrg	      $echo "*** it was explicitly requested with -no-undefined,"
3864a966c04fSmrg	      $echo "*** libtool will only create a static version of it."
3865a966c04fSmrg	      if test "$build_old_libs" = no; then
3866a966c04fSmrg		oldlibs="$output_objdir/$libname.$libext"
3867a966c04fSmrg		build_libtool_libs=module
3868a966c04fSmrg		build_old_libs=yes
3869a966c04fSmrg	      else
3870a966c04fSmrg		build_libtool_libs=no
3871a966c04fSmrg	      fi
3872a966c04fSmrg	    fi
3873a966c04fSmrg	  fi
3874a966c04fSmrg	fi
3875a966c04fSmrg	# Done checking deplibs!
3876a966c04fSmrg	deplibs=$newdeplibs
3877a966c04fSmrg      fi
3878a966c04fSmrg
3879a966c04fSmrg
3880a966c04fSmrg      # move library search paths that coincide with paths to not yet
3881a966c04fSmrg      # installed libraries to the beginning of the library search list
3882a966c04fSmrg      new_libs=
3883a966c04fSmrg      for path in $notinst_path; do
3884a966c04fSmrg	case " $new_libs " in
3885a966c04fSmrg	*" -L$path/$objdir "*) ;;
3886a966c04fSmrg	*)
3887a966c04fSmrg	  case " $deplibs " in
3888a966c04fSmrg	  *" -L$path/$objdir "*)
3889a966c04fSmrg	    new_libs="$new_libs -L$path/$objdir" ;;
3890a966c04fSmrg	  esac
3891a966c04fSmrg	  ;;
3892a966c04fSmrg	esac
3893a966c04fSmrg      done
3894a966c04fSmrg      for deplib in $deplibs; do
3895a966c04fSmrg	case $deplib in
3896a966c04fSmrg	-L*)
3897a966c04fSmrg	  case " $new_libs " in
3898a966c04fSmrg	  *" $deplib "*) ;;
3899a966c04fSmrg	  *) new_libs="$new_libs $deplib" ;;
3900a966c04fSmrg	  esac
3901a966c04fSmrg	  ;;
3902a966c04fSmrg	*) new_libs="$new_libs $deplib" ;;
3903a966c04fSmrg	esac
3904a966c04fSmrg      done
3905a966c04fSmrg      deplibs="$new_libs"
3906a966c04fSmrg
3907a966c04fSmrg
3908a966c04fSmrg      # All the library-specific variables (install_libdir is set above).
3909a966c04fSmrg      library_names=
3910a966c04fSmrg      old_library=
3911a966c04fSmrg      dlname=
3912a966c04fSmrg
3913a966c04fSmrg      # Test again, we may have decided not to build it any more
3914a966c04fSmrg      if test "$build_libtool_libs" = yes; then
3915a966c04fSmrg	if test "$hardcode_into_libs" = yes; then
3916a966c04fSmrg	  # Hardcode the library paths
3917a966c04fSmrg	  hardcode_libdirs=
3918a966c04fSmrg	  dep_rpath=
3919a966c04fSmrg	  rpath="$finalize_rpath"
3920a966c04fSmrg	  test "$mode" != relink && rpath="$compile_rpath$rpath"
3921a966c04fSmrg	  for libdir in $rpath; do
3922a966c04fSmrg	    if test -n "$hardcode_libdir_flag_spec"; then
3923a966c04fSmrg	      if test -n "$hardcode_libdir_separator"; then
3924a966c04fSmrg		if test -z "$hardcode_libdirs"; then
3925a966c04fSmrg		  hardcode_libdirs="$libdir"
3926a966c04fSmrg		else
3927a966c04fSmrg		  # Just accumulate the unique libdirs.
3928a966c04fSmrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
3929a966c04fSmrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
3930a966c04fSmrg		    ;;
3931a966c04fSmrg		  *)
3932a966c04fSmrg		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
3933a966c04fSmrg		    ;;
3934a966c04fSmrg		  esac
3935a966c04fSmrg		fi
3936a966c04fSmrg	      else
3937a966c04fSmrg		eval flag=\"$hardcode_libdir_flag_spec\"
3938a966c04fSmrg		dep_rpath="$dep_rpath $flag"
3939a966c04fSmrg	      fi
3940a966c04fSmrg	    elif test -n "$runpath_var"; then
3941a966c04fSmrg	      case "$perm_rpath " in
3942a966c04fSmrg	      *" $libdir "*) ;;
3943a966c04fSmrg	      *) perm_rpath="$perm_rpath $libdir" ;;
3944a966c04fSmrg	      esac
3945a966c04fSmrg	    fi
3946a966c04fSmrg	  done
3947a966c04fSmrg	  # Substitute the hardcoded libdirs into the rpath.
3948a966c04fSmrg	  if test -n "$hardcode_libdir_separator" &&
3949a966c04fSmrg	     test -n "$hardcode_libdirs"; then
3950a966c04fSmrg	    libdir="$hardcode_libdirs"
3951a966c04fSmrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
39522e2dd055Smrg	      case $archive_cmds in
39532e2dd055Smrg	      *\$LD*) eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" ;;
39542e2dd055Smrg	      *)      eval dep_rpath=\"$hardcode_libdir_flag_spec\" ;;
39552e2dd055Smrg	      esac
3956a966c04fSmrg	    else
3957a966c04fSmrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
3958a966c04fSmrg	    fi
3959a966c04fSmrg	  fi
3960a966c04fSmrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
3961a966c04fSmrg	    # We should set the runpath_var.
3962a966c04fSmrg	    rpath=
3963a966c04fSmrg	    for dir in $perm_rpath; do
3964a966c04fSmrg	      rpath="$rpath$dir:"
3965a966c04fSmrg	    done
3966a966c04fSmrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
3967a966c04fSmrg	  fi
3968a966c04fSmrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
3969a966c04fSmrg	fi
3970a966c04fSmrg
3971a966c04fSmrg	shlibpath="$finalize_shlibpath"
3972a966c04fSmrg	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
3973a966c04fSmrg	if test -n "$shlibpath"; then
3974a966c04fSmrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
3975a966c04fSmrg	fi
3976a966c04fSmrg
3977a966c04fSmrg	# Get the real and link names of the library.
3978a966c04fSmrg	eval shared_ext=\"$shrext_cmds\"
3979a966c04fSmrg	eval library_names=\"$library_names_spec\"
3980a966c04fSmrg	set dummy $library_names
3981a966c04fSmrg	realname="$2"
3982a966c04fSmrg	shift; shift
3983a966c04fSmrg
3984a966c04fSmrg	if test -n "$soname_spec"; then
3985a966c04fSmrg	  eval soname=\"$soname_spec\"
3986a966c04fSmrg	else
3987a966c04fSmrg	  soname="$realname"
3988a966c04fSmrg	fi
3989a966c04fSmrg	if test -z "$dlname"; then
3990a966c04fSmrg	  dlname=$soname
3991a966c04fSmrg	fi
3992a966c04fSmrg
3993a966c04fSmrg	lib="$output_objdir/$realname"
3994a966c04fSmrg	linknames=
3995a966c04fSmrg	for link
3996a966c04fSmrg	do
3997a966c04fSmrg	  linknames="$linknames $link"
3998a966c04fSmrg	done
3999a966c04fSmrg
4000a966c04fSmrg	# Use standard objects if they are pic
4001a966c04fSmrg	test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
4002a966c04fSmrg
4003a966c04fSmrg	# Prepare the list of exported symbols
4004a966c04fSmrg	if test -z "$export_symbols"; then
4005a966c04fSmrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
4006a966c04fSmrg	    $show "generating symbol list for \`$libname.la'"
4007a966c04fSmrg	    export_symbols="$output_objdir/$libname.exp"
4008a966c04fSmrg	    $run $rm $export_symbols
4009a966c04fSmrg	    cmds=$export_symbols_cmds
4010a966c04fSmrg	    save_ifs="$IFS"; IFS='~'
4011a966c04fSmrg	    for cmd in $cmds; do
4012a966c04fSmrg	      IFS="$save_ifs"
4013a966c04fSmrg	      eval cmd=\"$cmd\"
4014a966c04fSmrg	      if len=`expr "X$cmd" : ".*"` &&
4015a966c04fSmrg	       test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
4016a966c04fSmrg	        $show "$cmd"
4017a966c04fSmrg	        $run eval "$cmd" || exit $?
4018a966c04fSmrg	        skipped_export=false
4019a966c04fSmrg	      else
4020a966c04fSmrg	        # The command line is too long to execute in one step.
4021a966c04fSmrg	        $show "using reloadable object file for export list..."
4022a966c04fSmrg	        skipped_export=:
4023a966c04fSmrg		# Break out early, otherwise skipped_export may be
4024a966c04fSmrg		# set to false by a later but shorter cmd.
4025a966c04fSmrg		break
4026a966c04fSmrg	      fi
4027a966c04fSmrg	    done
4028a966c04fSmrg	    IFS="$save_ifs"
4029a966c04fSmrg	    if test -n "$export_symbols_regex"; then
4030a966c04fSmrg	      $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
4031a966c04fSmrg	      $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
4032a966c04fSmrg	      $show "$mv \"${export_symbols}T\" \"$export_symbols\""
4033a966c04fSmrg	      $run eval '$mv "${export_symbols}T" "$export_symbols"'
4034a966c04fSmrg	    fi
4035a966c04fSmrg	  fi
4036a966c04fSmrg	fi
4037a966c04fSmrg
4038a966c04fSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
4039a966c04fSmrg	  $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
4040a966c04fSmrg	fi
4041a966c04fSmrg
4042a966c04fSmrg	tmp_deplibs=
4043a966c04fSmrg	for test_deplib in $deplibs; do
4044a966c04fSmrg		case " $convenience " in
4045a966c04fSmrg		*" $test_deplib "*) ;;
4046a966c04fSmrg		*)
4047a966c04fSmrg			tmp_deplibs="$tmp_deplibs $test_deplib"
4048a966c04fSmrg			;;
4049a966c04fSmrg		esac
4050a966c04fSmrg	done
4051a966c04fSmrg	deplibs="$tmp_deplibs"
4052a966c04fSmrg
4053a966c04fSmrg	if test -n "$convenience"; then
4054a966c04fSmrg	  if test -n "$whole_archive_flag_spec"; then
4055a966c04fSmrg	    save_libobjs=$libobjs
4056a966c04fSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
4057a966c04fSmrg	  else
4058a966c04fSmrg	    gentop="$output_objdir/${outputname}x"
4059a966c04fSmrg	    generated="$generated $gentop"
4060a966c04fSmrg
4061a966c04fSmrg	    func_extract_archives $gentop $convenience
4062a966c04fSmrg	    libobjs="$libobjs $func_extract_archives_result"
4063a966c04fSmrg	  fi
4064a966c04fSmrg	fi
4065a966c04fSmrg	
4066a966c04fSmrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
4067a966c04fSmrg	  eval flag=\"$thread_safe_flag_spec\"
4068a966c04fSmrg	  linker_flags="$linker_flags $flag"
4069a966c04fSmrg	fi
4070a966c04fSmrg
4071a966c04fSmrg	# Make a backup of the uninstalled library when relinking
4072a966c04fSmrg	if test "$mode" = relink; then
4073a966c04fSmrg	  $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $?
4074a966c04fSmrg	fi
4075a966c04fSmrg
4076a966c04fSmrg	# Do each of the archive commands.
4077a966c04fSmrg	if test "$module" = yes && test -n "$module_cmds" ; then
4078a966c04fSmrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
4079a966c04fSmrg	    eval test_cmds=\"$module_expsym_cmds\"
4080a966c04fSmrg	    cmds=$module_expsym_cmds
4081a966c04fSmrg	  else
4082a966c04fSmrg	    eval test_cmds=\"$module_cmds\"
4083a966c04fSmrg	    cmds=$module_cmds
4084a966c04fSmrg	  fi
4085a966c04fSmrg	else
4086a966c04fSmrg	if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
4087a966c04fSmrg	  eval test_cmds=\"$archive_expsym_cmds\"
4088a966c04fSmrg	  cmds=$archive_expsym_cmds
4089a966c04fSmrg	else
4090a966c04fSmrg	  eval test_cmds=\"$archive_cmds\"
4091a966c04fSmrg	  cmds=$archive_cmds
4092a966c04fSmrg	  fi
4093a966c04fSmrg	fi
4094a966c04fSmrg
4095a966c04fSmrg	if test "X$skipped_export" != "X:" &&
4096a966c04fSmrg	   len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
4097a966c04fSmrg	   test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
4098a966c04fSmrg	  :
4099a966c04fSmrg	else
4100a966c04fSmrg	  # The command line is too long to link in one step, link piecewise.
4101a966c04fSmrg	  $echo "creating reloadable object files..."
4102a966c04fSmrg
4103a966c04fSmrg	  # Save the value of $output and $libobjs because we want to
4104a966c04fSmrg	  # use them later.  If we have whole_archive_flag_spec, we
4105a966c04fSmrg	  # want to use save_libobjs as it was before
4106a966c04fSmrg	  # whole_archive_flag_spec was expanded, because we can't
4107a966c04fSmrg	  # assume the linker understands whole_archive_flag_spec.
4108a966c04fSmrg	  # This may have to be revisited, in case too many
4109a966c04fSmrg	  # convenience libraries get linked in and end up exceeding
4110a966c04fSmrg	  # the spec.
4111a966c04fSmrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
4112a966c04fSmrg	    save_libobjs=$libobjs
4113a966c04fSmrg	  fi
4114a966c04fSmrg	  save_output=$output
4115a966c04fSmrg	  output_la=`$echo "X$output" | $Xsed -e "$basename"`
4116a966c04fSmrg
4117a966c04fSmrg	  # Clear the reloadable object creation command queue and
4118a966c04fSmrg	  # initialize k to one.
4119a966c04fSmrg	  test_cmds=
4120a966c04fSmrg	  concat_cmds=
4121a966c04fSmrg	  objlist=
4122a966c04fSmrg	  delfiles=
4123a966c04fSmrg	  last_robj=
4124a966c04fSmrg	  k=1
4125a966c04fSmrg	  output=$output_objdir/$output_la-${k}.$objext
4126a966c04fSmrg	  # Loop over the list of objects to be linked.
4127a966c04fSmrg	  for obj in $save_libobjs
4128a966c04fSmrg	  do
4129a966c04fSmrg	    eval test_cmds=\"$reload_cmds $objlist $last_robj\"
4130a966c04fSmrg	    if test "X$objlist" = X ||
4131a966c04fSmrg	       { len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
4132a966c04fSmrg		 test "$len" -le "$max_cmd_len"; }; then
4133a966c04fSmrg	      objlist="$objlist $obj"
4134a966c04fSmrg	    else
4135a966c04fSmrg	      # The command $test_cmds is almost too long, add a
4136a966c04fSmrg	      # command to the queue.
4137a966c04fSmrg	      if test "$k" -eq 1 ; then
4138a966c04fSmrg		# The first file doesn't have a previous command to add.
4139a966c04fSmrg		eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
4140a966c04fSmrg	      else
4141a966c04fSmrg		# All subsequent reloadable object files will link in
4142a966c04fSmrg		# the last one created.
4143a966c04fSmrg		eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
4144a966c04fSmrg	      fi
4145a966c04fSmrg	      last_robj=$output_objdir/$output_la-${k}.$objext
4146a966c04fSmrg	      k=`expr $k + 1`
4147a966c04fSmrg	      output=$output_objdir/$output_la-${k}.$objext
4148a966c04fSmrg	      objlist=$obj
4149a966c04fSmrg	      len=1
4150a966c04fSmrg	    fi
4151a966c04fSmrg	  done
4152a966c04fSmrg	  # Handle the remaining objects by creating one last
4153a966c04fSmrg	  # reloadable object file.  All subsequent reloadable object
4154a966c04fSmrg	  # files will link in the last one created.
4155a966c04fSmrg	  test -z "$concat_cmds" || concat_cmds=$concat_cmds~
4156a966c04fSmrg	  eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
4157a966c04fSmrg
4158a966c04fSmrg	  if ${skipped_export-false}; then
4159a966c04fSmrg	    $show "generating symbol list for \`$libname.la'"
4160a966c04fSmrg	    export_symbols="$output_objdir/$libname.exp"
4161a966c04fSmrg	    $run $rm $export_symbols
4162a966c04fSmrg	    libobjs=$output
4163a966c04fSmrg	    # Append the command to create the export file.
4164a966c04fSmrg	    eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
4165a966c04fSmrg          fi
4166a966c04fSmrg
4167a966c04fSmrg	  # Set up a command to remove the reloadable object files
4168a966c04fSmrg	  # after they are used.
4169a966c04fSmrg	  i=0
4170a966c04fSmrg	  while test "$i" -lt "$k"
4171a966c04fSmrg	  do
4172a966c04fSmrg	    i=`expr $i + 1`
4173a966c04fSmrg	    delfiles="$delfiles $output_objdir/$output_la-${i}.$objext"
4174a966c04fSmrg	  done
4175a966c04fSmrg
4176a966c04fSmrg	  $echo "creating a temporary reloadable object file: $output"
4177a966c04fSmrg
4178a966c04fSmrg	  # Loop through the commands generated above and execute them.
4179a966c04fSmrg	  save_ifs="$IFS"; IFS='~'
4180a966c04fSmrg	  for cmd in $concat_cmds; do
4181a966c04fSmrg	    IFS="$save_ifs"
4182a966c04fSmrg	    $show "$cmd"
4183a966c04fSmrg	    $run eval "$cmd" || exit $?
4184a966c04fSmrg	  done
4185a966c04fSmrg	  IFS="$save_ifs"
4186a966c04fSmrg
4187a966c04fSmrg	  libobjs=$output
4188a966c04fSmrg	  # Restore the value of output.
4189a966c04fSmrg	  output=$save_output
4190a966c04fSmrg
4191a966c04fSmrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
4192a966c04fSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
4193a966c04fSmrg	  fi
4194a966c04fSmrg	  # Expand the library linking commands again to reset the
4195a966c04fSmrg	  # value of $libobjs for piecewise linking.
4196a966c04fSmrg
4197a966c04fSmrg	  # Do each of the archive commands.
4198a966c04fSmrg	  if test "$module" = yes && test -n "$module_cmds" ; then
4199a966c04fSmrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
4200a966c04fSmrg	      cmds=$module_expsym_cmds
4201a966c04fSmrg	    else
4202a966c04fSmrg	      cmds=$module_cmds
4203a966c04fSmrg	    fi
4204a966c04fSmrg	  else
4205a966c04fSmrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
4206a966c04fSmrg	    cmds=$archive_expsym_cmds
4207a966c04fSmrg	  else
4208a966c04fSmrg	    cmds=$archive_cmds
4209a966c04fSmrg	    fi
4210a966c04fSmrg	  fi
4211a966c04fSmrg
4212a966c04fSmrg	  # Append the command to remove the reloadable object files
4213a966c04fSmrg	  # to the just-reset $cmds.
4214a966c04fSmrg	  eval cmds=\"\$cmds~\$rm $delfiles\"
4215a966c04fSmrg	fi
4216a966c04fSmrg	save_ifs="$IFS"; IFS='~'
4217a966c04fSmrg	for cmd in $cmds; do
4218a966c04fSmrg	  IFS="$save_ifs"
4219a966c04fSmrg	  eval cmd=\"$cmd\"
4220a966c04fSmrg	  $show "$cmd"
4221a966c04fSmrg	  $run eval "$cmd" || {
4222a966c04fSmrg	    lt_exit=$?
4223a966c04fSmrg
4224a966c04fSmrg	    # Restore the uninstalled library and exit
4225a966c04fSmrg	    if test "$mode" = relink; then
4226a966c04fSmrg	      $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
4227a966c04fSmrg	    fi
4228a966c04fSmrg
4229a966c04fSmrg	    exit $lt_exit
4230a966c04fSmrg	  }
4231a966c04fSmrg	done
4232a966c04fSmrg	IFS="$save_ifs"
4233a966c04fSmrg
4234a966c04fSmrg	# Restore the uninstalled library and exit
4235a966c04fSmrg	if test "$mode" = relink; then
4236a966c04fSmrg	  $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
4237a966c04fSmrg
4238a966c04fSmrg	  if test -n "$convenience"; then
4239a966c04fSmrg	    if test -z "$whole_archive_flag_spec"; then
4240a966c04fSmrg	      $show "${rm}r $gentop"
4241a966c04fSmrg	      $run ${rm}r "$gentop"
4242a966c04fSmrg	    fi
4243a966c04fSmrg	  fi
4244a966c04fSmrg
4245a966c04fSmrg	  exit $EXIT_SUCCESS
4246a966c04fSmrg	fi
4247a966c04fSmrg
4248a966c04fSmrg	# Create links to the real library.
4249a966c04fSmrg	for linkname in $linknames; do
4250a966c04fSmrg	  if test "$realname" != "$linkname"; then
4251a966c04fSmrg	    $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
4252a966c04fSmrg	    $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
4253a966c04fSmrg	  fi
4254a966c04fSmrg	done
4255a966c04fSmrg
4256a966c04fSmrg	# If -module or -export-dynamic was specified, set the dlname.
4257a966c04fSmrg	if test "$module" = yes || test "$export_dynamic" = yes; then
4258a966c04fSmrg	  # On all known operating systems, these are identical.
4259a966c04fSmrg	  dlname="$soname"
4260a966c04fSmrg	fi
4261a966c04fSmrg      fi
4262a966c04fSmrg      ;;
4263a966c04fSmrg
4264a966c04fSmrg    obj)
42652e2dd055Smrg      case " $deplibs" in
42662e2dd055Smrg      *\ -l* | *\ -L*)
42672e2dd055Smrg	$echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 ;;
42682e2dd055Smrg      esac
4269a966c04fSmrg
4270a966c04fSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
4271a966c04fSmrg	$echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
4272a966c04fSmrg      fi
4273a966c04fSmrg
4274a966c04fSmrg      if test -n "$rpath"; then
4275a966c04fSmrg	$echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
4276a966c04fSmrg      fi
4277a966c04fSmrg
4278a966c04fSmrg      if test -n "$xrpath"; then
4279a966c04fSmrg	$echo "$modename: warning: \`-R' is ignored for objects" 1>&2
4280a966c04fSmrg      fi
4281a966c04fSmrg
4282a966c04fSmrg      if test -n "$vinfo"; then
4283a966c04fSmrg	$echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
4284a966c04fSmrg      fi
4285a966c04fSmrg
4286a966c04fSmrg      if test -n "$release"; then
4287a966c04fSmrg	$echo "$modename: warning: \`-release' is ignored for objects" 1>&2
4288a966c04fSmrg      fi
4289a966c04fSmrg
4290a966c04fSmrg      case $output in
4291a966c04fSmrg      *.lo)
4292a966c04fSmrg	if test -n "$objs$old_deplibs"; then
4293a966c04fSmrg	  $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
4294a966c04fSmrg	  exit $EXIT_FAILURE
4295a966c04fSmrg	fi
4296a966c04fSmrg	libobj="$output"
4297a966c04fSmrg	obj=`$echo "X$output" | $Xsed -e "$lo2o"`
4298a966c04fSmrg	;;
4299a966c04fSmrg      *)
4300a966c04fSmrg	libobj=
4301a966c04fSmrg	obj="$output"
4302a966c04fSmrg	;;
4303a966c04fSmrg      esac
4304a966c04fSmrg
4305a966c04fSmrg      # Delete the old objects.
4306a966c04fSmrg      $run $rm $obj $libobj
4307a966c04fSmrg
4308a966c04fSmrg      # Objects from convenience libraries.  This assumes
4309a966c04fSmrg      # single-version convenience libraries.  Whenever we create
4310a966c04fSmrg      # different ones for PIC/non-PIC, this we'll have to duplicate
4311a966c04fSmrg      # the extraction.
4312a966c04fSmrg      reload_conv_objs=
4313a966c04fSmrg      gentop=
4314a966c04fSmrg      # reload_cmds runs $LD directly, so let us get rid of
43152e2dd055Smrg      # -Wl from whole_archive_flag_spec and hope we can get by with
43162e2dd055Smrg      # turning comma into space..
4317a966c04fSmrg      wl=
4318a966c04fSmrg
4319a966c04fSmrg      if test -n "$convenience"; then
4320a966c04fSmrg	if test -n "$whole_archive_flag_spec"; then
43212e2dd055Smrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
43222e2dd055Smrg	  reload_conv_objs=$reload_objs\ `$echo "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
4323a966c04fSmrg	else
4324a966c04fSmrg	  gentop="$output_objdir/${obj}x"
4325a966c04fSmrg	  generated="$generated $gentop"
4326a966c04fSmrg
4327a966c04fSmrg	  func_extract_archives $gentop $convenience
4328a966c04fSmrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
4329a966c04fSmrg	fi
4330a966c04fSmrg      fi
4331a966c04fSmrg
4332a966c04fSmrg      # Create the old-style object.
4333a966c04fSmrg      reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
4334a966c04fSmrg
4335a966c04fSmrg      output="$obj"
4336a966c04fSmrg      cmds=$reload_cmds
4337a966c04fSmrg      save_ifs="$IFS"; IFS='~'
4338a966c04fSmrg      for cmd in $cmds; do
4339a966c04fSmrg	IFS="$save_ifs"
4340a966c04fSmrg	eval cmd=\"$cmd\"
4341a966c04fSmrg	$show "$cmd"
4342a966c04fSmrg	$run eval "$cmd" || exit $?
4343a966c04fSmrg      done
4344a966c04fSmrg      IFS="$save_ifs"
4345a966c04fSmrg
4346a966c04fSmrg      # Exit if we aren't doing a library object file.
4347a966c04fSmrg      if test -z "$libobj"; then
4348a966c04fSmrg	if test -n "$gentop"; then
4349a966c04fSmrg	  $show "${rm}r $gentop"
4350a966c04fSmrg	  $run ${rm}r $gentop
4351a966c04fSmrg	fi
4352a966c04fSmrg
4353a966c04fSmrg	exit $EXIT_SUCCESS
4354a966c04fSmrg      fi
4355a966c04fSmrg
4356a966c04fSmrg      if test "$build_libtool_libs" != yes; then
4357a966c04fSmrg	if test -n "$gentop"; then
4358a966c04fSmrg	  $show "${rm}r $gentop"
4359a966c04fSmrg	  $run ${rm}r $gentop
4360a966c04fSmrg	fi
4361a966c04fSmrg
4362a966c04fSmrg	# Create an invalid libtool object if no PIC, so that we don't
4363a966c04fSmrg	# accidentally link it into a program.
4364a966c04fSmrg	# $show "echo timestamp > $libobj"
4365a966c04fSmrg	# $run eval "echo timestamp > $libobj" || exit $?
4366a966c04fSmrg	exit $EXIT_SUCCESS
4367a966c04fSmrg      fi
4368a966c04fSmrg
4369a966c04fSmrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
4370a966c04fSmrg	# Only do commands if we really have different PIC objects.
4371a966c04fSmrg	reload_objs="$libobjs $reload_conv_objs"
4372a966c04fSmrg	output="$libobj"
4373a966c04fSmrg	cmds=$reload_cmds
4374a966c04fSmrg	save_ifs="$IFS"; IFS='~'
4375a966c04fSmrg	for cmd in $cmds; do
4376a966c04fSmrg	  IFS="$save_ifs"
4377a966c04fSmrg	  eval cmd=\"$cmd\"
4378a966c04fSmrg	  $show "$cmd"
4379a966c04fSmrg	  $run eval "$cmd" || exit $?
4380a966c04fSmrg	done
4381a966c04fSmrg	IFS="$save_ifs"
4382a966c04fSmrg      fi
4383a966c04fSmrg
4384a966c04fSmrg      if test -n "$gentop"; then
4385a966c04fSmrg	$show "${rm}r $gentop"
4386a966c04fSmrg	$run ${rm}r $gentop
4387a966c04fSmrg      fi
4388a966c04fSmrg
4389a966c04fSmrg      exit $EXIT_SUCCESS
4390a966c04fSmrg      ;;
4391a966c04fSmrg
4392a966c04fSmrg    prog)
4393a966c04fSmrg      case $host in
4394a966c04fSmrg	*cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
4395a966c04fSmrg      esac
4396a966c04fSmrg      if test -n "$vinfo"; then
4397a966c04fSmrg	$echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
4398a966c04fSmrg      fi
4399a966c04fSmrg
4400a966c04fSmrg      if test -n "$release"; then
4401a966c04fSmrg	$echo "$modename: warning: \`-release' is ignored for programs" 1>&2
4402a966c04fSmrg      fi
4403a966c04fSmrg
4404a966c04fSmrg      if test "$preload" = yes; then
4405a966c04fSmrg	if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown &&
4406a966c04fSmrg	   test "$dlopen_self_static" = unknown; then
4407a966c04fSmrg	  $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
4408a966c04fSmrg	fi
4409a966c04fSmrg      fi
4410a966c04fSmrg
4411a966c04fSmrg      case $host in
4412a966c04fSmrg      *-*-rhapsody* | *-*-darwin1.[012])
4413a966c04fSmrg	# On Rhapsody replace the C library is the System framework
4414a966c04fSmrg	compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
4415a966c04fSmrg	finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
4416a966c04fSmrg	;;
4417a966c04fSmrg      esac
4418a966c04fSmrg
4419a966c04fSmrg      case $host in
4420a966c04fSmrg      *darwin*)
4421a966c04fSmrg        # Don't allow lazy linking, it breaks C++ global constructors
4422a966c04fSmrg        if test "$tagname" = CXX ; then
4423a966c04fSmrg        compile_command="$compile_command ${wl}-bind_at_load"
4424a966c04fSmrg        finalize_command="$finalize_command ${wl}-bind_at_load"
4425a966c04fSmrg        fi
4426a966c04fSmrg        ;;
4427a966c04fSmrg      esac
4428a966c04fSmrg
4429a966c04fSmrg
4430a966c04fSmrg      # move library search paths that coincide with paths to not yet
4431a966c04fSmrg      # installed libraries to the beginning of the library search list
4432a966c04fSmrg      new_libs=
4433a966c04fSmrg      for path in $notinst_path; do
4434a966c04fSmrg	case " $new_libs " in
4435a966c04fSmrg	*" -L$path/$objdir "*) ;;
4436a966c04fSmrg	*)
4437a966c04fSmrg	  case " $compile_deplibs " in
4438a966c04fSmrg	  *" -L$path/$objdir "*)
4439a966c04fSmrg	    new_libs="$new_libs -L$path/$objdir" ;;
4440a966c04fSmrg	  esac
4441a966c04fSmrg	  ;;
4442a966c04fSmrg	esac
4443a966c04fSmrg      done
4444a966c04fSmrg      for deplib in $compile_deplibs; do
4445a966c04fSmrg	case $deplib in
4446a966c04fSmrg	-L*)
4447a966c04fSmrg	  case " $new_libs " in
4448a966c04fSmrg	  *" $deplib "*) ;;
4449a966c04fSmrg	  *) new_libs="$new_libs $deplib" ;;
4450a966c04fSmrg	  esac
4451a966c04fSmrg	  ;;
4452a966c04fSmrg	*) new_libs="$new_libs $deplib" ;;
4453a966c04fSmrg	esac
4454a966c04fSmrg      done
4455a966c04fSmrg      compile_deplibs="$new_libs"
4456a966c04fSmrg
4457a966c04fSmrg
4458a966c04fSmrg      compile_command="$compile_command $compile_deplibs"
4459a966c04fSmrg      finalize_command="$finalize_command $finalize_deplibs"
4460a966c04fSmrg
4461a966c04fSmrg      if test -n "$rpath$xrpath"; then
4462a966c04fSmrg	# If the user specified any rpath flags, then add them.
4463a966c04fSmrg	for libdir in $rpath $xrpath; do
4464a966c04fSmrg	  # This is the magic to use -rpath.
4465a966c04fSmrg	  case "$finalize_rpath " in
4466a966c04fSmrg	  *" $libdir "*) ;;
4467a966c04fSmrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
4468a966c04fSmrg	  esac
4469a966c04fSmrg	done
4470a966c04fSmrg      fi
4471a966c04fSmrg
4472a966c04fSmrg      # Now hardcode the library paths
4473a966c04fSmrg      rpath=
4474a966c04fSmrg      hardcode_libdirs=
4475a966c04fSmrg      for libdir in $compile_rpath $finalize_rpath; do
4476a966c04fSmrg	if test -n "$hardcode_libdir_flag_spec"; then
4477a966c04fSmrg	  if test -n "$hardcode_libdir_separator"; then
4478a966c04fSmrg	    if test -z "$hardcode_libdirs"; then
4479a966c04fSmrg	      hardcode_libdirs="$libdir"
4480a966c04fSmrg	    else
4481a966c04fSmrg	      # Just accumulate the unique libdirs.
4482a966c04fSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
4483a966c04fSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
4484a966c04fSmrg		;;
4485a966c04fSmrg	      *)
4486a966c04fSmrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
4487a966c04fSmrg		;;
4488a966c04fSmrg	      esac
4489a966c04fSmrg	    fi
4490a966c04fSmrg	  else
4491a966c04fSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
4492a966c04fSmrg	    rpath="$rpath $flag"
4493a966c04fSmrg	  fi
4494a966c04fSmrg	elif test -n "$runpath_var"; then
4495a966c04fSmrg	  case "$perm_rpath " in
4496a966c04fSmrg	  *" $libdir "*) ;;
4497a966c04fSmrg	  *) perm_rpath="$perm_rpath $libdir" ;;
4498a966c04fSmrg	  esac
4499a966c04fSmrg	fi
4500a966c04fSmrg	case $host in
4501a966c04fSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
4502a966c04fSmrg	  testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'`
4503a966c04fSmrg	  case :$dllsearchpath: in
4504a966c04fSmrg	  *":$libdir:"*) ;;
4505a966c04fSmrg	  *) dllsearchpath="$dllsearchpath:$libdir";;
4506a966c04fSmrg	  esac
4507a966c04fSmrg	  case :$dllsearchpath: in
4508a966c04fSmrg	  *":$testbindir:"*) ;;
4509a966c04fSmrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
4510a966c04fSmrg	  esac
4511a966c04fSmrg	  ;;
4512a966c04fSmrg	esac
4513a966c04fSmrg      done
4514a966c04fSmrg      # Substitute the hardcoded libdirs into the rpath.
4515a966c04fSmrg      if test -n "$hardcode_libdir_separator" &&
4516a966c04fSmrg	 test -n "$hardcode_libdirs"; then
4517a966c04fSmrg	libdir="$hardcode_libdirs"
4518a966c04fSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
4519a966c04fSmrg      fi
4520a966c04fSmrg      compile_rpath="$rpath"
4521a966c04fSmrg
4522a966c04fSmrg      rpath=
4523a966c04fSmrg      hardcode_libdirs=
4524a966c04fSmrg      for libdir in $finalize_rpath; do
4525a966c04fSmrg	if test -n "$hardcode_libdir_flag_spec"; then
4526a966c04fSmrg	  if test -n "$hardcode_libdir_separator"; then
4527a966c04fSmrg	    if test -z "$hardcode_libdirs"; then
4528a966c04fSmrg	      hardcode_libdirs="$libdir"
4529a966c04fSmrg	    else
4530a966c04fSmrg	      # Just accumulate the unique libdirs.
4531a966c04fSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
4532a966c04fSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
4533a966c04fSmrg		;;
4534a966c04fSmrg	      *)
4535a966c04fSmrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
4536a966c04fSmrg		;;
4537a966c04fSmrg	      esac
4538a966c04fSmrg	    fi
4539a966c04fSmrg	  else
4540a966c04fSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
4541a966c04fSmrg	    rpath="$rpath $flag"
4542a966c04fSmrg	  fi
4543a966c04fSmrg	elif test -n "$runpath_var"; then
4544a966c04fSmrg	  case "$finalize_perm_rpath " in
4545a966c04fSmrg	  *" $libdir "*) ;;
4546a966c04fSmrg	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
4547a966c04fSmrg	  esac
4548a966c04fSmrg	fi
4549a966c04fSmrg      done
4550a966c04fSmrg      # Substitute the hardcoded libdirs into the rpath.
4551a966c04fSmrg      if test -n "$hardcode_libdir_separator" &&
4552a966c04fSmrg	 test -n "$hardcode_libdirs"; then
4553a966c04fSmrg	libdir="$hardcode_libdirs"
4554a966c04fSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
4555a966c04fSmrg      fi
4556a966c04fSmrg      finalize_rpath="$rpath"
4557a966c04fSmrg
4558a966c04fSmrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
4559a966c04fSmrg	# Transform all the library objects into standard objects.
4560a966c04fSmrg	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
4561a966c04fSmrg	finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
4562a966c04fSmrg      fi
4563a966c04fSmrg
4564a966c04fSmrg      dlsyms=
4565a966c04fSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
4566a966c04fSmrg	if test -n "$NM" && test -n "$global_symbol_pipe"; then
4567a966c04fSmrg	  dlsyms="${outputname}S.c"
4568a966c04fSmrg	else
4569a966c04fSmrg	  $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
4570a966c04fSmrg	fi
4571a966c04fSmrg      fi
4572a966c04fSmrg
4573a966c04fSmrg      if test -n "$dlsyms"; then
4574a966c04fSmrg	case $dlsyms in
4575a966c04fSmrg	"") ;;
4576a966c04fSmrg	*.c)
4577a966c04fSmrg	  # Discover the nlist of each of the dlfiles.
4578a966c04fSmrg	  nlist="$output_objdir/${outputname}.nm"
4579a966c04fSmrg
4580a966c04fSmrg	  $show "$rm $nlist ${nlist}S ${nlist}T"
4581a966c04fSmrg	  $run $rm "$nlist" "${nlist}S" "${nlist}T"
4582a966c04fSmrg
4583a966c04fSmrg	  # Parse the name list into a source file.
4584a966c04fSmrg	  $show "creating $output_objdir/$dlsyms"
4585a966c04fSmrg
4586a966c04fSmrg	  test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
4587a966c04fSmrg/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
4588a966c04fSmrg/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
4589a966c04fSmrg
4590a966c04fSmrg#ifdef __cplusplus
4591a966c04fSmrgextern \"C\" {
4592a966c04fSmrg#endif
4593a966c04fSmrg
4594a966c04fSmrg/* Prevent the only kind of declaration conflicts we can make. */
4595a966c04fSmrg#define lt_preloaded_symbols some_other_symbol
4596a966c04fSmrg
4597a966c04fSmrg/* External symbol declarations for the compiler. */\
4598a966c04fSmrg"
4599a966c04fSmrg
4600a966c04fSmrg	  if test "$dlself" = yes; then
4601a966c04fSmrg	    $show "generating symbol list for \`$output'"
4602a966c04fSmrg
4603a966c04fSmrg	    test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
4604a966c04fSmrg
4605a966c04fSmrg	    # Add our own program objects to the symbol list.
4606a966c04fSmrg	    progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
4607a966c04fSmrg	    for arg in $progfiles; do
4608a966c04fSmrg	      $show "extracting global C symbols from \`$arg'"
4609a966c04fSmrg	      $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
4610a966c04fSmrg	    done
4611a966c04fSmrg
4612a966c04fSmrg	    if test -n "$exclude_expsyms"; then
4613a966c04fSmrg	      $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
4614a966c04fSmrg	      $run eval '$mv "$nlist"T "$nlist"'
4615a966c04fSmrg	    fi
4616a966c04fSmrg
4617a966c04fSmrg	    if test -n "$export_symbols_regex"; then
4618a966c04fSmrg	      $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
4619a966c04fSmrg	      $run eval '$mv "$nlist"T "$nlist"'
4620a966c04fSmrg	    fi
4621a966c04fSmrg
4622a966c04fSmrg	    # Prepare the list of exported symbols
4623a966c04fSmrg	    if test -z "$export_symbols"; then
4624a966c04fSmrg	      export_symbols="$output_objdir/$outputname.exp"
4625a966c04fSmrg	      $run $rm $export_symbols
4626a966c04fSmrg	      $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4627a966c04fSmrg              case $host in
4628a966c04fSmrg              *cygwin* | *mingw* )
4629a966c04fSmrg	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4630a966c04fSmrg		$run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
4631a966c04fSmrg                ;;
4632a966c04fSmrg              esac
4633a966c04fSmrg	    else
4634a966c04fSmrg	      $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4635a966c04fSmrg	      $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
4636a966c04fSmrg	      $run eval 'mv "$nlist"T "$nlist"'
4637a966c04fSmrg              case $host in
4638a966c04fSmrg              *cygwin* | *mingw* )
4639a966c04fSmrg	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4640a966c04fSmrg		$run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
4641a966c04fSmrg                ;;
4642a966c04fSmrg              esac
4643a966c04fSmrg	    fi
4644a966c04fSmrg	  fi
4645a966c04fSmrg
4646a966c04fSmrg	  for arg in $dlprefiles; do
4647a966c04fSmrg	    $show "extracting global C symbols from \`$arg'"
4648a966c04fSmrg	    name=`$echo "$arg" | ${SED} -e 's%^.*/%%'`
4649a966c04fSmrg	    $run eval '$echo ": $name " >> "$nlist"'
4650a966c04fSmrg	    $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
4651a966c04fSmrg	  done
4652a966c04fSmrg
4653a966c04fSmrg	  if test -z "$run"; then
4654a966c04fSmrg	    # Make sure we have at least an empty file.
4655a966c04fSmrg	    test -f "$nlist" || : > "$nlist"
4656a966c04fSmrg
4657a966c04fSmrg	    if test -n "$exclude_expsyms"; then
4658a966c04fSmrg	      $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
4659a966c04fSmrg	      $mv "$nlist"T "$nlist"
4660a966c04fSmrg	    fi
4661a966c04fSmrg
4662a966c04fSmrg	    # Try sorting and uniquifying the output.
4663a966c04fSmrg	    if grep -v "^: " < "$nlist" |
4664a966c04fSmrg		if sort -k 3 </dev/null >/dev/null 2>&1; then
4665a966c04fSmrg		  sort -k 3
4666a966c04fSmrg		else
4667a966c04fSmrg		  sort +2
4668a966c04fSmrg		fi |
4669a966c04fSmrg		uniq > "$nlist"S; then
4670a966c04fSmrg	      :
4671a966c04fSmrg	    else
4672a966c04fSmrg	      grep -v "^: " < "$nlist" > "$nlist"S
4673a966c04fSmrg	    fi
4674a966c04fSmrg
4675a966c04fSmrg	    if test -f "$nlist"S; then
4676a966c04fSmrg	      eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
4677a966c04fSmrg	    else
4678a966c04fSmrg	      $echo '/* NONE */' >> "$output_objdir/$dlsyms"
4679a966c04fSmrg	    fi
4680a966c04fSmrg
4681a966c04fSmrg	    $echo >> "$output_objdir/$dlsyms" "\
4682a966c04fSmrg
4683a966c04fSmrg#undef lt_preloaded_symbols
4684a966c04fSmrg
4685a966c04fSmrg#if defined (__STDC__) && __STDC__
4686a966c04fSmrg# define lt_ptr void *
4687a966c04fSmrg#else
4688a966c04fSmrg# define lt_ptr char *
4689a966c04fSmrg# define const
4690a966c04fSmrg#endif
4691a966c04fSmrg
4692a966c04fSmrg/* The mapping between symbol names and symbols. */
4693a966c04fSmrg"
4694a966c04fSmrg
4695a966c04fSmrg	    case $host in
4696a966c04fSmrg	    *cygwin* | *mingw* )
4697a966c04fSmrg	  $echo >> "$output_objdir/$dlsyms" "\
4698a966c04fSmrg/* DATA imports from DLLs on WIN32 can't be const, because
4699a966c04fSmrg   runtime relocations are performed -- see ld's documentation
4700a966c04fSmrg   on pseudo-relocs */
4701a966c04fSmrgstruct {
4702a966c04fSmrg"
4703a966c04fSmrg	      ;;
4704a966c04fSmrg	    * )
4705a966c04fSmrg	  $echo >> "$output_objdir/$dlsyms" "\
4706a966c04fSmrgconst struct {
4707a966c04fSmrg"
4708a966c04fSmrg	      ;;
4709a966c04fSmrg	    esac
4710a966c04fSmrg
4711a966c04fSmrg
4712a966c04fSmrg	  $echo >> "$output_objdir/$dlsyms" "\
4713a966c04fSmrg  const char *name;
4714a966c04fSmrg  lt_ptr address;
4715a966c04fSmrg}
4716a966c04fSmrglt_preloaded_symbols[] =
4717a966c04fSmrg{\
4718a966c04fSmrg"
4719a966c04fSmrg
4720a966c04fSmrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
4721a966c04fSmrg
4722a966c04fSmrg	    $echo >> "$output_objdir/$dlsyms" "\
4723a966c04fSmrg  {0, (lt_ptr) 0}
4724a966c04fSmrg};
4725a966c04fSmrg
4726a966c04fSmrg/* This works around a problem in FreeBSD linker */
4727a966c04fSmrg#ifdef FREEBSD_WORKAROUND
4728a966c04fSmrgstatic const void *lt_preloaded_setup() {
4729a966c04fSmrg  return lt_preloaded_symbols;
4730a966c04fSmrg}
4731a966c04fSmrg#endif
4732a966c04fSmrg
4733a966c04fSmrg#ifdef __cplusplus
4734a966c04fSmrg}
4735a966c04fSmrg#endif\
4736a966c04fSmrg"
4737a966c04fSmrg	  fi
4738a966c04fSmrg
4739a966c04fSmrg	  pic_flag_for_symtable=
4740a966c04fSmrg	  case $host in
4741a966c04fSmrg	  # compiling the symbol table file with pic_flag works around
4742a966c04fSmrg	  # a FreeBSD bug that causes programs to crash when -lm is
4743a966c04fSmrg	  # linked before any other PIC object.  But we must not use
4744a966c04fSmrg	  # pic_flag when linking with -static.  The problem exists in
4745a966c04fSmrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
4746a966c04fSmrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
4747a966c04fSmrg	    case "$compile_command " in
4748a966c04fSmrg	    *" -static "*) ;;
4749a966c04fSmrg	    *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";;
4750a966c04fSmrg	    esac;;
4751a966c04fSmrg	  *-*-hpux*)
4752a966c04fSmrg	    case "$compile_command " in
4753a966c04fSmrg	    *" -static "*) ;;
4754a966c04fSmrg	    *) pic_flag_for_symtable=" $pic_flag";;
4755a966c04fSmrg	    esac
4756a966c04fSmrg	  esac
4757a966c04fSmrg
4758a966c04fSmrg	  # Now compile the dynamic symbol file.
4759a966c04fSmrg	  $show "(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
4760a966c04fSmrg	  $run eval '(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
4761a966c04fSmrg
4762a966c04fSmrg	  # Clean up the generated files.
4763a966c04fSmrg	  $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
4764a966c04fSmrg	  $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
4765a966c04fSmrg
4766a966c04fSmrg	  # Transform the symbol file into the correct name.
4767a966c04fSmrg          case $host in
4768a966c04fSmrg          *cygwin* | *mingw* )
4769a966c04fSmrg            if test -f "$output_objdir/${outputname}.def" ; then
47702e2dd055Smrg              compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP`
47712e2dd055Smrg              finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP`
4772a966c04fSmrg            else
47732e2dd055Smrg              compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
47742e2dd055Smrg              finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
4775a966c04fSmrg             fi
4776a966c04fSmrg            ;;
4777a966c04fSmrg          * )
47782e2dd055Smrg            compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
47792e2dd055Smrg            finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
4780a966c04fSmrg            ;;
4781a966c04fSmrg          esac
4782a966c04fSmrg	  ;;
4783a966c04fSmrg	*)
4784a966c04fSmrg	  $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
4785a966c04fSmrg	  exit $EXIT_FAILURE
4786a966c04fSmrg	  ;;
4787a966c04fSmrg	esac
4788a966c04fSmrg      else
4789a966c04fSmrg	# We keep going just in case the user didn't refer to
4790a966c04fSmrg	# lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
4791a966c04fSmrg	# really was required.
4792a966c04fSmrg
4793a966c04fSmrg	# Nullify the symbol file.
47942e2dd055Smrg	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP`
47952e2dd055Smrg	finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP`
4796a966c04fSmrg      fi
4797a966c04fSmrg
4798a966c04fSmrg      if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
4799a966c04fSmrg	# Replace the output file specification.
48002e2dd055Smrg	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$output"'%g' | $NL2SP`
4801a966c04fSmrg	link_command="$compile_command$compile_rpath"
4802a966c04fSmrg
4803a966c04fSmrg	# We have no uninstalled library dependencies, so finalize right now.
4804a966c04fSmrg	$show "$link_command"
4805a966c04fSmrg	$run eval "$link_command"
4806a966c04fSmrg	exit_status=$?
4807a966c04fSmrg
4808a966c04fSmrg	# Delete the generated files.
4809a966c04fSmrg	if test -n "$dlsyms"; then
4810a966c04fSmrg	  $show "$rm $output_objdir/${outputname}S.${objext}"
4811a966c04fSmrg	  $run $rm "$output_objdir/${outputname}S.${objext}"
4812a966c04fSmrg	fi
4813a966c04fSmrg
4814a966c04fSmrg	exit $exit_status
4815a966c04fSmrg      fi
4816a966c04fSmrg
4817a966c04fSmrg      if test -n "$shlibpath_var"; then
4818a966c04fSmrg	# We should set the shlibpath_var
4819a966c04fSmrg	rpath=
4820a966c04fSmrg	for dir in $temp_rpath; do
4821a966c04fSmrg	  case $dir in
4822a966c04fSmrg	  [\\/]* | [A-Za-z]:[\\/]*)
4823a966c04fSmrg	    # Absolute path.
4824a966c04fSmrg	    rpath="$rpath$dir:"
4825a966c04fSmrg	    ;;
4826a966c04fSmrg	  *)
4827a966c04fSmrg	    # Relative path: add a thisdir entry.
4828a966c04fSmrg	    rpath="$rpath\$thisdir/$dir:"
4829a966c04fSmrg	    ;;
4830a966c04fSmrg	  esac
4831a966c04fSmrg	done
4832a966c04fSmrg	temp_rpath="$rpath"
4833a966c04fSmrg      fi
4834a966c04fSmrg
4835a966c04fSmrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
4836a966c04fSmrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
4837a966c04fSmrg      fi
4838a966c04fSmrg      if test -n "$finalize_shlibpath"; then
4839a966c04fSmrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
4840a966c04fSmrg      fi
4841a966c04fSmrg
4842a966c04fSmrg      compile_var=
4843a966c04fSmrg      finalize_var=
4844a966c04fSmrg      if test -n "$runpath_var"; then
4845a966c04fSmrg	if test -n "$perm_rpath"; then
4846a966c04fSmrg	  # We should set the runpath_var.
4847a966c04fSmrg	  rpath=
4848a966c04fSmrg	  for dir in $perm_rpath; do
4849a966c04fSmrg	    rpath="$rpath$dir:"
4850a966c04fSmrg	  done
4851a966c04fSmrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
4852a966c04fSmrg	fi
4853a966c04fSmrg	if test -n "$finalize_perm_rpath"; then
4854a966c04fSmrg	  # We should set the runpath_var.
4855a966c04fSmrg	  rpath=
4856a966c04fSmrg	  for dir in $finalize_perm_rpath; do
4857a966c04fSmrg	    rpath="$rpath$dir:"
4858a966c04fSmrg	  done
4859a966c04fSmrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
4860a966c04fSmrg	fi
4861a966c04fSmrg      fi
4862a966c04fSmrg
4863a966c04fSmrg      if test "$no_install" = yes; then
4864a966c04fSmrg	# We don't need to create a wrapper script.
4865a966c04fSmrg	link_command="$compile_var$compile_command$compile_rpath"
4866a966c04fSmrg	# Replace the output file specification.
4867a966c04fSmrg	link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
4868a966c04fSmrg	# Delete the old output file.
4869a966c04fSmrg	$run $rm $output
4870a966c04fSmrg	# Link the executable and exit
4871a966c04fSmrg	$show "$link_command"
4872a966c04fSmrg	$run eval "$link_command" || exit $?
4873a966c04fSmrg	exit $EXIT_SUCCESS
4874a966c04fSmrg      fi
4875a966c04fSmrg
4876a966c04fSmrg      if test "$hardcode_action" = relink; then
4877a966c04fSmrg	# Fast installation is not supported
4878a966c04fSmrg	link_command="$compile_var$compile_command$compile_rpath"
4879a966c04fSmrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
4880a966c04fSmrg
4881a966c04fSmrg	$echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
4882a966c04fSmrg	$echo "$modename: \`$output' will be relinked during installation" 1>&2
4883a966c04fSmrg      else
4884a966c04fSmrg	if test "$fast_install" != no; then
4885a966c04fSmrg	  link_command="$finalize_var$compile_command$finalize_rpath"
4886a966c04fSmrg	  if test "$fast_install" = yes; then
48872e2dd055Smrg	    relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $SP2NL | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g' | $NL2SP`
4888a966c04fSmrg	  else
4889a966c04fSmrg	    # fast_install is set to needless
4890a966c04fSmrg	    relink_command=
4891a966c04fSmrg	  fi
4892a966c04fSmrg	else
4893a966c04fSmrg	  link_command="$compile_var$compile_command$compile_rpath"
4894a966c04fSmrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
4895a966c04fSmrg	fi
4896a966c04fSmrg      fi
4897a966c04fSmrg
4898a966c04fSmrg      # Replace the output file specification.
4899a966c04fSmrg      link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
4900a966c04fSmrg
4901a966c04fSmrg      # Delete the old output files.
4902a966c04fSmrg      $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
4903a966c04fSmrg
4904a966c04fSmrg      $show "$link_command"
4905a966c04fSmrg      $run eval "$link_command" || exit $?
4906a966c04fSmrg
4907a966c04fSmrg      # Now create the wrapper script.
4908a966c04fSmrg      $show "creating $output"
4909a966c04fSmrg
4910a966c04fSmrg      # Quote the relink command for shipping.
4911a966c04fSmrg      if test -n "$relink_command"; then
4912a966c04fSmrg	# Preserve any variables that may affect compiler behavior
4913a966c04fSmrg	for var in $variables_saved_for_relink; do
4914a966c04fSmrg	  if eval test -z \"\${$var+set}\"; then
4915a966c04fSmrg	    relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
4916a966c04fSmrg	  elif eval var_value=\$$var; test -z "$var_value"; then
4917a966c04fSmrg	    relink_command="$var=; export $var; $relink_command"
4918a966c04fSmrg	  else
4919a966c04fSmrg	    var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
4920a966c04fSmrg	    relink_command="$var=\"$var_value\"; export $var; $relink_command"
4921a966c04fSmrg	  fi
4922a966c04fSmrg	done
4923a966c04fSmrg	relink_command="(cd `pwd`; $relink_command)"
49242e2dd055Smrg	relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e "$sed_quote_subst" | $NL2SP`
4925a966c04fSmrg      fi
4926a966c04fSmrg
4927a966c04fSmrg      # Quote $echo for shipping.
4928a966c04fSmrg      if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then
4929a966c04fSmrg	case $progpath in
4930a966c04fSmrg	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
4931a966c04fSmrg	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
4932a966c04fSmrg	esac
4933a966c04fSmrg	qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
4934a966c04fSmrg      else
4935a966c04fSmrg	qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
4936a966c04fSmrg      fi
4937a966c04fSmrg
4938a966c04fSmrg      # Only actually do things if our run command is non-null.
4939a966c04fSmrg      if test -z "$run"; then
4940a966c04fSmrg	# win32 will think the script is a binary if it has
4941a966c04fSmrg	# a .exe suffix, so we strip it off here.
4942a966c04fSmrg	case $output in
4943a966c04fSmrg	  *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;;
4944a966c04fSmrg	esac
4945a966c04fSmrg	# test for cygwin because mv fails w/o .exe extensions
4946a966c04fSmrg	case $host in
4947a966c04fSmrg	  *cygwin*)
4948a966c04fSmrg	    exeext=.exe
4949a966c04fSmrg	    outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;;
4950a966c04fSmrg	  *) exeext= ;;
4951a966c04fSmrg	esac
4952a966c04fSmrg	case $host in
4953a966c04fSmrg	  *cygwin* | *mingw* )
4954a966c04fSmrg            output_name=`basename $output`
4955a966c04fSmrg            output_path=`dirname $output`
4956a966c04fSmrg            cwrappersource="$output_path/$objdir/lt-$output_name.c"
4957a966c04fSmrg            cwrapper="$output_path/$output_name.exe"
4958a966c04fSmrg            $rm $cwrappersource $cwrapper
4959a966c04fSmrg            trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
4960a966c04fSmrg
4961a966c04fSmrg	    cat > $cwrappersource <<EOF
4962a966c04fSmrg
4963a966c04fSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
4964a966c04fSmrg   Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
4965a966c04fSmrg
4966a966c04fSmrg   The $output program cannot be directly executed until all the libtool
4967a966c04fSmrg   libraries that it depends on are installed.
4968a966c04fSmrg
4969a966c04fSmrg   This wrapper executable should never be moved out of the build directory.
4970a966c04fSmrg   If it is, it will not operate correctly.
4971a966c04fSmrg
4972a966c04fSmrg   Currently, it simply execs the wrapper *script* "/bin/sh $output",
4973a966c04fSmrg   but could eventually absorb all of the scripts functionality and
4974a966c04fSmrg   exec $objdir/$outputname directly.
4975a966c04fSmrg*/
4976a966c04fSmrgEOF
4977a966c04fSmrg	    cat >> $cwrappersource<<"EOF"
4978a966c04fSmrg#include <stdio.h>
4979a966c04fSmrg#include <stdlib.h>
4980a966c04fSmrg#include <unistd.h>
4981a966c04fSmrg#include <malloc.h>
4982a966c04fSmrg#include <stdarg.h>
4983a966c04fSmrg#include <assert.h>
4984a966c04fSmrg#include <string.h>
4985a966c04fSmrg#include <ctype.h>
4986a966c04fSmrg#include <sys/stat.h>
4987a966c04fSmrg
4988a966c04fSmrg#if defined(PATH_MAX)
4989a966c04fSmrg# define LT_PATHMAX PATH_MAX
4990a966c04fSmrg#elif defined(MAXPATHLEN)
4991a966c04fSmrg# define LT_PATHMAX MAXPATHLEN
4992a966c04fSmrg#else
4993a966c04fSmrg# define LT_PATHMAX 1024
4994a966c04fSmrg#endif
4995a966c04fSmrg
4996a966c04fSmrg#ifndef DIR_SEPARATOR
4997a966c04fSmrg# define DIR_SEPARATOR '/'
4998a966c04fSmrg# define PATH_SEPARATOR ':'
4999a966c04fSmrg#endif
5000a966c04fSmrg
5001a966c04fSmrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
5002a966c04fSmrg  defined (__OS2__)
5003a966c04fSmrg# define HAVE_DOS_BASED_FILE_SYSTEM
5004a966c04fSmrg# ifndef DIR_SEPARATOR_2
5005a966c04fSmrg#  define DIR_SEPARATOR_2 '\\'
5006a966c04fSmrg# endif
5007a966c04fSmrg# ifndef PATH_SEPARATOR_2
5008a966c04fSmrg#  define PATH_SEPARATOR_2 ';'
5009a966c04fSmrg# endif
5010a966c04fSmrg#endif
5011a966c04fSmrg
5012a966c04fSmrg#ifndef DIR_SEPARATOR_2
5013a966c04fSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
5014a966c04fSmrg#else /* DIR_SEPARATOR_2 */
5015a966c04fSmrg# define IS_DIR_SEPARATOR(ch) \
5016a966c04fSmrg        (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
5017a966c04fSmrg#endif /* DIR_SEPARATOR_2 */
5018a966c04fSmrg
5019a966c04fSmrg#ifndef PATH_SEPARATOR_2
5020a966c04fSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
5021a966c04fSmrg#else /* PATH_SEPARATOR_2 */
5022a966c04fSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
5023a966c04fSmrg#endif /* PATH_SEPARATOR_2 */
5024a966c04fSmrg
5025a966c04fSmrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
5026a966c04fSmrg#define XFREE(stale) do { \
5027a966c04fSmrg  if (stale) { free ((void *) stale); stale = 0; } \
5028a966c04fSmrg} while (0)
5029a966c04fSmrg
5030a966c04fSmrg/* -DDEBUG is fairly common in CFLAGS.  */
5031a966c04fSmrg#undef DEBUG
5032a966c04fSmrg#if defined DEBUGWRAPPER
5033a966c04fSmrg# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
5034a966c04fSmrg#else
5035a966c04fSmrg# define DEBUG(format, ...)
5036a966c04fSmrg#endif
5037a966c04fSmrg
5038a966c04fSmrgconst char *program_name = NULL;
5039a966c04fSmrg
5040a966c04fSmrgvoid * xmalloc (size_t num);
5041a966c04fSmrgchar * xstrdup (const char *string);
5042a966c04fSmrgconst char * base_name (const char *name);
5043a966c04fSmrgchar * find_executable(const char *wrapper);
5044a966c04fSmrgint    check_executable(const char *path);
5045a966c04fSmrgchar * strendzap(char *str, const char *pat);
5046a966c04fSmrgvoid lt_fatal (const char *message, ...);
5047a966c04fSmrg
5048a966c04fSmrgint
5049a966c04fSmrgmain (int argc, char *argv[])
5050a966c04fSmrg{
5051a966c04fSmrg  char **newargz;
5052a966c04fSmrg  int i;
5053a966c04fSmrg
5054a966c04fSmrg  program_name = (char *) xstrdup (base_name (argv[0]));
5055a966c04fSmrg  DEBUG("(main) argv[0]      : %s\n",argv[0]);
5056a966c04fSmrg  DEBUG("(main) program_name : %s\n",program_name);
5057a966c04fSmrg  newargz = XMALLOC(char *, argc+2);
5058a966c04fSmrgEOF
5059a966c04fSmrg
5060a966c04fSmrg            cat >> $cwrappersource <<EOF
5061a966c04fSmrg  newargz[0] = (char *) xstrdup("$SHELL");
5062a966c04fSmrgEOF
5063a966c04fSmrg
5064a966c04fSmrg            cat >> $cwrappersource <<"EOF"
5065a966c04fSmrg  newargz[1] = find_executable(argv[0]);
5066a966c04fSmrg  if (newargz[1] == NULL)
5067a966c04fSmrg    lt_fatal("Couldn't find %s", argv[0]);
5068a966c04fSmrg  DEBUG("(main) found exe at : %s\n",newargz[1]);
5069a966c04fSmrg  /* we know the script has the same name, without the .exe */
5070a966c04fSmrg  /* so make sure newargz[1] doesn't end in .exe */
5071a966c04fSmrg  strendzap(newargz[1],".exe");
5072a966c04fSmrg  for (i = 1; i < argc; i++)
5073a966c04fSmrg    newargz[i+1] = xstrdup(argv[i]);
5074a966c04fSmrg  newargz[argc+1] = NULL;
5075a966c04fSmrg
5076a966c04fSmrg  for (i=0; i<argc+1; i++)
5077a966c04fSmrg  {
5078a966c04fSmrg    DEBUG("(main) newargz[%d]   : %s\n",i,newargz[i]);
5079a966c04fSmrg    ;
5080a966c04fSmrg  }
5081a966c04fSmrg
5082a966c04fSmrgEOF
5083a966c04fSmrg
5084a966c04fSmrg            case $host_os in
5085a966c04fSmrg              mingw*)
5086a966c04fSmrg                cat >> $cwrappersource <<EOF
5087a966c04fSmrg  execv("$SHELL",(char const **)newargz);
5088a966c04fSmrgEOF
5089a966c04fSmrg              ;;
5090a966c04fSmrg              *)
5091a966c04fSmrg                cat >> $cwrappersource <<EOF
5092a966c04fSmrg  execv("$SHELL",newargz);
5093a966c04fSmrgEOF
5094a966c04fSmrg              ;;
5095a966c04fSmrg            esac
5096a966c04fSmrg
5097a966c04fSmrg            cat >> $cwrappersource <<"EOF"
5098a966c04fSmrg  return 127;
5099a966c04fSmrg}
5100a966c04fSmrg
5101a966c04fSmrgvoid *
5102a966c04fSmrgxmalloc (size_t num)
5103a966c04fSmrg{
5104a966c04fSmrg  void * p = (void *) malloc (num);
5105a966c04fSmrg  if (!p)
5106a966c04fSmrg    lt_fatal ("Memory exhausted");
5107a966c04fSmrg
5108a966c04fSmrg  return p;
5109a966c04fSmrg}
5110a966c04fSmrg
5111a966c04fSmrgchar *
5112a966c04fSmrgxstrdup (const char *string)
5113a966c04fSmrg{
5114a966c04fSmrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL
5115a966c04fSmrg;
5116a966c04fSmrg}
5117a966c04fSmrg
5118a966c04fSmrgconst char *
5119a966c04fSmrgbase_name (const char *name)
5120a966c04fSmrg{
5121a966c04fSmrg  const char *base;
5122a966c04fSmrg
5123a966c04fSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5124a966c04fSmrg  /* Skip over the disk name in MSDOS pathnames. */
5125a966c04fSmrg  if (isalpha ((unsigned char)name[0]) && name[1] == ':')
5126a966c04fSmrg    name += 2;
5127a966c04fSmrg#endif
5128a966c04fSmrg
5129a966c04fSmrg  for (base = name; *name; name++)
5130a966c04fSmrg    if (IS_DIR_SEPARATOR (*name))
5131a966c04fSmrg      base = name + 1;
5132a966c04fSmrg  return base;
5133a966c04fSmrg}
5134a966c04fSmrg
5135a966c04fSmrgint
5136a966c04fSmrgcheck_executable(const char * path)
5137a966c04fSmrg{
5138a966c04fSmrg  struct stat st;
5139a966c04fSmrg
5140a966c04fSmrg  DEBUG("(check_executable)  : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
5141a966c04fSmrg  if ((!path) || (!*path))
5142a966c04fSmrg    return 0;
5143a966c04fSmrg
5144a966c04fSmrg  if ((stat (path, &st) >= 0) &&
5145a966c04fSmrg      (
5146a966c04fSmrg        /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
5147a966c04fSmrg#if defined (S_IXOTH)
5148a966c04fSmrg       ((st.st_mode & S_IXOTH) == S_IXOTH) ||
5149a966c04fSmrg#endif
5150a966c04fSmrg#if defined (S_IXGRP)
5151a966c04fSmrg       ((st.st_mode & S_IXGRP) == S_IXGRP) ||
5152a966c04fSmrg#endif
5153a966c04fSmrg       ((st.st_mode & S_IXUSR) == S_IXUSR))
5154a966c04fSmrg      )
5155a966c04fSmrg    return 1;
5156a966c04fSmrg  else
5157a966c04fSmrg    return 0;
5158a966c04fSmrg}
5159a966c04fSmrg
5160a966c04fSmrg/* Searches for the full path of the wrapper.  Returns
5161a966c04fSmrg   newly allocated full path name if found, NULL otherwise */
5162a966c04fSmrgchar *
5163a966c04fSmrgfind_executable (const char* wrapper)
5164a966c04fSmrg{
5165a966c04fSmrg  int has_slash = 0;
5166a966c04fSmrg  const char* p;
5167a966c04fSmrg  const char* p_next;
5168a966c04fSmrg  /* static buffer for getcwd */
5169a966c04fSmrg  char tmp[LT_PATHMAX + 1];
5170a966c04fSmrg  int tmp_len;
5171a966c04fSmrg  char* concat_name;
5172a966c04fSmrg
5173a966c04fSmrg  DEBUG("(find_executable)  : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
5174a966c04fSmrg
5175a966c04fSmrg  if ((wrapper == NULL) || (*wrapper == '\0'))
5176a966c04fSmrg    return NULL;
5177a966c04fSmrg
5178a966c04fSmrg  /* Absolute path? */
5179a966c04fSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5180a966c04fSmrg  if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
5181a966c04fSmrg  {
5182a966c04fSmrg    concat_name = xstrdup (wrapper);
5183a966c04fSmrg    if (check_executable(concat_name))
5184a966c04fSmrg      return concat_name;
5185a966c04fSmrg    XFREE(concat_name);
5186a966c04fSmrg  }
5187a966c04fSmrg  else
5188a966c04fSmrg  {
5189a966c04fSmrg#endif
5190a966c04fSmrg    if (IS_DIR_SEPARATOR (wrapper[0]))
5191a966c04fSmrg    {
5192a966c04fSmrg      concat_name = xstrdup (wrapper);
5193a966c04fSmrg      if (check_executable(concat_name))
5194a966c04fSmrg        return concat_name;
5195a966c04fSmrg      XFREE(concat_name);
5196a966c04fSmrg    }
5197a966c04fSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5198a966c04fSmrg  }
5199a966c04fSmrg#endif
5200a966c04fSmrg
5201a966c04fSmrg  for (p = wrapper; *p; p++)
5202a966c04fSmrg    if (*p == '/')
5203a966c04fSmrg    {
5204a966c04fSmrg      has_slash = 1;
5205a966c04fSmrg      break;
5206a966c04fSmrg    }
5207a966c04fSmrg  if (!has_slash)
5208a966c04fSmrg  {
5209a966c04fSmrg    /* no slashes; search PATH */
5210a966c04fSmrg    const char* path = getenv ("PATH");
5211a966c04fSmrg    if (path != NULL)
5212a966c04fSmrg    {
5213a966c04fSmrg      for (p = path; *p; p = p_next)
5214a966c04fSmrg      {
5215a966c04fSmrg        const char* q;
5216a966c04fSmrg        size_t p_len;
5217a966c04fSmrg        for (q = p; *q; q++)
5218a966c04fSmrg          if (IS_PATH_SEPARATOR(*q))
5219a966c04fSmrg            break;
5220a966c04fSmrg        p_len = q - p;
5221a966c04fSmrg        p_next = (*q == '\0' ? q : q + 1);
5222a966c04fSmrg        if (p_len == 0)
5223a966c04fSmrg        {
5224a966c04fSmrg          /* empty path: current directory */
5225a966c04fSmrg          if (getcwd (tmp, LT_PATHMAX) == NULL)
5226a966c04fSmrg            lt_fatal ("getcwd failed");
5227a966c04fSmrg          tmp_len = strlen(tmp);
5228a966c04fSmrg          concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
5229a966c04fSmrg          memcpy (concat_name, tmp, tmp_len);
5230a966c04fSmrg          concat_name[tmp_len] = '/';
5231a966c04fSmrg          strcpy (concat_name + tmp_len + 1, wrapper);
5232a966c04fSmrg        }
5233a966c04fSmrg        else
5234a966c04fSmrg        {
5235a966c04fSmrg          concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
5236a966c04fSmrg          memcpy (concat_name, p, p_len);
5237a966c04fSmrg          concat_name[p_len] = '/';
5238a966c04fSmrg          strcpy (concat_name + p_len + 1, wrapper);
5239a966c04fSmrg        }
5240a966c04fSmrg        if (check_executable(concat_name))
5241a966c04fSmrg          return concat_name;
5242a966c04fSmrg        XFREE(concat_name);
5243a966c04fSmrg      }
5244a966c04fSmrg    }
5245a966c04fSmrg    /* not found in PATH; assume curdir */
5246a966c04fSmrg  }
5247a966c04fSmrg  /* Relative path | not found in path: prepend cwd */
5248a966c04fSmrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
5249a966c04fSmrg    lt_fatal ("getcwd failed");
5250a966c04fSmrg  tmp_len = strlen(tmp);
5251a966c04fSmrg  concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
5252a966c04fSmrg  memcpy (concat_name, tmp, tmp_len);
5253a966c04fSmrg  concat_name[tmp_len] = '/';
5254a966c04fSmrg  strcpy (concat_name + tmp_len + 1, wrapper);
5255a966c04fSmrg
5256a966c04fSmrg  if (check_executable(concat_name))
5257a966c04fSmrg    return concat_name;
5258a966c04fSmrg  XFREE(concat_name);
5259a966c04fSmrg  return NULL;
5260a966c04fSmrg}
5261a966c04fSmrg
5262a966c04fSmrgchar *
5263a966c04fSmrgstrendzap(char *str, const char *pat)
5264a966c04fSmrg{
5265a966c04fSmrg  size_t len, patlen;
5266a966c04fSmrg
5267a966c04fSmrg  assert(str != NULL);
5268a966c04fSmrg  assert(pat != NULL);
5269a966c04fSmrg
5270a966c04fSmrg  len = strlen(str);
5271a966c04fSmrg  patlen = strlen(pat);
5272a966c04fSmrg
5273a966c04fSmrg  if (patlen <= len)
5274a966c04fSmrg  {
5275a966c04fSmrg    str += len - patlen;
5276a966c04fSmrg    if (strcmp(str, pat) == 0)
5277a966c04fSmrg      *str = '\0';
5278a966c04fSmrg  }
5279a966c04fSmrg  return str;
5280a966c04fSmrg}
5281a966c04fSmrg
5282a966c04fSmrgstatic void
5283a966c04fSmrglt_error_core (int exit_status, const char * mode,
5284a966c04fSmrg          const char * message, va_list ap)
5285a966c04fSmrg{
5286a966c04fSmrg  fprintf (stderr, "%s: %s: ", program_name, mode);
5287a966c04fSmrg  vfprintf (stderr, message, ap);
5288a966c04fSmrg  fprintf (stderr, ".\n");
5289a966c04fSmrg
5290a966c04fSmrg  if (exit_status >= 0)
5291a966c04fSmrg    exit (exit_status);
5292a966c04fSmrg}
5293a966c04fSmrg
5294a966c04fSmrgvoid
5295a966c04fSmrglt_fatal (const char *message, ...)
5296a966c04fSmrg{
5297a966c04fSmrg  va_list ap;
5298a966c04fSmrg  va_start (ap, message);
5299a966c04fSmrg  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
5300a966c04fSmrg  va_end (ap);
5301a966c04fSmrg}
5302a966c04fSmrgEOF
5303a966c04fSmrg          # we should really use a build-platform specific compiler
5304a966c04fSmrg          # here, but OTOH, the wrappers (shell script and this C one)
5305a966c04fSmrg          # are only useful if you want to execute the "real" binary.
5306a966c04fSmrg          # Since the "real" binary is built for $host, then this
5307a966c04fSmrg          # wrapper might as well be built for $host, too.
5308a966c04fSmrg          $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
5309a966c04fSmrg          ;;
5310a966c04fSmrg        esac
5311a966c04fSmrg        $rm $output
5312a966c04fSmrg        trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
5313a966c04fSmrg
5314a966c04fSmrg	$echo > $output "\
5315a966c04fSmrg#! $SHELL
5316a966c04fSmrg
5317a966c04fSmrg# $output - temporary wrapper script for $objdir/$outputname
5318a966c04fSmrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
5319a966c04fSmrg#
5320a966c04fSmrg# The $output program cannot be directly executed until all the libtool
5321a966c04fSmrg# libraries that it depends on are installed.
5322a966c04fSmrg#
5323a966c04fSmrg# This wrapper script should never be moved out of the build directory.
5324a966c04fSmrg# If it is, it will not operate correctly.
5325a966c04fSmrg
5326a966c04fSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
5327a966c04fSmrg# metacharacters that are still active within double-quoted strings.
5328a966c04fSmrgXsed='${SED} -e 1s/^X//'
5329a966c04fSmrgsed_quote_subst='$sed_quote_subst'
5330a966c04fSmrg
53312e2dd055Smrg# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE).
53322e2dd055Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
53332e2dd055Smrg  emulate sh
53342e2dd055Smrg  NULLCMD=:
53352e2dd055Smrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
53362e2dd055Smrg  # is contrary to our usage.  Disable this feature.
53372e2dd055Smrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
53382e2dd055Smrg  setopt NO_GLOB_SUBST
53392e2dd055Smrgelse
53402e2dd055Smrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
53412e2dd055Smrgfi
53422e2dd055SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
53432e2dd055SmrgDUALCASE=1; export DUALCASE # for MKS sh
53442e2dd055Smrg
5345a966c04fSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout
5346a966c04fSmrg# if CDPATH is set.
5347a966c04fSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
5348a966c04fSmrg
5349a966c04fSmrgrelink_command=\"$relink_command\"
5350a966c04fSmrg
5351a966c04fSmrg# This environment variable determines our operation mode.
5352a966c04fSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then
5353a966c04fSmrg  # install mode needs the following variable:
5354a966c04fSmrg  notinst_deplibs='$notinst_deplibs'
5355a966c04fSmrgelse
5356a966c04fSmrg  # When we are sourced in execute mode, \$file and \$echo are already set.
5357a966c04fSmrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
5358a966c04fSmrg    echo=\"$qecho\"
5359a966c04fSmrg    file=\"\$0\"
5360a966c04fSmrg    # Make sure echo works.
5361a966c04fSmrg    if test \"X\$1\" = X--no-reexec; then
5362a966c04fSmrg      # Discard the --no-reexec flag, and continue.
5363a966c04fSmrg      shift
5364a966c04fSmrg    elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
5365a966c04fSmrg      # Yippee, \$echo works!
5366a966c04fSmrg      :
5367a966c04fSmrg    else
5368a966c04fSmrg      # Restart under the correct shell, and then maybe \$echo will work.
5369a966c04fSmrg      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
5370a966c04fSmrg    fi
5371a966c04fSmrg  fi\
5372a966c04fSmrg"
5373a966c04fSmrg	$echo >> $output "\
5374a966c04fSmrg
5375a966c04fSmrg  # Find the directory that this script lives in.
5376a966c04fSmrg  thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
5377a966c04fSmrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
5378a966c04fSmrg
5379a966c04fSmrg  # Follow symbolic links until we get to the real thisdir.
5380a966c04fSmrg  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
5381a966c04fSmrg  while test -n \"\$file\"; do
5382a966c04fSmrg    destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
5383a966c04fSmrg
5384a966c04fSmrg    # If there was a directory component, then change thisdir.
5385a966c04fSmrg    if test \"x\$destdir\" != \"x\$file\"; then
5386a966c04fSmrg      case \"\$destdir\" in
5387a966c04fSmrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
5388a966c04fSmrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
5389a966c04fSmrg      esac
5390a966c04fSmrg    fi
5391a966c04fSmrg
5392a966c04fSmrg    file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
5393a966c04fSmrg    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
5394a966c04fSmrg  done
5395a966c04fSmrg
5396a966c04fSmrg  # Try to get the absolute directory name.
5397a966c04fSmrg  absdir=\`cd \"\$thisdir\" && pwd\`
5398a966c04fSmrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
5399a966c04fSmrg"
5400a966c04fSmrg
5401a966c04fSmrg	if test "$fast_install" = yes; then
5402a966c04fSmrg	  $echo >> $output "\
5403a966c04fSmrg  program=lt-'$outputname'$exeext
5404a966c04fSmrg  progdir=\"\$thisdir/$objdir\"
5405a966c04fSmrg
5406a966c04fSmrg  if test ! -f \"\$progdir/\$program\" || \\
5407a966c04fSmrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
5408a966c04fSmrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
5409a966c04fSmrg
5410a966c04fSmrg    file=\"\$\$-\$program\"
5411a966c04fSmrg
5412a966c04fSmrg    if test ! -d \"\$progdir\"; then
5413a966c04fSmrg      $mkdir \"\$progdir\"
5414a966c04fSmrg    else
5415a966c04fSmrg      $rm \"\$progdir/\$file\"
5416a966c04fSmrg    fi"
5417a966c04fSmrg
5418a966c04fSmrg	  $echo >> $output "\
5419a966c04fSmrg
5420a966c04fSmrg    # relink executable if necessary
5421a966c04fSmrg    if test -n \"\$relink_command\"; then
5422a966c04fSmrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
5423a966c04fSmrg      else
5424a966c04fSmrg	$echo \"\$relink_command_output\" >&2
5425a966c04fSmrg	$rm \"\$progdir/\$file\"
5426a966c04fSmrg	exit $EXIT_FAILURE
5427a966c04fSmrg      fi
5428a966c04fSmrg    fi
5429a966c04fSmrg
5430a966c04fSmrg    $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
5431a966c04fSmrg    { $rm \"\$progdir/\$program\";
5432a966c04fSmrg      $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
5433a966c04fSmrg    $rm \"\$progdir/\$file\"
5434a966c04fSmrg  fi"
5435a966c04fSmrg	else
5436a966c04fSmrg	  $echo >> $output "\
5437a966c04fSmrg  program='$outputname'
5438a966c04fSmrg  progdir=\"\$thisdir/$objdir\"
5439a966c04fSmrg"
5440a966c04fSmrg	fi
5441a966c04fSmrg
5442a966c04fSmrg	$echo >> $output "\
5443a966c04fSmrg
5444a966c04fSmrg  if test -f \"\$progdir/\$program\"; then"
5445a966c04fSmrg
5446a966c04fSmrg	# Export our shlibpath_var if we have one.
5447a966c04fSmrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5448a966c04fSmrg	  $echo >> $output "\
5449a966c04fSmrg    # Add our own library path to $shlibpath_var
5450a966c04fSmrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
5451a966c04fSmrg
5452a966c04fSmrg    # Some systems cannot cope with colon-terminated $shlibpath_var
5453a966c04fSmrg    # The second colon is a workaround for a bug in BeOS R4 sed
5454a966c04fSmrg    $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
5455a966c04fSmrg
5456a966c04fSmrg    export $shlibpath_var
5457a966c04fSmrg"
5458a966c04fSmrg	fi
5459a966c04fSmrg
5460a966c04fSmrg	# fixup the dll searchpath if we need to.
5461a966c04fSmrg	if test -n "$dllsearchpath"; then
5462a966c04fSmrg	  $echo >> $output "\
5463a966c04fSmrg    # Add the dll search path components to the executable PATH
5464a966c04fSmrg    PATH=$dllsearchpath:\$PATH
5465a966c04fSmrg"
5466a966c04fSmrg	fi
5467a966c04fSmrg
5468a966c04fSmrg	$echo >> $output "\
5469a966c04fSmrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
5470a966c04fSmrg      # Run the actual program with our arguments.
5471a966c04fSmrg"
5472a966c04fSmrg	case $host in
5473a966c04fSmrg	# Backslashes separate directories on plain windows
5474a966c04fSmrg	*-*-mingw | *-*-os2*)
5475a966c04fSmrg	  $echo >> $output "\
5476a966c04fSmrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
5477a966c04fSmrg"
5478a966c04fSmrg	  ;;
5479a966c04fSmrg
5480a966c04fSmrg	*)
5481a966c04fSmrg	  $echo >> $output "\
5482a966c04fSmrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
5483a966c04fSmrg"
5484a966c04fSmrg	  ;;
5485a966c04fSmrg	esac
5486a966c04fSmrg	$echo >> $output "\
54872e2dd055Smrg      \$echo \"\$0: cannot exec \$program \$*\"
5488a966c04fSmrg      exit $EXIT_FAILURE
5489a966c04fSmrg    fi
5490a966c04fSmrg  else
5491a966c04fSmrg    # The program doesn't exist.
5492a966c04fSmrg    \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
5493a966c04fSmrg    \$echo \"This script is just a wrapper for \$program.\" 1>&2
5494a966c04fSmrg    $echo \"See the $PACKAGE documentation for more information.\" 1>&2
5495a966c04fSmrg    exit $EXIT_FAILURE
5496a966c04fSmrg  fi
5497a966c04fSmrgfi\
5498a966c04fSmrg"
5499a966c04fSmrg	chmod +x $output
5500a966c04fSmrg      fi
5501a966c04fSmrg      exit $EXIT_SUCCESS
5502a966c04fSmrg      ;;
5503a966c04fSmrg    esac
5504a966c04fSmrg
5505a966c04fSmrg    # See if we need to build an old-fashioned archive.
5506a966c04fSmrg    for oldlib in $oldlibs; do
5507a966c04fSmrg
5508a966c04fSmrg      if test "$build_libtool_libs" = convenience; then
5509a966c04fSmrg	oldobjs="$libobjs_save"
5510a966c04fSmrg	addlibs="$convenience"
5511a966c04fSmrg	build_libtool_libs=no
5512a966c04fSmrg      else
5513a966c04fSmrg	if test "$build_libtool_libs" = module; then
5514a966c04fSmrg	  oldobjs="$libobjs_save"
5515a966c04fSmrg	  build_libtool_libs=no
5516a966c04fSmrg	else
5517a966c04fSmrg	  oldobjs="$old_deplibs $non_pic_objects"
5518a966c04fSmrg	fi
5519a966c04fSmrg	addlibs="$old_convenience"
5520a966c04fSmrg      fi
5521a966c04fSmrg
5522a966c04fSmrg      if test -n "$addlibs"; then
5523a966c04fSmrg	gentop="$output_objdir/${outputname}x"
5524a966c04fSmrg	generated="$generated $gentop"
5525a966c04fSmrg
5526a966c04fSmrg	func_extract_archives $gentop $addlibs
5527a966c04fSmrg	oldobjs="$oldobjs $func_extract_archives_result"
5528a966c04fSmrg      fi
5529a966c04fSmrg
5530a966c04fSmrg      # Do each command in the archive commands.
5531a966c04fSmrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
5532a966c04fSmrg       cmds=$old_archive_from_new_cmds
5533a966c04fSmrg      else
5534a966c04fSmrg	# POSIX demands no paths to be encoded in archives.  We have
5535a966c04fSmrg	# to avoid creating archives with duplicate basenames if we
5536a966c04fSmrg	# might have to extract them afterwards, e.g., when creating a
5537a966c04fSmrg	# static archive out of a convenience library, or when linking
5538a966c04fSmrg	# the entirety of a libtool archive into another (currently
5539a966c04fSmrg	# not supported by libtool).
5540a966c04fSmrg	if (for obj in $oldobjs
5541a966c04fSmrg	    do
5542a966c04fSmrg	      $echo "X$obj" | $Xsed -e 's%^.*/%%'
5543a966c04fSmrg	    done | sort | sort -uc >/dev/null 2>&1); then
5544a966c04fSmrg	  :
5545a966c04fSmrg	else
5546a966c04fSmrg	  $echo "copying selected object files to avoid basename conflicts..."
5547a966c04fSmrg
5548a966c04fSmrg	  if test -z "$gentop"; then
5549a966c04fSmrg	    gentop="$output_objdir/${outputname}x"
5550a966c04fSmrg	    generated="$generated $gentop"
5551a966c04fSmrg
5552a966c04fSmrg	    $show "${rm}r $gentop"
5553a966c04fSmrg	    $run ${rm}r "$gentop"
5554a966c04fSmrg	    $show "$mkdir $gentop"
5555a966c04fSmrg	    $run $mkdir "$gentop"
5556a966c04fSmrg	    exit_status=$?
5557a966c04fSmrg	    if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
5558a966c04fSmrg	      exit $exit_status
5559a966c04fSmrg	    fi
5560a966c04fSmrg	  fi
5561a966c04fSmrg
5562a966c04fSmrg	  save_oldobjs=$oldobjs
5563a966c04fSmrg	  oldobjs=
5564a966c04fSmrg	  counter=1
5565a966c04fSmrg	  for obj in $save_oldobjs
5566a966c04fSmrg	  do
5567a966c04fSmrg	    objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
5568a966c04fSmrg	    case " $oldobjs " in
5569a966c04fSmrg	    " ") oldobjs=$obj ;;
5570a966c04fSmrg	    *[\ /]"$objbase "*)
5571a966c04fSmrg	      while :; do
5572a966c04fSmrg		# Make sure we don't pick an alternate name that also
5573a966c04fSmrg		# overlaps.
5574a966c04fSmrg		newobj=lt$counter-$objbase
5575a966c04fSmrg		counter=`expr $counter + 1`
5576a966c04fSmrg		case " $oldobjs " in
5577a966c04fSmrg		*[\ /]"$newobj "*) ;;
5578a966c04fSmrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
5579a966c04fSmrg		esac
5580a966c04fSmrg	      done
5581a966c04fSmrg	      $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
5582a966c04fSmrg	      $run ln "$obj" "$gentop/$newobj" ||
5583a966c04fSmrg	      $run cp "$obj" "$gentop/$newobj"
5584a966c04fSmrg	      oldobjs="$oldobjs $gentop/$newobj"
5585a966c04fSmrg	      ;;
5586a966c04fSmrg	    *) oldobjs="$oldobjs $obj" ;;
5587a966c04fSmrg	    esac
5588a966c04fSmrg	  done
5589a966c04fSmrg	fi
5590a966c04fSmrg
5591a966c04fSmrg	eval cmds=\"$old_archive_cmds\"
5592a966c04fSmrg
5593a966c04fSmrg	if len=`expr "X$cmds" : ".*"` &&
5594a966c04fSmrg	     test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
5595a966c04fSmrg	  cmds=$old_archive_cmds
5596a966c04fSmrg	else
5597a966c04fSmrg	  # the command line is too long to link in one step, link in parts
5598a966c04fSmrg	  $echo "using piecewise archive linking..."
5599a966c04fSmrg	  save_RANLIB=$RANLIB
5600a966c04fSmrg	  RANLIB=:
5601a966c04fSmrg	  objlist=
5602a966c04fSmrg	  concat_cmds=
5603a966c04fSmrg	  save_oldobjs=$oldobjs
5604a966c04fSmrg
5605a966c04fSmrg	  # Is there a better way of finding the last object in the list?
5606a966c04fSmrg	  for obj in $save_oldobjs
5607a966c04fSmrg	  do
5608a966c04fSmrg	    last_oldobj=$obj
5609a966c04fSmrg	  done
5610a966c04fSmrg	  for obj in $save_oldobjs
5611a966c04fSmrg	  do
5612a966c04fSmrg	    oldobjs="$objlist $obj"
5613a966c04fSmrg	    objlist="$objlist $obj"
5614a966c04fSmrg	    eval test_cmds=\"$old_archive_cmds\"
5615a966c04fSmrg	    if len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
5616a966c04fSmrg	       test "$len" -le "$max_cmd_len"; then
5617a966c04fSmrg	      :
5618a966c04fSmrg	    else
5619a966c04fSmrg	      # the above command should be used before it gets too long
5620a966c04fSmrg	      oldobjs=$objlist
5621a966c04fSmrg	      if test "$obj" = "$last_oldobj" ; then
5622a966c04fSmrg	        RANLIB=$save_RANLIB
5623a966c04fSmrg	      fi
5624a966c04fSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
5625a966c04fSmrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
5626a966c04fSmrg	      objlist=
5627a966c04fSmrg	    fi
5628a966c04fSmrg	  done
5629a966c04fSmrg	  RANLIB=$save_RANLIB
5630a966c04fSmrg	  oldobjs=$objlist
5631a966c04fSmrg	  if test "X$oldobjs" = "X" ; then
5632a966c04fSmrg	    eval cmds=\"\$concat_cmds\"
5633a966c04fSmrg	  else
5634a966c04fSmrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
5635a966c04fSmrg	  fi
5636a966c04fSmrg	fi
5637a966c04fSmrg      fi
5638a966c04fSmrg      save_ifs="$IFS"; IFS='~'
5639a966c04fSmrg      for cmd in $cmds; do
5640a966c04fSmrg        eval cmd=\"$cmd\"
5641a966c04fSmrg	IFS="$save_ifs"
5642a966c04fSmrg	$show "$cmd"
5643a966c04fSmrg	$run eval "$cmd" || exit $?
5644a966c04fSmrg      done
5645a966c04fSmrg      IFS="$save_ifs"
5646a966c04fSmrg    done
5647a966c04fSmrg
5648a966c04fSmrg    if test -n "$generated"; then
5649a966c04fSmrg      $show "${rm}r$generated"
5650a966c04fSmrg      $run ${rm}r$generated
5651a966c04fSmrg    fi
5652a966c04fSmrg
5653a966c04fSmrg    # Now create the libtool archive.
5654a966c04fSmrg    case $output in
5655a966c04fSmrg    *.la)
5656a966c04fSmrg      old_library=
5657a966c04fSmrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
5658a966c04fSmrg      $show "creating $output"
5659a966c04fSmrg
5660a966c04fSmrg      # Preserve any variables that may affect compiler behavior
5661a966c04fSmrg      for var in $variables_saved_for_relink; do
5662a966c04fSmrg	if eval test -z \"\${$var+set}\"; then
5663a966c04fSmrg	  relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
5664a966c04fSmrg	elif eval var_value=\$$var; test -z "$var_value"; then
5665a966c04fSmrg	  relink_command="$var=; export $var; $relink_command"
5666a966c04fSmrg	else
5667a966c04fSmrg	  var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
5668a966c04fSmrg	  relink_command="$var=\"$var_value\"; export $var; $relink_command"
5669a966c04fSmrg	fi
5670a966c04fSmrg      done
5671a966c04fSmrg      # Quote the link command for shipping.
5672a966c04fSmrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
56732e2dd055Smrg      relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e "$sed_quote_subst" | $NL2SP`
5674a966c04fSmrg      if test "$hardcode_automatic" = yes ; then
5675a966c04fSmrg	relink_command=
5676a966c04fSmrg      fi
5677a966c04fSmrg
5678a966c04fSmrg
5679a966c04fSmrg      # Only create the output if not a dry run.
5680a966c04fSmrg      if test -z "$run"; then
5681a966c04fSmrg	for installed in no yes; do
5682a966c04fSmrg	  if test "$installed" = yes; then
5683a966c04fSmrg	    if test -z "$install_libdir"; then
5684a966c04fSmrg	      break
5685a966c04fSmrg	    fi
5686a966c04fSmrg	    output="$output_objdir/$outputname"i
5687a966c04fSmrg	    # Replace all uninstalled libtool libraries with the installed ones
5688a966c04fSmrg	    newdependency_libs=
5689a966c04fSmrg	    for deplib in $dependency_libs; do
5690a966c04fSmrg	      case $deplib in
5691a966c04fSmrg	      *.la)
5692a966c04fSmrg		name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
5693a966c04fSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
5694a966c04fSmrg		if test -z "$libdir"; then
5695a966c04fSmrg		  $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
5696a966c04fSmrg		  exit $EXIT_FAILURE
5697a966c04fSmrg		fi
5698a966c04fSmrg		newdependency_libs="$newdependency_libs $libdir/$name"
5699a966c04fSmrg		;;
5700a966c04fSmrg	      *) newdependency_libs="$newdependency_libs $deplib" ;;
5701a966c04fSmrg	      esac
5702a966c04fSmrg	    done
5703a966c04fSmrg	    dependency_libs="$newdependency_libs"
5704a966c04fSmrg	    newdlfiles=
5705a966c04fSmrg	    for lib in $dlfiles; do
5706a966c04fSmrg	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
5707a966c04fSmrg	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
5708a966c04fSmrg	      if test -z "$libdir"; then
5709a966c04fSmrg		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
5710a966c04fSmrg		exit $EXIT_FAILURE
5711a966c04fSmrg	      fi
5712a966c04fSmrg	      newdlfiles="$newdlfiles $libdir/$name"
5713a966c04fSmrg	    done
5714a966c04fSmrg	    dlfiles="$newdlfiles"
5715a966c04fSmrg	    newdlprefiles=
5716a966c04fSmrg	    for lib in $dlprefiles; do
5717a966c04fSmrg	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
5718a966c04fSmrg	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
5719a966c04fSmrg	      if test -z "$libdir"; then
5720a966c04fSmrg		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
5721a966c04fSmrg		exit $EXIT_FAILURE
5722a966c04fSmrg	      fi
5723a966c04fSmrg	      newdlprefiles="$newdlprefiles $libdir/$name"
5724a966c04fSmrg	    done
5725a966c04fSmrg	    dlprefiles="$newdlprefiles"
5726a966c04fSmrg	  else
5727a966c04fSmrg	    newdlfiles=
5728a966c04fSmrg	    for lib in $dlfiles; do
5729a966c04fSmrg	      case $lib in
5730a966c04fSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
5731a966c04fSmrg		*) abs=`pwd`"/$lib" ;;
5732a966c04fSmrg	      esac
5733a966c04fSmrg	      newdlfiles="$newdlfiles $abs"
5734a966c04fSmrg	    done
5735a966c04fSmrg	    dlfiles="$newdlfiles"
5736a966c04fSmrg	    newdlprefiles=
5737a966c04fSmrg	    for lib in $dlprefiles; do
5738a966c04fSmrg	      case $lib in
5739a966c04fSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
5740a966c04fSmrg		*) abs=`pwd`"/$lib" ;;
5741a966c04fSmrg	      esac
5742a966c04fSmrg	      newdlprefiles="$newdlprefiles $abs"
5743a966c04fSmrg	    done
5744a966c04fSmrg	    dlprefiles="$newdlprefiles"
5745a966c04fSmrg	  fi
5746a966c04fSmrg	  $rm $output
5747a966c04fSmrg	  # place dlname in correct position for cygwin
5748a966c04fSmrg	  tdlname=$dlname
5749a966c04fSmrg	  case $host,$output,$installed,$module,$dlname in
5750a966c04fSmrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
5751a966c04fSmrg	  esac
5752a966c04fSmrg	  $echo > $output "\
5753a966c04fSmrg# $outputname - a libtool library file
5754a966c04fSmrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
5755a966c04fSmrg#
5756a966c04fSmrg# Please DO NOT delete this file!
5757a966c04fSmrg# It is necessary for linking the library.
5758a966c04fSmrg
5759a966c04fSmrg# The name that we can dlopen(3).
5760a966c04fSmrgdlname='$tdlname'
5761a966c04fSmrg
5762a966c04fSmrg# Names of this library.
5763a966c04fSmrglibrary_names='$library_names'
5764a966c04fSmrg
5765a966c04fSmrg# The name of the static archive.
5766a966c04fSmrgold_library='$old_library'
5767a966c04fSmrg
5768a966c04fSmrg# Libraries that this one depends upon.
5769a966c04fSmrgdependency_libs='$dependency_libs'
5770a966c04fSmrg
5771a966c04fSmrg# Version information for $libname.
5772a966c04fSmrgcurrent=$current
5773a966c04fSmrgage=$age
5774a966c04fSmrgrevision=$revision
5775a966c04fSmrg
5776a966c04fSmrg# Is this an already installed library?
5777a966c04fSmrginstalled=$installed
5778a966c04fSmrg
5779a966c04fSmrg# Should we warn about portability when linking against -modules?
5780a966c04fSmrgshouldnotlink=$module
5781a966c04fSmrg
5782a966c04fSmrg# Files to dlopen/dlpreopen
5783a966c04fSmrgdlopen='$dlfiles'
5784a966c04fSmrgdlpreopen='$dlprefiles'
5785a966c04fSmrg
5786a966c04fSmrg# Directory that this library needs to be installed in:
5787a966c04fSmrglibdir='$install_libdir'"
5788a966c04fSmrg	  if test "$installed" = no && test "$need_relink" = yes; then
5789a966c04fSmrg	    $echo >> $output "\
5790a966c04fSmrgrelink_command=\"$relink_command\""
5791a966c04fSmrg	  fi
5792a966c04fSmrg	done
5793a966c04fSmrg      fi
5794a966c04fSmrg
5795a966c04fSmrg      # Do a symbolic link so that the libtool archive can be found in
5796a966c04fSmrg      # LD_LIBRARY_PATH before the program is installed.
5797a966c04fSmrg      $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
5798a966c04fSmrg      $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $?
5799a966c04fSmrg      ;;
5800a966c04fSmrg    esac
5801a966c04fSmrg    exit $EXIT_SUCCESS
5802a966c04fSmrg    ;;
5803a966c04fSmrg
5804a966c04fSmrg  # libtool install mode
5805a966c04fSmrg  install)
5806a966c04fSmrg    modename="$modename: install"
5807a966c04fSmrg
5808a966c04fSmrg    # There may be an optional sh(1) argument at the beginning of
5809a966c04fSmrg    # install_prog (especially on Windows NT).
5810a966c04fSmrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
5811a966c04fSmrg       # Allow the use of GNU shtool's install command.
5812a966c04fSmrg       $echo "X$nonopt" | grep shtool > /dev/null; then
5813a966c04fSmrg      # Aesthetically quote it.
5814a966c04fSmrg      arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
5815a966c04fSmrg      case $arg in
5816a966c04fSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
5817a966c04fSmrg	arg="\"$arg\""
5818a966c04fSmrg	;;
5819a966c04fSmrg      esac
5820a966c04fSmrg      install_prog="$arg "
5821a966c04fSmrg      arg="$1"
5822a966c04fSmrg      shift
5823a966c04fSmrg    else
5824a966c04fSmrg      install_prog=
5825a966c04fSmrg      arg=$nonopt
5826a966c04fSmrg    fi
5827a966c04fSmrg
5828a966c04fSmrg    # The real first argument should be the name of the installation program.
5829a966c04fSmrg    # Aesthetically quote it.
5830a966c04fSmrg    arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
5831a966c04fSmrg    case $arg in
5832a966c04fSmrg    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
5833a966c04fSmrg      arg="\"$arg\""
5834a966c04fSmrg      ;;
5835a966c04fSmrg    esac
5836a966c04fSmrg    install_prog="$install_prog$arg"
5837a966c04fSmrg
5838a966c04fSmrg    # We need to accept at least all the BSD install flags.
5839a966c04fSmrg    dest=
5840a966c04fSmrg    files=
5841a966c04fSmrg    opts=
5842a966c04fSmrg    prev=
5843a966c04fSmrg    install_type=
5844a966c04fSmrg    isdir=no
5845a966c04fSmrg    stripme=
5846a966c04fSmrg    for arg
5847a966c04fSmrg    do
5848a966c04fSmrg      if test -n "$dest"; then
5849a966c04fSmrg	files="$files $dest"
5850a966c04fSmrg	dest=$arg
5851a966c04fSmrg	continue
5852a966c04fSmrg      fi
5853a966c04fSmrg
5854a966c04fSmrg      case $arg in
5855a966c04fSmrg      -d) isdir=yes ;;
5856a966c04fSmrg      -f) 
5857a966c04fSmrg      	case " $install_prog " in
5858a966c04fSmrg	*[\\\ /]cp\ *) ;;
5859a966c04fSmrg	*) prev=$arg ;;
5860a966c04fSmrg	esac
5861a966c04fSmrg	;;
5862a966c04fSmrg      -g | -m | -o) prev=$arg ;;
5863a966c04fSmrg      -s)
5864a966c04fSmrg	stripme=" -s"
5865a966c04fSmrg	continue
5866a966c04fSmrg	;;
5867a966c04fSmrg      -*)
5868a966c04fSmrg	;;
5869a966c04fSmrg      *)
5870a966c04fSmrg	# If the previous option needed an argument, then skip it.
5871a966c04fSmrg	if test -n "$prev"; then
5872a966c04fSmrg	  prev=
5873a966c04fSmrg	else
5874a966c04fSmrg	  dest=$arg
5875a966c04fSmrg	  continue
5876a966c04fSmrg	fi
5877a966c04fSmrg	;;
5878a966c04fSmrg      esac
5879a966c04fSmrg
5880a966c04fSmrg      # Aesthetically quote the argument.
5881a966c04fSmrg      arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
5882a966c04fSmrg      case $arg in
5883a966c04fSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
5884a966c04fSmrg	arg="\"$arg\""
5885a966c04fSmrg	;;
5886a966c04fSmrg      esac
5887a966c04fSmrg      install_prog="$install_prog $arg"
5888a966c04fSmrg    done
5889a966c04fSmrg
5890a966c04fSmrg    if test -z "$install_prog"; then
5891a966c04fSmrg      $echo "$modename: you must specify an install program" 1>&2
5892a966c04fSmrg      $echo "$help" 1>&2
5893a966c04fSmrg      exit $EXIT_FAILURE
5894a966c04fSmrg    fi
5895a966c04fSmrg
5896a966c04fSmrg    if test -n "$prev"; then
5897a966c04fSmrg      $echo "$modename: the \`$prev' option requires an argument" 1>&2
5898a966c04fSmrg      $echo "$help" 1>&2
5899a966c04fSmrg      exit $EXIT_FAILURE
5900a966c04fSmrg    fi
5901a966c04fSmrg
5902a966c04fSmrg    if test -z "$files"; then
5903a966c04fSmrg      if test -z "$dest"; then
5904a966c04fSmrg	$echo "$modename: no file or destination specified" 1>&2
5905a966c04fSmrg      else
5906a966c04fSmrg	$echo "$modename: you must specify a destination" 1>&2
5907a966c04fSmrg      fi
5908a966c04fSmrg      $echo "$help" 1>&2
5909a966c04fSmrg      exit $EXIT_FAILURE
5910a966c04fSmrg    fi
5911a966c04fSmrg
5912a966c04fSmrg    # Strip any trailing slash from the destination.
5913a966c04fSmrg    dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
5914a966c04fSmrg
5915a966c04fSmrg    # Check to see that the destination is a directory.
5916a966c04fSmrg    test -d "$dest" && isdir=yes
5917a966c04fSmrg    if test "$isdir" = yes; then
5918a966c04fSmrg      destdir="$dest"
5919a966c04fSmrg      destname=
5920a966c04fSmrg    else
5921a966c04fSmrg      destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
5922a966c04fSmrg      test "X$destdir" = "X$dest" && destdir=.
5923a966c04fSmrg      destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
5924a966c04fSmrg
5925a966c04fSmrg      # Not a directory, so check to see that there is only one file specified.
5926a966c04fSmrg      set dummy $files
5927a966c04fSmrg      if test "$#" -gt 2; then
5928a966c04fSmrg	$echo "$modename: \`$dest' is not a directory" 1>&2
5929a966c04fSmrg	$echo "$help" 1>&2
5930a966c04fSmrg	exit $EXIT_FAILURE
5931a966c04fSmrg      fi
5932a966c04fSmrg    fi
5933a966c04fSmrg    case $destdir in
5934a966c04fSmrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
5935a966c04fSmrg    *)
5936a966c04fSmrg      for file in $files; do
5937a966c04fSmrg	case $file in
5938a966c04fSmrg	*.lo) ;;
5939a966c04fSmrg	*)
5940a966c04fSmrg	  $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
5941a966c04fSmrg	  $echo "$help" 1>&2
5942a966c04fSmrg	  exit $EXIT_FAILURE
5943a966c04fSmrg	  ;;
5944a966c04fSmrg	esac
5945a966c04fSmrg      done
5946a966c04fSmrg      ;;
5947a966c04fSmrg    esac
5948a966c04fSmrg
5949a966c04fSmrg    # This variable tells wrapper scripts just to set variables rather
5950a966c04fSmrg    # than running their programs.
5951a966c04fSmrg    libtool_install_magic="$magic"
5952a966c04fSmrg
5953a966c04fSmrg    staticlibs=
5954a966c04fSmrg    future_libdirs=
5955a966c04fSmrg    current_libdirs=
5956a966c04fSmrg    for file in $files; do
5957a966c04fSmrg
5958a966c04fSmrg      # Do each installation.
5959a966c04fSmrg      case $file in
5960a966c04fSmrg      *.$libext)
5961a966c04fSmrg	# Do the static libraries later.
5962a966c04fSmrg	staticlibs="$staticlibs $file"
5963a966c04fSmrg	;;
5964a966c04fSmrg
5965a966c04fSmrg      *.la)
5966a966c04fSmrg	# Check to see that this really is a libtool archive.
5967a966c04fSmrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
5968a966c04fSmrg	else
5969a966c04fSmrg	  $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
5970a966c04fSmrg	  $echo "$help" 1>&2
5971a966c04fSmrg	  exit $EXIT_FAILURE
5972a966c04fSmrg	fi
5973a966c04fSmrg
5974a966c04fSmrg	library_names=
5975a966c04fSmrg	old_library=
5976a966c04fSmrg	relink_command=
5977a966c04fSmrg	# If there is no directory component, then add one.
5978a966c04fSmrg	case $file in
5979a966c04fSmrg	*/* | *\\*) . $file ;;
5980a966c04fSmrg	*) . ./$file ;;
5981a966c04fSmrg	esac
5982a966c04fSmrg
5983a966c04fSmrg	# Add the libdir to current_libdirs if it is the destination.
5984a966c04fSmrg	if test "X$destdir" = "X$libdir"; then
5985a966c04fSmrg	  case "$current_libdirs " in
5986a966c04fSmrg	  *" $libdir "*) ;;
5987a966c04fSmrg	  *) current_libdirs="$current_libdirs $libdir" ;;
5988a966c04fSmrg	  esac
5989a966c04fSmrg	else
5990a966c04fSmrg	  # Note the libdir as a future libdir.
5991a966c04fSmrg	  case "$future_libdirs " in
5992a966c04fSmrg	  *" $libdir "*) ;;
5993a966c04fSmrg	  *) future_libdirs="$future_libdirs $libdir" ;;
5994a966c04fSmrg	  esac
5995a966c04fSmrg	fi
5996a966c04fSmrg
5997a966c04fSmrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/
5998a966c04fSmrg	test "X$dir" = "X$file/" && dir=
5999a966c04fSmrg	dir="$dir$objdir"
6000a966c04fSmrg
6001a966c04fSmrg	if test -n "$relink_command"; then
6002a966c04fSmrg	  # Determine the prefix the user has applied to our future dir.
6003a966c04fSmrg	  inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"`
6004a966c04fSmrg
6005a966c04fSmrg	  # Don't allow the user to place us outside of our expected
6006a966c04fSmrg	  # location b/c this prevents finding dependent libraries that
6007a966c04fSmrg	  # are installed to the same prefix.
6008a966c04fSmrg	  # At present, this check doesn't affect windows .dll's that
6009a966c04fSmrg	  # are installed into $libdir/../bin (currently, that works fine)
6010a966c04fSmrg	  # but it's something to keep an eye on.
6011a966c04fSmrg	  if test "$inst_prefix_dir" = "$destdir"; then
6012a966c04fSmrg	    $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
6013a966c04fSmrg	    exit $EXIT_FAILURE
6014a966c04fSmrg	  fi
6015a966c04fSmrg
6016a966c04fSmrg	  if test -n "$inst_prefix_dir"; then
6017a966c04fSmrg	    # Stick the inst_prefix_dir data into the link command.
60182e2dd055Smrg	    relink_command=`$echo "$relink_command" | $SP2NL | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%" | $NL2SP`
6019a966c04fSmrg	  else
60202e2dd055Smrg	    relink_command=`$echo "$relink_command" | $SP2NL | $SED "s%@inst_prefix_dir@%%" | $NL2SP`
6021a966c04fSmrg	  fi
6022a966c04fSmrg
6023a966c04fSmrg	  $echo "$modename: warning: relinking \`$file'" 1>&2
6024a966c04fSmrg	  $show "$relink_command"
6025a966c04fSmrg	  if $run eval "$relink_command"; then :
6026a966c04fSmrg	  else
6027a966c04fSmrg	    $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
6028a966c04fSmrg	    exit $EXIT_FAILURE
6029a966c04fSmrg	  fi
6030a966c04fSmrg	fi
6031a966c04fSmrg
6032a966c04fSmrg	# See the names of the shared library.
6033a966c04fSmrg	set dummy $library_names
6034a966c04fSmrg	if test -n "$2"; then
6035a966c04fSmrg	  realname="$2"
6036a966c04fSmrg	  shift
6037a966c04fSmrg	  shift
6038a966c04fSmrg
6039a966c04fSmrg	  srcname="$realname"
6040a966c04fSmrg	  test -n "$relink_command" && srcname="$realname"T
6041a966c04fSmrg
6042a966c04fSmrg	  # Install the shared library and build the symlinks.
6043a966c04fSmrg	  $show "$install_prog $dir/$srcname $destdir/$realname"
6044a966c04fSmrg	  $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $?
6045a966c04fSmrg	  if test -n "$stripme" && test -n "$striplib"; then
6046a966c04fSmrg	    $show "$striplib $destdir/$realname"
6047a966c04fSmrg	    $run eval "$striplib $destdir/$realname" || exit $?
6048a966c04fSmrg	  fi
6049a966c04fSmrg
6050a966c04fSmrg	  if test "$#" -gt 0; then
6051a966c04fSmrg	    # Delete the old symlinks, and create new ones.
6052a966c04fSmrg	    # Try `ln -sf' first, because the `ln' binary might depend on
6053a966c04fSmrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
6054a966c04fSmrg	    # so we also need to try rm && ln -s.
6055a966c04fSmrg	    for linkname
6056a966c04fSmrg	    do
6057a966c04fSmrg	      if test "$linkname" != "$realname"; then
6058a966c04fSmrg                $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
6059a966c04fSmrg                $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
6060a966c04fSmrg	      fi
6061a966c04fSmrg	    done
6062a966c04fSmrg	  fi
6063a966c04fSmrg
6064a966c04fSmrg	  # Do each command in the postinstall commands.
6065a966c04fSmrg	  lib="$destdir/$realname"
6066a966c04fSmrg	  cmds=$postinstall_cmds
6067a966c04fSmrg	  save_ifs="$IFS"; IFS='~'
6068a966c04fSmrg	  for cmd in $cmds; do
6069a966c04fSmrg	    IFS="$save_ifs"
6070a966c04fSmrg	    eval cmd=\"$cmd\"
6071a966c04fSmrg	    $show "$cmd"
6072a966c04fSmrg	    $run eval "$cmd" || {
6073a966c04fSmrg	      lt_exit=$?
6074a966c04fSmrg
6075a966c04fSmrg	      # Restore the uninstalled library and exit
6076a966c04fSmrg	      if test "$mode" = relink; then
6077a966c04fSmrg		$run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
6078a966c04fSmrg	      fi
6079a966c04fSmrg
6080a966c04fSmrg	      exit $lt_exit
6081a966c04fSmrg	    }
6082a966c04fSmrg	  done
6083a966c04fSmrg	  IFS="$save_ifs"
6084a966c04fSmrg	fi
6085a966c04fSmrg
6086a966c04fSmrg	# Install the pseudo-library for information purposes.
6087a966c04fSmrg	name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
6088a966c04fSmrg	instname="$dir/$name"i
6089a966c04fSmrg	$show "$install_prog $instname $destdir/$name"
6090a966c04fSmrg	$run eval "$install_prog $instname $destdir/$name" || exit $?
6091a966c04fSmrg
6092a966c04fSmrg	# Maybe install the static library, too.
6093a966c04fSmrg	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
6094a966c04fSmrg	;;
6095a966c04fSmrg
6096a966c04fSmrg      *.lo)
6097a966c04fSmrg	# Install (i.e. copy) a libtool object.
6098a966c04fSmrg
6099a966c04fSmrg	# Figure out destination file name, if it wasn't already specified.
6100a966c04fSmrg	if test -n "$destname"; then
6101a966c04fSmrg	  destfile="$destdir/$destname"
6102a966c04fSmrg	else
6103a966c04fSmrg	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
6104a966c04fSmrg	  destfile="$destdir/$destfile"
6105a966c04fSmrg	fi
6106a966c04fSmrg
6107a966c04fSmrg	# Deduce the name of the destination old-style object file.
6108a966c04fSmrg	case $destfile in
6109a966c04fSmrg	*.lo)
6110a966c04fSmrg	  staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
6111a966c04fSmrg	  ;;
6112a966c04fSmrg	*.$objext)
6113a966c04fSmrg	  staticdest="$destfile"
6114a966c04fSmrg	  destfile=
6115a966c04fSmrg	  ;;
6116a966c04fSmrg	*)
6117a966c04fSmrg	  $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
6118a966c04fSmrg	  $echo "$help" 1>&2
6119a966c04fSmrg	  exit $EXIT_FAILURE
6120a966c04fSmrg	  ;;
6121a966c04fSmrg	esac
6122a966c04fSmrg
6123a966c04fSmrg	# Install the libtool object if requested.
6124a966c04fSmrg	if test -n "$destfile"; then
6125a966c04fSmrg	  $show "$install_prog $file $destfile"
6126a966c04fSmrg	  $run eval "$install_prog $file $destfile" || exit $?
6127a966c04fSmrg	fi
6128a966c04fSmrg
6129a966c04fSmrg	# Install the old object if enabled.
6130a966c04fSmrg	if test "$build_old_libs" = yes; then
6131a966c04fSmrg	  # Deduce the name of the old-style object file.
6132a966c04fSmrg	  staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
6133a966c04fSmrg
6134a966c04fSmrg	  $show "$install_prog $staticobj $staticdest"
6135a966c04fSmrg	  $run eval "$install_prog \$staticobj \$staticdest" || exit $?
6136a966c04fSmrg	fi
6137a966c04fSmrg	exit $EXIT_SUCCESS
6138a966c04fSmrg	;;
6139a966c04fSmrg
6140a966c04fSmrg      *)
6141a966c04fSmrg	# Figure out destination file name, if it wasn't already specified.
6142a966c04fSmrg	if test -n "$destname"; then
6143a966c04fSmrg	  destfile="$destdir/$destname"
6144a966c04fSmrg	else
6145a966c04fSmrg	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
6146a966c04fSmrg	  destfile="$destdir/$destfile"
6147a966c04fSmrg	fi
6148a966c04fSmrg
6149a966c04fSmrg	# If the file is missing, and there is a .exe on the end, strip it
6150a966c04fSmrg	# because it is most likely a libtool script we actually want to
6151a966c04fSmrg	# install
6152a966c04fSmrg	stripped_ext=""
6153a966c04fSmrg	case $file in
6154a966c04fSmrg	  *.exe)
6155a966c04fSmrg	    if test ! -f "$file"; then
6156a966c04fSmrg	      file=`$echo $file|${SED} 's,.exe$,,'`
6157a966c04fSmrg	      stripped_ext=".exe"
6158a966c04fSmrg	    fi
6159a966c04fSmrg	    ;;
6160a966c04fSmrg	esac
6161a966c04fSmrg
6162a966c04fSmrg	# Do a test to see if this is really a libtool program.
6163a966c04fSmrg	case $host in
6164a966c04fSmrg	*cygwin*|*mingw*)
6165a966c04fSmrg	    wrapper=`$echo $file | ${SED} -e 's,.exe$,,'`
6166a966c04fSmrg	    ;;
6167a966c04fSmrg	*)
6168a966c04fSmrg	    wrapper=$file
6169a966c04fSmrg	    ;;
6170a966c04fSmrg	esac
6171a966c04fSmrg	if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then
6172a966c04fSmrg	  notinst_deplibs=
6173a966c04fSmrg	  relink_command=
6174a966c04fSmrg
6175a966c04fSmrg	  # Note that it is not necessary on cygwin/mingw to append a dot to
6176a966c04fSmrg	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
6177a966c04fSmrg	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
6178a966c04fSmrg	  # `FILE.' does not work on cygwin managed mounts.
6179a966c04fSmrg	  #
6180a966c04fSmrg	  # If there is no directory component, then add one.
6181a966c04fSmrg	  case $wrapper in
6182a966c04fSmrg	  */* | *\\*) . ${wrapper} ;;
6183a966c04fSmrg	  *) . ./${wrapper} ;;
6184a966c04fSmrg	  esac
6185a966c04fSmrg
6186a966c04fSmrg	  # Check the variables that should have been set.
6187a966c04fSmrg	  if test -z "$notinst_deplibs"; then
6188a966c04fSmrg	    $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2
6189a966c04fSmrg	    exit $EXIT_FAILURE
6190a966c04fSmrg	  fi
6191a966c04fSmrg
6192a966c04fSmrg	  finalize=yes
6193a966c04fSmrg	  for lib in $notinst_deplibs; do
6194a966c04fSmrg	    # Check to see that each library is installed.
6195a966c04fSmrg	    libdir=
6196a966c04fSmrg	    if test -f "$lib"; then
6197a966c04fSmrg	      # If there is no directory component, then add one.
6198a966c04fSmrg	      case $lib in
6199a966c04fSmrg	      */* | *\\*) . $lib ;;
6200a966c04fSmrg	      *) . ./$lib ;;
6201a966c04fSmrg	      esac
6202a966c04fSmrg	    fi
6203a966c04fSmrg	    libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
6204a966c04fSmrg	    if test -n "$libdir" && test ! -f "$libfile"; then
6205a966c04fSmrg	      $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
6206a966c04fSmrg	      finalize=no
6207a966c04fSmrg	    fi
6208a966c04fSmrg	  done
6209a966c04fSmrg
6210a966c04fSmrg	  relink_command=
6211a966c04fSmrg	  # Note that it is not necessary on cygwin/mingw to append a dot to
6212a966c04fSmrg	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
6213a966c04fSmrg	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
6214a966c04fSmrg	  # `FILE.' does not work on cygwin managed mounts.
6215a966c04fSmrg	  #
6216a966c04fSmrg	  # If there is no directory component, then add one.
6217a966c04fSmrg	  case $wrapper in
6218a966c04fSmrg	  */* | *\\*) . ${wrapper} ;;
6219a966c04fSmrg	  *) . ./${wrapper} ;;
6220a966c04fSmrg	  esac
6221a966c04fSmrg
6222a966c04fSmrg	  outputname=
6223a966c04fSmrg	  if test "$fast_install" = no && test -n "$relink_command"; then
6224a966c04fSmrg	    if test "$finalize" = yes && test -z "$run"; then
6225a966c04fSmrg	      tmpdir=`func_mktempdir`
6226a966c04fSmrg	      file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
6227a966c04fSmrg	      outputname="$tmpdir/$file"
6228a966c04fSmrg	      # Replace the output file specification.
62292e2dd055Smrg	      relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g' | $NL2SP`
6230a966c04fSmrg
6231a966c04fSmrg	      $show "$relink_command"
6232a966c04fSmrg	      if $run eval "$relink_command"; then :
6233a966c04fSmrg	      else
6234a966c04fSmrg		$echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
6235a966c04fSmrg		${rm}r "$tmpdir"
6236a966c04fSmrg		continue
6237a966c04fSmrg	      fi
6238a966c04fSmrg	      file="$outputname"
6239a966c04fSmrg	    else
6240a966c04fSmrg	      $echo "$modename: warning: cannot relink \`$file'" 1>&2
6241a966c04fSmrg	    fi
6242a966c04fSmrg	  else
6243a966c04fSmrg	    # Install the binary that we compiled earlier.
6244a966c04fSmrg	    file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
6245a966c04fSmrg	  fi
6246a966c04fSmrg	fi
6247a966c04fSmrg
6248a966c04fSmrg	# remove .exe since cygwin /usr/bin/install will append another
6249a966c04fSmrg	# one anyway 
6250a966c04fSmrg	case $install_prog,$host in
6251a966c04fSmrg	*/usr/bin/install*,*cygwin*)
6252a966c04fSmrg	  case $file:$destfile in
6253a966c04fSmrg	  *.exe:*.exe)
6254a966c04fSmrg	    # this is ok
6255a966c04fSmrg	    ;;
6256a966c04fSmrg	  *.exe:*)
6257a966c04fSmrg	    destfile=$destfile.exe
6258a966c04fSmrg	    ;;
6259a966c04fSmrg	  *:*.exe)
6260a966c04fSmrg	    destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'`
6261a966c04fSmrg	    ;;
6262a966c04fSmrg	  esac
6263a966c04fSmrg	  ;;
6264a966c04fSmrg	esac
6265a966c04fSmrg	$show "$install_prog$stripme $file $destfile"
6266a966c04fSmrg	$run eval "$install_prog\$stripme \$file \$destfile" || exit $?
6267a966c04fSmrg	test -n "$outputname" && ${rm}r "$tmpdir"
6268a966c04fSmrg	;;
6269a966c04fSmrg      esac
6270a966c04fSmrg    done
6271a966c04fSmrg
6272a966c04fSmrg    for file in $staticlibs; do
6273a966c04fSmrg      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
6274a966c04fSmrg
6275a966c04fSmrg      # Set up the ranlib parameters.
6276a966c04fSmrg      oldlib="$destdir/$name"
6277a966c04fSmrg
6278a966c04fSmrg      $show "$install_prog $file $oldlib"
6279a966c04fSmrg      $run eval "$install_prog \$file \$oldlib" || exit $?
6280a966c04fSmrg
6281a966c04fSmrg      if test -n "$stripme" && test -n "$old_striplib"; then
6282a966c04fSmrg	$show "$old_striplib $oldlib"
6283a966c04fSmrg	$run eval "$old_striplib $oldlib" || exit $?
6284a966c04fSmrg      fi
6285a966c04fSmrg
6286a966c04fSmrg      # Do each command in the postinstall commands.
6287a966c04fSmrg      cmds=$old_postinstall_cmds
6288a966c04fSmrg      save_ifs="$IFS"; IFS='~'
6289a966c04fSmrg      for cmd in $cmds; do
6290a966c04fSmrg	IFS="$save_ifs"
6291a966c04fSmrg	eval cmd=\"$cmd\"
6292a966c04fSmrg	$show "$cmd"
6293a966c04fSmrg	$run eval "$cmd" || exit $?
6294a966c04fSmrg      done
6295a966c04fSmrg      IFS="$save_ifs"
6296a966c04fSmrg    done
6297a966c04fSmrg
6298a966c04fSmrg    if test -n "$future_libdirs"; then
6299a966c04fSmrg      $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
6300a966c04fSmrg    fi
6301a966c04fSmrg
6302a966c04fSmrg    if test -n "$current_libdirs"; then
6303a966c04fSmrg      # Maybe just do a dry run.
6304a966c04fSmrg      test -n "$run" && current_libdirs=" -n$current_libdirs"
6305a966c04fSmrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
6306a966c04fSmrg    else
6307a966c04fSmrg      exit $EXIT_SUCCESS
6308a966c04fSmrg    fi
6309a966c04fSmrg    ;;
6310a966c04fSmrg
6311a966c04fSmrg  # libtool finish mode
6312a966c04fSmrg  finish)
6313a966c04fSmrg    modename="$modename: finish"
6314a966c04fSmrg    libdirs="$nonopt"
6315a966c04fSmrg    admincmds=
6316a966c04fSmrg
6317a966c04fSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
6318a966c04fSmrg      for dir
6319a966c04fSmrg      do
6320a966c04fSmrg	libdirs="$libdirs $dir"
6321a966c04fSmrg      done
6322a966c04fSmrg
6323a966c04fSmrg      for libdir in $libdirs; do
6324a966c04fSmrg	if test -n "$finish_cmds"; then
6325a966c04fSmrg	  # Do each command in the finish commands.
6326a966c04fSmrg	  cmds=$finish_cmds
6327a966c04fSmrg	  save_ifs="$IFS"; IFS='~'
6328a966c04fSmrg	  for cmd in $cmds; do
6329a966c04fSmrg	    IFS="$save_ifs"
6330a966c04fSmrg	    eval cmd=\"$cmd\"
6331a966c04fSmrg	    $show "$cmd"
6332a966c04fSmrg	    $run eval "$cmd" || admincmds="$admincmds
6333a966c04fSmrg       $cmd"
6334a966c04fSmrg	  done
6335a966c04fSmrg	  IFS="$save_ifs"
6336a966c04fSmrg	fi
6337a966c04fSmrg	if test -n "$finish_eval"; then
6338a966c04fSmrg	  # Do the single finish_eval.
6339a966c04fSmrg	  eval cmds=\"$finish_eval\"
6340a966c04fSmrg	  $run eval "$cmds" || admincmds="$admincmds
6341a966c04fSmrg       $cmds"
6342a966c04fSmrg	fi
6343a966c04fSmrg      done
6344a966c04fSmrg    fi
6345a966c04fSmrg
6346a966c04fSmrg    # Exit here if they wanted silent mode.
6347a966c04fSmrg    test "$show" = : && exit $EXIT_SUCCESS
6348a966c04fSmrg
6349a966c04fSmrg    $echo "X----------------------------------------------------------------------" | $Xsed
6350a966c04fSmrg    $echo "Libraries have been installed in:"
6351a966c04fSmrg    for libdir in $libdirs; do
6352a966c04fSmrg      $echo "   $libdir"
6353a966c04fSmrg    done
6354a966c04fSmrg    $echo
6355a966c04fSmrg    $echo "If you ever happen to want to link against installed libraries"
6356a966c04fSmrg    $echo "in a given directory, LIBDIR, you must either use libtool, and"
6357a966c04fSmrg    $echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
6358a966c04fSmrg    $echo "flag during linking and do at least one of the following:"
6359a966c04fSmrg    if test -n "$shlibpath_var"; then
6360a966c04fSmrg      $echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
6361a966c04fSmrg      $echo "     during execution"
6362a966c04fSmrg    fi
6363a966c04fSmrg    if test -n "$runpath_var"; then
6364a966c04fSmrg      $echo "   - add LIBDIR to the \`$runpath_var' environment variable"
6365a966c04fSmrg      $echo "     during linking"
6366a966c04fSmrg    fi
6367a966c04fSmrg    if test -n "$hardcode_libdir_flag_spec"; then
6368a966c04fSmrg      libdir=LIBDIR
6369a966c04fSmrg      eval flag=\"$hardcode_libdir_flag_spec\"
6370a966c04fSmrg
6371a966c04fSmrg      $echo "   - use the \`$flag' linker flag"
6372a966c04fSmrg    fi
6373a966c04fSmrg    if test -n "$admincmds"; then
6374a966c04fSmrg      $echo "   - have your system administrator run these commands:$admincmds"
6375a966c04fSmrg    fi
6376a966c04fSmrg    if test -f /etc/ld.so.conf; then
6377a966c04fSmrg      $echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
6378a966c04fSmrg    fi
6379a966c04fSmrg    $echo
6380a966c04fSmrg    $echo "See any operating system documentation about shared libraries for"
6381a966c04fSmrg    $echo "more information, such as the ld(1) and ld.so(8) manual pages."
6382a966c04fSmrg    $echo "X----------------------------------------------------------------------" | $Xsed
6383a966c04fSmrg    exit $EXIT_SUCCESS
6384a966c04fSmrg    ;;
6385a966c04fSmrg
6386a966c04fSmrg  # libtool execute mode
6387a966c04fSmrg  execute)
6388a966c04fSmrg    modename="$modename: execute"
6389a966c04fSmrg
6390a966c04fSmrg    # The first argument is the command name.
6391a966c04fSmrg    cmd="$nonopt"
6392a966c04fSmrg    if test -z "$cmd"; then
6393a966c04fSmrg      $echo "$modename: you must specify a COMMAND" 1>&2
6394a966c04fSmrg      $echo "$help"
6395a966c04fSmrg      exit $EXIT_FAILURE
6396a966c04fSmrg    fi
6397a966c04fSmrg
6398a966c04fSmrg    # Handle -dlopen flags immediately.
6399a966c04fSmrg    for file in $execute_dlfiles; do
6400a966c04fSmrg      if test ! -f "$file"; then
6401a966c04fSmrg	$echo "$modename: \`$file' is not a file" 1>&2
6402a966c04fSmrg	$echo "$help" 1>&2
6403a966c04fSmrg	exit $EXIT_FAILURE
6404a966c04fSmrg      fi
6405a966c04fSmrg
6406a966c04fSmrg      dir=
6407a966c04fSmrg      case $file in
6408a966c04fSmrg      *.la)
6409a966c04fSmrg	# Check to see that this really is a libtool archive.
6410a966c04fSmrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
6411a966c04fSmrg	else
6412a966c04fSmrg	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
6413a966c04fSmrg	  $echo "$help" 1>&2
6414a966c04fSmrg	  exit $EXIT_FAILURE
6415a966c04fSmrg	fi
6416a966c04fSmrg
6417a966c04fSmrg	# Read the libtool library.
6418a966c04fSmrg	dlname=
6419a966c04fSmrg	library_names=
6420a966c04fSmrg
6421a966c04fSmrg	# If there is no directory component, then add one.
6422a966c04fSmrg	case $file in
6423a966c04fSmrg	*/* | *\\*) . $file ;;
6424a966c04fSmrg	*) . ./$file ;;
6425a966c04fSmrg	esac
6426a966c04fSmrg
6427a966c04fSmrg	# Skip this library if it cannot be dlopened.
6428a966c04fSmrg	if test -z "$dlname"; then
6429a966c04fSmrg	  # Warn if it was a shared library.
6430a966c04fSmrg	  test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
6431a966c04fSmrg	  continue
6432a966c04fSmrg	fi
6433a966c04fSmrg
6434a966c04fSmrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
6435a966c04fSmrg	test "X$dir" = "X$file" && dir=.
6436a966c04fSmrg
6437a966c04fSmrg	if test -f "$dir/$objdir/$dlname"; then
6438a966c04fSmrg	  dir="$dir/$objdir"
6439a966c04fSmrg	else
64402e2dd055Smrg	  if test ! -f "$dir/$dlname"; then
64412e2dd055Smrg	    $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
64422e2dd055Smrg	    exit $EXIT_FAILURE
64432e2dd055Smrg	  fi
6444a966c04fSmrg	fi
6445a966c04fSmrg	;;
6446a966c04fSmrg
6447a966c04fSmrg      *.lo)
6448a966c04fSmrg	# Just add the directory containing the .lo file.
6449a966c04fSmrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
6450a966c04fSmrg	test "X$dir" = "X$file" && dir=.
6451a966c04fSmrg	;;
6452a966c04fSmrg
6453a966c04fSmrg      *)
6454a966c04fSmrg	$echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
6455a966c04fSmrg	continue
6456a966c04fSmrg	;;
6457a966c04fSmrg      esac
6458a966c04fSmrg
6459a966c04fSmrg      # Get the absolute pathname.
6460a966c04fSmrg      absdir=`cd "$dir" && pwd`
6461a966c04fSmrg      test -n "$absdir" && dir="$absdir"
6462a966c04fSmrg
6463a966c04fSmrg      # Now add the directory to shlibpath_var.
6464a966c04fSmrg      if eval "test -z \"\$$shlibpath_var\""; then
6465a966c04fSmrg	eval "$shlibpath_var=\"\$dir\""
6466a966c04fSmrg      else
6467a966c04fSmrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
6468a966c04fSmrg      fi
6469a966c04fSmrg    done
6470a966c04fSmrg
6471a966c04fSmrg    # This variable tells wrapper scripts just to set shlibpath_var
6472a966c04fSmrg    # rather than running their programs.
6473a966c04fSmrg    libtool_execute_magic="$magic"
6474a966c04fSmrg
6475a966c04fSmrg    # Check if any of the arguments is a wrapper script.
6476a966c04fSmrg    args=
6477a966c04fSmrg    for file
6478a966c04fSmrg    do
6479a966c04fSmrg      case $file in
6480a966c04fSmrg      -*) ;;
6481a966c04fSmrg      *)
6482a966c04fSmrg	# Do a test to see if this is really a libtool program.
6483a966c04fSmrg	if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
6484a966c04fSmrg	  # If there is no directory component, then add one.
6485a966c04fSmrg	  case $file in
6486a966c04fSmrg	  */* | *\\*) . $file ;;
6487a966c04fSmrg	  *) . ./$file ;;
6488a966c04fSmrg	  esac
6489a966c04fSmrg
6490a966c04fSmrg	  # Transform arg to wrapped name.
6491a966c04fSmrg	  file="$progdir/$program"
6492a966c04fSmrg	fi
6493a966c04fSmrg	;;
6494a966c04fSmrg      esac
6495a966c04fSmrg      # Quote arguments (to preserve shell metacharacters).
6496a966c04fSmrg      file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
6497a966c04fSmrg      args="$args \"$file\""
6498a966c04fSmrg    done
6499a966c04fSmrg
6500a966c04fSmrg    if test -z "$run"; then
6501a966c04fSmrg      if test -n "$shlibpath_var"; then
6502a966c04fSmrg	# Export the shlibpath_var.
6503a966c04fSmrg	eval "export $shlibpath_var"
6504a966c04fSmrg      fi
6505a966c04fSmrg
6506a966c04fSmrg      # Restore saved environment variables
65072e2dd055Smrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
65082e2dd055Smrg      do
65092e2dd055Smrg	eval "if test \"\${save_$lt_var+set}\" = set; then
65102e2dd055Smrg		$lt_var=\$save_$lt_var; export $lt_var
65112e2dd055Smrg	      fi"
65122e2dd055Smrg      done
6513a966c04fSmrg
6514a966c04fSmrg      # Now prepare to actually exec the command.
6515a966c04fSmrg      exec_cmd="\$cmd$args"
6516a966c04fSmrg    else
6517a966c04fSmrg      # Display what would be done.
6518a966c04fSmrg      if test -n "$shlibpath_var"; then
6519a966c04fSmrg	eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
6520a966c04fSmrg	$echo "export $shlibpath_var"
6521a966c04fSmrg      fi
6522a966c04fSmrg      $echo "$cmd$args"
6523a966c04fSmrg      exit $EXIT_SUCCESS
6524a966c04fSmrg    fi
6525a966c04fSmrg    ;;
6526a966c04fSmrg
6527a966c04fSmrg  # libtool clean and uninstall mode
6528a966c04fSmrg  clean | uninstall)
6529a966c04fSmrg    modename="$modename: $mode"
6530a966c04fSmrg    rm="$nonopt"
6531a966c04fSmrg    files=
6532a966c04fSmrg    rmforce=
6533a966c04fSmrg    exit_status=0
6534a966c04fSmrg
6535a966c04fSmrg    # This variable tells wrapper scripts just to set variables rather
6536a966c04fSmrg    # than running their programs.
6537a966c04fSmrg    libtool_install_magic="$magic"
6538a966c04fSmrg
6539a966c04fSmrg    for arg
6540a966c04fSmrg    do
6541a966c04fSmrg      case $arg in
6542a966c04fSmrg      -f) rm="$rm $arg"; rmforce=yes ;;
6543a966c04fSmrg      -*) rm="$rm $arg" ;;
6544a966c04fSmrg      *) files="$files $arg" ;;
6545a966c04fSmrg      esac
6546a966c04fSmrg    done
6547a966c04fSmrg
6548a966c04fSmrg    if test -z "$rm"; then
6549a966c04fSmrg      $echo "$modename: you must specify an RM program" 1>&2
6550a966c04fSmrg      $echo "$help" 1>&2
6551a966c04fSmrg      exit $EXIT_FAILURE
6552a966c04fSmrg    fi
6553a966c04fSmrg
6554a966c04fSmrg    rmdirs=
6555a966c04fSmrg
6556a966c04fSmrg    origobjdir="$objdir"
6557a966c04fSmrg    for file in $files; do
6558a966c04fSmrg      dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
6559a966c04fSmrg      if test "X$dir" = "X$file"; then
6560a966c04fSmrg	dir=.
6561a966c04fSmrg	objdir="$origobjdir"
6562a966c04fSmrg      else
6563a966c04fSmrg	objdir="$dir/$origobjdir"
6564a966c04fSmrg      fi
6565a966c04fSmrg      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
6566a966c04fSmrg      test "$mode" = uninstall && objdir="$dir"
6567a966c04fSmrg
6568a966c04fSmrg      # Remember objdir for removal later, being careful to avoid duplicates
6569a966c04fSmrg      if test "$mode" = clean; then
6570a966c04fSmrg	case " $rmdirs " in
6571a966c04fSmrg	  *" $objdir "*) ;;
6572a966c04fSmrg	  *) rmdirs="$rmdirs $objdir" ;;
6573a966c04fSmrg	esac
6574a966c04fSmrg      fi
6575a966c04fSmrg
6576a966c04fSmrg      # Don't error if the file doesn't exist and rm -f was used.
6577a966c04fSmrg      if (test -L "$file") >/dev/null 2>&1 \
6578a966c04fSmrg	|| (test -h "$file") >/dev/null 2>&1 \
6579a966c04fSmrg	|| test -f "$file"; then
6580a966c04fSmrg	:
6581a966c04fSmrg      elif test -d "$file"; then
6582a966c04fSmrg	exit_status=1
6583a966c04fSmrg	continue
6584a966c04fSmrg      elif test "$rmforce" = yes; then
6585a966c04fSmrg	continue
6586a966c04fSmrg      fi
6587a966c04fSmrg
6588a966c04fSmrg      rmfiles="$file"
6589a966c04fSmrg
6590a966c04fSmrg      case $name in
6591a966c04fSmrg      *.la)
6592a966c04fSmrg	# Possibly a libtool archive, so verify it.
6593a966c04fSmrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
6594a966c04fSmrg	  . $dir/$name
6595a966c04fSmrg
6596a966c04fSmrg	  # Delete the libtool libraries and symlinks.
6597a966c04fSmrg	  for n in $library_names; do
6598a966c04fSmrg	    rmfiles="$rmfiles $objdir/$n"
6599a966c04fSmrg	  done
6600a966c04fSmrg	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
6601a966c04fSmrg
6602a966c04fSmrg	  case "$mode" in
6603a966c04fSmrg	  clean)
6604a966c04fSmrg	    case "  $library_names " in
6605a966c04fSmrg	    # "  " in the beginning catches empty $dlname
6606a966c04fSmrg	    *" $dlname "*) ;;
6607a966c04fSmrg	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
6608a966c04fSmrg	    esac
6609a966c04fSmrg	     test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
6610a966c04fSmrg	    ;;
6611a966c04fSmrg	  uninstall)
6612a966c04fSmrg	    if test -n "$library_names"; then
6613a966c04fSmrg	      # Do each command in the postuninstall commands.
6614a966c04fSmrg	      cmds=$postuninstall_cmds
6615a966c04fSmrg	      save_ifs="$IFS"; IFS='~'
6616a966c04fSmrg	      for cmd in $cmds; do
6617a966c04fSmrg		IFS="$save_ifs"
6618a966c04fSmrg		eval cmd=\"$cmd\"
6619a966c04fSmrg		$show "$cmd"
6620a966c04fSmrg		$run eval "$cmd"
6621a966c04fSmrg		if test "$?" -ne 0 && test "$rmforce" != yes; then
6622a966c04fSmrg		  exit_status=1
6623a966c04fSmrg		fi
6624a966c04fSmrg	      done
6625a966c04fSmrg	      IFS="$save_ifs"
6626a966c04fSmrg	    fi
6627a966c04fSmrg
6628a966c04fSmrg	    if test -n "$old_library"; then
6629a966c04fSmrg	      # Do each command in the old_postuninstall commands.
6630a966c04fSmrg	      cmds=$old_postuninstall_cmds
6631a966c04fSmrg	      save_ifs="$IFS"; IFS='~'
6632a966c04fSmrg	      for cmd in $cmds; do
6633a966c04fSmrg		IFS="$save_ifs"
6634a966c04fSmrg		eval cmd=\"$cmd\"
6635a966c04fSmrg		$show "$cmd"
6636a966c04fSmrg		$run eval "$cmd"
6637a966c04fSmrg		if test "$?" -ne 0 && test "$rmforce" != yes; then
6638a966c04fSmrg		  exit_status=1
6639a966c04fSmrg		fi
6640a966c04fSmrg	      done
6641a966c04fSmrg	      IFS="$save_ifs"
6642a966c04fSmrg	    fi
6643a966c04fSmrg	    # FIXME: should reinstall the best remaining shared library.
6644a966c04fSmrg	    ;;
6645a966c04fSmrg	  esac
6646a966c04fSmrg	fi
6647a966c04fSmrg	;;
6648a966c04fSmrg
6649a966c04fSmrg      *.lo)
6650a966c04fSmrg	# Possibly a libtool object, so verify it.
6651a966c04fSmrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
6652a966c04fSmrg
6653a966c04fSmrg	  # Read the .lo file
6654a966c04fSmrg	  . $dir/$name
6655a966c04fSmrg
6656a966c04fSmrg	  # Add PIC object to the list of files to remove.
6657a966c04fSmrg	  if test -n "$pic_object" \
6658a966c04fSmrg	     && test "$pic_object" != none; then
6659a966c04fSmrg	    rmfiles="$rmfiles $dir/$pic_object"
6660a966c04fSmrg	  fi
6661a966c04fSmrg
6662a966c04fSmrg	  # Add non-PIC object to the list of files to remove.
6663a966c04fSmrg	  if test -n "$non_pic_object" \
6664a966c04fSmrg	     && test "$non_pic_object" != none; then
6665a966c04fSmrg	    rmfiles="$rmfiles $dir/$non_pic_object"
6666a966c04fSmrg	  fi
6667a966c04fSmrg	fi
6668a966c04fSmrg	;;
6669a966c04fSmrg
6670a966c04fSmrg      *)
6671a966c04fSmrg	if test "$mode" = clean ; then
6672a966c04fSmrg	  noexename=$name
6673a966c04fSmrg	  case $file in
6674a966c04fSmrg	  *.exe)
6675a966c04fSmrg	    file=`$echo $file|${SED} 's,.exe$,,'`
6676a966c04fSmrg	    noexename=`$echo $name|${SED} 's,.exe$,,'`
6677a966c04fSmrg	    # $file with .exe has already been added to rmfiles,
6678a966c04fSmrg	    # add $file without .exe
6679a966c04fSmrg	    rmfiles="$rmfiles $file"
6680a966c04fSmrg	    ;;
6681a966c04fSmrg	  esac
6682a966c04fSmrg	  # Do a test to see if this is a libtool program.
6683a966c04fSmrg	  if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
6684a966c04fSmrg	    relink_command=
6685a966c04fSmrg	    . $dir/$noexename
6686a966c04fSmrg
6687a966c04fSmrg	    # note $name still contains .exe if it was in $file originally
6688a966c04fSmrg	    # as does the version of $file that was added into $rmfiles
6689a966c04fSmrg	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
6690a966c04fSmrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
6691a966c04fSmrg	      rmfiles="$rmfiles $objdir/lt-$name"
6692a966c04fSmrg	    fi
6693a966c04fSmrg	    if test "X$noexename" != "X$name" ; then
6694a966c04fSmrg	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
6695a966c04fSmrg	    fi
6696a966c04fSmrg	  fi
6697a966c04fSmrg	fi
6698a966c04fSmrg	;;
6699a966c04fSmrg      esac
6700a966c04fSmrg      $show "$rm $rmfiles"
6701a966c04fSmrg      $run $rm $rmfiles || exit_status=1
6702a966c04fSmrg    done
6703a966c04fSmrg    objdir="$origobjdir"
6704a966c04fSmrg
6705a966c04fSmrg    # Try to remove the ${objdir}s in the directories where we deleted files
6706a966c04fSmrg    for dir in $rmdirs; do
6707a966c04fSmrg      if test -d "$dir"; then
6708a966c04fSmrg	$show "rmdir $dir"
6709a966c04fSmrg	$run rmdir $dir >/dev/null 2>&1
6710a966c04fSmrg      fi
6711a966c04fSmrg    done
6712a966c04fSmrg
6713a966c04fSmrg    exit $exit_status
6714a966c04fSmrg    ;;
6715a966c04fSmrg
6716a966c04fSmrg  "")
6717a966c04fSmrg    $echo "$modename: you must specify a MODE" 1>&2
6718a966c04fSmrg    $echo "$generic_help" 1>&2
6719a966c04fSmrg    exit $EXIT_FAILURE
6720a966c04fSmrg    ;;
6721a966c04fSmrg  esac
6722a966c04fSmrg
6723a966c04fSmrg  if test -z "$exec_cmd"; then
6724a966c04fSmrg    $echo "$modename: invalid operation mode \`$mode'" 1>&2
6725a966c04fSmrg    $echo "$generic_help" 1>&2
6726a966c04fSmrg    exit $EXIT_FAILURE
6727a966c04fSmrg  fi
6728a966c04fSmrgfi # test -z "$show_help"
6729a966c04fSmrg
6730a966c04fSmrgif test -n "$exec_cmd"; then
6731a966c04fSmrg  eval exec $exec_cmd
6732a966c04fSmrg  exit $EXIT_FAILURE
6733a966c04fSmrgfi
6734a966c04fSmrg
6735a966c04fSmrg# We need to display help for each of the modes.
6736a966c04fSmrgcase $mode in
6737a966c04fSmrg"") $echo \
6738a966c04fSmrg"Usage: $modename [OPTION]... [MODE-ARG]...
6739a966c04fSmrg
6740a966c04fSmrgProvide generalized library-building support services.
6741a966c04fSmrg
6742a966c04fSmrg    --config          show all configuration variables
6743a966c04fSmrg    --debug           enable verbose shell tracing
6744a966c04fSmrg-n, --dry-run         display commands without modifying any files
6745a966c04fSmrg    --features        display basic configuration information and exit
6746a966c04fSmrg    --finish          same as \`--mode=finish'
6747a966c04fSmrg    --help            display this help message and exit
6748a966c04fSmrg    --mode=MODE       use operation mode MODE [default=inferred from MODE-ARGS]
6749a966c04fSmrg    --quiet           same as \`--silent'
6750a966c04fSmrg    --silent          don't print informational messages
6751a966c04fSmrg    --tag=TAG         use configuration variables from tag TAG
6752a966c04fSmrg    --version         print version information
6753a966c04fSmrg
6754a966c04fSmrgMODE must be one of the following:
6755a966c04fSmrg
6756a966c04fSmrg      clean           remove files from the build directory
6757a966c04fSmrg      compile         compile a source file into a libtool object
6758a966c04fSmrg      execute         automatically set library path, then run a program
6759a966c04fSmrg      finish          complete the installation of libtool libraries
6760a966c04fSmrg      install         install libraries or executables
6761a966c04fSmrg      link            create a library or an executable
6762a966c04fSmrg      uninstall       remove libraries from an installed directory
6763a966c04fSmrg
6764a966c04fSmrgMODE-ARGS vary depending on the MODE.  Try \`$modename --help --mode=MODE' for
6765a966c04fSmrga more detailed description of MODE.
6766a966c04fSmrg
6767a966c04fSmrgReport bugs to <bug-libtool@gnu.org>."
6768a966c04fSmrg  exit $EXIT_SUCCESS
6769a966c04fSmrg  ;;
6770a966c04fSmrg
6771a966c04fSmrgclean)
6772a966c04fSmrg  $echo \
6773a966c04fSmrg"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
6774a966c04fSmrg
6775a966c04fSmrgRemove files from the build directory.
6776a966c04fSmrg
6777a966c04fSmrgRM is the name of the program to use to delete files associated with each FILE
6778a966c04fSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
6779a966c04fSmrgto RM.
6780a966c04fSmrg
6781a966c04fSmrgIf FILE is a libtool library, object or program, all the files associated
6782a966c04fSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
6783a966c04fSmrg  ;;
6784a966c04fSmrg
6785a966c04fSmrgcompile)
6786a966c04fSmrg  $echo \
6787a966c04fSmrg"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
6788a966c04fSmrg
6789a966c04fSmrgCompile a source file into a libtool library object.
6790a966c04fSmrg
6791a966c04fSmrgThis mode accepts the following additional options:
6792a966c04fSmrg
6793a966c04fSmrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
6794a966c04fSmrg  -prefer-pic       try to building PIC objects only
6795a966c04fSmrg  -prefer-non-pic   try to building non-PIC objects only
6796a966c04fSmrg  -static           always build a \`.o' file suitable for static linking
6797a966c04fSmrg
6798a966c04fSmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
6799a966c04fSmrgfrom the given SOURCEFILE.
6800a966c04fSmrg
6801a966c04fSmrgThe output file name is determined by removing the directory component from
6802a966c04fSmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
6803a966c04fSmrglibrary object suffix, \`.lo'."
6804a966c04fSmrg  ;;
6805a966c04fSmrg
6806a966c04fSmrgexecute)
6807a966c04fSmrg  $echo \
6808a966c04fSmrg"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
6809a966c04fSmrg
6810a966c04fSmrgAutomatically set library path, then run a program.
6811a966c04fSmrg
6812a966c04fSmrgThis mode accepts the following additional options:
6813a966c04fSmrg
6814a966c04fSmrg  -dlopen FILE      add the directory containing FILE to the library path
6815a966c04fSmrg
6816a966c04fSmrgThis mode sets the library path environment variable according to \`-dlopen'
6817a966c04fSmrgflags.
6818a966c04fSmrg
6819a966c04fSmrgIf any of the ARGS are libtool executable wrappers, then they are translated
6820a966c04fSmrginto their corresponding uninstalled binary, and any of their required library
6821a966c04fSmrgdirectories are added to the library path.
6822a966c04fSmrg
6823a966c04fSmrgThen, COMMAND is executed, with ARGS as arguments."
6824a966c04fSmrg  ;;
6825a966c04fSmrg
6826a966c04fSmrgfinish)
6827a966c04fSmrg  $echo \
6828a966c04fSmrg"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
6829a966c04fSmrg
6830a966c04fSmrgComplete the installation of libtool libraries.
6831a966c04fSmrg
6832a966c04fSmrgEach LIBDIR is a directory that contains libtool libraries.
6833a966c04fSmrg
6834a966c04fSmrgThe commands that this mode executes may require superuser privileges.  Use
6835a966c04fSmrgthe \`--dry-run' option if you just want to see what would be executed."
6836a966c04fSmrg  ;;
6837a966c04fSmrg
6838a966c04fSmrginstall)
6839a966c04fSmrg  $echo \
6840a966c04fSmrg"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
6841a966c04fSmrg
6842a966c04fSmrgInstall executables or libraries.
6843a966c04fSmrg
6844a966c04fSmrgINSTALL-COMMAND is the installation command.  The first component should be
6845a966c04fSmrgeither the \`install' or \`cp' program.
6846a966c04fSmrg
6847a966c04fSmrgThe rest of the components are interpreted as arguments to that command (only
6848a966c04fSmrgBSD-compatible install options are recognized)."
6849a966c04fSmrg  ;;
6850a966c04fSmrg
6851a966c04fSmrglink)
6852a966c04fSmrg  $echo \
6853a966c04fSmrg"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
6854a966c04fSmrg
6855a966c04fSmrgLink object files or libraries together to form another library, or to
6856a966c04fSmrgcreate an executable program.
6857a966c04fSmrg
6858a966c04fSmrgLINK-COMMAND is a command using the C compiler that you would use to create
6859a966c04fSmrga program from several object files.
6860a966c04fSmrg
6861a966c04fSmrgThe following components of LINK-COMMAND are treated specially:
6862a966c04fSmrg
6863a966c04fSmrg  -all-static       do not do any dynamic linking at all
6864a966c04fSmrg  -avoid-version    do not add a version suffix if possible
6865a966c04fSmrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
6866a966c04fSmrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
6867a966c04fSmrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
6868a966c04fSmrg  -export-symbols SYMFILE
68692e2dd055Smrg                    try to export only the symbols listed in SYMFILE
6870a966c04fSmrg  -export-symbols-regex REGEX
68712e2dd055Smrg                    try to export only the symbols matching REGEX
6872a966c04fSmrg  -LLIBDIR          search LIBDIR for required installed libraries
6873a966c04fSmrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
6874a966c04fSmrg  -module           build a library that can dlopened
6875a966c04fSmrg  -no-fast-install  disable the fast-install mode
6876a966c04fSmrg  -no-install       link a not-installable executable
6877a966c04fSmrg  -no-undefined     declare that a library does not refer to external symbols
6878a966c04fSmrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
6879a966c04fSmrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
6880a966c04fSmrg  -precious-files-regex REGEX
6881a966c04fSmrg                    don't remove output files matching REGEX
6882a966c04fSmrg  -release RELEASE  specify package release information
6883a966c04fSmrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
6884a966c04fSmrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
68852e2dd055Smrg  -static           do not do any dynamic linking of uninstalled libtool libraries
68862e2dd055Smrg  -static-libtool-libs
68872e2dd055Smrg                    do not do any dynamic linking of libtool libraries
6888a966c04fSmrg  -version-info CURRENT[:REVISION[:AGE]]
68892e2dd055Smrg                    specify library version info [each variable defaults to 0]
6890a966c04fSmrg
6891a966c04fSmrgAll other options (arguments beginning with \`-') are ignored.
6892a966c04fSmrg
6893a966c04fSmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
6894a966c04fSmrgtreated as uninstalled libtool libraries, other files are standard or library
6895a966c04fSmrgobject files.
6896a966c04fSmrg
6897a966c04fSmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
6898a966c04fSmrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
6899a966c04fSmrgrequired, except when creating a convenience library.
6900a966c04fSmrg
6901a966c04fSmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
6902a966c04fSmrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
6903a966c04fSmrg
6904a966c04fSmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
6905a966c04fSmrgis created, otherwise an executable program is created."
6906a966c04fSmrg  ;;
6907a966c04fSmrg
6908a966c04fSmrguninstall)
6909a966c04fSmrg  $echo \
6910a966c04fSmrg"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
6911a966c04fSmrg
6912a966c04fSmrgRemove libraries from an installation directory.
6913a966c04fSmrg
6914a966c04fSmrgRM is the name of the program to use to delete files associated with each FILE
6915a966c04fSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
6916a966c04fSmrgto RM.
6917a966c04fSmrg
6918a966c04fSmrgIf FILE is a libtool library, all the files associated with it are deleted.
6919a966c04fSmrgOtherwise, only FILE itself is deleted using RM."
6920a966c04fSmrg  ;;
6921a966c04fSmrg
6922a966c04fSmrg*)
6923a966c04fSmrg  $echo "$modename: invalid operation mode \`$mode'" 1>&2
6924a966c04fSmrg  $echo "$help" 1>&2
6925a966c04fSmrg  exit $EXIT_FAILURE
6926a966c04fSmrg  ;;
6927a966c04fSmrgesac
6928a966c04fSmrg
6929a966c04fSmrg$echo
6930a966c04fSmrg$echo "Try \`$modename --help' for more information about other modes."
6931a966c04fSmrg
6932a966c04fSmrgexit $?
6933a966c04fSmrg
6934a966c04fSmrg# The TAGs below are defined such that we never get into a situation
6935a966c04fSmrg# in which we disable both kinds of libraries.  Given conflicting
6936a966c04fSmrg# choices, we go for a static library, that is the most portable,
6937a966c04fSmrg# since we can't tell whether shared libraries were disabled because
6938a966c04fSmrg# the user asked for that or because the platform doesn't support
6939a966c04fSmrg# them.  This is particularly important on AIX, because we don't
6940a966c04fSmrg# support having both static and shared libraries enabled at the same
6941a966c04fSmrg# time on that platform, so we default to a shared-only configuration.
6942a966c04fSmrg# If a disable-shared tag is given, we'll fallback to a static-only
6943a966c04fSmrg# configuration.  But we'll never go from static-only to shared-only.
6944a966c04fSmrg
6945a966c04fSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
6946a966c04fSmrgdisable_libs=shared
6947a966c04fSmrg# ### END LIBTOOL TAG CONFIG: disable-shared
6948a966c04fSmrg
6949a966c04fSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
6950a966c04fSmrgdisable_libs=static
6951a966c04fSmrg# ### END LIBTOOL TAG CONFIG: disable-static
6952a966c04fSmrg
6953a966c04fSmrg# Local Variables:
6954a966c04fSmrg# mode:shell-script
6955a966c04fSmrg# sh-indentation:2
6956a966c04fSmrg# End:
6957