ltmain.sh revision a18ebfb2
1a18ebfb2Smrg# ltmain.sh - Provide generalized library-building support services.
2a18ebfb2Smrg# NOTE: Changing this file will not affect anything until you rerun configure.
3a18ebfb2Smrg#
4a18ebfb2Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
5a18ebfb2Smrg# 2007, 2008  Free Software Foundation, Inc.
6a18ebfb2Smrg# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
7a18ebfb2Smrg#
8a18ebfb2Smrg# This program is free software; you can redistribute it and/or modify
950806d53Smrg# it under the terms of the GNU General Public License as published by
1050806d53Smrg# the Free Software Foundation; either version 2 of the License, or
1150806d53Smrg# (at your option) any later version.
1250806d53Smrg#
13a18ebfb2Smrg# This program is distributed in the hope that it will be useful, but
1450806d53Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
1550806d53Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1650806d53Smrg# General Public License for more details.
1750806d53Smrg#
1850806d53Smrg# You should have received a copy of the GNU General Public License
19a18ebfb2Smrg# along with this program; if not, write to the Free Software
20a18ebfb2Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21af1a9c97Smrg#
22a18ebfb2Smrg# As a special exception to the GNU General Public License, if you
23a18ebfb2Smrg# distribute this file as part of a program that contains a
24a18ebfb2Smrg# configuration script generated by Autoconf, you may include it under
25a18ebfb2Smrg# the same distribution terms that you use for the rest of that program.
26a18ebfb2Smrg
27a18ebfb2Smrgbasename="s,^.*/,,g"
28a18ebfb2Smrg
29a18ebfb2Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
30a18ebfb2Smrg# is ksh but when the shell is invoked as "sh" and the current value of
31a18ebfb2Smrg# the _XPG environment variable is not equal to 1 (one), the special
32a18ebfb2Smrg# positional parameter $0, within a function call, is the name of the
33a18ebfb2Smrg# function.
34a18ebfb2Smrgprogpath="$0"
35a18ebfb2Smrg
36a18ebfb2Smrg# The name of this program:
37a18ebfb2Smrgprogname=`echo "$progpath" | $SED $basename`
38a18ebfb2Smrgmodename="$progname"
39a18ebfb2Smrg
40a18ebfb2Smrg# Global variables:
41a18ebfb2SmrgEXIT_SUCCESS=0
42a18ebfb2SmrgEXIT_FAILURE=1
4350806d53Smrg
4450806d53SmrgPROGRAM=ltmain.sh
4550806d53SmrgPACKAGE=libtool
46a18ebfb2SmrgVERSION=1.5.26
47a18ebfb2SmrgTIMESTAMP=" (1.1220.2.493 2008/02/01 16:58:18)"
4850806d53Smrg
49a18ebfb2Smrg# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE).
5050806d53Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
5150806d53Smrg  emulate sh
5250806d53Smrg  NULLCMD=:
5350806d53Smrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
5450806d53Smrg  # is contrary to our usage.  Disable this feature.
5550806d53Smrg  alias -g '${1+"$@"}'='"$@"'
5650806d53Smrg  setopt NO_GLOB_SUBST
5750806d53Smrgelse
5850806d53Smrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
5950806d53Smrgfi
607965d9acSmrgBIN_SH=xpg4; export BIN_SH # for Tru64
617965d9acSmrgDUALCASE=1; export DUALCASE # for MKS sh
6250806d53Smrg
63a18ebfb2Smrg# Check that we have a working $echo.
64a18ebfb2Smrgif test "X$1" = X--no-reexec; then
65a18ebfb2Smrg  # Discard the --no-reexec flag, and continue.
66a18ebfb2Smrg  shift
67a18ebfb2Smrgelif test "X$1" = X--fallback-echo; then
68a18ebfb2Smrg  # Avoid inline document here, it may be left over
69a18ebfb2Smrg  :
70a18ebfb2Smrgelif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
71a18ebfb2Smrg  # Yippee, $echo works!
72a18ebfb2Smrg  :
73a18ebfb2Smrgelse
74a18ebfb2Smrg  # Restart under the correct shell, and then maybe $echo will work.
75a18ebfb2Smrg  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
76a18ebfb2Smrgfi
77a18ebfb2Smrg
78a18ebfb2Smrgif test "X$1" = X--fallback-echo; then
79a18ebfb2Smrg  # used as fallback echo
80a18ebfb2Smrg  shift
81a18ebfb2Smrg  cat <<EOF
82a18ebfb2Smrg$*
83a18ebfb2SmrgEOF
84a18ebfb2Smrg  exit $EXIT_SUCCESS
85a18ebfb2Smrgfi
86a18ebfb2Smrg
87a18ebfb2Smrgdefault_mode=
88a18ebfb2Smrghelp="Try \`$progname --help' for more information."
89a18ebfb2Smrgmagic="%%%MAGIC variable%%%"
90a18ebfb2Smrgmkdir="mkdir"
91a18ebfb2Smrgmv="mv -f"
92a18ebfb2Smrgrm="rm -f"
93a18ebfb2Smrg
94a18ebfb2Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
95a18ebfb2Smrg# metacharacters that are still active within double-quoted strings.
96a18ebfb2SmrgXsed="${SED}"' -e 1s/^X//'
97a18ebfb2Smrgsed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
98a18ebfb2Smrg# test EBCDIC or ASCII
99a18ebfb2Smrgcase `echo X|tr X '\101'` in
100a18ebfb2Smrg A) # ASCII based system
101a18ebfb2Smrg    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
102a18ebfb2Smrg  SP2NL='tr \040 \012'
103a18ebfb2Smrg  NL2SP='tr \015\012 \040\040'
104a18ebfb2Smrg  ;;
105a18ebfb2Smrg *) # EBCDIC based system
106a18ebfb2Smrg  SP2NL='tr \100 \n'
107a18ebfb2Smrg  NL2SP='tr \r\n \100\100'
108a18ebfb2Smrg  ;;
109a18ebfb2Smrgesac
110a18ebfb2Smrg
111a18ebfb2Smrg# NLS nuisances.
11250806d53Smrg# Only set LANG and LC_ALL to C if already set.
11350806d53Smrg# These must not be set unconditionally because not all systems understand
11450806d53Smrg# e.g. LANG=C (notably SCO).
115a18ebfb2Smrg# We save the old values to restore during execute mode.
116a18ebfb2Smrglt_env=
1177965d9acSmrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
11850806d53Smrgdo
11950806d53Smrg  eval "if test \"\${$lt_var+set}\" = set; then
120a18ebfb2Smrg	  save_$lt_var=\$$lt_var
121a18ebfb2Smrg	  lt_env=\"$lt_var=\$$lt_var \$lt_env\"
122a18ebfb2Smrg	  $lt_var=C
1237965d9acSmrg	  export $lt_var
1247965d9acSmrg	fi"
12550806d53Smrgdone
12650806d53Smrg
127a18ebfb2Smrgif test -n "$lt_env"; then
128a18ebfb2Smrg  lt_env="env $lt_env"
129a18ebfb2Smrgfi
1307965d9acSmrg
13150806d53Smrg# Make sure IFS has a sensible default
13250806d53Smrglt_nl='
13350806d53Smrg'
13450806d53SmrgIFS=" 	$lt_nl"
13550806d53Smrg
136a18ebfb2Smrgif test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
137a18ebfb2Smrg  $echo "$modename: not configured to build any kind of library" 1>&2
138a18ebfb2Smrg  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
139a18ebfb2Smrg  exit $EXIT_FAILURE
140a18ebfb2Smrgfi
141af1a9c97Smrg
142a18ebfb2Smrg# Global variables.
143a18ebfb2Smrgmode=$default_mode
144a18ebfb2Smrgnonopt=
145a18ebfb2Smrgprev=
146a18ebfb2Smrgprevopt=
147a18ebfb2Smrgrun=
148a18ebfb2Smrgshow="$echo"
149a18ebfb2Smrgshow_help=
150a18ebfb2Smrgexecute_dlfiles=
151a18ebfb2Smrgduplicate_deps=no
152a18ebfb2Smrgpreserve_args=
153a18ebfb2Smrglo2o="s/\\.lo\$/.${objext}/"
154a18ebfb2Smrgo2lo="s/\\.${objext}\$/.lo/"
155a18ebfb2Smrgextracted_archives=
156a18ebfb2Smrgextracted_serial=0
15750806d53Smrg
158a18ebfb2Smrg#####################################
159a18ebfb2Smrg# Shell function definitions:
160a18ebfb2Smrg# This seems to be the best place for them
16150806d53Smrg
16250806d53Smrg# func_mktempdir [string]
16350806d53Smrg# Make a temporary directory that won't clash with other running
16450806d53Smrg# libtool processes, and avoids race conditions if possible.  If
16550806d53Smrg# given, STRING is the basename for that directory.
16650806d53Smrgfunc_mktempdir ()
16750806d53Smrg{
16850806d53Smrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
16950806d53Smrg
170a18ebfb2Smrg    if test "$run" = ":"; then
17150806d53Smrg      # Return a directory name, but don't create it in dry-run mode
17250806d53Smrg      my_tmpdir="${my_template}-$$"
17350806d53Smrg    else
17450806d53Smrg
17550806d53Smrg      # If mktemp works, use that first and foremost
17650806d53Smrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
17750806d53Smrg
17850806d53Smrg      if test ! -d "$my_tmpdir"; then
179a18ebfb2Smrg	# Failing that, at least try and use $RANDOM to avoid a race
180a18ebfb2Smrg	my_tmpdir="${my_template}-${RANDOM-0}$$"
18150806d53Smrg
182a18ebfb2Smrg	save_mktempdir_umask=`umask`
183a18ebfb2Smrg	umask 0077
184a18ebfb2Smrg	$mkdir "$my_tmpdir"
185a18ebfb2Smrg	umask $save_mktempdir_umask
18650806d53Smrg      fi
18750806d53Smrg
18850806d53Smrg      # If we're not in dry-run mode, bomb out on failure
189a18ebfb2Smrg      test -d "$my_tmpdir" || {
190a18ebfb2Smrg        $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
191a18ebfb2Smrg	exit $EXIT_FAILURE
192a18ebfb2Smrg      }
19350806d53Smrg    fi
19450806d53Smrg
195a18ebfb2Smrg    $echo "X$my_tmpdir" | $Xsed
19650806d53Smrg}
19750806d53Smrg
19850806d53Smrg
199a18ebfb2Smrg# func_win32_libid arg
200a18ebfb2Smrg# return the library type of file 'arg'
201a18ebfb2Smrg#
202a18ebfb2Smrg# Need a lot of goo to handle *both* DLLs and import libs
203a18ebfb2Smrg# Has to be a shell function in order to 'eat' the argument
204a18ebfb2Smrg# that is supplied when $file_magic_command is called.
205a18ebfb2Smrgfunc_win32_libid ()
20650806d53Smrg{
207a18ebfb2Smrg  win32_libid_type="unknown"
208a18ebfb2Smrg  win32_fileres=`file -L $1 2>/dev/null`
209a18ebfb2Smrg  case $win32_fileres in
210a18ebfb2Smrg  *ar\ archive\ import\ library*) # definitely import
211a18ebfb2Smrg    win32_libid_type="x86 archive import"
212a18ebfb2Smrg    ;;
213a18ebfb2Smrg  *ar\ archive*) # could be an import, or static
214a18ebfb2Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
215a18ebfb2Smrg      $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
216a18ebfb2Smrg      win32_nmres=`eval $NM -f posix -A $1 | \
217a18ebfb2Smrg	$SED -n -e '1,100{
218a18ebfb2Smrg		/ I /{
219a18ebfb2Smrg			s,.*,import,
220a18ebfb2Smrg			p
221a18ebfb2Smrg			q
222a18ebfb2Smrg			}
223a18ebfb2Smrg		}'`
224a18ebfb2Smrg      case $win32_nmres in
225a18ebfb2Smrg      import*)  win32_libid_type="x86 archive import";;
226a18ebfb2Smrg      *)        win32_libid_type="x86 archive static";;
227a18ebfb2Smrg      esac
228a18ebfb2Smrg    fi
229a18ebfb2Smrg    ;;
230a18ebfb2Smrg  *DLL*)
231a18ebfb2Smrg    win32_libid_type="x86 DLL"
232a18ebfb2Smrg    ;;
233a18ebfb2Smrg  *executable*) # but shell scripts are "executable" too...
234a18ebfb2Smrg    case $win32_fileres in
235a18ebfb2Smrg    *MS\ Windows\ PE\ Intel*)
236a18ebfb2Smrg      win32_libid_type="x86 DLL"
237a18ebfb2Smrg      ;;
23850806d53Smrg    esac
239a18ebfb2Smrg    ;;
240a18ebfb2Smrg  esac
241a18ebfb2Smrg  $echo $win32_libid_type
24250806d53Smrg}
24350806d53Smrg
24450806d53Smrg
245a18ebfb2Smrg# func_infer_tag arg
246a18ebfb2Smrg# Infer tagged configuration to use if any are available and
247a18ebfb2Smrg# if one wasn't chosen via the "--tag" command line option.
248a18ebfb2Smrg# Only attempt this if the compiler in the base compile
249a18ebfb2Smrg# command doesn't match the default compiler.
250a18ebfb2Smrg# arg is usually of the form 'gcc ...'
251a18ebfb2Smrgfunc_infer_tag ()
25250806d53Smrg{
253a18ebfb2Smrg    if test -n "$available_tags" && test -z "$tagname"; then
254a18ebfb2Smrg      CC_quoted=
255a18ebfb2Smrg      for arg in $CC; do
256a18ebfb2Smrg	case $arg in
257a18ebfb2Smrg	  *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
258a18ebfb2Smrg	  arg="\"$arg\""
259a18ebfb2Smrg	  ;;
260a18ebfb2Smrg	esac
261a18ebfb2Smrg	CC_quoted="$CC_quoted $arg"
262a18ebfb2Smrg      done
263a18ebfb2Smrg      case $@ in
264a18ebfb2Smrg      # Blanks in the command may have been stripped by the calling shell,
265a18ebfb2Smrg      # but not from the CC environment variable when configure was run.
266a18ebfb2Smrg      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
267a18ebfb2Smrg      # Blanks at the start of $base_compile will cause this to fail
268a18ebfb2Smrg      # if we don't check for them as well.
26950806d53Smrg      *)
270a18ebfb2Smrg	for z in $available_tags; do
271a18ebfb2Smrg	  if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
272a18ebfb2Smrg	    # Evaluate the configuration.
273a18ebfb2Smrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
274a18ebfb2Smrg	    CC_quoted=
275a18ebfb2Smrg	    for arg in $CC; do
276a18ebfb2Smrg	    # Double-quote args containing other shell metacharacters.
277a18ebfb2Smrg	    case $arg in
278a18ebfb2Smrg	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
279a18ebfb2Smrg	      arg="\"$arg\""
280a18ebfb2Smrg	      ;;
281a18ebfb2Smrg	    esac
282a18ebfb2Smrg	    CC_quoted="$CC_quoted $arg"
283a18ebfb2Smrg	  done
284a18ebfb2Smrg	    case "$@ " in
285a18ebfb2Smrg	      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
286a18ebfb2Smrg	      # The compiler in the base compile command matches
287a18ebfb2Smrg	      # the one in the tagged configuration.
288a18ebfb2Smrg	      # Assume this is the tagged configuration we want.
289a18ebfb2Smrg	      tagname=$z
290a18ebfb2Smrg	      break
291a18ebfb2Smrg	      ;;
292a18ebfb2Smrg	    esac
293a18ebfb2Smrg	  fi
294a18ebfb2Smrg	done
295a18ebfb2Smrg	# If $tagname still isn't set, then no tagged configuration
296a18ebfb2Smrg	# was found and let the user know that the "--tag" command
297a18ebfb2Smrg	# line option must be used.
298a18ebfb2Smrg	if test -z "$tagname"; then
299a18ebfb2Smrg	  $echo "$modename: unable to infer tagged configuration"
300a18ebfb2Smrg	  $echo "$modename: specify a tag with \`--tag'" 1>&2
301a18ebfb2Smrg	  exit $EXIT_FAILURE
302a18ebfb2Smrg#        else
303a18ebfb2Smrg#          $echo "$modename: using $tagname tagged configuration"
304a18ebfb2Smrg	fi
305a18ebfb2Smrg	;;
306a18ebfb2Smrg      esac
307a18ebfb2Smrg    fi
30850806d53Smrg}
30950806d53Smrg
31050806d53Smrg
311a18ebfb2Smrg# func_extract_an_archive dir oldlib
312a18ebfb2Smrgfunc_extract_an_archive ()
31350806d53Smrg{
314a18ebfb2Smrg    f_ex_an_ar_dir="$1"; shift
315a18ebfb2Smrg    f_ex_an_ar_oldlib="$1"
316af1a9c97Smrg
317a18ebfb2Smrg    $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
318a18ebfb2Smrg    $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
319a18ebfb2Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
320a18ebfb2Smrg     :
321a18ebfb2Smrg    else
322a18ebfb2Smrg      $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
323a18ebfb2Smrg      exit $EXIT_FAILURE
32450806d53Smrg    fi
32550806d53Smrg}
32650806d53Smrg
327a18ebfb2Smrg# func_extract_archives gentop oldlib ...
328a18ebfb2Smrgfunc_extract_archives ()
32950806d53Smrg{
330a18ebfb2Smrg    my_gentop="$1"; shift
331a18ebfb2Smrg    my_oldlibs=${1+"$@"}
332a18ebfb2Smrg    my_oldobjs=""
333a18ebfb2Smrg    my_xlib=""
334a18ebfb2Smrg    my_xabs=""
335a18ebfb2Smrg    my_xdir=""
336a18ebfb2Smrg    my_status=""
337a18ebfb2Smrg
338a18ebfb2Smrg    $show "${rm}r $my_gentop"
339a18ebfb2Smrg    $run ${rm}r "$my_gentop"
340a18ebfb2Smrg    $show "$mkdir $my_gentop"
341a18ebfb2Smrg    $run $mkdir "$my_gentop"
342a18ebfb2Smrg    my_status=$?
343a18ebfb2Smrg    if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
344a18ebfb2Smrg      exit $my_status
34550806d53Smrg    fi
34650806d53Smrg
347a18ebfb2Smrg    for my_xlib in $my_oldlibs; do
348a18ebfb2Smrg      # Extract the objects.
349a18ebfb2Smrg      case $my_xlib in
350a18ebfb2Smrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
351a18ebfb2Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
352a18ebfb2Smrg      esac
353a18ebfb2Smrg      my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
354a18ebfb2Smrg      my_xlib_u=$my_xlib
355a18ebfb2Smrg      while :; do
356a18ebfb2Smrg        case " $extracted_archives " in
357a18ebfb2Smrg	*" $my_xlib_u "*)
358a18ebfb2Smrg	  extracted_serial=`expr $extracted_serial + 1`
359a18ebfb2Smrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
360a18ebfb2Smrg	*) break ;;
361a18ebfb2Smrg	esac
362a18ebfb2Smrg      done
363a18ebfb2Smrg      extracted_archives="$extracted_archives $my_xlib_u"
364a18ebfb2Smrg      my_xdir="$my_gentop/$my_xlib_u"
365af1a9c97Smrg
366a18ebfb2Smrg      $show "${rm}r $my_xdir"
367a18ebfb2Smrg      $run ${rm}r "$my_xdir"
368a18ebfb2Smrg      $show "$mkdir $my_xdir"
369a18ebfb2Smrg      $run $mkdir "$my_xdir"
370a18ebfb2Smrg      exit_status=$?
371a18ebfb2Smrg      if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
372a18ebfb2Smrg	exit $exit_status
373a18ebfb2Smrg      fi
374a18ebfb2Smrg      case $host in
375a18ebfb2Smrg      *-darwin*)
376a18ebfb2Smrg	$show "Extracting $my_xabs"
377a18ebfb2Smrg	# Do not bother doing anything if just a dry run
378a18ebfb2Smrg	if test -z "$run"; then
379a18ebfb2Smrg	  darwin_orig_dir=`pwd`
380a18ebfb2Smrg	  cd $my_xdir || exit $?
381a18ebfb2Smrg	  darwin_archive=$my_xabs
382a18ebfb2Smrg	  darwin_curdir=`pwd`
383a18ebfb2Smrg	  darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
384a18ebfb2Smrg	  darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
385a18ebfb2Smrg	  if test -n "$darwin_arches"; then 
386a18ebfb2Smrg	    darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
387a18ebfb2Smrg	    darwin_arch=
388a18ebfb2Smrg	    $show "$darwin_base_archive has multiple architectures $darwin_arches"
389a18ebfb2Smrg	    for darwin_arch in  $darwin_arches ; do
390a18ebfb2Smrg	      mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
391a18ebfb2Smrg	      lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
392a18ebfb2Smrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
393a18ebfb2Smrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
394a18ebfb2Smrg	      cd "$darwin_curdir"
395a18ebfb2Smrg	      $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
396a18ebfb2Smrg	    done # $darwin_arches
397a18ebfb2Smrg      ## Okay now we have a bunch of thin objects, gotta fatten them up :)
398a18ebfb2Smrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
399a18ebfb2Smrg	    darwin_file=
400a18ebfb2Smrg	    darwin_files=
401a18ebfb2Smrg	    for darwin_file in $darwin_filelist; do
402a18ebfb2Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
403a18ebfb2Smrg	      lipo -create -output "$darwin_file" $darwin_files
404a18ebfb2Smrg	    done # $darwin_filelist
405a18ebfb2Smrg	    ${rm}r unfat-$$
406a18ebfb2Smrg	    cd "$darwin_orig_dir"
407a18ebfb2Smrg	  else
408a18ebfb2Smrg	    cd "$darwin_orig_dir"
409a18ebfb2Smrg 	    func_extract_an_archive "$my_xdir" "$my_xabs"
410a18ebfb2Smrg	  fi # $darwin_arches
411a18ebfb2Smrg	fi # $run
412a18ebfb2Smrg	;;
413a18ebfb2Smrg      *)
414a18ebfb2Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
415a18ebfb2Smrg        ;;
416a18ebfb2Smrg      esac
417a18ebfb2Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
418a18ebfb2Smrg    done
419a18ebfb2Smrg    func_extract_archives_result="$my_oldobjs"
42050806d53Smrg}
421a18ebfb2Smrg# End of Shell function definitions
422a18ebfb2Smrg#####################################
42350806d53Smrg
424a18ebfb2Smrg# Darwin sucks
425a18ebfb2Smrgeval std_shrext=\"$shrext_cmds\"
426af1a9c97Smrg
427a18ebfb2Smrgdisable_libs=no
428af1a9c97Smrg
429a18ebfb2Smrg# Parse our command line options once, thoroughly.
430a18ebfb2Smrgwhile test "$#" -gt 0
431a18ebfb2Smrgdo
432a18ebfb2Smrg  arg="$1"
433af1a9c97Smrg  shift
43450806d53Smrg
435a18ebfb2Smrg  case $arg in
436a18ebfb2Smrg  -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
437a18ebfb2Smrg  *) optarg= ;;
438a18ebfb2Smrg  esac
43950806d53Smrg
440a18ebfb2Smrg  # If the previous option needs an argument, assign it.
441a18ebfb2Smrg  if test -n "$prev"; then
442a18ebfb2Smrg    case $prev in
443a18ebfb2Smrg    execute_dlfiles)
444a18ebfb2Smrg      execute_dlfiles="$execute_dlfiles $arg"
445a18ebfb2Smrg      ;;
446a18ebfb2Smrg    tag)
447a18ebfb2Smrg      tagname="$arg"
448a18ebfb2Smrg      preserve_args="${preserve_args}=$arg"
449a18ebfb2Smrg
450a18ebfb2Smrg      # Check whether tagname contains only valid characters
451a18ebfb2Smrg      case $tagname in
452a18ebfb2Smrg      *[!-_A-Za-z0-9,/]*)
453a18ebfb2Smrg	$echo "$progname: invalid tag name: $tagname" 1>&2
454a18ebfb2Smrg	exit $EXIT_FAILURE
455a18ebfb2Smrg	;;
456a18ebfb2Smrg      esac
45750806d53Smrg
458a18ebfb2Smrg      case $tagname in
459a18ebfb2Smrg      CC)
460a18ebfb2Smrg	# Don't test for the "default" C tag, as we know, it's there, but
461a18ebfb2Smrg	# not specially marked.
462a18ebfb2Smrg	;;
463a18ebfb2Smrg      *)
464a18ebfb2Smrg	if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
465a18ebfb2Smrg	  taglist="$taglist $tagname"
466a18ebfb2Smrg	  # Evaluate the configuration.
467a18ebfb2Smrg	  eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
468a18ebfb2Smrg	else
469a18ebfb2Smrg	  $echo "$progname: ignoring unknown tag $tagname" 1>&2
470a18ebfb2Smrg	fi
471a18ebfb2Smrg	;;
472a18ebfb2Smrg      esac
473a18ebfb2Smrg      ;;
474a18ebfb2Smrg    *)
475a18ebfb2Smrg      eval "$prev=\$arg"
476a18ebfb2Smrg      ;;
477a18ebfb2Smrg    esac
478af1a9c97Smrg
479a18ebfb2Smrg    prev=
480a18ebfb2Smrg    prevopt=
481a18ebfb2Smrg    continue
482a18ebfb2Smrg  fi
48350806d53Smrg
484a18ebfb2Smrg  # Have we seen a non-optional argument yet?
485a18ebfb2Smrg  case $arg in
486a18ebfb2Smrg  --help)
487a18ebfb2Smrg    show_help=yes
488a18ebfb2Smrg    ;;
4897965d9acSmrg
490a18ebfb2Smrg  --version)
491a18ebfb2Smrg    echo "\
492a18ebfb2Smrg$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP
493af1a9c97Smrg
494a18ebfb2SmrgCopyright (C) 2008  Free Software Foundation, Inc.
495a18ebfb2SmrgThis is free software; see the source for copying conditions.  There is NO
496a18ebfb2Smrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
497a18ebfb2Smrg    exit $?
498a18ebfb2Smrg    ;;
49950806d53Smrg
500a18ebfb2Smrg  --config)
501a18ebfb2Smrg    ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
50250806d53Smrg    # Now print the configurations for the tags.
50350806d53Smrg    for tagname in $taglist; do
504a18ebfb2Smrg      ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
50550806d53Smrg    done
506af1a9c97Smrg    exit $?
507a18ebfb2Smrg    ;;
50850806d53Smrg
509a18ebfb2Smrg  --debug)
510a18ebfb2Smrg    $echo "$progname: enabling shell trace mode"
511a18ebfb2Smrg    set -x
512a18ebfb2Smrg    preserve_args="$preserve_args $arg"
513a18ebfb2Smrg    ;;
514a18ebfb2Smrg
515a18ebfb2Smrg  --dry-run | -n)
516a18ebfb2Smrg    run=:
517a18ebfb2Smrg    ;;
518a18ebfb2Smrg
519a18ebfb2Smrg  --features)
520a18ebfb2Smrg    $echo "host: $host"
52150806d53Smrg    if test "$build_libtool_libs" = yes; then
522a18ebfb2Smrg      $echo "enable shared libraries"
52350806d53Smrg    else
524a18ebfb2Smrg      $echo "disable shared libraries"
52550806d53Smrg    fi
52650806d53Smrg    if test "$build_old_libs" = yes; then
527a18ebfb2Smrg      $echo "enable static libraries"
52850806d53Smrg    else
529a18ebfb2Smrg      $echo "disable static libraries"
53050806d53Smrg    fi
53150806d53Smrg    exit $?
532a18ebfb2Smrg    ;;
53350806d53Smrg
534a18ebfb2Smrg  --finish) mode="finish" ;;
53550806d53Smrg
536a18ebfb2Smrg  --mode) prevopt="--mode" prev=mode ;;
537a18ebfb2Smrg  --mode=*) mode="$optarg" ;;
538af1a9c97Smrg
539a18ebfb2Smrg  --preserve-dup-deps) duplicate_deps="yes" ;;
54050806d53Smrg
541a18ebfb2Smrg  --quiet | --silent)
542a18ebfb2Smrg    show=:
543a18ebfb2Smrg    preserve_args="$preserve_args $arg"
54450806d53Smrg    ;;
545a18ebfb2Smrg
546a18ebfb2Smrg  --tag)
547a18ebfb2Smrg    prevopt="--tag"
548a18ebfb2Smrg    prev=tag
549a18ebfb2Smrg    preserve_args="$preserve_args --tag"
55050806d53Smrg    ;;
551a18ebfb2Smrg  --tag=*)
552a18ebfb2Smrg    set tag "$optarg" ${1+"$@"}
553a18ebfb2Smrg    shift
554a18ebfb2Smrg    prev=tag
555a18ebfb2Smrg    preserve_args="$preserve_args --tag"
55650806d53Smrg    ;;
557a18ebfb2Smrg
558a18ebfb2Smrg  -dlopen)
559a18ebfb2Smrg    prevopt="-dlopen"
560a18ebfb2Smrg    prev=execute_dlfiles
561af1a9c97Smrg    ;;
562a18ebfb2Smrg
563a18ebfb2Smrg  -*)
564a18ebfb2Smrg    $echo "$modename: unrecognized option \`$arg'" 1>&2
565a18ebfb2Smrg    $echo "$help" 1>&2
566a18ebfb2Smrg    exit $EXIT_FAILURE
567af1a9c97Smrg    ;;
568a18ebfb2Smrg
569a18ebfb2Smrg  *)
570a18ebfb2Smrg    nonopt="$arg"
571a18ebfb2Smrg    break
57250806d53Smrg    ;;
57350806d53Smrg  esac
574a18ebfb2Smrgdone
57550806d53Smrg
576a18ebfb2Smrgif test -n "$prevopt"; then
577a18ebfb2Smrg  $echo "$modename: option \`$prevopt' requires an argument" 1>&2
578a18ebfb2Smrg  $echo "$help" 1>&2
579a18ebfb2Smrg  exit $EXIT_FAILURE
580a18ebfb2Smrgfi
581af1a9c97Smrg
582a18ebfb2Smrgcase $disable_libs in
583a18ebfb2Smrgno) 
584a18ebfb2Smrg  ;;
585a18ebfb2Smrgshared)
586a18ebfb2Smrg  build_libtool_libs=no
587a18ebfb2Smrg  build_old_libs=yes
588a18ebfb2Smrg  ;;
589a18ebfb2Smrgstatic)
590a18ebfb2Smrg  build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
591a18ebfb2Smrg  ;;
592a18ebfb2Smrgesac
593af1a9c97Smrg
594a18ebfb2Smrg# If this variable is set in any of the actions, the command in it
595a18ebfb2Smrg# will be execed at the end.  This prevents here-documents from being
596a18ebfb2Smrg# left over by shells.
597a18ebfb2Smrgexec_cmd=
598af1a9c97Smrg
599a18ebfb2Smrgif test -z "$show_help"; then
600af1a9c97Smrg
601a18ebfb2Smrg  # Infer the operation mode.
602a18ebfb2Smrg  if test -z "$mode"; then
603a18ebfb2Smrg    $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
604a18ebfb2Smrg    $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
605a18ebfb2Smrg    case $nonopt in
606a18ebfb2Smrg    *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
607a18ebfb2Smrg      mode=link
608a18ebfb2Smrg      for arg
609a18ebfb2Smrg      do
610a18ebfb2Smrg	case $arg in
611a18ebfb2Smrg	-c)
612a18ebfb2Smrg	   mode=compile
613a18ebfb2Smrg	   break
614a18ebfb2Smrg	   ;;
615a18ebfb2Smrg	esac
616a18ebfb2Smrg      done
61750806d53Smrg      ;;
618a18ebfb2Smrg    *db | *dbx | *strace | *truss)
619a18ebfb2Smrg      mode=execute
620af1a9c97Smrg      ;;
621a18ebfb2Smrg    *install*|cp|mv)
622a18ebfb2Smrg      mode=install
623a18ebfb2Smrg      ;;
624a18ebfb2Smrg    *rm)
625a18ebfb2Smrg      mode=uninstall
626a18ebfb2Smrg      ;;
627a18ebfb2Smrg    *)
628a18ebfb2Smrg      # If we have no mode, but dlfiles were specified, then do execute mode.
629a18ebfb2Smrg      test -n "$execute_dlfiles" && mode=execute
630af1a9c97Smrg
631a18ebfb2Smrg      # Just use the default operation mode.
632a18ebfb2Smrg      if test -z "$mode"; then
633a18ebfb2Smrg	if test -n "$nonopt"; then
634a18ebfb2Smrg	  $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
635a18ebfb2Smrg	else
636a18ebfb2Smrg	  $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
637a18ebfb2Smrg	fi
63850806d53Smrg      fi
639a18ebfb2Smrg      ;;
640a18ebfb2Smrg    esac
64150806d53Smrg  fi
64250806d53Smrg
64350806d53Smrg  # Only execute mode is allowed to have -dlopen flags.
64450806d53Smrg  if test -n "$execute_dlfiles" && test "$mode" != execute; then
645a18ebfb2Smrg    $echo "$modename: unrecognized option \`-dlopen'" 1>&2
646a18ebfb2Smrg    $echo "$help" 1>&2
64750806d53Smrg    exit $EXIT_FAILURE
64850806d53Smrg  fi
64950806d53Smrg
65050806d53Smrg  # Change the help message to a mode-specific one.
65150806d53Smrg  generic_help="$help"
652a18ebfb2Smrg  help="Try \`$modename --help --mode=$mode' for more information."
65350806d53Smrg
654a18ebfb2Smrg  # These modes are in order of execution frequency so that they run quickly.
655a18ebfb2Smrg  case $mode in
656a18ebfb2Smrg  # libtool compile mode
657a18ebfb2Smrg  compile)
658a18ebfb2Smrg    modename="$modename: compile"
659a18ebfb2Smrg    # Get the compilation command and the source file.
660a18ebfb2Smrg    base_compile=
661a18ebfb2Smrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
662a18ebfb2Smrg    suppress_opt=yes
663a18ebfb2Smrg    suppress_output=
664a18ebfb2Smrg    arg_mode=normal
665a18ebfb2Smrg    libobj=
666a18ebfb2Smrg    later=
66750806d53Smrg
668a18ebfb2Smrg    for arg
669a18ebfb2Smrg    do
670a18ebfb2Smrg      case $arg_mode in
671a18ebfb2Smrg      arg  )
672a18ebfb2Smrg	# do not "continue".  Instead, add this to base_compile
673a18ebfb2Smrg	lastarg="$arg"
674a18ebfb2Smrg	arg_mode=normal
675a18ebfb2Smrg	;;
67650806d53Smrg
677a18ebfb2Smrg      target )
678a18ebfb2Smrg	libobj="$arg"
679a18ebfb2Smrg	arg_mode=normal
680a18ebfb2Smrg	continue
681a18ebfb2Smrg	;;
68250806d53Smrg
683a18ebfb2Smrg      normal )
684a18ebfb2Smrg	# Accept any command-line options.
685a18ebfb2Smrg	case $arg in
686a18ebfb2Smrg	-o)
687a18ebfb2Smrg	  if test -n "$libobj" ; then
688a18ebfb2Smrg	    $echo "$modename: you cannot specify \`-o' more than once" 1>&2
689a18ebfb2Smrg	    exit $EXIT_FAILURE
690a18ebfb2Smrg	  fi
691a18ebfb2Smrg	  arg_mode=target
692a18ebfb2Smrg	  continue
693a18ebfb2Smrg	  ;;
69450806d53Smrg
695a18ebfb2Smrg	-static | -prefer-pic | -prefer-non-pic)
696a18ebfb2Smrg	  later="$later $arg"
697a18ebfb2Smrg	  continue
698a18ebfb2Smrg	  ;;
699af1a9c97Smrg
700af1a9c97Smrg	-no-suppress)
70150806d53Smrg	  suppress_opt=no
70250806d53Smrg	  continue
70350806d53Smrg	  ;;
70450806d53Smrg
70550806d53Smrg	-Xcompiler)
70650806d53Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
70750806d53Smrg	  continue      #  The current "srcfile" will either be retained or
70850806d53Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
70950806d53Smrg
71050806d53Smrg	-Wc,*)
711a18ebfb2Smrg	  args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
71250806d53Smrg	  lastarg=
71350806d53Smrg	  save_ifs="$IFS"; IFS=','
714a18ebfb2Smrg 	  for arg in $args; do
71550806d53Smrg	    IFS="$save_ifs"
716a18ebfb2Smrg
717a18ebfb2Smrg	    # Double-quote args containing other shell metacharacters.
718a18ebfb2Smrg	    # Many Bourne shells cannot handle close brackets correctly
719a18ebfb2Smrg	    # in scan sets, so we specify it separately.
720a18ebfb2Smrg	    case $arg in
721a18ebfb2Smrg	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
722a18ebfb2Smrg	      arg="\"$arg\""
723a18ebfb2Smrg	      ;;
724a18ebfb2Smrg	    esac
725a18ebfb2Smrg	    lastarg="$lastarg $arg"
72650806d53Smrg	  done
72750806d53Smrg	  IFS="$save_ifs"
728a18ebfb2Smrg	  lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
72950806d53Smrg
73050806d53Smrg	  # Add the arguments to base_compile.
73150806d53Smrg	  base_compile="$base_compile $lastarg"
73250806d53Smrg	  continue
73350806d53Smrg	  ;;
73450806d53Smrg
735a18ebfb2Smrg	* )
73650806d53Smrg	  # Accept the current argument as the source file.
73750806d53Smrg	  # The previous "srcfile" becomes the current argument.
73850806d53Smrg	  #
73950806d53Smrg	  lastarg="$srcfile"
74050806d53Smrg	  srcfile="$arg"
74150806d53Smrg	  ;;
74250806d53Smrg	esac  #  case $arg
74350806d53Smrg	;;
74450806d53Smrg      esac    #  case $arg_mode
74550806d53Smrg
74650806d53Smrg      # Aesthetically quote the previous argument.
747a18ebfb2Smrg      lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
748a18ebfb2Smrg
749a18ebfb2Smrg      case $lastarg in
750a18ebfb2Smrg      # Double-quote args containing other shell metacharacters.
751a18ebfb2Smrg      # Many Bourne shells cannot handle close brackets correctly
752a18ebfb2Smrg      # in scan sets, and some SunOS ksh mistreat backslash-escaping
753a18ebfb2Smrg      # in scan sets (worked around with variable expansion),
754a18ebfb2Smrg      # and furthermore cannot handle '|' '&' '(' ')' in scan sets 
755a18ebfb2Smrg      # at all, so we specify them separately.
756a18ebfb2Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
757a18ebfb2Smrg	lastarg="\"$lastarg\""
758a18ebfb2Smrg	;;
759a18ebfb2Smrg      esac
760a18ebfb2Smrg
761a18ebfb2Smrg      base_compile="$base_compile $lastarg"
76250806d53Smrg    done # for arg
76350806d53Smrg
76450806d53Smrg    case $arg_mode in
76550806d53Smrg    arg)
766a18ebfb2Smrg      $echo "$modename: you must specify an argument for -Xcompile"
767a18ebfb2Smrg      exit $EXIT_FAILURE
76850806d53Smrg      ;;
76950806d53Smrg    target)
770a18ebfb2Smrg      $echo "$modename: you must specify a target with \`-o'" 1>&2
771a18ebfb2Smrg      exit $EXIT_FAILURE
77250806d53Smrg      ;;
77350806d53Smrg    *)
77450806d53Smrg      # Get the name of the library object.
775a18ebfb2Smrg      [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
77650806d53Smrg      ;;
77750806d53Smrg    esac
77850806d53Smrg
77950806d53Smrg    # Recognize several different file suffixes.
78050806d53Smrg    # If the user specifies -o file.o, it is replaced with file.lo
781a18ebfb2Smrg    xform='[cCFSifmso]'
78250806d53Smrg    case $libobj in
783a18ebfb2Smrg    *.ada) xform=ada ;;
784a18ebfb2Smrg    *.adb) xform=adb ;;
785a18ebfb2Smrg    *.ads) xform=ads ;;
786a18ebfb2Smrg    *.asm) xform=asm ;;
787a18ebfb2Smrg    *.c++) xform=c++ ;;
788a18ebfb2Smrg    *.cc) xform=cc ;;
789a18ebfb2Smrg    *.ii) xform=ii ;;
790a18ebfb2Smrg    *.class) xform=class ;;
791a18ebfb2Smrg    *.cpp) xform=cpp ;;
792a18ebfb2Smrg    *.cxx) xform=cxx ;;
793a18ebfb2Smrg    *.[fF][09]?) xform=[fF][09]. ;;
794a18ebfb2Smrg    *.for) xform=for ;;
795a18ebfb2Smrg    *.java) xform=java ;;
796a18ebfb2Smrg    *.obj) xform=obj ;;
797a18ebfb2Smrg    *.sx) xform=sx ;;
79850806d53Smrg    esac
79950806d53Smrg
800a18ebfb2Smrg    libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
801a18ebfb2Smrg
80250806d53Smrg    case $libobj in
803a18ebfb2Smrg    *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
80450806d53Smrg    *)
805a18ebfb2Smrg      $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
806a18ebfb2Smrg      exit $EXIT_FAILURE
80750806d53Smrg      ;;
80850806d53Smrg    esac
80950806d53Smrg
81050806d53Smrg    func_infer_tag $base_compile
81150806d53Smrg
81250806d53Smrg    for arg in $later; do
81350806d53Smrg      case $arg in
81450806d53Smrg      -static)
81550806d53Smrg	build_old_libs=yes
81650806d53Smrg	continue
81750806d53Smrg	;;
81850806d53Smrg
81950806d53Smrg      -prefer-pic)
82050806d53Smrg	pic_mode=yes
82150806d53Smrg	continue
82250806d53Smrg	;;
82350806d53Smrg
82450806d53Smrg      -prefer-non-pic)
82550806d53Smrg	pic_mode=no
82650806d53Smrg	continue
82750806d53Smrg	;;
82850806d53Smrg      esac
82950806d53Smrg    done
83050806d53Smrg
831a18ebfb2Smrg    qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
832a18ebfb2Smrg    case $qlibobj in
833a18ebfb2Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
834a18ebfb2Smrg	qlibobj="\"$qlibobj\"" ;;
835a18ebfb2Smrg    esac
836a18ebfb2Smrg    test "X$libobj" != "X$qlibobj" \
837a18ebfb2Smrg	&& $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' 	&()|`$[]' \
838a18ebfb2Smrg	&& $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
839a18ebfb2Smrg    objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
840a18ebfb2Smrg    xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
841a18ebfb2Smrg    if test "X$xdir" = "X$obj"; then
842a18ebfb2Smrg      xdir=
843a18ebfb2Smrg    else
844a18ebfb2Smrg      xdir=$xdir/
845a18ebfb2Smrg    fi
84650806d53Smrg    lobj=${xdir}$objdir/$objname
84750806d53Smrg
848a18ebfb2Smrg    if test -z "$base_compile"; then
849a18ebfb2Smrg      $echo "$modename: you must specify a compilation command" 1>&2
850a18ebfb2Smrg      $echo "$help" 1>&2
851a18ebfb2Smrg      exit $EXIT_FAILURE
852a18ebfb2Smrg    fi
85350806d53Smrg
85450806d53Smrg    # Delete any leftover library objects.
85550806d53Smrg    if test "$build_old_libs" = yes; then
85650806d53Smrg      removelist="$obj $lobj $libobj ${libobj}T"
85750806d53Smrg    else
85850806d53Smrg      removelist="$lobj $libobj ${libobj}T"
85950806d53Smrg    fi
86050806d53Smrg
861a18ebfb2Smrg    $run $rm $removelist
862a18ebfb2Smrg    trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
863a18ebfb2Smrg
86450806d53Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
86550806d53Smrg    case $host_os in
866a18ebfb2Smrg    cygwin* | mingw* | pw32* | os2*)
86750806d53Smrg      pic_mode=default
86850806d53Smrg      ;;
86950806d53Smrg    esac
87050806d53Smrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
87150806d53Smrg      # non-PIC code in shared libraries is not supported
87250806d53Smrg      pic_mode=default
87350806d53Smrg    fi
87450806d53Smrg
87550806d53Smrg    # Calculate the filename of the output object if compiler does
87650806d53Smrg    # not support -o with -c
87750806d53Smrg    if test "$compiler_c_o" = no; then
878a18ebfb2Smrg      output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
87950806d53Smrg      lockfile="$output_obj.lock"
880a18ebfb2Smrg      removelist="$removelist $output_obj $lockfile"
881a18ebfb2Smrg      trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
88250806d53Smrg    else
88350806d53Smrg      output_obj=
88450806d53Smrg      need_locks=no
88550806d53Smrg      lockfile=
88650806d53Smrg    fi
88750806d53Smrg
88850806d53Smrg    # Lock this critical section if it is needed
88950806d53Smrg    # We use this script file to make the link, it avoids creating a new file
89050806d53Smrg    if test "$need_locks" = yes; then
891a18ebfb2Smrg      until $run ln "$progpath" "$lockfile" 2>/dev/null; do
892a18ebfb2Smrg	$show "Waiting for $lockfile to be removed"
89350806d53Smrg	sleep 2
89450806d53Smrg      done
89550806d53Smrg    elif test "$need_locks" = warn; then
89650806d53Smrg      if test -f "$lockfile"; then
897a18ebfb2Smrg	$echo "\
89850806d53Smrg*** ERROR, $lockfile exists and contains:
89950806d53Smrg`cat $lockfile 2>/dev/null`
90050806d53Smrg
90150806d53SmrgThis indicates that another process is trying to use the same
90250806d53Smrgtemporary object file, and libtool could not work around it because
90350806d53Smrgyour compiler does not support \`-c' and \`-o' together.  If you
90450806d53Smrgrepeat this compilation, it may succeed, by chance, but you had better
90550806d53Smrgavoid parallel builds (make -j) in this platform, or get a better
90650806d53Smrgcompiler."
90750806d53Smrg
908a18ebfb2Smrg	$run $rm $removelist
90950806d53Smrg	exit $EXIT_FAILURE
91050806d53Smrg      fi
911a18ebfb2Smrg      $echo "$srcfile" > "$lockfile"
91250806d53Smrg    fi
91350806d53Smrg
91450806d53Smrg    if test -n "$fix_srcfile_path"; then
91550806d53Smrg      eval srcfile=\"$fix_srcfile_path\"
91650806d53Smrg    fi
917a18ebfb2Smrg    qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"`
918a18ebfb2Smrg    case $qsrcfile in
919a18ebfb2Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
920a18ebfb2Smrg      qsrcfile="\"$qsrcfile\"" ;;
921a18ebfb2Smrg    esac
922a18ebfb2Smrg
923a18ebfb2Smrg    $run $rm "$libobj" "${libobj}T"
924a18ebfb2Smrg
925a18ebfb2Smrg    # Create a libtool object file (analogous to a ".la" file),
926a18ebfb2Smrg    # but don't create it if we're doing a dry run.
927a18ebfb2Smrg    test -z "$run" && cat > ${libobj}T <<EOF
928a18ebfb2Smrg# $libobj - a libtool object file
929a18ebfb2Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
930a18ebfb2Smrg#
931a18ebfb2Smrg# Please DO NOT delete this file!
932a18ebfb2Smrg# It is necessary for linking the library.
933a18ebfb2Smrg
934a18ebfb2Smrg# Name of the PIC object.
935a18ebfb2SmrgEOF
93650806d53Smrg
93750806d53Smrg    # Only build a PIC object if we are building libtool libraries.
93850806d53Smrg    if test "$build_libtool_libs" = yes; then
93950806d53Smrg      # Without this assignment, base_compile gets emptied.
94050806d53Smrg      fbsd_hideous_sh_bug=$base_compile
94150806d53Smrg
94250806d53Smrg      if test "$pic_mode" != no; then
94350806d53Smrg	command="$base_compile $qsrcfile $pic_flag"
94450806d53Smrg      else
94550806d53Smrg	# Don't build PIC code
94650806d53Smrg	command="$base_compile $qsrcfile"
94750806d53Smrg      fi
94850806d53Smrg
949a18ebfb2Smrg      if test ! -d "${xdir}$objdir"; then
950a18ebfb2Smrg	$show "$mkdir ${xdir}$objdir"
951a18ebfb2Smrg	$run $mkdir ${xdir}$objdir
952a18ebfb2Smrg	exit_status=$?
953a18ebfb2Smrg	if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
954a18ebfb2Smrg	  exit $exit_status
955a18ebfb2Smrg	fi
956a18ebfb2Smrg      fi
95750806d53Smrg
95850806d53Smrg      if test -z "$output_obj"; then
95950806d53Smrg	# Place PIC objects in $objdir
96050806d53Smrg	command="$command -o $lobj"
96150806d53Smrg      fi
96250806d53Smrg
963a18ebfb2Smrg      $run $rm "$lobj" "$output_obj"
964a18ebfb2Smrg
965a18ebfb2Smrg      $show "$command"
966a18ebfb2Smrg      if $run eval $lt_env "$command"; then :
967a18ebfb2Smrg      else
968a18ebfb2Smrg	test -n "$output_obj" && $run $rm $removelist
969a18ebfb2Smrg	exit $EXIT_FAILURE
970a18ebfb2Smrg      fi
97150806d53Smrg
97250806d53Smrg      if test "$need_locks" = warn &&
97350806d53Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
974a18ebfb2Smrg	$echo "\
97550806d53Smrg*** ERROR, $lockfile contains:
97650806d53Smrg`cat $lockfile 2>/dev/null`
97750806d53Smrg
97850806d53Smrgbut it should contain:
97950806d53Smrg$srcfile
98050806d53Smrg
98150806d53SmrgThis indicates that another process is trying to use the same
98250806d53Smrgtemporary object file, and libtool could not work around it because
98350806d53Smrgyour compiler does not support \`-c' and \`-o' together.  If you
98450806d53Smrgrepeat this compilation, it may succeed, by chance, but you had better
98550806d53Smrgavoid parallel builds (make -j) in this platform, or get a better
98650806d53Smrgcompiler."
98750806d53Smrg
988a18ebfb2Smrg	$run $rm $removelist
98950806d53Smrg	exit $EXIT_FAILURE
99050806d53Smrg      fi
99150806d53Smrg
99250806d53Smrg      # Just move the object if needed, then go on to compile the next one
99350806d53Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
994a18ebfb2Smrg	$show "$mv $output_obj $lobj"
995a18ebfb2Smrg	if $run $mv $output_obj $lobj; then :
996a18ebfb2Smrg	else
997a18ebfb2Smrg	  error=$?
998a18ebfb2Smrg	  $run $rm $removelist
999a18ebfb2Smrg	  exit $error
1000a18ebfb2Smrg	fi
100150806d53Smrg      fi
100250806d53Smrg
1003a18ebfb2Smrg      # Append the name of the PIC object to the libtool object file.
1004a18ebfb2Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
1005a18ebfb2Smrgpic_object='$objdir/$objname'
1006a18ebfb2Smrg
1007a18ebfb2SmrgEOF
1008a18ebfb2Smrg
100950806d53Smrg      # Allow error messages only from the first compilation.
101050806d53Smrg      if test "$suppress_opt" = yes; then
1011a18ebfb2Smrg        suppress_output=' >/dev/null 2>&1'
101250806d53Smrg      fi
1013a18ebfb2Smrg    else
1014a18ebfb2Smrg      # No PIC object so indicate it doesn't exist in the libtool
1015a18ebfb2Smrg      # object file.
1016a18ebfb2Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
1017a18ebfb2Smrgpic_object=none
1018a18ebfb2Smrg
1019a18ebfb2SmrgEOF
102050806d53Smrg    fi
102150806d53Smrg
102250806d53Smrg    # Only build a position-dependent object if we build old libraries.
102350806d53Smrg    if test "$build_old_libs" = yes; then
102450806d53Smrg      if test "$pic_mode" != yes; then
102550806d53Smrg	# Don't build PIC code
1026a18ebfb2Smrg	command="$base_compile $qsrcfile"
102750806d53Smrg      else
102850806d53Smrg	command="$base_compile $qsrcfile $pic_flag"
102950806d53Smrg      fi
103050806d53Smrg      if test "$compiler_c_o" = yes; then
103150806d53Smrg	command="$command -o $obj"
103250806d53Smrg      fi
103350806d53Smrg
103450806d53Smrg      # Suppress compiler output if we already did a PIC compilation.
103550806d53Smrg      command="$command$suppress_output"
1036a18ebfb2Smrg      $run $rm "$obj" "$output_obj"
1037a18ebfb2Smrg      $show "$command"
1038a18ebfb2Smrg      if $run eval $lt_env "$command"; then :
1039a18ebfb2Smrg      else
1040a18ebfb2Smrg	$run $rm $removelist
1041a18ebfb2Smrg	exit $EXIT_FAILURE
1042a18ebfb2Smrg      fi
104350806d53Smrg
104450806d53Smrg      if test "$need_locks" = warn &&
104550806d53Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1046a18ebfb2Smrg	$echo "\
104750806d53Smrg*** ERROR, $lockfile contains:
104850806d53Smrg`cat $lockfile 2>/dev/null`
104950806d53Smrg
105050806d53Smrgbut it should contain:
105150806d53Smrg$srcfile
105250806d53Smrg
105350806d53SmrgThis indicates that another process is trying to use the same
105450806d53Smrgtemporary object file, and libtool could not work around it because
105550806d53Smrgyour compiler does not support \`-c' and \`-o' together.  If you
105650806d53Smrgrepeat this compilation, it may succeed, by chance, but you had better
105750806d53Smrgavoid parallel builds (make -j) in this platform, or get a better
105850806d53Smrgcompiler."
105950806d53Smrg
1060a18ebfb2Smrg	$run $rm $removelist
106150806d53Smrg	exit $EXIT_FAILURE
106250806d53Smrg      fi
106350806d53Smrg
106450806d53Smrg      # Just move the object if needed
106550806d53Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
1066a18ebfb2Smrg	$show "$mv $output_obj $obj"
1067a18ebfb2Smrg	if $run $mv $output_obj $obj; then :
1068a18ebfb2Smrg	else
1069a18ebfb2Smrg	  error=$?
1070a18ebfb2Smrg	  $run $rm $removelist
1071a18ebfb2Smrg	  exit $error
1072a18ebfb2Smrg	fi
107350806d53Smrg      fi
1074a18ebfb2Smrg
1075a18ebfb2Smrg      # Append the name of the non-PIC object the libtool object file.
1076a18ebfb2Smrg      # Only append if the libtool object file exists.
1077a18ebfb2Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
1078a18ebfb2Smrg# Name of the non-PIC object.
1079a18ebfb2Smrgnon_pic_object='$objname'
1080a18ebfb2Smrg
1081a18ebfb2SmrgEOF
1082a18ebfb2Smrg    else
1083a18ebfb2Smrg      # Append the name of the non-PIC object the libtool object file.
1084a18ebfb2Smrg      # Only append if the libtool object file exists.
1085a18ebfb2Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
1086a18ebfb2Smrg# Name of the non-PIC object.
1087a18ebfb2Smrgnon_pic_object=none
1088a18ebfb2Smrg
1089a18ebfb2SmrgEOF
109050806d53Smrg    fi
109150806d53Smrg
1092a18ebfb2Smrg    $run $mv "${libobj}T" "${libobj}"
109350806d53Smrg
1094a18ebfb2Smrg    # Unlock the critical section if it was locked
1095a18ebfb2Smrg    if test "$need_locks" != no; then
1096a18ebfb2Smrg      $run $rm "$lockfile"
1097a18ebfb2Smrg    fi
109850806d53Smrg
109950806d53Smrg    exit $EXIT_SUCCESS
1100a18ebfb2Smrg    ;;
110150806d53Smrg
1102a18ebfb2Smrg  # libtool link mode
1103a18ebfb2Smrg  link | relink)
1104a18ebfb2Smrg    modename="$modename: link"
1105a18ebfb2Smrg    case $host in
1106a18ebfb2Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
1107a18ebfb2Smrg      # It is impossible to link a dll without this setting, and
1108a18ebfb2Smrg      # we shouldn't force the makefile maintainer to figure out
1109a18ebfb2Smrg      # which system we are compiling for in order to pass an extra
1110a18ebfb2Smrg      # flag for every libtool invocation.
1111a18ebfb2Smrg      # allow_undefined=no
111250806d53Smrg
1113a18ebfb2Smrg      # FIXME: Unfortunately, there are problems with the above when trying
1114a18ebfb2Smrg      # to make a dll which has undefined symbols, in which case not
1115a18ebfb2Smrg      # even a static library is built.  For now, we need to specify
1116a18ebfb2Smrg      # -no-undefined on the libtool link line when we can be certain
1117a18ebfb2Smrg      # that all symbols are satisfied, otherwise we get a static library.
1118a18ebfb2Smrg      allow_undefined=yes
1119a18ebfb2Smrg      ;;
1120a18ebfb2Smrg    *)
1121a18ebfb2Smrg      allow_undefined=yes
1122a18ebfb2Smrg      ;;
1123a18ebfb2Smrg    esac
1124a18ebfb2Smrg    libtool_args="$nonopt"
1125a18ebfb2Smrg    base_compile="$nonopt $@"
1126a18ebfb2Smrg    compile_command="$nonopt"
1127a18ebfb2Smrg    finalize_command="$nonopt"
112850806d53Smrg
1129a18ebfb2Smrg    compile_rpath=
1130a18ebfb2Smrg    finalize_rpath=
1131a18ebfb2Smrg    compile_shlibpath=
1132a18ebfb2Smrg    finalize_shlibpath=
1133a18ebfb2Smrg    convenience=
1134a18ebfb2Smrg    old_convenience=
1135a18ebfb2Smrg    deplibs=
1136a18ebfb2Smrg    old_deplibs=
1137a18ebfb2Smrg    compiler_flags=
1138a18ebfb2Smrg    linker_flags=
1139a18ebfb2Smrg    dllsearchpath=
1140a18ebfb2Smrg    lib_search_path=`pwd`
1141a18ebfb2Smrg    inst_prefix_dir=
114250806d53Smrg
1143a18ebfb2Smrg    avoid_version=no
1144a18ebfb2Smrg    dlfiles=
1145a18ebfb2Smrg    dlprefiles=
1146a18ebfb2Smrg    dlself=no
1147a18ebfb2Smrg    export_dynamic=no
1148a18ebfb2Smrg    export_symbols=
1149a18ebfb2Smrg    export_symbols_regex=
1150a18ebfb2Smrg    generated=
1151a18ebfb2Smrg    libobjs=
1152a18ebfb2Smrg    ltlibs=
1153a18ebfb2Smrg    module=no
1154a18ebfb2Smrg    no_install=no
1155a18ebfb2Smrg    objs=
1156a18ebfb2Smrg    non_pic_objects=
1157a18ebfb2Smrg    notinst_path= # paths that contain not-installed libtool libraries
1158a18ebfb2Smrg    precious_files_regex=
1159a18ebfb2Smrg    prefer_static_libs=no
1160a18ebfb2Smrg    preload=no
1161a18ebfb2Smrg    prev=
1162a18ebfb2Smrg    prevarg=
1163a18ebfb2Smrg    release=
1164a18ebfb2Smrg    rpath=
1165a18ebfb2Smrg    xrpath=
1166a18ebfb2Smrg    perm_rpath=
1167a18ebfb2Smrg    temp_rpath=
1168a18ebfb2Smrg    thread_safe=no
1169a18ebfb2Smrg    vinfo=
1170a18ebfb2Smrg    vinfo_number=no
1171a18ebfb2Smrg    single_module="${wl}-single_module"
117250806d53Smrg
1173a18ebfb2Smrg    func_infer_tag $base_compile
117450806d53Smrg
1175a18ebfb2Smrg    # We need to know -static, to get the right output filenames.
1176a18ebfb2Smrg    for arg
1177a18ebfb2Smrg    do
1178a18ebfb2Smrg      case $arg in
1179a18ebfb2Smrg      -all-static | -static | -static-libtool-libs)
1180a18ebfb2Smrg	case $arg in
1181a18ebfb2Smrg	-all-static)
1182a18ebfb2Smrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
1183a18ebfb2Smrg	    $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
1184a18ebfb2Smrg	  fi
1185a18ebfb2Smrg	  if test -n "$link_static_flag"; then
1186a18ebfb2Smrg	    dlopen_self=$dlopen_self_static
1187a18ebfb2Smrg	  fi
1188a18ebfb2Smrg	  prefer_static_libs=yes
1189a18ebfb2Smrg	  ;;
1190a18ebfb2Smrg	-static)
1191a18ebfb2Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
1192a18ebfb2Smrg	    dlopen_self=$dlopen_self_static
1193a18ebfb2Smrg	  fi
1194a18ebfb2Smrg	  prefer_static_libs=built
1195a18ebfb2Smrg	  ;;
1196a18ebfb2Smrg	-static-libtool-libs)
1197a18ebfb2Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
1198a18ebfb2Smrg	    dlopen_self=$dlopen_self_static
1199a18ebfb2Smrg	  fi
1200a18ebfb2Smrg	  prefer_static_libs=yes
1201a18ebfb2Smrg	  ;;
1202a18ebfb2Smrg	esac
1203a18ebfb2Smrg	build_libtool_libs=no
1204a18ebfb2Smrg	build_old_libs=yes
1205a18ebfb2Smrg	break
1206a18ebfb2Smrg	;;
1207a18ebfb2Smrg      esac
1208a18ebfb2Smrg    done
120950806d53Smrg
1210a18ebfb2Smrg    # See if our shared archives depend on static archives.
1211a18ebfb2Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
121250806d53Smrg
1213a18ebfb2Smrg    # Go through the arguments, transforming them on the way.
1214a18ebfb2Smrg    while test "$#" -gt 0; do
1215a18ebfb2Smrg      arg="$1"
1216a18ebfb2Smrg      shift
1217a18ebfb2Smrg      case $arg in
1218a18ebfb2Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1219a18ebfb2Smrg	qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
1220a18ebfb2Smrg	;;
1221a18ebfb2Smrg      *) qarg=$arg ;;
1222a18ebfb2Smrg      esac
1223a18ebfb2Smrg      libtool_args="$libtool_args $qarg"
122450806d53Smrg
1225a18ebfb2Smrg      # If the previous option needs an argument, assign it.
1226a18ebfb2Smrg      if test -n "$prev"; then
1227a18ebfb2Smrg	case $prev in
1228a18ebfb2Smrg	output)
1229a18ebfb2Smrg	  compile_command="$compile_command @OUTPUT@"
1230a18ebfb2Smrg	  finalize_command="$finalize_command @OUTPUT@"
1231a18ebfb2Smrg	  ;;
1232a18ebfb2Smrg	esac
123350806d53Smrg
1234a18ebfb2Smrg	case $prev in
1235a18ebfb2Smrg	dlfiles|dlprefiles)
1236a18ebfb2Smrg	  if test "$preload" = no; then
1237a18ebfb2Smrg	    # Add the symbol object into the linking commands.
1238a18ebfb2Smrg	    compile_command="$compile_command @SYMFILE@"
1239a18ebfb2Smrg	    finalize_command="$finalize_command @SYMFILE@"
1240a18ebfb2Smrg	    preload=yes
1241a18ebfb2Smrg	  fi
1242a18ebfb2Smrg	  case $arg in
1243a18ebfb2Smrg	  *.la | *.lo) ;;  # We handle these cases below.
1244a18ebfb2Smrg	  force)
1245a18ebfb2Smrg	    if test "$dlself" = no; then
1246a18ebfb2Smrg	      dlself=needless
1247a18ebfb2Smrg	      export_dynamic=yes
1248a18ebfb2Smrg	    fi
1249a18ebfb2Smrg	    prev=
1250a18ebfb2Smrg	    continue
1251a18ebfb2Smrg	    ;;
1252a18ebfb2Smrg	  self)
1253a18ebfb2Smrg	    if test "$prev" = dlprefiles; then
1254a18ebfb2Smrg	      dlself=yes
1255a18ebfb2Smrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
1256a18ebfb2Smrg	      dlself=yes
1257a18ebfb2Smrg	    else
1258a18ebfb2Smrg	      dlself=needless
1259a18ebfb2Smrg	      export_dynamic=yes
1260a18ebfb2Smrg	    fi
1261a18ebfb2Smrg	    prev=
1262a18ebfb2Smrg	    continue
1263a18ebfb2Smrg	    ;;
1264a18ebfb2Smrg	  *)
1265a18ebfb2Smrg	    if test "$prev" = dlfiles; then
1266a18ebfb2Smrg	      dlfiles="$dlfiles $arg"
1267a18ebfb2Smrg	    else
1268a18ebfb2Smrg	      dlprefiles="$dlprefiles $arg"
1269a18ebfb2Smrg	    fi
1270a18ebfb2Smrg	    prev=
1271a18ebfb2Smrg	    continue
1272a18ebfb2Smrg	    ;;
1273a18ebfb2Smrg	  esac
1274a18ebfb2Smrg	  ;;
1275a18ebfb2Smrg	expsyms)
1276a18ebfb2Smrg	  export_symbols="$arg"
1277a18ebfb2Smrg	  if test ! -f "$arg"; then
1278a18ebfb2Smrg	    $echo "$modename: symbol file \`$arg' does not exist"
1279a18ebfb2Smrg	    exit $EXIT_FAILURE
1280a18ebfb2Smrg	  fi
1281a18ebfb2Smrg	  prev=
1282a18ebfb2Smrg	  continue
1283a18ebfb2Smrg	  ;;
1284a18ebfb2Smrg	expsyms_regex)
1285a18ebfb2Smrg	  export_symbols_regex="$arg"
1286a18ebfb2Smrg	  prev=
1287a18ebfb2Smrg	  continue
1288a18ebfb2Smrg	  ;;
1289a18ebfb2Smrg	inst_prefix)
1290a18ebfb2Smrg	  inst_prefix_dir="$arg"
1291a18ebfb2Smrg	  prev=
1292a18ebfb2Smrg	  continue
1293a18ebfb2Smrg	  ;;
1294a18ebfb2Smrg	precious_regex)
1295a18ebfb2Smrg	  precious_files_regex="$arg"
1296a18ebfb2Smrg	  prev=
1297a18ebfb2Smrg	  continue
1298a18ebfb2Smrg	  ;;
1299a18ebfb2Smrg	release)
1300a18ebfb2Smrg	  release="-$arg"
1301a18ebfb2Smrg	  prev=
1302a18ebfb2Smrg	  continue
1303a18ebfb2Smrg	  ;;
1304a18ebfb2Smrg	objectlist)
1305a18ebfb2Smrg	  if test -f "$arg"; then
1306a18ebfb2Smrg	    save_arg=$arg
1307a18ebfb2Smrg	    moreargs=
1308a18ebfb2Smrg	    for fil in `cat $save_arg`
1309a18ebfb2Smrg	    do
1310a18ebfb2Smrg#	      moreargs="$moreargs $fil"
1311a18ebfb2Smrg	      arg=$fil
1312a18ebfb2Smrg	      # A libtool-controlled object.
131350806d53Smrg
1314a18ebfb2Smrg	      # Check to see that this really is a libtool object.
1315a18ebfb2Smrg	      if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
1316a18ebfb2Smrg		pic_object=
1317a18ebfb2Smrg		non_pic_object=
131850806d53Smrg
1319a18ebfb2Smrg		# Read the .lo file
1320a18ebfb2Smrg		# If there is no directory component, then add one.
1321a18ebfb2Smrg		case $arg in
1322a18ebfb2Smrg		*/* | *\\*) . $arg ;;
1323a18ebfb2Smrg		*) . ./$arg ;;
1324a18ebfb2Smrg		esac
132550806d53Smrg
1326a18ebfb2Smrg		if test -z "$pic_object" || \
1327a18ebfb2Smrg		   test -z "$non_pic_object" ||
1328a18ebfb2Smrg		   test "$pic_object" = none && \
1329a18ebfb2Smrg		   test "$non_pic_object" = none; then
1330a18ebfb2Smrg		  $echo "$modename: cannot find name of object for \`$arg'" 1>&2
1331a18ebfb2Smrg		  exit $EXIT_FAILURE
1332a18ebfb2Smrg		fi
133350806d53Smrg
1334a18ebfb2Smrg		# Extract subdirectory from the argument.
1335a18ebfb2Smrg		xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1336a18ebfb2Smrg		if test "X$xdir" = "X$arg"; then
1337a18ebfb2Smrg		  xdir=
1338a18ebfb2Smrg		else
1339a18ebfb2Smrg		  xdir="$xdir/"
1340a18ebfb2Smrg		fi
134150806d53Smrg
1342a18ebfb2Smrg		if test "$pic_object" != none; then
1343a18ebfb2Smrg		  # Prepend the subdirectory the object is found in.
1344a18ebfb2Smrg		  pic_object="$xdir$pic_object"
134550806d53Smrg
1346a18ebfb2Smrg		  if test "$prev" = dlfiles; then
1347a18ebfb2Smrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
1348a18ebfb2Smrg		      dlfiles="$dlfiles $pic_object"
1349a18ebfb2Smrg		      prev=
1350a18ebfb2Smrg		      continue
1351a18ebfb2Smrg		    else
1352a18ebfb2Smrg		      # If libtool objects are unsupported, then we need to preload.
1353a18ebfb2Smrg		      prev=dlprefiles
1354a18ebfb2Smrg		    fi
1355a18ebfb2Smrg		  fi
135650806d53Smrg
1357a18ebfb2Smrg		  # CHECK ME:  I think I busted this.  -Ossama
1358a18ebfb2Smrg		  if test "$prev" = dlprefiles; then
1359a18ebfb2Smrg		    # Preload the old-style object.
1360a18ebfb2Smrg		    dlprefiles="$dlprefiles $pic_object"
1361a18ebfb2Smrg		    prev=
1362a18ebfb2Smrg		  fi
136350806d53Smrg
1364a18ebfb2Smrg		  # A PIC object.
1365a18ebfb2Smrg		  libobjs="$libobjs $pic_object"
1366a18ebfb2Smrg		  arg="$pic_object"
1367a18ebfb2Smrg		fi
136850806d53Smrg
1369a18ebfb2Smrg		# Non-PIC object.
1370a18ebfb2Smrg		if test "$non_pic_object" != none; then
1371a18ebfb2Smrg		  # Prepend the subdirectory the object is found in.
1372a18ebfb2Smrg		  non_pic_object="$xdir$non_pic_object"
137350806d53Smrg
1374a18ebfb2Smrg		  # A standard non-PIC object
1375a18ebfb2Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
1376a18ebfb2Smrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
1377a18ebfb2Smrg		    arg="$non_pic_object"
1378a18ebfb2Smrg		  fi
1379a18ebfb2Smrg		else
1380a18ebfb2Smrg		  # If the PIC object exists, use it instead.
1381a18ebfb2Smrg		  # $xdir was prepended to $pic_object above.
1382a18ebfb2Smrg		  non_pic_object="$pic_object"
1383a18ebfb2Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
1384a18ebfb2Smrg		fi
1385a18ebfb2Smrg	      else
1386a18ebfb2Smrg		# Only an error if not doing a dry-run.
1387a18ebfb2Smrg		if test -z "$run"; then
1388a18ebfb2Smrg		  $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
1389a18ebfb2Smrg		  exit $EXIT_FAILURE
1390a18ebfb2Smrg		else
1391a18ebfb2Smrg		  # Dry-run case.
139250806d53Smrg
1393a18ebfb2Smrg		  # Extract subdirectory from the argument.
1394a18ebfb2Smrg		  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1395a18ebfb2Smrg		  if test "X$xdir" = "X$arg"; then
1396a18ebfb2Smrg		    xdir=
1397a18ebfb2Smrg		  else
1398a18ebfb2Smrg		    xdir="$xdir/"
1399a18ebfb2Smrg		  fi
140050806d53Smrg
1401a18ebfb2Smrg		  pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
1402a18ebfb2Smrg		  non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
1403a18ebfb2Smrg		  libobjs="$libobjs $pic_object"
1404a18ebfb2Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
1405a18ebfb2Smrg		fi
1406a18ebfb2Smrg	      fi
1407a18ebfb2Smrg	    done
1408a18ebfb2Smrg	  else
1409a18ebfb2Smrg	    $echo "$modename: link input file \`$save_arg' does not exist"
1410a18ebfb2Smrg	    exit $EXIT_FAILURE
1411a18ebfb2Smrg	  fi
1412a18ebfb2Smrg	  arg=$save_arg
1413a18ebfb2Smrg	  prev=
1414a18ebfb2Smrg	  continue
1415a18ebfb2Smrg	  ;;
1416a18ebfb2Smrg	rpath | xrpath)
1417a18ebfb2Smrg	  # We need an absolute path.
1418a18ebfb2Smrg	  case $arg in
1419a18ebfb2Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
1420a18ebfb2Smrg	  *)
1421a18ebfb2Smrg	    $echo "$modename: only absolute run-paths are allowed" 1>&2
1422a18ebfb2Smrg	    exit $EXIT_FAILURE
1423a18ebfb2Smrg	    ;;
1424a18ebfb2Smrg	  esac
1425a18ebfb2Smrg	  if test "$prev" = rpath; then
1426a18ebfb2Smrg	    case "$rpath " in
1427a18ebfb2Smrg	    *" $arg "*) ;;
1428a18ebfb2Smrg	    *) rpath="$rpath $arg" ;;
1429a18ebfb2Smrg	    esac
1430a18ebfb2Smrg	  else
1431a18ebfb2Smrg	    case "$xrpath " in
1432a18ebfb2Smrg	    *" $arg "*) ;;
1433a18ebfb2Smrg	    *) xrpath="$xrpath $arg" ;;
1434a18ebfb2Smrg	    esac
1435a18ebfb2Smrg	  fi
1436a18ebfb2Smrg	  prev=
1437a18ebfb2Smrg	  continue
1438a18ebfb2Smrg	  ;;
1439a18ebfb2Smrg	xcompiler)
1440a18ebfb2Smrg	  compiler_flags="$compiler_flags $qarg"
1441a18ebfb2Smrg	  prev=
1442a18ebfb2Smrg	  compile_command="$compile_command $qarg"
1443a18ebfb2Smrg	  finalize_command="$finalize_command $qarg"
1444a18ebfb2Smrg	  continue
1445a18ebfb2Smrg	  ;;
1446a18ebfb2Smrg	xlinker)
1447a18ebfb2Smrg	  linker_flags="$linker_flags $qarg"
1448a18ebfb2Smrg	  compiler_flags="$compiler_flags $wl$qarg"
1449a18ebfb2Smrg	  prev=
1450a18ebfb2Smrg	  compile_command="$compile_command $wl$qarg"
1451a18ebfb2Smrg	  finalize_command="$finalize_command $wl$qarg"
1452a18ebfb2Smrg	  continue
1453a18ebfb2Smrg	  ;;
1454a18ebfb2Smrg	xcclinker)
1455a18ebfb2Smrg	  linker_flags="$linker_flags $qarg"
1456a18ebfb2Smrg	  compiler_flags="$compiler_flags $qarg"
1457a18ebfb2Smrg	  prev=
1458a18ebfb2Smrg	  compile_command="$compile_command $qarg"
1459a18ebfb2Smrg	  finalize_command="$finalize_command $qarg"
1460a18ebfb2Smrg	  continue
1461a18ebfb2Smrg	  ;;
1462a18ebfb2Smrg	shrext)
1463a18ebfb2Smrg  	  shrext_cmds="$arg"
1464a18ebfb2Smrg	  prev=
1465a18ebfb2Smrg	  continue
1466a18ebfb2Smrg	  ;;
1467a18ebfb2Smrg	darwin_framework|darwin_framework_skip)
1468a18ebfb2Smrg	  test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg"
1469a18ebfb2Smrg	  compile_command="$compile_command $arg"
1470a18ebfb2Smrg	  finalize_command="$finalize_command $arg"
1471a18ebfb2Smrg	  prev=
1472a18ebfb2Smrg	  continue
1473a18ebfb2Smrg	  ;;
1474a18ebfb2Smrg	*)
1475a18ebfb2Smrg	  eval "$prev=\"\$arg\""
1476a18ebfb2Smrg	  prev=
1477a18ebfb2Smrg	  continue
1478a18ebfb2Smrg	  ;;
1479a18ebfb2Smrg	esac
1480a18ebfb2Smrg      fi # test -n "$prev"
148150806d53Smrg
1482a18ebfb2Smrg      prevarg="$arg"
148350806d53Smrg
1484a18ebfb2Smrg      case $arg in
1485a18ebfb2Smrg      -all-static)
1486a18ebfb2Smrg	if test -n "$link_static_flag"; then
1487a18ebfb2Smrg	  compile_command="$compile_command $link_static_flag"
1488a18ebfb2Smrg	  finalize_command="$finalize_command $link_static_flag"
1489a18ebfb2Smrg	fi
1490a18ebfb2Smrg	continue
1491a18ebfb2Smrg	;;
149250806d53Smrg
1493a18ebfb2Smrg      -allow-undefined)
1494a18ebfb2Smrg	# FIXME: remove this flag sometime in the future.
1495a18ebfb2Smrg	$echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
1496a18ebfb2Smrg	continue
1497a18ebfb2Smrg	;;
149850806d53Smrg
1499a18ebfb2Smrg      -avoid-version)
1500a18ebfb2Smrg	avoid_version=yes
1501a18ebfb2Smrg	continue
1502a18ebfb2Smrg	;;
150350806d53Smrg
1504a18ebfb2Smrg      -dlopen)
1505a18ebfb2Smrg	prev=dlfiles
1506a18ebfb2Smrg	continue
1507a18ebfb2Smrg	;;
150850806d53Smrg
1509a18ebfb2Smrg      -dlpreopen)
1510a18ebfb2Smrg	prev=dlprefiles
1511a18ebfb2Smrg	continue
1512a18ebfb2Smrg	;;
151350806d53Smrg
1514a18ebfb2Smrg      -export-dynamic)
1515a18ebfb2Smrg	export_dynamic=yes
1516a18ebfb2Smrg	continue
1517a18ebfb2Smrg	;;
151850806d53Smrg
1519a18ebfb2Smrg      -export-symbols | -export-symbols-regex)
1520a18ebfb2Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
1521a18ebfb2Smrg	  $echo "$modename: more than one -exported-symbols argument is not allowed"
1522a18ebfb2Smrg	  exit $EXIT_FAILURE
1523a18ebfb2Smrg	fi
1524a18ebfb2Smrg	if test "X$arg" = "X-export-symbols"; then
1525a18ebfb2Smrg	  prev=expsyms
1526a18ebfb2Smrg	else
1527a18ebfb2Smrg	  prev=expsyms_regex
1528a18ebfb2Smrg	fi
1529a18ebfb2Smrg	continue
1530a18ebfb2Smrg	;;
153150806d53Smrg
1532a18ebfb2Smrg      -framework|-arch|-isysroot)
1533a18ebfb2Smrg	case " $CC " in
1534a18ebfb2Smrg	  *" ${arg} ${1} "* | *" ${arg}	${1} "*) 
1535a18ebfb2Smrg		prev=darwin_framework_skip ;;
1536a18ebfb2Smrg	  *) compiler_flags="$compiler_flags $arg"
1537a18ebfb2Smrg	     prev=darwin_framework ;;
1538a18ebfb2Smrg	esac
1539a18ebfb2Smrg	compile_command="$compile_command $arg"
1540a18ebfb2Smrg	finalize_command="$finalize_command $arg"
1541a18ebfb2Smrg	continue
1542a18ebfb2Smrg	;;
154350806d53Smrg
1544a18ebfb2Smrg      -inst-prefix-dir)
1545a18ebfb2Smrg	prev=inst_prefix
1546a18ebfb2Smrg	continue
1547a18ebfb2Smrg	;;
154850806d53Smrg
1549a18ebfb2Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
1550a18ebfb2Smrg      # so, if we see these flags be careful not to treat them like -L
1551a18ebfb2Smrg      -L[A-Z][A-Z]*:*)
1552a18ebfb2Smrg	case $with_gcc/$host in
1553a18ebfb2Smrg	no/*-*-irix* | /*-*-irix*)
1554a18ebfb2Smrg	  compile_command="$compile_command $arg"
1555a18ebfb2Smrg	  finalize_command="$finalize_command $arg"
1556a18ebfb2Smrg	  ;;
1557a18ebfb2Smrg	esac
1558a18ebfb2Smrg	continue
1559a18ebfb2Smrg	;;
156050806d53Smrg
1561a18ebfb2Smrg      -L*)
1562a18ebfb2Smrg	dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
1563a18ebfb2Smrg	# We need an absolute path.
1564a18ebfb2Smrg	case $dir in
1565a18ebfb2Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
1566a18ebfb2Smrg	*)
1567a18ebfb2Smrg	  absdir=`cd "$dir" && pwd`
1568a18ebfb2Smrg	  if test -z "$absdir"; then
1569a18ebfb2Smrg	    $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
1570a18ebfb2Smrg	    absdir="$dir"
1571a18ebfb2Smrg	    notinst_path="$notinst_path $dir"
1572a18ebfb2Smrg	  fi
1573a18ebfb2Smrg	  dir="$absdir"
1574a18ebfb2Smrg	  ;;
1575a18ebfb2Smrg	esac
1576a18ebfb2Smrg	case "$deplibs " in
1577a18ebfb2Smrg	*" -L$dir "*) ;;
1578a18ebfb2Smrg	*)
1579a18ebfb2Smrg	  deplibs="$deplibs -L$dir"
1580a18ebfb2Smrg	  lib_search_path="$lib_search_path $dir"
1581a18ebfb2Smrg	  ;;
1582a18ebfb2Smrg	esac
1583a18ebfb2Smrg	case $host in
1584a18ebfb2Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
1585a18ebfb2Smrg	  testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'`
1586a18ebfb2Smrg	  case :$dllsearchpath: in
1587a18ebfb2Smrg	  *":$dir:"*) ;;
1588a18ebfb2Smrg	  *) dllsearchpath="$dllsearchpath:$dir";;
1589a18ebfb2Smrg	  esac
1590a18ebfb2Smrg	  case :$dllsearchpath: in
1591a18ebfb2Smrg	  *":$testbindir:"*) ;;
1592a18ebfb2Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
1593a18ebfb2Smrg	  esac
1594a18ebfb2Smrg	  ;;
1595a18ebfb2Smrg	esac
1596a18ebfb2Smrg	continue
1597a18ebfb2Smrg	;;
159850806d53Smrg
1599a18ebfb2Smrg      -l*)
1600a18ebfb2Smrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
1601a18ebfb2Smrg	  case $host in
1602a18ebfb2Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
1603a18ebfb2Smrg	    # These systems don't actually have a C or math library (as such)
1604a18ebfb2Smrg	    continue
1605a18ebfb2Smrg	    ;;
1606a18ebfb2Smrg	  *-*-os2*)
1607a18ebfb2Smrg	    # These systems don't actually have a C library (as such)
1608a18ebfb2Smrg	    test "X$arg" = "X-lc" && continue
1609a18ebfb2Smrg	    ;;
1610a18ebfb2Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
1611a18ebfb2Smrg	    # Do not include libc due to us having libc/libc_r.
1612a18ebfb2Smrg	    test "X$arg" = "X-lc" && continue
1613a18ebfb2Smrg	    ;;
1614a18ebfb2Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
1615a18ebfb2Smrg	    # Rhapsody C and math libraries are in the System framework
1616a18ebfb2Smrg	    deplibs="$deplibs -framework System"
1617a18ebfb2Smrg	    continue
1618a18ebfb2Smrg	    ;;
1619a18ebfb2Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
1620a18ebfb2Smrg	    # Causes problems with __ctype
1621a18ebfb2Smrg	    test "X$arg" = "X-lc" && continue
1622a18ebfb2Smrg	    ;;
1623a18ebfb2Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
1624a18ebfb2Smrg	    # Compiler inserts libc in the correct place for threads to work
1625a18ebfb2Smrg	    test "X$arg" = "X-lc" && continue
1626a18ebfb2Smrg	    ;;
1627a18ebfb2Smrg	  esac
1628a18ebfb2Smrg	elif test "X$arg" = "X-lc_r"; then
1629a18ebfb2Smrg	 case $host in
1630a18ebfb2Smrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
1631a18ebfb2Smrg	   # Do not include libc_r directly, use -pthread flag.
1632a18ebfb2Smrg	   continue
1633a18ebfb2Smrg	   ;;
1634a18ebfb2Smrg	 esac
1635af1a9c97Smrg	fi
1636a18ebfb2Smrg	deplibs="$deplibs $arg"
1637a18ebfb2Smrg	continue
1638a18ebfb2Smrg	;;
163950806d53Smrg
1640a18ebfb2Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
1641a18ebfb2Smrg      # classes, name mangling, and exception handling.
1642a18ebfb2Smrg      -model)
1643a18ebfb2Smrg	compile_command="$compile_command $arg"
1644a18ebfb2Smrg	compiler_flags="$compiler_flags $arg"
1645a18ebfb2Smrg	finalize_command="$finalize_command $arg"
1646a18ebfb2Smrg	prev=xcompiler
1647a18ebfb2Smrg	continue
164850806d53Smrg	;;
164950806d53Smrg
1650a18ebfb2Smrg     -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
1651a18ebfb2Smrg	compiler_flags="$compiler_flags $arg"
1652a18ebfb2Smrg	compile_command="$compile_command $arg"
1653a18ebfb2Smrg	finalize_command="$finalize_command $arg"
1654a18ebfb2Smrg	continue
165550806d53Smrg	;;
165650806d53Smrg
1657a18ebfb2Smrg      -multi_module)
1658a18ebfb2Smrg	single_module="${wl}-multi_module"
165950806d53Smrg	continue
166050806d53Smrg	;;
166150806d53Smrg
1662a18ebfb2Smrg      -module)
1663a18ebfb2Smrg	module=yes
1664a18ebfb2Smrg	continue
1665a18ebfb2Smrg	;;
166650806d53Smrg
1667a18ebfb2Smrg      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
1668a18ebfb2Smrg      # -r[0-9][0-9]* specifies the processor on the SGI compiler
1669a18ebfb2Smrg      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
1670a18ebfb2Smrg      # +DA*, +DD* enable 64-bit mode on the HP compiler
1671a18ebfb2Smrg      # -q* pass through compiler args for the IBM compiler
1672a18ebfb2Smrg      # -m* pass through architecture-specific compiler args for GCC
1673a18ebfb2Smrg      # -m*, -t[45]*, -txscale* pass through architecture-specific
1674a18ebfb2Smrg      # compiler args for GCC
1675a18ebfb2Smrg      # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
1676a18ebfb2Smrg      # -F/path gives path to uninstalled frameworks, gcc on darwin
1677a18ebfb2Smrg      # @file GCC response files
1678a18ebfb2Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
1679a18ebfb2Smrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
168050806d53Smrg
1681a18ebfb2Smrg	# Unknown arguments in both finalize_command and compile_command need
1682a18ebfb2Smrg	# to be aesthetically quoted because they are evaled later.
1683a18ebfb2Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1684a18ebfb2Smrg	case $arg in
1685a18ebfb2Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1686a18ebfb2Smrg	  arg="\"$arg\""
1687a18ebfb2Smrg	  ;;
1688a18ebfb2Smrg	esac
1689a18ebfb2Smrg        compile_command="$compile_command $arg"
1690a18ebfb2Smrg        finalize_command="$finalize_command $arg"
1691a18ebfb2Smrg        compiler_flags="$compiler_flags $arg"
1692a18ebfb2Smrg        continue
1693a18ebfb2Smrg        ;;
169450806d53Smrg
1695a18ebfb2Smrg      -shrext)
1696a18ebfb2Smrg	prev=shrext
1697a18ebfb2Smrg	continue
1698af1a9c97Smrg	;;
169950806d53Smrg
1700a18ebfb2Smrg      -no-fast-install)
1701a18ebfb2Smrg	fast_install=no
1702a18ebfb2Smrg	continue
1703a18ebfb2Smrg	;;
170450806d53Smrg
1705a18ebfb2Smrg      -no-install)
1706a18ebfb2Smrg	case $host in
1707a18ebfb2Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin*)
1708a18ebfb2Smrg	  # The PATH hackery in wrapper scripts is required on Windows
1709a18ebfb2Smrg	  # and Darwin in order for the loader to find any dlls it needs.
1710a18ebfb2Smrg	  $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
1711a18ebfb2Smrg	  $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
1712a18ebfb2Smrg	  fast_install=no
1713a18ebfb2Smrg	  ;;
1714a18ebfb2Smrg	*) no_install=yes ;;
1715a18ebfb2Smrg	esac
1716a18ebfb2Smrg	continue
1717a18ebfb2Smrg	;;
1718af1a9c97Smrg
1719a18ebfb2Smrg      -no-undefined)
1720a18ebfb2Smrg	allow_undefined=no
1721a18ebfb2Smrg	continue
1722a18ebfb2Smrg	;;
1723af1a9c97Smrg
1724a18ebfb2Smrg      -objectlist)
1725a18ebfb2Smrg	prev=objectlist
1726a18ebfb2Smrg	continue
1727af1a9c97Smrg	;;
1728af1a9c97Smrg
1729a18ebfb2Smrg      -o) prev=output ;;
1730af1a9c97Smrg
1731a18ebfb2Smrg      -precious-files-regex)
1732a18ebfb2Smrg	prev=precious_regex
1733a18ebfb2Smrg	continue
1734a18ebfb2Smrg	;;
1735af1a9c97Smrg
1736a18ebfb2Smrg      -release)
1737a18ebfb2Smrg	prev=release
1738a18ebfb2Smrg	continue
1739a18ebfb2Smrg	;;
1740af1a9c97Smrg
1741a18ebfb2Smrg      -rpath)
1742a18ebfb2Smrg	prev=rpath
1743a18ebfb2Smrg	continue
1744a18ebfb2Smrg	;;
1745af1a9c97Smrg
1746a18ebfb2Smrg      -R)
1747a18ebfb2Smrg	prev=xrpath
1748af1a9c97Smrg	continue
1749a18ebfb2Smrg	;;
1750af1a9c97Smrg
1751a18ebfb2Smrg      -R*)
1752a18ebfb2Smrg	dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
1753a18ebfb2Smrg	# We need an absolute path.
1754a18ebfb2Smrg	case $dir in
1755a18ebfb2Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
1756a18ebfb2Smrg	*)
1757a18ebfb2Smrg	  $echo "$modename: only absolute run-paths are allowed" 1>&2
1758a18ebfb2Smrg	  exit $EXIT_FAILURE
1759a18ebfb2Smrg	  ;;
1760a18ebfb2Smrg	esac
1761a18ebfb2Smrg	case "$xrpath " in
1762a18ebfb2Smrg	*" $dir "*) ;;
1763a18ebfb2Smrg	*) xrpath="$xrpath $dir" ;;
1764af1a9c97Smrg	esac
1765a18ebfb2Smrg	continue
1766af1a9c97Smrg	;;
1767a18ebfb2Smrg
1768a18ebfb2Smrg      -static | -static-libtool-libs)
1769a18ebfb2Smrg	# The effects of -static are defined in a previous loop.
1770a18ebfb2Smrg	# We used to do the same as -all-static on platforms that
1771a18ebfb2Smrg	# didn't have a PIC flag, but the assumption that the effects
1772a18ebfb2Smrg	# would be equivalent was wrong.  It would break on at least
1773a18ebfb2Smrg	# Digital Unix and AIX.
1774a18ebfb2Smrg	continue
1775af1a9c97Smrg	;;
1776a18ebfb2Smrg
1777a18ebfb2Smrg      -thread-safe)
1778a18ebfb2Smrg	thread_safe=yes
1779af1a9c97Smrg	continue
1780af1a9c97Smrg	;;
1781a18ebfb2Smrg
1782a18ebfb2Smrg      -version-info)
1783a18ebfb2Smrg	prev=vinfo
1784a18ebfb2Smrg	continue
1785af1a9c97Smrg	;;
1786a18ebfb2Smrg      -version-number)
1787a18ebfb2Smrg	prev=vinfo
1788a18ebfb2Smrg	vinfo_number=yes
1789a18ebfb2Smrg	continue
179050806d53Smrg	;;
179150806d53Smrg
1792a18ebfb2Smrg      -Wc,*)
1793a18ebfb2Smrg	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
1794a18ebfb2Smrg	arg=
1795a18ebfb2Smrg	save_ifs="$IFS"; IFS=','
1796a18ebfb2Smrg	for flag in $args; do
1797a18ebfb2Smrg	  IFS="$save_ifs"
1798a18ebfb2Smrg	  case $flag in
1799a18ebfb2Smrg	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1800a18ebfb2Smrg	    flag="\"$flag\""
1801a18ebfb2Smrg	    ;;
1802a18ebfb2Smrg	  esac
1803a18ebfb2Smrg	  arg="$arg $wl$flag"
1804a18ebfb2Smrg	  compiler_flags="$compiler_flags $flag"
1805a18ebfb2Smrg	done
1806a18ebfb2Smrg	IFS="$save_ifs"
1807a18ebfb2Smrg	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
1808a18ebfb2Smrg	;;
180950806d53Smrg
1810a18ebfb2Smrg      -Wl,*)
1811a18ebfb2Smrg	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
1812a18ebfb2Smrg	arg=
1813a18ebfb2Smrg	save_ifs="$IFS"; IFS=','
1814a18ebfb2Smrg	for flag in $args; do
1815a18ebfb2Smrg	  IFS="$save_ifs"
1816a18ebfb2Smrg	  case $flag in
1817a18ebfb2Smrg	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1818a18ebfb2Smrg	    flag="\"$flag\""
1819a18ebfb2Smrg	    ;;
1820a18ebfb2Smrg	  esac
1821a18ebfb2Smrg	  arg="$arg $wl$flag"
1822a18ebfb2Smrg	  compiler_flags="$compiler_flags $wl$flag"
1823a18ebfb2Smrg	  linker_flags="$linker_flags $flag"
1824a18ebfb2Smrg	done
1825a18ebfb2Smrg	IFS="$save_ifs"
1826a18ebfb2Smrg	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
1827a18ebfb2Smrg	;;
182850806d53Smrg
1829a18ebfb2Smrg      -Xcompiler)
1830a18ebfb2Smrg	prev=xcompiler
1831a18ebfb2Smrg	continue
1832a18ebfb2Smrg	;;
183350806d53Smrg
1834a18ebfb2Smrg      -Xlinker)
1835a18ebfb2Smrg	prev=xlinker
1836a18ebfb2Smrg	continue
1837a18ebfb2Smrg	;;
183850806d53Smrg
1839a18ebfb2Smrg      -XCClinker)
1840a18ebfb2Smrg	prev=xcclinker
1841a18ebfb2Smrg	continue
1842a18ebfb2Smrg	;;
184350806d53Smrg
1844a18ebfb2Smrg      # Some other compiler flag.
1845a18ebfb2Smrg      -* | +*)
1846a18ebfb2Smrg	# Unknown arguments in both finalize_command and compile_command need
1847a18ebfb2Smrg	# to be aesthetically quoted because they are evaled later.
1848a18ebfb2Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1849a18ebfb2Smrg	case $arg in
1850a18ebfb2Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1851a18ebfb2Smrg	  arg="\"$arg\""
1852af1a9c97Smrg	  ;;
1853af1a9c97Smrg	esac
1854a18ebfb2Smrg	;;
185550806d53Smrg
1856a18ebfb2Smrg      *.$objext)
1857a18ebfb2Smrg	# A standard object.
1858a18ebfb2Smrg	objs="$objs $arg"
1859af1a9c97Smrg	;;
1860af1a9c97Smrg
1861a18ebfb2Smrg      *.lo)
1862a18ebfb2Smrg	# A libtool-controlled object.
1863af1a9c97Smrg
1864a18ebfb2Smrg	# Check to see that this really is a libtool object.
1865a18ebfb2Smrg	if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
1866a18ebfb2Smrg	  pic_object=
1867a18ebfb2Smrg	  non_pic_object=
1868af1a9c97Smrg
1869a18ebfb2Smrg	  # Read the .lo file
1870a18ebfb2Smrg	  # If there is no directory component, then add one.
1871a18ebfb2Smrg	  case $arg in
1872a18ebfb2Smrg	  */* | *\\*) . $arg ;;
1873a18ebfb2Smrg	  *) . ./$arg ;;
1874af1a9c97Smrg	  esac
1875af1a9c97Smrg
1876a18ebfb2Smrg	  if test -z "$pic_object" || \
1877a18ebfb2Smrg	     test -z "$non_pic_object" ||
1878a18ebfb2Smrg	     test "$pic_object" = none && \
1879a18ebfb2Smrg	     test "$non_pic_object" = none; then
1880a18ebfb2Smrg	    $echo "$modename: cannot find name of object for \`$arg'" 1>&2
1881a18ebfb2Smrg	    exit $EXIT_FAILURE
1882a18ebfb2Smrg	  fi
1883af1a9c97Smrg
1884a18ebfb2Smrg	  # Extract subdirectory from the argument.
1885a18ebfb2Smrg	  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1886a18ebfb2Smrg	  if test "X$xdir" = "X$arg"; then
1887a18ebfb2Smrg	    xdir=
1888a18ebfb2Smrg 	  else
1889a18ebfb2Smrg	    xdir="$xdir/"
1890af1a9c97Smrg	  fi
1891af1a9c97Smrg
1892a18ebfb2Smrg	  if test "$pic_object" != none; then
1893a18ebfb2Smrg	    # Prepend the subdirectory the object is found in.
1894a18ebfb2Smrg	    pic_object="$xdir$pic_object"
1895af1a9c97Smrg
1896a18ebfb2Smrg	    if test "$prev" = dlfiles; then
1897a18ebfb2Smrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
1898a18ebfb2Smrg		dlfiles="$dlfiles $pic_object"
1899a18ebfb2Smrg		prev=
1900a18ebfb2Smrg		continue
1901a18ebfb2Smrg	      else
1902a18ebfb2Smrg		# If libtool objects are unsupported, then we need to preload.
1903a18ebfb2Smrg		prev=dlprefiles
1904a18ebfb2Smrg	      fi
1905a18ebfb2Smrg	    fi
1906af1a9c97Smrg
1907a18ebfb2Smrg	    # CHECK ME:  I think I busted this.  -Ossama
1908a18ebfb2Smrg	    if test "$prev" = dlprefiles; then
1909a18ebfb2Smrg	      # Preload the old-style object.
1910a18ebfb2Smrg	      dlprefiles="$dlprefiles $pic_object"
1911a18ebfb2Smrg	      prev=
1912a18ebfb2Smrg	    fi
1913af1a9c97Smrg
1914a18ebfb2Smrg	    # A PIC object.
1915a18ebfb2Smrg	    libobjs="$libobjs $pic_object"
1916a18ebfb2Smrg	    arg="$pic_object"
191750806d53Smrg	  fi
1918af1a9c97Smrg
1919a18ebfb2Smrg	  # Non-PIC object.
1920a18ebfb2Smrg	  if test "$non_pic_object" != none; then
1921a18ebfb2Smrg	    # Prepend the subdirectory the object is found in.
1922a18ebfb2Smrg	    non_pic_object="$xdir$non_pic_object"
1923a18ebfb2Smrg
1924a18ebfb2Smrg	    # A standard non-PIC object
1925a18ebfb2Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
1926a18ebfb2Smrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
1927a18ebfb2Smrg	      arg="$non_pic_object"
1928a18ebfb2Smrg	    fi
1929a18ebfb2Smrg	  else
1930a18ebfb2Smrg	    # If the PIC object exists, use it instead.
1931a18ebfb2Smrg	    # $xdir was prepended to $pic_object above.
1932a18ebfb2Smrg	    non_pic_object="$pic_object"
1933a18ebfb2Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
193450806d53Smrg	  fi
1935a18ebfb2Smrg	else
1936a18ebfb2Smrg	  # Only an error if not doing a dry-run.
1937a18ebfb2Smrg	  if test -z "$run"; then
1938a18ebfb2Smrg	    $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
1939a18ebfb2Smrg	    exit $EXIT_FAILURE
1940a18ebfb2Smrg	  else
1941a18ebfb2Smrg	    # Dry-run case.
194250806d53Smrg
1943a18ebfb2Smrg	    # Extract subdirectory from the argument.
1944a18ebfb2Smrg	    xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1945a18ebfb2Smrg	    if test "X$xdir" = "X$arg"; then
1946a18ebfb2Smrg	      xdir=
1947a18ebfb2Smrg	    else
1948a18ebfb2Smrg	      xdir="$xdir/"
1949a18ebfb2Smrg	    fi
195050806d53Smrg
1951a18ebfb2Smrg	    pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
1952a18ebfb2Smrg	    non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
1953a18ebfb2Smrg	    libobjs="$libobjs $pic_object"
1954a18ebfb2Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
1955a18ebfb2Smrg	  fi
1956a18ebfb2Smrg	fi
1957a18ebfb2Smrg	;;
195850806d53Smrg
1959a18ebfb2Smrg      *.$libext)
1960a18ebfb2Smrg	# An archive.
1961a18ebfb2Smrg	deplibs="$deplibs $arg"
1962a18ebfb2Smrg	old_deplibs="$old_deplibs $arg"
1963a18ebfb2Smrg	continue
1964af1a9c97Smrg	;;
196550806d53Smrg
1966a18ebfb2Smrg      *.la)
1967a18ebfb2Smrg	# A libtool-controlled library.
196850806d53Smrg
1969a18ebfb2Smrg	if test "$prev" = dlfiles; then
1970a18ebfb2Smrg	  # This library was specified with -dlopen.
1971a18ebfb2Smrg	  dlfiles="$dlfiles $arg"
1972a18ebfb2Smrg	  prev=
1973a18ebfb2Smrg	elif test "$prev" = dlprefiles; then
1974a18ebfb2Smrg	  # The library was specified with -dlpreopen.
1975a18ebfb2Smrg	  dlprefiles="$dlprefiles $arg"
1976a18ebfb2Smrg	  prev=
1977af1a9c97Smrg	else
1978a18ebfb2Smrg	  deplibs="$deplibs $arg"
197950806d53Smrg	fi
1980a18ebfb2Smrg	continue
1981a18ebfb2Smrg	;;
198250806d53Smrg
1983a18ebfb2Smrg      # Some other compiler argument.
1984a18ebfb2Smrg      *)
1985a18ebfb2Smrg	# Unknown arguments in both finalize_command and compile_command need
1986a18ebfb2Smrg	# to be aesthetically quoted because they are evaled later.
1987a18ebfb2Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1988a18ebfb2Smrg	case $arg in
1989a18ebfb2Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1990a18ebfb2Smrg	  arg="\"$arg\""
1991af1a9c97Smrg	  ;;
1992af1a9c97Smrg	esac
1993af1a9c97Smrg	;;
1994a18ebfb2Smrg      esac # arg
199550806d53Smrg
1996a18ebfb2Smrg      # Now actually substitute the argument into the commands.
1997a18ebfb2Smrg      if test -n "$arg"; then
1998a18ebfb2Smrg	compile_command="$compile_command $arg"
1999a18ebfb2Smrg	finalize_command="$finalize_command $arg"
2000a18ebfb2Smrg      fi
2001a18ebfb2Smrg    done # argument parsing loop
200250806d53Smrg
2003a18ebfb2Smrg    if test -n "$prev"; then
2004a18ebfb2Smrg      $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
2005a18ebfb2Smrg      $echo "$help" 1>&2
2006a18ebfb2Smrg      exit $EXIT_FAILURE
2007a18ebfb2Smrg    fi
2008af1a9c97Smrg
2009a18ebfb2Smrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
2010a18ebfb2Smrg      eval arg=\"$export_dynamic_flag_spec\"
2011a18ebfb2Smrg      compile_command="$compile_command $arg"
2012a18ebfb2Smrg      finalize_command="$finalize_command $arg"
2013a18ebfb2Smrg    fi
2014af1a9c97Smrg
2015a18ebfb2Smrg    oldlibs=
2016a18ebfb2Smrg    # calculate the name of the file, without its directory
2017a18ebfb2Smrg    outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
2018a18ebfb2Smrg    libobjs_save="$libobjs"
2019af1a9c97Smrg
2020a18ebfb2Smrg    if test -n "$shlibpath_var"; then
2021a18ebfb2Smrg      # get the directories listed in $shlibpath_var
2022a18ebfb2Smrg      eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
2023a18ebfb2Smrg    else
2024a18ebfb2Smrg      shlib_search_path=
2025a18ebfb2Smrg    fi
2026a18ebfb2Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
2027a18ebfb2Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
2028af1a9c97Smrg
2029a18ebfb2Smrg    output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
2030a18ebfb2Smrg    if test "X$output_objdir" = "X$output"; then
2031a18ebfb2Smrg      output_objdir="$objdir"
2032af1a9c97Smrg    else
2033a18ebfb2Smrg      output_objdir="$output_objdir/$objdir"
2034af1a9c97Smrg    fi
2035a18ebfb2Smrg    # Create the object directory.
2036a18ebfb2Smrg    if test ! -d "$output_objdir"; then
2037a18ebfb2Smrg      $show "$mkdir $output_objdir"
2038a18ebfb2Smrg      $run $mkdir $output_objdir
2039a18ebfb2Smrg      exit_status=$?
2040a18ebfb2Smrg      if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then
2041a18ebfb2Smrg	exit $exit_status
2042af1a9c97Smrg      fi
2043af1a9c97Smrg    fi
2044af1a9c97Smrg
2045a18ebfb2Smrg    # Determine the type of output
2046a18ebfb2Smrg    case $output in
2047a18ebfb2Smrg    "")
2048a18ebfb2Smrg      $echo "$modename: you must specify an output file" 1>&2
2049a18ebfb2Smrg      $echo "$help" 1>&2
2050a18ebfb2Smrg      exit $EXIT_FAILURE
2051a18ebfb2Smrg      ;;
2052a18ebfb2Smrg    *.$libext) linkmode=oldlib ;;
2053a18ebfb2Smrg    *.lo | *.$objext) linkmode=obj ;;
2054a18ebfb2Smrg    *.la) linkmode=lib ;;
2055a18ebfb2Smrg    *) linkmode=prog ;; # Anything else should be a program.
2056a18ebfb2Smrg    esac
205750806d53Smrg
2058a18ebfb2Smrg    case $host in
2059a18ebfb2Smrg    *cygwin* | *mingw* | *pw32*)
2060a18ebfb2Smrg      # don't eliminate duplications in $postdeps and $predeps
2061a18ebfb2Smrg      duplicate_compiler_generated_deps=yes
2062a18ebfb2Smrg      ;;
2063a18ebfb2Smrg    *)
2064a18ebfb2Smrg      duplicate_compiler_generated_deps=$duplicate_deps
2065a18ebfb2Smrg      ;;
2066a18ebfb2Smrg    esac
2067a18ebfb2Smrg    specialdeplibs=
206850806d53Smrg
2069a18ebfb2Smrg    libs=
2070a18ebfb2Smrg    # Find all interdependent deplibs by searching for libraries
2071a18ebfb2Smrg    # that are linked more than once (e.g. -la -lb -la)
2072a18ebfb2Smrg    for deplib in $deplibs; do
2073a18ebfb2Smrg      if test "X$duplicate_deps" = "Xyes" ; then
2074a18ebfb2Smrg	case "$libs " in
2075a18ebfb2Smrg	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2076a18ebfb2Smrg	esac
2077a18ebfb2Smrg      fi
2078a18ebfb2Smrg      libs="$libs $deplib"
2079a18ebfb2Smrg    done
208050806d53Smrg
2081a18ebfb2Smrg    if test "$linkmode" = lib; then
2082a18ebfb2Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
208350806d53Smrg
2084a18ebfb2Smrg      # Compute libraries that are listed more than once in $predeps
2085a18ebfb2Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
2086a18ebfb2Smrg      # not to be eliminated).
2087a18ebfb2Smrg      pre_post_deps=
2088a18ebfb2Smrg      if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
2089a18ebfb2Smrg	for pre_post_dep in $predeps $postdeps; do
2090a18ebfb2Smrg	  case "$pre_post_deps " in
2091a18ebfb2Smrg	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
2092af1a9c97Smrg	  esac
2093a18ebfb2Smrg	  pre_post_deps="$pre_post_deps $pre_post_dep"
2094a18ebfb2Smrg	done
2095a18ebfb2Smrg      fi
2096a18ebfb2Smrg      pre_post_deps=
2097a18ebfb2Smrg    fi
2098af1a9c97Smrg
2099a18ebfb2Smrg    deplibs=
2100a18ebfb2Smrg    newdependency_libs=
2101a18ebfb2Smrg    newlib_search_path=
2102a18ebfb2Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
2103a18ebfb2Smrg    notinst_deplibs= # not-installed libtool libraries
2104a18ebfb2Smrg    case $linkmode in
2105a18ebfb2Smrg    lib)
2106a18ebfb2Smrg	passes="conv link"
2107a18ebfb2Smrg	for file in $dlfiles $dlprefiles; do
2108a18ebfb2Smrg	  case $file in
2109a18ebfb2Smrg	  *.la) ;;
2110af1a9c97Smrg	  *)
2111a18ebfb2Smrg	    $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
2112a18ebfb2Smrg	    exit $EXIT_FAILURE
2113af1a9c97Smrg	    ;;
2114af1a9c97Smrg	  esac
2115af1a9c97Smrg	done
2116af1a9c97Smrg	;;
2117a18ebfb2Smrg    prog)
2118a18ebfb2Smrg	compile_deplibs=
2119a18ebfb2Smrg	finalize_deplibs=
2120a18ebfb2Smrg	alldeplibs=no
2121a18ebfb2Smrg	newdlfiles=
2122a18ebfb2Smrg	newdlprefiles=
2123a18ebfb2Smrg	passes="conv scan dlopen dlpreopen link"
2124a18ebfb2Smrg	;;
2125a18ebfb2Smrg    *)  passes="conv"
2126af1a9c97Smrg	;;
2127af1a9c97Smrg    esac
2128a18ebfb2Smrg    for pass in $passes; do
2129a18ebfb2Smrg      if test "$linkmode,$pass" = "lib,link" ||
2130a18ebfb2Smrg	 test "$linkmode,$pass" = "prog,scan"; then
2131a18ebfb2Smrg	libs="$deplibs"
2132a18ebfb2Smrg	deplibs=
2133a18ebfb2Smrg      fi
2134a18ebfb2Smrg      if test "$linkmode" = prog; then
2135a18ebfb2Smrg	case $pass in
2136a18ebfb2Smrg	dlopen) libs="$dlfiles" ;;
2137a18ebfb2Smrg	dlpreopen) libs="$dlprefiles" ;;
2138a18ebfb2Smrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
2139a18ebfb2Smrg	esac
2140a18ebfb2Smrg      fi
2141a18ebfb2Smrg      if test "$pass" = dlopen; then
2142a18ebfb2Smrg	# Collect dlpreopened libraries
2143a18ebfb2Smrg	save_deplibs="$deplibs"
2144a18ebfb2Smrg	deplibs=
2145a18ebfb2Smrg      fi
2146a18ebfb2Smrg      for deplib in $libs; do
2147a18ebfb2Smrg	lib=
2148a18ebfb2Smrg	found=no
2149a18ebfb2Smrg	case $deplib in
2150a18ebfb2Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
2151a18ebfb2Smrg	  if test "$linkmode,$pass" = "prog,link"; then
2152a18ebfb2Smrg	    compile_deplibs="$deplib $compile_deplibs"
2153a18ebfb2Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
2154a18ebfb2Smrg	  else
2155a18ebfb2Smrg	    compiler_flags="$compiler_flags $deplib"
2156a18ebfb2Smrg	  fi
2157a18ebfb2Smrg	  continue
2158a18ebfb2Smrg	  ;;
2159a18ebfb2Smrg	-l*)
2160a18ebfb2Smrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
2161a18ebfb2Smrg	    $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
2162a18ebfb2Smrg	    continue
2163a18ebfb2Smrg	  fi
2164a18ebfb2Smrg	  name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
2165a18ebfb2Smrg	  if test "$linkmode" = lib; then
2166a18ebfb2Smrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
2167a18ebfb2Smrg	  else
2168a18ebfb2Smrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
2169a18ebfb2Smrg	  fi
2170a18ebfb2Smrg	  for searchdir in $searchdirs; do
2171a18ebfb2Smrg	    for search_ext in .la $std_shrext .so .a; do
2172a18ebfb2Smrg	      # Search the libtool library
2173a18ebfb2Smrg	      lib="$searchdir/lib${name}${search_ext}"
2174a18ebfb2Smrg	      if test -f "$lib"; then
2175a18ebfb2Smrg		if test "$search_ext" = ".la"; then
2176a18ebfb2Smrg		  found=yes
2177a18ebfb2Smrg		else
2178a18ebfb2Smrg		  found=no
2179a18ebfb2Smrg		fi
2180a18ebfb2Smrg		break 2
2181a18ebfb2Smrg	      fi
2182a18ebfb2Smrg	    done
2183a18ebfb2Smrg	  done
2184a18ebfb2Smrg	  if test "$found" != yes; then
2185a18ebfb2Smrg	    # deplib doesn't seem to be a libtool library
2186a18ebfb2Smrg	    if test "$linkmode,$pass" = "prog,link"; then
2187a18ebfb2Smrg	      compile_deplibs="$deplib $compile_deplibs"
2188a18ebfb2Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
2189a18ebfb2Smrg	    else
2190a18ebfb2Smrg	      deplibs="$deplib $deplibs"
2191a18ebfb2Smrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
2192a18ebfb2Smrg	    fi
2193a18ebfb2Smrg	    continue
2194a18ebfb2Smrg	  else # deplib is a libtool library
2195a18ebfb2Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
2196a18ebfb2Smrg	    # We need to do some special things here, and not later.
2197a18ebfb2Smrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
2198a18ebfb2Smrg	      case " $predeps $postdeps " in
2199a18ebfb2Smrg	      *" $deplib "*)
2200a18ebfb2Smrg		if (${SED} -e '2q' $lib |
2201a18ebfb2Smrg                    grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
2202a18ebfb2Smrg		  library_names=
2203a18ebfb2Smrg		  old_library=
2204a18ebfb2Smrg		  case $lib in
2205a18ebfb2Smrg		  */* | *\\*) . $lib ;;
2206a18ebfb2Smrg		  *) . ./$lib ;;
2207a18ebfb2Smrg		  esac
2208a18ebfb2Smrg		  for l in $old_library $library_names; do
2209a18ebfb2Smrg		    ll="$l"
2210a18ebfb2Smrg		  done
2211a18ebfb2Smrg		  if test "X$ll" = "X$old_library" ; then # only static version available
2212a18ebfb2Smrg		    found=no
2213a18ebfb2Smrg		    ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
2214a18ebfb2Smrg		    test "X$ladir" = "X$lib" && ladir="."
2215a18ebfb2Smrg		    lib=$ladir/$old_library
2216a18ebfb2Smrg		    if test "$linkmode,$pass" = "prog,link"; then
2217a18ebfb2Smrg		      compile_deplibs="$deplib $compile_deplibs"
2218a18ebfb2Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
2219a18ebfb2Smrg		    else
2220a18ebfb2Smrg		      deplibs="$deplib $deplibs"
2221a18ebfb2Smrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
2222a18ebfb2Smrg		    fi
2223a18ebfb2Smrg		    continue
2224a18ebfb2Smrg		  fi
2225a18ebfb2Smrg		fi
2226a18ebfb2Smrg	        ;;
2227a18ebfb2Smrg	      *) ;;
2228a18ebfb2Smrg	      esac
2229a18ebfb2Smrg	    fi
2230a18ebfb2Smrg	  fi
2231a18ebfb2Smrg	  ;; # -l
2232a18ebfb2Smrg	-L*)
2233a18ebfb2Smrg	  case $linkmode in
2234a18ebfb2Smrg	  lib)
2235a18ebfb2Smrg	    deplibs="$deplib $deplibs"
2236a18ebfb2Smrg	    test "$pass" = conv && continue
2237a18ebfb2Smrg	    newdependency_libs="$deplib $newdependency_libs"
2238a18ebfb2Smrg	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
2239a18ebfb2Smrg	    ;;
2240a18ebfb2Smrg	  prog)
2241a18ebfb2Smrg	    if test "$pass" = conv; then
2242a18ebfb2Smrg	      deplibs="$deplib $deplibs"
2243a18ebfb2Smrg	      continue
2244a18ebfb2Smrg	    fi
2245a18ebfb2Smrg	    if test "$pass" = scan; then
2246a18ebfb2Smrg	      deplibs="$deplib $deplibs"
2247a18ebfb2Smrg	    else
2248a18ebfb2Smrg	      compile_deplibs="$deplib $compile_deplibs"
2249a18ebfb2Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
2250a18ebfb2Smrg	    fi
2251a18ebfb2Smrg	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
2252a18ebfb2Smrg	    ;;
2253a18ebfb2Smrg	  *)
2254a18ebfb2Smrg	    $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
2255a18ebfb2Smrg	    ;;
2256a18ebfb2Smrg	  esac # linkmode
2257a18ebfb2Smrg	  continue
2258a18ebfb2Smrg	  ;; # -L
2259a18ebfb2Smrg	-R*)
2260a18ebfb2Smrg	  if test "$pass" = link; then
2261a18ebfb2Smrg	    dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
2262a18ebfb2Smrg	    # Make sure the xrpath contains only unique directories.
2263a18ebfb2Smrg	    case "$xrpath " in
2264a18ebfb2Smrg	    *" $dir "*) ;;
2265a18ebfb2Smrg	    *) xrpath="$xrpath $dir" ;;
2266a18ebfb2Smrg	    esac
2267a18ebfb2Smrg	  fi
2268a18ebfb2Smrg	  deplibs="$deplib $deplibs"
2269a18ebfb2Smrg	  continue
2270a18ebfb2Smrg	  ;;
2271a18ebfb2Smrg	*.la) lib="$deplib" ;;
2272a18ebfb2Smrg	*.$libext)
2273a18ebfb2Smrg	  if test "$pass" = conv; then
2274a18ebfb2Smrg	    deplibs="$deplib $deplibs"
2275a18ebfb2Smrg	    continue
2276a18ebfb2Smrg	  fi
2277a18ebfb2Smrg	  case $linkmode in
2278a18ebfb2Smrg	  lib)
2279a18ebfb2Smrg	    valid_a_lib=no
2280a18ebfb2Smrg	    case $deplibs_check_method in
2281a18ebfb2Smrg	      match_pattern*)
2282a18ebfb2Smrg		set dummy $deplibs_check_method
2283a18ebfb2Smrg	        match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
2284a18ebfb2Smrg		if eval $echo \"$deplib\" 2>/dev/null \
2285a18ebfb2Smrg		    | $SED 10q \
2286a18ebfb2Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
2287a18ebfb2Smrg		  valid_a_lib=yes
2288a18ebfb2Smrg		fi
2289a18ebfb2Smrg		;;
2290a18ebfb2Smrg	      pass_all)
2291a18ebfb2Smrg		valid_a_lib=yes
2292a18ebfb2Smrg		;;
2293a18ebfb2Smrg            esac
2294a18ebfb2Smrg	    if test "$valid_a_lib" != yes; then
2295a18ebfb2Smrg	      $echo
2296a18ebfb2Smrg	      $echo "*** Warning: Trying to link with static lib archive $deplib."
2297a18ebfb2Smrg	      $echo "*** I have the capability to make that library automatically link in when"
2298a18ebfb2Smrg	      $echo "*** you link to this library.  But I can only do this if you have a"
2299a18ebfb2Smrg	      $echo "*** shared version of the library, which you do not appear to have"
2300a18ebfb2Smrg	      $echo "*** because the file extensions .$libext of this argument makes me believe"
2301a18ebfb2Smrg	      $echo "*** that it is just a static archive that I should not used here."
2302a18ebfb2Smrg	    else
2303a18ebfb2Smrg	      $echo
2304a18ebfb2Smrg	      $echo "*** Warning: Linking the shared library $output against the"
2305a18ebfb2Smrg	      $echo "*** static library $deplib is not portable!"
2306a18ebfb2Smrg	      deplibs="$deplib $deplibs"
2307a18ebfb2Smrg	    fi
2308a18ebfb2Smrg	    continue
2309a18ebfb2Smrg	    ;;
2310a18ebfb2Smrg	  prog)
2311a18ebfb2Smrg	    if test "$pass" != link; then
2312a18ebfb2Smrg	      deplibs="$deplib $deplibs"
2313a18ebfb2Smrg	    else
2314a18ebfb2Smrg	      compile_deplibs="$deplib $compile_deplibs"
2315a18ebfb2Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
2316a18ebfb2Smrg	    fi
2317a18ebfb2Smrg	    continue
2318a18ebfb2Smrg	    ;;
2319a18ebfb2Smrg	  esac # linkmode
2320a18ebfb2Smrg	  ;; # *.$libext
2321a18ebfb2Smrg	*.lo | *.$objext)
2322a18ebfb2Smrg	  if test "$pass" = conv; then
2323a18ebfb2Smrg	    deplibs="$deplib $deplibs"
2324a18ebfb2Smrg	  elif test "$linkmode" = prog; then
2325a18ebfb2Smrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
2326a18ebfb2Smrg	      # If there is no dlopen support or we're linking statically,
2327a18ebfb2Smrg	      # we need to preload.
2328a18ebfb2Smrg	      newdlprefiles="$newdlprefiles $deplib"
2329a18ebfb2Smrg	      compile_deplibs="$deplib $compile_deplibs"
2330a18ebfb2Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
2331a18ebfb2Smrg	    else
2332a18ebfb2Smrg	      newdlfiles="$newdlfiles $deplib"
2333a18ebfb2Smrg	    fi
2334a18ebfb2Smrg	  fi
2335a18ebfb2Smrg	  continue
2336a18ebfb2Smrg	  ;;
2337a18ebfb2Smrg	%DEPLIBS%)
2338a18ebfb2Smrg	  alldeplibs=yes
2339a18ebfb2Smrg	  continue
2340a18ebfb2Smrg	  ;;
2341a18ebfb2Smrg	esac # case $deplib
2342a18ebfb2Smrg	if test "$found" = yes || test -f "$lib"; then :
2343a18ebfb2Smrg	else
2344a18ebfb2Smrg	  $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2
2345a18ebfb2Smrg	  exit $EXIT_FAILURE
2346a18ebfb2Smrg	fi
234750806d53Smrg
2348a18ebfb2Smrg	# Check to see that this really is a libtool archive.
2349a18ebfb2Smrg	if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
2350a18ebfb2Smrg	else
2351a18ebfb2Smrg	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
2352a18ebfb2Smrg	  exit $EXIT_FAILURE
2353a18ebfb2Smrg	fi
235450806d53Smrg
2355a18ebfb2Smrg	ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
2356a18ebfb2Smrg	test "X$ladir" = "X$lib" && ladir="."
235750806d53Smrg
2358a18ebfb2Smrg	dlname=
2359a18ebfb2Smrg	dlopen=
2360a18ebfb2Smrg	dlpreopen=
2361a18ebfb2Smrg	libdir=
2362a18ebfb2Smrg	library_names=
2363a18ebfb2Smrg	old_library=
2364a18ebfb2Smrg	# If the library was installed with an old release of libtool,
2365a18ebfb2Smrg	# it will not redefine variables installed, or shouldnotlink
2366a18ebfb2Smrg	installed=yes
2367a18ebfb2Smrg	shouldnotlink=no
2368a18ebfb2Smrg	avoidtemprpath=
236950806d53Smrg
237050806d53Smrg
2371a18ebfb2Smrg	# Read the .la file
2372a18ebfb2Smrg	case $lib in
2373a18ebfb2Smrg	*/* | *\\*) . $lib ;;
2374a18ebfb2Smrg	*) . ./$lib ;;
2375af1a9c97Smrg	esac
237650806d53Smrg
2377a18ebfb2Smrg	if test "$linkmode,$pass" = "lib,link" ||
2378a18ebfb2Smrg	   test "$linkmode,$pass" = "prog,scan" ||
2379a18ebfb2Smrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
2380a18ebfb2Smrg	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
2381a18ebfb2Smrg	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
2382a18ebfb2Smrg	fi
238350806d53Smrg
2384a18ebfb2Smrg	if test "$pass" = conv; then
2385a18ebfb2Smrg	  # Only check for convenience libraries
2386a18ebfb2Smrg	  deplibs="$lib $deplibs"
2387a18ebfb2Smrg	  if test -z "$libdir"; then
2388a18ebfb2Smrg	    if test -z "$old_library"; then
2389a18ebfb2Smrg	      $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
2390a18ebfb2Smrg	      exit $EXIT_FAILURE
2391a18ebfb2Smrg	    fi
2392a18ebfb2Smrg	    # It is a libtool convenience library, so add in its objects.
2393a18ebfb2Smrg	    convenience="$convenience $ladir/$objdir/$old_library"
2394a18ebfb2Smrg	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
2395a18ebfb2Smrg	    tmp_libs=
2396a18ebfb2Smrg	    for deplib in $dependency_libs; do
2397a18ebfb2Smrg	      deplibs="$deplib $deplibs"
2398a18ebfb2Smrg              if test "X$duplicate_deps" = "Xyes" ; then
2399a18ebfb2Smrg	        case "$tmp_libs " in
2400a18ebfb2Smrg	        *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2401a18ebfb2Smrg	        esac
2402a18ebfb2Smrg              fi
2403a18ebfb2Smrg	      tmp_libs="$tmp_libs $deplib"
2404a18ebfb2Smrg	    done
2405a18ebfb2Smrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
2406a18ebfb2Smrg	    $echo "$modename: \`$lib' is not a convenience library" 1>&2
2407a18ebfb2Smrg	    exit $EXIT_FAILURE
2408a18ebfb2Smrg	  fi
2409a18ebfb2Smrg	  continue
2410a18ebfb2Smrg	fi # $pass = conv
241150806d53Smrg
241250806d53Smrg
2413a18ebfb2Smrg	# Get the name of the library we link against.
2414a18ebfb2Smrg	linklib=
2415a18ebfb2Smrg	for l in $old_library $library_names; do
2416a18ebfb2Smrg	  linklib="$l"
2417a18ebfb2Smrg	done
2418a18ebfb2Smrg	if test -z "$linklib"; then
2419a18ebfb2Smrg	  $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
2420a18ebfb2Smrg	  exit $EXIT_FAILURE
242150806d53Smrg	fi
242250806d53Smrg
2423a18ebfb2Smrg	# This library was specified with -dlopen.
2424a18ebfb2Smrg	if test "$pass" = dlopen; then
2425a18ebfb2Smrg	  if test -z "$libdir"; then
2426a18ebfb2Smrg	    $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
2427a18ebfb2Smrg	    exit $EXIT_FAILURE
2428a18ebfb2Smrg	  fi
2429a18ebfb2Smrg	  if test -z "$dlname" ||
2430a18ebfb2Smrg	     test "$dlopen_support" != yes ||
2431a18ebfb2Smrg	     test "$build_libtool_libs" = no; then
2432a18ebfb2Smrg	    # If there is no dlname, no dlopen support or we're linking
2433a18ebfb2Smrg	    # statically, we need to preload.  We also need to preload any
2434a18ebfb2Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
2435a18ebfb2Smrg	    # bomb out in the load deplibs phase.
2436a18ebfb2Smrg	    dlprefiles="$dlprefiles $lib $dependency_libs"
2437a18ebfb2Smrg	  else
2438a18ebfb2Smrg	    newdlfiles="$newdlfiles $lib"
2439a18ebfb2Smrg	  fi
2440a18ebfb2Smrg	  continue
2441a18ebfb2Smrg	fi # $pass = dlopen
244250806d53Smrg
2443a18ebfb2Smrg	# We need an absolute path.
2444a18ebfb2Smrg	case $ladir in
2445a18ebfb2Smrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
2446a18ebfb2Smrg	*)
2447a18ebfb2Smrg	  abs_ladir=`cd "$ladir" && pwd`
2448a18ebfb2Smrg	  if test -z "$abs_ladir"; then
2449a18ebfb2Smrg	    $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2
2450a18ebfb2Smrg	    $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
2451a18ebfb2Smrg	    abs_ladir="$ladir"
2452a18ebfb2Smrg	  fi
2453a18ebfb2Smrg	  ;;
2454a18ebfb2Smrg	esac
2455a18ebfb2Smrg	laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
245650806d53Smrg
2457a18ebfb2Smrg	# Find the relevant object directory and library name.
2458a18ebfb2Smrg	if test "X$installed" = Xyes; then
2459a18ebfb2Smrg	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
2460a18ebfb2Smrg	    $echo "$modename: warning: library \`$lib' was moved." 1>&2
2461a18ebfb2Smrg	    dir="$ladir"
2462a18ebfb2Smrg	    absdir="$abs_ladir"
2463a18ebfb2Smrg	    libdir="$abs_ladir"
2464a18ebfb2Smrg	  else
2465a18ebfb2Smrg	    dir="$libdir"
2466a18ebfb2Smrg	    absdir="$libdir"
2467a18ebfb2Smrg	  fi
2468a18ebfb2Smrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
2469a18ebfb2Smrg	else
2470a18ebfb2Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
2471a18ebfb2Smrg	    dir="$ladir"
2472a18ebfb2Smrg	    absdir="$abs_ladir"
2473a18ebfb2Smrg	    # Remove this search path later
2474a18ebfb2Smrg	    notinst_path="$notinst_path $abs_ladir"
2475a18ebfb2Smrg	  else
2476a18ebfb2Smrg	    dir="$ladir/$objdir"
2477a18ebfb2Smrg	    absdir="$abs_ladir/$objdir"
2478a18ebfb2Smrg	    # Remove this search path later
2479a18ebfb2Smrg	    notinst_path="$notinst_path $abs_ladir"
2480a18ebfb2Smrg	  fi
2481a18ebfb2Smrg	fi # $installed = yes
2482a18ebfb2Smrg	name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
248350806d53Smrg
2484a18ebfb2Smrg	# This library was specified with -dlpreopen.
2485a18ebfb2Smrg	if test "$pass" = dlpreopen; then
2486a18ebfb2Smrg	  if test -z "$libdir"; then
2487a18ebfb2Smrg	    $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
2488a18ebfb2Smrg	    exit $EXIT_FAILURE
2489a18ebfb2Smrg	  fi
2490a18ebfb2Smrg	  # Prefer using a static library (so that no silly _DYNAMIC symbols
2491a18ebfb2Smrg	  # are required to link).
2492a18ebfb2Smrg	  if test -n "$old_library"; then
2493a18ebfb2Smrg	    newdlprefiles="$newdlprefiles $dir/$old_library"
2494a18ebfb2Smrg	  # Otherwise, use the dlname, so that lt_dlopen finds it.
2495a18ebfb2Smrg	  elif test -n "$dlname"; then
2496a18ebfb2Smrg	    newdlprefiles="$newdlprefiles $dir/$dlname"
2497a18ebfb2Smrg	  else
2498a18ebfb2Smrg	    newdlprefiles="$newdlprefiles $dir/$linklib"
2499a18ebfb2Smrg	  fi
2500a18ebfb2Smrg	fi # $pass = dlpreopen
250150806d53Smrg
2502a18ebfb2Smrg	if test -z "$libdir"; then
2503a18ebfb2Smrg	  # Link the convenience library
2504a18ebfb2Smrg	  if test "$linkmode" = lib; then
2505a18ebfb2Smrg	    deplibs="$dir/$old_library $deplibs"
2506a18ebfb2Smrg	  elif test "$linkmode,$pass" = "prog,link"; then
2507a18ebfb2Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
2508a18ebfb2Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
2509a18ebfb2Smrg	  else
2510a18ebfb2Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
2511a18ebfb2Smrg	  fi
2512a18ebfb2Smrg	  continue
2513a18ebfb2Smrg	fi
251450806d53Smrg
251550806d53Smrg
2516a18ebfb2Smrg	if test "$linkmode" = prog && test "$pass" != link; then
2517a18ebfb2Smrg	  newlib_search_path="$newlib_search_path $ladir"
2518a18ebfb2Smrg	  deplibs="$lib $deplibs"
251950806d53Smrg
2520a18ebfb2Smrg	  linkalldeplibs=no
2521a18ebfb2Smrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
2522a18ebfb2Smrg	     test "$build_libtool_libs" = no; then
2523a18ebfb2Smrg	    linkalldeplibs=yes
2524a18ebfb2Smrg	  fi
252550806d53Smrg
2526a18ebfb2Smrg	  tmp_libs=
2527a18ebfb2Smrg	  for deplib in $dependency_libs; do
2528a18ebfb2Smrg	    case $deplib in
2529a18ebfb2Smrg	    -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
2530a18ebfb2Smrg	    esac
2531a18ebfb2Smrg	    # Need to link against all dependency_libs?
2532a18ebfb2Smrg	    if test "$linkalldeplibs" = yes; then
2533a18ebfb2Smrg	      deplibs="$deplib $deplibs"
2534a18ebfb2Smrg	    else
2535a18ebfb2Smrg	      # Need to hardcode shared library paths
2536a18ebfb2Smrg	      # or/and link against static libraries
2537a18ebfb2Smrg	      newdependency_libs="$deplib $newdependency_libs"
2538a18ebfb2Smrg	    fi
2539a18ebfb2Smrg	    if test "X$duplicate_deps" = "Xyes" ; then
2540a18ebfb2Smrg	      case "$tmp_libs " in
2541a18ebfb2Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2542a18ebfb2Smrg	      esac
2543a18ebfb2Smrg	    fi
2544a18ebfb2Smrg	    tmp_libs="$tmp_libs $deplib"
2545a18ebfb2Smrg	  done # for deplib
2546a18ebfb2Smrg	  continue
2547a18ebfb2Smrg	fi # $linkmode = prog...
254850806d53Smrg
2549a18ebfb2Smrg	if test "$linkmode,$pass" = "prog,link"; then
2550a18ebfb2Smrg	  if test -n "$library_names" &&
2551a18ebfb2Smrg	     { { test "$prefer_static_libs" = no ||
2552a18ebfb2Smrg		 test "$prefer_static_libs,$installed" = "built,yes"; } ||
2553a18ebfb2Smrg	       test -z "$old_library"; }; then
2554a18ebfb2Smrg	    # We need to hardcode the library path
2555a18ebfb2Smrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
2556a18ebfb2Smrg	      # Make sure the rpath contains only unique directories.
2557a18ebfb2Smrg	      case "$temp_rpath " in
2558a18ebfb2Smrg	      *" $dir "*) ;;
2559a18ebfb2Smrg	      *" $absdir "*) ;;
2560a18ebfb2Smrg	      *) temp_rpath="$temp_rpath $absdir" ;;
2561a18ebfb2Smrg	      esac
2562a18ebfb2Smrg	    fi
256350806d53Smrg
2564a18ebfb2Smrg	    # Hardcode the library path.
2565a18ebfb2Smrg	    # Skip directories that are in the system default run-time
2566a18ebfb2Smrg	    # search path.
2567a18ebfb2Smrg	    case " $sys_lib_dlsearch_path " in
2568a18ebfb2Smrg	    *" $absdir "*) ;;
2569a18ebfb2Smrg	    *)
2570a18ebfb2Smrg	      case "$compile_rpath " in
2571a18ebfb2Smrg	      *" $absdir "*) ;;
2572a18ebfb2Smrg	      *) compile_rpath="$compile_rpath $absdir"
2573a18ebfb2Smrg	      esac
2574a18ebfb2Smrg	      ;;
2575a18ebfb2Smrg	    esac
2576a18ebfb2Smrg	    case " $sys_lib_dlsearch_path " in
2577a18ebfb2Smrg	    *" $libdir "*) ;;
2578a18ebfb2Smrg	    *)
2579a18ebfb2Smrg	      case "$finalize_rpath " in
2580a18ebfb2Smrg	      *" $libdir "*) ;;
2581a18ebfb2Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
2582a18ebfb2Smrg	      esac
2583a18ebfb2Smrg	      ;;
2584a18ebfb2Smrg	    esac
2585a18ebfb2Smrg	  fi # $linkmode,$pass = prog,link...
2586af1a9c97Smrg
2587a18ebfb2Smrg	  if test "$alldeplibs" = yes &&
2588a18ebfb2Smrg	     { test "$deplibs_check_method" = pass_all ||
2589a18ebfb2Smrg	       { test "$build_libtool_libs" = yes &&
2590a18ebfb2Smrg		 test -n "$library_names"; }; }; then
2591a18ebfb2Smrg	    # We only need to search for static libraries
2592a18ebfb2Smrg	    continue
2593a18ebfb2Smrg	  fi
259450806d53Smrg	fi
259550806d53Smrg
2596a18ebfb2Smrg	link_static=no # Whether the deplib will be linked statically
2597a18ebfb2Smrg	use_static_libs=$prefer_static_libs
2598a18ebfb2Smrg	if test "$use_static_libs" = built && test "$installed" = yes ; then
2599a18ebfb2Smrg	  use_static_libs=no
2600a18ebfb2Smrg	fi
2601a18ebfb2Smrg	if test -n "$library_names" &&
2602a18ebfb2Smrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
2603a18ebfb2Smrg	  if test "$installed" = no; then
2604a18ebfb2Smrg	    notinst_deplibs="$notinst_deplibs $lib"
2605a18ebfb2Smrg	    need_relink=yes
2606a18ebfb2Smrg	  fi
2607a18ebfb2Smrg	  # This is a shared library
260850806d53Smrg
2609a18ebfb2Smrg	  # Warn about portability, can't link against -module's on
2610a18ebfb2Smrg	  # some systems (darwin)
2611a18ebfb2Smrg	  if test "$shouldnotlink" = yes && test "$pass" = link ; then
2612a18ebfb2Smrg	    $echo
2613a18ebfb2Smrg	    if test "$linkmode" = prog; then
2614a18ebfb2Smrg	      $echo "*** Warning: Linking the executable $output against the loadable module"
2615a18ebfb2Smrg	    else
2616a18ebfb2Smrg	      $echo "*** Warning: Linking the shared library $output against the loadable module"
2617a18ebfb2Smrg	    fi
2618a18ebfb2Smrg	    $echo "*** $linklib is not portable!"
2619a18ebfb2Smrg	  fi
2620a18ebfb2Smrg	  if test "$linkmode" = lib &&
2621a18ebfb2Smrg	     test "$hardcode_into_libs" = yes; then
2622a18ebfb2Smrg	    # Hardcode the library path.
2623a18ebfb2Smrg	    # Skip directories that are in the system default run-time
2624a18ebfb2Smrg	    # search path.
2625a18ebfb2Smrg	    case " $sys_lib_dlsearch_path " in
2626a18ebfb2Smrg	    *" $absdir "*) ;;
2627a18ebfb2Smrg	    *)
2628a18ebfb2Smrg	      case "$compile_rpath " in
2629a18ebfb2Smrg	      *" $absdir "*) ;;
2630a18ebfb2Smrg	      *) compile_rpath="$compile_rpath $absdir"
2631a18ebfb2Smrg	      esac
2632a18ebfb2Smrg	      ;;
2633a18ebfb2Smrg	    esac
2634a18ebfb2Smrg	    case " $sys_lib_dlsearch_path " in
2635a18ebfb2Smrg	    *" $libdir "*) ;;
2636a18ebfb2Smrg	    *)
2637a18ebfb2Smrg	      case "$finalize_rpath " in
2638a18ebfb2Smrg	      *" $libdir "*) ;;
2639a18ebfb2Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
2640a18ebfb2Smrg	      esac
2641a18ebfb2Smrg	      ;;
2642a18ebfb2Smrg	    esac
2643a18ebfb2Smrg	  fi
2644af1a9c97Smrg
2645a18ebfb2Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
2646a18ebfb2Smrg	    # figure out the soname
2647a18ebfb2Smrg	    set dummy $library_names
2648a18ebfb2Smrg	    realname="$2"
2649a18ebfb2Smrg	    shift; shift
2650a18ebfb2Smrg	    libname=`eval \\$echo \"$libname_spec\"`
2651a18ebfb2Smrg	    # use dlname if we got it. it's perfectly good, no?
2652a18ebfb2Smrg	    if test -n "$dlname"; then
2653a18ebfb2Smrg	      soname="$dlname"
2654a18ebfb2Smrg	    elif test -n "$soname_spec"; then
2655a18ebfb2Smrg	      # bleh windows
2656a18ebfb2Smrg	      case $host in
2657a18ebfb2Smrg	      *cygwin* | mingw*)
2658a18ebfb2Smrg		major=`expr $current - $age`
2659a18ebfb2Smrg		versuffix="-$major"
2660a18ebfb2Smrg		;;
2661a18ebfb2Smrg	      esac
2662a18ebfb2Smrg	      eval soname=\"$soname_spec\"
2663a18ebfb2Smrg	    else
2664a18ebfb2Smrg	      soname="$realname"
2665a18ebfb2Smrg	    fi
2666af1a9c97Smrg
2667a18ebfb2Smrg	    # Make a new name for the extract_expsyms_cmds to use
2668a18ebfb2Smrg	    soroot="$soname"
2669a18ebfb2Smrg	    soname=`$echo $soroot | ${SED} -e 's/^.*\///'`
2670a18ebfb2Smrg	    newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
2671af1a9c97Smrg
2672a18ebfb2Smrg	    # If the library has no export list, then create one now
2673a18ebfb2Smrg	    if test -f "$output_objdir/$soname-def"; then :
2674a18ebfb2Smrg	    else
2675a18ebfb2Smrg	      $show "extracting exported symbol list from \`$soname'"
2676a18ebfb2Smrg	      save_ifs="$IFS"; IFS='~'
2677a18ebfb2Smrg	      cmds=$extract_expsyms_cmds
2678a18ebfb2Smrg	      for cmd in $cmds; do
2679a18ebfb2Smrg		IFS="$save_ifs"
2680a18ebfb2Smrg		eval cmd=\"$cmd\"
2681a18ebfb2Smrg		$show "$cmd"
2682a18ebfb2Smrg		$run eval "$cmd" || exit $?
2683a18ebfb2Smrg	      done
2684a18ebfb2Smrg	      IFS="$save_ifs"
2685a18ebfb2Smrg	    fi
2686af1a9c97Smrg
2687a18ebfb2Smrg	    # Create $newlib
2688a18ebfb2Smrg	    if test -f "$output_objdir/$newlib"; then :; else
2689a18ebfb2Smrg	      $show "generating import library for \`$soname'"
2690a18ebfb2Smrg	      save_ifs="$IFS"; IFS='~'
2691a18ebfb2Smrg	      cmds=$old_archive_from_expsyms_cmds
2692a18ebfb2Smrg	      for cmd in $cmds; do
2693a18ebfb2Smrg		IFS="$save_ifs"
2694a18ebfb2Smrg		eval cmd=\"$cmd\"
2695a18ebfb2Smrg		$show "$cmd"
2696a18ebfb2Smrg		$run eval "$cmd" || exit $?
2697a18ebfb2Smrg	      done
2698a18ebfb2Smrg	      IFS="$save_ifs"
2699a18ebfb2Smrg	    fi
2700a18ebfb2Smrg	    # make sure the library variables are pointing to the new library
2701a18ebfb2Smrg	    dir=$output_objdir
2702a18ebfb2Smrg	    linklib=$newlib
2703a18ebfb2Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
270450806d53Smrg
2705a18ebfb2Smrg	  if test "$linkmode" = prog || test "$mode" != relink; then
2706a18ebfb2Smrg	    add_shlibpath=
2707a18ebfb2Smrg	    add_dir=
2708a18ebfb2Smrg	    add=
2709a18ebfb2Smrg	    lib_linked=yes
2710a18ebfb2Smrg	    case $hardcode_action in
2711a18ebfb2Smrg	    immediate | unsupported)
2712a18ebfb2Smrg	      if test "$hardcode_direct" = no; then
2713a18ebfb2Smrg		add="$dir/$linklib"
2714a18ebfb2Smrg		case $host in
2715a18ebfb2Smrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
2716a18ebfb2Smrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
2717a18ebfb2Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
2718a18ebfb2Smrg		    *-*-unixware7*) add_dir="-L$dir" ;;
2719a18ebfb2Smrg		  *-*-darwin* )
2720a18ebfb2Smrg		    # if the lib is a module then we can not link against
2721a18ebfb2Smrg		    # it, someone is ignoring the new warnings I added
2722a18ebfb2Smrg		    if /usr/bin/file -L $add 2> /dev/null |
2723a18ebfb2Smrg                      $EGREP ": [^:]* bundle" >/dev/null ; then
2724a18ebfb2Smrg		      $echo "** Warning, lib $linklib is a module, not a shared library"
2725a18ebfb2Smrg		      if test -z "$old_library" ; then
2726a18ebfb2Smrg		        $echo
2727a18ebfb2Smrg		        $echo "** And there doesn't seem to be a static archive available"
2728a18ebfb2Smrg		        $echo "** The link will probably fail, sorry"
2729a18ebfb2Smrg		      else
2730a18ebfb2Smrg		        add="$dir/$old_library"
2731a18ebfb2Smrg		      fi
2732a18ebfb2Smrg		    fi
2733a18ebfb2Smrg		esac
2734a18ebfb2Smrg	      elif test "$hardcode_minus_L" = no; then
2735a18ebfb2Smrg		case $host in
2736a18ebfb2Smrg		*-*-sunos*) add_shlibpath="$dir" ;;
2737a18ebfb2Smrg		esac
2738a18ebfb2Smrg		add_dir="-L$dir"
2739a18ebfb2Smrg		add="-l$name"
2740a18ebfb2Smrg	      elif test "$hardcode_shlibpath_var" = no; then
2741a18ebfb2Smrg		add_shlibpath="$dir"
2742a18ebfb2Smrg		add="-l$name"
2743a18ebfb2Smrg	      else
2744a18ebfb2Smrg		lib_linked=no
2745a18ebfb2Smrg	      fi
2746a18ebfb2Smrg	      ;;
2747a18ebfb2Smrg	    relink)
2748a18ebfb2Smrg	      if test "$hardcode_direct" = yes; then
2749a18ebfb2Smrg		add="$dir/$linklib"
2750a18ebfb2Smrg	      elif test "$hardcode_minus_L" = yes; then
2751a18ebfb2Smrg		add_dir="-L$dir"
2752a18ebfb2Smrg		# Try looking first in the location we're being installed to.
2753a18ebfb2Smrg		if test -n "$inst_prefix_dir"; then
2754a18ebfb2Smrg		  case $libdir in
2755a18ebfb2Smrg		    [\\/]*)
2756a18ebfb2Smrg		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
2757a18ebfb2Smrg		      ;;
2758a18ebfb2Smrg		  esac
2759a18ebfb2Smrg		fi
2760a18ebfb2Smrg		add="-l$name"
2761a18ebfb2Smrg	      elif test "$hardcode_shlibpath_var" = yes; then
2762a18ebfb2Smrg		add_shlibpath="$dir"
2763a18ebfb2Smrg		add="-l$name"
2764a18ebfb2Smrg	      else
2765a18ebfb2Smrg		lib_linked=no
2766a18ebfb2Smrg	      fi
2767a18ebfb2Smrg	      ;;
2768a18ebfb2Smrg	    *) lib_linked=no ;;
2769a18ebfb2Smrg	    esac
277050806d53Smrg
2771a18ebfb2Smrg	    if test "$lib_linked" != yes; then
2772a18ebfb2Smrg	      $echo "$modename: configuration error: unsupported hardcode properties"
2773a18ebfb2Smrg	      exit $EXIT_FAILURE
2774a18ebfb2Smrg	    fi
277550806d53Smrg
2776a18ebfb2Smrg	    if test -n "$add_shlibpath"; then
2777a18ebfb2Smrg	      case :$compile_shlibpath: in
2778a18ebfb2Smrg	      *":$add_shlibpath:"*) ;;
2779a18ebfb2Smrg	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
2780a18ebfb2Smrg	      esac
2781a18ebfb2Smrg	    fi
2782a18ebfb2Smrg	    if test "$linkmode" = prog; then
2783a18ebfb2Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
2784a18ebfb2Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
2785a18ebfb2Smrg	    else
2786a18ebfb2Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
2787a18ebfb2Smrg	      test -n "$add" && deplibs="$add $deplibs"
2788a18ebfb2Smrg	      if test "$hardcode_direct" != yes && \
2789a18ebfb2Smrg		 test "$hardcode_minus_L" != yes && \
2790a18ebfb2Smrg		 test "$hardcode_shlibpath_var" = yes; then
2791a18ebfb2Smrg		case :$finalize_shlibpath: in
2792a18ebfb2Smrg		*":$libdir:"*) ;;
2793a18ebfb2Smrg		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
2794a18ebfb2Smrg		esac
2795a18ebfb2Smrg	      fi
2796a18ebfb2Smrg	    fi
2797a18ebfb2Smrg	  fi
279850806d53Smrg
2799a18ebfb2Smrg	  if test "$linkmode" = prog || test "$mode" = relink; then
2800a18ebfb2Smrg	    add_shlibpath=
2801a18ebfb2Smrg	    add_dir=
2802a18ebfb2Smrg	    add=
2803a18ebfb2Smrg	    # Finalize command for both is simple: just hardcode it.
2804a18ebfb2Smrg	    if test "$hardcode_direct" = yes; then
2805a18ebfb2Smrg	      add="$libdir/$linklib"
2806a18ebfb2Smrg	    elif test "$hardcode_minus_L" = yes; then
2807a18ebfb2Smrg	      add_dir="-L$libdir"
2808a18ebfb2Smrg	      add="-l$name"
2809a18ebfb2Smrg	    elif test "$hardcode_shlibpath_var" = yes; then
2810a18ebfb2Smrg	      case :$finalize_shlibpath: in
2811a18ebfb2Smrg	      *":$libdir:"*) ;;
2812a18ebfb2Smrg	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
2813a18ebfb2Smrg	      esac
2814a18ebfb2Smrg	      add="-l$name"
2815a18ebfb2Smrg	    elif test "$hardcode_automatic" = yes; then
2816a18ebfb2Smrg	      if test -n "$inst_prefix_dir" &&
2817a18ebfb2Smrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
2818a18ebfb2Smrg	        add="$inst_prefix_dir$libdir/$linklib"
2819a18ebfb2Smrg	      else
2820a18ebfb2Smrg	        add="$libdir/$linklib"
2821a18ebfb2Smrg	      fi
2822a18ebfb2Smrg	    else
2823a18ebfb2Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
2824a18ebfb2Smrg	      add_dir="-L$libdir"
2825a18ebfb2Smrg	      # Try looking first in the location we're being installed to.
2826a18ebfb2Smrg	      if test -n "$inst_prefix_dir"; then
2827a18ebfb2Smrg		case $libdir in
2828a18ebfb2Smrg		  [\\/]*)
2829a18ebfb2Smrg		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
2830a18ebfb2Smrg		    ;;
2831a18ebfb2Smrg		esac
2832a18ebfb2Smrg	      fi
2833a18ebfb2Smrg	      add="-l$name"
2834a18ebfb2Smrg	    fi
2835af1a9c97Smrg
2836a18ebfb2Smrg	    if test "$linkmode" = prog; then
2837a18ebfb2Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
2838a18ebfb2Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
2839a18ebfb2Smrg	    else
2840a18ebfb2Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
2841a18ebfb2Smrg	      test -n "$add" && deplibs="$add $deplibs"
2842a18ebfb2Smrg	    fi
2843a18ebfb2Smrg	  fi
2844a18ebfb2Smrg	elif test "$linkmode" = prog; then
2845a18ebfb2Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
2846a18ebfb2Smrg	  # is not unsupported.  This is valid on all known static and
2847a18ebfb2Smrg	  # shared platforms.
2848a18ebfb2Smrg	  if test "$hardcode_direct" != unsupported; then
2849a18ebfb2Smrg	    test -n "$old_library" && linklib="$old_library"
2850a18ebfb2Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
2851a18ebfb2Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
2852a18ebfb2Smrg	  else
2853a18ebfb2Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
2854a18ebfb2Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
2855a18ebfb2Smrg	  fi
2856a18ebfb2Smrg	elif test "$build_libtool_libs" = yes; then
2857a18ebfb2Smrg	  # Not a shared library
2858a18ebfb2Smrg	  if test "$deplibs_check_method" != pass_all; then
2859a18ebfb2Smrg	    # We're trying link a shared library against a static one
2860a18ebfb2Smrg	    # but the system doesn't support it.
286150806d53Smrg
2862a18ebfb2Smrg	    # Just print a warning and add the library to dependency_libs so
2863a18ebfb2Smrg	    # that the program can be linked against the static library.
2864a18ebfb2Smrg	    $echo
2865a18ebfb2Smrg	    $echo "*** Warning: This system can not link to static lib archive $lib."
2866a18ebfb2Smrg	    $echo "*** I have the capability to make that library automatically link in when"
2867a18ebfb2Smrg	    $echo "*** you link to this library.  But I can only do this if you have a"
2868a18ebfb2Smrg	    $echo "*** shared version of the library, which you do not appear to have."
2869a18ebfb2Smrg	    if test "$module" = yes; then
2870a18ebfb2Smrg	      $echo "*** But as you try to build a module library, libtool will still create "
2871a18ebfb2Smrg	      $echo "*** a static module, that should work as long as the dlopening application"
2872a18ebfb2Smrg	      $echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
2873a18ebfb2Smrg	      if test -z "$global_symbol_pipe"; then
2874a18ebfb2Smrg		$echo
2875a18ebfb2Smrg		$echo "*** However, this would only work if libtool was able to extract symbol"
2876a18ebfb2Smrg		$echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
2877a18ebfb2Smrg		$echo "*** not find such a program.  So, this module is probably useless."
2878a18ebfb2Smrg		$echo "*** \`nm' from GNU binutils and a full rebuild may help."
2879a18ebfb2Smrg	      fi
2880a18ebfb2Smrg	      if test "$build_old_libs" = no; then
2881a18ebfb2Smrg		build_libtool_libs=module
2882a18ebfb2Smrg		build_old_libs=yes
2883a18ebfb2Smrg	      else
2884a18ebfb2Smrg		build_libtool_libs=no
2885a18ebfb2Smrg	      fi
2886a18ebfb2Smrg	    fi
2887a18ebfb2Smrg	  else
2888a18ebfb2Smrg	    deplibs="$dir/$old_library $deplibs"
2889a18ebfb2Smrg	    link_static=yes
2890a18ebfb2Smrg	  fi
2891a18ebfb2Smrg	fi # link shared/static library?
289250806d53Smrg
2893a18ebfb2Smrg	if test "$linkmode" = lib; then
2894a18ebfb2Smrg	  if test -n "$dependency_libs" &&
2895a18ebfb2Smrg	     { test "$hardcode_into_libs" != yes ||
2896a18ebfb2Smrg	       test "$build_old_libs" = yes ||
2897a18ebfb2Smrg	       test "$link_static" = yes; }; then
2898a18ebfb2Smrg	    # Extract -R from dependency_libs
2899a18ebfb2Smrg	    temp_deplibs=
2900a18ebfb2Smrg	    for libdir in $dependency_libs; do
2901a18ebfb2Smrg	      case $libdir in
2902a18ebfb2Smrg	      -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'`
2903a18ebfb2Smrg		   case " $xrpath " in
2904a18ebfb2Smrg		   *" $temp_xrpath "*) ;;
2905a18ebfb2Smrg		   *) xrpath="$xrpath $temp_xrpath";;
2906a18ebfb2Smrg		   esac;;
2907a18ebfb2Smrg	      *) temp_deplibs="$temp_deplibs $libdir";;
2908a18ebfb2Smrg	      esac
2909a18ebfb2Smrg	    done
2910a18ebfb2Smrg	    dependency_libs="$temp_deplibs"
2911a18ebfb2Smrg	  fi
291250806d53Smrg
2913a18ebfb2Smrg	  newlib_search_path="$newlib_search_path $absdir"
2914a18ebfb2Smrg	  # Link against this library
2915a18ebfb2Smrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
2916a18ebfb2Smrg	  # ... and its dependency_libs
2917a18ebfb2Smrg	  tmp_libs=
2918a18ebfb2Smrg	  for deplib in $dependency_libs; do
2919a18ebfb2Smrg	    newdependency_libs="$deplib $newdependency_libs"
2920a18ebfb2Smrg	    if test "X$duplicate_deps" = "Xyes" ; then
2921a18ebfb2Smrg	      case "$tmp_libs " in
2922a18ebfb2Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2923a18ebfb2Smrg	      esac
2924a18ebfb2Smrg	    fi
2925a18ebfb2Smrg	    tmp_libs="$tmp_libs $deplib"
2926a18ebfb2Smrg	  done
292750806d53Smrg
2928a18ebfb2Smrg	  if test "$link_all_deplibs" != no; then
2929a18ebfb2Smrg	    # Add the search paths of all dependency libraries
2930a18ebfb2Smrg	    for deplib in $dependency_libs; do
2931a18ebfb2Smrg	      case $deplib in
2932a18ebfb2Smrg	      -L*) path="$deplib" ;;
2933a18ebfb2Smrg	      *.la)
2934a18ebfb2Smrg		dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
2935a18ebfb2Smrg		test "X$dir" = "X$deplib" && dir="."
2936a18ebfb2Smrg		# We need an absolute path.
2937a18ebfb2Smrg		case $dir in
2938a18ebfb2Smrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
2939a18ebfb2Smrg		*)
2940a18ebfb2Smrg		  absdir=`cd "$dir" && pwd`
2941a18ebfb2Smrg		  if test -z "$absdir"; then
2942a18ebfb2Smrg		    $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
2943a18ebfb2Smrg		    absdir="$dir"
2944a18ebfb2Smrg		  fi
2945a18ebfb2Smrg		  ;;
2946a18ebfb2Smrg		esac
2947a18ebfb2Smrg		if grep "^installed=no" $deplib > /dev/null; then
2948a18ebfb2Smrg		  path="$absdir/$objdir"
2949a18ebfb2Smrg		else
2950a18ebfb2Smrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
2951a18ebfb2Smrg		  if test -z "$libdir"; then
2952a18ebfb2Smrg		    $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
2953a18ebfb2Smrg		    exit $EXIT_FAILURE
2954a18ebfb2Smrg		  fi
2955a18ebfb2Smrg		  if test "$absdir" != "$libdir"; then
2956a18ebfb2Smrg		    $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
2957a18ebfb2Smrg		  fi
2958a18ebfb2Smrg		  path="$absdir"
2959a18ebfb2Smrg		fi
2960a18ebfb2Smrg		depdepl=
2961a18ebfb2Smrg		case $host in
2962a18ebfb2Smrg		*-*-darwin*)
2963a18ebfb2Smrg		  # we do not want to link against static libs,
2964a18ebfb2Smrg		  # but need to link against shared
2965a18ebfb2Smrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
2966a18ebfb2Smrg		  eval deplibdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
2967a18ebfb2Smrg		  if test -n "$deplibrary_names" ; then
2968a18ebfb2Smrg		    for tmp in $deplibrary_names ; do
2969a18ebfb2Smrg		      depdepl=$tmp
2970a18ebfb2Smrg		    done
2971a18ebfb2Smrg		    if test -f "$deplibdir/$depdepl" ; then
2972a18ebfb2Smrg		      depdepl="$deplibdir/$depdepl"
2973a18ebfb2Smrg	      	    elif test -f "$path/$depdepl" ; then
2974a18ebfb2Smrg		      depdepl="$path/$depdepl"
2975a18ebfb2Smrg		    else
2976a18ebfb2Smrg		      # Can't find it, oh well...
2977a18ebfb2Smrg		      depdepl=
2978a18ebfb2Smrg		    fi
2979a18ebfb2Smrg		    # do not add paths which are already there
2980a18ebfb2Smrg		    case " $newlib_search_path " in
2981a18ebfb2Smrg		    *" $path "*) ;;
2982a18ebfb2Smrg		    *) newlib_search_path="$newlib_search_path $path";;
2983a18ebfb2Smrg		    esac
2984a18ebfb2Smrg		  fi
2985a18ebfb2Smrg		  path=""
2986a18ebfb2Smrg		  ;;
2987a18ebfb2Smrg		*)
2988a18ebfb2Smrg		  path="-L$path"
2989a18ebfb2Smrg		  ;;
2990a18ebfb2Smrg		esac
2991a18ebfb2Smrg		;;
2992a18ebfb2Smrg	      -l*)
2993a18ebfb2Smrg		case $host in
2994a18ebfb2Smrg		*-*-darwin*)
2995a18ebfb2Smrg		  # Again, we only want to link against shared libraries
2996a18ebfb2Smrg		  eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
2997a18ebfb2Smrg		  for tmp in $newlib_search_path ; do
2998a18ebfb2Smrg		    if test -f "$tmp/lib$tmp_libs.dylib" ; then
2999a18ebfb2Smrg		      eval depdepl="$tmp/lib$tmp_libs.dylib"
3000a18ebfb2Smrg		      break
3001a18ebfb2Smrg		    fi
3002a18ebfb2Smrg		  done
3003a18ebfb2Smrg		  path=""
3004a18ebfb2Smrg		  ;;
3005a18ebfb2Smrg		*) continue ;;
3006a18ebfb2Smrg		esac
3007a18ebfb2Smrg		;;
3008a18ebfb2Smrg	      *) continue ;;
3009a18ebfb2Smrg	      esac
3010a18ebfb2Smrg	      case " $deplibs " in
3011a18ebfb2Smrg	      *" $path "*) ;;
3012a18ebfb2Smrg	      *) deplibs="$path $deplibs" ;;
3013a18ebfb2Smrg	      esac
3014a18ebfb2Smrg	      case " $deplibs " in
3015a18ebfb2Smrg	      *" $depdepl "*) ;;
3016a18ebfb2Smrg	      *) deplibs="$depdepl $deplibs" ;;
3017a18ebfb2Smrg	      esac
3018a18ebfb2Smrg	    done
3019a18ebfb2Smrg	  fi # link_all_deplibs != no
3020a18ebfb2Smrg	fi # linkmode = lib
3021a18ebfb2Smrg      done # for deplib in $libs
3022a18ebfb2Smrg      dependency_libs="$newdependency_libs"
3023a18ebfb2Smrg      if test "$pass" = dlpreopen; then
3024a18ebfb2Smrg	# Link the dlpreopened libraries before other libraries
3025a18ebfb2Smrg	for deplib in $save_deplibs; do
3026a18ebfb2Smrg	  deplibs="$deplib $deplibs"
3027a18ebfb2Smrg	done
3028a18ebfb2Smrg      fi
3029a18ebfb2Smrg      if test "$pass" != dlopen; then
3030a18ebfb2Smrg	if test "$pass" != conv; then
3031a18ebfb2Smrg	  # Make sure lib_search_path contains only unique directories.
3032a18ebfb2Smrg	  lib_search_path=
3033a18ebfb2Smrg	  for dir in $newlib_search_path; do
3034a18ebfb2Smrg	    case "$lib_search_path " in
3035a18ebfb2Smrg	    *" $dir "*) ;;
3036a18ebfb2Smrg	    *) lib_search_path="$lib_search_path $dir" ;;
3037a18ebfb2Smrg	    esac
3038a18ebfb2Smrg	  done
3039a18ebfb2Smrg	  newlib_search_path=
3040a18ebfb2Smrg	fi
3041a18ebfb2Smrg
3042a18ebfb2Smrg	if test "$linkmode,$pass" != "prog,link"; then
3043a18ebfb2Smrg	  vars="deplibs"
3044a18ebfb2Smrg	else
3045a18ebfb2Smrg	  vars="compile_deplibs finalize_deplibs"
3046a18ebfb2Smrg	fi
3047a18ebfb2Smrg	for var in $vars dependency_libs; do
3048a18ebfb2Smrg	  # Add libraries to $var in reverse order
3049a18ebfb2Smrg	  eval tmp_libs=\"\$$var\"
3050a18ebfb2Smrg	  new_libs=
3051a18ebfb2Smrg	  for deplib in $tmp_libs; do
3052a18ebfb2Smrg	    # FIXME: Pedantically, this is the right thing to do, so
3053a18ebfb2Smrg	    #        that some nasty dependency loop isn't accidentally
3054a18ebfb2Smrg	    #        broken:
3055a18ebfb2Smrg	    #new_libs="$deplib $new_libs"
3056a18ebfb2Smrg	    # Pragmatically, this seems to cause very few problems in
3057a18ebfb2Smrg	    # practice:
3058a18ebfb2Smrg	    case $deplib in
3059a18ebfb2Smrg	    -L*) new_libs="$deplib $new_libs" ;;
3060a18ebfb2Smrg	    -R*) ;;
3061a18ebfb2Smrg	    *)
3062a18ebfb2Smrg	      # And here is the reason: when a library appears more
3063a18ebfb2Smrg	      # than once as an explicit dependence of a library, or
3064a18ebfb2Smrg	      # is implicitly linked in more than once by the
3065a18ebfb2Smrg	      # compiler, it is considered special, and multiple
3066a18ebfb2Smrg	      # occurrences thereof are not removed.  Compare this
3067a18ebfb2Smrg	      # with having the same library being listed as a
3068a18ebfb2Smrg	      # dependency of multiple other libraries: in this case,
3069a18ebfb2Smrg	      # we know (pedantically, we assume) the library does not
3070a18ebfb2Smrg	      # need to be listed more than once, so we keep only the
3071a18ebfb2Smrg	      # last copy.  This is not always right, but it is rare
3072a18ebfb2Smrg	      # enough that we require users that really mean to play
3073a18ebfb2Smrg	      # such unportable linking tricks to link the library
3074a18ebfb2Smrg	      # using -Wl,-lname, so that libtool does not consider it
3075a18ebfb2Smrg	      # for duplicate removal.
3076a18ebfb2Smrg	      case " $specialdeplibs " in
3077a18ebfb2Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
3078a18ebfb2Smrg	      *)
3079a18ebfb2Smrg		case " $new_libs " in
3080a18ebfb2Smrg		*" $deplib "*) ;;
3081a18ebfb2Smrg		*) new_libs="$deplib $new_libs" ;;
3082a18ebfb2Smrg		esac
3083a18ebfb2Smrg		;;
3084a18ebfb2Smrg	      esac
3085a18ebfb2Smrg	      ;;
3086a18ebfb2Smrg	    esac
3087a18ebfb2Smrg	  done
3088a18ebfb2Smrg	  tmp_libs=
3089a18ebfb2Smrg	  for deplib in $new_libs; do
3090a18ebfb2Smrg	    case $deplib in
3091a18ebfb2Smrg	    -L*)
3092a18ebfb2Smrg	      case " $tmp_libs " in
3093a18ebfb2Smrg	      *" $deplib "*) ;;
3094a18ebfb2Smrg	      *) tmp_libs="$tmp_libs $deplib" ;;
3095a18ebfb2Smrg	      esac
3096a18ebfb2Smrg	      ;;
3097a18ebfb2Smrg	    *) tmp_libs="$tmp_libs $deplib" ;;
3098a18ebfb2Smrg	    esac
3099a18ebfb2Smrg	  done
3100a18ebfb2Smrg	  eval $var=\"$tmp_libs\"
3101a18ebfb2Smrg	done # for var
3102a18ebfb2Smrg      fi
3103a18ebfb2Smrg      # Last step: remove runtime libs from dependency_libs
3104a18ebfb2Smrg      # (they stay in deplibs)
3105a18ebfb2Smrg      tmp_libs=
3106a18ebfb2Smrg      for i in $dependency_libs ; do
3107a18ebfb2Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
3108a18ebfb2Smrg	*" $i "*)
3109a18ebfb2Smrg	  i=""
311050806d53Smrg	  ;;
311150806d53Smrg	esac
3112a18ebfb2Smrg	if test -n "$i" ; then
3113a18ebfb2Smrg	  tmp_libs="$tmp_libs $i"
3114a18ebfb2Smrg	fi
3115a18ebfb2Smrg      done
3116a18ebfb2Smrg      dependency_libs=$tmp_libs
3117a18ebfb2Smrg    done # for pass
3118a18ebfb2Smrg    if test "$linkmode" = prog; then
3119a18ebfb2Smrg      dlfiles="$newdlfiles"
3120a18ebfb2Smrg      dlprefiles="$newdlprefiles"
3121af1a9c97Smrg    fi
312250806d53Smrg
3123a18ebfb2Smrg    case $linkmode in
3124a18ebfb2Smrg    oldlib)
3125a18ebfb2Smrg      case " $deplibs" in
3126a18ebfb2Smrg      *\ -l* | *\ -L*)
3127a18ebfb2Smrg	$echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2 ;;
3128a18ebfb2Smrg      esac
312950806d53Smrg
3130a18ebfb2Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
3131a18ebfb2Smrg	$echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
3132a18ebfb2Smrg      fi
313350806d53Smrg
3134a18ebfb2Smrg      if test -n "$rpath"; then
3135a18ebfb2Smrg	$echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
3136a18ebfb2Smrg      fi
313750806d53Smrg
3138a18ebfb2Smrg      if test -n "$xrpath"; then
3139a18ebfb2Smrg	$echo "$modename: warning: \`-R' is ignored for archives" 1>&2
3140a18ebfb2Smrg      fi
314150806d53Smrg
3142a18ebfb2Smrg      if test -n "$vinfo"; then
3143a18ebfb2Smrg	$echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2
3144a18ebfb2Smrg      fi
314550806d53Smrg
3146a18ebfb2Smrg      if test -n "$release"; then
3147a18ebfb2Smrg	$echo "$modename: warning: \`-release' is ignored for archives" 1>&2
3148a18ebfb2Smrg      fi
314950806d53Smrg
3150a18ebfb2Smrg      if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
3151a18ebfb2Smrg	$echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
3152a18ebfb2Smrg      fi
315350806d53Smrg
3154a18ebfb2Smrg      # Now set the variables for building old libraries.
3155a18ebfb2Smrg      build_libtool_libs=no
3156a18ebfb2Smrg      oldlibs="$output"
3157a18ebfb2Smrg      objs="$objs$old_deplibs"
3158a18ebfb2Smrg      ;;
315950806d53Smrg
3160a18ebfb2Smrg    lib)
3161a18ebfb2Smrg      # Make sure we only generate libraries of the form `libNAME.la'.
3162a18ebfb2Smrg      case $outputname in
3163a18ebfb2Smrg      lib*)
3164a18ebfb2Smrg	name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
3165a18ebfb2Smrg	eval shared_ext=\"$shrext_cmds\"
3166a18ebfb2Smrg	eval libname=\"$libname_spec\"
3167a18ebfb2Smrg	;;
3168a18ebfb2Smrg      *)
3169a18ebfb2Smrg	if test "$module" = no; then
3170a18ebfb2Smrg	  $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
3171a18ebfb2Smrg	  $echo "$help" 1>&2
3172a18ebfb2Smrg	  exit $EXIT_FAILURE
3173a18ebfb2Smrg	fi
3174a18ebfb2Smrg	if test "$need_lib_prefix" != no; then
3175a18ebfb2Smrg	  # Add the "lib" prefix for modules if required
3176a18ebfb2Smrg	  name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
3177a18ebfb2Smrg	  eval shared_ext=\"$shrext_cmds\"
3178a18ebfb2Smrg	  eval libname=\"$libname_spec\"
3179a18ebfb2Smrg	else
3180a18ebfb2Smrg	  libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
3181a18ebfb2Smrg	fi
3182a18ebfb2Smrg	;;
3183a18ebfb2Smrg      esac
318450806d53Smrg
3185a18ebfb2Smrg      if test -n "$objs"; then
3186a18ebfb2Smrg	if test "$deplibs_check_method" != pass_all; then
3187a18ebfb2Smrg	  $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
3188a18ebfb2Smrg	  exit $EXIT_FAILURE
3189a18ebfb2Smrg	else
3190a18ebfb2Smrg	  $echo
3191a18ebfb2Smrg	  $echo "*** Warning: Linking the shared library $output against the non-libtool"
3192a18ebfb2Smrg	  $echo "*** objects $objs is not portable!"
3193a18ebfb2Smrg	  libobjs="$libobjs $objs"
3194a18ebfb2Smrg	fi
3195a18ebfb2Smrg      fi
319650806d53Smrg
3197a18ebfb2Smrg      if test "$dlself" != no; then
3198a18ebfb2Smrg	$echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2
3199a18ebfb2Smrg      fi
320050806d53Smrg
3201a18ebfb2Smrg      set dummy $rpath
3202a18ebfb2Smrg      if test "$#" -gt 2; then
3203a18ebfb2Smrg	$echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
3204a18ebfb2Smrg      fi
3205a18ebfb2Smrg      install_libdir="$2"
320650806d53Smrg
3207a18ebfb2Smrg      oldlibs=
3208a18ebfb2Smrg      if test -z "$rpath"; then
3209a18ebfb2Smrg	if test "$build_libtool_libs" = yes; then
3210a18ebfb2Smrg	  # Building a libtool convenience library.
3211a18ebfb2Smrg	  # Some compilers have problems with a `.al' extension so
3212a18ebfb2Smrg	  # convenience libraries should have the same extension an
3213a18ebfb2Smrg	  # archive normally would.
3214a18ebfb2Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
3215a18ebfb2Smrg	  build_libtool_libs=convenience
3216a18ebfb2Smrg	  build_old_libs=yes
3217a18ebfb2Smrg	fi
321850806d53Smrg
3219a18ebfb2Smrg	if test -n "$vinfo"; then
3220a18ebfb2Smrg	  $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2
3221a18ebfb2Smrg	fi
322250806d53Smrg
3223a18ebfb2Smrg	if test -n "$release"; then
3224a18ebfb2Smrg	  $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
3225a18ebfb2Smrg	fi
3226a18ebfb2Smrg      else
322750806d53Smrg
3228a18ebfb2Smrg	# Parse the version information argument.
3229a18ebfb2Smrg	save_ifs="$IFS"; IFS=':'
3230a18ebfb2Smrg	set dummy $vinfo 0 0 0
3231a18ebfb2Smrg	IFS="$save_ifs"
323250806d53Smrg
3233a18ebfb2Smrg	if test -n "$8"; then
3234a18ebfb2Smrg	  $echo "$modename: too many parameters to \`-version-info'" 1>&2
3235a18ebfb2Smrg	  $echo "$help" 1>&2
3236a18ebfb2Smrg	  exit $EXIT_FAILURE
3237a18ebfb2Smrg	fi
323850806d53Smrg
3239a18ebfb2Smrg	# convert absolute version numbers to libtool ages
3240a18ebfb2Smrg	# this retains compatibility with .la files and attempts
3241a18ebfb2Smrg	# to make the code below a bit more comprehensible
324250806d53Smrg
3243a18ebfb2Smrg	case $vinfo_number in
3244a18ebfb2Smrg	yes)
3245a18ebfb2Smrg	  number_major="$2"
3246a18ebfb2Smrg	  number_minor="$3"
3247a18ebfb2Smrg	  number_revision="$4"
3248a18ebfb2Smrg	  #
3249a18ebfb2Smrg	  # There are really only two kinds -- those that
3250a18ebfb2Smrg	  # use the current revision as the major version
3251a18ebfb2Smrg	  # and those that subtract age and use age as
3252a18ebfb2Smrg	  # a minor version.  But, then there is irix
3253a18ebfb2Smrg	  # which has an extra 1 added just for fun
3254a18ebfb2Smrg	  #
3255a18ebfb2Smrg	  case $version_type in
3256a18ebfb2Smrg	  darwin|linux|osf|windows|none)
3257a18ebfb2Smrg	    current=`expr $number_major + $number_minor`
3258a18ebfb2Smrg	    age="$number_minor"
3259a18ebfb2Smrg	    revision="$number_revision"
3260a18ebfb2Smrg	    ;;
3261a18ebfb2Smrg	  freebsd-aout|freebsd-elf|sunos)
3262a18ebfb2Smrg	    current="$number_major"
3263a18ebfb2Smrg	    revision="$number_minor"
3264a18ebfb2Smrg	    age="0"
3265a18ebfb2Smrg	    ;;
3266a18ebfb2Smrg	  irix|nonstopux)
3267a18ebfb2Smrg	    current=`expr $number_major + $number_minor`
3268a18ebfb2Smrg	    age="$number_minor"
3269a18ebfb2Smrg	    revision="$number_minor"
3270a18ebfb2Smrg	    lt_irix_increment=no
3271a18ebfb2Smrg	    ;;
3272a18ebfb2Smrg	  esac
3273a18ebfb2Smrg	  ;;
3274a18ebfb2Smrg	no)
3275a18ebfb2Smrg	  current="$2"
3276a18ebfb2Smrg	  revision="$3"
3277a18ebfb2Smrg	  age="$4"
3278a18ebfb2Smrg	  ;;
3279a18ebfb2Smrg	esac
328050806d53Smrg
3281a18ebfb2Smrg	# Check that each of the things are valid numbers.
3282a18ebfb2Smrg	case $current in
3283a18ebfb2Smrg	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]) ;;
3284a18ebfb2Smrg	*)
3285a18ebfb2Smrg	  $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2
3286a18ebfb2Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3287a18ebfb2Smrg	  exit $EXIT_FAILURE
3288a18ebfb2Smrg	  ;;
3289a18ebfb2Smrg	esac
329050806d53Smrg
3291a18ebfb2Smrg	case $revision in
3292a18ebfb2Smrg	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]) ;;
3293a18ebfb2Smrg	*)
3294a18ebfb2Smrg	  $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2
3295a18ebfb2Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3296a18ebfb2Smrg	  exit $EXIT_FAILURE
3297a18ebfb2Smrg	  ;;
3298a18ebfb2Smrg	esac
329950806d53Smrg
3300a18ebfb2Smrg	case $age in
3301a18ebfb2Smrg	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]) ;;
3302a18ebfb2Smrg	*)
3303a18ebfb2Smrg	  $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2
3304a18ebfb2Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3305a18ebfb2Smrg	  exit $EXIT_FAILURE
3306a18ebfb2Smrg	  ;;
3307a18ebfb2Smrg	esac
330850806d53Smrg
3309a18ebfb2Smrg	if test "$age" -gt "$current"; then
3310a18ebfb2Smrg	  $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
3311a18ebfb2Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3312a18ebfb2Smrg	  exit $EXIT_FAILURE
3313a18ebfb2Smrg	fi
331450806d53Smrg
3315a18ebfb2Smrg	# Calculate the version variables.
3316a18ebfb2Smrg	major=
3317a18ebfb2Smrg	versuffix=
3318a18ebfb2Smrg	verstring=
3319a18ebfb2Smrg	case $version_type in
3320a18ebfb2Smrg	none) ;;
332150806d53Smrg
3322a18ebfb2Smrg	darwin)
3323a18ebfb2Smrg	  # Like Linux, but with the current version available in
3324a18ebfb2Smrg	  # verstring for coding it into the library header
3325a18ebfb2Smrg	  major=.`expr $current - $age`
3326a18ebfb2Smrg	  versuffix="$major.$age.$revision"
3327a18ebfb2Smrg	  # Darwin ld doesn't like 0 for these options...
3328a18ebfb2Smrg	  minor_current=`expr $current + 1`
3329a18ebfb2Smrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
3330a18ebfb2Smrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
3331a18ebfb2Smrg	  ;;
333250806d53Smrg
3333a18ebfb2Smrg	freebsd-aout)
3334a18ebfb2Smrg	  major=".$current"
3335a18ebfb2Smrg	  versuffix=".$current.$revision";
3336a18ebfb2Smrg	  ;;
333750806d53Smrg
3338a18ebfb2Smrg	freebsd-elf)
3339a18ebfb2Smrg	  major=".$current"
3340a18ebfb2Smrg	  versuffix=".$current";
3341a18ebfb2Smrg	  ;;
3342af1a9c97Smrg
3343a18ebfb2Smrg	irix | nonstopux)
3344a18ebfb2Smrg	  if test "X$lt_irix_increment" = "Xno"; then
3345a18ebfb2Smrg	    major=`expr $current - $age`
3346a18ebfb2Smrg	  else
3347a18ebfb2Smrg	    major=`expr $current - $age + 1`
3348a18ebfb2Smrg	  fi
3349a18ebfb2Smrg	  case $version_type in
3350a18ebfb2Smrg	    nonstopux) verstring_prefix=nonstopux ;;
3351a18ebfb2Smrg	    *)         verstring_prefix=sgi ;;
3352a18ebfb2Smrg	  esac
3353a18ebfb2Smrg	  verstring="$verstring_prefix$major.$revision"
335450806d53Smrg
3355a18ebfb2Smrg	  # Add in all the interfaces that we are compatible with.
3356a18ebfb2Smrg	  loop=$revision
3357a18ebfb2Smrg	  while test "$loop" -ne 0; do
3358a18ebfb2Smrg	    iface=`expr $revision - $loop`
3359a18ebfb2Smrg	    loop=`expr $loop - 1`
3360a18ebfb2Smrg	    verstring="$verstring_prefix$major.$iface:$verstring"
3361a18ebfb2Smrg	  done
336250806d53Smrg
3363a18ebfb2Smrg	  # Before this point, $major must not contain `.'.
3364a18ebfb2Smrg	  major=.$major
3365a18ebfb2Smrg	  versuffix="$major.$revision"
3366a18ebfb2Smrg	  ;;
336750806d53Smrg
3368a18ebfb2Smrg	linux)
3369a18ebfb2Smrg	  major=.`expr $current - $age`
3370a18ebfb2Smrg	  versuffix="$major.$age.$revision"
3371a18ebfb2Smrg	  ;;
337250806d53Smrg
3373a18ebfb2Smrg	osf)
3374a18ebfb2Smrg	  major=.`expr $current - $age`
3375a18ebfb2Smrg	  versuffix=".$current.$age.$revision"
3376a18ebfb2Smrg	  verstring="$current.$age.$revision"
337750806d53Smrg
3378a18ebfb2Smrg	  # Add in all the interfaces that we are compatible with.
3379a18ebfb2Smrg	  loop=$age
3380a18ebfb2Smrg	  while test "$loop" -ne 0; do
3381a18ebfb2Smrg	    iface=`expr $current - $loop`
3382a18ebfb2Smrg	    loop=`expr $loop - 1`
3383a18ebfb2Smrg	    verstring="$verstring:${iface}.0"
3384a18ebfb2Smrg	  done
338550806d53Smrg
3386a18ebfb2Smrg	  # Make executables depend on our current version.
3387a18ebfb2Smrg	  verstring="$verstring:${current}.0"
3388a18ebfb2Smrg	  ;;
338950806d53Smrg
3390a18ebfb2Smrg	sunos)
3391a18ebfb2Smrg	  major=".$current"
3392a18ebfb2Smrg	  versuffix=".$current.$revision"
3393a18ebfb2Smrg	  ;;
339450806d53Smrg
3395a18ebfb2Smrg	windows)
3396a18ebfb2Smrg	  # Use '-' rather than '.', since we only want one
3397a18ebfb2Smrg	  # extension on DOS 8.3 filesystems.
3398a18ebfb2Smrg	  major=`expr $current - $age`
3399a18ebfb2Smrg	  versuffix="-$major"
3400a18ebfb2Smrg	  ;;
340150806d53Smrg
3402a18ebfb2Smrg	*)
3403a18ebfb2Smrg	  $echo "$modename: unknown library version type \`$version_type'" 1>&2
3404a18ebfb2Smrg	  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
3405a18ebfb2Smrg	  exit $EXIT_FAILURE
3406a18ebfb2Smrg	  ;;
3407a18ebfb2Smrg	esac
340850806d53Smrg
3409a18ebfb2Smrg	# Clear the version info if we defaulted, and they specified a release.
3410a18ebfb2Smrg	if test -z "$vinfo" && test -n "$release"; then
3411a18ebfb2Smrg	  major=
3412a18ebfb2Smrg	  case $version_type in
3413a18ebfb2Smrg	  darwin)
3414a18ebfb2Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
3415a18ebfb2Smrg	    # problems, so we reset it completely
3416a18ebfb2Smrg	    verstring=
3417af1a9c97Smrg	    ;;
3418a18ebfb2Smrg	  *)
3419a18ebfb2Smrg	    verstring="0.0"
3420a18ebfb2Smrg	    ;;
3421a18ebfb2Smrg	  esac
3422a18ebfb2Smrg	  if test "$need_version" = no; then
3423a18ebfb2Smrg	    versuffix=
3424a18ebfb2Smrg	  else
3425a18ebfb2Smrg	    versuffix=".0.0"
3426a18ebfb2Smrg	  fi
3427a18ebfb2Smrg	fi
342850806d53Smrg
3429a18ebfb2Smrg	# Remove version info from name if versioning should be avoided
3430a18ebfb2Smrg	if test "$avoid_version" = yes && test "$need_version" = no; then
3431a18ebfb2Smrg	  major=
3432a18ebfb2Smrg	  versuffix=
3433a18ebfb2Smrg	  verstring=""
3434a18ebfb2Smrg	fi
343550806d53Smrg
3436a18ebfb2Smrg	# Check to see if the archive will have undefined symbols.
3437a18ebfb2Smrg	if test "$allow_undefined" = yes; then
3438a18ebfb2Smrg	  if test "$allow_undefined_flag" = unsupported; then
3439a18ebfb2Smrg	    $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
3440a18ebfb2Smrg	    build_libtool_libs=no
3441a18ebfb2Smrg	    build_old_libs=yes
3442a18ebfb2Smrg	  fi
3443a18ebfb2Smrg	else
3444a18ebfb2Smrg	  # Don't allow undefined symbols.
3445a18ebfb2Smrg	  allow_undefined_flag="$no_undefined_flag"
3446a18ebfb2Smrg	fi
3447a18ebfb2Smrg      fi
344850806d53Smrg
3449a18ebfb2Smrg      if test "$mode" != relink; then
3450a18ebfb2Smrg	# Remove our outputs, but don't remove object files since they
3451a18ebfb2Smrg	# may have been created when compiling PIC objects.
3452a18ebfb2Smrg	removelist=
3453a18ebfb2Smrg	tempremovelist=`$echo "$output_objdir/*"`
3454a18ebfb2Smrg	for p in $tempremovelist; do
3455a18ebfb2Smrg	  case $p in
3456a18ebfb2Smrg	    *.$objext)
3457a18ebfb2Smrg	       ;;
3458a18ebfb2Smrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
3459a18ebfb2Smrg	       if test "X$precious_files_regex" != "X"; then
3460a18ebfb2Smrg	         if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
3461a18ebfb2Smrg	         then
3462a18ebfb2Smrg		   continue
3463a18ebfb2Smrg		 fi
3464a18ebfb2Smrg	       fi
3465a18ebfb2Smrg	       removelist="$removelist $p"
3466a18ebfb2Smrg	       ;;
3467a18ebfb2Smrg	    *) ;;
3468a18ebfb2Smrg	  esac
3469a18ebfb2Smrg	done
3470a18ebfb2Smrg	if test -n "$removelist"; then
3471a18ebfb2Smrg	  $show "${rm}r $removelist"
3472a18ebfb2Smrg	  $run ${rm}r $removelist
3473a18ebfb2Smrg	fi
3474a18ebfb2Smrg      fi
347550806d53Smrg
3476a18ebfb2Smrg      # Now set the variables for building old libraries.
3477a18ebfb2Smrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
3478a18ebfb2Smrg	oldlibs="$oldlibs $output_objdir/$libname.$libext"
347950806d53Smrg
3480a18ebfb2Smrg	# Transform .lo files to .o files.
3481a18ebfb2Smrg	oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
3482a18ebfb2Smrg      fi
348350806d53Smrg
3484a18ebfb2Smrg      # Eliminate all temporary directories.
3485a18ebfb2Smrg      #for path in $notinst_path; do
3486a18ebfb2Smrg      #	lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
3487a18ebfb2Smrg      #	deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
3488a18ebfb2Smrg      #	dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
3489a18ebfb2Smrg      #done
349050806d53Smrg
3491a18ebfb2Smrg      if test -n "$xrpath"; then
3492a18ebfb2Smrg	# If the user specified any rpath flags, then add them.
3493a18ebfb2Smrg	temp_xrpath=
3494a18ebfb2Smrg	for libdir in $xrpath; do
3495a18ebfb2Smrg	  temp_xrpath="$temp_xrpath -R$libdir"
3496a18ebfb2Smrg	  case "$finalize_rpath " in
3497a18ebfb2Smrg	  *" $libdir "*) ;;
3498a18ebfb2Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
3499a18ebfb2Smrg	  esac
3500a18ebfb2Smrg	done
3501a18ebfb2Smrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
3502a18ebfb2Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
3503a18ebfb2Smrg	fi
3504a18ebfb2Smrg      fi
350550806d53Smrg
3506a18ebfb2Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
3507a18ebfb2Smrg      old_dlfiles="$dlfiles"
3508a18ebfb2Smrg      dlfiles=
3509a18ebfb2Smrg      for lib in $old_dlfiles; do
3510a18ebfb2Smrg	case " $dlprefiles $dlfiles " in
3511a18ebfb2Smrg	*" $lib "*) ;;
3512a18ebfb2Smrg	*) dlfiles="$dlfiles $lib" ;;
3513a18ebfb2Smrg	esac
3514a18ebfb2Smrg      done
351550806d53Smrg
3516a18ebfb2Smrg      # Make sure dlprefiles contains only unique files
3517a18ebfb2Smrg      old_dlprefiles="$dlprefiles"
3518a18ebfb2Smrg      dlprefiles=
3519a18ebfb2Smrg      for lib in $old_dlprefiles; do
3520a18ebfb2Smrg	case "$dlprefiles " in
3521a18ebfb2Smrg	*" $lib "*) ;;
3522a18ebfb2Smrg	*) dlprefiles="$dlprefiles $lib" ;;
3523a18ebfb2Smrg	esac
3524a18ebfb2Smrg      done
352550806d53Smrg
3526a18ebfb2Smrg      if test "$build_libtool_libs" = yes; then
3527a18ebfb2Smrg	if test -n "$rpath"; then
3528a18ebfb2Smrg	  case $host in
3529a18ebfb2Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
3530a18ebfb2Smrg	    # these systems don't actually have a c library (as such)!
3531a18ebfb2Smrg	    ;;
3532a18ebfb2Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
3533a18ebfb2Smrg	    # Rhapsody C library is in the System framework
3534a18ebfb2Smrg	    deplibs="$deplibs -framework System"
3535a18ebfb2Smrg	    ;;
3536a18ebfb2Smrg	  *-*-netbsd*)
3537a18ebfb2Smrg	    # Don't link with libc until the a.out ld.so is fixed.
3538a18ebfb2Smrg	    ;;
3539a18ebfb2Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
3540a18ebfb2Smrg	    # Do not include libc due to us having libc/libc_r.
3541a18ebfb2Smrg	    ;;
3542a18ebfb2Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
3543a18ebfb2Smrg	    # Causes problems with __ctype
3544a18ebfb2Smrg	    ;;
3545a18ebfb2Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
3546a18ebfb2Smrg	    # Compiler inserts libc in the correct place for threads to work
3547a18ebfb2Smrg	    ;;
3548a18ebfb2Smrg 	  *)
3549a18ebfb2Smrg	    # Add libc to deplibs on all other systems if necessary.
3550a18ebfb2Smrg	    if test "$build_libtool_need_lc" = "yes"; then
3551a18ebfb2Smrg	      deplibs="$deplibs -lc"
3552a18ebfb2Smrg	    fi
3553a18ebfb2Smrg	    ;;
3554a18ebfb2Smrg	  esac
3555a18ebfb2Smrg	fi
355650806d53Smrg
3557a18ebfb2Smrg	# Transform deplibs into only deplibs that can be linked in shared.
3558a18ebfb2Smrg	name_save=$name
3559a18ebfb2Smrg	libname_save=$libname
3560a18ebfb2Smrg	release_save=$release
3561a18ebfb2Smrg	versuffix_save=$versuffix
3562a18ebfb2Smrg	major_save=$major
3563a18ebfb2Smrg	# I'm not sure if I'm treating the release correctly.  I think
3564a18ebfb2Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
3565a18ebfb2Smrg	# add it in twice.  Is that correct?
3566a18ebfb2Smrg	release=""
3567a18ebfb2Smrg	versuffix=""
3568a18ebfb2Smrg	major=""
3569a18ebfb2Smrg	newdeplibs=
3570a18ebfb2Smrg	droppeddeps=no
3571a18ebfb2Smrg	case $deplibs_check_method in
3572a18ebfb2Smrg	pass_all)
3573a18ebfb2Smrg	  # Don't check for shared/static.  Everything works.
3574a18ebfb2Smrg	  # This might be a little naive.  We might want to check
3575a18ebfb2Smrg	  # whether the library exists or not.  But this is on
3576a18ebfb2Smrg	  # osf3 & osf4 and I'm not really sure... Just
3577a18ebfb2Smrg	  # implementing what was already the behavior.
3578a18ebfb2Smrg	  newdeplibs=$deplibs
3579a18ebfb2Smrg	  ;;
3580a18ebfb2Smrg	test_compile)
3581a18ebfb2Smrg	  # This code stresses the "libraries are programs" paradigm to its
3582a18ebfb2Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
3583a18ebfb2Smrg	  # against the deplibs as a proxy for the library.  Then we can check
3584a18ebfb2Smrg	  # whether they linked in statically or dynamically with ldd.
3585a18ebfb2Smrg	  $rm conftest.c
3586a18ebfb2Smrg	  cat > conftest.c <<EOF
3587a18ebfb2Smrg	  int main() { return 0; }
3588a18ebfb2SmrgEOF
3589a18ebfb2Smrg	  $rm conftest
3590a18ebfb2Smrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
3591a18ebfb2Smrg	    ldd_output=`ldd conftest`
3592a18ebfb2Smrg	    for i in $deplibs; do
3593a18ebfb2Smrg	      name=`expr $i : '-l\(.*\)'`
3594a18ebfb2Smrg	      # If $name is empty we are operating on a -L argument.
3595a18ebfb2Smrg              if test "$name" != "" && test "$name" != "0"; then
3596a18ebfb2Smrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3597a18ebfb2Smrg		  case " $predeps $postdeps " in
3598a18ebfb2Smrg		  *" $i "*)
3599a18ebfb2Smrg		    newdeplibs="$newdeplibs $i"
3600a18ebfb2Smrg		    i=""
3601a18ebfb2Smrg		    ;;
3602a18ebfb2Smrg		  esac
3603a18ebfb2Smrg	        fi
3604a18ebfb2Smrg		if test -n "$i" ; then
3605a18ebfb2Smrg		  libname=`eval \\$echo \"$libname_spec\"`
3606a18ebfb2Smrg		  deplib_matches=`eval \\$echo \"$library_names_spec\"`
3607a18ebfb2Smrg		  set dummy $deplib_matches
3608a18ebfb2Smrg		  deplib_match=$2
3609a18ebfb2Smrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
3610a18ebfb2Smrg		    newdeplibs="$newdeplibs $i"
3611a18ebfb2Smrg		  else
3612a18ebfb2Smrg		    droppeddeps=yes
3613a18ebfb2Smrg		    $echo
3614a18ebfb2Smrg		    $echo "*** Warning: dynamic linker does not accept needed library $i."
3615a18ebfb2Smrg		    $echo "*** I have the capability to make that library automatically link in when"
3616a18ebfb2Smrg		    $echo "*** you link to this library.  But I can only do this if you have a"
3617a18ebfb2Smrg		    $echo "*** shared version of the library, which I believe you do not have"
3618a18ebfb2Smrg		    $echo "*** because a test_compile did reveal that the linker did not use it for"
3619a18ebfb2Smrg		    $echo "*** its dynamic dependency list that programs get resolved with at runtime."
3620a18ebfb2Smrg		  fi
3621a18ebfb2Smrg		fi
3622a18ebfb2Smrg	      else
3623a18ebfb2Smrg		newdeplibs="$newdeplibs $i"
3624a18ebfb2Smrg	      fi
3625a18ebfb2Smrg	    done
3626a18ebfb2Smrg	  else
3627a18ebfb2Smrg	    # Error occurred in the first compile.  Let's try to salvage
3628a18ebfb2Smrg	    # the situation: Compile a separate program for each library.
3629a18ebfb2Smrg	    for i in $deplibs; do
3630a18ebfb2Smrg	      name=`expr $i : '-l\(.*\)'`
3631a18ebfb2Smrg	      # If $name is empty we are operating on a -L argument.
3632a18ebfb2Smrg              if test "$name" != "" && test "$name" != "0"; then
3633a18ebfb2Smrg		$rm conftest
3634a18ebfb2Smrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
3635a18ebfb2Smrg		  ldd_output=`ldd conftest`
3636a18ebfb2Smrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3637a18ebfb2Smrg		    case " $predeps $postdeps " in
3638a18ebfb2Smrg		    *" $i "*)
3639a18ebfb2Smrg		      newdeplibs="$newdeplibs $i"
3640a18ebfb2Smrg		      i=""
3641a18ebfb2Smrg		      ;;
3642a18ebfb2Smrg		    esac
3643a18ebfb2Smrg		  fi
3644a18ebfb2Smrg		  if test -n "$i" ; then
3645a18ebfb2Smrg		    libname=`eval \\$echo \"$libname_spec\"`
3646a18ebfb2Smrg		    deplib_matches=`eval \\$echo \"$library_names_spec\"`
3647a18ebfb2Smrg		    set dummy $deplib_matches
3648a18ebfb2Smrg		    deplib_match=$2
3649a18ebfb2Smrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
3650a18ebfb2Smrg		      newdeplibs="$newdeplibs $i"
3651a18ebfb2Smrg		    else
3652a18ebfb2Smrg		      droppeddeps=yes
3653a18ebfb2Smrg		      $echo
3654a18ebfb2Smrg		      $echo "*** Warning: dynamic linker does not accept needed library $i."
3655a18ebfb2Smrg		      $echo "*** I have the capability to make that library automatically link in when"
3656a18ebfb2Smrg		      $echo "*** you link to this library.  But I can only do this if you have a"
3657a18ebfb2Smrg		      $echo "*** shared version of the library, which you do not appear to have"
3658a18ebfb2Smrg		      $echo "*** because a test_compile did reveal that the linker did not use this one"
3659a18ebfb2Smrg		      $echo "*** as a dynamic dependency that programs can get resolved with at runtime."
3660a18ebfb2Smrg		    fi
3661a18ebfb2Smrg		  fi
3662a18ebfb2Smrg		else
3663a18ebfb2Smrg		  droppeddeps=yes
3664a18ebfb2Smrg		  $echo
3665a18ebfb2Smrg		  $echo "*** Warning!  Library $i is needed by this library but I was not able to"
3666a18ebfb2Smrg		  $echo "*** make it link in!  You will probably need to install it or some"
3667a18ebfb2Smrg		  $echo "*** library that it depends on before this library will be fully"
3668a18ebfb2Smrg		  $echo "*** functional.  Installing it before continuing would be even better."
3669a18ebfb2Smrg		fi
3670a18ebfb2Smrg	      else
3671a18ebfb2Smrg		newdeplibs="$newdeplibs $i"
3672a18ebfb2Smrg	      fi
3673a18ebfb2Smrg	    done
3674a18ebfb2Smrg	  fi
3675a18ebfb2Smrg	  ;;
3676a18ebfb2Smrg	file_magic*)
3677a18ebfb2Smrg	  set dummy $deplibs_check_method
3678a18ebfb2Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
3679a18ebfb2Smrg	  for a_deplib in $deplibs; do
3680a18ebfb2Smrg	    name=`expr $a_deplib : '-l\(.*\)'`
3681a18ebfb2Smrg	    # If $name is empty we are operating on a -L argument.
3682a18ebfb2Smrg            if test "$name" != "" && test  "$name" != "0"; then
3683a18ebfb2Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3684a18ebfb2Smrg		case " $predeps $postdeps " in
3685a18ebfb2Smrg		*" $a_deplib "*)
3686a18ebfb2Smrg		  newdeplibs="$newdeplibs $a_deplib"
3687a18ebfb2Smrg		  a_deplib=""
3688a18ebfb2Smrg		  ;;
3689a18ebfb2Smrg		esac
3690a18ebfb2Smrg	      fi
3691a18ebfb2Smrg	      if test -n "$a_deplib" ; then
3692a18ebfb2Smrg		libname=`eval \\$echo \"$libname_spec\"`
3693a18ebfb2Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
3694a18ebfb2Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
3695a18ebfb2Smrg		  for potent_lib in $potential_libs; do
3696a18ebfb2Smrg		      # Follow soft links.
3697a18ebfb2Smrg		      if ls -lLd "$potent_lib" 2>/dev/null \
3698a18ebfb2Smrg			 | grep " -> " >/dev/null; then
3699a18ebfb2Smrg			continue
3700a18ebfb2Smrg		      fi
3701a18ebfb2Smrg		      # The statement above tries to avoid entering an
3702a18ebfb2Smrg		      # endless loop below, in case of cyclic links.
3703a18ebfb2Smrg		      # We might still enter an endless loop, since a link
3704a18ebfb2Smrg		      # loop can be closed while we follow links,
3705a18ebfb2Smrg		      # but so what?
3706a18ebfb2Smrg		      potlib="$potent_lib"
3707a18ebfb2Smrg		      while test -h "$potlib" 2>/dev/null; do
3708a18ebfb2Smrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
3709a18ebfb2Smrg			case $potliblink in
3710a18ebfb2Smrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
3711a18ebfb2Smrg			*) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
3712a18ebfb2Smrg			esac
3713a18ebfb2Smrg		      done
3714a18ebfb2Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
3715a18ebfb2Smrg			 | ${SED} 10q \
3716a18ebfb2Smrg			 | $EGREP "$file_magic_regex" > /dev/null; then
3717a18ebfb2Smrg			newdeplibs="$newdeplibs $a_deplib"
3718a18ebfb2Smrg			a_deplib=""
3719a18ebfb2Smrg			break 2
3720a18ebfb2Smrg		      fi
3721a18ebfb2Smrg		  done
3722a18ebfb2Smrg		done
3723a18ebfb2Smrg	      fi
3724a18ebfb2Smrg	      if test -n "$a_deplib" ; then
3725a18ebfb2Smrg		droppeddeps=yes
3726a18ebfb2Smrg		$echo
3727a18ebfb2Smrg		$echo "*** Warning: linker path does not have real file for library $a_deplib."
3728a18ebfb2Smrg		$echo "*** I have the capability to make that library automatically link in when"
3729a18ebfb2Smrg		$echo "*** you link to this library.  But I can only do this if you have a"
3730a18ebfb2Smrg		$echo "*** shared version of the library, which you do not appear to have"
3731a18ebfb2Smrg		$echo "*** because I did check the linker path looking for a file starting"
3732a18ebfb2Smrg		if test -z "$potlib" ; then
3733a18ebfb2Smrg		  $echo "*** with $libname but no candidates were found. (...for file magic test)"
3734a18ebfb2Smrg		else
3735a18ebfb2Smrg		  $echo "*** with $libname and none of the candidates passed a file format test"
3736a18ebfb2Smrg		  $echo "*** using a file magic. Last file checked: $potlib"
3737a18ebfb2Smrg		fi
3738a18ebfb2Smrg	      fi
3739a18ebfb2Smrg	    else
3740a18ebfb2Smrg	      # Add a -L argument.
3741a18ebfb2Smrg	      newdeplibs="$newdeplibs $a_deplib"
3742a18ebfb2Smrg	    fi
3743a18ebfb2Smrg	  done # Gone through all deplibs.
3744a18ebfb2Smrg	  ;;
3745a18ebfb2Smrg	match_pattern*)
3746a18ebfb2Smrg	  set dummy $deplibs_check_method
3747a18ebfb2Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
3748a18ebfb2Smrg	  for a_deplib in $deplibs; do
3749a18ebfb2Smrg	    name=`expr $a_deplib : '-l\(.*\)'`
3750a18ebfb2Smrg	    # If $name is empty we are operating on a -L argument.
3751a18ebfb2Smrg	    if test -n "$name" && test "$name" != "0"; then
3752a18ebfb2Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3753a18ebfb2Smrg		case " $predeps $postdeps " in
3754a18ebfb2Smrg		*" $a_deplib "*)
3755a18ebfb2Smrg		  newdeplibs="$newdeplibs $a_deplib"
3756a18ebfb2Smrg		  a_deplib=""
3757a18ebfb2Smrg		  ;;
3758a18ebfb2Smrg		esac
3759a18ebfb2Smrg	      fi
3760a18ebfb2Smrg	      if test -n "$a_deplib" ; then
3761a18ebfb2Smrg		libname=`eval \\$echo \"$libname_spec\"`
3762a18ebfb2Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
3763a18ebfb2Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
3764a18ebfb2Smrg		  for potent_lib in $potential_libs; do
3765a18ebfb2Smrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
3766a18ebfb2Smrg		    if eval $echo \"$potent_lib\" 2>/dev/null \
3767a18ebfb2Smrg		        | ${SED} 10q \
3768a18ebfb2Smrg		        | $EGREP "$match_pattern_regex" > /dev/null; then
3769a18ebfb2Smrg		      newdeplibs="$newdeplibs $a_deplib"
3770a18ebfb2Smrg		      a_deplib=""
3771a18ebfb2Smrg		      break 2
3772a18ebfb2Smrg		    fi
3773a18ebfb2Smrg		  done
3774a18ebfb2Smrg		done
3775a18ebfb2Smrg	      fi
3776a18ebfb2Smrg	      if test -n "$a_deplib" ; then
3777a18ebfb2Smrg		droppeddeps=yes
3778a18ebfb2Smrg		$echo
3779a18ebfb2Smrg		$echo "*** Warning: linker path does not have real file for library $a_deplib."
3780a18ebfb2Smrg		$echo "*** I have the capability to make that library automatically link in when"
3781a18ebfb2Smrg		$echo "*** you link to this library.  But I can only do this if you have a"
3782a18ebfb2Smrg		$echo "*** shared version of the library, which you do not appear to have"
3783a18ebfb2Smrg		$echo "*** because I did check the linker path looking for a file starting"
3784a18ebfb2Smrg		if test -z "$potlib" ; then
3785a18ebfb2Smrg		  $echo "*** with $libname but no candidates were found. (...for regex pattern test)"
3786a18ebfb2Smrg		else
3787a18ebfb2Smrg		  $echo "*** with $libname and none of the candidates passed a file format test"
3788a18ebfb2Smrg		  $echo "*** using a regex pattern. Last file checked: $potlib"
3789a18ebfb2Smrg		fi
3790a18ebfb2Smrg	      fi
3791a18ebfb2Smrg	    else
3792a18ebfb2Smrg	      # Add a -L argument.
3793a18ebfb2Smrg	      newdeplibs="$newdeplibs $a_deplib"
3794a18ebfb2Smrg	    fi
3795a18ebfb2Smrg	  done # Gone through all deplibs.
3796a18ebfb2Smrg	  ;;
3797a18ebfb2Smrg	none | unknown | *)
3798a18ebfb2Smrg	  newdeplibs=""
3799a18ebfb2Smrg	  tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
3800a18ebfb2Smrg	    -e 's/ -[LR][^ ]*//g'`
3801a18ebfb2Smrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3802a18ebfb2Smrg	    for i in $predeps $postdeps ; do
3803a18ebfb2Smrg	      # can't use Xsed below, because $i might contain '/'
3804a18ebfb2Smrg	      tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"`
3805a18ebfb2Smrg	    done
3806a18ebfb2Smrg	  fi
3807a18ebfb2Smrg	  if $echo "X $tmp_deplibs" | $Xsed -e 's/[ 	]//g' \
3808a18ebfb2Smrg	    | grep . >/dev/null; then
3809a18ebfb2Smrg	    $echo
3810a18ebfb2Smrg	    if test "X$deplibs_check_method" = "Xnone"; then
3811a18ebfb2Smrg	      $echo "*** Warning: inter-library dependencies are not supported in this platform."
3812a18ebfb2Smrg	    else
3813a18ebfb2Smrg	      $echo "*** Warning: inter-library dependencies are not known to be supported."
3814a18ebfb2Smrg	    fi
3815a18ebfb2Smrg	    $echo "*** All declared inter-library dependencies are being dropped."
3816a18ebfb2Smrg	    droppeddeps=yes
3817a18ebfb2Smrg	  fi
3818a18ebfb2Smrg	  ;;
3819a18ebfb2Smrg	esac
3820a18ebfb2Smrg	versuffix=$versuffix_save
3821a18ebfb2Smrg	major=$major_save
3822a18ebfb2Smrg	release=$release_save
3823a18ebfb2Smrg	libname=$libname_save
3824a18ebfb2Smrg	name=$name_save
382550806d53Smrg
3826a18ebfb2Smrg	case $host in
3827a18ebfb2Smrg	*-*-rhapsody* | *-*-darwin1.[012])
3828a18ebfb2Smrg	  # On Rhapsody replace the C library is the System framework
3829a18ebfb2Smrg	  newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'`
3830a18ebfb2Smrg	  ;;
3831a18ebfb2Smrg	esac
383250806d53Smrg
3833a18ebfb2Smrg	if test "$droppeddeps" = yes; then
3834a18ebfb2Smrg	  if test "$module" = yes; then
3835a18ebfb2Smrg	    $echo
3836a18ebfb2Smrg	    $echo "*** Warning: libtool could not satisfy all declared inter-library"
3837a18ebfb2Smrg	    $echo "*** dependencies of module $libname.  Therefore, libtool will create"
3838a18ebfb2Smrg	    $echo "*** a static module, that should work as long as the dlopening"
3839a18ebfb2Smrg	    $echo "*** application is linked with the -dlopen flag."
3840a18ebfb2Smrg	    if test -z "$global_symbol_pipe"; then
3841a18ebfb2Smrg	      $echo
3842a18ebfb2Smrg	      $echo "*** However, this would only work if libtool was able to extract symbol"
3843a18ebfb2Smrg	      $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
3844a18ebfb2Smrg	      $echo "*** not find such a program.  So, this module is probably useless."
3845a18ebfb2Smrg	      $echo "*** \`nm' from GNU binutils and a full rebuild may help."
3846a18ebfb2Smrg	    fi
3847a18ebfb2Smrg	    if test "$build_old_libs" = no; then
3848a18ebfb2Smrg	      oldlibs="$output_objdir/$libname.$libext"
3849a18ebfb2Smrg	      build_libtool_libs=module
3850a18ebfb2Smrg	      build_old_libs=yes
3851a18ebfb2Smrg	    else
3852a18ebfb2Smrg	      build_libtool_libs=no
3853a18ebfb2Smrg	    fi
3854a18ebfb2Smrg	  else
3855a18ebfb2Smrg	    $echo "*** The inter-library dependencies that have been dropped here will be"
3856a18ebfb2Smrg	    $echo "*** automatically added whenever a program is linked with this library"
3857a18ebfb2Smrg	    $echo "*** or is declared to -dlopen it."
385850806d53Smrg
3859a18ebfb2Smrg	    if test "$allow_undefined" = no; then
3860a18ebfb2Smrg	      $echo
3861a18ebfb2Smrg	      $echo "*** Since this library must not contain undefined symbols,"
3862a18ebfb2Smrg	      $echo "*** because either the platform does not support them or"
3863a18ebfb2Smrg	      $echo "*** it was explicitly requested with -no-undefined,"
3864a18ebfb2Smrg	      $echo "*** libtool will only create a static version of it."
3865a18ebfb2Smrg	      if test "$build_old_libs" = no; then
3866a18ebfb2Smrg		oldlibs="$output_objdir/$libname.$libext"
3867a18ebfb2Smrg		build_libtool_libs=module
3868a18ebfb2Smrg		build_old_libs=yes
3869a18ebfb2Smrg	      else
3870a18ebfb2Smrg		build_libtool_libs=no
3871a18ebfb2Smrg	      fi
3872a18ebfb2Smrg	    fi
3873a18ebfb2Smrg	  fi
3874a18ebfb2Smrg	fi
3875a18ebfb2Smrg	# Done checking deplibs!
3876a18ebfb2Smrg	deplibs=$newdeplibs
3877a18ebfb2Smrg      fi
387850806d53Smrg
387950806d53Smrg
3880a18ebfb2Smrg      # move library search paths that coincide with paths to not yet
3881a18ebfb2Smrg      # installed libraries to the beginning of the library search list
3882a18ebfb2Smrg      new_libs=
3883a18ebfb2Smrg      for path in $notinst_path; do
3884a18ebfb2Smrg	case " $new_libs " in
3885a18ebfb2Smrg	*" -L$path/$objdir "*) ;;
3886a18ebfb2Smrg	*)
3887a18ebfb2Smrg	  case " $deplibs " in
3888a18ebfb2Smrg	  *" -L$path/$objdir "*)
3889a18ebfb2Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
3890a18ebfb2Smrg	  esac
3891a18ebfb2Smrg	  ;;
3892a18ebfb2Smrg	esac
3893a18ebfb2Smrg      done
3894a18ebfb2Smrg      for deplib in $deplibs; do
3895a18ebfb2Smrg	case $deplib in
3896a18ebfb2Smrg	-L*)
3897a18ebfb2Smrg	  case " $new_libs " in
3898a18ebfb2Smrg	  *" $deplib "*) ;;
3899a18ebfb2Smrg	  *) new_libs="$new_libs $deplib" ;;
3900a18ebfb2Smrg	  esac
3901a18ebfb2Smrg	  ;;
3902a18ebfb2Smrg	*) new_libs="$new_libs $deplib" ;;
3903a18ebfb2Smrg	esac
3904a18ebfb2Smrg      done
3905a18ebfb2Smrg      deplibs="$new_libs"
390650806d53Smrg
390750806d53Smrg
3908a18ebfb2Smrg      # All the library-specific variables (install_libdir is set above).
3909a18ebfb2Smrg      library_names=
3910a18ebfb2Smrg      old_library=
3911a18ebfb2Smrg      dlname=
391250806d53Smrg
3913a18ebfb2Smrg      # Test again, we may have decided not to build it any more
3914a18ebfb2Smrg      if test "$build_libtool_libs" = yes; then
3915a18ebfb2Smrg	if test "$hardcode_into_libs" = yes; then
3916a18ebfb2Smrg	  # Hardcode the library paths
3917a18ebfb2Smrg	  hardcode_libdirs=
3918a18ebfb2Smrg	  dep_rpath=
3919a18ebfb2Smrg	  rpath="$finalize_rpath"
3920a18ebfb2Smrg	  test "$mode" != relink && rpath="$compile_rpath$rpath"
3921a18ebfb2Smrg	  for libdir in $rpath; do
3922a18ebfb2Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
3923a18ebfb2Smrg	      if test -n "$hardcode_libdir_separator"; then
3924a18ebfb2Smrg		if test -z "$hardcode_libdirs"; then
3925a18ebfb2Smrg		  hardcode_libdirs="$libdir"
3926a18ebfb2Smrg		else
3927a18ebfb2Smrg		  # Just accumulate the unique libdirs.
3928a18ebfb2Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
3929a18ebfb2Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
3930a18ebfb2Smrg		    ;;
3931a18ebfb2Smrg		  *)
3932a18ebfb2Smrg		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
3933a18ebfb2Smrg		    ;;
3934a18ebfb2Smrg		  esac
3935a18ebfb2Smrg		fi
3936a18ebfb2Smrg	      else
3937a18ebfb2Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
3938a18ebfb2Smrg		dep_rpath="$dep_rpath $flag"
3939a18ebfb2Smrg	      fi
3940a18ebfb2Smrg	    elif test -n "$runpath_var"; then
3941a18ebfb2Smrg	      case "$perm_rpath " in
3942a18ebfb2Smrg	      *" $libdir "*) ;;
3943a18ebfb2Smrg	      *) perm_rpath="$perm_rpath $libdir" ;;
3944a18ebfb2Smrg	      esac
3945a18ebfb2Smrg	    fi
3946a18ebfb2Smrg	  done
3947a18ebfb2Smrg	  # Substitute the hardcoded libdirs into the rpath.
3948a18ebfb2Smrg	  if test -n "$hardcode_libdir_separator" &&
3949a18ebfb2Smrg	     test -n "$hardcode_libdirs"; then
3950a18ebfb2Smrg	    libdir="$hardcode_libdirs"
3951a18ebfb2Smrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
3952a18ebfb2Smrg	      case $archive_cmds in
3953a18ebfb2Smrg	      *\$LD*) eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" ;;
3954a18ebfb2Smrg	      *)      eval dep_rpath=\"$hardcode_libdir_flag_spec\" ;;
3955a18ebfb2Smrg	      esac
3956a18ebfb2Smrg	    else
3957a18ebfb2Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
3958a18ebfb2Smrg	    fi
3959a18ebfb2Smrg	  fi
3960a18ebfb2Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
3961a18ebfb2Smrg	    # We should set the runpath_var.
3962a18ebfb2Smrg	    rpath=
3963a18ebfb2Smrg	    for dir in $perm_rpath; do
3964a18ebfb2Smrg	      rpath="$rpath$dir:"
3965a18ebfb2Smrg	    done
3966a18ebfb2Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
3967a18ebfb2Smrg	  fi
3968a18ebfb2Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
3969a18ebfb2Smrg	fi
397050806d53Smrg
3971a18ebfb2Smrg	shlibpath="$finalize_shlibpath"
3972a18ebfb2Smrg	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
3973a18ebfb2Smrg	if test -n "$shlibpath"; then
3974a18ebfb2Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
3975a18ebfb2Smrg	fi
397650806d53Smrg
3977a18ebfb2Smrg	# Get the real and link names of the library.
3978a18ebfb2Smrg	eval shared_ext=\"$shrext_cmds\"
3979a18ebfb2Smrg	eval library_names=\"$library_names_spec\"
3980a18ebfb2Smrg	set dummy $library_names
3981a18ebfb2Smrg	realname="$2"
3982a18ebfb2Smrg	shift; shift
398350806d53Smrg
3984a18ebfb2Smrg	if test -n "$soname_spec"; then
3985a18ebfb2Smrg	  eval soname=\"$soname_spec\"
3986a18ebfb2Smrg	else
3987a18ebfb2Smrg	  soname="$realname"
3988a18ebfb2Smrg	fi
3989a18ebfb2Smrg	if test -z "$dlname"; then
3990a18ebfb2Smrg	  dlname=$soname
3991a18ebfb2Smrg	fi
399250806d53Smrg
3993a18ebfb2Smrg	lib="$output_objdir/$realname"
3994a18ebfb2Smrg	linknames=
3995a18ebfb2Smrg	for link
3996a18ebfb2Smrg	do
3997a18ebfb2Smrg	  linknames="$linknames $link"
3998a18ebfb2Smrg	done
399950806d53Smrg
4000a18ebfb2Smrg	# Use standard objects if they are pic
4001a18ebfb2Smrg	test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
400250806d53Smrg
4003a18ebfb2Smrg	# Prepare the list of exported symbols
4004a18ebfb2Smrg	if test -z "$export_symbols"; then
4005a18ebfb2Smrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
4006a18ebfb2Smrg	    $show "generating symbol list for \`$libname.la'"
4007a18ebfb2Smrg	    export_symbols="$output_objdir/$libname.exp"
4008a18ebfb2Smrg	    $run $rm $export_symbols
4009a18ebfb2Smrg	    cmds=$export_symbols_cmds
4010a18ebfb2Smrg	    save_ifs="$IFS"; IFS='~'
4011a18ebfb2Smrg	    for cmd in $cmds; do
4012a18ebfb2Smrg	      IFS="$save_ifs"
4013a18ebfb2Smrg	      eval cmd=\"$cmd\"
4014a18ebfb2Smrg	      if len=`expr "X$cmd" : ".*"` &&
4015a18ebfb2Smrg	       test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
4016a18ebfb2Smrg	        $show "$cmd"
4017a18ebfb2Smrg	        $run eval "$cmd" || exit $?
4018a18ebfb2Smrg	        skipped_export=false
4019a18ebfb2Smrg	      else
4020a18ebfb2Smrg	        # The command line is too long to execute in one step.
4021a18ebfb2Smrg	        $show "using reloadable object file for export list..."
4022a18ebfb2Smrg	        skipped_export=:
4023a18ebfb2Smrg		# Break out early, otherwise skipped_export may be
4024a18ebfb2Smrg		# set to false by a later but shorter cmd.
4025a18ebfb2Smrg		break
4026a18ebfb2Smrg	      fi
4027a18ebfb2Smrg	    done
4028a18ebfb2Smrg	    IFS="$save_ifs"
4029a18ebfb2Smrg	    if test -n "$export_symbols_regex"; then
4030a18ebfb2Smrg	      $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
4031a18ebfb2Smrg	      $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
4032a18ebfb2Smrg	      $show "$mv \"${export_symbols}T\" \"$export_symbols\""
4033a18ebfb2Smrg	      $run eval '$mv "${export_symbols}T" "$export_symbols"'
4034a18ebfb2Smrg	    fi
4035a18ebfb2Smrg	  fi
4036a18ebfb2Smrg	fi
403750806d53Smrg
4038a18ebfb2Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
4039a18ebfb2Smrg	  $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
4040a18ebfb2Smrg	fi
404150806d53Smrg
4042a18ebfb2Smrg	tmp_deplibs=
4043a18ebfb2Smrg	for test_deplib in $deplibs; do
4044a18ebfb2Smrg		case " $convenience " in
4045a18ebfb2Smrg		*" $test_deplib "*) ;;
4046a18ebfb2Smrg		*)
4047a18ebfb2Smrg			tmp_deplibs="$tmp_deplibs $test_deplib"
4048a18ebfb2Smrg			;;
4049a18ebfb2Smrg		esac
4050a18ebfb2Smrg	done
4051a18ebfb2Smrg	deplibs="$tmp_deplibs"
405250806d53Smrg
4053a18ebfb2Smrg	if test -n "$convenience"; then
4054a18ebfb2Smrg	  if test -n "$whole_archive_flag_spec"; then
4055a18ebfb2Smrg	    save_libobjs=$libobjs
4056a18ebfb2Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
4057a18ebfb2Smrg	  else
4058a18ebfb2Smrg	    gentop="$output_objdir/${outputname}x"
4059a18ebfb2Smrg	    generated="$generated $gentop"
406050806d53Smrg
4061a18ebfb2Smrg	    func_extract_archives $gentop $convenience
4062a18ebfb2Smrg	    libobjs="$libobjs $func_extract_archives_result"
4063a18ebfb2Smrg	  fi
4064a18ebfb2Smrg	fi
4065a18ebfb2Smrg	
4066a18ebfb2Smrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
4067a18ebfb2Smrg	  eval flag=\"$thread_safe_flag_spec\"
4068a18ebfb2Smrg	  linker_flags="$linker_flags $flag"
4069a18ebfb2Smrg	fi
407050806d53Smrg
4071a18ebfb2Smrg	# Make a backup of the uninstalled library when relinking
4072a18ebfb2Smrg	if test "$mode" = relink; then
4073a18ebfb2Smrg	  $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $?
4074a18ebfb2Smrg	fi
407550806d53Smrg
4076a18ebfb2Smrg	# Do each of the archive commands.
4077a18ebfb2Smrg	if test "$module" = yes && test -n "$module_cmds" ; then
4078a18ebfb2Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
4079a18ebfb2Smrg	    eval test_cmds=\"$module_expsym_cmds\"
4080a18ebfb2Smrg	    cmds=$module_expsym_cmds
4081a18ebfb2Smrg	  else
4082a18ebfb2Smrg	    eval test_cmds=\"$module_cmds\"
4083a18ebfb2Smrg	    cmds=$module_cmds
4084a18ebfb2Smrg	  fi
4085a18ebfb2Smrg	else
4086a18ebfb2Smrg	if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
4087a18ebfb2Smrg	  eval test_cmds=\"$archive_expsym_cmds\"
4088a18ebfb2Smrg	  cmds=$archive_expsym_cmds
4089a18ebfb2Smrg	else
4090a18ebfb2Smrg	  eval test_cmds=\"$archive_cmds\"
4091a18ebfb2Smrg	  cmds=$archive_cmds
4092a18ebfb2Smrg	  fi
4093a18ebfb2Smrg	fi
409450806d53Smrg
4095a18ebfb2Smrg	if test "X$skipped_export" != "X:" &&
4096a18ebfb2Smrg	   len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
4097a18ebfb2Smrg	   test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
4098a18ebfb2Smrg	  :
4099a18ebfb2Smrg	else
4100a18ebfb2Smrg	  # The command line is too long to link in one step, link piecewise.
4101a18ebfb2Smrg	  $echo "creating reloadable object files..."
410250806d53Smrg
4103a18ebfb2Smrg	  # Save the value of $output and $libobjs because we want to
4104a18ebfb2Smrg	  # use them later.  If we have whole_archive_flag_spec, we
4105a18ebfb2Smrg	  # want to use save_libobjs as it was before
4106a18ebfb2Smrg	  # whole_archive_flag_spec was expanded, because we can't
4107a18ebfb2Smrg	  # assume the linker understands whole_archive_flag_spec.
4108a18ebfb2Smrg	  # This may have to be revisited, in case too many
4109a18ebfb2Smrg	  # convenience libraries get linked in and end up exceeding
4110a18ebfb2Smrg	  # the spec.
4111a18ebfb2Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
4112a18ebfb2Smrg	    save_libobjs=$libobjs
4113a18ebfb2Smrg	  fi
4114a18ebfb2Smrg	  save_output=$output
4115a18ebfb2Smrg	  output_la=`$echo "X$output" | $Xsed -e "$basename"`
411650806d53Smrg
4117a18ebfb2Smrg	  # Clear the reloadable object creation command queue and
4118a18ebfb2Smrg	  # initialize k to one.
4119a18ebfb2Smrg	  test_cmds=
4120a18ebfb2Smrg	  concat_cmds=
4121a18ebfb2Smrg	  objlist=
4122a18ebfb2Smrg	  delfiles=
4123a18ebfb2Smrg	  last_robj=
4124a18ebfb2Smrg	  k=1
4125a18ebfb2Smrg	  output=$output_objdir/$output_la-${k}.$objext
4126a18ebfb2Smrg	  # Loop over the list of objects to be linked.
4127a18ebfb2Smrg	  for obj in $save_libobjs
4128a18ebfb2Smrg	  do
4129a18ebfb2Smrg	    eval test_cmds=\"$reload_cmds $objlist $last_robj\"
4130a18ebfb2Smrg	    if test "X$objlist" = X ||
4131a18ebfb2Smrg	       { len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
4132a18ebfb2Smrg		 test "$len" -le "$max_cmd_len"; }; then
4133a18ebfb2Smrg	      objlist="$objlist $obj"
4134a18ebfb2Smrg	    else
4135a18ebfb2Smrg	      # The command $test_cmds is almost too long, add a
4136a18ebfb2Smrg	      # command to the queue.
4137a18ebfb2Smrg	      if test "$k" -eq 1 ; then
4138a18ebfb2Smrg		# The first file doesn't have a previous command to add.
4139a18ebfb2Smrg		eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
4140a18ebfb2Smrg	      else
4141a18ebfb2Smrg		# All subsequent reloadable object files will link in
4142a18ebfb2Smrg		# the last one created.
4143a18ebfb2Smrg		eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
4144a18ebfb2Smrg	      fi
4145a18ebfb2Smrg	      last_robj=$output_objdir/$output_la-${k}.$objext
4146a18ebfb2Smrg	      k=`expr $k + 1`
4147a18ebfb2Smrg	      output=$output_objdir/$output_la-${k}.$objext
4148a18ebfb2Smrg	      objlist=$obj
4149a18ebfb2Smrg	      len=1
4150a18ebfb2Smrg	    fi
4151a18ebfb2Smrg	  done
4152a18ebfb2Smrg	  # Handle the remaining objects by creating one last
4153a18ebfb2Smrg	  # reloadable object file.  All subsequent reloadable object
4154a18ebfb2Smrg	  # files will link in the last one created.
4155a18ebfb2Smrg	  test -z "$concat_cmds" || concat_cmds=$concat_cmds~
4156a18ebfb2Smrg	  eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
4157a18ebfb2Smrg
4158a18ebfb2Smrg	  if ${skipped_export-false}; then
4159a18ebfb2Smrg	    $show "generating symbol list for \`$libname.la'"
4160a18ebfb2Smrg	    export_symbols="$output_objdir/$libname.exp"
4161a18ebfb2Smrg	    $run $rm $export_symbols
4162a18ebfb2Smrg	    libobjs=$output
4163a18ebfb2Smrg	    # Append the command to create the export file.
4164a18ebfb2Smrg	    eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
4165a18ebfb2Smrg          fi
4166a18ebfb2Smrg
4167a18ebfb2Smrg	  # Set up a command to remove the reloadable object files
4168a18ebfb2Smrg	  # after they are used.
4169a18ebfb2Smrg	  i=0
4170a18ebfb2Smrg	  while test "$i" -lt "$k"
4171a18ebfb2Smrg	  do
4172a18ebfb2Smrg	    i=`expr $i + 1`
4173a18ebfb2Smrg	    delfiles="$delfiles $output_objdir/$output_la-${i}.$objext"
4174a18ebfb2Smrg	  done
417550806d53Smrg
4176a18ebfb2Smrg	  $echo "creating a temporary reloadable object file: $output"
417750806d53Smrg
4178a18ebfb2Smrg	  # Loop through the commands generated above and execute them.
4179a18ebfb2Smrg	  save_ifs="$IFS"; IFS='~'
4180a18ebfb2Smrg	  for cmd in $concat_cmds; do
4181a18ebfb2Smrg	    IFS="$save_ifs"
4182a18ebfb2Smrg	    $show "$cmd"
4183a18ebfb2Smrg	    $run eval "$cmd" || exit $?
4184a18ebfb2Smrg	  done
4185a18ebfb2Smrg	  IFS="$save_ifs"
418650806d53Smrg
4187a18ebfb2Smrg	  libobjs=$output
4188a18ebfb2Smrg	  # Restore the value of output.
4189a18ebfb2Smrg	  output=$save_output
419050806d53Smrg
4191a18ebfb2Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
4192a18ebfb2Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
4193a18ebfb2Smrg	  fi
4194a18ebfb2Smrg	  # Expand the library linking commands again to reset the
4195a18ebfb2Smrg	  # value of $libobjs for piecewise linking.
419650806d53Smrg
4197a18ebfb2Smrg	  # Do each of the archive commands.
4198a18ebfb2Smrg	  if test "$module" = yes && test -n "$module_cmds" ; then
4199a18ebfb2Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
4200a18ebfb2Smrg	      cmds=$module_expsym_cmds
4201a18ebfb2Smrg	    else
4202a18ebfb2Smrg	      cmds=$module_cmds
4203a18ebfb2Smrg	    fi
4204a18ebfb2Smrg	  else
4205a18ebfb2Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
4206a18ebfb2Smrg	    cmds=$archive_expsym_cmds
4207a18ebfb2Smrg	  else
4208a18ebfb2Smrg	    cmds=$archive_cmds
4209a18ebfb2Smrg	    fi
4210a18ebfb2Smrg	  fi
421150806d53Smrg
4212a18ebfb2Smrg	  # Append the command to remove the reloadable object files
4213a18ebfb2Smrg	  # to the just-reset $cmds.
4214a18ebfb2Smrg	  eval cmds=\"\$cmds~\$rm $delfiles\"
4215a18ebfb2Smrg	fi
4216a18ebfb2Smrg	save_ifs="$IFS"; IFS='~'
4217a18ebfb2Smrg	for cmd in $cmds; do
4218a18ebfb2Smrg	  IFS="$save_ifs"
4219a18ebfb2Smrg	  eval cmd=\"$cmd\"
4220a18ebfb2Smrg	  $show "$cmd"
4221a18ebfb2Smrg	  $run eval "$cmd" || {
4222a18ebfb2Smrg	    lt_exit=$?
422350806d53Smrg
4224a18ebfb2Smrg	    # Restore the uninstalled library and exit
4225a18ebfb2Smrg	    if test "$mode" = relink; then
4226a18ebfb2Smrg	      $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
4227a18ebfb2Smrg	    fi
422850806d53Smrg
4229a18ebfb2Smrg	    exit $lt_exit
4230a18ebfb2Smrg	  }
4231a18ebfb2Smrg	done
4232a18ebfb2Smrg	IFS="$save_ifs"
4233a18ebfb2Smrg
4234a18ebfb2Smrg	# Restore the uninstalled library and exit
4235a18ebfb2Smrg	if test "$mode" = relink; then
4236a18ebfb2Smrg	  $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
4237a18ebfb2Smrg
4238a18ebfb2Smrg	  if test -n "$convenience"; then
4239a18ebfb2Smrg	    if test -z "$whole_archive_flag_spec"; then
4240a18ebfb2Smrg	      $show "${rm}r $gentop"
4241a18ebfb2Smrg	      $run ${rm}r "$gentop"
4242a18ebfb2Smrg	    fi
4243a18ebfb2Smrg	  fi
4244a18ebfb2Smrg
4245a18ebfb2Smrg	  exit $EXIT_SUCCESS
4246a18ebfb2Smrg	fi
4247a18ebfb2Smrg
4248a18ebfb2Smrg	# Create links to the real library.
4249a18ebfb2Smrg	for linkname in $linknames; do
4250a18ebfb2Smrg	  if test "$realname" != "$linkname"; then
4251a18ebfb2Smrg	    $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
4252a18ebfb2Smrg	    $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
4253a18ebfb2Smrg	  fi
4254a18ebfb2Smrg	done
4255a18ebfb2Smrg
4256a18ebfb2Smrg	# If -module or -export-dynamic was specified, set the dlname.
4257a18ebfb2Smrg	if test "$module" = yes || test "$export_dynamic" = yes; then
4258a18ebfb2Smrg	  # On all known operating systems, these are identical.
4259a18ebfb2Smrg	  dlname="$soname"
4260a18ebfb2Smrg	fi
4261a18ebfb2Smrg      fi
4262af1a9c97Smrg      ;;
426350806d53Smrg
4264a18ebfb2Smrg    obj)
4265a18ebfb2Smrg      case " $deplibs" in
4266a18ebfb2Smrg      *\ -l* | *\ -L*)
4267a18ebfb2Smrg	$echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 ;;
4268a18ebfb2Smrg      esac
426950806d53Smrg
4270a18ebfb2Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
4271a18ebfb2Smrg	$echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
4272a18ebfb2Smrg      fi
427350806d53Smrg
4274a18ebfb2Smrg      if test -n "$rpath"; then
4275a18ebfb2Smrg	$echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
4276a18ebfb2Smrg      fi
4277a18ebfb2Smrg
4278a18ebfb2Smrg      if test -n "$xrpath"; then
4279a18ebfb2Smrg	$echo "$modename: warning: \`-R' is ignored for objects" 1>&2
4280a18ebfb2Smrg      fi
4281a18ebfb2Smrg
4282a18ebfb2Smrg      if test -n "$vinfo"; then
4283a18ebfb2Smrg	$echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
4284a18ebfb2Smrg      fi
4285a18ebfb2Smrg
4286a18ebfb2Smrg      if test -n "$release"; then
4287a18ebfb2Smrg	$echo "$modename: warning: \`-release' is ignored for objects" 1>&2
4288a18ebfb2Smrg      fi
4289a18ebfb2Smrg
4290a18ebfb2Smrg      case $output in
4291a18ebfb2Smrg      *.lo)
4292a18ebfb2Smrg	if test -n "$objs$old_deplibs"; then
4293a18ebfb2Smrg	  $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
4294a18ebfb2Smrg	  exit $EXIT_FAILURE
4295a18ebfb2Smrg	fi
4296a18ebfb2Smrg	libobj="$output"
4297a18ebfb2Smrg	obj=`$echo "X$output" | $Xsed -e "$lo2o"`
4298af1a9c97Smrg	;;
4299a18ebfb2Smrg      *)
4300a18ebfb2Smrg	libobj=
4301a18ebfb2Smrg	obj="$output"
4302af1a9c97Smrg	;;
4303af1a9c97Smrg      esac
430450806d53Smrg
4305a18ebfb2Smrg      # Delete the old objects.
4306a18ebfb2Smrg      $run $rm $obj $libobj
430750806d53Smrg
4308a18ebfb2Smrg      # Objects from convenience libraries.  This assumes
4309a18ebfb2Smrg      # single-version convenience libraries.  Whenever we create
4310a18ebfb2Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
4311a18ebfb2Smrg      # the extraction.
4312a18ebfb2Smrg      reload_conv_objs=
4313a18ebfb2Smrg      gentop=
4314a18ebfb2Smrg      # reload_cmds runs $LD directly, so let us get rid of
4315a18ebfb2Smrg      # -Wl from whole_archive_flag_spec and hope we can get by with
4316a18ebfb2Smrg      # turning comma into space..
4317a18ebfb2Smrg      wl=
431850806d53Smrg
4319a18ebfb2Smrg      if test -n "$convenience"; then
4320a18ebfb2Smrg	if test -n "$whole_archive_flag_spec"; then
4321a18ebfb2Smrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
4322a18ebfb2Smrg	  reload_conv_objs=$reload_objs\ `$echo "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
4323a18ebfb2Smrg	else
4324a18ebfb2Smrg	  gentop="$output_objdir/${obj}x"
4325a18ebfb2Smrg	  generated="$generated $gentop"
432650806d53Smrg
4327a18ebfb2Smrg	  func_extract_archives $gentop $convenience
4328a18ebfb2Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
4329a18ebfb2Smrg	fi
4330a18ebfb2Smrg      fi
433150806d53Smrg
4332a18ebfb2Smrg      # Create the old-style object.
4333a18ebfb2Smrg      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
433450806d53Smrg
4335a18ebfb2Smrg      output="$obj"
4336a18ebfb2Smrg      cmds=$reload_cmds
4337a18ebfb2Smrg      save_ifs="$IFS"; IFS='~'
4338a18ebfb2Smrg      for cmd in $cmds; do
4339a18ebfb2Smrg	IFS="$save_ifs"
4340a18ebfb2Smrg	eval cmd=\"$cmd\"
4341a18ebfb2Smrg	$show "$cmd"
4342a18ebfb2Smrg	$run eval "$cmd" || exit $?
4343a18ebfb2Smrg      done
4344a18ebfb2Smrg      IFS="$save_ifs"
434550806d53Smrg
4346a18ebfb2Smrg      # Exit if we aren't doing a library object file.
4347a18ebfb2Smrg      if test -z "$libobj"; then
4348a18ebfb2Smrg	if test -n "$gentop"; then
4349a18ebfb2Smrg	  $show "${rm}r $gentop"
4350a18ebfb2Smrg	  $run ${rm}r $gentop
4351a18ebfb2Smrg	fi
435250806d53Smrg
4353a18ebfb2Smrg	exit $EXIT_SUCCESS
4354a18ebfb2Smrg      fi
435550806d53Smrg
4356a18ebfb2Smrg      if test "$build_libtool_libs" != yes; then
4357a18ebfb2Smrg	if test -n "$gentop"; then
4358a18ebfb2Smrg	  $show "${rm}r $gentop"
4359a18ebfb2Smrg	  $run ${rm}r $gentop
4360a18ebfb2Smrg	fi
436150806d53Smrg
4362a18ebfb2Smrg	# Create an invalid libtool object if no PIC, so that we don't
4363a18ebfb2Smrg	# accidentally link it into a program.
4364a18ebfb2Smrg	# $show "echo timestamp > $libobj"
4365a18ebfb2Smrg	# $run eval "echo timestamp > $libobj" || exit $?
4366a18ebfb2Smrg	exit $EXIT_SUCCESS
4367a18ebfb2Smrg      fi
436850806d53Smrg
4369a18ebfb2Smrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
4370a18ebfb2Smrg	# Only do commands if we really have different PIC objects.
4371a18ebfb2Smrg	reload_objs="$libobjs $reload_conv_objs"
4372a18ebfb2Smrg	output="$libobj"
4373a18ebfb2Smrg	cmds=$reload_cmds
4374a18ebfb2Smrg	save_ifs="$IFS"; IFS='~'
4375a18ebfb2Smrg	for cmd in $cmds; do
4376a18ebfb2Smrg	  IFS="$save_ifs"
4377a18ebfb2Smrg	  eval cmd=\"$cmd\"
4378a18ebfb2Smrg	  $show "$cmd"
4379a18ebfb2Smrg	  $run eval "$cmd" || exit $?
4380a18ebfb2Smrg	done
4381a18ebfb2Smrg	IFS="$save_ifs"
4382a18ebfb2Smrg      fi
438350806d53Smrg
4384a18ebfb2Smrg      if test -n "$gentop"; then
4385a18ebfb2Smrg	$show "${rm}r $gentop"
4386a18ebfb2Smrg	$run ${rm}r $gentop
4387a18ebfb2Smrg      fi
438850806d53Smrg
4389a18ebfb2Smrg      exit $EXIT_SUCCESS
4390a18ebfb2Smrg      ;;
4391af1a9c97Smrg
4392a18ebfb2Smrg    prog)
4393a18ebfb2Smrg      case $host in
4394a18ebfb2Smrg	*cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
4395a18ebfb2Smrg      esac
4396a18ebfb2Smrg      if test -n "$vinfo"; then
4397a18ebfb2Smrg	$echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
4398a18ebfb2Smrg      fi
439950806d53Smrg
4400a18ebfb2Smrg      if test -n "$release"; then
4401a18ebfb2Smrg	$echo "$modename: warning: \`-release' is ignored for programs" 1>&2
4402a18ebfb2Smrg      fi
440350806d53Smrg
4404a18ebfb2Smrg      if test "$preload" = yes; then
4405a18ebfb2Smrg	if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown &&
4406a18ebfb2Smrg	   test "$dlopen_self_static" = unknown; then
4407a18ebfb2Smrg	  $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
4408af1a9c97Smrg	fi
4409a18ebfb2Smrg      fi
441050806d53Smrg
4411a18ebfb2Smrg      case $host in
4412a18ebfb2Smrg      *-*-rhapsody* | *-*-darwin1.[012])
4413a18ebfb2Smrg	# On Rhapsody replace the C library is the System framework
4414a18ebfb2Smrg	compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
4415a18ebfb2Smrg	finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
4416af1a9c97Smrg	;;
4417a18ebfb2Smrg      esac
441850806d53Smrg
4419a18ebfb2Smrg      case $host in
4420a18ebfb2Smrg      *darwin*)
4421a18ebfb2Smrg        # Don't allow lazy linking, it breaks C++ global constructors
4422a18ebfb2Smrg        if test "$tagname" = CXX ; then
4423a18ebfb2Smrg        compile_command="$compile_command ${wl}-bind_at_load"
4424a18ebfb2Smrg        finalize_command="$finalize_command ${wl}-bind_at_load"
4425a18ebfb2Smrg        fi
4426a18ebfb2Smrg        ;;
4427a18ebfb2Smrg      esac
442850806d53Smrg
442950806d53Smrg
4430a18ebfb2Smrg      # move library search paths that coincide with paths to not yet
4431a18ebfb2Smrg      # installed libraries to the beginning of the library search list
4432a18ebfb2Smrg      new_libs=
4433a18ebfb2Smrg      for path in $notinst_path; do
4434a18ebfb2Smrg	case " $new_libs " in
4435a18ebfb2Smrg	*" -L$path/$objdir "*) ;;
4436a18ebfb2Smrg	*)
4437a18ebfb2Smrg	  case " $compile_deplibs " in
4438a18ebfb2Smrg	  *" -L$path/$objdir "*)
4439a18ebfb2Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
4440a18ebfb2Smrg	  esac
4441a18ebfb2Smrg	  ;;
4442a18ebfb2Smrg	esac
4443a18ebfb2Smrg      done
4444a18ebfb2Smrg      for deplib in $compile_deplibs; do
4445a18ebfb2Smrg	case $deplib in
4446a18ebfb2Smrg	-L*)
4447a18ebfb2Smrg	  case " $new_libs " in
4448a18ebfb2Smrg	  *" $deplib "*) ;;
4449a18ebfb2Smrg	  *) new_libs="$new_libs $deplib" ;;
4450a18ebfb2Smrg	  esac
4451a18ebfb2Smrg	  ;;
4452a18ebfb2Smrg	*) new_libs="$new_libs $deplib" ;;
4453a18ebfb2Smrg	esac
4454a18ebfb2Smrg      done
4455a18ebfb2Smrg      compile_deplibs="$new_libs"
445650806d53Smrg
445750806d53Smrg
4458a18ebfb2Smrg      compile_command="$compile_command $compile_deplibs"
4459a18ebfb2Smrg      finalize_command="$finalize_command $finalize_deplibs"
446050806d53Smrg
4461a18ebfb2Smrg      if test -n "$rpath$xrpath"; then
4462a18ebfb2Smrg	# If the user specified any rpath flags, then add them.
4463a18ebfb2Smrg	for libdir in $rpath $xrpath; do
4464a18ebfb2Smrg	  # This is the magic to use -rpath.
4465a18ebfb2Smrg	  case "$finalize_rpath " in
4466a18ebfb2Smrg	  *" $libdir "*) ;;
4467a18ebfb2Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
4468a18ebfb2Smrg	  esac
4469a18ebfb2Smrg	done
4470a18ebfb2Smrg      fi
447150806d53Smrg
4472a18ebfb2Smrg      # Now hardcode the library paths
4473a18ebfb2Smrg      rpath=
4474a18ebfb2Smrg      hardcode_libdirs=
4475a18ebfb2Smrg      for libdir in $compile_rpath $finalize_rpath; do
4476a18ebfb2Smrg	if test -n "$hardcode_libdir_flag_spec"; then
4477a18ebfb2Smrg	  if test -n "$hardcode_libdir_separator"; then
4478a18ebfb2Smrg	    if test -z "$hardcode_libdirs"; then
4479a18ebfb2Smrg	      hardcode_libdirs="$libdir"
4480a18ebfb2Smrg	    else
4481a18ebfb2Smrg	      # Just accumulate the unique libdirs.
4482a18ebfb2Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
4483a18ebfb2Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
4484a18ebfb2Smrg		;;
4485a18ebfb2Smrg	      *)
4486a18ebfb2Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
4487a18ebfb2Smrg		;;
4488a18ebfb2Smrg	      esac
4489a18ebfb2Smrg	    fi
4490af1a9c97Smrg	  else
4491a18ebfb2Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
4492a18ebfb2Smrg	    rpath="$rpath $flag"
4493af1a9c97Smrg	  fi
4494a18ebfb2Smrg	elif test -n "$runpath_var"; then
4495a18ebfb2Smrg	  case "$perm_rpath " in
4496a18ebfb2Smrg	  *" $libdir "*) ;;
4497a18ebfb2Smrg	  *) perm_rpath="$perm_rpath $libdir" ;;
4498a18ebfb2Smrg	  esac
4499af1a9c97Smrg	fi
4500af1a9c97Smrg	case $host in
4501a18ebfb2Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
4502a18ebfb2Smrg	  testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'`
4503af1a9c97Smrg	  case :$dllsearchpath: in
4504a18ebfb2Smrg	  *":$libdir:"*) ;;
4505a18ebfb2Smrg	  *) dllsearchpath="$dllsearchpath:$libdir";;
4506af1a9c97Smrg	  esac
4507af1a9c97Smrg	  case :$dllsearchpath: in
4508af1a9c97Smrg	  *":$testbindir:"*) ;;
4509af1a9c97Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
4510af1a9c97Smrg	  esac
4511af1a9c97Smrg	  ;;
4512af1a9c97Smrg	esac
4513a18ebfb2Smrg      done
4514a18ebfb2Smrg      # Substitute the hardcoded libdirs into the rpath.
4515a18ebfb2Smrg      if test -n "$hardcode_libdir_separator" &&
4516a18ebfb2Smrg	 test -n "$hardcode_libdirs"; then
4517a18ebfb2Smrg	libdir="$hardcode_libdirs"
4518a18ebfb2Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
4519a18ebfb2Smrg      fi
4520a18ebfb2Smrg      compile_rpath="$rpath"
452150806d53Smrg
4522a18ebfb2Smrg      rpath=
4523a18ebfb2Smrg      hardcode_libdirs=
4524a18ebfb2Smrg      for libdir in $finalize_rpath; do
4525a18ebfb2Smrg	if test -n "$hardcode_libdir_flag_spec"; then
4526a18ebfb2Smrg	  if test -n "$hardcode_libdir_separator"; then
4527a18ebfb2Smrg	    if test -z "$hardcode_libdirs"; then
4528a18ebfb2Smrg	      hardcode_libdirs="$libdir"
4529a18ebfb2Smrg	    else
4530a18ebfb2Smrg	      # Just accumulate the unique libdirs.
4531a18ebfb2Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
4532a18ebfb2Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
4533a18ebfb2Smrg		;;
4534a18ebfb2Smrg	      *)
4535a18ebfb2Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
4536a18ebfb2Smrg		;;
4537a18ebfb2Smrg	      esac
4538a18ebfb2Smrg	    fi
4539a18ebfb2Smrg	  else
4540a18ebfb2Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
4541a18ebfb2Smrg	    rpath="$rpath $flag"
4542a18ebfb2Smrg	  fi
4543a18ebfb2Smrg	elif test -n "$runpath_var"; then
4544a18ebfb2Smrg	  case "$finalize_perm_rpath " in
4545a18ebfb2Smrg	  *" $libdir "*) ;;
4546a18ebfb2Smrg	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
4547af1a9c97Smrg	  esac
4548af1a9c97Smrg	fi
4549a18ebfb2Smrg      done
4550a18ebfb2Smrg      # Substitute the hardcoded libdirs into the rpath.
4551a18ebfb2Smrg      if test -n "$hardcode_libdir_separator" &&
4552a18ebfb2Smrg	 test -n "$hardcode_libdirs"; then
4553a18ebfb2Smrg	libdir="$hardcode_libdirs"
4554a18ebfb2Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
4555a18ebfb2Smrg      fi
4556a18ebfb2Smrg      finalize_rpath="$rpath"
455750806d53Smrg
4558a18ebfb2Smrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
4559a18ebfb2Smrg	# Transform all the library objects into standard objects.
4560a18ebfb2Smrg	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
4561a18ebfb2Smrg	finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
4562a18ebfb2Smrg      fi
456350806d53Smrg
4564a18ebfb2Smrg      dlsyms=
4565a18ebfb2Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
4566a18ebfb2Smrg	if test -n "$NM" && test -n "$global_symbol_pipe"; then
4567a18ebfb2Smrg	  dlsyms="${outputname}S.c"
4568a18ebfb2Smrg	else
4569a18ebfb2Smrg	  $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
4570a18ebfb2Smrg	fi
4571a18ebfb2Smrg      fi
457250806d53Smrg
4573a18ebfb2Smrg      if test -n "$dlsyms"; then
4574a18ebfb2Smrg	case $dlsyms in
4575a18ebfb2Smrg	"") ;;
4576a18ebfb2Smrg	*.c)
4577a18ebfb2Smrg	  # Discover the nlist of each of the dlfiles.
4578a18ebfb2Smrg	  nlist="$output_objdir/${outputname}.nm"
457950806d53Smrg
4580a18ebfb2Smrg	  $show "$rm $nlist ${nlist}S ${nlist}T"
4581a18ebfb2Smrg	  $run $rm "$nlist" "${nlist}S" "${nlist}T"
458250806d53Smrg
4583a18ebfb2Smrg	  # Parse the name list into a source file.
4584a18ebfb2Smrg	  $show "creating $output_objdir/$dlsyms"
458550806d53Smrg
4586a18ebfb2Smrg	  test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
4587a18ebfb2Smrg/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
4588a18ebfb2Smrg/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
458950806d53Smrg
4590a18ebfb2Smrg#ifdef __cplusplus
4591a18ebfb2Smrgextern \"C\" {
4592a18ebfb2Smrg#endif
459350806d53Smrg
4594a18ebfb2Smrg/* Prevent the only kind of declaration conflicts we can make. */
4595a18ebfb2Smrg#define lt_preloaded_symbols some_other_symbol
459650806d53Smrg
4597a18ebfb2Smrg/* External symbol declarations for the compiler. */\
4598a18ebfb2Smrg"
459950806d53Smrg
4600a18ebfb2Smrg	  if test "$dlself" = yes; then
4601a18ebfb2Smrg	    $show "generating symbol list for \`$output'"
460250806d53Smrg
4603a18ebfb2Smrg	    test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
460450806d53Smrg
4605a18ebfb2Smrg	    # Add our own program objects to the symbol list.
4606a18ebfb2Smrg	    progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
4607a18ebfb2Smrg	    for arg in $progfiles; do
4608a18ebfb2Smrg	      $show "extracting global C symbols from \`$arg'"
4609a18ebfb2Smrg	      $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
4610a18ebfb2Smrg	    done
461150806d53Smrg
4612a18ebfb2Smrg	    if test -n "$exclude_expsyms"; then
4613a18ebfb2Smrg	      $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
4614a18ebfb2Smrg	      $run eval '$mv "$nlist"T "$nlist"'
4615a18ebfb2Smrg	    fi
461650806d53Smrg
4617a18ebfb2Smrg	    if test -n "$export_symbols_regex"; then
4618a18ebfb2Smrg	      $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
4619a18ebfb2Smrg	      $run eval '$mv "$nlist"T "$nlist"'
4620a18ebfb2Smrg	    fi
462150806d53Smrg
4622a18ebfb2Smrg	    # Prepare the list of exported symbols
4623a18ebfb2Smrg	    if test -z "$export_symbols"; then
4624a18ebfb2Smrg	      export_symbols="$output_objdir/$outputname.exp"
4625a18ebfb2Smrg	      $run $rm $export_symbols
4626a18ebfb2Smrg	      $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4627a18ebfb2Smrg              case $host in
4628a18ebfb2Smrg              *cygwin* | *mingw* )
4629a18ebfb2Smrg	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4630a18ebfb2Smrg		$run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
4631a18ebfb2Smrg                ;;
4632a18ebfb2Smrg              esac
4633a18ebfb2Smrg	    else
4634a18ebfb2Smrg	      $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4635a18ebfb2Smrg	      $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
4636a18ebfb2Smrg	      $run eval 'mv "$nlist"T "$nlist"'
4637a18ebfb2Smrg              case $host in
4638a18ebfb2Smrg              *cygwin* | *mingw* )
4639a18ebfb2Smrg	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4640a18ebfb2Smrg		$run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
4641a18ebfb2Smrg                ;;
4642a18ebfb2Smrg              esac
4643a18ebfb2Smrg	    fi
4644a18ebfb2Smrg	  fi
464550806d53Smrg
4646a18ebfb2Smrg	  for arg in $dlprefiles; do
4647a18ebfb2Smrg	    $show "extracting global C symbols from \`$arg'"
4648a18ebfb2Smrg	    name=`$echo "$arg" | ${SED} -e 's%^.*/%%'`
4649a18ebfb2Smrg	    $run eval '$echo ": $name " >> "$nlist"'
4650a18ebfb2Smrg	    $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
4651a18ebfb2Smrg	  done
465250806d53Smrg
4653a18ebfb2Smrg	  if test -z "$run"; then
4654a18ebfb2Smrg	    # Make sure we have at least an empty file.
4655a18ebfb2Smrg	    test -f "$nlist" || : > "$nlist"
465650806d53Smrg
4657a18ebfb2Smrg	    if test -n "$exclude_expsyms"; then
4658a18ebfb2Smrg	      $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
4659a18ebfb2Smrg	      $mv "$nlist"T "$nlist"
4660a18ebfb2Smrg	    fi
466150806d53Smrg
4662a18ebfb2Smrg	    # Try sorting and uniquifying the output.
4663a18ebfb2Smrg	    if grep -v "^: " < "$nlist" |
4664a18ebfb2Smrg		if sort -k 3 </dev/null >/dev/null 2>&1; then
4665a18ebfb2Smrg		  sort -k 3
4666a18ebfb2Smrg		else
4667a18ebfb2Smrg		  sort +2
4668a18ebfb2Smrg		fi |
4669a18ebfb2Smrg		uniq > "$nlist"S; then
4670a18ebfb2Smrg	      :
4671a18ebfb2Smrg	    else
4672a18ebfb2Smrg	      grep -v "^: " < "$nlist" > "$nlist"S
4673a18ebfb2Smrg	    fi
467450806d53Smrg
4675a18ebfb2Smrg	    if test -f "$nlist"S; then
4676a18ebfb2Smrg	      eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
4677a18ebfb2Smrg	    else
4678a18ebfb2Smrg	      $echo '/* NONE */' >> "$output_objdir/$dlsyms"
4679a18ebfb2Smrg	    fi
468050806d53Smrg
4681a18ebfb2Smrg	    $echo >> "$output_objdir/$dlsyms" "\
468250806d53Smrg
4683a18ebfb2Smrg#undef lt_preloaded_symbols
468450806d53Smrg
4685a18ebfb2Smrg#if defined (__STDC__) && __STDC__
4686a18ebfb2Smrg# define lt_ptr void *
4687a18ebfb2Smrg#else
4688a18ebfb2Smrg# define lt_ptr char *
4689a18ebfb2Smrg# define const
4690a18ebfb2Smrg#endif
469150806d53Smrg
4692a18ebfb2Smrg/* The mapping between symbol names and symbols. */
4693a18ebfb2Smrg"
469450806d53Smrg
4695a18ebfb2Smrg	    case $host in
4696a18ebfb2Smrg	    *cygwin* | *mingw* )
4697a18ebfb2Smrg	  $echo >> "$output_objdir/$dlsyms" "\
4698a18ebfb2Smrg/* DATA imports from DLLs on WIN32 can't be const, because
4699a18ebfb2Smrg   runtime relocations are performed -- see ld's documentation
4700a18ebfb2Smrg   on pseudo-relocs */
4701a18ebfb2Smrgstruct {
4702a18ebfb2Smrg"
4703a18ebfb2Smrg	      ;;
4704a18ebfb2Smrg	    * )
4705a18ebfb2Smrg	  $echo >> "$output_objdir/$dlsyms" "\
4706a18ebfb2Smrgconst struct {
4707a18ebfb2Smrg"
4708a18ebfb2Smrg	      ;;
4709a18ebfb2Smrg	    esac
471050806d53Smrg
471150806d53Smrg
4712a18ebfb2Smrg	  $echo >> "$output_objdir/$dlsyms" "\
4713a18ebfb2Smrg  const char *name;
4714a18ebfb2Smrg  lt_ptr address;
4715a18ebfb2Smrg}
4716a18ebfb2Smrglt_preloaded_symbols[] =
4717a18ebfb2Smrg{\
4718a18ebfb2Smrg"
471950806d53Smrg
4720a18ebfb2Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
472150806d53Smrg
4722a18ebfb2Smrg	    $echo >> "$output_objdir/$dlsyms" "\
4723a18ebfb2Smrg  {0, (lt_ptr) 0}
4724a18ebfb2Smrg};
472550806d53Smrg
4726a18ebfb2Smrg/* This works around a problem in FreeBSD linker */
4727a18ebfb2Smrg#ifdef FREEBSD_WORKAROUND
4728a18ebfb2Smrgstatic const void *lt_preloaded_setup() {
4729a18ebfb2Smrg  return lt_preloaded_symbols;
4730a18ebfb2Smrg}
4731a18ebfb2Smrg#endif
473250806d53Smrg
4733a18ebfb2Smrg#ifdef __cplusplus
4734a18ebfb2Smrg}
4735a18ebfb2Smrg#endif\
4736a18ebfb2Smrg"
4737af1a9c97Smrg	  fi
473850806d53Smrg
4739a18ebfb2Smrg	  pic_flag_for_symtable=
4740a18ebfb2Smrg	  case $host in
4741a18ebfb2Smrg	  # compiling the symbol table file with pic_flag works around
4742a18ebfb2Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
4743a18ebfb2Smrg	  # linked before any other PIC object.  But we must not use
4744a18ebfb2Smrg	  # pic_flag when linking with -static.  The problem exists in
4745a18ebfb2Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
4746a18ebfb2Smrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
4747a18ebfb2Smrg	    case "$compile_command " in
4748a18ebfb2Smrg	    *" -static "*) ;;
4749a18ebfb2Smrg	    *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";;
4750a18ebfb2Smrg	    esac;;
4751a18ebfb2Smrg	  *-*-hpux*)
4752a18ebfb2Smrg	    case "$compile_command " in
4753a18ebfb2Smrg	    *" -static "*) ;;
4754a18ebfb2Smrg	    *) pic_flag_for_symtable=" $pic_flag";;
4755a18ebfb2Smrg	    esac
4756a18ebfb2Smrg	  esac
475750806d53Smrg
4758a18ebfb2Smrg	  # Now compile the dynamic symbol file.
4759a18ebfb2Smrg	  $show "(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
4760a18ebfb2Smrg	  $run eval '(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
476150806d53Smrg
4762a18ebfb2Smrg	  # Clean up the generated files.
4763a18ebfb2Smrg	  $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
4764a18ebfb2Smrg	  $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
476550806d53Smrg
4766a18ebfb2Smrg	  # Transform the symbol file into the correct name.
4767a18ebfb2Smrg          case $host in
4768a18ebfb2Smrg          *cygwin* | *mingw* )
4769a18ebfb2Smrg            if test -f "$output_objdir/${outputname}.def" ; then
4770a18ebfb2Smrg              compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP`
4771a18ebfb2Smrg              finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP`
4772a18ebfb2Smrg            else
4773a18ebfb2Smrg              compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
4774a18ebfb2Smrg              finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
4775a18ebfb2Smrg             fi
4776a18ebfb2Smrg            ;;
4777a18ebfb2Smrg          * )
4778a18ebfb2Smrg            compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
4779a18ebfb2Smrg            finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
4780a18ebfb2Smrg            ;;
4781a18ebfb2Smrg          esac
4782a18ebfb2Smrg	  ;;
4783a18ebfb2Smrg	*)
4784a18ebfb2Smrg	  $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
4785a18ebfb2Smrg	  exit $EXIT_FAILURE
4786a18ebfb2Smrg	  ;;
4787a18ebfb2Smrg	esac
4788a18ebfb2Smrg      else
4789a18ebfb2Smrg	# We keep going just in case the user didn't refer to
4790a18ebfb2Smrg	# lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
4791a18ebfb2Smrg	# really was required.
479250806d53Smrg
4793a18ebfb2Smrg	# Nullify the symbol file.
4794a18ebfb2Smrg	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP`
4795a18ebfb2Smrg	finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP`
4796a18ebfb2Smrg      fi
4797af1a9c97Smrg
4798a18ebfb2Smrg      if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
4799a18ebfb2Smrg	# Replace the output file specification.
4800a18ebfb2Smrg	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$output"'%g' | $NL2SP`
4801a18ebfb2Smrg	link_command="$compile_command$compile_rpath"
4802af1a9c97Smrg
4803a18ebfb2Smrg	# We have no uninstalled library dependencies, so finalize right now.
4804a18ebfb2Smrg	$show "$link_command"
4805a18ebfb2Smrg	$run eval "$link_command"
4806a18ebfb2Smrg	exit_status=$?
4807af1a9c97Smrg
4808a18ebfb2Smrg	# Delete the generated files.
4809a18ebfb2Smrg	if test -n "$dlsyms"; then
4810a18ebfb2Smrg	  $show "$rm $output_objdir/${outputname}S.${objext}"
4811a18ebfb2Smrg	  $run $rm "$output_objdir/${outputname}S.${objext}"
4812af1a9c97Smrg	fi
4813af1a9c97Smrg
4814a18ebfb2Smrg	exit $exit_status
4815a18ebfb2Smrg      fi
4816af1a9c97Smrg
4817a18ebfb2Smrg      if test -n "$shlibpath_var"; then
4818a18ebfb2Smrg	# We should set the shlibpath_var
4819a18ebfb2Smrg	rpath=
4820a18ebfb2Smrg	for dir in $temp_rpath; do
4821a18ebfb2Smrg	  case $dir in
4822a18ebfb2Smrg	  [\\/]* | [A-Za-z]:[\\/]*)
4823a18ebfb2Smrg	    # Absolute path.
4824a18ebfb2Smrg	    rpath="$rpath$dir:"
4825a18ebfb2Smrg	    ;;
4826a18ebfb2Smrg	  *)
4827a18ebfb2Smrg	    # Relative path: add a thisdir entry.
4828a18ebfb2Smrg	    rpath="$rpath\$thisdir/$dir:"
4829a18ebfb2Smrg	    ;;
4830a18ebfb2Smrg	  esac
4831a18ebfb2Smrg	done
4832a18ebfb2Smrg	temp_rpath="$rpath"
4833af1a9c97Smrg      fi
4834af1a9c97Smrg
4835a18ebfb2Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
4836a18ebfb2Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
4837a18ebfb2Smrg      fi
4838a18ebfb2Smrg      if test -n "$finalize_shlibpath"; then
4839a18ebfb2Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
4840a18ebfb2Smrg      fi
4841af1a9c97Smrg
4842a18ebfb2Smrg      compile_var=
4843a18ebfb2Smrg      finalize_var=
4844a18ebfb2Smrg      if test -n "$runpath_var"; then
4845a18ebfb2Smrg	if test -n "$perm_rpath"; then
4846a18ebfb2Smrg	  # We should set the runpath_var.
4847a18ebfb2Smrg	  rpath=
4848a18ebfb2Smrg	  for dir in $perm_rpath; do
4849a18ebfb2Smrg	    rpath="$rpath$dir:"
4850a18ebfb2Smrg	  done
4851a18ebfb2Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
4852a18ebfb2Smrg	fi
4853a18ebfb2Smrg	if test -n "$finalize_perm_rpath"; then
4854a18ebfb2Smrg	  # We should set the runpath_var.
4855a18ebfb2Smrg	  rpath=
4856a18ebfb2Smrg	  for dir in $finalize_perm_rpath; do
4857a18ebfb2Smrg	    rpath="$rpath$dir:"
4858a18ebfb2Smrg	  done
4859a18ebfb2Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
4860a18ebfb2Smrg	fi
4861a18ebfb2Smrg      fi
4862af1a9c97Smrg
4863a18ebfb2Smrg      if test "$no_install" = yes; then
4864a18ebfb2Smrg	# We don't need to create a wrapper script.
4865a18ebfb2Smrg	link_command="$compile_var$compile_command$compile_rpath"
4866a18ebfb2Smrg	# Replace the output file specification.
4867a18ebfb2Smrg	link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
4868a18ebfb2Smrg	# Delete the old output file.
4869a18ebfb2Smrg	$run $rm $output
4870a18ebfb2Smrg	# Link the executable and exit
4871a18ebfb2Smrg	$show "$link_command"
4872a18ebfb2Smrg	$run eval "$link_command" || exit $?
4873a18ebfb2Smrg	exit $EXIT_SUCCESS
4874a18ebfb2Smrg      fi
4875af1a9c97Smrg
4876a18ebfb2Smrg      if test "$hardcode_action" = relink; then
4877a18ebfb2Smrg	# Fast installation is not supported
4878a18ebfb2Smrg	link_command="$compile_var$compile_command$compile_rpath"
4879a18ebfb2Smrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
4880af1a9c97Smrg
4881a18ebfb2Smrg	$echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
4882a18ebfb2Smrg	$echo "$modename: \`$output' will be relinked during installation" 1>&2
4883a18ebfb2Smrg      else
4884a18ebfb2Smrg	if test "$fast_install" != no; then
4885a18ebfb2Smrg	  link_command="$finalize_var$compile_command$finalize_rpath"
4886a18ebfb2Smrg	  if test "$fast_install" = yes; then
4887a18ebfb2Smrg	    relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $SP2NL | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g' | $NL2SP`
4888a18ebfb2Smrg	  else
4889a18ebfb2Smrg	    # fast_install is set to needless
4890a18ebfb2Smrg	    relink_command=
4891a18ebfb2Smrg	  fi
4892a18ebfb2Smrg	else
4893a18ebfb2Smrg	  link_command="$compile_var$compile_command$compile_rpath"
4894a18ebfb2Smrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
4895a18ebfb2Smrg	fi
4896af1a9c97Smrg      fi
4897af1a9c97Smrg
4898a18ebfb2Smrg      # Replace the output file specification.
4899a18ebfb2Smrg      link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
4900af1a9c97Smrg
4901a18ebfb2Smrg      # Delete the old output files.
4902a18ebfb2Smrg      $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
4903af1a9c97Smrg
4904a18ebfb2Smrg      $show "$link_command"
4905a18ebfb2Smrg      $run eval "$link_command" || exit $?
4906af1a9c97Smrg
4907a18ebfb2Smrg      # Now create the wrapper script.
4908a18ebfb2Smrg      $show "creating $output"
4909af1a9c97Smrg
4910a18ebfb2Smrg      # Quote the relink command for shipping.
4911a18ebfb2Smrg      if test -n "$relink_command"; then
4912a18ebfb2Smrg	# Preserve any variables that may affect compiler behavior
4913a18ebfb2Smrg	for var in $variables_saved_for_relink; do
4914a18ebfb2Smrg	  if eval test -z \"\${$var+set}\"; then
4915a18ebfb2Smrg	    relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
4916a18ebfb2Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
4917a18ebfb2Smrg	    relink_command="$var=; export $var; $relink_command"
4918a18ebfb2Smrg	  else
4919a18ebfb2Smrg	    var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
4920a18ebfb2Smrg	    relink_command="$var=\"$var_value\"; export $var; $relink_command"
4921a18ebfb2Smrg	  fi
4922af1a9c97Smrg	done
4923a18ebfb2Smrg	relink_command="(cd `pwd`; $relink_command)"
4924a18ebfb2Smrg	relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e "$sed_quote_subst" | $NL2SP`
4925af1a9c97Smrg      fi
4926af1a9c97Smrg
4927a18ebfb2Smrg      # Quote $echo for shipping.
4928a18ebfb2Smrg      if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then
4929a18ebfb2Smrg	case $progpath in
4930a18ebfb2Smrg	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
4931a18ebfb2Smrg	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
4932af1a9c97Smrg	esac
4933a18ebfb2Smrg	qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
4934a18ebfb2Smrg      else
4935a18ebfb2Smrg	qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
4936af1a9c97Smrg      fi
4937af1a9c97Smrg
4938a18ebfb2Smrg      # Only actually do things if our run command is non-null.
4939a18ebfb2Smrg      if test -z "$run"; then
4940a18ebfb2Smrg	# win32 will think the script is a binary if it has
4941a18ebfb2Smrg	# a .exe suffix, so we strip it off here.
4942a18ebfb2Smrg	case $output in
4943a18ebfb2Smrg	  *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;;
4944a18ebfb2Smrg	esac
4945a18ebfb2Smrg	# test for cygwin because mv fails w/o .exe extensions
4946a18ebfb2Smrg	case $host in
4947a18ebfb2Smrg	  *cygwin*)
4948a18ebfb2Smrg	    exeext=.exe
4949a18ebfb2Smrg	    outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;;
4950a18ebfb2Smrg	  *) exeext= ;;
4951a18ebfb2Smrg	esac
4952a18ebfb2Smrg	case $host in
4953a18ebfb2Smrg	  *cygwin* | *mingw* )
4954a18ebfb2Smrg            output_name=`basename $output`
4955a18ebfb2Smrg            output_path=`dirname $output`
4956a18ebfb2Smrg            cwrappersource="$output_path/$objdir/lt-$output_name.c"
4957a18ebfb2Smrg            cwrapper="$output_path/$output_name.exe"
4958a18ebfb2Smrg            $rm $cwrappersource $cwrapper
4959a18ebfb2Smrg            trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
4960af1a9c97Smrg
4961a18ebfb2Smrg	    cat > $cwrappersource <<EOF
4962af1a9c97Smrg
4963a18ebfb2Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
4964a18ebfb2Smrg   Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
4965af1a9c97Smrg
4966a18ebfb2Smrg   The $output program cannot be directly executed until all the libtool
4967a18ebfb2Smrg   libraries that it depends on are installed.
4968af1a9c97Smrg
4969a18ebfb2Smrg   This wrapper executable should never be moved out of the build directory.
4970a18ebfb2Smrg   If it is, it will not operate correctly.
4971af1a9c97Smrg
4972a18ebfb2Smrg   Currently, it simply execs the wrapper *script* "/bin/sh $output",
4973a18ebfb2Smrg   but could eventually absorb all of the scripts functionality and
4974a18ebfb2Smrg   exec $objdir/$outputname directly.
4975a18ebfb2Smrg*/
4976a18ebfb2SmrgEOF
4977a18ebfb2Smrg	    cat >> $cwrappersource<<"EOF"
4978a18ebfb2Smrg#include <stdio.h>
4979a18ebfb2Smrg#include <stdlib.h>
4980a18ebfb2Smrg#include <unistd.h>
4981a18ebfb2Smrg#include <malloc.h>
4982a18ebfb2Smrg#include <stdarg.h>
4983a18ebfb2Smrg#include <assert.h>
4984a18ebfb2Smrg#include <string.h>
4985a18ebfb2Smrg#include <ctype.h>
4986a18ebfb2Smrg#include <sys/stat.h>
4987af1a9c97Smrg
4988a18ebfb2Smrg#if defined(PATH_MAX)
4989a18ebfb2Smrg# define LT_PATHMAX PATH_MAX
4990a18ebfb2Smrg#elif defined(MAXPATHLEN)
4991a18ebfb2Smrg# define LT_PATHMAX MAXPATHLEN
4992a18ebfb2Smrg#else
4993a18ebfb2Smrg# define LT_PATHMAX 1024
4994a18ebfb2Smrg#endif
4995af1a9c97Smrg
4996a18ebfb2Smrg#ifndef DIR_SEPARATOR
4997a18ebfb2Smrg# define DIR_SEPARATOR '/'
4998a18ebfb2Smrg# define PATH_SEPARATOR ':'
4999a18ebfb2Smrg#endif
5000af1a9c97Smrg
5001a18ebfb2Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
5002a18ebfb2Smrg  defined (__OS2__)
5003a18ebfb2Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
5004a18ebfb2Smrg# ifndef DIR_SEPARATOR_2
5005a18ebfb2Smrg#  define DIR_SEPARATOR_2 '\\'
5006a18ebfb2Smrg# endif
5007a18ebfb2Smrg# ifndef PATH_SEPARATOR_2
5008a18ebfb2Smrg#  define PATH_SEPARATOR_2 ';'
5009a18ebfb2Smrg# endif
5010a18ebfb2Smrg#endif
5011af1a9c97Smrg
5012a18ebfb2Smrg#ifndef DIR_SEPARATOR_2
5013a18ebfb2Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
5014a18ebfb2Smrg#else /* DIR_SEPARATOR_2 */
5015a18ebfb2Smrg# define IS_DIR_SEPARATOR(ch) \
5016a18ebfb2Smrg        (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
5017a18ebfb2Smrg#endif /* DIR_SEPARATOR_2 */
5018af1a9c97Smrg
5019a18ebfb2Smrg#ifndef PATH_SEPARATOR_2
5020a18ebfb2Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
5021a18ebfb2Smrg#else /* PATH_SEPARATOR_2 */
5022a18ebfb2Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
5023a18ebfb2Smrg#endif /* PATH_SEPARATOR_2 */
5024af1a9c97Smrg
5025a18ebfb2Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
5026a18ebfb2Smrg#define XFREE(stale) do { \
5027a18ebfb2Smrg  if (stale) { free ((void *) stale); stale = 0; } \
5028a18ebfb2Smrg} while (0)
5029af1a9c97Smrg
5030a18ebfb2Smrg/* -DDEBUG is fairly common in CFLAGS.  */
5031a18ebfb2Smrg#undef DEBUG
5032a18ebfb2Smrg#if defined DEBUGWRAPPER
5033a18ebfb2Smrg# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
5034a18ebfb2Smrg#else
5035a18ebfb2Smrg# define DEBUG(format, ...)
5036a18ebfb2Smrg#endif
5037af1a9c97Smrg
5038a18ebfb2Smrgconst char *program_name = NULL;
5039af1a9c97Smrg
5040a18ebfb2Smrgvoid * xmalloc (size_t num);
5041a18ebfb2Smrgchar * xstrdup (const char *string);
5042a18ebfb2Smrgconst char * base_name (const char *name);
5043a18ebfb2Smrgchar * find_executable(const char *wrapper);
5044a18ebfb2Smrgint    check_executable(const char *path);
5045a18ebfb2Smrgchar * strendzap(char *str, const char *pat);
5046a18ebfb2Smrgvoid lt_fatal (const char *message, ...);
5047af1a9c97Smrg
5048a18ebfb2Smrgint
5049a18ebfb2Smrgmain (int argc, char *argv[])
5050a18ebfb2Smrg{
5051a18ebfb2Smrg  char **newargz;
5052a18ebfb2Smrg  int i;
5053af1a9c97Smrg
5054a18ebfb2Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
5055a18ebfb2Smrg  DEBUG("(main) argv[0]      : %s\n",argv[0]);
5056a18ebfb2Smrg  DEBUG("(main) program_name : %s\n",program_name);
5057a18ebfb2Smrg  newargz = XMALLOC(char *, argc+2);
5058a18ebfb2SmrgEOF
5059af1a9c97Smrg
5060a18ebfb2Smrg            cat >> $cwrappersource <<EOF
5061a18ebfb2Smrg  newargz[0] = (char *) xstrdup("$SHELL");
5062a18ebfb2SmrgEOF
5063af1a9c97Smrg
5064a18ebfb2Smrg            cat >> $cwrappersource <<"EOF"
5065a18ebfb2Smrg  newargz[1] = find_executable(argv[0]);
5066a18ebfb2Smrg  if (newargz[1] == NULL)
5067a18ebfb2Smrg    lt_fatal("Couldn't find %s", argv[0]);
5068a18ebfb2Smrg  DEBUG("(main) found exe at : %s\n",newargz[1]);
5069a18ebfb2Smrg  /* we know the script has the same name, without the .exe */
5070a18ebfb2Smrg  /* so make sure newargz[1] doesn't end in .exe */
5071a18ebfb2Smrg  strendzap(newargz[1],".exe");
5072a18ebfb2Smrg  for (i = 1; i < argc; i++)
5073a18ebfb2Smrg    newargz[i+1] = xstrdup(argv[i]);
5074a18ebfb2Smrg  newargz[argc+1] = NULL;
5075af1a9c97Smrg
5076a18ebfb2Smrg  for (i=0; i<argc+1; i++)
5077a18ebfb2Smrg  {
5078a18ebfb2Smrg    DEBUG("(main) newargz[%d]   : %s\n",i,newargz[i]);
5079a18ebfb2Smrg    ;
5080a18ebfb2Smrg  }
5081af1a9c97Smrg
5082a18ebfb2SmrgEOF
5083af1a9c97Smrg
5084a18ebfb2Smrg            case $host_os in
5085a18ebfb2Smrg              mingw*)
5086a18ebfb2Smrg                cat >> $cwrappersource <<EOF
5087a18ebfb2Smrg  execv("$SHELL",(char const **)newargz);
5088a18ebfb2SmrgEOF
5089a18ebfb2Smrg              ;;
5090a18ebfb2Smrg              *)
5091a18ebfb2Smrg                cat >> $cwrappersource <<EOF
5092a18ebfb2Smrg  execv("$SHELL",newargz);
5093a18ebfb2SmrgEOF
5094a18ebfb2Smrg              ;;
5095a18ebfb2Smrg            esac
5096af1a9c97Smrg
5097a18ebfb2Smrg            cat >> $cwrappersource <<"EOF"
5098a18ebfb2Smrg  return 127;
5099a18ebfb2Smrg}
5100af1a9c97Smrg
5101a18ebfb2Smrgvoid *
5102a18ebfb2Smrgxmalloc (size_t num)
5103a18ebfb2Smrg{
5104a18ebfb2Smrg  void * p = (void *) malloc (num);
5105a18ebfb2Smrg  if (!p)
5106a18ebfb2Smrg    lt_fatal ("Memory exhausted");
5107af1a9c97Smrg
5108a18ebfb2Smrg  return p;
5109a18ebfb2Smrg}
5110af1a9c97Smrg
5111a18ebfb2Smrgchar *
5112a18ebfb2Smrgxstrdup (const char *string)
5113a18ebfb2Smrg{
5114a18ebfb2Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL
5115a18ebfb2Smrg;
5116a18ebfb2Smrg}
5117af1a9c97Smrg
5118a18ebfb2Smrgconst char *
5119a18ebfb2Smrgbase_name (const char *name)
5120a18ebfb2Smrg{
5121a18ebfb2Smrg  const char *base;
5122af1a9c97Smrg
5123a18ebfb2Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5124a18ebfb2Smrg  /* Skip over the disk name in MSDOS pathnames. */
5125a18ebfb2Smrg  if (isalpha ((unsigned char)name[0]) && name[1] == ':')
5126a18ebfb2Smrg    name += 2;
5127a18ebfb2Smrg#endif
5128af1a9c97Smrg
5129a18ebfb2Smrg  for (base = name; *name; name++)
5130a18ebfb2Smrg    if (IS_DIR_SEPARATOR (*name))
5131a18ebfb2Smrg      base = name + 1;
5132a18ebfb2Smrg  return base;
5133a18ebfb2Smrg}
5134af1a9c97Smrg
5135a18ebfb2Smrgint
5136a18ebfb2Smrgcheck_executable(const char * path)
5137a18ebfb2Smrg{
5138a18ebfb2Smrg  struct stat st;
5139af1a9c97Smrg
5140a18ebfb2Smrg  DEBUG("(check_executable)  : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
5141a18ebfb2Smrg  if ((!path) || (!*path))
5142a18ebfb2Smrg    return 0;
5143af1a9c97Smrg
5144a18ebfb2Smrg  if ((stat (path, &st) >= 0) &&
5145a18ebfb2Smrg      (
5146a18ebfb2Smrg        /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
5147a18ebfb2Smrg#if defined (S_IXOTH)
5148a18ebfb2Smrg       ((st.st_mode & S_IXOTH) == S_IXOTH) ||
5149a18ebfb2Smrg#endif
5150a18ebfb2Smrg#if defined (S_IXGRP)
5151a18ebfb2Smrg       ((st.st_mode & S_IXGRP) == S_IXGRP) ||
5152a18ebfb2Smrg#endif
5153a18ebfb2Smrg       ((st.st_mode & S_IXUSR) == S_IXUSR))
5154a18ebfb2Smrg      )
5155a18ebfb2Smrg    return 1;
5156a18ebfb2Smrg  else
5157a18ebfb2Smrg    return 0;
5158a18ebfb2Smrg}
5159af1a9c97Smrg
5160a18ebfb2Smrg/* Searches for the full path of the wrapper.  Returns
5161a18ebfb2Smrg   newly allocated full path name if found, NULL otherwise */
5162a18ebfb2Smrgchar *
5163a18ebfb2Smrgfind_executable (const char* wrapper)
5164a18ebfb2Smrg{
5165a18ebfb2Smrg  int has_slash = 0;
5166a18ebfb2Smrg  const char* p;
5167a18ebfb2Smrg  const char* p_next;
5168a18ebfb2Smrg  /* static buffer for getcwd */
5169a18ebfb2Smrg  char tmp[LT_PATHMAX + 1];
5170a18ebfb2Smrg  int tmp_len;
5171a18ebfb2Smrg  char* concat_name;
5172af1a9c97Smrg
5173a18ebfb2Smrg  DEBUG("(find_executable)  : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
5174af1a9c97Smrg
5175a18ebfb2Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
5176a18ebfb2Smrg    return NULL;
517750806d53Smrg
5178a18ebfb2Smrg  /* Absolute path? */
5179a18ebfb2Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5180a18ebfb2Smrg  if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
5181a18ebfb2Smrg  {
5182a18ebfb2Smrg    concat_name = xstrdup (wrapper);
5183a18ebfb2Smrg    if (check_executable(concat_name))
5184a18ebfb2Smrg      return concat_name;
5185a18ebfb2Smrg    XFREE(concat_name);
5186a18ebfb2Smrg  }
5187a18ebfb2Smrg  else
5188a18ebfb2Smrg  {
5189a18ebfb2Smrg#endif
5190a18ebfb2Smrg    if (IS_DIR_SEPARATOR (wrapper[0]))
5191a18ebfb2Smrg    {
5192a18ebfb2Smrg      concat_name = xstrdup (wrapper);
5193a18ebfb2Smrg      if (check_executable(concat_name))
5194a18ebfb2Smrg        return concat_name;
5195a18ebfb2Smrg      XFREE(concat_name);
5196a18ebfb2Smrg    }
5197a18ebfb2Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5198a18ebfb2Smrg  }
5199a18ebfb2Smrg#endif
5200a18ebfb2Smrg
5201a18ebfb2Smrg  for (p = wrapper; *p; p++)
5202a18ebfb2Smrg    if (*p == '/')
5203a18ebfb2Smrg    {
5204a18ebfb2Smrg      has_slash = 1;
5205a18ebfb2Smrg      break;
5206a18ebfb2Smrg    }
5207a18ebfb2Smrg  if (!has_slash)
5208a18ebfb2Smrg  {
5209a18ebfb2Smrg    /* no slashes; search PATH */
5210a18ebfb2Smrg    const char* path = getenv ("PATH");
5211a18ebfb2Smrg    if (path != NULL)
5212a18ebfb2Smrg    {
5213a18ebfb2Smrg      for (p = path; *p; p = p_next)
5214a18ebfb2Smrg      {
5215a18ebfb2Smrg        const char* q;
5216a18ebfb2Smrg        size_t p_len;
5217a18ebfb2Smrg        for (q = p; *q; q++)
5218a18ebfb2Smrg          if (IS_PATH_SEPARATOR(*q))
5219a18ebfb2Smrg            break;
5220a18ebfb2Smrg        p_len = q - p;
5221a18ebfb2Smrg        p_next = (*q == '\0' ? q : q + 1);
5222a18ebfb2Smrg        if (p_len == 0)
5223a18ebfb2Smrg        {
5224a18ebfb2Smrg          /* empty path: current directory */
5225a18ebfb2Smrg          if (getcwd (tmp, LT_PATHMAX) == NULL)
5226a18ebfb2Smrg            lt_fatal ("getcwd failed");
5227a18ebfb2Smrg          tmp_len = strlen(tmp);
5228a18ebfb2Smrg          concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
5229a18ebfb2Smrg          memcpy (concat_name, tmp, tmp_len);
5230a18ebfb2Smrg          concat_name[tmp_len] = '/';
5231a18ebfb2Smrg          strcpy (concat_name + tmp_len + 1, wrapper);
5232a18ebfb2Smrg        }
5233a18ebfb2Smrg        else
5234a18ebfb2Smrg        {
5235a18ebfb2Smrg          concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
5236a18ebfb2Smrg          memcpy (concat_name, p, p_len);
5237a18ebfb2Smrg          concat_name[p_len] = '/';
5238a18ebfb2Smrg          strcpy (concat_name + p_len + 1, wrapper);
5239a18ebfb2Smrg        }
5240a18ebfb2Smrg        if (check_executable(concat_name))
5241a18ebfb2Smrg          return concat_name;
5242a18ebfb2Smrg        XFREE(concat_name);
5243a18ebfb2Smrg      }
5244a18ebfb2Smrg    }
5245a18ebfb2Smrg    /* not found in PATH; assume curdir */
5246a18ebfb2Smrg  }
5247a18ebfb2Smrg  /* Relative path | not found in path: prepend cwd */
5248a18ebfb2Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
5249a18ebfb2Smrg    lt_fatal ("getcwd failed");
5250a18ebfb2Smrg  tmp_len = strlen(tmp);
5251a18ebfb2Smrg  concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
5252a18ebfb2Smrg  memcpy (concat_name, tmp, tmp_len);
5253a18ebfb2Smrg  concat_name[tmp_len] = '/';
5254a18ebfb2Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
5255a18ebfb2Smrg
5256a18ebfb2Smrg  if (check_executable(concat_name))
5257a18ebfb2Smrg    return concat_name;
5258a18ebfb2Smrg  XFREE(concat_name);
5259a18ebfb2Smrg  return NULL;
5260a18ebfb2Smrg}
5261a18ebfb2Smrg
5262a18ebfb2Smrgchar *
5263a18ebfb2Smrgstrendzap(char *str, const char *pat)
5264a18ebfb2Smrg{
5265a18ebfb2Smrg  size_t len, patlen;
5266a18ebfb2Smrg
5267a18ebfb2Smrg  assert(str != NULL);
5268a18ebfb2Smrg  assert(pat != NULL);
5269a18ebfb2Smrg
5270a18ebfb2Smrg  len = strlen(str);
5271a18ebfb2Smrg  patlen = strlen(pat);
5272a18ebfb2Smrg
5273a18ebfb2Smrg  if (patlen <= len)
5274a18ebfb2Smrg  {
5275a18ebfb2Smrg    str += len - patlen;
5276a18ebfb2Smrg    if (strcmp(str, pat) == 0)
5277a18ebfb2Smrg      *str = '\0';
5278a18ebfb2Smrg  }
5279a18ebfb2Smrg  return str;
5280a18ebfb2Smrg}
5281a18ebfb2Smrg
5282a18ebfb2Smrgstatic void
5283a18ebfb2Smrglt_error_core (int exit_status, const char * mode,
5284a18ebfb2Smrg          const char * message, va_list ap)
5285a18ebfb2Smrg{
5286a18ebfb2Smrg  fprintf (stderr, "%s: %s: ", program_name, mode);
5287a18ebfb2Smrg  vfprintf (stderr, message, ap);
5288a18ebfb2Smrg  fprintf (stderr, ".\n");
5289a18ebfb2Smrg
5290a18ebfb2Smrg  if (exit_status >= 0)
5291a18ebfb2Smrg    exit (exit_status);
5292a18ebfb2Smrg}
5293a18ebfb2Smrg
5294a18ebfb2Smrgvoid
5295a18ebfb2Smrglt_fatal (const char *message, ...)
5296a18ebfb2Smrg{
5297a18ebfb2Smrg  va_list ap;
5298a18ebfb2Smrg  va_start (ap, message);
5299a18ebfb2Smrg  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
5300a18ebfb2Smrg  va_end (ap);
5301a18ebfb2Smrg}
5302a18ebfb2SmrgEOF
5303a18ebfb2Smrg          # we should really use a build-platform specific compiler
5304a18ebfb2Smrg          # here, but OTOH, the wrappers (shell script and this C one)
5305a18ebfb2Smrg          # are only useful if you want to execute the "real" binary.
5306a18ebfb2Smrg          # Since the "real" binary is built for $host, then this
5307a18ebfb2Smrg          # wrapper might as well be built for $host, too.
5308a18ebfb2Smrg          $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
5309a18ebfb2Smrg          ;;
5310a18ebfb2Smrg        esac
5311a18ebfb2Smrg        $rm $output
5312a18ebfb2Smrg        trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
5313a18ebfb2Smrg
5314a18ebfb2Smrg	$echo > $output "\
5315a18ebfb2Smrg#! $SHELL
5316a18ebfb2Smrg
5317a18ebfb2Smrg# $output - temporary wrapper script for $objdir/$outputname
5318a18ebfb2Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
5319a18ebfb2Smrg#
5320a18ebfb2Smrg# The $output program cannot be directly executed until all the libtool
5321a18ebfb2Smrg# libraries that it depends on are installed.
5322a18ebfb2Smrg#
5323a18ebfb2Smrg# This wrapper script should never be moved out of the build directory.
5324a18ebfb2Smrg# If it is, it will not operate correctly.
5325a18ebfb2Smrg
5326a18ebfb2Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
5327a18ebfb2Smrg# metacharacters that are still active within double-quoted strings.
5328a18ebfb2SmrgXsed='${SED} -e 1s/^X//'
5329a18ebfb2Smrgsed_quote_subst='$sed_quote_subst'
5330a18ebfb2Smrg
5331a18ebfb2Smrg# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE).
5332a18ebfb2Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
5333a18ebfb2Smrg  emulate sh
5334a18ebfb2Smrg  NULLCMD=:
5335a18ebfb2Smrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
5336a18ebfb2Smrg  # is contrary to our usage.  Disable this feature.
5337a18ebfb2Smrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
5338a18ebfb2Smrg  setopt NO_GLOB_SUBST
5339a18ebfb2Smrgelse
5340a18ebfb2Smrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
5341a18ebfb2Smrgfi
5342a18ebfb2SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
5343a18ebfb2SmrgDUALCASE=1; export DUALCASE # for MKS sh
5344a18ebfb2Smrg
5345a18ebfb2Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
5346a18ebfb2Smrg# if CDPATH is set.
5347a18ebfb2Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
5348a18ebfb2Smrg
5349a18ebfb2Smrgrelink_command=\"$relink_command\"
5350a18ebfb2Smrg
5351a18ebfb2Smrg# This environment variable determines our operation mode.
5352a18ebfb2Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
5353a18ebfb2Smrg  # install mode needs the following variable:
5354a18ebfb2Smrg  notinst_deplibs='$notinst_deplibs'
5355a18ebfb2Smrgelse
5356a18ebfb2Smrg  # When we are sourced in execute mode, \$file and \$echo are already set.
5357a18ebfb2Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
5358a18ebfb2Smrg    echo=\"$qecho\"
5359a18ebfb2Smrg    file=\"\$0\"
5360a18ebfb2Smrg    # Make sure echo works.
5361a18ebfb2Smrg    if test \"X\$1\" = X--no-reexec; then
5362a18ebfb2Smrg      # Discard the --no-reexec flag, and continue.
5363a18ebfb2Smrg      shift
5364a18ebfb2Smrg    elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
5365a18ebfb2Smrg      # Yippee, \$echo works!
5366a18ebfb2Smrg      :
5367a18ebfb2Smrg    else
5368a18ebfb2Smrg      # Restart under the correct shell, and then maybe \$echo will work.
5369a18ebfb2Smrg      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
5370a18ebfb2Smrg    fi
5371a18ebfb2Smrg  fi\
5372a18ebfb2Smrg"
5373a18ebfb2Smrg	$echo >> $output "\
537450806d53Smrg
5375a18ebfb2Smrg  # Find the directory that this script lives in.
5376a18ebfb2Smrg  thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
5377a18ebfb2Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
537850806d53Smrg
5379a18ebfb2Smrg  # Follow symbolic links until we get to the real thisdir.
5380a18ebfb2Smrg  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
5381a18ebfb2Smrg  while test -n \"\$file\"; do
5382a18ebfb2Smrg    destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
538350806d53Smrg
5384a18ebfb2Smrg    # If there was a directory component, then change thisdir.
5385a18ebfb2Smrg    if test \"x\$destdir\" != \"x\$file\"; then
5386a18ebfb2Smrg      case \"\$destdir\" in
5387a18ebfb2Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
5388a18ebfb2Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
5389a18ebfb2Smrg      esac
5390a18ebfb2Smrg    fi
539150806d53Smrg
5392a18ebfb2Smrg    file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
5393a18ebfb2Smrg    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
5394a18ebfb2Smrg  done
539550806d53Smrg
5396a18ebfb2Smrg  # Try to get the absolute directory name.
5397a18ebfb2Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
5398a18ebfb2Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
5399a18ebfb2Smrg"
540050806d53Smrg
5401a18ebfb2Smrg	if test "$fast_install" = yes; then
5402a18ebfb2Smrg	  $echo >> $output "\
5403a18ebfb2Smrg  program=lt-'$outputname'$exeext
5404a18ebfb2Smrg  progdir=\"\$thisdir/$objdir\"
540550806d53Smrg
5406a18ebfb2Smrg  if test ! -f \"\$progdir/\$program\" || \\
5407a18ebfb2Smrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
5408a18ebfb2Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
540950806d53Smrg
5410a18ebfb2Smrg    file=\"\$\$-\$program\"
541150806d53Smrg
5412a18ebfb2Smrg    if test ! -d \"\$progdir\"; then
5413a18ebfb2Smrg      $mkdir \"\$progdir\"
5414a18ebfb2Smrg    else
5415a18ebfb2Smrg      $rm \"\$progdir/\$file\"
5416a18ebfb2Smrg    fi"
541750806d53Smrg
5418a18ebfb2Smrg	  $echo >> $output "\
541950806d53Smrg
5420a18ebfb2Smrg    # relink executable if necessary
5421a18ebfb2Smrg    if test -n \"\$relink_command\"; then
5422a18ebfb2Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
5423a18ebfb2Smrg      else
5424a18ebfb2Smrg	$echo \"\$relink_command_output\" >&2
5425a18ebfb2Smrg	$rm \"\$progdir/\$file\"
5426a18ebfb2Smrg	exit $EXIT_FAILURE
5427a18ebfb2Smrg      fi
5428a18ebfb2Smrg    fi
542950806d53Smrg
5430a18ebfb2Smrg    $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
5431a18ebfb2Smrg    { $rm \"\$progdir/\$program\";
5432a18ebfb2Smrg      $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
5433a18ebfb2Smrg    $rm \"\$progdir/\$file\"
5434a18ebfb2Smrg  fi"
5435a18ebfb2Smrg	else
5436a18ebfb2Smrg	  $echo >> $output "\
5437a18ebfb2Smrg  program='$outputname'
5438a18ebfb2Smrg  progdir=\"\$thisdir/$objdir\"
5439a18ebfb2Smrg"
544050806d53Smrg	fi
544150806d53Smrg
5442a18ebfb2Smrg	$echo >> $output "\
544350806d53Smrg
5444a18ebfb2Smrg  if test -f \"\$progdir/\$program\"; then"
544550806d53Smrg
5446a18ebfb2Smrg	# Export our shlibpath_var if we have one.
5447a18ebfb2Smrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5448a18ebfb2Smrg	  $echo >> $output "\
5449a18ebfb2Smrg    # Add our own library path to $shlibpath_var
5450a18ebfb2Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
545150806d53Smrg
5452a18ebfb2Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
5453a18ebfb2Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
5454a18ebfb2Smrg    $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
545550806d53Smrg
5456a18ebfb2Smrg    export $shlibpath_var
5457a18ebfb2Smrg"
5458a18ebfb2Smrg	fi
545950806d53Smrg
5460a18ebfb2Smrg	# fixup the dll searchpath if we need to.
5461a18ebfb2Smrg	if test -n "$dllsearchpath"; then
5462a18ebfb2Smrg	  $echo >> $output "\
5463a18ebfb2Smrg    # Add the dll search path components to the executable PATH
5464a18ebfb2Smrg    PATH=$dllsearchpath:\$PATH
5465a18ebfb2Smrg"
5466a18ebfb2Smrg	fi
5467af1a9c97Smrg
5468a18ebfb2Smrg	$echo >> $output "\
5469a18ebfb2Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
5470a18ebfb2Smrg      # Run the actual program with our arguments.
5471a18ebfb2Smrg"
5472a18ebfb2Smrg	case $host in
5473a18ebfb2Smrg	# Backslashes separate directories on plain windows
5474a18ebfb2Smrg	*-*-mingw | *-*-os2*)
5475a18ebfb2Smrg	  $echo >> $output "\
5476a18ebfb2Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
5477a18ebfb2Smrg"
5478a18ebfb2Smrg	  ;;
547950806d53Smrg
5480a18ebfb2Smrg	*)
5481a18ebfb2Smrg	  $echo >> $output "\
5482a18ebfb2Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
5483a18ebfb2Smrg"
5484a18ebfb2Smrg	  ;;
5485a18ebfb2Smrg	esac
5486a18ebfb2Smrg	$echo >> $output "\
5487a18ebfb2Smrg      \$echo \"\$0: cannot exec \$program \$*\"
5488a18ebfb2Smrg      exit $EXIT_FAILURE
5489a18ebfb2Smrg    fi
5490a18ebfb2Smrg  else
5491a18ebfb2Smrg    # The program doesn't exist.
5492a18ebfb2Smrg    \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
5493a18ebfb2Smrg    \$echo \"This script is just a wrapper for \$program.\" 1>&2
5494a18ebfb2Smrg    $echo \"See the $PACKAGE documentation for more information.\" 1>&2
5495a18ebfb2Smrg    exit $EXIT_FAILURE
5496a18ebfb2Smrg  fi
5497a18ebfb2Smrgfi\
5498a18ebfb2Smrg"
5499a18ebfb2Smrg	chmod +x $output
5500a18ebfb2Smrg      fi
5501a18ebfb2Smrg      exit $EXIT_SUCCESS
5502a18ebfb2Smrg      ;;
5503a18ebfb2Smrg    esac
550450806d53Smrg
5505a18ebfb2Smrg    # See if we need to build an old-fashioned archive.
5506a18ebfb2Smrg    for oldlib in $oldlibs; do
550750806d53Smrg
5508a18ebfb2Smrg      if test "$build_libtool_libs" = convenience; then
5509a18ebfb2Smrg	oldobjs="$libobjs_save"
5510a18ebfb2Smrg	addlibs="$convenience"
5511a18ebfb2Smrg	build_libtool_libs=no
5512a18ebfb2Smrg      else
5513a18ebfb2Smrg	if test "$build_libtool_libs" = module; then
5514a18ebfb2Smrg	  oldobjs="$libobjs_save"
5515a18ebfb2Smrg	  build_libtool_libs=no
5516a18ebfb2Smrg	else
5517a18ebfb2Smrg	  oldobjs="$old_deplibs $non_pic_objects"
5518a18ebfb2Smrg	fi
5519a18ebfb2Smrg	addlibs="$old_convenience"
5520a18ebfb2Smrg      fi
552150806d53Smrg
5522a18ebfb2Smrg      if test -n "$addlibs"; then
5523a18ebfb2Smrg	gentop="$output_objdir/${outputname}x"
5524a18ebfb2Smrg	generated="$generated $gentop"
552550806d53Smrg
5526a18ebfb2Smrg	func_extract_archives $gentop $addlibs
5527a18ebfb2Smrg	oldobjs="$oldobjs $func_extract_archives_result"
5528a18ebfb2Smrg      fi
552950806d53Smrg
5530a18ebfb2Smrg      # Do each command in the archive commands.
5531a18ebfb2Smrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
5532a18ebfb2Smrg       cmds=$old_archive_from_new_cmds
5533a18ebfb2Smrg      else
5534a18ebfb2Smrg	# POSIX demands no paths to be encoded in archives.  We have
5535a18ebfb2Smrg	# to avoid creating archives with duplicate basenames if we
5536a18ebfb2Smrg	# might have to extract them afterwards, e.g., when creating a
5537a18ebfb2Smrg	# static archive out of a convenience library, or when linking
5538a18ebfb2Smrg	# the entirety of a libtool archive into another (currently
5539a18ebfb2Smrg	# not supported by libtool).
5540a18ebfb2Smrg	if (for obj in $oldobjs
5541a18ebfb2Smrg	    do
5542a18ebfb2Smrg	      $echo "X$obj" | $Xsed -e 's%^.*/%%'
5543a18ebfb2Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
5544a18ebfb2Smrg	  :
5545a18ebfb2Smrg	else
5546a18ebfb2Smrg	  $echo "copying selected object files to avoid basename conflicts..."
554750806d53Smrg
5548a18ebfb2Smrg	  if test -z "$gentop"; then
5549a18ebfb2Smrg	    gentop="$output_objdir/${outputname}x"
5550a18ebfb2Smrg	    generated="$generated $gentop"
555150806d53Smrg
5552a18ebfb2Smrg	    $show "${rm}r $gentop"
5553a18ebfb2Smrg	    $run ${rm}r "$gentop"
5554a18ebfb2Smrg	    $show "$mkdir $gentop"
5555a18ebfb2Smrg	    $run $mkdir "$gentop"
5556a18ebfb2Smrg	    exit_status=$?
5557a18ebfb2Smrg	    if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
5558a18ebfb2Smrg	      exit $exit_status
5559af1a9c97Smrg	    fi
5560af1a9c97Smrg	  fi
556150806d53Smrg
5562a18ebfb2Smrg	  save_oldobjs=$oldobjs
5563a18ebfb2Smrg	  oldobjs=
5564a18ebfb2Smrg	  counter=1
5565a18ebfb2Smrg	  for obj in $save_oldobjs
5566a18ebfb2Smrg	  do
5567a18ebfb2Smrg	    objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
5568a18ebfb2Smrg	    case " $oldobjs " in
5569a18ebfb2Smrg	    " ") oldobjs=$obj ;;
5570a18ebfb2Smrg	    *[\ /]"$objbase "*)
5571a18ebfb2Smrg	      while :; do
5572a18ebfb2Smrg		# Make sure we don't pick an alternate name that also
5573a18ebfb2Smrg		# overlaps.
5574a18ebfb2Smrg		newobj=lt$counter-$objbase
5575a18ebfb2Smrg		counter=`expr $counter + 1`
5576a18ebfb2Smrg		case " $oldobjs " in
5577a18ebfb2Smrg		*[\ /]"$newobj "*) ;;
5578a18ebfb2Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
5579a18ebfb2Smrg		esac
5580a18ebfb2Smrg	      done
5581a18ebfb2Smrg	      $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
5582a18ebfb2Smrg	      $run ln "$obj" "$gentop/$newobj" ||
5583a18ebfb2Smrg	      $run cp "$obj" "$gentop/$newobj"
5584a18ebfb2Smrg	      oldobjs="$oldobjs $gentop/$newobj"
5585a18ebfb2Smrg	      ;;
5586a18ebfb2Smrg	    *) oldobjs="$oldobjs $obj" ;;
5587a18ebfb2Smrg	    esac
5588a18ebfb2Smrg	  done
5589a18ebfb2Smrg	fi
559050806d53Smrg
5591a18ebfb2Smrg	eval cmds=\"$old_archive_cmds\"
559250806d53Smrg
5593a18ebfb2Smrg	if len=`expr "X$cmds" : ".*"` &&
5594a18ebfb2Smrg	     test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
5595a18ebfb2Smrg	  cmds=$old_archive_cmds
5596a18ebfb2Smrg	else
5597a18ebfb2Smrg	  # the command line is too long to link in one step, link in parts
5598a18ebfb2Smrg	  $echo "using piecewise archive linking..."
5599a18ebfb2Smrg	  save_RANLIB=$RANLIB
5600a18ebfb2Smrg	  RANLIB=:
5601a18ebfb2Smrg	  objlist=
5602a18ebfb2Smrg	  concat_cmds=
5603a18ebfb2Smrg	  save_oldobjs=$oldobjs
5604a18ebfb2Smrg
5605a18ebfb2Smrg	  # Is there a better way of finding the last object in the list?
5606a18ebfb2Smrg	  for obj in $save_oldobjs
5607a18ebfb2Smrg	  do
5608a18ebfb2Smrg	    last_oldobj=$obj
5609a18ebfb2Smrg	  done
5610a18ebfb2Smrg	  for obj in $save_oldobjs
5611a18ebfb2Smrg	  do
5612a18ebfb2Smrg	    oldobjs="$objlist $obj"
5613a18ebfb2Smrg	    objlist="$objlist $obj"
5614a18ebfb2Smrg	    eval test_cmds=\"$old_archive_cmds\"
5615a18ebfb2Smrg	    if len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
5616a18ebfb2Smrg	       test "$len" -le "$max_cmd_len"; then
5617a18ebfb2Smrg	      :
5618af1a9c97Smrg	    else
5619a18ebfb2Smrg	      # the above command should be used before it gets too long
5620a18ebfb2Smrg	      oldobjs=$objlist
5621a18ebfb2Smrg	      if test "$obj" = "$last_oldobj" ; then
5622a18ebfb2Smrg	        RANLIB=$save_RANLIB
5623a18ebfb2Smrg	      fi
5624a18ebfb2Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
5625a18ebfb2Smrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
5626a18ebfb2Smrg	      objlist=
562750806d53Smrg	    fi
5628a18ebfb2Smrg	  done
5629a18ebfb2Smrg	  RANLIB=$save_RANLIB
5630a18ebfb2Smrg	  oldobjs=$objlist
5631a18ebfb2Smrg	  if test "X$oldobjs" = "X" ; then
5632a18ebfb2Smrg	    eval cmds=\"\$concat_cmds\"
563350806d53Smrg	  else
5634a18ebfb2Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
563550806d53Smrg	  fi
5636af1a9c97Smrg	fi
5637a18ebfb2Smrg      fi
5638a18ebfb2Smrg      save_ifs="$IFS"; IFS='~'
5639a18ebfb2Smrg      for cmd in $cmds; do
5640a18ebfb2Smrg        eval cmd=\"$cmd\"
5641af1a9c97Smrg	IFS="$save_ifs"
5642a18ebfb2Smrg	$show "$cmd"
5643a18ebfb2Smrg	$run eval "$cmd" || exit $?
5644a18ebfb2Smrg      done
5645a18ebfb2Smrg      IFS="$save_ifs"
5646a18ebfb2Smrg    done
564750806d53Smrg
5648a18ebfb2Smrg    if test -n "$generated"; then
5649a18ebfb2Smrg      $show "${rm}r$generated"
5650a18ebfb2Smrg      $run ${rm}r$generated
5651a18ebfb2Smrg    fi
5652af1a9c97Smrg
5653a18ebfb2Smrg    # Now create the libtool archive.
5654a18ebfb2Smrg    case $output in
5655a18ebfb2Smrg    *.la)
5656a18ebfb2Smrg      old_library=
5657a18ebfb2Smrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
5658a18ebfb2Smrg      $show "creating $output"
565950806d53Smrg
5660a18ebfb2Smrg      # Preserve any variables that may affect compiler behavior
5661a18ebfb2Smrg      for var in $variables_saved_for_relink; do
5662a18ebfb2Smrg	if eval test -z \"\${$var+set}\"; then
5663a18ebfb2Smrg	  relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
5664a18ebfb2Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
5665a18ebfb2Smrg	  relink_command="$var=; export $var; $relink_command"
5666a18ebfb2Smrg	else
5667a18ebfb2Smrg	  var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
5668a18ebfb2Smrg	  relink_command="$var=\"$var_value\"; export $var; $relink_command"
5669af1a9c97Smrg	fi
5670a18ebfb2Smrg      done
5671a18ebfb2Smrg      # Quote the link command for shipping.
5672a18ebfb2Smrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
5673a18ebfb2Smrg      relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e "$sed_quote_subst" | $NL2SP`
5674a18ebfb2Smrg      if test "$hardcode_automatic" = yes ; then
5675a18ebfb2Smrg	relink_command=
5676af1a9c97Smrg      fi
567750806d53Smrg
567850806d53Smrg
5679a18ebfb2Smrg      # Only create the output if not a dry run.
5680a18ebfb2Smrg      if test -z "$run"; then
5681a18ebfb2Smrg	for installed in no yes; do
5682a18ebfb2Smrg	  if test "$installed" = yes; then
5683a18ebfb2Smrg	    if test -z "$install_libdir"; then
5684a18ebfb2Smrg	      break
5685a18ebfb2Smrg	    fi
5686a18ebfb2Smrg	    output="$output_objdir/$outputname"i
5687a18ebfb2Smrg	    # Replace all uninstalled libtool libraries with the installed ones
5688a18ebfb2Smrg	    newdependency_libs=
5689a18ebfb2Smrg	    for deplib in $dependency_libs; do
5690a18ebfb2Smrg	      case $deplib in
5691a18ebfb2Smrg	      *.la)
5692a18ebfb2Smrg		name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
5693a18ebfb2Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
5694a18ebfb2Smrg		if test -z "$libdir"; then
5695a18ebfb2Smrg		  $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
5696a18ebfb2Smrg		  exit $EXIT_FAILURE
5697a18ebfb2Smrg		fi
5698a18ebfb2Smrg		newdependency_libs="$newdependency_libs $libdir/$name"
5699a18ebfb2Smrg		;;
5700a18ebfb2Smrg	      *) newdependency_libs="$newdependency_libs $deplib" ;;
5701a18ebfb2Smrg	      esac
5702a18ebfb2Smrg	    done
5703a18ebfb2Smrg	    dependency_libs="$newdependency_libs"
5704a18ebfb2Smrg	    newdlfiles=
5705a18ebfb2Smrg	    for lib in $dlfiles; do
5706a18ebfb2Smrg	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
5707a18ebfb2Smrg	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
5708a18ebfb2Smrg	      if test -z "$libdir"; then
5709a18ebfb2Smrg		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
5710a18ebfb2Smrg		exit $EXIT_FAILURE
5711a18ebfb2Smrg	      fi
5712a18ebfb2Smrg	      newdlfiles="$newdlfiles $libdir/$name"
5713a18ebfb2Smrg	    done
5714a18ebfb2Smrg	    dlfiles="$newdlfiles"
5715a18ebfb2Smrg	    newdlprefiles=
5716a18ebfb2Smrg	    for lib in $dlprefiles; do
5717a18ebfb2Smrg	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
5718a18ebfb2Smrg	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
5719a18ebfb2Smrg	      if test -z "$libdir"; then
5720a18ebfb2Smrg		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
5721a18ebfb2Smrg		exit $EXIT_FAILURE
5722a18ebfb2Smrg	      fi
5723a18ebfb2Smrg	      newdlprefiles="$newdlprefiles $libdir/$name"
5724a18ebfb2Smrg	    done
5725a18ebfb2Smrg	    dlprefiles="$newdlprefiles"
5726a18ebfb2Smrg	  else
5727a18ebfb2Smrg	    newdlfiles=
5728a18ebfb2Smrg	    for lib in $dlfiles; do
5729a18ebfb2Smrg	      case $lib in
5730a18ebfb2Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
5731a18ebfb2Smrg		*) abs=`pwd`"/$lib" ;;
5732a18ebfb2Smrg	      esac
5733a18ebfb2Smrg	      newdlfiles="$newdlfiles $abs"
5734a18ebfb2Smrg	    done
5735a18ebfb2Smrg	    dlfiles="$newdlfiles"
5736a18ebfb2Smrg	    newdlprefiles=
5737a18ebfb2Smrg	    for lib in $dlprefiles; do
5738a18ebfb2Smrg	      case $lib in
5739a18ebfb2Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
5740a18ebfb2Smrg		*) abs=`pwd`"/$lib" ;;
5741a18ebfb2Smrg	      esac
5742a18ebfb2Smrg	      newdlprefiles="$newdlprefiles $abs"
5743a18ebfb2Smrg	    done
5744a18ebfb2Smrg	    dlprefiles="$newdlprefiles"
5745a18ebfb2Smrg	  fi
5746a18ebfb2Smrg	  $rm $output
5747a18ebfb2Smrg	  # place dlname in correct position for cygwin
5748a18ebfb2Smrg	  tdlname=$dlname
5749a18ebfb2Smrg	  case $host,$output,$installed,$module,$dlname in
5750a18ebfb2Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
5751a18ebfb2Smrg	  esac
5752a18ebfb2Smrg	  $echo > $output "\
5753a18ebfb2Smrg# $outputname - a libtool library file
5754a18ebfb2Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
5755a18ebfb2Smrg#
5756a18ebfb2Smrg# Please DO NOT delete this file!
5757a18ebfb2Smrg# It is necessary for linking the library.
575850806d53Smrg
5759a18ebfb2Smrg# The name that we can dlopen(3).
5760a18ebfb2Smrgdlname='$tdlname'
576150806d53Smrg
5762a18ebfb2Smrg# Names of this library.
5763a18ebfb2Smrglibrary_names='$library_names'
576450806d53Smrg
5765a18ebfb2Smrg# The name of the static archive.
5766a18ebfb2Smrgold_library='$old_library'
576750806d53Smrg
5768a18ebfb2Smrg# Libraries that this one depends upon.
5769a18ebfb2Smrgdependency_libs='$dependency_libs'
5770af1a9c97Smrg
5771a18ebfb2Smrg# Version information for $libname.
5772a18ebfb2Smrgcurrent=$current
5773a18ebfb2Smrgage=$age
5774a18ebfb2Smrgrevision=$revision
5775af1a9c97Smrg
5776a18ebfb2Smrg# Is this an already installed library?
5777a18ebfb2Smrginstalled=$installed
5778af1a9c97Smrg
5779a18ebfb2Smrg# Should we warn about portability when linking against -modules?
5780a18ebfb2Smrgshouldnotlink=$module
5781af1a9c97Smrg
5782a18ebfb2Smrg# Files to dlopen/dlpreopen
5783a18ebfb2Smrgdlopen='$dlfiles'
5784a18ebfb2Smrgdlpreopen='$dlprefiles'
5785af1a9c97Smrg
5786a18ebfb2Smrg# Directory that this library needs to be installed in:
5787a18ebfb2Smrglibdir='$install_libdir'"
5788a18ebfb2Smrg	  if test "$installed" = no && test "$need_relink" = yes; then
5789a18ebfb2Smrg	    $echo >> $output "\
5790a18ebfb2Smrgrelink_command=\"$relink_command\""
5791a18ebfb2Smrg	  fi
5792a18ebfb2Smrg	done
5793af1a9c97Smrg      fi
5794af1a9c97Smrg
5795a18ebfb2Smrg      # Do a symbolic link so that the libtool archive can be found in
5796a18ebfb2Smrg      # LD_LIBRARY_PATH before the program is installed.
5797a18ebfb2Smrg      $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
5798a18ebfb2Smrg      $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $?
579950806d53Smrg      ;;
5800a18ebfb2Smrg    esac
5801a18ebfb2Smrg    exit $EXIT_SUCCESS
5802a18ebfb2Smrg    ;;
580350806d53Smrg
5804a18ebfb2Smrg  # libtool install mode
5805a18ebfb2Smrg  install)
5806a18ebfb2Smrg    modename="$modename: install"
5807a18ebfb2Smrg
5808a18ebfb2Smrg    # There may be an optional sh(1) argument at the beginning of
5809a18ebfb2Smrg    # install_prog (especially on Windows NT).
5810a18ebfb2Smrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
5811a18ebfb2Smrg       # Allow the use of GNU shtool's install command.
5812a18ebfb2Smrg       $echo "X$nonopt" | grep shtool > /dev/null; then
5813a18ebfb2Smrg      # Aesthetically quote it.
5814a18ebfb2Smrg      arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
5815a18ebfb2Smrg      case $arg in
5816a18ebfb2Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
5817a18ebfb2Smrg	arg="\"$arg\""
5818a18ebfb2Smrg	;;
5819af1a9c97Smrg      esac
5820a18ebfb2Smrg      install_prog="$arg "
5821a18ebfb2Smrg      arg="$1"
5822a18ebfb2Smrg      shift
5823a18ebfb2Smrg    else
5824a18ebfb2Smrg      install_prog=
5825a18ebfb2Smrg      arg=$nonopt
5826a18ebfb2Smrg    fi
582750806d53Smrg
5828a18ebfb2Smrg    # The real first argument should be the name of the installation program.
5829a18ebfb2Smrg    # Aesthetically quote it.
5830a18ebfb2Smrg    arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
5831a18ebfb2Smrg    case $arg in
5832a18ebfb2Smrg    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
5833a18ebfb2Smrg      arg="\"$arg\""
5834a18ebfb2Smrg      ;;
5835a18ebfb2Smrg    esac
5836a18ebfb2Smrg    install_prog="$install_prog$arg"
583750806d53Smrg
5838a18ebfb2Smrg    # We need to accept at least all the BSD install flags.
5839a18ebfb2Smrg    dest=
5840a18ebfb2Smrg    files=
5841a18ebfb2Smrg    opts=
5842a18ebfb2Smrg    prev=
5843a18ebfb2Smrg    install_type=
5844a18ebfb2Smrg    isdir=no
5845a18ebfb2Smrg    stripme=
5846a18ebfb2Smrg    for arg
5847a18ebfb2Smrg    do
5848a18ebfb2Smrg      if test -n "$dest"; then
5849a18ebfb2Smrg	files="$files $dest"
5850a18ebfb2Smrg	dest=$arg
5851a18ebfb2Smrg	continue
5852a18ebfb2Smrg      fi
5853af1a9c97Smrg
5854a18ebfb2Smrg      case $arg in
5855a18ebfb2Smrg      -d) isdir=yes ;;
5856a18ebfb2Smrg      -f) 
5857a18ebfb2Smrg      	case " $install_prog " in
5858a18ebfb2Smrg	*[\\\ /]cp\ *) ;;
5859a18ebfb2Smrg	*) prev=$arg ;;
5860a18ebfb2Smrg	esac
5861a18ebfb2Smrg	;;
5862a18ebfb2Smrg      -g | -m | -o) prev=$arg ;;
5863a18ebfb2Smrg      -s)
5864a18ebfb2Smrg	stripme=" -s"
5865a18ebfb2Smrg	continue
5866a18ebfb2Smrg	;;
5867a18ebfb2Smrg      -*)
5868a18ebfb2Smrg	;;
5869a18ebfb2Smrg      *)
5870a18ebfb2Smrg	# If the previous option needed an argument, then skip it.
5871a18ebfb2Smrg	if test -n "$prev"; then
5872a18ebfb2Smrg	  prev=
5873a18ebfb2Smrg	else
5874a18ebfb2Smrg	  dest=$arg
5875a18ebfb2Smrg	  continue
5876a18ebfb2Smrg	fi
587750806d53Smrg	;;
5878af1a9c97Smrg      esac
587950806d53Smrg
5880a18ebfb2Smrg      # Aesthetically quote the argument.
5881a18ebfb2Smrg      arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
5882a18ebfb2Smrg      case $arg in
5883a18ebfb2Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
5884a18ebfb2Smrg	arg="\"$arg\""
5885af1a9c97Smrg	;;
5886af1a9c97Smrg      esac
5887a18ebfb2Smrg      install_prog="$install_prog $arg"
5888a18ebfb2Smrg    done
588950806d53Smrg
5890a18ebfb2Smrg    if test -z "$install_prog"; then
5891a18ebfb2Smrg      $echo "$modename: you must specify an install program" 1>&2
5892a18ebfb2Smrg      $echo "$help" 1>&2
5893a18ebfb2Smrg      exit $EXIT_FAILURE
5894a18ebfb2Smrg    fi
589550806d53Smrg
5896a18ebfb2Smrg    if test -n "$prev"; then
5897a18ebfb2Smrg      $echo "$modename: the \`$prev' option requires an argument" 1>&2
5898a18ebfb2Smrg      $echo "$help" 1>&2
5899a18ebfb2Smrg      exit $EXIT_FAILURE
5900a18ebfb2Smrg    fi
5901a18ebfb2Smrg
5902a18ebfb2Smrg    if test -z "$files"; then
5903a18ebfb2Smrg      if test -z "$dest"; then
5904a18ebfb2Smrg	$echo "$modename: no file or destination specified" 1>&2
5905a18ebfb2Smrg      else
5906a18ebfb2Smrg	$echo "$modename: you must specify a destination" 1>&2
5907a18ebfb2Smrg      fi
5908a18ebfb2Smrg      $echo "$help" 1>&2
5909a18ebfb2Smrg      exit $EXIT_FAILURE
5910a18ebfb2Smrg    fi
5911a18ebfb2Smrg
5912a18ebfb2Smrg    # Strip any trailing slash from the destination.
5913a18ebfb2Smrg    dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
5914a18ebfb2Smrg
5915a18ebfb2Smrg    # Check to see that the destination is a directory.
5916a18ebfb2Smrg    test -d "$dest" && isdir=yes
5917a18ebfb2Smrg    if test "$isdir" = yes; then
5918a18ebfb2Smrg      destdir="$dest"
5919a18ebfb2Smrg      destname=
5920a18ebfb2Smrg    else
5921a18ebfb2Smrg      destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
5922a18ebfb2Smrg      test "X$destdir" = "X$dest" && destdir=.
5923a18ebfb2Smrg      destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
5924a18ebfb2Smrg
5925a18ebfb2Smrg      # Not a directory, so check to see that there is only one file specified.
5926a18ebfb2Smrg      set dummy $files
5927a18ebfb2Smrg      if test "$#" -gt 2; then
5928a18ebfb2Smrg	$echo "$modename: \`$dest' is not a directory" 1>&2
5929a18ebfb2Smrg	$echo "$help" 1>&2
5930a18ebfb2Smrg	exit $EXIT_FAILURE
5931a18ebfb2Smrg      fi
5932a18ebfb2Smrg    fi
5933a18ebfb2Smrg    case $destdir in
5934a18ebfb2Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
5935a18ebfb2Smrg    *)
5936a18ebfb2Smrg      for file in $files; do
5937a18ebfb2Smrg	case $file in
5938a18ebfb2Smrg	*.lo) ;;
5939af1a9c97Smrg	*)
5940a18ebfb2Smrg	  $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
5941a18ebfb2Smrg	  $echo "$help" 1>&2
5942a18ebfb2Smrg	  exit $EXIT_FAILURE
5943af1a9c97Smrg	  ;;
5944af1a9c97Smrg	esac
5945af1a9c97Smrg      done
5946a18ebfb2Smrg      ;;
5947a18ebfb2Smrg    esac
594850806d53Smrg
5949a18ebfb2Smrg    # This variable tells wrapper scripts just to set variables rather
5950a18ebfb2Smrg    # than running their programs.
5951a18ebfb2Smrg    libtool_install_magic="$magic"
595250806d53Smrg
5953a18ebfb2Smrg    staticlibs=
5954a18ebfb2Smrg    future_libdirs=
5955a18ebfb2Smrg    current_libdirs=
5956a18ebfb2Smrg    for file in $files; do
595750806d53Smrg
5958a18ebfb2Smrg      # Do each installation.
5959a18ebfb2Smrg      case $file in
5960a18ebfb2Smrg      *.$libext)
5961a18ebfb2Smrg	# Do the static libraries later.
5962a18ebfb2Smrg	staticlibs="$staticlibs $file"
5963a18ebfb2Smrg	;;
5964a18ebfb2Smrg
5965a18ebfb2Smrg      *.la)
5966a18ebfb2Smrg	# Check to see that this really is a libtool archive.
5967a18ebfb2Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
5968a18ebfb2Smrg	else
5969a18ebfb2Smrg	  $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
5970a18ebfb2Smrg	  $echo "$help" 1>&2
5971a18ebfb2Smrg	  exit $EXIT_FAILURE
5972a18ebfb2Smrg	fi
5973a18ebfb2Smrg
5974a18ebfb2Smrg	library_names=
5975a18ebfb2Smrg	old_library=
5976a18ebfb2Smrg	relink_command=
5977a18ebfb2Smrg	# If there is no directory component, then add one.
5978a18ebfb2Smrg	case $file in
5979a18ebfb2Smrg	*/* | *\\*) . $file ;;
5980a18ebfb2Smrg	*) . ./$file ;;
5981a18ebfb2Smrg	esac
5982a18ebfb2Smrg
5983a18ebfb2Smrg	# Add the libdir to current_libdirs if it is the destination.
5984a18ebfb2Smrg	if test "X$destdir" = "X$libdir"; then
5985a18ebfb2Smrg	  case "$current_libdirs " in
5986af1a9c97Smrg	  *" $libdir "*) ;;
5987a18ebfb2Smrg	  *) current_libdirs="$current_libdirs $libdir" ;;
5988af1a9c97Smrg	  esac
5989a18ebfb2Smrg	else
5990a18ebfb2Smrg	  # Note the libdir as a future libdir.
5991a18ebfb2Smrg	  case "$future_libdirs " in
5992af1a9c97Smrg	  *" $libdir "*) ;;
5993a18ebfb2Smrg	  *) future_libdirs="$future_libdirs $libdir" ;;
5994af1a9c97Smrg	  esac
5995af1a9c97Smrg	fi
599650806d53Smrg
5997a18ebfb2Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/
5998a18ebfb2Smrg	test "X$dir" = "X$file/" && dir=
5999a18ebfb2Smrg	dir="$dir$objdir"
6000a18ebfb2Smrg
6001a18ebfb2Smrg	if test -n "$relink_command"; then
6002a18ebfb2Smrg	  # Determine the prefix the user has applied to our future dir.
6003a18ebfb2Smrg	  inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"`
6004a18ebfb2Smrg
6005a18ebfb2Smrg	  # Don't allow the user to place us outside of our expected
6006a18ebfb2Smrg	  # location b/c this prevents finding dependent libraries that
6007a18ebfb2Smrg	  # are installed to the same prefix.
6008a18ebfb2Smrg	  # At present, this check doesn't affect windows .dll's that
6009a18ebfb2Smrg	  # are installed into $libdir/../bin (currently, that works fine)
6010a18ebfb2Smrg	  # but it's something to keep an eye on.
6011a18ebfb2Smrg	  if test "$inst_prefix_dir" = "$destdir"; then
6012a18ebfb2Smrg	    $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
6013a18ebfb2Smrg	    exit $EXIT_FAILURE
6014a18ebfb2Smrg	  fi
6015a18ebfb2Smrg
6016a18ebfb2Smrg	  if test -n "$inst_prefix_dir"; then
6017a18ebfb2Smrg	    # Stick the inst_prefix_dir data into the link command.
6018a18ebfb2Smrg	    relink_command=`$echo "$relink_command" | $SP2NL | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%" | $NL2SP`
6019a18ebfb2Smrg	  else
6020a18ebfb2Smrg	    relink_command=`$echo "$relink_command" | $SP2NL | $SED "s%@inst_prefix_dir@%%" | $NL2SP`
6021a18ebfb2Smrg	  fi
6022a18ebfb2Smrg
6023a18ebfb2Smrg	  $echo "$modename: warning: relinking \`$file'" 1>&2
6024a18ebfb2Smrg	  $show "$relink_command"
6025a18ebfb2Smrg	  if $run eval "$relink_command"; then :
602650806d53Smrg	  else
6027a18ebfb2Smrg	    $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
6028a18ebfb2Smrg	    exit $EXIT_FAILURE
602950806d53Smrg	  fi
603050806d53Smrg	fi
603150806d53Smrg
6032a18ebfb2Smrg	# See the names of the shared library.
6033a18ebfb2Smrg	set dummy $library_names
6034a18ebfb2Smrg	if test -n "$2"; then
6035a18ebfb2Smrg	  realname="$2"
6036a18ebfb2Smrg	  shift
6037a18ebfb2Smrg	  shift
603850806d53Smrg
6039a18ebfb2Smrg	  srcname="$realname"
6040a18ebfb2Smrg	  test -n "$relink_command" && srcname="$realname"T
604150806d53Smrg
6042a18ebfb2Smrg	  # Install the shared library and build the symlinks.
6043a18ebfb2Smrg	  $show "$install_prog $dir/$srcname $destdir/$realname"
6044a18ebfb2Smrg	  $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $?
6045a18ebfb2Smrg	  if test -n "$stripme" && test -n "$striplib"; then
6046a18ebfb2Smrg	    $show "$striplib $destdir/$realname"
6047a18ebfb2Smrg	    $run eval "$striplib $destdir/$realname" || exit $?
6048a18ebfb2Smrg	  fi
604950806d53Smrg
6050a18ebfb2Smrg	  if test "$#" -gt 0; then
6051a18ebfb2Smrg	    # Delete the old symlinks, and create new ones.
6052a18ebfb2Smrg	    # Try `ln -sf' first, because the `ln' binary might depend on
6053a18ebfb2Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
6054a18ebfb2Smrg	    # so we also need to try rm && ln -s.
6055a18ebfb2Smrg	    for linkname
6056a18ebfb2Smrg	    do
6057a18ebfb2Smrg	      if test "$linkname" != "$realname"; then
6058a18ebfb2Smrg                $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
6059a18ebfb2Smrg                $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
6060a18ebfb2Smrg	      fi
6061a18ebfb2Smrg	    done
6062a18ebfb2Smrg	  fi
606350806d53Smrg
6064a18ebfb2Smrg	  # Do each command in the postinstall commands.
6065a18ebfb2Smrg	  lib="$destdir/$realname"
6066a18ebfb2Smrg	  cmds=$postinstall_cmds
6067a18ebfb2Smrg	  save_ifs="$IFS"; IFS='~'
6068a18ebfb2Smrg	  for cmd in $cmds; do
6069a18ebfb2Smrg	    IFS="$save_ifs"
6070a18ebfb2Smrg	    eval cmd=\"$cmd\"
6071a18ebfb2Smrg	    $show "$cmd"
6072a18ebfb2Smrg	    $run eval "$cmd" || {
6073a18ebfb2Smrg	      lt_exit=$?
6074a18ebfb2Smrg
6075a18ebfb2Smrg	      # Restore the uninstalled library and exit
6076a18ebfb2Smrg	      if test "$mode" = relink; then
6077a18ebfb2Smrg		$run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
6078a18ebfb2Smrg	      fi
607950806d53Smrg
6080a18ebfb2Smrg	      exit $lt_exit
6081a18ebfb2Smrg	    }
6082a18ebfb2Smrg	  done
6083a18ebfb2Smrg	  IFS="$save_ifs"
608450806d53Smrg	fi
608550806d53Smrg
6086a18ebfb2Smrg	# Install the pseudo-library for information purposes.
6087a18ebfb2Smrg	name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
6088a18ebfb2Smrg	instname="$dir/$name"i
6089a18ebfb2Smrg	$show "$install_prog $instname $destdir/$name"
6090a18ebfb2Smrg	$run eval "$install_prog $instname $destdir/$name" || exit $?
609150806d53Smrg
6092a18ebfb2Smrg	# Maybe install the static library, too.
6093a18ebfb2Smrg	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
6094a18ebfb2Smrg	;;
609550806d53Smrg
6096a18ebfb2Smrg      *.lo)
6097a18ebfb2Smrg	# Install (i.e. copy) a libtool object.
6098a18ebfb2Smrg
6099a18ebfb2Smrg	# Figure out destination file name, if it wasn't already specified.
6100a18ebfb2Smrg	if test -n "$destname"; then
6101a18ebfb2Smrg	  destfile="$destdir/$destname"
6102a18ebfb2Smrg	else
6103a18ebfb2Smrg	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
6104a18ebfb2Smrg	  destfile="$destdir/$destfile"
610550806d53Smrg	fi
6106a18ebfb2Smrg
6107a18ebfb2Smrg	# Deduce the name of the destination old-style object file.
6108a18ebfb2Smrg	case $destfile in
6109a18ebfb2Smrg	*.lo)
6110a18ebfb2Smrg	  staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
6111a18ebfb2Smrg	  ;;
6112a18ebfb2Smrg	*.$objext)
6113a18ebfb2Smrg	  staticdest="$destfile"
6114a18ebfb2Smrg	  destfile=
6115a18ebfb2Smrg	  ;;
6116a18ebfb2Smrg	*)
6117a18ebfb2Smrg	  $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
6118a18ebfb2Smrg	  $echo "$help" 1>&2
6119a18ebfb2Smrg	  exit $EXIT_FAILURE
6120a18ebfb2Smrg	  ;;
6121a18ebfb2Smrg	esac
6122a18ebfb2Smrg
6123a18ebfb2Smrg	# Install the libtool object if requested.
6124a18ebfb2Smrg	if test -n "$destfile"; then
6125a18ebfb2Smrg	  $show "$install_prog $file $destfile"
6126a18ebfb2Smrg	  $run eval "$install_prog $file $destfile" || exit $?
612750806d53Smrg	fi
612850806d53Smrg
6129a18ebfb2Smrg	# Install the old object if enabled.
6130a18ebfb2Smrg	if test "$build_old_libs" = yes; then
6131a18ebfb2Smrg	  # Deduce the name of the old-style object file.
6132a18ebfb2Smrg	  staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
613350806d53Smrg
6134a18ebfb2Smrg	  $show "$install_prog $staticobj $staticdest"
6135a18ebfb2Smrg	  $run eval "$install_prog \$staticobj \$staticdest" || exit $?
6136a18ebfb2Smrg	fi
6137a18ebfb2Smrg	exit $EXIT_SUCCESS
6138a18ebfb2Smrg	;;
6139af1a9c97Smrg
6140a18ebfb2Smrg      *)
6141a18ebfb2Smrg	# Figure out destination file name, if it wasn't already specified.
6142a18ebfb2Smrg	if test -n "$destname"; then
6143a18ebfb2Smrg	  destfile="$destdir/$destname"
614450806d53Smrg	else
6145a18ebfb2Smrg	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
6146a18ebfb2Smrg	  destfile="$destdir/$destfile"
614750806d53Smrg	fi
614850806d53Smrg
6149a18ebfb2Smrg	# If the file is missing, and there is a .exe on the end, strip it
6150a18ebfb2Smrg	# because it is most likely a libtool script we actually want to
6151a18ebfb2Smrg	# install
6152a18ebfb2Smrg	stripped_ext=""
6153a18ebfb2Smrg	case $file in
6154a18ebfb2Smrg	  *.exe)
6155a18ebfb2Smrg	    if test ! -f "$file"; then
6156a18ebfb2Smrg	      file=`$echo $file|${SED} 's,.exe$,,'`
6157a18ebfb2Smrg	      stripped_ext=".exe"
6158a18ebfb2Smrg	    fi
6159a18ebfb2Smrg	    ;;
6160a18ebfb2Smrg	esac
616150806d53Smrg
6162a18ebfb2Smrg	# Do a test to see if this is really a libtool program.
6163a18ebfb2Smrg	case $host in
6164a18ebfb2Smrg	*cygwin*|*mingw*)
6165a18ebfb2Smrg	    wrapper=`$echo $file | ${SED} -e 's,.exe$,,'`
6166a18ebfb2Smrg	    ;;
6167a18ebfb2Smrg	*)
6168a18ebfb2Smrg	    wrapper=$file
6169a18ebfb2Smrg	    ;;
6170a18ebfb2Smrg	esac
6171a18ebfb2Smrg	if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then
6172a18ebfb2Smrg	  notinst_deplibs=
6173a18ebfb2Smrg	  relink_command=
617450806d53Smrg
6175a18ebfb2Smrg	  # Note that it is not necessary on cygwin/mingw to append a dot to
6176a18ebfb2Smrg	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
6177a18ebfb2Smrg	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
6178a18ebfb2Smrg	  # `FILE.' does not work on cygwin managed mounts.
6179a18ebfb2Smrg	  #
6180a18ebfb2Smrg	  # If there is no directory component, then add one.
6181a18ebfb2Smrg	  case $wrapper in
6182a18ebfb2Smrg	  */* | *\\*) . ${wrapper} ;;
6183a18ebfb2Smrg	  *) . ./${wrapper} ;;
6184a18ebfb2Smrg	  esac
618550806d53Smrg
6186a18ebfb2Smrg	  # Check the variables that should have been set.
6187a18ebfb2Smrg	  if test -z "$notinst_deplibs"; then
6188a18ebfb2Smrg	    $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2
6189a18ebfb2Smrg	    exit $EXIT_FAILURE
6190a18ebfb2Smrg	  fi
619150806d53Smrg
6192a18ebfb2Smrg	  finalize=yes
6193a18ebfb2Smrg	  for lib in $notinst_deplibs; do
6194a18ebfb2Smrg	    # Check to see that each library is installed.
6195a18ebfb2Smrg	    libdir=
6196a18ebfb2Smrg	    if test -f "$lib"; then
6197a18ebfb2Smrg	      # If there is no directory component, then add one.
6198a18ebfb2Smrg	      case $lib in
6199a18ebfb2Smrg	      */* | *\\*) . $lib ;;
6200a18ebfb2Smrg	      *) . ./$lib ;;
6201a18ebfb2Smrg	      esac
6202a18ebfb2Smrg	    fi
6203a18ebfb2Smrg	    libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
6204a18ebfb2Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
6205a18ebfb2Smrg	      $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
6206a18ebfb2Smrg	      finalize=no
6207a18ebfb2Smrg	    fi
6208a18ebfb2Smrg	  done
6209a18ebfb2Smrg
6210a18ebfb2Smrg	  relink_command=
6211a18ebfb2Smrg	  # Note that it is not necessary on cygwin/mingw to append a dot to
6212a18ebfb2Smrg	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
6213a18ebfb2Smrg	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
6214a18ebfb2Smrg	  # `FILE.' does not work on cygwin managed mounts.
6215a18ebfb2Smrg	  #
6216a18ebfb2Smrg	  # If there is no directory component, then add one.
6217a18ebfb2Smrg	  case $wrapper in
6218a18ebfb2Smrg	  */* | *\\*) . ${wrapper} ;;
6219a18ebfb2Smrg	  *) . ./${wrapper} ;;
6220a18ebfb2Smrg	  esac
6221a18ebfb2Smrg
6222a18ebfb2Smrg	  outputname=
6223a18ebfb2Smrg	  if test "$fast_install" = no && test -n "$relink_command"; then
6224a18ebfb2Smrg	    if test "$finalize" = yes && test -z "$run"; then
6225a18ebfb2Smrg	      tmpdir=`func_mktempdir`
6226a18ebfb2Smrg	      file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
6227a18ebfb2Smrg	      outputname="$tmpdir/$file"
6228a18ebfb2Smrg	      # Replace the output file specification.
6229a18ebfb2Smrg	      relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g' | $NL2SP`
6230a18ebfb2Smrg
6231a18ebfb2Smrg	      $show "$relink_command"
6232a18ebfb2Smrg	      if $run eval "$relink_command"; then :
6233a18ebfb2Smrg	      else
6234a18ebfb2Smrg		$echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
6235a18ebfb2Smrg		${rm}r "$tmpdir"
6236a18ebfb2Smrg		continue
6237a18ebfb2Smrg	      fi
6238a18ebfb2Smrg	      file="$outputname"
6239a18ebfb2Smrg	    else
6240a18ebfb2Smrg	      $echo "$modename: warning: cannot relink \`$file'" 1>&2
6241a18ebfb2Smrg	    fi
624250806d53Smrg	  else
6243a18ebfb2Smrg	    # Install the binary that we compiled earlier.
6244a18ebfb2Smrg	    file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
624550806d53Smrg	  fi
6246a18ebfb2Smrg	fi
6247af1a9c97Smrg
6248a18ebfb2Smrg	# remove .exe since cygwin /usr/bin/install will append another
6249a18ebfb2Smrg	# one anyway 
6250a18ebfb2Smrg	case $install_prog,$host in
6251a18ebfb2Smrg	*/usr/bin/install*,*cygwin*)
6252a18ebfb2Smrg	  case $file:$destfile in
6253a18ebfb2Smrg	  *.exe:*.exe)
6254a18ebfb2Smrg	    # this is ok
6255a18ebfb2Smrg	    ;;
6256a18ebfb2Smrg	  *.exe:*)
6257a18ebfb2Smrg	    destfile=$destfile.exe
6258a18ebfb2Smrg	    ;;
6259a18ebfb2Smrg	  *:*.exe)
6260a18ebfb2Smrg	    destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'`
6261a18ebfb2Smrg	    ;;
6262a18ebfb2Smrg	  esac
6263a18ebfb2Smrg	  ;;
626450806d53Smrg	esac
6265a18ebfb2Smrg	$show "$install_prog$stripme $file $destfile"
6266a18ebfb2Smrg	$run eval "$install_prog\$stripme \$file \$destfile" || exit $?
6267a18ebfb2Smrg	test -n "$outputname" && ${rm}r "$tmpdir"
6268a18ebfb2Smrg	;;
6269a18ebfb2Smrg      esac
6270a18ebfb2Smrg    done
627150806d53Smrg
6272a18ebfb2Smrg    for file in $staticlibs; do
6273a18ebfb2Smrg      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
627450806d53Smrg
6275a18ebfb2Smrg      # Set up the ranlib parameters.
6276a18ebfb2Smrg      oldlib="$destdir/$name"
627750806d53Smrg
6278a18ebfb2Smrg      $show "$install_prog $file $oldlib"
6279a18ebfb2Smrg      $run eval "$install_prog \$file \$oldlib" || exit $?
628050806d53Smrg
6281a18ebfb2Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
6282a18ebfb2Smrg	$show "$old_striplib $oldlib"
6283a18ebfb2Smrg	$run eval "$old_striplib $oldlib" || exit $?
628450806d53Smrg      fi
628550806d53Smrg
6286a18ebfb2Smrg      # Do each command in the postinstall commands.
6287a18ebfb2Smrg      cmds=$old_postinstall_cmds
6288a18ebfb2Smrg      save_ifs="$IFS"; IFS='~'
6289a18ebfb2Smrg      for cmd in $cmds; do
6290a18ebfb2Smrg	IFS="$save_ifs"
6291a18ebfb2Smrg	eval cmd=\"$cmd\"
6292a18ebfb2Smrg	$show "$cmd"
6293a18ebfb2Smrg	$run eval "$cmd" || exit $?
6294a18ebfb2Smrg      done
6295a18ebfb2Smrg      IFS="$save_ifs"
6296a18ebfb2Smrg    done
629750806d53Smrg
6298a18ebfb2Smrg    if test -n "$future_libdirs"; then
6299a18ebfb2Smrg      $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
6300a18ebfb2Smrg    fi
630150806d53Smrg
6302a18ebfb2Smrg    if test -n "$current_libdirs"; then
6303a18ebfb2Smrg      # Maybe just do a dry run.
6304a18ebfb2Smrg      test -n "$run" && current_libdirs=" -n$current_libdirs"
6305a18ebfb2Smrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
6306a18ebfb2Smrg    else
6307a18ebfb2Smrg      exit $EXIT_SUCCESS
6308a18ebfb2Smrg    fi
6309a18ebfb2Smrg    ;;
631050806d53Smrg
6311a18ebfb2Smrg  # libtool finish mode
6312a18ebfb2Smrg  finish)
6313a18ebfb2Smrg    modename="$modename: finish"
6314a18ebfb2Smrg    libdirs="$nonopt"
6315a18ebfb2Smrg    admincmds=
631650806d53Smrg
6317a18ebfb2Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
6318a18ebfb2Smrg      for dir
6319a18ebfb2Smrg      do
6320a18ebfb2Smrg	libdirs="$libdirs $dir"
6321a18ebfb2Smrg      done
632250806d53Smrg
6323a18ebfb2Smrg      for libdir in $libdirs; do
6324a18ebfb2Smrg	if test -n "$finish_cmds"; then
6325a18ebfb2Smrg	  # Do each command in the finish commands.
6326a18ebfb2Smrg	  cmds=$finish_cmds
6327a18ebfb2Smrg	  save_ifs="$IFS"; IFS='~'
6328a18ebfb2Smrg	  for cmd in $cmds; do
6329a18ebfb2Smrg	    IFS="$save_ifs"
6330a18ebfb2Smrg	    eval cmd=\"$cmd\"
6331a18ebfb2Smrg	    $show "$cmd"
6332a18ebfb2Smrg	    $run eval "$cmd" || admincmds="$admincmds
6333a18ebfb2Smrg       $cmd"
633450806d53Smrg	  done
6335a18ebfb2Smrg	  IFS="$save_ifs"
633650806d53Smrg	fi
6337a18ebfb2Smrg	if test -n "$finish_eval"; then
6338a18ebfb2Smrg	  # Do the single finish_eval.
6339a18ebfb2Smrg	  eval cmds=\"$finish_eval\"
6340a18ebfb2Smrg	  $run eval "$cmds" || admincmds="$admincmds
6341a18ebfb2Smrg       $cmds"
6342af1a9c97Smrg	fi
6343a18ebfb2Smrg      done
6344a18ebfb2Smrg    fi
6345a18ebfb2Smrg
6346a18ebfb2Smrg    # Exit here if they wanted silent mode.
6347a18ebfb2Smrg    test "$show" = : && exit $EXIT_SUCCESS
6348a18ebfb2Smrg
6349a18ebfb2Smrg    $echo "X----------------------------------------------------------------------" | $Xsed
6350a18ebfb2Smrg    $echo "Libraries have been installed in:"
6351a18ebfb2Smrg    for libdir in $libdirs; do
6352a18ebfb2Smrg      $echo "   $libdir"
635350806d53Smrg    done
6354a18ebfb2Smrg    $echo
6355a18ebfb2Smrg    $echo "If you ever happen to want to link against installed libraries"
6356a18ebfb2Smrg    $echo "in a given directory, LIBDIR, you must either use libtool, and"
6357a18ebfb2Smrg    $echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
6358a18ebfb2Smrg    $echo "flag during linking and do at least one of the following:"
6359a18ebfb2Smrg    if test -n "$shlibpath_var"; then
6360a18ebfb2Smrg      $echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
6361a18ebfb2Smrg      $echo "     during execution"
6362a18ebfb2Smrg    fi
6363a18ebfb2Smrg    if test -n "$runpath_var"; then
6364a18ebfb2Smrg      $echo "   - add LIBDIR to the \`$runpath_var' environment variable"
6365a18ebfb2Smrg      $echo "     during linking"
6366a18ebfb2Smrg    fi
6367a18ebfb2Smrg    if test -n "$hardcode_libdir_flag_spec"; then
6368a18ebfb2Smrg      libdir=LIBDIR
6369a18ebfb2Smrg      eval flag=\"$hardcode_libdir_flag_spec\"
637050806d53Smrg
6371a18ebfb2Smrg      $echo "   - use the \`$flag' linker flag"
6372a18ebfb2Smrg    fi
6373a18ebfb2Smrg    if test -n "$admincmds"; then
6374a18ebfb2Smrg      $echo "   - have your system administrator run these commands:$admincmds"
6375a18ebfb2Smrg    fi
6376a18ebfb2Smrg    if test -f /etc/ld.so.conf; then
6377a18ebfb2Smrg      $echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
6378a18ebfb2Smrg    fi
6379a18ebfb2Smrg    $echo
6380a18ebfb2Smrg    $echo "See any operating system documentation about shared libraries for"
6381a18ebfb2Smrg    $echo "more information, such as the ld(1) and ld.so(8) manual pages."
6382a18ebfb2Smrg    $echo "X----------------------------------------------------------------------" | $Xsed
6383a18ebfb2Smrg    exit $EXIT_SUCCESS
6384a18ebfb2Smrg    ;;
638550806d53Smrg
6386a18ebfb2Smrg  # libtool execute mode
6387a18ebfb2Smrg  execute)
6388a18ebfb2Smrg    modename="$modename: execute"
638950806d53Smrg
6390a18ebfb2Smrg    # The first argument is the command name.
6391a18ebfb2Smrg    cmd="$nonopt"
6392a18ebfb2Smrg    if test -z "$cmd"; then
6393a18ebfb2Smrg      $echo "$modename: you must specify a COMMAND" 1>&2
6394a18ebfb2Smrg      $echo "$help"
6395a18ebfb2Smrg      exit $EXIT_FAILURE
6396a18ebfb2Smrg    fi
639750806d53Smrg
6398a18ebfb2Smrg    # Handle -dlopen flags immediately.
6399a18ebfb2Smrg    for file in $execute_dlfiles; do
6400a18ebfb2Smrg      if test ! -f "$file"; then
6401a18ebfb2Smrg	$echo "$modename: \`$file' is not a file" 1>&2
6402a18ebfb2Smrg	$echo "$help" 1>&2
6403a18ebfb2Smrg	exit $EXIT_FAILURE
6404a18ebfb2Smrg      fi
6405af1a9c97Smrg
6406a18ebfb2Smrg      dir=
6407a18ebfb2Smrg      case $file in
6408a18ebfb2Smrg      *.la)
6409a18ebfb2Smrg	# Check to see that this really is a libtool archive.
6410a18ebfb2Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
6411a18ebfb2Smrg	else
6412a18ebfb2Smrg	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
6413a18ebfb2Smrg	  $echo "$help" 1>&2
6414a18ebfb2Smrg	  exit $EXIT_FAILURE
6415a18ebfb2Smrg	fi
641650806d53Smrg
6417a18ebfb2Smrg	# Read the libtool library.
6418a18ebfb2Smrg	dlname=
6419a18ebfb2Smrg	library_names=
642050806d53Smrg
6421a18ebfb2Smrg	# If there is no directory component, then add one.
6422a18ebfb2Smrg	case $file in
6423a18ebfb2Smrg	*/* | *\\*) . $file ;;
6424a18ebfb2Smrg	*) . ./$file ;;
6425a18ebfb2Smrg	esac
642650806d53Smrg
6427a18ebfb2Smrg	# Skip this library if it cannot be dlopened.
6428a18ebfb2Smrg	if test -z "$dlname"; then
6429a18ebfb2Smrg	  # Warn if it was a shared library.
6430a18ebfb2Smrg	  test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
6431a18ebfb2Smrg	  continue
6432a18ebfb2Smrg	fi
643350806d53Smrg
6434a18ebfb2Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
6435a18ebfb2Smrg	test "X$dir" = "X$file" && dir=.
643650806d53Smrg
6437a18ebfb2Smrg	if test -f "$dir/$objdir/$dlname"; then
6438a18ebfb2Smrg	  dir="$dir/$objdir"
6439a18ebfb2Smrg	else
6440a18ebfb2Smrg	  if test ! -f "$dir/$dlname"; then
6441a18ebfb2Smrg	    $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
6442a18ebfb2Smrg	    exit $EXIT_FAILURE
6443a18ebfb2Smrg	  fi
6444a18ebfb2Smrg	fi
6445a18ebfb2Smrg	;;
644650806d53Smrg
6447a18ebfb2Smrg      *.lo)
6448a18ebfb2Smrg	# Just add the directory containing the .lo file.
6449a18ebfb2Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
6450a18ebfb2Smrg	test "X$dir" = "X$file" && dir=.
6451a18ebfb2Smrg	;;
645250806d53Smrg
6453a18ebfb2Smrg      *)
6454a18ebfb2Smrg	$echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
6455a18ebfb2Smrg	continue
6456a18ebfb2Smrg	;;
6457a18ebfb2Smrg      esac
645850806d53Smrg
6459a18ebfb2Smrg      # Get the absolute pathname.
6460a18ebfb2Smrg      absdir=`cd "$dir" && pwd`
6461a18ebfb2Smrg      test -n "$absdir" && dir="$absdir"
646250806d53Smrg
6463a18ebfb2Smrg      # Now add the directory to shlibpath_var.
6464a18ebfb2Smrg      if eval "test -z \"\$$shlibpath_var\""; then
6465a18ebfb2Smrg	eval "$shlibpath_var=\"\$dir\""
6466a18ebfb2Smrg      else
6467a18ebfb2Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
6468a18ebfb2Smrg      fi
6469a18ebfb2Smrg    done
647050806d53Smrg
6471a18ebfb2Smrg    # This variable tells wrapper scripts just to set shlibpath_var
6472a18ebfb2Smrg    # rather than running their programs.
6473a18ebfb2Smrg    libtool_execute_magic="$magic"
647450806d53Smrg
6475a18ebfb2Smrg    # Check if any of the arguments is a wrapper script.
6476a18ebfb2Smrg    args=
6477a18ebfb2Smrg    for file
6478a18ebfb2Smrg    do
6479a18ebfb2Smrg      case $file in
6480a18ebfb2Smrg      -*) ;;
6481a18ebfb2Smrg      *)
6482a18ebfb2Smrg	# Do a test to see if this is really a libtool program.
6483a18ebfb2Smrg	if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
6484a18ebfb2Smrg	  # If there is no directory component, then add one.
6485a18ebfb2Smrg	  case $file in
6486a18ebfb2Smrg	  */* | *\\*) . $file ;;
6487a18ebfb2Smrg	  *) . ./$file ;;
6488a18ebfb2Smrg	  esac
648950806d53Smrg
6490a18ebfb2Smrg	  # Transform arg to wrapped name.
6491a18ebfb2Smrg	  file="$progdir/$program"
6492a18ebfb2Smrg	fi
6493a18ebfb2Smrg	;;
6494a18ebfb2Smrg      esac
6495a18ebfb2Smrg      # Quote arguments (to preserve shell metacharacters).
6496a18ebfb2Smrg      file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
6497a18ebfb2Smrg      args="$args \"$file\""
6498a18ebfb2Smrg    done
649950806d53Smrg
6500a18ebfb2Smrg    if test -z "$run"; then
6501a18ebfb2Smrg      if test -n "$shlibpath_var"; then
6502a18ebfb2Smrg	# Export the shlibpath_var.
6503a18ebfb2Smrg	eval "export $shlibpath_var"
6504a18ebfb2Smrg      fi
6505a18ebfb2Smrg
6506a18ebfb2Smrg      # Restore saved environment variables
6507a18ebfb2Smrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
6508a18ebfb2Smrg      do
6509a18ebfb2Smrg	eval "if test \"\${save_$lt_var+set}\" = set; then
6510a18ebfb2Smrg		$lt_var=\$save_$lt_var; export $lt_var
6511a18ebfb2Smrg	      fi"
6512a18ebfb2Smrg      done
651350806d53Smrg
6514a18ebfb2Smrg      # Now prepare to actually exec the command.
6515a18ebfb2Smrg      exec_cmd="\$cmd$args"
6516a18ebfb2Smrg    else
6517a18ebfb2Smrg      # Display what would be done.
6518a18ebfb2Smrg      if test -n "$shlibpath_var"; then
6519a18ebfb2Smrg	eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
6520a18ebfb2Smrg	$echo "export $shlibpath_var"
6521a18ebfb2Smrg      fi
6522a18ebfb2Smrg      $echo "$cmd$args"
6523a18ebfb2Smrg      exit $EXIT_SUCCESS
6524a18ebfb2Smrg    fi
6525a18ebfb2Smrg    ;;
652650806d53Smrg
6527a18ebfb2Smrg  # libtool clean and uninstall mode
6528a18ebfb2Smrg  clean | uninstall)
6529a18ebfb2Smrg    modename="$modename: $mode"
6530a18ebfb2Smrg    rm="$nonopt"
653150806d53Smrg    files=
653250806d53Smrg    rmforce=
653350806d53Smrg    exit_status=0
653450806d53Smrg
653550806d53Smrg    # This variable tells wrapper scripts just to set variables rather
653650806d53Smrg    # than running their programs.
653750806d53Smrg    libtool_install_magic="$magic"
653850806d53Smrg
653950806d53Smrg    for arg
654050806d53Smrg    do
654150806d53Smrg      case $arg in
6542a18ebfb2Smrg      -f) rm="$rm $arg"; rmforce=yes ;;
6543a18ebfb2Smrg      -*) rm="$rm $arg" ;;
654450806d53Smrg      *) files="$files $arg" ;;
654550806d53Smrg      esac
654650806d53Smrg    done
654750806d53Smrg
6548a18ebfb2Smrg    if test -z "$rm"; then
6549a18ebfb2Smrg      $echo "$modename: you must specify an RM program" 1>&2
6550a18ebfb2Smrg      $echo "$help" 1>&2
6551a18ebfb2Smrg      exit $EXIT_FAILURE
6552a18ebfb2Smrg    fi
655350806d53Smrg
655450806d53Smrg    rmdirs=
655550806d53Smrg
655650806d53Smrg    origobjdir="$objdir"
655750806d53Smrg    for file in $files; do
6558a18ebfb2Smrg      dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
6559a18ebfb2Smrg      if test "X$dir" = "X$file"; then
6560a18ebfb2Smrg	dir=.
656150806d53Smrg	objdir="$origobjdir"
656250806d53Smrg      else
656350806d53Smrg	objdir="$dir/$origobjdir"
656450806d53Smrg      fi
6565a18ebfb2Smrg      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
656650806d53Smrg      test "$mode" = uninstall && objdir="$dir"
656750806d53Smrg
656850806d53Smrg      # Remember objdir for removal later, being careful to avoid duplicates
656950806d53Smrg      if test "$mode" = clean; then
657050806d53Smrg	case " $rmdirs " in
657150806d53Smrg	  *" $objdir "*) ;;
657250806d53Smrg	  *) rmdirs="$rmdirs $objdir" ;;
657350806d53Smrg	esac
657450806d53Smrg      fi
657550806d53Smrg
657650806d53Smrg      # Don't error if the file doesn't exist and rm -f was used.
6577a18ebfb2Smrg      if (test -L "$file") >/dev/null 2>&1 \
6578a18ebfb2Smrg	|| (test -h "$file") >/dev/null 2>&1 \
6579a18ebfb2Smrg	|| test -f "$file"; then
658050806d53Smrg	:
658150806d53Smrg      elif test -d "$file"; then
658250806d53Smrg	exit_status=1
658350806d53Smrg	continue
658450806d53Smrg      elif test "$rmforce" = yes; then
658550806d53Smrg	continue
658650806d53Smrg      fi
658750806d53Smrg
658850806d53Smrg      rmfiles="$file"
658950806d53Smrg
659050806d53Smrg      case $name in
659150806d53Smrg      *.la)
659250806d53Smrg	# Possibly a libtool archive, so verify it.
6593a18ebfb2Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
6594a18ebfb2Smrg	  . $dir/$name
659550806d53Smrg
659650806d53Smrg	  # Delete the libtool libraries and symlinks.
659750806d53Smrg	  for n in $library_names; do
659850806d53Smrg	    rmfiles="$rmfiles $objdir/$n"
659950806d53Smrg	  done
660050806d53Smrg	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
660150806d53Smrg
660250806d53Smrg	  case "$mode" in
660350806d53Smrg	  clean)
660450806d53Smrg	    case "  $library_names " in
660550806d53Smrg	    # "  " in the beginning catches empty $dlname
660650806d53Smrg	    *" $dlname "*) ;;
660750806d53Smrg	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
660850806d53Smrg	    esac
6609a18ebfb2Smrg	     test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
661050806d53Smrg	    ;;
661150806d53Smrg	  uninstall)
661250806d53Smrg	    if test -n "$library_names"; then
661350806d53Smrg	      # Do each command in the postuninstall commands.
6614a18ebfb2Smrg	      cmds=$postuninstall_cmds
6615a18ebfb2Smrg	      save_ifs="$IFS"; IFS='~'
6616a18ebfb2Smrg	      for cmd in $cmds; do
6617a18ebfb2Smrg		IFS="$save_ifs"
6618a18ebfb2Smrg		eval cmd=\"$cmd\"
6619a18ebfb2Smrg		$show "$cmd"
6620a18ebfb2Smrg		$run eval "$cmd"
6621a18ebfb2Smrg		if test "$?" -ne 0 && test "$rmforce" != yes; then
6622a18ebfb2Smrg		  exit_status=1
6623a18ebfb2Smrg		fi
6624a18ebfb2Smrg	      done
6625a18ebfb2Smrg	      IFS="$save_ifs"
662650806d53Smrg	    fi
662750806d53Smrg
662850806d53Smrg	    if test -n "$old_library"; then
662950806d53Smrg	      # Do each command in the old_postuninstall commands.
6630a18ebfb2Smrg	      cmds=$old_postuninstall_cmds
6631a18ebfb2Smrg	      save_ifs="$IFS"; IFS='~'
6632a18ebfb2Smrg	      for cmd in $cmds; do
6633a18ebfb2Smrg		IFS="$save_ifs"
6634a18ebfb2Smrg		eval cmd=\"$cmd\"
6635a18ebfb2Smrg		$show "$cmd"
6636a18ebfb2Smrg		$run eval "$cmd"
6637a18ebfb2Smrg		if test "$?" -ne 0 && test "$rmforce" != yes; then
6638a18ebfb2Smrg		  exit_status=1
6639a18ebfb2Smrg		fi
6640a18ebfb2Smrg	      done
6641a18ebfb2Smrg	      IFS="$save_ifs"
664250806d53Smrg	    fi
664350806d53Smrg	    # FIXME: should reinstall the best remaining shared library.
664450806d53Smrg	    ;;
664550806d53Smrg	  esac
664650806d53Smrg	fi
664750806d53Smrg	;;
664850806d53Smrg
664950806d53Smrg      *.lo)
665050806d53Smrg	# Possibly a libtool object, so verify it.
6651a18ebfb2Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
665250806d53Smrg
665350806d53Smrg	  # Read the .lo file
6654a18ebfb2Smrg	  . $dir/$name
665550806d53Smrg
665650806d53Smrg	  # Add PIC object to the list of files to remove.
6657a18ebfb2Smrg	  if test -n "$pic_object" \
6658a18ebfb2Smrg	     && test "$pic_object" != none; then
665950806d53Smrg	    rmfiles="$rmfiles $dir/$pic_object"
666050806d53Smrg	  fi
666150806d53Smrg
666250806d53Smrg	  # Add non-PIC object to the list of files to remove.
6663a18ebfb2Smrg	  if test -n "$non_pic_object" \
6664a18ebfb2Smrg	     && test "$non_pic_object" != none; then
666550806d53Smrg	    rmfiles="$rmfiles $dir/$non_pic_object"
666650806d53Smrg	  fi
666750806d53Smrg	fi
666850806d53Smrg	;;
666950806d53Smrg
667050806d53Smrg      *)
667150806d53Smrg	if test "$mode" = clean ; then
667250806d53Smrg	  noexename=$name
667350806d53Smrg	  case $file in
667450806d53Smrg	  *.exe)
6675a18ebfb2Smrg	    file=`$echo $file|${SED} 's,.exe$,,'`
6676a18ebfb2Smrg	    noexename=`$echo $name|${SED} 's,.exe$,,'`
667750806d53Smrg	    # $file with .exe has already been added to rmfiles,
667850806d53Smrg	    # add $file without .exe
667950806d53Smrg	    rmfiles="$rmfiles $file"
668050806d53Smrg	    ;;
668150806d53Smrg	  esac
668250806d53Smrg	  # Do a test to see if this is a libtool program.
6683a18ebfb2Smrg	  if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
6684a18ebfb2Smrg	    relink_command=
6685a18ebfb2Smrg	    . $dir/$noexename
668650806d53Smrg
668750806d53Smrg	    # note $name still contains .exe if it was in $file originally
668850806d53Smrg	    # as does the version of $file that was added into $rmfiles
668950806d53Smrg	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
669050806d53Smrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
669150806d53Smrg	      rmfiles="$rmfiles $objdir/lt-$name"
669250806d53Smrg	    fi
669350806d53Smrg	    if test "X$noexename" != "X$name" ; then
669450806d53Smrg	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
669550806d53Smrg	    fi
669650806d53Smrg	  fi
669750806d53Smrg	fi
669850806d53Smrg	;;
669950806d53Smrg      esac
6700a18ebfb2Smrg      $show "$rm $rmfiles"
6701a18ebfb2Smrg      $run $rm $rmfiles || exit_status=1
670250806d53Smrg    done
670350806d53Smrg    objdir="$origobjdir"
670450806d53Smrg
670550806d53Smrg    # Try to remove the ${objdir}s in the directories where we deleted files
670650806d53Smrg    for dir in $rmdirs; do
670750806d53Smrg      if test -d "$dir"; then
6708a18ebfb2Smrg	$show "rmdir $dir"
6709a18ebfb2Smrg	$run rmdir $dir >/dev/null 2>&1
671050806d53Smrg      fi
671150806d53Smrg    done
671250806d53Smrg
671350806d53Smrg    exit $exit_status
6714a18ebfb2Smrg    ;;
671550806d53Smrg
6716a18ebfb2Smrg  "")
6717a18ebfb2Smrg    $echo "$modename: you must specify a MODE" 1>&2
6718a18ebfb2Smrg    $echo "$generic_help" 1>&2
6719a18ebfb2Smrg    exit $EXIT_FAILURE
6720a18ebfb2Smrg    ;;
6721a18ebfb2Smrg  esac
6722af1a9c97Smrg
6723a18ebfb2Smrg  if test -z "$exec_cmd"; then
6724a18ebfb2Smrg    $echo "$modename: invalid operation mode \`$mode'" 1>&2
6725a18ebfb2Smrg    $echo "$generic_help" 1>&2
6726a18ebfb2Smrg    exit $EXIT_FAILURE
6727a18ebfb2Smrg  fi
6728a18ebfb2Smrgfi # test -z "$show_help"
672950806d53Smrg
673050806d53Smrgif test -n "$exec_cmd"; then
6731a18ebfb2Smrg  eval exec $exec_cmd
673250806d53Smrg  exit $EXIT_FAILURE
673350806d53Smrgfi
673450806d53Smrg
6735a18ebfb2Smrg# We need to display help for each of the modes.
6736a18ebfb2Smrgcase $mode in
6737a18ebfb2Smrg"") $echo \
6738a18ebfb2Smrg"Usage: $modename [OPTION]... [MODE-ARG]...
6739a18ebfb2Smrg
6740a18ebfb2SmrgProvide generalized library-building support services.
6741a18ebfb2Smrg
6742a18ebfb2Smrg    --config          show all configuration variables
6743a18ebfb2Smrg    --debug           enable verbose shell tracing
6744a18ebfb2Smrg-n, --dry-run         display commands without modifying any files
6745a18ebfb2Smrg    --features        display basic configuration information and exit
6746a18ebfb2Smrg    --finish          same as \`--mode=finish'
6747a18ebfb2Smrg    --help            display this help message and exit
6748a18ebfb2Smrg    --mode=MODE       use operation mode MODE [default=inferred from MODE-ARGS]
6749a18ebfb2Smrg    --quiet           same as \`--silent'
6750a18ebfb2Smrg    --silent          don't print informational messages
6751a18ebfb2Smrg    --tag=TAG         use configuration variables from tag TAG
6752a18ebfb2Smrg    --version         print version information
6753a18ebfb2Smrg
6754a18ebfb2SmrgMODE must be one of the following:
6755a18ebfb2Smrg
6756a18ebfb2Smrg      clean           remove files from the build directory
6757a18ebfb2Smrg      compile         compile a source file into a libtool object
6758a18ebfb2Smrg      execute         automatically set library path, then run a program
6759a18ebfb2Smrg      finish          complete the installation of libtool libraries
6760a18ebfb2Smrg      install         install libraries or executables
6761a18ebfb2Smrg      link            create a library or an executable
6762a18ebfb2Smrg      uninstall       remove libraries from an installed directory
6763a18ebfb2Smrg
6764a18ebfb2SmrgMODE-ARGS vary depending on the MODE.  Try \`$modename --help --mode=MODE' for
6765a18ebfb2Smrga more detailed description of MODE.
6766a18ebfb2Smrg
6767a18ebfb2SmrgReport bugs to <bug-libtool@gnu.org>."
6768a18ebfb2Smrg  exit $EXIT_SUCCESS
6769a18ebfb2Smrg  ;;
6770a18ebfb2Smrg
6771a18ebfb2Smrgclean)
6772a18ebfb2Smrg  $echo \
6773a18ebfb2Smrg"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
6774a18ebfb2Smrg
6775a18ebfb2SmrgRemove files from the build directory.
6776a18ebfb2Smrg
6777a18ebfb2SmrgRM is the name of the program to use to delete files associated with each FILE
6778a18ebfb2Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
6779a18ebfb2Smrgto RM.
6780a18ebfb2Smrg
6781a18ebfb2SmrgIf FILE is a libtool library, object or program, all the files associated
6782a18ebfb2Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
6783a18ebfb2Smrg  ;;
6784a18ebfb2Smrg
6785a18ebfb2Smrgcompile)
6786a18ebfb2Smrg  $echo \
6787a18ebfb2Smrg"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
6788a18ebfb2Smrg
6789a18ebfb2SmrgCompile a source file into a libtool library object.
6790a18ebfb2Smrg
6791a18ebfb2SmrgThis mode accepts the following additional options:
6792a18ebfb2Smrg
6793a18ebfb2Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
6794a18ebfb2Smrg  -prefer-pic       try to building PIC objects only
6795a18ebfb2Smrg  -prefer-non-pic   try to building non-PIC objects only
6796a18ebfb2Smrg  -static           always build a \`.o' file suitable for static linking
6797a18ebfb2Smrg
6798a18ebfb2SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
6799a18ebfb2Smrgfrom the given SOURCEFILE.
6800a18ebfb2Smrg
6801a18ebfb2SmrgThe output file name is determined by removing the directory component from
6802a18ebfb2SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
6803a18ebfb2Smrglibrary object suffix, \`.lo'."
6804a18ebfb2Smrg  ;;
6805a18ebfb2Smrg
6806a18ebfb2Smrgexecute)
6807a18ebfb2Smrg  $echo \
6808a18ebfb2Smrg"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
6809a18ebfb2Smrg
6810a18ebfb2SmrgAutomatically set library path, then run a program.
6811a18ebfb2Smrg
6812a18ebfb2SmrgThis mode accepts the following additional options:
6813a18ebfb2Smrg
6814a18ebfb2Smrg  -dlopen FILE      add the directory containing FILE to the library path
6815a18ebfb2Smrg
6816a18ebfb2SmrgThis mode sets the library path environment variable according to \`-dlopen'
6817a18ebfb2Smrgflags.
6818a18ebfb2Smrg
6819a18ebfb2SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
6820a18ebfb2Smrginto their corresponding uninstalled binary, and any of their required library
6821a18ebfb2Smrgdirectories are added to the library path.
6822a18ebfb2Smrg
6823a18ebfb2SmrgThen, COMMAND is executed, with ARGS as arguments."
6824a18ebfb2Smrg  ;;
6825a18ebfb2Smrg
6826a18ebfb2Smrgfinish)
6827a18ebfb2Smrg  $echo \
6828a18ebfb2Smrg"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
6829a18ebfb2Smrg
6830a18ebfb2SmrgComplete the installation of libtool libraries.
6831a18ebfb2Smrg
6832a18ebfb2SmrgEach LIBDIR is a directory that contains libtool libraries.
6833a18ebfb2Smrg
6834a18ebfb2SmrgThe commands that this mode executes may require superuser privileges.  Use
6835a18ebfb2Smrgthe \`--dry-run' option if you just want to see what would be executed."
6836a18ebfb2Smrg  ;;
6837a18ebfb2Smrg
6838a18ebfb2Smrginstall)
6839a18ebfb2Smrg  $echo \
6840a18ebfb2Smrg"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
6841a18ebfb2Smrg
6842a18ebfb2SmrgInstall executables or libraries.
6843a18ebfb2Smrg
6844a18ebfb2SmrgINSTALL-COMMAND is the installation command.  The first component should be
6845a18ebfb2Smrgeither the \`install' or \`cp' program.
6846a18ebfb2Smrg
6847a18ebfb2SmrgThe rest of the components are interpreted as arguments to that command (only
6848a18ebfb2SmrgBSD-compatible install options are recognized)."
6849a18ebfb2Smrg  ;;
6850a18ebfb2Smrg
6851a18ebfb2Smrglink)
6852a18ebfb2Smrg  $echo \
6853a18ebfb2Smrg"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
6854a18ebfb2Smrg
6855a18ebfb2SmrgLink object files or libraries together to form another library, or to
6856a18ebfb2Smrgcreate an executable program.
685750806d53Smrg
6858a18ebfb2SmrgLINK-COMMAND is a command using the C compiler that you would use to create
6859a18ebfb2Smrga program from several object files.
6860a18ebfb2Smrg
6861a18ebfb2SmrgThe following components of LINK-COMMAND are treated specially:
6862a18ebfb2Smrg
6863a18ebfb2Smrg  -all-static       do not do any dynamic linking at all
6864a18ebfb2Smrg  -avoid-version    do not add a version suffix if possible
6865a18ebfb2Smrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
6866a18ebfb2Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
6867a18ebfb2Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
6868a18ebfb2Smrg  -export-symbols SYMFILE
6869a18ebfb2Smrg                    try to export only the symbols listed in SYMFILE
6870a18ebfb2Smrg  -export-symbols-regex REGEX
6871a18ebfb2Smrg                    try to export only the symbols matching REGEX
6872a18ebfb2Smrg  -LLIBDIR          search LIBDIR for required installed libraries
6873a18ebfb2Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
6874a18ebfb2Smrg  -module           build a library that can dlopened
6875a18ebfb2Smrg  -no-fast-install  disable the fast-install mode
6876a18ebfb2Smrg  -no-install       link a not-installable executable
6877a18ebfb2Smrg  -no-undefined     declare that a library does not refer to external symbols
6878a18ebfb2Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
6879a18ebfb2Smrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
6880a18ebfb2Smrg  -precious-files-regex REGEX
6881a18ebfb2Smrg                    don't remove output files matching REGEX
6882a18ebfb2Smrg  -release RELEASE  specify package release information
6883a18ebfb2Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
6884a18ebfb2Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
6885a18ebfb2Smrg  -static           do not do any dynamic linking of uninstalled libtool libraries
6886a18ebfb2Smrg  -static-libtool-libs
6887a18ebfb2Smrg                    do not do any dynamic linking of libtool libraries
6888a18ebfb2Smrg  -version-info CURRENT[:REVISION[:AGE]]
6889a18ebfb2Smrg                    specify library version info [each variable defaults to 0]
6890a18ebfb2Smrg
6891a18ebfb2SmrgAll other options (arguments beginning with \`-') are ignored.
6892a18ebfb2Smrg
6893a18ebfb2SmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
6894a18ebfb2Smrgtreated as uninstalled libtool libraries, other files are standard or library
6895a18ebfb2Smrgobject files.
6896a18ebfb2Smrg
6897a18ebfb2SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
6898a18ebfb2Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
6899a18ebfb2Smrgrequired, except when creating a convenience library.
6900a18ebfb2Smrg
6901a18ebfb2SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
6902a18ebfb2Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
6903a18ebfb2Smrg
6904a18ebfb2SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
6905a18ebfb2Smrgis created, otherwise an executable program is created."
6906a18ebfb2Smrg  ;;
6907a18ebfb2Smrg
6908a18ebfb2Smrguninstall)
6909a18ebfb2Smrg  $echo \
6910a18ebfb2Smrg"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
6911a18ebfb2Smrg
6912a18ebfb2SmrgRemove libraries from an installation directory.
6913a18ebfb2Smrg
6914a18ebfb2SmrgRM is the name of the program to use to delete files associated with each FILE
6915a18ebfb2Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
6916a18ebfb2Smrgto RM.
6917a18ebfb2Smrg
6918a18ebfb2SmrgIf FILE is a libtool library, all the files associated with it are deleted.
6919a18ebfb2SmrgOtherwise, only FILE itself is deleted using RM."
6920a18ebfb2Smrg  ;;
6921a18ebfb2Smrg
6922a18ebfb2Smrg*)
6923a18ebfb2Smrg  $echo "$modename: invalid operation mode \`$mode'" 1>&2
6924a18ebfb2Smrg  $echo "$help" 1>&2
6925a18ebfb2Smrg  exit $EXIT_FAILURE
6926a18ebfb2Smrg  ;;
6927a18ebfb2Smrgesac
6928a18ebfb2Smrg
6929a18ebfb2Smrg$echo
6930a18ebfb2Smrg$echo "Try \`$modename --help' for more information about other modes."
6931a18ebfb2Smrg
6932a18ebfb2Smrgexit $?
693350806d53Smrg
693450806d53Smrg# The TAGs below are defined such that we never get into a situation
693550806d53Smrg# in which we disable both kinds of libraries.  Given conflicting
693650806d53Smrg# choices, we go for a static library, that is the most portable,
693750806d53Smrg# since we can't tell whether shared libraries were disabled because
693850806d53Smrg# the user asked for that or because the platform doesn't support
693950806d53Smrg# them.  This is particularly important on AIX, because we don't
694050806d53Smrg# support having both static and shared libraries enabled at the same
694150806d53Smrg# time on that platform, so we default to a shared-only configuration.
694250806d53Smrg# If a disable-shared tag is given, we'll fallback to a static-only
694350806d53Smrg# configuration.  But we'll never go from static-only to shared-only.
694450806d53Smrg
694550806d53Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
6946a18ebfb2Smrgdisable_libs=shared
694750806d53Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
694850806d53Smrg
694950806d53Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
6950a18ebfb2Smrgdisable_libs=static
695150806d53Smrg# ### END LIBTOOL TAG CONFIG: disable-static
695250806d53Smrg
695350806d53Smrg# Local Variables:
695450806d53Smrg# mode:shell-script
695550806d53Smrg# sh-indentation:2
695650806d53Smrg# End:
6957