ltmain.sh revision ec713c28
1ec713c28Smrg# ltmain.sh - Provide generalized library-building support services.
2ec713c28Smrg# NOTE: Changing this file will not affect anything until you rerun configure.
3ec713c28Smrg#
4ec713c28Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
5ec713c28Smrg# 2007, 2008  Free Software Foundation, Inc.
6ec713c28Smrg# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
7ec713c28Smrg#
8ec713c28Smrg# This program is free software; you can redistribute it and/or modify
91d54945dSmrg# it under the terms of the GNU General Public License as published by
101d54945dSmrg# the Free Software Foundation; either version 2 of the License, or
111d54945dSmrg# (at your option) any later version.
121d54945dSmrg#
13ec713c28Smrg# This program is distributed in the hope that it will be useful, but
141d54945dSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
151d54945dSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
161d54945dSmrg# General Public License for more details.
171d54945dSmrg#
181d54945dSmrg# You should have received a copy of the GNU General Public License
19ec713c28Smrg# along with this program; if not, write to the Free Software
20ec713c28Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21786a6f21Smrg#
22ec713c28Smrg# As a special exception to the GNU General Public License, if you
23ec713c28Smrg# distribute this file as part of a program that contains a
24ec713c28Smrg# configuration script generated by Autoconf, you may include it under
25ec713c28Smrg# the same distribution terms that you use for the rest of that program.
26ec713c28Smrg
27ec713c28Smrgbasename="s,^.*/,,g"
28ec713c28Smrg
29ec713c28Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
30ec713c28Smrg# is ksh but when the shell is invoked as "sh" and the current value of
31ec713c28Smrg# the _XPG environment variable is not equal to 1 (one), the special
32ec713c28Smrg# positional parameter $0, within a function call, is the name of the
33ec713c28Smrg# function.
34ec713c28Smrgprogpath="$0"
35ec713c28Smrg
36ec713c28Smrg# The name of this program:
37ec713c28Smrgprogname=`echo "$progpath" | $SED $basename`
38ec713c28Smrgmodename="$progname"
39ec713c28Smrg
40ec713c28Smrg# Global variables:
41ec713c28SmrgEXIT_SUCCESS=0
42ec713c28SmrgEXIT_FAILURE=1
431d54945dSmrg
441d54945dSmrgPROGRAM=ltmain.sh
451d54945dSmrgPACKAGE=libtool
46ec713c28SmrgVERSION=1.5.26
47ec713c28SmrgTIMESTAMP=" (1.1220.2.493 2008/02/01 16:58:18)"
481d54945dSmrg
49ec713c28Smrg# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE).
50ba85709eSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
51ba85709eSmrg  emulate sh
52ba85709eSmrg  NULLCMD=:
53ba85709eSmrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
54ba85709eSmrg  # is contrary to our usage.  Disable this feature.
55ba85709eSmrg  alias -g '${1+"$@"}'='"$@"'
561d54945dSmrg  setopt NO_GLOB_SUBST
57ba85709eSmrgelse
58ba85709eSmrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
591d54945dSmrgfi
60786a6f21SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
61786a6f21SmrgDUALCASE=1; export DUALCASE # for MKS sh
621d54945dSmrg
63ec713c28Smrg# Check that we have a working $echo.
64ec713c28Smrgif test "X$1" = X--no-reexec; then
65ec713c28Smrg  # Discard the --no-reexec flag, and continue.
66ec713c28Smrg  shift
67ec713c28Smrgelif test "X$1" = X--fallback-echo; then
68ec713c28Smrg  # Avoid inline document here, it may be left over
69ec713c28Smrg  :
70ec713c28Smrgelif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
71ec713c28Smrg  # Yippee, $echo works!
72ec713c28Smrg  :
73ec713c28Smrgelse
74ec713c28Smrg  # Restart under the correct shell, and then maybe $echo will work.
75ec713c28Smrg  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
76ec713c28Smrgfi
77ec713c28Smrg
78ec713c28Smrgif test "X$1" = X--fallback-echo; then
79ec713c28Smrg  # used as fallback echo
80ec713c28Smrg  shift
81ec713c28Smrg  cat <<EOF
82ec713c28Smrg$*
83ec713c28SmrgEOF
84ec713c28Smrg  exit $EXIT_SUCCESS
85ec713c28Smrgfi
86ec713c28Smrg
87ec713c28Smrgdefault_mode=
88ec713c28Smrghelp="Try \`$progname --help' for more information."
89ec713c28Smrgmagic="%%%MAGIC variable%%%"
90ec713c28Smrgmkdir="mkdir"
91ec713c28Smrgmv="mv -f"
92ec713c28Smrgrm="rm -f"
93ec713c28Smrg
94ec713c28Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
95ec713c28Smrg# metacharacters that are still active within double-quoted strings.
96ec713c28SmrgXsed="${SED}"' -e 1s/^X//'
97ec713c28Smrgsed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
98ec713c28Smrg# test EBCDIC or ASCII
99ec713c28Smrgcase `echo X|tr X '\101'` in
100ec713c28Smrg A) # ASCII based system
101ec713c28Smrg    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
102ec713c28Smrg  SP2NL='tr \040 \012'
103ec713c28Smrg  NL2SP='tr \015\012 \040\040'
104ec713c28Smrg  ;;
105ec713c28Smrg *) # EBCDIC based system
106ec713c28Smrg  SP2NL='tr \100 \n'
107ec713c28Smrg  NL2SP='tr \r\n \100\100'
108ec713c28Smrg  ;;
109ec713c28Smrgesac
110ec713c28Smrg
111ec713c28Smrg# NLS nuisances.
1121d54945dSmrg# Only set LANG and LC_ALL to C if already set.
1131d54945dSmrg# These must not be set unconditionally because not all systems understand
1141d54945dSmrg# e.g. LANG=C (notably SCO).
115ec713c28Smrg# We save the old values to restore during execute mode.
116ec713c28Smrglt_env=
117786a6f21Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
118ba85709eSmrgdo
119ba85709eSmrg  eval "if test \"\${$lt_var+set}\" = set; then
120ec713c28Smrg	  save_$lt_var=\$$lt_var
121ec713c28Smrg	  lt_env=\"$lt_var=\$$lt_var \$lt_env\"
122ec713c28Smrg	  $lt_var=C
123786a6f21Smrg	  export $lt_var
124786a6f21Smrg	fi"
125ba85709eSmrgdone
1261d54945dSmrg
127ec713c28Smrgif test -n "$lt_env"; then
128ec713c28Smrg  lt_env="env $lt_env"
129ec713c28Smrgfi
130786a6f21Smrg
1311d54945dSmrg# Make sure IFS has a sensible default
1321d54945dSmrglt_nl='
1331d54945dSmrg'
1341d54945dSmrgIFS=" 	$lt_nl"
1351d54945dSmrg
136ec713c28Smrgif test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
137ec713c28Smrg  $echo "$modename: not configured to build any kind of library" 1>&2
138ec713c28Smrg  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
139ec713c28Smrg  exit $EXIT_FAILURE
140ec713c28Smrgfi
141786a6f21Smrg
142ec713c28Smrg# Global variables.
143ec713c28Smrgmode=$default_mode
144ec713c28Smrgnonopt=
145ec713c28Smrgprev=
146ec713c28Smrgprevopt=
147ec713c28Smrgrun=
148ec713c28Smrgshow="$echo"
149ec713c28Smrgshow_help=
150ec713c28Smrgexecute_dlfiles=
151ec713c28Smrgduplicate_deps=no
152ec713c28Smrgpreserve_args=
153ec713c28Smrglo2o="s/\\.lo\$/.${objext}/"
154ec713c28Smrgo2lo="s/\\.${objext}\$/.lo/"
155ec713c28Smrgextracted_archives=
156ec713c28Smrgextracted_serial=0
1571d54945dSmrg
158ec713c28Smrg#####################################
159ec713c28Smrg# Shell function definitions:
160ec713c28Smrg# This seems to be the best place for them
1611d54945dSmrg
1621d54945dSmrg# func_mktempdir [string]
1631d54945dSmrg# Make a temporary directory that won't clash with other running
1641d54945dSmrg# libtool processes, and avoids race conditions if possible.  If
1651d54945dSmrg# given, STRING is the basename for that directory.
1661d54945dSmrgfunc_mktempdir ()
1671d54945dSmrg{
1681d54945dSmrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
1691d54945dSmrg
170ec713c28Smrg    if test "$run" = ":"; then
1711d54945dSmrg      # Return a directory name, but don't create it in dry-run mode
1721d54945dSmrg      my_tmpdir="${my_template}-$$"
1731d54945dSmrg    else
1741d54945dSmrg
1751d54945dSmrg      # If mktemp works, use that first and foremost
1761d54945dSmrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
1771d54945dSmrg
1781d54945dSmrg      if test ! -d "$my_tmpdir"; then
179ec713c28Smrg	# Failing that, at least try and use $RANDOM to avoid a race
180ec713c28Smrg	my_tmpdir="${my_template}-${RANDOM-0}$$"
1811d54945dSmrg
182ec713c28Smrg	save_mktempdir_umask=`umask`
183ec713c28Smrg	umask 0077
184ec713c28Smrg	$mkdir "$my_tmpdir"
185ec713c28Smrg	umask $save_mktempdir_umask
1861d54945dSmrg      fi
1871d54945dSmrg
1881d54945dSmrg      # If we're not in dry-run mode, bomb out on failure
189ec713c28Smrg      test -d "$my_tmpdir" || {
190ec713c28Smrg        $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
191ec713c28Smrg	exit $EXIT_FAILURE
192ec713c28Smrg      }
1931d54945dSmrg    fi
1941d54945dSmrg
195ec713c28Smrg    $echo "X$my_tmpdir" | $Xsed
1961d54945dSmrg}
1971d54945dSmrg
1981d54945dSmrg
199ec713c28Smrg# func_win32_libid arg
200ec713c28Smrg# return the library type of file 'arg'
201ec713c28Smrg#
202ec713c28Smrg# Need a lot of goo to handle *both* DLLs and import libs
203ec713c28Smrg# Has to be a shell function in order to 'eat' the argument
204ec713c28Smrg# that is supplied when $file_magic_command is called.
205ec713c28Smrgfunc_win32_libid ()
2061d54945dSmrg{
207ec713c28Smrg  win32_libid_type="unknown"
208ec713c28Smrg  win32_fileres=`file -L $1 2>/dev/null`
209ec713c28Smrg  case $win32_fileres in
210ec713c28Smrg  *ar\ archive\ import\ library*) # definitely import
211ec713c28Smrg    win32_libid_type="x86 archive import"
212ec713c28Smrg    ;;
213ec713c28Smrg  *ar\ archive*) # could be an import, or static
214ec713c28Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
215ec713c28Smrg      $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
216ec713c28Smrg      win32_nmres=`eval $NM -f posix -A $1 | \
217ec713c28Smrg	$SED -n -e '1,100{
218ec713c28Smrg		/ I /{
219ec713c28Smrg			s,.*,import,
220ec713c28Smrg			p
221ec713c28Smrg			q
222ec713c28Smrg			}
223ec713c28Smrg		}'`
224ec713c28Smrg      case $win32_nmres in
225ec713c28Smrg      import*)  win32_libid_type="x86 archive import";;
226ec713c28Smrg      *)        win32_libid_type="x86 archive static";;
227ec713c28Smrg      esac
228ec713c28Smrg    fi
229ec713c28Smrg    ;;
230ec713c28Smrg  *DLL*)
231ec713c28Smrg    win32_libid_type="x86 DLL"
232ec713c28Smrg    ;;
233ec713c28Smrg  *executable*) # but shell scripts are "executable" too...
234ec713c28Smrg    case $win32_fileres in
235ec713c28Smrg    *MS\ Windows\ PE\ Intel*)
236ec713c28Smrg      win32_libid_type="x86 DLL"
237ec713c28Smrg      ;;
2381d54945dSmrg    esac
239ec713c28Smrg    ;;
240ec713c28Smrg  esac
241ec713c28Smrg  $echo $win32_libid_type
2421d54945dSmrg}
2431d54945dSmrg
2441d54945dSmrg
245ec713c28Smrg# func_infer_tag arg
246ec713c28Smrg# Infer tagged configuration to use if any are available and
247ec713c28Smrg# if one wasn't chosen via the "--tag" command line option.
248ec713c28Smrg# Only attempt this if the compiler in the base compile
249ec713c28Smrg# command doesn't match the default compiler.
250ec713c28Smrg# arg is usually of the form 'gcc ...'
251ec713c28Smrgfunc_infer_tag ()
2521d54945dSmrg{
253ec713c28Smrg    if test -n "$available_tags" && test -z "$tagname"; then
254ec713c28Smrg      CC_quoted=
255ec713c28Smrg      for arg in $CC; do
256ec713c28Smrg	case $arg in
257ec713c28Smrg	  *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
258ec713c28Smrg	  arg="\"$arg\""
259ec713c28Smrg	  ;;
260ec713c28Smrg	esac
261ec713c28Smrg	CC_quoted="$CC_quoted $arg"
262ec713c28Smrg      done
263ec713c28Smrg      case $@ in
264ec713c28Smrg      # Blanks in the command may have been stripped by the calling shell,
265ec713c28Smrg      # but not from the CC environment variable when configure was run.
266ec713c28Smrg      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
267ec713c28Smrg      # Blanks at the start of $base_compile will cause this to fail
268ec713c28Smrg      # if we don't check for them as well.
2691d54945dSmrg      *)
270ec713c28Smrg	for z in $available_tags; do
271ec713c28Smrg	  if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
272ec713c28Smrg	    # Evaluate the configuration.
273ec713c28Smrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
274ec713c28Smrg	    CC_quoted=
275ec713c28Smrg	    for arg in $CC; do
276ec713c28Smrg	    # Double-quote args containing other shell metacharacters.
277ec713c28Smrg	    case $arg in
278ec713c28Smrg	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
279ec713c28Smrg	      arg="\"$arg\""
280ec713c28Smrg	      ;;
281ec713c28Smrg	    esac
282ec713c28Smrg	    CC_quoted="$CC_quoted $arg"
283ec713c28Smrg	  done
284ec713c28Smrg	    case "$@ " in
285ec713c28Smrg	      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
286ec713c28Smrg	      # The compiler in the base compile command matches
287ec713c28Smrg	      # the one in the tagged configuration.
288ec713c28Smrg	      # Assume this is the tagged configuration we want.
289ec713c28Smrg	      tagname=$z
290ec713c28Smrg	      break
291ec713c28Smrg	      ;;
292ec713c28Smrg	    esac
293ec713c28Smrg	  fi
294ec713c28Smrg	done
295ec713c28Smrg	# If $tagname still isn't set, then no tagged configuration
296ec713c28Smrg	# was found and let the user know that the "--tag" command
297ec713c28Smrg	# line option must be used.
298ec713c28Smrg	if test -z "$tagname"; then
299ec713c28Smrg	  $echo "$modename: unable to infer tagged configuration"
300ec713c28Smrg	  $echo "$modename: specify a tag with \`--tag'" 1>&2
301ec713c28Smrg	  exit $EXIT_FAILURE
302ec713c28Smrg#        else
303ec713c28Smrg#          $echo "$modename: using $tagname tagged configuration"
304ec713c28Smrg	fi
305ec713c28Smrg	;;
306ec713c28Smrg      esac
307ec713c28Smrg    fi
3081d54945dSmrg}
3091d54945dSmrg
3101d54945dSmrg
311ec713c28Smrg# func_extract_an_archive dir oldlib
312ec713c28Smrgfunc_extract_an_archive ()
3131d54945dSmrg{
314ec713c28Smrg    f_ex_an_ar_dir="$1"; shift
315ec713c28Smrg    f_ex_an_ar_oldlib="$1"
316786a6f21Smrg
317ec713c28Smrg    $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
318ec713c28Smrg    $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
319ec713c28Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
320ec713c28Smrg     :
321ec713c28Smrg    else
322ec713c28Smrg      $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
323ec713c28Smrg      exit $EXIT_FAILURE
3241d54945dSmrg    fi
3251d54945dSmrg}
3261d54945dSmrg
327ec713c28Smrg# func_extract_archives gentop oldlib ...
328ec713c28Smrgfunc_extract_archives ()
3291d54945dSmrg{
330ec713c28Smrg    my_gentop="$1"; shift
331ec713c28Smrg    my_oldlibs=${1+"$@"}
332ec713c28Smrg    my_oldobjs=""
333ec713c28Smrg    my_xlib=""
334ec713c28Smrg    my_xabs=""
335ec713c28Smrg    my_xdir=""
336ec713c28Smrg    my_status=""
337ec713c28Smrg
338ec713c28Smrg    $show "${rm}r $my_gentop"
339ec713c28Smrg    $run ${rm}r "$my_gentop"
340ec713c28Smrg    $show "$mkdir $my_gentop"
341ec713c28Smrg    $run $mkdir "$my_gentop"
342ec713c28Smrg    my_status=$?
343ec713c28Smrg    if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
344ec713c28Smrg      exit $my_status
3451d54945dSmrg    fi
3461d54945dSmrg
347ec713c28Smrg    for my_xlib in $my_oldlibs; do
348ec713c28Smrg      # Extract the objects.
349ec713c28Smrg      case $my_xlib in
350ec713c28Smrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
351ec713c28Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
352ec713c28Smrg      esac
353ec713c28Smrg      my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
354ec713c28Smrg      my_xlib_u=$my_xlib
355ec713c28Smrg      while :; do
356ec713c28Smrg        case " $extracted_archives " in
357ec713c28Smrg	*" $my_xlib_u "*)
358ec713c28Smrg	  extracted_serial=`expr $extracted_serial + 1`
359ec713c28Smrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
360ec713c28Smrg	*) break ;;
361ec713c28Smrg	esac
362ec713c28Smrg      done
363ec713c28Smrg      extracted_archives="$extracted_archives $my_xlib_u"
364ec713c28Smrg      my_xdir="$my_gentop/$my_xlib_u"
365786a6f21Smrg
366ec713c28Smrg      $show "${rm}r $my_xdir"
367ec713c28Smrg      $run ${rm}r "$my_xdir"
368ec713c28Smrg      $show "$mkdir $my_xdir"
369ec713c28Smrg      $run $mkdir "$my_xdir"
370ec713c28Smrg      exit_status=$?
371ec713c28Smrg      if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
372ec713c28Smrg	exit $exit_status
373ec713c28Smrg      fi
374ec713c28Smrg      case $host in
375ec713c28Smrg      *-darwin*)
376ec713c28Smrg	$show "Extracting $my_xabs"
377ec713c28Smrg	# Do not bother doing anything if just a dry run
378ec713c28Smrg	if test -z "$run"; then
379ec713c28Smrg	  darwin_orig_dir=`pwd`
380ec713c28Smrg	  cd $my_xdir || exit $?
381ec713c28Smrg	  darwin_archive=$my_xabs
382ec713c28Smrg	  darwin_curdir=`pwd`
383ec713c28Smrg	  darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
384ec713c28Smrg	  darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
385ec713c28Smrg	  if test -n "$darwin_arches"; then 
386ec713c28Smrg	    darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
387ec713c28Smrg	    darwin_arch=
388ec713c28Smrg	    $show "$darwin_base_archive has multiple architectures $darwin_arches"
389ec713c28Smrg	    for darwin_arch in  $darwin_arches ; do
390ec713c28Smrg	      mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
391ec713c28Smrg	      lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
392ec713c28Smrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
393ec713c28Smrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
394ec713c28Smrg	      cd "$darwin_curdir"
395ec713c28Smrg	      $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
396ec713c28Smrg	    done # $darwin_arches
397ec713c28Smrg      ## Okay now we have a bunch of thin objects, gotta fatten them up :)
398ec713c28Smrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
399ec713c28Smrg	    darwin_file=
400ec713c28Smrg	    darwin_files=
401ec713c28Smrg	    for darwin_file in $darwin_filelist; do
402ec713c28Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
403ec713c28Smrg	      lipo -create -output "$darwin_file" $darwin_files
404ec713c28Smrg	    done # $darwin_filelist
405ec713c28Smrg	    ${rm}r unfat-$$
406ec713c28Smrg	    cd "$darwin_orig_dir"
407ec713c28Smrg	  else
408ec713c28Smrg	    cd "$darwin_orig_dir"
409ec713c28Smrg 	    func_extract_an_archive "$my_xdir" "$my_xabs"
410ec713c28Smrg	  fi # $darwin_arches
411ec713c28Smrg	fi # $run
412ec713c28Smrg	;;
413ec713c28Smrg      *)
414ec713c28Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
415ec713c28Smrg        ;;
416ec713c28Smrg      esac
417ec713c28Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
418ec713c28Smrg    done
419ec713c28Smrg    func_extract_archives_result="$my_oldobjs"
4201d54945dSmrg}
421ec713c28Smrg# End of Shell function definitions
422ec713c28Smrg#####################################
4231d54945dSmrg
424ec713c28Smrg# Darwin sucks
425ec713c28Smrgeval std_shrext=\"$shrext_cmds\"
426786a6f21Smrg
427ec713c28Smrgdisable_libs=no
428786a6f21Smrg
429ec713c28Smrg# Parse our command line options once, thoroughly.
430ec713c28Smrgwhile test "$#" -gt 0
431ec713c28Smrgdo
432ec713c28Smrg  arg="$1"
4331d54945dSmrg  shift
4341d54945dSmrg
435ec713c28Smrg  case $arg in
436ec713c28Smrg  -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
437ec713c28Smrg  *) optarg= ;;
438ec713c28Smrg  esac
4391d54945dSmrg
440ec713c28Smrg  # If the previous option needs an argument, assign it.
441ec713c28Smrg  if test -n "$prev"; then
442ec713c28Smrg    case $prev in
443ec713c28Smrg    execute_dlfiles)
444ec713c28Smrg      execute_dlfiles="$execute_dlfiles $arg"
445ec713c28Smrg      ;;
446ec713c28Smrg    tag)
447ec713c28Smrg      tagname="$arg"
448ec713c28Smrg      preserve_args="${preserve_args}=$arg"
449ec713c28Smrg
450ec713c28Smrg      # Check whether tagname contains only valid characters
451ec713c28Smrg      case $tagname in
452ec713c28Smrg      *[!-_A-Za-z0-9,/]*)
453ec713c28Smrg	$echo "$progname: invalid tag name: $tagname" 1>&2
454ec713c28Smrg	exit $EXIT_FAILURE
455ec713c28Smrg	;;
456ec713c28Smrg      esac
4571d54945dSmrg
458ec713c28Smrg      case $tagname in
459ec713c28Smrg      CC)
460ec713c28Smrg	# Don't test for the "default" C tag, as we know, it's there, but
461ec713c28Smrg	# not specially marked.
462ec713c28Smrg	;;
463ec713c28Smrg      *)
464ec713c28Smrg	if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
465ec713c28Smrg	  taglist="$taglist $tagname"
466ec713c28Smrg	  # Evaluate the configuration.
467ec713c28Smrg	  eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
468ec713c28Smrg	else
469ec713c28Smrg	  $echo "$progname: ignoring unknown tag $tagname" 1>&2
470ec713c28Smrg	fi
471ec713c28Smrg	;;
472ec713c28Smrg      esac
473ec713c28Smrg      ;;
474ec713c28Smrg    *)
475ec713c28Smrg      eval "$prev=\$arg"
476ec713c28Smrg      ;;
477ec713c28Smrg    esac
4781d54945dSmrg
479ec713c28Smrg    prev=
480ec713c28Smrg    prevopt=
481ec713c28Smrg    continue
482ec713c28Smrg  fi
4831d54945dSmrg
484ec713c28Smrg  # Have we seen a non-optional argument yet?
485ec713c28Smrg  case $arg in
486ec713c28Smrg  --help)
487ec713c28Smrg    show_help=yes
488ec713c28Smrg    ;;
4891d54945dSmrg
490ec713c28Smrg  --version)
491ec713c28Smrg    echo "\
492ec713c28Smrg$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP
493786a6f21Smrg
494ec713c28SmrgCopyright (C) 2008  Free Software Foundation, Inc.
495ec713c28SmrgThis is free software; see the source for copying conditions.  There is NO
496ec713c28Smrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
497ec713c28Smrg    exit $?
498ec713c28Smrg    ;;
499786a6f21Smrg
500ec713c28Smrg  --config)
501ec713c28Smrg    ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
5021d54945dSmrg    # Now print the configurations for the tags.
5031d54945dSmrg    for tagname in $taglist; do
504ec713c28Smrg      ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
5051d54945dSmrg    done
506786a6f21Smrg    exit $?
507ec713c28Smrg    ;;
5081d54945dSmrg
509ec713c28Smrg  --debug)
510ec713c28Smrg    $echo "$progname: enabling shell trace mode"
511ec713c28Smrg    set -x
512ec713c28Smrg    preserve_args="$preserve_args $arg"
513ec713c28Smrg    ;;
514ec713c28Smrg
515ec713c28Smrg  --dry-run | -n)
516ec713c28Smrg    run=:
517ec713c28Smrg    ;;
518ec713c28Smrg
519ec713c28Smrg  --features)
520ec713c28Smrg    $echo "host: $host"
5211d54945dSmrg    if test "$build_libtool_libs" = yes; then
522ec713c28Smrg      $echo "enable shared libraries"
5231d54945dSmrg    else
524ec713c28Smrg      $echo "disable shared libraries"
5251d54945dSmrg    fi
5261d54945dSmrg    if test "$build_old_libs" = yes; then
527ec713c28Smrg      $echo "enable static libraries"
5281d54945dSmrg    else
529ec713c28Smrg      $echo "disable static libraries"
5301d54945dSmrg    fi
5311d54945dSmrg    exit $?
532ec713c28Smrg    ;;
5331d54945dSmrg
534ec713c28Smrg  --finish) mode="finish" ;;
5351d54945dSmrg
536ec713c28Smrg  --mode) prevopt="--mode" prev=mode ;;
537ec713c28Smrg  --mode=*) mode="$optarg" ;;
538786a6f21Smrg
539ec713c28Smrg  --preserve-dup-deps) duplicate_deps="yes" ;;
5401d54945dSmrg
541ec713c28Smrg  --quiet | --silent)
542ec713c28Smrg    show=:
543ec713c28Smrg    preserve_args="$preserve_args $arg"
5441d54945dSmrg    ;;
545ec713c28Smrg
546ec713c28Smrg  --tag)
547ec713c28Smrg    prevopt="--tag"
548ec713c28Smrg    prev=tag
549ec713c28Smrg    preserve_args="$preserve_args --tag"
5501d54945dSmrg    ;;
551ec713c28Smrg  --tag=*)
552ec713c28Smrg    set tag "$optarg" ${1+"$@"}
553ec713c28Smrg    shift
554ec713c28Smrg    prev=tag
555ec713c28Smrg    preserve_args="$preserve_args --tag"
5561d54945dSmrg    ;;
557ec713c28Smrg
558ec713c28Smrg  -dlopen)
559ec713c28Smrg    prevopt="-dlopen"
560ec713c28Smrg    prev=execute_dlfiles
561786a6f21Smrg    ;;
562ec713c28Smrg
563ec713c28Smrg  -*)
564ec713c28Smrg    $echo "$modename: unrecognized option \`$arg'" 1>&2
565ec713c28Smrg    $echo "$help" 1>&2
566ec713c28Smrg    exit $EXIT_FAILURE
567786a6f21Smrg    ;;
568ec713c28Smrg
569ec713c28Smrg  *)
570ec713c28Smrg    nonopt="$arg"
571ec713c28Smrg    break
5721d54945dSmrg    ;;
5731d54945dSmrg  esac
574ec713c28Smrgdone
5751d54945dSmrg
576ec713c28Smrgif test -n "$prevopt"; then
577ec713c28Smrg  $echo "$modename: option \`$prevopt' requires an argument" 1>&2
578ec713c28Smrg  $echo "$help" 1>&2
579ec713c28Smrg  exit $EXIT_FAILURE
580ec713c28Smrgfi
581786a6f21Smrg
582ec713c28Smrgcase $disable_libs in
583ec713c28Smrgno) 
584ec713c28Smrg  ;;
585ec713c28Smrgshared)
586ec713c28Smrg  build_libtool_libs=no
587ec713c28Smrg  build_old_libs=yes
588ec713c28Smrg  ;;
589ec713c28Smrgstatic)
590ec713c28Smrg  build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
591ec713c28Smrg  ;;
592ec713c28Smrgesac
593786a6f21Smrg
594ec713c28Smrg# If this variable is set in any of the actions, the command in it
595ec713c28Smrg# will be execed at the end.  This prevents here-documents from being
596ec713c28Smrg# left over by shells.
597ec713c28Smrgexec_cmd=
598786a6f21Smrg
599ec713c28Smrgif test -z "$show_help"; then
600786a6f21Smrg
601ec713c28Smrg  # Infer the operation mode.
602ec713c28Smrg  if test -z "$mode"; then
603ec713c28Smrg    $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
604ec713c28Smrg    $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
605ec713c28Smrg    case $nonopt in
606ec713c28Smrg    *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
607ec713c28Smrg      mode=link
608ec713c28Smrg      for arg
609ec713c28Smrg      do
610ec713c28Smrg	case $arg in
611ec713c28Smrg	-c)
612ec713c28Smrg	   mode=compile
613ec713c28Smrg	   break
614ec713c28Smrg	   ;;
615ec713c28Smrg	esac
616ec713c28Smrg      done
6171d54945dSmrg      ;;
618ec713c28Smrg    *db | *dbx | *strace | *truss)
619ec713c28Smrg      mode=execute
620786a6f21Smrg      ;;
621ec713c28Smrg    *install*|cp|mv)
622ec713c28Smrg      mode=install
623ec713c28Smrg      ;;
624ec713c28Smrg    *rm)
625ec713c28Smrg      mode=uninstall
626ec713c28Smrg      ;;
627ec713c28Smrg    *)
628ec713c28Smrg      # If we have no mode, but dlfiles were specified, then do execute mode.
629ec713c28Smrg      test -n "$execute_dlfiles" && mode=execute
630786a6f21Smrg
631ec713c28Smrg      # Just use the default operation mode.
632ec713c28Smrg      if test -z "$mode"; then
633ec713c28Smrg	if test -n "$nonopt"; then
634ec713c28Smrg	  $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
635ec713c28Smrg	else
636ec713c28Smrg	  $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
637ec713c28Smrg	fi
6381d54945dSmrg      fi
639ec713c28Smrg      ;;
640ec713c28Smrg    esac
6411d54945dSmrg  fi
6421d54945dSmrg
6431d54945dSmrg  # Only execute mode is allowed to have -dlopen flags.
6441d54945dSmrg  if test -n "$execute_dlfiles" && test "$mode" != execute; then
645ec713c28Smrg    $echo "$modename: unrecognized option \`-dlopen'" 1>&2
646ec713c28Smrg    $echo "$help" 1>&2
6471d54945dSmrg    exit $EXIT_FAILURE
6481d54945dSmrg  fi
6491d54945dSmrg
6501d54945dSmrg  # Change the help message to a mode-specific one.
6511d54945dSmrg  generic_help="$help"
652ec713c28Smrg  help="Try \`$modename --help --mode=$mode' for more information."
6531d54945dSmrg
654ec713c28Smrg  # These modes are in order of execution frequency so that they run quickly.
655ec713c28Smrg  case $mode in
656ec713c28Smrg  # libtool compile mode
657ec713c28Smrg  compile)
658ec713c28Smrg    modename="$modename: compile"
659ec713c28Smrg    # Get the compilation command and the source file.
660ec713c28Smrg    base_compile=
661ec713c28Smrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
662ec713c28Smrg    suppress_opt=yes
663ec713c28Smrg    suppress_output=
664ec713c28Smrg    arg_mode=normal
665ec713c28Smrg    libobj=
666ec713c28Smrg    later=
6671d54945dSmrg
668ec713c28Smrg    for arg
669ec713c28Smrg    do
670ec713c28Smrg      case $arg_mode in
671ec713c28Smrg      arg  )
672ec713c28Smrg	# do not "continue".  Instead, add this to base_compile
673ec713c28Smrg	lastarg="$arg"
674ec713c28Smrg	arg_mode=normal
675ec713c28Smrg	;;
6761d54945dSmrg
677ec713c28Smrg      target )
678ec713c28Smrg	libobj="$arg"
679ec713c28Smrg	arg_mode=normal
680ec713c28Smrg	continue
681ec713c28Smrg	;;
6821d54945dSmrg
683ec713c28Smrg      normal )
684ec713c28Smrg	# Accept any command-line options.
685ec713c28Smrg	case $arg in
686ec713c28Smrg	-o)
687ec713c28Smrg	  if test -n "$libobj" ; then
688ec713c28Smrg	    $echo "$modename: you cannot specify \`-o' more than once" 1>&2
689ec713c28Smrg	    exit $EXIT_FAILURE
690ec713c28Smrg	  fi
691ec713c28Smrg	  arg_mode=target
692ec713c28Smrg	  continue
693ec713c28Smrg	  ;;
6941d54945dSmrg
695ec713c28Smrg	-static | -prefer-pic | -prefer-non-pic)
696ec713c28Smrg	  later="$later $arg"
697ec713c28Smrg	  continue
698ec713c28Smrg	  ;;
699786a6f21Smrg
700786a6f21Smrg	-no-suppress)
701786a6f21Smrg	  suppress_opt=no
702786a6f21Smrg	  continue
703786a6f21Smrg	  ;;
7041d54945dSmrg
7051d54945dSmrg	-Xcompiler)
7061d54945dSmrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
7071d54945dSmrg	  continue      #  The current "srcfile" will either be retained or
7081d54945dSmrg	  ;;            #  replaced later.  I would guess that would be a bug.
7091d54945dSmrg
7101d54945dSmrg	-Wc,*)
711ec713c28Smrg	  args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
7121d54945dSmrg	  lastarg=
7131d54945dSmrg	  save_ifs="$IFS"; IFS=','
714ec713c28Smrg 	  for arg in $args; do
7151d54945dSmrg	    IFS="$save_ifs"
716ec713c28Smrg
717ec713c28Smrg	    # Double-quote args containing other shell metacharacters.
718ec713c28Smrg	    # Many Bourne shells cannot handle close brackets correctly
719ec713c28Smrg	    # in scan sets, so we specify it separately.
720ec713c28Smrg	    case $arg in
721ec713c28Smrg	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
722ec713c28Smrg	      arg="\"$arg\""
723ec713c28Smrg	      ;;
724ec713c28Smrg	    esac
725ec713c28Smrg	    lastarg="$lastarg $arg"
7261d54945dSmrg	  done
7271d54945dSmrg	  IFS="$save_ifs"
728ec713c28Smrg	  lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
7291d54945dSmrg
7301d54945dSmrg	  # Add the arguments to base_compile.
7311d54945dSmrg	  base_compile="$base_compile $lastarg"
7321d54945dSmrg	  continue
7331d54945dSmrg	  ;;
7341d54945dSmrg
735ec713c28Smrg	* )
7361d54945dSmrg	  # Accept the current argument as the source file.
7371d54945dSmrg	  # The previous "srcfile" becomes the current argument.
7381d54945dSmrg	  #
7391d54945dSmrg	  lastarg="$srcfile"
7401d54945dSmrg	  srcfile="$arg"
7411d54945dSmrg	  ;;
7421d54945dSmrg	esac  #  case $arg
7431d54945dSmrg	;;
7441d54945dSmrg      esac    #  case $arg_mode
7451d54945dSmrg
7461d54945dSmrg      # Aesthetically quote the previous argument.
747ec713c28Smrg      lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
748ec713c28Smrg
749ec713c28Smrg      case $lastarg in
750ec713c28Smrg      # Double-quote args containing other shell metacharacters.
751ec713c28Smrg      # Many Bourne shells cannot handle close brackets correctly
752ec713c28Smrg      # in scan sets, and some SunOS ksh mistreat backslash-escaping
753ec713c28Smrg      # in scan sets (worked around with variable expansion),
754ec713c28Smrg      # and furthermore cannot handle '|' '&' '(' ')' in scan sets 
755ec713c28Smrg      # at all, so we specify them separately.
756ec713c28Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
757ec713c28Smrg	lastarg="\"$lastarg\""
758ec713c28Smrg	;;
759ec713c28Smrg      esac
760ec713c28Smrg
761ec713c28Smrg      base_compile="$base_compile $lastarg"
7621d54945dSmrg    done # for arg
7631d54945dSmrg
7641d54945dSmrg    case $arg_mode in
7651d54945dSmrg    arg)
766ec713c28Smrg      $echo "$modename: you must specify an argument for -Xcompile"
767ec713c28Smrg      exit $EXIT_FAILURE
7681d54945dSmrg      ;;
7691d54945dSmrg    target)
770ec713c28Smrg      $echo "$modename: you must specify a target with \`-o'" 1>&2
771ec713c28Smrg      exit $EXIT_FAILURE
7721d54945dSmrg      ;;
7731d54945dSmrg    *)
7741d54945dSmrg      # Get the name of the library object.
775ec713c28Smrg      [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
7761d54945dSmrg      ;;
7771d54945dSmrg    esac
7781d54945dSmrg
7791d54945dSmrg    # Recognize several different file suffixes.
7801d54945dSmrg    # If the user specifies -o file.o, it is replaced with file.lo
781ec713c28Smrg    xform='[cCFSifmso]'
7821d54945dSmrg    case $libobj in
783ec713c28Smrg    *.ada) xform=ada ;;
784ec713c28Smrg    *.adb) xform=adb ;;
785ec713c28Smrg    *.ads) xform=ads ;;
786ec713c28Smrg    *.asm) xform=asm ;;
787ec713c28Smrg    *.c++) xform=c++ ;;
788ec713c28Smrg    *.cc) xform=cc ;;
789ec713c28Smrg    *.ii) xform=ii ;;
790ec713c28Smrg    *.class) xform=class ;;
791ec713c28Smrg    *.cpp) xform=cpp ;;
792ec713c28Smrg    *.cxx) xform=cxx ;;
793ec713c28Smrg    *.[fF][09]?) xform=[fF][09]. ;;
794ec713c28Smrg    *.for) xform=for ;;
795ec713c28Smrg    *.java) xform=java ;;
796ec713c28Smrg    *.obj) xform=obj ;;
797ec713c28Smrg    *.sx) xform=sx ;;
7981d54945dSmrg    esac
7991d54945dSmrg
800ec713c28Smrg    libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
801ec713c28Smrg
8021d54945dSmrg    case $libobj in
803ec713c28Smrg    *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
8041d54945dSmrg    *)
805ec713c28Smrg      $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
806ec713c28Smrg      exit $EXIT_FAILURE
8071d54945dSmrg      ;;
8081d54945dSmrg    esac
8091d54945dSmrg
8101d54945dSmrg    func_infer_tag $base_compile
8111d54945dSmrg
8121d54945dSmrg    for arg in $later; do
8131d54945dSmrg      case $arg in
8141d54945dSmrg      -static)
8151d54945dSmrg	build_old_libs=yes
8161d54945dSmrg	continue
8171d54945dSmrg	;;
8181d54945dSmrg
8191d54945dSmrg      -prefer-pic)
8201d54945dSmrg	pic_mode=yes
8211d54945dSmrg	continue
8221d54945dSmrg	;;
8231d54945dSmrg
8241d54945dSmrg      -prefer-non-pic)
8251d54945dSmrg	pic_mode=no
8261d54945dSmrg	continue
8271d54945dSmrg	;;
8281d54945dSmrg      esac
8291d54945dSmrg    done
8301d54945dSmrg
831ec713c28Smrg    qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
832ec713c28Smrg    case $qlibobj in
833ec713c28Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
834ec713c28Smrg	qlibobj="\"$qlibobj\"" ;;
835ec713c28Smrg    esac
836ec713c28Smrg    test "X$libobj" != "X$qlibobj" \
837ec713c28Smrg	&& $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' 	&()|`$[]' \
838ec713c28Smrg	&& $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
839ec713c28Smrg    objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
840ec713c28Smrg    xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
841ec713c28Smrg    if test "X$xdir" = "X$obj"; then
842ec713c28Smrg      xdir=
843ec713c28Smrg    else
844ec713c28Smrg      xdir=$xdir/
845ec713c28Smrg    fi
8461d54945dSmrg    lobj=${xdir}$objdir/$objname
8471d54945dSmrg
848ec713c28Smrg    if test -z "$base_compile"; then
849ec713c28Smrg      $echo "$modename: you must specify a compilation command" 1>&2
850ec713c28Smrg      $echo "$help" 1>&2
851ec713c28Smrg      exit $EXIT_FAILURE
852ec713c28Smrg    fi
8531d54945dSmrg
8541d54945dSmrg    # Delete any leftover library objects.
8551d54945dSmrg    if test "$build_old_libs" = yes; then
8561d54945dSmrg      removelist="$obj $lobj $libobj ${libobj}T"
8571d54945dSmrg    else
8581d54945dSmrg      removelist="$lobj $libobj ${libobj}T"
8591d54945dSmrg    fi
8601d54945dSmrg
861ec713c28Smrg    $run $rm $removelist
862ec713c28Smrg    trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
863ec713c28Smrg
8641d54945dSmrg    # On Cygwin there's no "real" PIC flag so we must build both object types
8651d54945dSmrg    case $host_os in
866ec713c28Smrg    cygwin* | mingw* | pw32* | os2*)
8671d54945dSmrg      pic_mode=default
8681d54945dSmrg      ;;
8691d54945dSmrg    esac
8701d54945dSmrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
8711d54945dSmrg      # non-PIC code in shared libraries is not supported
8721d54945dSmrg      pic_mode=default
8731d54945dSmrg    fi
8741d54945dSmrg
8751d54945dSmrg    # Calculate the filename of the output object if compiler does
8761d54945dSmrg    # not support -o with -c
8771d54945dSmrg    if test "$compiler_c_o" = no; then
878ec713c28Smrg      output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
8791d54945dSmrg      lockfile="$output_obj.lock"
880ec713c28Smrg      removelist="$removelist $output_obj $lockfile"
881ec713c28Smrg      trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
8821d54945dSmrg    else
8831d54945dSmrg      output_obj=
8841d54945dSmrg      need_locks=no
8851d54945dSmrg      lockfile=
8861d54945dSmrg    fi
8871d54945dSmrg
8881d54945dSmrg    # Lock this critical section if it is needed
8891d54945dSmrg    # We use this script file to make the link, it avoids creating a new file
8901d54945dSmrg    if test "$need_locks" = yes; then
891ec713c28Smrg      until $run ln "$progpath" "$lockfile" 2>/dev/null; do
892ec713c28Smrg	$show "Waiting for $lockfile to be removed"
8931d54945dSmrg	sleep 2
8941d54945dSmrg      done
8951d54945dSmrg    elif test "$need_locks" = warn; then
8961d54945dSmrg      if test -f "$lockfile"; then
897ec713c28Smrg	$echo "\
8981d54945dSmrg*** ERROR, $lockfile exists and contains:
8991d54945dSmrg`cat $lockfile 2>/dev/null`
9001d54945dSmrg
9011d54945dSmrgThis indicates that another process is trying to use the same
9021d54945dSmrgtemporary object file, and libtool could not work around it because
9031d54945dSmrgyour compiler does not support \`-c' and \`-o' together.  If you
9041d54945dSmrgrepeat this compilation, it may succeed, by chance, but you had better
9051d54945dSmrgavoid parallel builds (make -j) in this platform, or get a better
9061d54945dSmrgcompiler."
9071d54945dSmrg
908ec713c28Smrg	$run $rm $removelist
9091d54945dSmrg	exit $EXIT_FAILURE
9101d54945dSmrg      fi
911ec713c28Smrg      $echo "$srcfile" > "$lockfile"
9121d54945dSmrg    fi
9131d54945dSmrg
9141d54945dSmrg    if test -n "$fix_srcfile_path"; then
9151d54945dSmrg      eval srcfile=\"$fix_srcfile_path\"
9161d54945dSmrg    fi
917ec713c28Smrg    qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"`
918ec713c28Smrg    case $qsrcfile in
919ec713c28Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
920ec713c28Smrg      qsrcfile="\"$qsrcfile\"" ;;
921ec713c28Smrg    esac
922ec713c28Smrg
923ec713c28Smrg    $run $rm "$libobj" "${libobj}T"
924ec713c28Smrg
925ec713c28Smrg    # Create a libtool object file (analogous to a ".la" file),
926ec713c28Smrg    # but don't create it if we're doing a dry run.
927ec713c28Smrg    test -z "$run" && cat > ${libobj}T <<EOF
928ec713c28Smrg# $libobj - a libtool object file
929ec713c28Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
930ec713c28Smrg#
931ec713c28Smrg# Please DO NOT delete this file!
932ec713c28Smrg# It is necessary for linking the library.
933ec713c28Smrg
934ec713c28Smrg# Name of the PIC object.
935ec713c28SmrgEOF
9361d54945dSmrg
9371d54945dSmrg    # Only build a PIC object if we are building libtool libraries.
9381d54945dSmrg    if test "$build_libtool_libs" = yes; then
9391d54945dSmrg      # Without this assignment, base_compile gets emptied.
9401d54945dSmrg      fbsd_hideous_sh_bug=$base_compile
9411d54945dSmrg
9421d54945dSmrg      if test "$pic_mode" != no; then
9431d54945dSmrg	command="$base_compile $qsrcfile $pic_flag"
9441d54945dSmrg      else
9451d54945dSmrg	# Don't build PIC code
9461d54945dSmrg	command="$base_compile $qsrcfile"
9471d54945dSmrg      fi
9481d54945dSmrg
949ec713c28Smrg      if test ! -d "${xdir}$objdir"; then
950ec713c28Smrg	$show "$mkdir ${xdir}$objdir"
951ec713c28Smrg	$run $mkdir ${xdir}$objdir
952ec713c28Smrg	exit_status=$?
953ec713c28Smrg	if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
954ec713c28Smrg	  exit $exit_status
955ec713c28Smrg	fi
956ec713c28Smrg      fi
9571d54945dSmrg
9581d54945dSmrg      if test -z "$output_obj"; then
9591d54945dSmrg	# Place PIC objects in $objdir
9601d54945dSmrg	command="$command -o $lobj"
9611d54945dSmrg      fi
9621d54945dSmrg
963ec713c28Smrg      $run $rm "$lobj" "$output_obj"
964ec713c28Smrg
965ec713c28Smrg      $show "$command"
966ec713c28Smrg      if $run eval $lt_env "$command"; then :
967ec713c28Smrg      else
968ec713c28Smrg	test -n "$output_obj" && $run $rm $removelist
969ec713c28Smrg	exit $EXIT_FAILURE
970ec713c28Smrg      fi
9711d54945dSmrg
9721d54945dSmrg      if test "$need_locks" = warn &&
9731d54945dSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
974ec713c28Smrg	$echo "\
9751d54945dSmrg*** ERROR, $lockfile contains:
9761d54945dSmrg`cat $lockfile 2>/dev/null`
9771d54945dSmrg
9781d54945dSmrgbut it should contain:
9791d54945dSmrg$srcfile
9801d54945dSmrg
9811d54945dSmrgThis indicates that another process is trying to use the same
9821d54945dSmrgtemporary object file, and libtool could not work around it because
9831d54945dSmrgyour compiler does not support \`-c' and \`-o' together.  If you
9841d54945dSmrgrepeat this compilation, it may succeed, by chance, but you had better
9851d54945dSmrgavoid parallel builds (make -j) in this platform, or get a better
9861d54945dSmrgcompiler."
9871d54945dSmrg
988ec713c28Smrg	$run $rm $removelist
9891d54945dSmrg	exit $EXIT_FAILURE
9901d54945dSmrg      fi
9911d54945dSmrg
9921d54945dSmrg      # Just move the object if needed, then go on to compile the next one
9931d54945dSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
994ec713c28Smrg	$show "$mv $output_obj $lobj"
995ec713c28Smrg	if $run $mv $output_obj $lobj; then :
996ec713c28Smrg	else
997ec713c28Smrg	  error=$?
998ec713c28Smrg	  $run $rm $removelist
999ec713c28Smrg	  exit $error
1000ec713c28Smrg	fi
10011d54945dSmrg      fi
10021d54945dSmrg
1003ec713c28Smrg      # Append the name of the PIC object to the libtool object file.
1004ec713c28Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
1005ec713c28Smrgpic_object='$objdir/$objname'
1006ec713c28Smrg
1007ec713c28SmrgEOF
1008ec713c28Smrg
10091d54945dSmrg      # Allow error messages only from the first compilation.
10101d54945dSmrg      if test "$suppress_opt" = yes; then
1011ec713c28Smrg        suppress_output=' >/dev/null 2>&1'
10121d54945dSmrg      fi
1013ec713c28Smrg    else
1014ec713c28Smrg      # No PIC object so indicate it doesn't exist in the libtool
1015ec713c28Smrg      # object file.
1016ec713c28Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
1017ec713c28Smrgpic_object=none
1018ec713c28Smrg
1019ec713c28SmrgEOF
10201d54945dSmrg    fi
10211d54945dSmrg
10221d54945dSmrg    # Only build a position-dependent object if we build old libraries.
10231d54945dSmrg    if test "$build_old_libs" = yes; then
10241d54945dSmrg      if test "$pic_mode" != yes; then
10251d54945dSmrg	# Don't build PIC code
1026ec713c28Smrg	command="$base_compile $qsrcfile"
10271d54945dSmrg      else
10281d54945dSmrg	command="$base_compile $qsrcfile $pic_flag"
10291d54945dSmrg      fi
10301d54945dSmrg      if test "$compiler_c_o" = yes; then
10311d54945dSmrg	command="$command -o $obj"
10321d54945dSmrg      fi
10331d54945dSmrg
10341d54945dSmrg      # Suppress compiler output if we already did a PIC compilation.
10351d54945dSmrg      command="$command$suppress_output"
1036ec713c28Smrg      $run $rm "$obj" "$output_obj"
1037ec713c28Smrg      $show "$command"
1038ec713c28Smrg      if $run eval $lt_env "$command"; then :
1039ec713c28Smrg      else
1040ec713c28Smrg	$run $rm $removelist
1041ec713c28Smrg	exit $EXIT_FAILURE
1042ec713c28Smrg      fi
10431d54945dSmrg
10441d54945dSmrg      if test "$need_locks" = warn &&
10451d54945dSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1046ec713c28Smrg	$echo "\
10471d54945dSmrg*** ERROR, $lockfile contains:
10481d54945dSmrg`cat $lockfile 2>/dev/null`
10491d54945dSmrg
10501d54945dSmrgbut it should contain:
10511d54945dSmrg$srcfile
10521d54945dSmrg
10531d54945dSmrgThis indicates that another process is trying to use the same
10541d54945dSmrgtemporary object file, and libtool could not work around it because
10551d54945dSmrgyour compiler does not support \`-c' and \`-o' together.  If you
10561d54945dSmrgrepeat this compilation, it may succeed, by chance, but you had better
10571d54945dSmrgavoid parallel builds (make -j) in this platform, or get a better
10581d54945dSmrgcompiler."
10591d54945dSmrg
1060ec713c28Smrg	$run $rm $removelist
10611d54945dSmrg	exit $EXIT_FAILURE
10621d54945dSmrg      fi
10631d54945dSmrg
10641d54945dSmrg      # Just move the object if needed
10651d54945dSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
1066ec713c28Smrg	$show "$mv $output_obj $obj"
1067ec713c28Smrg	if $run $mv $output_obj $obj; then :
1068ec713c28Smrg	else
1069ec713c28Smrg	  error=$?
1070ec713c28Smrg	  $run $rm $removelist
1071ec713c28Smrg	  exit $error
1072ec713c28Smrg	fi
10731d54945dSmrg      fi
1074ec713c28Smrg
1075ec713c28Smrg      # Append the name of the non-PIC object the libtool object file.
1076ec713c28Smrg      # Only append if the libtool object file exists.
1077ec713c28Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
1078ec713c28Smrg# Name of the non-PIC object.
1079ec713c28Smrgnon_pic_object='$objname'
1080ec713c28Smrg
1081ec713c28SmrgEOF
1082ec713c28Smrg    else
1083ec713c28Smrg      # Append the name of the non-PIC object the libtool object file.
1084ec713c28Smrg      # Only append if the libtool object file exists.
1085ec713c28Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
1086ec713c28Smrg# Name of the non-PIC object.
1087ec713c28Smrgnon_pic_object=none
1088ec713c28Smrg
1089ec713c28SmrgEOF
1090786a6f21Smrg    fi
10911d54945dSmrg
1092ec713c28Smrg    $run $mv "${libobj}T" "${libobj}"
10931d54945dSmrg
1094ec713c28Smrg    # Unlock the critical section if it was locked
1095ec713c28Smrg    if test "$need_locks" != no; then
1096ec713c28Smrg      $run $rm "$lockfile"
1097ec713c28Smrg    fi
10981d54945dSmrg
1099786a6f21Smrg    exit $EXIT_SUCCESS
1100ec713c28Smrg    ;;
11011d54945dSmrg
1102ec713c28Smrg  # libtool link mode
1103ec713c28Smrg  link | relink)
1104ec713c28Smrg    modename="$modename: link"
1105ec713c28Smrg    case $host in
1106ec713c28Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
1107ec713c28Smrg      # It is impossible to link a dll without this setting, and
1108ec713c28Smrg      # we shouldn't force the makefile maintainer to figure out
1109ec713c28Smrg      # which system we are compiling for in order to pass an extra
1110ec713c28Smrg      # flag for every libtool invocation.
1111ec713c28Smrg      # allow_undefined=no
11121d54945dSmrg
1113ec713c28Smrg      # FIXME: Unfortunately, there are problems with the above when trying
1114ec713c28Smrg      # to make a dll which has undefined symbols, in which case not
1115ec713c28Smrg      # even a static library is built.  For now, we need to specify
1116ec713c28Smrg      # -no-undefined on the libtool link line when we can be certain
1117ec713c28Smrg      # that all symbols are satisfied, otherwise we get a static library.
1118ec713c28Smrg      allow_undefined=yes
1119ec713c28Smrg      ;;
1120ec713c28Smrg    *)
1121ec713c28Smrg      allow_undefined=yes
1122ec713c28Smrg      ;;
1123ec713c28Smrg    esac
1124ec713c28Smrg    libtool_args="$nonopt"
1125ec713c28Smrg    base_compile="$nonopt $@"
1126ec713c28Smrg    compile_command="$nonopt"
1127ec713c28Smrg    finalize_command="$nonopt"
11281d54945dSmrg
1129ec713c28Smrg    compile_rpath=
1130ec713c28Smrg    finalize_rpath=
1131ec713c28Smrg    compile_shlibpath=
1132ec713c28Smrg    finalize_shlibpath=
1133ec713c28Smrg    convenience=
1134ec713c28Smrg    old_convenience=
1135ec713c28Smrg    deplibs=
1136ec713c28Smrg    old_deplibs=
1137ec713c28Smrg    compiler_flags=
1138ec713c28Smrg    linker_flags=
1139ec713c28Smrg    dllsearchpath=
1140ec713c28Smrg    lib_search_path=`pwd`
1141ec713c28Smrg    inst_prefix_dir=
11421d54945dSmrg
1143ec713c28Smrg    avoid_version=no
1144ec713c28Smrg    dlfiles=
1145ec713c28Smrg    dlprefiles=
1146ec713c28Smrg    dlself=no
1147ec713c28Smrg    export_dynamic=no
1148ec713c28Smrg    export_symbols=
1149ec713c28Smrg    export_symbols_regex=
1150ec713c28Smrg    generated=
1151ec713c28Smrg    libobjs=
1152ec713c28Smrg    ltlibs=
1153ec713c28Smrg    module=no
1154ec713c28Smrg    no_install=no
1155ec713c28Smrg    objs=
1156ec713c28Smrg    non_pic_objects=
1157ec713c28Smrg    notinst_path= # paths that contain not-installed libtool libraries
1158ec713c28Smrg    precious_files_regex=
1159ec713c28Smrg    prefer_static_libs=no
1160ec713c28Smrg    preload=no
1161ec713c28Smrg    prev=
1162ec713c28Smrg    prevarg=
1163ec713c28Smrg    release=
1164ec713c28Smrg    rpath=
1165ec713c28Smrg    xrpath=
1166ec713c28Smrg    perm_rpath=
1167ec713c28Smrg    temp_rpath=
1168ec713c28Smrg    thread_safe=no
1169ec713c28Smrg    vinfo=
1170ec713c28Smrg    vinfo_number=no
1171ec713c28Smrg    single_module="${wl}-single_module"
11721d54945dSmrg
1173ec713c28Smrg    func_infer_tag $base_compile
11741d54945dSmrg
1175ec713c28Smrg    # We need to know -static, to get the right output filenames.
1176ec713c28Smrg    for arg
1177ec713c28Smrg    do
1178ec713c28Smrg      case $arg in
1179ec713c28Smrg      -all-static | -static | -static-libtool-libs)
1180ec713c28Smrg	case $arg in
1181ec713c28Smrg	-all-static)
1182ec713c28Smrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
1183ec713c28Smrg	    $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
1184ec713c28Smrg	  fi
1185ec713c28Smrg	  if test -n "$link_static_flag"; then
1186ec713c28Smrg	    dlopen_self=$dlopen_self_static
1187ec713c28Smrg	  fi
1188ec713c28Smrg	  prefer_static_libs=yes
1189ec713c28Smrg	  ;;
1190ec713c28Smrg	-static)
1191ec713c28Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
1192ec713c28Smrg	    dlopen_self=$dlopen_self_static
1193ec713c28Smrg	  fi
1194ec713c28Smrg	  prefer_static_libs=built
1195ec713c28Smrg	  ;;
1196ec713c28Smrg	-static-libtool-libs)
1197ec713c28Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
1198ec713c28Smrg	    dlopen_self=$dlopen_self_static
1199ec713c28Smrg	  fi
1200ec713c28Smrg	  prefer_static_libs=yes
1201ec713c28Smrg	  ;;
1202ec713c28Smrg	esac
1203ec713c28Smrg	build_libtool_libs=no
1204ec713c28Smrg	build_old_libs=yes
1205ec713c28Smrg	break
1206ec713c28Smrg	;;
1207ec713c28Smrg      esac
1208ec713c28Smrg    done
12091d54945dSmrg
1210ec713c28Smrg    # See if our shared archives depend on static archives.
1211ec713c28Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
12121d54945dSmrg
1213ec713c28Smrg    # Go through the arguments, transforming them on the way.
1214ec713c28Smrg    while test "$#" -gt 0; do
1215ec713c28Smrg      arg="$1"
1216ec713c28Smrg      shift
1217ec713c28Smrg      case $arg in
1218ec713c28Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1219ec713c28Smrg	qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
1220ec713c28Smrg	;;
1221ec713c28Smrg      *) qarg=$arg ;;
1222ec713c28Smrg      esac
1223ec713c28Smrg      libtool_args="$libtool_args $qarg"
12241d54945dSmrg
1225ec713c28Smrg      # If the previous option needs an argument, assign it.
1226ec713c28Smrg      if test -n "$prev"; then
1227ec713c28Smrg	case $prev in
1228ec713c28Smrg	output)
1229ec713c28Smrg	  compile_command="$compile_command @OUTPUT@"
1230ec713c28Smrg	  finalize_command="$finalize_command @OUTPUT@"
1231ec713c28Smrg	  ;;
1232ec713c28Smrg	esac
12331d54945dSmrg
1234ec713c28Smrg	case $prev in
1235ec713c28Smrg	dlfiles|dlprefiles)
1236ec713c28Smrg	  if test "$preload" = no; then
1237ec713c28Smrg	    # Add the symbol object into the linking commands.
1238ec713c28Smrg	    compile_command="$compile_command @SYMFILE@"
1239ec713c28Smrg	    finalize_command="$finalize_command @SYMFILE@"
1240ec713c28Smrg	    preload=yes
1241ec713c28Smrg	  fi
1242ec713c28Smrg	  case $arg in
1243ec713c28Smrg	  *.la | *.lo) ;;  # We handle these cases below.
1244ec713c28Smrg	  force)
1245ec713c28Smrg	    if test "$dlself" = no; then
1246ec713c28Smrg	      dlself=needless
1247ec713c28Smrg	      export_dynamic=yes
1248ec713c28Smrg	    fi
1249ec713c28Smrg	    prev=
1250ec713c28Smrg	    continue
1251ec713c28Smrg	    ;;
1252ec713c28Smrg	  self)
1253ec713c28Smrg	    if test "$prev" = dlprefiles; then
1254ec713c28Smrg	      dlself=yes
1255ec713c28Smrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
1256ec713c28Smrg	      dlself=yes
1257ec713c28Smrg	    else
1258ec713c28Smrg	      dlself=needless
1259ec713c28Smrg	      export_dynamic=yes
1260ec713c28Smrg	    fi
1261ec713c28Smrg	    prev=
1262ec713c28Smrg	    continue
1263ec713c28Smrg	    ;;
1264ec713c28Smrg	  *)
1265ec713c28Smrg	    if test "$prev" = dlfiles; then
1266ec713c28Smrg	      dlfiles="$dlfiles $arg"
1267ec713c28Smrg	    else
1268ec713c28Smrg	      dlprefiles="$dlprefiles $arg"
1269ec713c28Smrg	    fi
1270ec713c28Smrg	    prev=
1271ec713c28Smrg	    continue
1272ec713c28Smrg	    ;;
1273ec713c28Smrg	  esac
1274ec713c28Smrg	  ;;
1275ec713c28Smrg	expsyms)
1276ec713c28Smrg	  export_symbols="$arg"
1277ec713c28Smrg	  if test ! -f "$arg"; then
1278ec713c28Smrg	    $echo "$modename: symbol file \`$arg' does not exist"
1279ec713c28Smrg	    exit $EXIT_FAILURE
1280ec713c28Smrg	  fi
1281ec713c28Smrg	  prev=
1282ec713c28Smrg	  continue
1283ec713c28Smrg	  ;;
1284ec713c28Smrg	expsyms_regex)
1285ec713c28Smrg	  export_symbols_regex="$arg"
1286ec713c28Smrg	  prev=
1287ec713c28Smrg	  continue
1288ec713c28Smrg	  ;;
1289ec713c28Smrg	inst_prefix)
1290ec713c28Smrg	  inst_prefix_dir="$arg"
1291ec713c28Smrg	  prev=
1292ec713c28Smrg	  continue
1293ec713c28Smrg	  ;;
1294ec713c28Smrg	precious_regex)
1295ec713c28Smrg	  precious_files_regex="$arg"
1296ec713c28Smrg	  prev=
1297ec713c28Smrg	  continue
1298ec713c28Smrg	  ;;
1299ec713c28Smrg	release)
1300ec713c28Smrg	  release="-$arg"
1301ec713c28Smrg	  prev=
1302ec713c28Smrg	  continue
1303ec713c28Smrg	  ;;
1304ec713c28Smrg	objectlist)
1305ec713c28Smrg	  if test -f "$arg"; then
1306ec713c28Smrg	    save_arg=$arg
1307ec713c28Smrg	    moreargs=
1308ec713c28Smrg	    for fil in `cat $save_arg`
1309ec713c28Smrg	    do
1310ec713c28Smrg#	      moreargs="$moreargs $fil"
1311ec713c28Smrg	      arg=$fil
1312ec713c28Smrg	      # A libtool-controlled object.
13131d54945dSmrg
1314ec713c28Smrg	      # Check to see that this really is a libtool object.
1315ec713c28Smrg	      if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
1316ec713c28Smrg		pic_object=
1317ec713c28Smrg		non_pic_object=
13181d54945dSmrg
1319ec713c28Smrg		# Read the .lo file
1320ec713c28Smrg		# If there is no directory component, then add one.
1321ec713c28Smrg		case $arg in
1322ec713c28Smrg		*/* | *\\*) . $arg ;;
1323ec713c28Smrg		*) . ./$arg ;;
1324ec713c28Smrg		esac
13251d54945dSmrg
1326ec713c28Smrg		if test -z "$pic_object" || \
1327ec713c28Smrg		   test -z "$non_pic_object" ||
1328ec713c28Smrg		   test "$pic_object" = none && \
1329ec713c28Smrg		   test "$non_pic_object" = none; then
1330ec713c28Smrg		  $echo "$modename: cannot find name of object for \`$arg'" 1>&2
1331ec713c28Smrg		  exit $EXIT_FAILURE
1332ec713c28Smrg		fi
13331d54945dSmrg
1334ec713c28Smrg		# Extract subdirectory from the argument.
1335ec713c28Smrg		xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1336ec713c28Smrg		if test "X$xdir" = "X$arg"; then
1337ec713c28Smrg		  xdir=
1338ec713c28Smrg		else
1339ec713c28Smrg		  xdir="$xdir/"
1340ec713c28Smrg		fi
13411d54945dSmrg
1342ec713c28Smrg		if test "$pic_object" != none; then
1343ec713c28Smrg		  # Prepend the subdirectory the object is found in.
1344ec713c28Smrg		  pic_object="$xdir$pic_object"
13451d54945dSmrg
1346ec713c28Smrg		  if test "$prev" = dlfiles; then
1347ec713c28Smrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
1348ec713c28Smrg		      dlfiles="$dlfiles $pic_object"
1349ec713c28Smrg		      prev=
1350ec713c28Smrg		      continue
1351ec713c28Smrg		    else
1352ec713c28Smrg		      # If libtool objects are unsupported, then we need to preload.
1353ec713c28Smrg		      prev=dlprefiles
1354ec713c28Smrg		    fi
1355ec713c28Smrg		  fi
13561d54945dSmrg
1357ec713c28Smrg		  # CHECK ME:  I think I busted this.  -Ossama
1358ec713c28Smrg		  if test "$prev" = dlprefiles; then
1359ec713c28Smrg		    # Preload the old-style object.
1360ec713c28Smrg		    dlprefiles="$dlprefiles $pic_object"
1361ec713c28Smrg		    prev=
1362ec713c28Smrg		  fi
13631d54945dSmrg
1364ec713c28Smrg		  # A PIC object.
1365ec713c28Smrg		  libobjs="$libobjs $pic_object"
1366ec713c28Smrg		  arg="$pic_object"
1367ec713c28Smrg		fi
13681d54945dSmrg
1369ec713c28Smrg		# Non-PIC object.
1370ec713c28Smrg		if test "$non_pic_object" != none; then
1371ec713c28Smrg		  # Prepend the subdirectory the object is found in.
1372ec713c28Smrg		  non_pic_object="$xdir$non_pic_object"
13731d54945dSmrg
1374ec713c28Smrg		  # A standard non-PIC object
1375ec713c28Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
1376ec713c28Smrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
1377ec713c28Smrg		    arg="$non_pic_object"
1378ec713c28Smrg		  fi
1379ec713c28Smrg		else
1380ec713c28Smrg		  # If the PIC object exists, use it instead.
1381ec713c28Smrg		  # $xdir was prepended to $pic_object above.
1382ec713c28Smrg		  non_pic_object="$pic_object"
1383ec713c28Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
1384ec713c28Smrg		fi
1385ec713c28Smrg	      else
1386ec713c28Smrg		# Only an error if not doing a dry-run.
1387ec713c28Smrg		if test -z "$run"; then
1388ec713c28Smrg		  $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
1389ec713c28Smrg		  exit $EXIT_FAILURE
1390ec713c28Smrg		else
1391ec713c28Smrg		  # Dry-run case.
13921d54945dSmrg
1393ec713c28Smrg		  # Extract subdirectory from the argument.
1394ec713c28Smrg		  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1395ec713c28Smrg		  if test "X$xdir" = "X$arg"; then
1396ec713c28Smrg		    xdir=
1397ec713c28Smrg		  else
1398ec713c28Smrg		    xdir="$xdir/"
1399ec713c28Smrg		  fi
14001d54945dSmrg
1401ec713c28Smrg		  pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
1402ec713c28Smrg		  non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
1403ec713c28Smrg		  libobjs="$libobjs $pic_object"
1404ec713c28Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
1405ec713c28Smrg		fi
1406ec713c28Smrg	      fi
1407ec713c28Smrg	    done
1408ec713c28Smrg	  else
1409ec713c28Smrg	    $echo "$modename: link input file \`$save_arg' does not exist"
1410ec713c28Smrg	    exit $EXIT_FAILURE
1411ec713c28Smrg	  fi
1412ec713c28Smrg	  arg=$save_arg
1413ec713c28Smrg	  prev=
1414ec713c28Smrg	  continue
1415ec713c28Smrg	  ;;
1416ec713c28Smrg	rpath | xrpath)
1417ec713c28Smrg	  # We need an absolute path.
1418ec713c28Smrg	  case $arg in
1419ec713c28Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
1420ec713c28Smrg	  *)
1421ec713c28Smrg	    $echo "$modename: only absolute run-paths are allowed" 1>&2
1422ec713c28Smrg	    exit $EXIT_FAILURE
1423ec713c28Smrg	    ;;
1424ec713c28Smrg	  esac
1425ec713c28Smrg	  if test "$prev" = rpath; then
1426ec713c28Smrg	    case "$rpath " in
1427ec713c28Smrg	    *" $arg "*) ;;
1428ec713c28Smrg	    *) rpath="$rpath $arg" ;;
1429ec713c28Smrg	    esac
1430ec713c28Smrg	  else
1431ec713c28Smrg	    case "$xrpath " in
1432ec713c28Smrg	    *" $arg "*) ;;
1433ec713c28Smrg	    *) xrpath="$xrpath $arg" ;;
1434ec713c28Smrg	    esac
1435ec713c28Smrg	  fi
1436ec713c28Smrg	  prev=
1437ec713c28Smrg	  continue
1438ec713c28Smrg	  ;;
1439ec713c28Smrg	xcompiler)
1440ec713c28Smrg	  compiler_flags="$compiler_flags $qarg"
1441ec713c28Smrg	  prev=
1442ec713c28Smrg	  compile_command="$compile_command $qarg"
1443ec713c28Smrg	  finalize_command="$finalize_command $qarg"
1444ec713c28Smrg	  continue
1445ec713c28Smrg	  ;;
1446ec713c28Smrg	xlinker)
1447ec713c28Smrg	  linker_flags="$linker_flags $qarg"
1448ec713c28Smrg	  compiler_flags="$compiler_flags $wl$qarg"
1449ec713c28Smrg	  prev=
1450ec713c28Smrg	  compile_command="$compile_command $wl$qarg"
1451ec713c28Smrg	  finalize_command="$finalize_command $wl$qarg"
1452ec713c28Smrg	  continue
1453ec713c28Smrg	  ;;
1454ec713c28Smrg	xcclinker)
1455ec713c28Smrg	  linker_flags="$linker_flags $qarg"
1456ec713c28Smrg	  compiler_flags="$compiler_flags $qarg"
1457ec713c28Smrg	  prev=
1458ec713c28Smrg	  compile_command="$compile_command $qarg"
1459ec713c28Smrg	  finalize_command="$finalize_command $qarg"
1460ec713c28Smrg	  continue
1461ec713c28Smrg	  ;;
1462ec713c28Smrg	shrext)
1463ec713c28Smrg  	  shrext_cmds="$arg"
1464ec713c28Smrg	  prev=
1465ec713c28Smrg	  continue
1466ec713c28Smrg	  ;;
1467ec713c28Smrg	darwin_framework|darwin_framework_skip)
1468ec713c28Smrg	  test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg"
1469ec713c28Smrg	  compile_command="$compile_command $arg"
1470ec713c28Smrg	  finalize_command="$finalize_command $arg"
1471ec713c28Smrg	  prev=
1472ec713c28Smrg	  continue
1473ec713c28Smrg	  ;;
1474ec713c28Smrg	*)
1475ec713c28Smrg	  eval "$prev=\"\$arg\""
1476ec713c28Smrg	  prev=
1477ec713c28Smrg	  continue
1478ec713c28Smrg	  ;;
1479ec713c28Smrg	esac
1480ec713c28Smrg      fi # test -n "$prev"
14811d54945dSmrg
1482ec713c28Smrg      prevarg="$arg"
14831d54945dSmrg
1484ec713c28Smrg      case $arg in
1485ec713c28Smrg      -all-static)
1486ec713c28Smrg	if test -n "$link_static_flag"; then
1487ec713c28Smrg	  compile_command="$compile_command $link_static_flag"
1488ec713c28Smrg	  finalize_command="$finalize_command $link_static_flag"
1489ec713c28Smrg	fi
1490ec713c28Smrg	continue
1491ec713c28Smrg	;;
14921d54945dSmrg
1493ec713c28Smrg      -allow-undefined)
1494ec713c28Smrg	# FIXME: remove this flag sometime in the future.
1495ec713c28Smrg	$echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
1496ec713c28Smrg	continue
1497ec713c28Smrg	;;
14981d54945dSmrg
1499ec713c28Smrg      -avoid-version)
1500ec713c28Smrg	avoid_version=yes
1501ec713c28Smrg	continue
1502ec713c28Smrg	;;
15031d54945dSmrg
1504ec713c28Smrg      -dlopen)
1505ec713c28Smrg	prev=dlfiles
1506ec713c28Smrg	continue
1507ec713c28Smrg	;;
15081d54945dSmrg
1509ec713c28Smrg      -dlpreopen)
1510ec713c28Smrg	prev=dlprefiles
1511ec713c28Smrg	continue
1512ec713c28Smrg	;;
15131d54945dSmrg
1514ec713c28Smrg      -export-dynamic)
1515ec713c28Smrg	export_dynamic=yes
1516ec713c28Smrg	continue
1517ec713c28Smrg	;;
15181d54945dSmrg
1519ec713c28Smrg      -export-symbols | -export-symbols-regex)
1520ec713c28Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
1521ec713c28Smrg	  $echo "$modename: more than one -exported-symbols argument is not allowed"
1522ec713c28Smrg	  exit $EXIT_FAILURE
1523ec713c28Smrg	fi
1524ec713c28Smrg	if test "X$arg" = "X-export-symbols"; then
1525ec713c28Smrg	  prev=expsyms
1526ec713c28Smrg	else
1527ec713c28Smrg	  prev=expsyms_regex
1528ec713c28Smrg	fi
1529ec713c28Smrg	continue
1530ec713c28Smrg	;;
15311d54945dSmrg
1532ec713c28Smrg      -framework|-arch|-isysroot)
1533ec713c28Smrg	case " $CC " in
1534ec713c28Smrg	  *" ${arg} ${1} "* | *" ${arg}	${1} "*) 
1535ec713c28Smrg		prev=darwin_framework_skip ;;
1536ec713c28Smrg	  *) compiler_flags="$compiler_flags $arg"
1537ec713c28Smrg	     prev=darwin_framework ;;
1538ec713c28Smrg	esac
1539ec713c28Smrg	compile_command="$compile_command $arg"
1540ec713c28Smrg	finalize_command="$finalize_command $arg"
1541ec713c28Smrg	continue
1542ec713c28Smrg	;;
15431d54945dSmrg
1544ec713c28Smrg      -inst-prefix-dir)
1545ec713c28Smrg	prev=inst_prefix
1546ec713c28Smrg	continue
1547ec713c28Smrg	;;
15481d54945dSmrg
1549ec713c28Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
1550ec713c28Smrg      # so, if we see these flags be careful not to treat them like -L
1551ec713c28Smrg      -L[A-Z][A-Z]*:*)
1552ec713c28Smrg	case $with_gcc/$host in
1553ec713c28Smrg	no/*-*-irix* | /*-*-irix*)
1554ec713c28Smrg	  compile_command="$compile_command $arg"
1555ec713c28Smrg	  finalize_command="$finalize_command $arg"
1556ec713c28Smrg	  ;;
1557ec713c28Smrg	esac
1558ec713c28Smrg	continue
1559ec713c28Smrg	;;
15601d54945dSmrg
1561ec713c28Smrg      -L*)
1562ec713c28Smrg	dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
1563ec713c28Smrg	# We need an absolute path.
1564ec713c28Smrg	case $dir in
1565ec713c28Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
1566ec713c28Smrg	*)
1567ec713c28Smrg	  absdir=`cd "$dir" && pwd`
1568ec713c28Smrg	  if test -z "$absdir"; then
1569ec713c28Smrg	    $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
1570ec713c28Smrg	    absdir="$dir"
1571ec713c28Smrg	    notinst_path="$notinst_path $dir"
1572ec713c28Smrg	  fi
1573ec713c28Smrg	  dir="$absdir"
1574ec713c28Smrg	  ;;
1575ec713c28Smrg	esac
1576ec713c28Smrg	case "$deplibs " in
1577ec713c28Smrg	*" -L$dir "*) ;;
1578ec713c28Smrg	*)
1579ec713c28Smrg	  deplibs="$deplibs -L$dir"
1580ec713c28Smrg	  lib_search_path="$lib_search_path $dir"
1581ec713c28Smrg	  ;;
1582ec713c28Smrg	esac
1583ec713c28Smrg	case $host in
1584ec713c28Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
1585ec713c28Smrg	  testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'`
1586ec713c28Smrg	  case :$dllsearchpath: in
1587ec713c28Smrg	  *":$dir:"*) ;;
1588ec713c28Smrg	  *) dllsearchpath="$dllsearchpath:$dir";;
1589ec713c28Smrg	  esac
1590ec713c28Smrg	  case :$dllsearchpath: in
1591ec713c28Smrg	  *":$testbindir:"*) ;;
1592ec713c28Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
1593ec713c28Smrg	  esac
1594ec713c28Smrg	  ;;
1595ec713c28Smrg	esac
1596ec713c28Smrg	continue
1597ec713c28Smrg	;;
15981d54945dSmrg
1599ec713c28Smrg      -l*)
1600ec713c28Smrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
1601ec713c28Smrg	  case $host in
1602ec713c28Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
1603ec713c28Smrg	    # These systems don't actually have a C or math library (as such)
1604ec713c28Smrg	    continue
1605ec713c28Smrg	    ;;
1606ec713c28Smrg	  *-*-os2*)
1607ec713c28Smrg	    # These systems don't actually have a C library (as such)
1608ec713c28Smrg	    test "X$arg" = "X-lc" && continue
1609ec713c28Smrg	    ;;
1610ec713c28Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
1611ec713c28Smrg	    # Do not include libc due to us having libc/libc_r.
1612ec713c28Smrg	    test "X$arg" = "X-lc" && continue
1613ec713c28Smrg	    ;;
1614ec713c28Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
1615ec713c28Smrg	    # Rhapsody C and math libraries are in the System framework
1616ec713c28Smrg	    deplibs="$deplibs -framework System"
1617ec713c28Smrg	    continue
1618ec713c28Smrg	    ;;
1619ec713c28Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
1620ec713c28Smrg	    # Causes problems with __ctype
1621ec713c28Smrg	    test "X$arg" = "X-lc" && continue
1622ec713c28Smrg	    ;;
1623ec713c28Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
1624ec713c28Smrg	    # Compiler inserts libc in the correct place for threads to work
1625ec713c28Smrg	    test "X$arg" = "X-lc" && continue
1626ec713c28Smrg	    ;;
1627ec713c28Smrg	  esac
1628ec713c28Smrg	elif test "X$arg" = "X-lc_r"; then
1629ec713c28Smrg	 case $host in
1630ec713c28Smrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
1631ec713c28Smrg	   # Do not include libc_r directly, use -pthread flag.
1632ec713c28Smrg	   continue
1633ec713c28Smrg	   ;;
1634ec713c28Smrg	 esac
1635786a6f21Smrg	fi
1636ec713c28Smrg	deplibs="$deplibs $arg"
1637ec713c28Smrg	continue
1638ec713c28Smrg	;;
16391d54945dSmrg
1640ec713c28Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
1641ec713c28Smrg      # classes, name mangling, and exception handling.
1642ec713c28Smrg      -model)
1643ec713c28Smrg	compile_command="$compile_command $arg"
1644ec713c28Smrg	compiler_flags="$compiler_flags $arg"
1645ec713c28Smrg	finalize_command="$finalize_command $arg"
1646ec713c28Smrg	prev=xcompiler
1647ec713c28Smrg	continue
16481d54945dSmrg	;;
16491d54945dSmrg
1650ec713c28Smrg     -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
1651ec713c28Smrg	compiler_flags="$compiler_flags $arg"
1652ec713c28Smrg	compile_command="$compile_command $arg"
1653ec713c28Smrg	finalize_command="$finalize_command $arg"
1654ec713c28Smrg	continue
16551d54945dSmrg	;;
16561d54945dSmrg
1657ec713c28Smrg      -multi_module)
1658ec713c28Smrg	single_module="${wl}-multi_module"
16591d54945dSmrg	continue
16601d54945dSmrg	;;
16611d54945dSmrg
1662ec713c28Smrg      -module)
1663ec713c28Smrg	module=yes
1664ec713c28Smrg	continue
1665ec713c28Smrg	;;
16661d54945dSmrg
1667ec713c28Smrg      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
1668ec713c28Smrg      # -r[0-9][0-9]* specifies the processor on the SGI compiler
1669ec713c28Smrg      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
1670ec713c28Smrg      # +DA*, +DD* enable 64-bit mode on the HP compiler
1671ec713c28Smrg      # -q* pass through compiler args for the IBM compiler
1672ec713c28Smrg      # -m* pass through architecture-specific compiler args for GCC
1673ec713c28Smrg      # -m*, -t[45]*, -txscale* pass through architecture-specific
1674ec713c28Smrg      # compiler args for GCC
1675ec713c28Smrg      # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
1676ec713c28Smrg      # -F/path gives path to uninstalled frameworks, gcc on darwin
1677ec713c28Smrg      # @file GCC response files
1678ec713c28Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
1679ec713c28Smrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
16801d54945dSmrg
1681ec713c28Smrg	# Unknown arguments in both finalize_command and compile_command need
1682ec713c28Smrg	# to be aesthetically quoted because they are evaled later.
1683ec713c28Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1684ec713c28Smrg	case $arg in
1685ec713c28Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1686ec713c28Smrg	  arg="\"$arg\""
1687ec713c28Smrg	  ;;
1688ec713c28Smrg	esac
1689ec713c28Smrg        compile_command="$compile_command $arg"
1690ec713c28Smrg        finalize_command="$finalize_command $arg"
1691ec713c28Smrg        compiler_flags="$compiler_flags $arg"
1692ec713c28Smrg        continue
1693ec713c28Smrg        ;;
16941d54945dSmrg
1695ec713c28Smrg      -shrext)
1696ec713c28Smrg	prev=shrext
1697ec713c28Smrg	continue
16981d54945dSmrg	;;
16991d54945dSmrg
1700ec713c28Smrg      -no-fast-install)
1701ec713c28Smrg	fast_install=no
1702ec713c28Smrg	continue
1703ec713c28Smrg	;;
17041d54945dSmrg
1705ec713c28Smrg      -no-install)
1706ec713c28Smrg	case $host in
1707ec713c28Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin*)
1708ec713c28Smrg	  # The PATH hackery in wrapper scripts is required on Windows
1709ec713c28Smrg	  # and Darwin in order for the loader to find any dlls it needs.
1710ec713c28Smrg	  $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
1711ec713c28Smrg	  $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
1712ec713c28Smrg	  fast_install=no
1713ec713c28Smrg	  ;;
1714ec713c28Smrg	*) no_install=yes ;;
1715ec713c28Smrg	esac
1716ec713c28Smrg	continue
1717ec713c28Smrg	;;
17181d54945dSmrg
1719ec713c28Smrg      -no-undefined)
1720ec713c28Smrg	allow_undefined=no
1721ec713c28Smrg	continue
1722ec713c28Smrg	;;
17231d54945dSmrg
1724ec713c28Smrg      -objectlist)
1725ec713c28Smrg	prev=objectlist
1726ec713c28Smrg	continue
1727786a6f21Smrg	;;
17281d54945dSmrg
1729ec713c28Smrg      -o) prev=output ;;
17301d54945dSmrg
1731ec713c28Smrg      -precious-files-regex)
1732ec713c28Smrg	prev=precious_regex
1733ec713c28Smrg	continue
1734ec713c28Smrg	;;
17351d54945dSmrg
1736ec713c28Smrg      -release)
1737ec713c28Smrg	prev=release
1738ec713c28Smrg	continue
1739ec713c28Smrg	;;
17401d54945dSmrg
1741ec713c28Smrg      -rpath)
1742ec713c28Smrg	prev=rpath
1743ec713c28Smrg	continue
1744ec713c28Smrg	;;
17451d54945dSmrg
1746ec713c28Smrg      -R)
1747ec713c28Smrg	prev=xrpath
17481d54945dSmrg	continue
1749ec713c28Smrg	;;
17501d54945dSmrg
1751ec713c28Smrg      -R*)
1752ec713c28Smrg	dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
1753ec713c28Smrg	# We need an absolute path.
1754ec713c28Smrg	case $dir in
1755ec713c28Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
1756ec713c28Smrg	*)
1757ec713c28Smrg	  $echo "$modename: only absolute run-paths are allowed" 1>&2
1758ec713c28Smrg	  exit $EXIT_FAILURE
1759ec713c28Smrg	  ;;
1760ec713c28Smrg	esac
1761ec713c28Smrg	case "$xrpath " in
1762ec713c28Smrg	*" $dir "*) ;;
1763ec713c28Smrg	*) xrpath="$xrpath $dir" ;;
1764786a6f21Smrg	esac
1765ec713c28Smrg	continue
1766786a6f21Smrg	;;
1767ec713c28Smrg
1768ec713c28Smrg      -static | -static-libtool-libs)
1769ec713c28Smrg	# The effects of -static are defined in a previous loop.
1770ec713c28Smrg	# We used to do the same as -all-static on platforms that
1771ec713c28Smrg	# didn't have a PIC flag, but the assumption that the effects
1772ec713c28Smrg	# would be equivalent was wrong.  It would break on at least
1773ec713c28Smrg	# Digital Unix and AIX.
1774ec713c28Smrg	continue
1775786a6f21Smrg	;;
1776ec713c28Smrg
1777ec713c28Smrg      -thread-safe)
1778ec713c28Smrg	thread_safe=yes
1779786a6f21Smrg	continue
1780786a6f21Smrg	;;
1781ec713c28Smrg
1782ec713c28Smrg      -version-info)
1783ec713c28Smrg	prev=vinfo
1784ec713c28Smrg	continue
1785786a6f21Smrg	;;
1786ec713c28Smrg      -version-number)
1787ec713c28Smrg	prev=vinfo
1788ec713c28Smrg	vinfo_number=yes
1789ec713c28Smrg	continue
17901d54945dSmrg	;;
17911d54945dSmrg
1792ec713c28Smrg      -Wc,*)
1793ec713c28Smrg	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
1794ec713c28Smrg	arg=
1795ec713c28Smrg	save_ifs="$IFS"; IFS=','
1796ec713c28Smrg	for flag in $args; do
1797ec713c28Smrg	  IFS="$save_ifs"
1798ec713c28Smrg	  case $flag in
1799ec713c28Smrg	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1800ec713c28Smrg	    flag="\"$flag\""
1801ec713c28Smrg	    ;;
1802ec713c28Smrg	  esac
1803ec713c28Smrg	  arg="$arg $wl$flag"
1804ec713c28Smrg	  compiler_flags="$compiler_flags $flag"
1805ec713c28Smrg	done
1806ec713c28Smrg	IFS="$save_ifs"
1807ec713c28Smrg	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
1808ec713c28Smrg	;;
18091d54945dSmrg
1810ec713c28Smrg      -Wl,*)
1811ec713c28Smrg	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
1812ec713c28Smrg	arg=
1813ec713c28Smrg	save_ifs="$IFS"; IFS=','
1814ec713c28Smrg	for flag in $args; do
1815ec713c28Smrg	  IFS="$save_ifs"
1816ec713c28Smrg	  case $flag in
1817ec713c28Smrg	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1818ec713c28Smrg	    flag="\"$flag\""
1819ec713c28Smrg	    ;;
1820ec713c28Smrg	  esac
1821ec713c28Smrg	  arg="$arg $wl$flag"
1822ec713c28Smrg	  compiler_flags="$compiler_flags $wl$flag"
1823ec713c28Smrg	  linker_flags="$linker_flags $flag"
1824ec713c28Smrg	done
1825ec713c28Smrg	IFS="$save_ifs"
1826ec713c28Smrg	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
1827ec713c28Smrg	;;
18281d54945dSmrg
1829ec713c28Smrg      -Xcompiler)
1830ec713c28Smrg	prev=xcompiler
1831ec713c28Smrg	continue
1832ec713c28Smrg	;;
18331d54945dSmrg
1834ec713c28Smrg      -Xlinker)
1835ec713c28Smrg	prev=xlinker
1836ec713c28Smrg	continue
1837ec713c28Smrg	;;
18381d54945dSmrg
1839ec713c28Smrg      -XCClinker)
1840ec713c28Smrg	prev=xcclinker
1841ec713c28Smrg	continue
1842ec713c28Smrg	;;
18431d54945dSmrg
1844ec713c28Smrg      # Some other compiler flag.
1845ec713c28Smrg      -* | +*)
1846ec713c28Smrg	# Unknown arguments in both finalize_command and compile_command need
1847ec713c28Smrg	# to be aesthetically quoted because they are evaled later.
1848ec713c28Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1849ec713c28Smrg	case $arg in
1850ec713c28Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1851ec713c28Smrg	  arg="\"$arg\""
1852786a6f21Smrg	  ;;
1853786a6f21Smrg	esac
1854ec713c28Smrg	;;
18551d54945dSmrg
1856ec713c28Smrg      *.$objext)
1857ec713c28Smrg	# A standard object.
1858ec713c28Smrg	objs="$objs $arg"
1859786a6f21Smrg	;;
1860786a6f21Smrg
1861ec713c28Smrg      *.lo)
1862ec713c28Smrg	# A libtool-controlled object.
1863786a6f21Smrg
1864ec713c28Smrg	# Check to see that this really is a libtool object.
1865ec713c28Smrg	if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
1866ec713c28Smrg	  pic_object=
1867ec713c28Smrg	  non_pic_object=
1868786a6f21Smrg
1869ec713c28Smrg	  # Read the .lo file
1870ec713c28Smrg	  # If there is no directory component, then add one.
1871ec713c28Smrg	  case $arg in
1872ec713c28Smrg	  */* | *\\*) . $arg ;;
1873ec713c28Smrg	  *) . ./$arg ;;
1874786a6f21Smrg	  esac
1875786a6f21Smrg
1876ec713c28Smrg	  if test -z "$pic_object" || \
1877ec713c28Smrg	     test -z "$non_pic_object" ||
1878ec713c28Smrg	     test "$pic_object" = none && \
1879ec713c28Smrg	     test "$non_pic_object" = none; then
1880ec713c28Smrg	    $echo "$modename: cannot find name of object for \`$arg'" 1>&2
1881ec713c28Smrg	    exit $EXIT_FAILURE
1882ec713c28Smrg	  fi
1883786a6f21Smrg
1884ec713c28Smrg	  # Extract subdirectory from the argument.
1885ec713c28Smrg	  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1886ec713c28Smrg	  if test "X$xdir" = "X$arg"; then
1887ec713c28Smrg	    xdir=
1888ec713c28Smrg 	  else
1889ec713c28Smrg	    xdir="$xdir/"
1890786a6f21Smrg	  fi
1891786a6f21Smrg
1892ec713c28Smrg	  if test "$pic_object" != none; then
1893ec713c28Smrg	    # Prepend the subdirectory the object is found in.
1894ec713c28Smrg	    pic_object="$xdir$pic_object"
1895786a6f21Smrg
1896ec713c28Smrg	    if test "$prev" = dlfiles; then
1897ec713c28Smrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
1898ec713c28Smrg		dlfiles="$dlfiles $pic_object"
1899ec713c28Smrg		prev=
1900ec713c28Smrg		continue
1901ec713c28Smrg	      else
1902ec713c28Smrg		# If libtool objects are unsupported, then we need to preload.
1903ec713c28Smrg		prev=dlprefiles
1904ec713c28Smrg	      fi
1905ec713c28Smrg	    fi
1906786a6f21Smrg
1907ec713c28Smrg	    # CHECK ME:  I think I busted this.  -Ossama
1908ec713c28Smrg	    if test "$prev" = dlprefiles; then
1909ec713c28Smrg	      # Preload the old-style object.
1910ec713c28Smrg	      dlprefiles="$dlprefiles $pic_object"
1911ec713c28Smrg	      prev=
1912ec713c28Smrg	    fi
1913786a6f21Smrg
1914ec713c28Smrg	    # A PIC object.
1915ec713c28Smrg	    libobjs="$libobjs $pic_object"
1916ec713c28Smrg	    arg="$pic_object"
1917786a6f21Smrg	  fi
1918786a6f21Smrg
1919ec713c28Smrg	  # Non-PIC object.
1920ec713c28Smrg	  if test "$non_pic_object" != none; then
1921ec713c28Smrg	    # Prepend the subdirectory the object is found in.
1922ec713c28Smrg	    non_pic_object="$xdir$non_pic_object"
1923ec713c28Smrg
1924ec713c28Smrg	    # A standard non-PIC object
1925ec713c28Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
1926ec713c28Smrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
1927ec713c28Smrg	      arg="$non_pic_object"
1928ec713c28Smrg	    fi
1929ec713c28Smrg	  else
1930ec713c28Smrg	    # If the PIC object exists, use it instead.
1931ec713c28Smrg	    # $xdir was prepended to $pic_object above.
1932ec713c28Smrg	    non_pic_object="$pic_object"
1933ec713c28Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
1934786a6f21Smrg	  fi
1935ec713c28Smrg	else
1936ec713c28Smrg	  # Only an error if not doing a dry-run.
1937ec713c28Smrg	  if test -z "$run"; then
1938ec713c28Smrg	    $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
1939ec713c28Smrg	    exit $EXIT_FAILURE
1940ec713c28Smrg	  else
1941ec713c28Smrg	    # Dry-run case.
1942786a6f21Smrg
1943ec713c28Smrg	    # Extract subdirectory from the argument.
1944ec713c28Smrg	    xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1945ec713c28Smrg	    if test "X$xdir" = "X$arg"; then
1946ec713c28Smrg	      xdir=
1947ec713c28Smrg	    else
1948ec713c28Smrg	      xdir="$xdir/"
1949ec713c28Smrg	    fi
1950786a6f21Smrg
1951ec713c28Smrg	    pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
1952ec713c28Smrg	    non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
1953ec713c28Smrg	    libobjs="$libobjs $pic_object"
1954ec713c28Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
1955ec713c28Smrg	  fi
1956ec713c28Smrg	fi
1957ec713c28Smrg	;;
1958786a6f21Smrg
1959ec713c28Smrg      *.$libext)
1960ec713c28Smrg	# An archive.
1961ec713c28Smrg	deplibs="$deplibs $arg"
1962ec713c28Smrg	old_deplibs="$old_deplibs $arg"
1963ec713c28Smrg	continue
19641d54945dSmrg	;;
1965786a6f21Smrg
1966ec713c28Smrg      *.la)
1967ec713c28Smrg	# A libtool-controlled library.
1968786a6f21Smrg
1969ec713c28Smrg	if test "$prev" = dlfiles; then
1970ec713c28Smrg	  # This library was specified with -dlopen.
1971ec713c28Smrg	  dlfiles="$dlfiles $arg"
1972ec713c28Smrg	  prev=
1973ec713c28Smrg	elif test "$prev" = dlprefiles; then
1974ec713c28Smrg	  # The library was specified with -dlpreopen.
1975ec713c28Smrg	  dlprefiles="$dlprefiles $arg"
1976ec713c28Smrg	  prev=
1977786a6f21Smrg	else
1978ec713c28Smrg	  deplibs="$deplibs $arg"
1979786a6f21Smrg	fi
1980ec713c28Smrg	continue
1981ec713c28Smrg	;;
1982786a6f21Smrg
1983ec713c28Smrg      # Some other compiler argument.
1984ec713c28Smrg      *)
1985ec713c28Smrg	# Unknown arguments in both finalize_command and compile_command need
1986ec713c28Smrg	# to be aesthetically quoted because they are evaled later.
1987ec713c28Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1988ec713c28Smrg	case $arg in
1989ec713c28Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1990ec713c28Smrg	  arg="\"$arg\""
19911d54945dSmrg	  ;;
1992786a6f21Smrg	esac
1993786a6f21Smrg	;;
1994ec713c28Smrg      esac # arg
19951d54945dSmrg
1996ec713c28Smrg      # Now actually substitute the argument into the commands.
1997ec713c28Smrg      if test -n "$arg"; then
1998ec713c28Smrg	compile_command="$compile_command $arg"
1999ec713c28Smrg	finalize_command="$finalize_command $arg"
2000ec713c28Smrg      fi
2001ec713c28Smrg    done # argument parsing loop
20021d54945dSmrg
2003ec713c28Smrg    if test -n "$prev"; then
2004ec713c28Smrg      $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
2005ec713c28Smrg      $echo "$help" 1>&2
2006ec713c28Smrg      exit $EXIT_FAILURE
2007ec713c28Smrg    fi
20081d54945dSmrg
2009ec713c28Smrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
2010ec713c28Smrg      eval arg=\"$export_dynamic_flag_spec\"
2011ec713c28Smrg      compile_command="$compile_command $arg"
2012ec713c28Smrg      finalize_command="$finalize_command $arg"
2013ec713c28Smrg    fi
20141d54945dSmrg
2015ec713c28Smrg    oldlibs=
2016ec713c28Smrg    # calculate the name of the file, without its directory
2017ec713c28Smrg    outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
2018ec713c28Smrg    libobjs_save="$libobjs"
20191d54945dSmrg
2020ec713c28Smrg    if test -n "$shlibpath_var"; then
2021ec713c28Smrg      # get the directories listed in $shlibpath_var
2022ec713c28Smrg      eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
2023ec713c28Smrg    else
2024ec713c28Smrg      shlib_search_path=
2025ec713c28Smrg    fi
2026ec713c28Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
2027ec713c28Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
2028786a6f21Smrg
2029ec713c28Smrg    output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
2030ec713c28Smrg    if test "X$output_objdir" = "X$output"; then
2031ec713c28Smrg      output_objdir="$objdir"
2032786a6f21Smrg    else
2033ec713c28Smrg      output_objdir="$output_objdir/$objdir"
2034786a6f21Smrg    fi
2035ec713c28Smrg    # Create the object directory.
2036ec713c28Smrg    if test ! -d "$output_objdir"; then
2037ec713c28Smrg      $show "$mkdir $output_objdir"
2038ec713c28Smrg      $run $mkdir $output_objdir
2039ec713c28Smrg      exit_status=$?
2040ec713c28Smrg      if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then
2041ec713c28Smrg	exit $exit_status
2042786a6f21Smrg      fi
2043786a6f21Smrg    fi
2044786a6f21Smrg
2045ec713c28Smrg    # Determine the type of output
2046ec713c28Smrg    case $output in
2047ec713c28Smrg    "")
2048ec713c28Smrg      $echo "$modename: you must specify an output file" 1>&2
2049ec713c28Smrg      $echo "$help" 1>&2
2050ec713c28Smrg      exit $EXIT_FAILURE
2051ec713c28Smrg      ;;
2052ec713c28Smrg    *.$libext) linkmode=oldlib ;;
2053ec713c28Smrg    *.lo | *.$objext) linkmode=obj ;;
2054ec713c28Smrg    *.la) linkmode=lib ;;
2055ec713c28Smrg    *) linkmode=prog ;; # Anything else should be a program.
2056ec713c28Smrg    esac
20571d54945dSmrg
2058ec713c28Smrg    case $host in
2059ec713c28Smrg    *cygwin* | *mingw* | *pw32*)
2060ec713c28Smrg      # don't eliminate duplications in $postdeps and $predeps
2061ec713c28Smrg      duplicate_compiler_generated_deps=yes
2062ec713c28Smrg      ;;
2063ec713c28Smrg    *)
2064ec713c28Smrg      duplicate_compiler_generated_deps=$duplicate_deps
2065ec713c28Smrg      ;;
2066ec713c28Smrg    esac
2067ec713c28Smrg    specialdeplibs=
20681d54945dSmrg
2069ec713c28Smrg    libs=
2070ec713c28Smrg    # Find all interdependent deplibs by searching for libraries
2071ec713c28Smrg    # that are linked more than once (e.g. -la -lb -la)
2072ec713c28Smrg    for deplib in $deplibs; do
2073ec713c28Smrg      if test "X$duplicate_deps" = "Xyes" ; then
2074ec713c28Smrg	case "$libs " in
2075ec713c28Smrg	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2076ec713c28Smrg	esac
2077ec713c28Smrg      fi
2078ec713c28Smrg      libs="$libs $deplib"
2079ec713c28Smrg    done
20801d54945dSmrg
2081ec713c28Smrg    if test "$linkmode" = lib; then
2082ec713c28Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
20831d54945dSmrg
2084ec713c28Smrg      # Compute libraries that are listed more than once in $predeps
2085ec713c28Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
2086ec713c28Smrg      # not to be eliminated).
2087ec713c28Smrg      pre_post_deps=
2088ec713c28Smrg      if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
2089ec713c28Smrg	for pre_post_dep in $predeps $postdeps; do
2090ec713c28Smrg	  case "$pre_post_deps " in
2091ec713c28Smrg	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
2092786a6f21Smrg	  esac
2093ec713c28Smrg	  pre_post_deps="$pre_post_deps $pre_post_dep"
2094ec713c28Smrg	done
2095ec713c28Smrg      fi
2096ec713c28Smrg      pre_post_deps=
2097ec713c28Smrg    fi
20981d54945dSmrg
2099ec713c28Smrg    deplibs=
2100ec713c28Smrg    newdependency_libs=
2101ec713c28Smrg    newlib_search_path=
2102ec713c28Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
2103ec713c28Smrg    notinst_deplibs= # not-installed libtool libraries
2104ec713c28Smrg    case $linkmode in
2105ec713c28Smrg    lib)
2106ec713c28Smrg	passes="conv link"
2107ec713c28Smrg	for file in $dlfiles $dlprefiles; do
2108ec713c28Smrg	  case $file in
2109ec713c28Smrg	  *.la) ;;
2110786a6f21Smrg	  *)
2111ec713c28Smrg	    $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
2112ec713c28Smrg	    exit $EXIT_FAILURE
2113786a6f21Smrg	    ;;
2114786a6f21Smrg	  esac
2115786a6f21Smrg	done
2116786a6f21Smrg	;;
2117ec713c28Smrg    prog)
2118ec713c28Smrg	compile_deplibs=
2119ec713c28Smrg	finalize_deplibs=
2120ec713c28Smrg	alldeplibs=no
2121ec713c28Smrg	newdlfiles=
2122ec713c28Smrg	newdlprefiles=
2123ec713c28Smrg	passes="conv scan dlopen dlpreopen link"
2124ec713c28Smrg	;;
2125ec713c28Smrg    *)  passes="conv"
2126786a6f21Smrg	;;
2127786a6f21Smrg    esac
2128ec713c28Smrg    for pass in $passes; do
2129ec713c28Smrg      if test "$linkmode,$pass" = "lib,link" ||
2130ec713c28Smrg	 test "$linkmode,$pass" = "prog,scan"; then
2131ec713c28Smrg	libs="$deplibs"
2132ec713c28Smrg	deplibs=
2133ec713c28Smrg      fi
2134ec713c28Smrg      if test "$linkmode" = prog; then
2135ec713c28Smrg	case $pass in
2136ec713c28Smrg	dlopen) libs="$dlfiles" ;;
2137ec713c28Smrg	dlpreopen) libs="$dlprefiles" ;;
2138ec713c28Smrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
2139ec713c28Smrg	esac
2140ec713c28Smrg      fi
2141ec713c28Smrg      if test "$pass" = dlopen; then
2142ec713c28Smrg	# Collect dlpreopened libraries
2143ec713c28Smrg	save_deplibs="$deplibs"
2144ec713c28Smrg	deplibs=
2145ec713c28Smrg      fi
2146ec713c28Smrg      for deplib in $libs; do
2147ec713c28Smrg	lib=
2148ec713c28Smrg	found=no
2149ec713c28Smrg	case $deplib in
2150ec713c28Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
2151ec713c28Smrg	  if test "$linkmode,$pass" = "prog,link"; then
2152ec713c28Smrg	    compile_deplibs="$deplib $compile_deplibs"
2153ec713c28Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
2154ec713c28Smrg	  else
2155ec713c28Smrg	    compiler_flags="$compiler_flags $deplib"
2156ec713c28Smrg	  fi
2157ec713c28Smrg	  continue
2158ec713c28Smrg	  ;;
2159ec713c28Smrg	-l*)
2160ec713c28Smrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
2161ec713c28Smrg	    $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
2162ec713c28Smrg	    continue
2163ec713c28Smrg	  fi
2164ec713c28Smrg	  name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
2165ec713c28Smrg	  if test "$linkmode" = lib; then
2166ec713c28Smrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
2167ec713c28Smrg	  else
2168ec713c28Smrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
2169ec713c28Smrg	  fi
2170ec713c28Smrg	  for searchdir in $searchdirs; do
2171ec713c28Smrg	    for search_ext in .la $std_shrext .so .a; do
2172ec713c28Smrg	      # Search the libtool library
2173ec713c28Smrg	      lib="$searchdir/lib${name}${search_ext}"
2174ec713c28Smrg	      if test -f "$lib"; then
2175ec713c28Smrg		if test "$search_ext" = ".la"; then
2176ec713c28Smrg		  found=yes
2177ec713c28Smrg		else
2178ec713c28Smrg		  found=no
2179ec713c28Smrg		fi
2180ec713c28Smrg		break 2
2181ec713c28Smrg	      fi
2182ec713c28Smrg	    done
2183ec713c28Smrg	  done
2184ec713c28Smrg	  if test "$found" != yes; then
2185ec713c28Smrg	    # deplib doesn't seem to be a libtool library
2186ec713c28Smrg	    if test "$linkmode,$pass" = "prog,link"; then
2187ec713c28Smrg	      compile_deplibs="$deplib $compile_deplibs"
2188ec713c28Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
2189ec713c28Smrg	    else
2190ec713c28Smrg	      deplibs="$deplib $deplibs"
2191ec713c28Smrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
2192ec713c28Smrg	    fi
2193ec713c28Smrg	    continue
2194ec713c28Smrg	  else # deplib is a libtool library
2195ec713c28Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
2196ec713c28Smrg	    # We need to do some special things here, and not later.
2197ec713c28Smrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
2198ec713c28Smrg	      case " $predeps $postdeps " in
2199ec713c28Smrg	      *" $deplib "*)
2200ec713c28Smrg		if (${SED} -e '2q' $lib |
2201ec713c28Smrg                    grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
2202ec713c28Smrg		  library_names=
2203ec713c28Smrg		  old_library=
2204ec713c28Smrg		  case $lib in
2205ec713c28Smrg		  */* | *\\*) . $lib ;;
2206ec713c28Smrg		  *) . ./$lib ;;
2207ec713c28Smrg		  esac
2208ec713c28Smrg		  for l in $old_library $library_names; do
2209ec713c28Smrg		    ll="$l"
2210ec713c28Smrg		  done
2211ec713c28Smrg		  if test "X$ll" = "X$old_library" ; then # only static version available
2212ec713c28Smrg		    found=no
2213ec713c28Smrg		    ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
2214ec713c28Smrg		    test "X$ladir" = "X$lib" && ladir="."
2215ec713c28Smrg		    lib=$ladir/$old_library
2216ec713c28Smrg		    if test "$linkmode,$pass" = "prog,link"; then
2217ec713c28Smrg		      compile_deplibs="$deplib $compile_deplibs"
2218ec713c28Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
2219ec713c28Smrg		    else
2220ec713c28Smrg		      deplibs="$deplib $deplibs"
2221ec713c28Smrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
2222ec713c28Smrg		    fi
2223ec713c28Smrg		    continue
2224ec713c28Smrg		  fi
2225ec713c28Smrg		fi
2226ec713c28Smrg	        ;;
2227ec713c28Smrg	      *) ;;
2228ec713c28Smrg	      esac
2229ec713c28Smrg	    fi
2230ec713c28Smrg	  fi
2231ec713c28Smrg	  ;; # -l
2232ec713c28Smrg	-L*)
2233ec713c28Smrg	  case $linkmode in
2234ec713c28Smrg	  lib)
2235ec713c28Smrg	    deplibs="$deplib $deplibs"
2236ec713c28Smrg	    test "$pass" = conv && continue
2237ec713c28Smrg	    newdependency_libs="$deplib $newdependency_libs"
2238ec713c28Smrg	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
2239ec713c28Smrg	    ;;
2240ec713c28Smrg	  prog)
2241ec713c28Smrg	    if test "$pass" = conv; then
2242ec713c28Smrg	      deplibs="$deplib $deplibs"
2243ec713c28Smrg	      continue
2244ec713c28Smrg	    fi
2245ec713c28Smrg	    if test "$pass" = scan; then
2246ec713c28Smrg	      deplibs="$deplib $deplibs"
2247ec713c28Smrg	    else
2248ec713c28Smrg	      compile_deplibs="$deplib $compile_deplibs"
2249ec713c28Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
2250ec713c28Smrg	    fi
2251ec713c28Smrg	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
2252ec713c28Smrg	    ;;
2253ec713c28Smrg	  *)
2254ec713c28Smrg	    $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
2255ec713c28Smrg	    ;;
2256ec713c28Smrg	  esac # linkmode
2257ec713c28Smrg	  continue
2258ec713c28Smrg	  ;; # -L
2259ec713c28Smrg	-R*)
2260ec713c28Smrg	  if test "$pass" = link; then
2261ec713c28Smrg	    dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
2262ec713c28Smrg	    # Make sure the xrpath contains only unique directories.
2263ec713c28Smrg	    case "$xrpath " in
2264ec713c28Smrg	    *" $dir "*) ;;
2265ec713c28Smrg	    *) xrpath="$xrpath $dir" ;;
2266ec713c28Smrg	    esac
2267ec713c28Smrg	  fi
2268ec713c28Smrg	  deplibs="$deplib $deplibs"
2269ec713c28Smrg	  continue
2270ec713c28Smrg	  ;;
2271ec713c28Smrg	*.la) lib="$deplib" ;;
2272ec713c28Smrg	*.$libext)
2273ec713c28Smrg	  if test "$pass" = conv; then
2274ec713c28Smrg	    deplibs="$deplib $deplibs"
2275ec713c28Smrg	    continue
2276ec713c28Smrg	  fi
2277ec713c28Smrg	  case $linkmode in
2278ec713c28Smrg	  lib)
2279ec713c28Smrg	    valid_a_lib=no
2280ec713c28Smrg	    case $deplibs_check_method in
2281ec713c28Smrg	      match_pattern*)
2282ec713c28Smrg		set dummy $deplibs_check_method
2283ec713c28Smrg	        match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
2284ec713c28Smrg		if eval $echo \"$deplib\" 2>/dev/null \
2285ec713c28Smrg		    | $SED 10q \
2286ec713c28Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
2287ec713c28Smrg		  valid_a_lib=yes
2288ec713c28Smrg		fi
2289ec713c28Smrg		;;
2290ec713c28Smrg	      pass_all)
2291ec713c28Smrg		valid_a_lib=yes
2292ec713c28Smrg		;;
2293ec713c28Smrg            esac
2294ec713c28Smrg	    if test "$valid_a_lib" != yes; then
2295ec713c28Smrg	      $echo
2296ec713c28Smrg	      $echo "*** Warning: Trying to link with static lib archive $deplib."
2297ec713c28Smrg	      $echo "*** I have the capability to make that library automatically link in when"
2298ec713c28Smrg	      $echo "*** you link to this library.  But I can only do this if you have a"
2299ec713c28Smrg	      $echo "*** shared version of the library, which you do not appear to have"
2300ec713c28Smrg	      $echo "*** because the file extensions .$libext of this argument makes me believe"
2301ec713c28Smrg	      $echo "*** that it is just a static archive that I should not used here."
2302ec713c28Smrg	    else
2303ec713c28Smrg	      $echo
2304ec713c28Smrg	      $echo "*** Warning: Linking the shared library $output against the"
2305ec713c28Smrg	      $echo "*** static library $deplib is not portable!"
2306ec713c28Smrg	      deplibs="$deplib $deplibs"
2307ec713c28Smrg	    fi
2308ec713c28Smrg	    continue
2309ec713c28Smrg	    ;;
2310ec713c28Smrg	  prog)
2311ec713c28Smrg	    if test "$pass" != link; then
2312ec713c28Smrg	      deplibs="$deplib $deplibs"
2313ec713c28Smrg	    else
2314ec713c28Smrg	      compile_deplibs="$deplib $compile_deplibs"
2315ec713c28Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
2316ec713c28Smrg	    fi
2317ec713c28Smrg	    continue
2318ec713c28Smrg	    ;;
2319ec713c28Smrg	  esac # linkmode
2320ec713c28Smrg	  ;; # *.$libext
2321ec713c28Smrg	*.lo | *.$objext)
2322ec713c28Smrg	  if test "$pass" = conv; then
2323ec713c28Smrg	    deplibs="$deplib $deplibs"
2324ec713c28Smrg	  elif test "$linkmode" = prog; then
2325ec713c28Smrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
2326ec713c28Smrg	      # If there is no dlopen support or we're linking statically,
2327ec713c28Smrg	      # we need to preload.
2328ec713c28Smrg	      newdlprefiles="$newdlprefiles $deplib"
2329ec713c28Smrg	      compile_deplibs="$deplib $compile_deplibs"
2330ec713c28Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
2331ec713c28Smrg	    else
2332ec713c28Smrg	      newdlfiles="$newdlfiles $deplib"
2333ec713c28Smrg	    fi
2334ec713c28Smrg	  fi
2335ec713c28Smrg	  continue
2336ec713c28Smrg	  ;;
2337ec713c28Smrg	%DEPLIBS%)
2338ec713c28Smrg	  alldeplibs=yes
2339ec713c28Smrg	  continue
2340ec713c28Smrg	  ;;
2341ec713c28Smrg	esac # case $deplib
2342ec713c28Smrg	if test "$found" = yes || test -f "$lib"; then :
2343ec713c28Smrg	else
2344ec713c28Smrg	  $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2
2345ec713c28Smrg	  exit $EXIT_FAILURE
2346ec713c28Smrg	fi
23471d54945dSmrg
2348ec713c28Smrg	# Check to see that this really is a libtool archive.
2349ec713c28Smrg	if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
2350ec713c28Smrg	else
2351ec713c28Smrg	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
2352ec713c28Smrg	  exit $EXIT_FAILURE
2353ec713c28Smrg	fi
23541d54945dSmrg
2355ec713c28Smrg	ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
2356ec713c28Smrg	test "X$ladir" = "X$lib" && ladir="."
23571d54945dSmrg
2358ec713c28Smrg	dlname=
2359ec713c28Smrg	dlopen=
2360ec713c28Smrg	dlpreopen=
2361ec713c28Smrg	libdir=
2362ec713c28Smrg	library_names=
2363ec713c28Smrg	old_library=
2364ec713c28Smrg	# If the library was installed with an old release of libtool,
2365ec713c28Smrg	# it will not redefine variables installed, or shouldnotlink
2366ec713c28Smrg	installed=yes
2367ec713c28Smrg	shouldnotlink=no
2368ec713c28Smrg	avoidtemprpath=
23691d54945dSmrg
23701d54945dSmrg
2371ec713c28Smrg	# Read the .la file
2372ec713c28Smrg	case $lib in
2373ec713c28Smrg	*/* | *\\*) . $lib ;;
2374ec713c28Smrg	*) . ./$lib ;;
2375786a6f21Smrg	esac
23761d54945dSmrg
2377ec713c28Smrg	if test "$linkmode,$pass" = "lib,link" ||
2378ec713c28Smrg	   test "$linkmode,$pass" = "prog,scan" ||
2379ec713c28Smrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
2380ec713c28Smrg	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
2381ec713c28Smrg	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
2382ec713c28Smrg	fi
23831d54945dSmrg
2384ec713c28Smrg	if test "$pass" = conv; then
2385ec713c28Smrg	  # Only check for convenience libraries
2386ec713c28Smrg	  deplibs="$lib $deplibs"
2387ec713c28Smrg	  if test -z "$libdir"; then
2388ec713c28Smrg	    if test -z "$old_library"; then
2389ec713c28Smrg	      $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
2390ec713c28Smrg	      exit $EXIT_FAILURE
2391ec713c28Smrg	    fi
2392ec713c28Smrg	    # It is a libtool convenience library, so add in its objects.
2393ec713c28Smrg	    convenience="$convenience $ladir/$objdir/$old_library"
2394ec713c28Smrg	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
2395ec713c28Smrg	    tmp_libs=
2396ec713c28Smrg	    for deplib in $dependency_libs; do
2397ec713c28Smrg	      deplibs="$deplib $deplibs"
2398ec713c28Smrg              if test "X$duplicate_deps" = "Xyes" ; then
2399ec713c28Smrg	        case "$tmp_libs " in
2400ec713c28Smrg	        *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2401ec713c28Smrg	        esac
2402ec713c28Smrg              fi
2403ec713c28Smrg	      tmp_libs="$tmp_libs $deplib"
2404ec713c28Smrg	    done
2405ec713c28Smrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
2406ec713c28Smrg	    $echo "$modename: \`$lib' is not a convenience library" 1>&2
2407ec713c28Smrg	    exit $EXIT_FAILURE
2408ec713c28Smrg	  fi
2409ec713c28Smrg	  continue
2410ec713c28Smrg	fi # $pass = conv
24111d54945dSmrg
24121d54945dSmrg
2413ec713c28Smrg	# Get the name of the library we link against.
2414ec713c28Smrg	linklib=
2415ec713c28Smrg	for l in $old_library $library_names; do
2416ec713c28Smrg	  linklib="$l"
2417ec713c28Smrg	done
2418ec713c28Smrg	if test -z "$linklib"; then
2419ec713c28Smrg	  $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
2420ec713c28Smrg	  exit $EXIT_FAILURE
24211d54945dSmrg	fi
24221d54945dSmrg
2423ec713c28Smrg	# This library was specified with -dlopen.
2424ec713c28Smrg	if test "$pass" = dlopen; then
2425ec713c28Smrg	  if test -z "$libdir"; then
2426ec713c28Smrg	    $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
2427ec713c28Smrg	    exit $EXIT_FAILURE
2428ec713c28Smrg	  fi
2429ec713c28Smrg	  if test -z "$dlname" ||
2430ec713c28Smrg	     test "$dlopen_support" != yes ||
2431ec713c28Smrg	     test "$build_libtool_libs" = no; then
2432ec713c28Smrg	    # If there is no dlname, no dlopen support or we're linking
2433ec713c28Smrg	    # statically, we need to preload.  We also need to preload any
2434ec713c28Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
2435ec713c28Smrg	    # bomb out in the load deplibs phase.
2436ec713c28Smrg	    dlprefiles="$dlprefiles $lib $dependency_libs"
2437ec713c28Smrg	  else
2438ec713c28Smrg	    newdlfiles="$newdlfiles $lib"
2439ec713c28Smrg	  fi
2440ec713c28Smrg	  continue
2441ec713c28Smrg	fi # $pass = dlopen
24421d54945dSmrg
2443ec713c28Smrg	# We need an absolute path.
2444ec713c28Smrg	case $ladir in
2445ec713c28Smrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
2446ec713c28Smrg	*)
2447ec713c28Smrg	  abs_ladir=`cd "$ladir" && pwd`
2448ec713c28Smrg	  if test -z "$abs_ladir"; then
2449ec713c28Smrg	    $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2
2450ec713c28Smrg	    $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
2451ec713c28Smrg	    abs_ladir="$ladir"
2452ec713c28Smrg	  fi
2453ec713c28Smrg	  ;;
2454ec713c28Smrg	esac
2455ec713c28Smrg	laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
24561d54945dSmrg
2457ec713c28Smrg	# Find the relevant object directory and library name.
2458ec713c28Smrg	if test "X$installed" = Xyes; then
2459ec713c28Smrg	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
2460ec713c28Smrg	    $echo "$modename: warning: library \`$lib' was moved." 1>&2
2461ec713c28Smrg	    dir="$ladir"
2462ec713c28Smrg	    absdir="$abs_ladir"
2463ec713c28Smrg	    libdir="$abs_ladir"
2464ec713c28Smrg	  else
2465ec713c28Smrg	    dir="$libdir"
2466ec713c28Smrg	    absdir="$libdir"
2467ec713c28Smrg	  fi
2468ec713c28Smrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
2469ec713c28Smrg	else
2470ec713c28Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
2471ec713c28Smrg	    dir="$ladir"
2472ec713c28Smrg	    absdir="$abs_ladir"
2473ec713c28Smrg	    # Remove this search path later
2474ec713c28Smrg	    notinst_path="$notinst_path $abs_ladir"
2475ec713c28Smrg	  else
2476ec713c28Smrg	    dir="$ladir/$objdir"
2477ec713c28Smrg	    absdir="$abs_ladir/$objdir"
2478ec713c28Smrg	    # Remove this search path later
2479ec713c28Smrg	    notinst_path="$notinst_path $abs_ladir"
2480ec713c28Smrg	  fi
2481ec713c28Smrg	fi # $installed = yes
2482ec713c28Smrg	name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
24831d54945dSmrg
2484ec713c28Smrg	# This library was specified with -dlpreopen.
2485ec713c28Smrg	if test "$pass" = dlpreopen; then
2486ec713c28Smrg	  if test -z "$libdir"; then
2487ec713c28Smrg	    $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
2488ec713c28Smrg	    exit $EXIT_FAILURE
2489ec713c28Smrg	  fi
2490ec713c28Smrg	  # Prefer using a static library (so that no silly _DYNAMIC symbols
2491ec713c28Smrg	  # are required to link).
2492ec713c28Smrg	  if test -n "$old_library"; then
2493ec713c28Smrg	    newdlprefiles="$newdlprefiles $dir/$old_library"
2494ec713c28Smrg	  # Otherwise, use the dlname, so that lt_dlopen finds it.
2495ec713c28Smrg	  elif test -n "$dlname"; then
2496ec713c28Smrg	    newdlprefiles="$newdlprefiles $dir/$dlname"
2497ec713c28Smrg	  else
2498ec713c28Smrg	    newdlprefiles="$newdlprefiles $dir/$linklib"
2499ec713c28Smrg	  fi
2500ec713c28Smrg	fi # $pass = dlpreopen
25011d54945dSmrg
2502ec713c28Smrg	if test -z "$libdir"; then
2503ec713c28Smrg	  # Link the convenience library
2504ec713c28Smrg	  if test "$linkmode" = lib; then
2505ec713c28Smrg	    deplibs="$dir/$old_library $deplibs"
2506ec713c28Smrg	  elif test "$linkmode,$pass" = "prog,link"; then
2507ec713c28Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
2508ec713c28Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
2509ec713c28Smrg	  else
2510ec713c28Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
2511ec713c28Smrg	  fi
2512ec713c28Smrg	  continue
2513ec713c28Smrg	fi
25141d54945dSmrg
25151d54945dSmrg
2516ec713c28Smrg	if test "$linkmode" = prog && test "$pass" != link; then
2517ec713c28Smrg	  newlib_search_path="$newlib_search_path $ladir"
2518ec713c28Smrg	  deplibs="$lib $deplibs"
25191d54945dSmrg
2520ec713c28Smrg	  linkalldeplibs=no
2521ec713c28Smrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
2522ec713c28Smrg	     test "$build_libtool_libs" = no; then
2523ec713c28Smrg	    linkalldeplibs=yes
2524ec713c28Smrg	  fi
25251d54945dSmrg
2526ec713c28Smrg	  tmp_libs=
2527ec713c28Smrg	  for deplib in $dependency_libs; do
2528ec713c28Smrg	    case $deplib in
2529ec713c28Smrg	    -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
2530ec713c28Smrg	    esac
2531ec713c28Smrg	    # Need to link against all dependency_libs?
2532ec713c28Smrg	    if test "$linkalldeplibs" = yes; then
2533ec713c28Smrg	      deplibs="$deplib $deplibs"
2534ec713c28Smrg	    else
2535ec713c28Smrg	      # Need to hardcode shared library paths
2536ec713c28Smrg	      # or/and link against static libraries
2537ec713c28Smrg	      newdependency_libs="$deplib $newdependency_libs"
2538ec713c28Smrg	    fi
2539ec713c28Smrg	    if test "X$duplicate_deps" = "Xyes" ; then
2540ec713c28Smrg	      case "$tmp_libs " in
2541ec713c28Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2542ec713c28Smrg	      esac
2543ec713c28Smrg	    fi
2544ec713c28Smrg	    tmp_libs="$tmp_libs $deplib"
2545ec713c28Smrg	  done # for deplib
2546ec713c28Smrg	  continue
2547ec713c28Smrg	fi # $linkmode = prog...
25481d54945dSmrg
2549ec713c28Smrg	if test "$linkmode,$pass" = "prog,link"; then
2550ec713c28Smrg	  if test -n "$library_names" &&
2551ec713c28Smrg	     { { test "$prefer_static_libs" = no ||
2552ec713c28Smrg		 test "$prefer_static_libs,$installed" = "built,yes"; } ||
2553ec713c28Smrg	       test -z "$old_library"; }; then
2554ec713c28Smrg	    # We need to hardcode the library path
2555ec713c28Smrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
2556ec713c28Smrg	      # Make sure the rpath contains only unique directories.
2557ec713c28Smrg	      case "$temp_rpath " in
2558ec713c28Smrg	      *" $dir "*) ;;
2559ec713c28Smrg	      *" $absdir "*) ;;
2560ec713c28Smrg	      *) temp_rpath="$temp_rpath $absdir" ;;
2561ec713c28Smrg	      esac
2562ec713c28Smrg	    fi
25631d54945dSmrg
2564ec713c28Smrg	    # Hardcode the library path.
2565ec713c28Smrg	    # Skip directories that are in the system default run-time
2566ec713c28Smrg	    # search path.
2567ec713c28Smrg	    case " $sys_lib_dlsearch_path " in
2568ec713c28Smrg	    *" $absdir "*) ;;
2569ec713c28Smrg	    *)
2570ec713c28Smrg	      case "$compile_rpath " in
2571ec713c28Smrg	      *" $absdir "*) ;;
2572ec713c28Smrg	      *) compile_rpath="$compile_rpath $absdir"
2573ec713c28Smrg	      esac
2574ec713c28Smrg	      ;;
2575ec713c28Smrg	    esac
2576ec713c28Smrg	    case " $sys_lib_dlsearch_path " in
2577ec713c28Smrg	    *" $libdir "*) ;;
2578ec713c28Smrg	    *)
2579ec713c28Smrg	      case "$finalize_rpath " in
2580ec713c28Smrg	      *" $libdir "*) ;;
2581ec713c28Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
2582ec713c28Smrg	      esac
2583ec713c28Smrg	      ;;
2584ec713c28Smrg	    esac
2585ec713c28Smrg	  fi # $linkmode,$pass = prog,link...
25861d54945dSmrg
2587ec713c28Smrg	  if test "$alldeplibs" = yes &&
2588ec713c28Smrg	     { test "$deplibs_check_method" = pass_all ||
2589ec713c28Smrg	       { test "$build_libtool_libs" = yes &&
2590ec713c28Smrg		 test -n "$library_names"; }; }; then
2591ec713c28Smrg	    # We only need to search for static libraries
2592ec713c28Smrg	    continue
2593ec713c28Smrg	  fi
2594786a6f21Smrg	fi
25951d54945dSmrg
2596ec713c28Smrg	link_static=no # Whether the deplib will be linked statically
2597ec713c28Smrg	use_static_libs=$prefer_static_libs
2598ec713c28Smrg	if test "$use_static_libs" = built && test "$installed" = yes ; then
2599ec713c28Smrg	  use_static_libs=no
2600ec713c28Smrg	fi
2601ec713c28Smrg	if test -n "$library_names" &&
2602ec713c28Smrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
2603ec713c28Smrg	  if test "$installed" = no; then
2604ec713c28Smrg	    notinst_deplibs="$notinst_deplibs $lib"
2605ec713c28Smrg	    need_relink=yes
2606ec713c28Smrg	  fi
2607ec713c28Smrg	  # This is a shared library
26081d54945dSmrg
2609ec713c28Smrg	  # Warn about portability, can't link against -module's on
2610ec713c28Smrg	  # some systems (darwin)
2611ec713c28Smrg	  if test "$shouldnotlink" = yes && test "$pass" = link ; then
2612ec713c28Smrg	    $echo
2613ec713c28Smrg	    if test "$linkmode" = prog; then
2614ec713c28Smrg	      $echo "*** Warning: Linking the executable $output against the loadable module"
2615ec713c28Smrg	    else
2616ec713c28Smrg	      $echo "*** Warning: Linking the shared library $output against the loadable module"
2617ec713c28Smrg	    fi
2618ec713c28Smrg	    $echo "*** $linklib is not portable!"
2619ec713c28Smrg	  fi
2620ec713c28Smrg	  if test "$linkmode" = lib &&
2621ec713c28Smrg	     test "$hardcode_into_libs" = yes; then
2622ec713c28Smrg	    # Hardcode the library path.
2623ec713c28Smrg	    # Skip directories that are in the system default run-time
2624ec713c28Smrg	    # search path.
2625ec713c28Smrg	    case " $sys_lib_dlsearch_path " in
2626ec713c28Smrg	    *" $absdir "*) ;;
2627ec713c28Smrg	    *)
2628ec713c28Smrg	      case "$compile_rpath " in
2629ec713c28Smrg	      *" $absdir "*) ;;
2630ec713c28Smrg	      *) compile_rpath="$compile_rpath $absdir"
2631ec713c28Smrg	      esac
2632ec713c28Smrg	      ;;
2633ec713c28Smrg	    esac
2634ec713c28Smrg	    case " $sys_lib_dlsearch_path " in
2635ec713c28Smrg	    *" $libdir "*) ;;
2636ec713c28Smrg	    *)
2637ec713c28Smrg	      case "$finalize_rpath " in
2638ec713c28Smrg	      *" $libdir "*) ;;
2639ec713c28Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
2640ec713c28Smrg	      esac
2641ec713c28Smrg	      ;;
2642ec713c28Smrg	    esac
2643ec713c28Smrg	  fi
26441d54945dSmrg
2645ec713c28Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
2646ec713c28Smrg	    # figure out the soname
2647ec713c28Smrg	    set dummy $library_names
2648ec713c28Smrg	    realname="$2"
2649ec713c28Smrg	    shift; shift
2650ec713c28Smrg	    libname=`eval \\$echo \"$libname_spec\"`
2651ec713c28Smrg	    # use dlname if we got it. it's perfectly good, no?
2652ec713c28Smrg	    if test -n "$dlname"; then
2653ec713c28Smrg	      soname="$dlname"
2654ec713c28Smrg	    elif test -n "$soname_spec"; then
2655ec713c28Smrg	      # bleh windows
2656ec713c28Smrg	      case $host in
2657ec713c28Smrg	      *cygwin* | mingw*)
2658ec713c28Smrg		major=`expr $current - $age`
2659ec713c28Smrg		versuffix="-$major"
2660ec713c28Smrg		;;
2661ec713c28Smrg	      esac
2662ec713c28Smrg	      eval soname=\"$soname_spec\"
2663ec713c28Smrg	    else
2664ec713c28Smrg	      soname="$realname"
2665ec713c28Smrg	    fi
26661d54945dSmrg
2667ec713c28Smrg	    # Make a new name for the extract_expsyms_cmds to use
2668ec713c28Smrg	    soroot="$soname"
2669ec713c28Smrg	    soname=`$echo $soroot | ${SED} -e 's/^.*\///'`
2670ec713c28Smrg	    newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
26711d54945dSmrg
2672ec713c28Smrg	    # If the library has no export list, then create one now
2673ec713c28Smrg	    if test -f "$output_objdir/$soname-def"; then :
2674ec713c28Smrg	    else
2675ec713c28Smrg	      $show "extracting exported symbol list from \`$soname'"
2676ec713c28Smrg	      save_ifs="$IFS"; IFS='~'
2677ec713c28Smrg	      cmds=$extract_expsyms_cmds
2678ec713c28Smrg	      for cmd in $cmds; do
2679ec713c28Smrg		IFS="$save_ifs"
2680ec713c28Smrg		eval cmd=\"$cmd\"
2681ec713c28Smrg		$show "$cmd"
2682ec713c28Smrg		$run eval "$cmd" || exit $?
2683ec713c28Smrg	      done
2684ec713c28Smrg	      IFS="$save_ifs"
2685ec713c28Smrg	    fi
26861d54945dSmrg
2687ec713c28Smrg	    # Create $newlib
2688ec713c28Smrg	    if test -f "$output_objdir/$newlib"; then :; else
2689ec713c28Smrg	      $show "generating import library for \`$soname'"
2690ec713c28Smrg	      save_ifs="$IFS"; IFS='~'
2691ec713c28Smrg	      cmds=$old_archive_from_expsyms_cmds
2692ec713c28Smrg	      for cmd in $cmds; do
2693ec713c28Smrg		IFS="$save_ifs"
2694ec713c28Smrg		eval cmd=\"$cmd\"
2695ec713c28Smrg		$show "$cmd"
2696ec713c28Smrg		$run eval "$cmd" || exit $?
2697ec713c28Smrg	      done
2698ec713c28Smrg	      IFS="$save_ifs"
2699ec713c28Smrg	    fi
2700ec713c28Smrg	    # make sure the library variables are pointing to the new library
2701ec713c28Smrg	    dir=$output_objdir
2702ec713c28Smrg	    linklib=$newlib
2703ec713c28Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
27041d54945dSmrg
2705ec713c28Smrg	  if test "$linkmode" = prog || test "$mode" != relink; then
2706ec713c28Smrg	    add_shlibpath=
2707ec713c28Smrg	    add_dir=
2708ec713c28Smrg	    add=
2709ec713c28Smrg	    lib_linked=yes
2710ec713c28Smrg	    case $hardcode_action in
2711ec713c28Smrg	    immediate | unsupported)
2712ec713c28Smrg	      if test "$hardcode_direct" = no; then
2713ec713c28Smrg		add="$dir/$linklib"
2714ec713c28Smrg		case $host in
2715ec713c28Smrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
2716ec713c28Smrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
2717ec713c28Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
2718ec713c28Smrg		    *-*-unixware7*) add_dir="-L$dir" ;;
2719ec713c28Smrg		  *-*-darwin* )
2720ec713c28Smrg		    # if the lib is a module then we can not link against
2721ec713c28Smrg		    # it, someone is ignoring the new warnings I added
2722ec713c28Smrg		    if /usr/bin/file -L $add 2> /dev/null |
2723ec713c28Smrg                      $EGREP ": [^:]* bundle" >/dev/null ; then
2724ec713c28Smrg		      $echo "** Warning, lib $linklib is a module, not a shared library"
2725ec713c28Smrg		      if test -z "$old_library" ; then
2726ec713c28Smrg		        $echo
2727ec713c28Smrg		        $echo "** And there doesn't seem to be a static archive available"
2728ec713c28Smrg		        $echo "** The link will probably fail, sorry"
2729ec713c28Smrg		      else
2730ec713c28Smrg		        add="$dir/$old_library"
2731ec713c28Smrg		      fi
2732ec713c28Smrg		    fi
2733ec713c28Smrg		esac
2734ec713c28Smrg	      elif test "$hardcode_minus_L" = no; then
2735ec713c28Smrg		case $host in
2736ec713c28Smrg		*-*-sunos*) add_shlibpath="$dir" ;;
2737ec713c28Smrg		esac
2738ec713c28Smrg		add_dir="-L$dir"
2739ec713c28Smrg		add="-l$name"
2740ec713c28Smrg	      elif test "$hardcode_shlibpath_var" = no; then
2741ec713c28Smrg		add_shlibpath="$dir"
2742ec713c28Smrg		add="-l$name"
2743ec713c28Smrg	      else
2744ec713c28Smrg		lib_linked=no
2745ec713c28Smrg	      fi
2746ec713c28Smrg	      ;;
2747ec713c28Smrg	    relink)
2748ec713c28Smrg	      if test "$hardcode_direct" = yes; then
2749ec713c28Smrg		add="$dir/$linklib"
2750ec713c28Smrg	      elif test "$hardcode_minus_L" = yes; then
2751ec713c28Smrg		add_dir="-L$dir"
2752ec713c28Smrg		# Try looking first in the location we're being installed to.
2753ec713c28Smrg		if test -n "$inst_prefix_dir"; then
2754ec713c28Smrg		  case $libdir in
2755ec713c28Smrg		    [\\/]*)
2756ec713c28Smrg		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
2757ec713c28Smrg		      ;;
2758ec713c28Smrg		  esac
2759ec713c28Smrg		fi
2760ec713c28Smrg		add="-l$name"
2761ec713c28Smrg	      elif test "$hardcode_shlibpath_var" = yes; then
2762ec713c28Smrg		add_shlibpath="$dir"
2763ec713c28Smrg		add="-l$name"
2764ec713c28Smrg	      else
2765ec713c28Smrg		lib_linked=no
2766ec713c28Smrg	      fi
2767ec713c28Smrg	      ;;
2768ec713c28Smrg	    *) lib_linked=no ;;
2769ec713c28Smrg	    esac
27701d54945dSmrg
2771ec713c28Smrg	    if test "$lib_linked" != yes; then
2772ec713c28Smrg	      $echo "$modename: configuration error: unsupported hardcode properties"
2773ec713c28Smrg	      exit $EXIT_FAILURE
2774ec713c28Smrg	    fi
27751d54945dSmrg
2776ec713c28Smrg	    if test -n "$add_shlibpath"; then
2777ec713c28Smrg	      case :$compile_shlibpath: in
2778ec713c28Smrg	      *":$add_shlibpath:"*) ;;
2779ec713c28Smrg	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
2780ec713c28Smrg	      esac
2781ec713c28Smrg	    fi
2782ec713c28Smrg	    if test "$linkmode" = prog; then
2783ec713c28Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
2784ec713c28Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
2785ec713c28Smrg	    else
2786ec713c28Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
2787ec713c28Smrg	      test -n "$add" && deplibs="$add $deplibs"
2788ec713c28Smrg	      if test "$hardcode_direct" != yes && \
2789ec713c28Smrg		 test "$hardcode_minus_L" != yes && \
2790ec713c28Smrg		 test "$hardcode_shlibpath_var" = yes; then
2791ec713c28Smrg		case :$finalize_shlibpath: in
2792ec713c28Smrg		*":$libdir:"*) ;;
2793ec713c28Smrg		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
2794ec713c28Smrg		esac
2795ec713c28Smrg	      fi
2796ec713c28Smrg	    fi
2797ec713c28Smrg	  fi
2798786a6f21Smrg
2799ec713c28Smrg	  if test "$linkmode" = prog || test "$mode" = relink; then
2800ec713c28Smrg	    add_shlibpath=
2801ec713c28Smrg	    add_dir=
2802ec713c28Smrg	    add=
2803ec713c28Smrg	    # Finalize command for both is simple: just hardcode it.
2804ec713c28Smrg	    if test "$hardcode_direct" = yes; then
2805ec713c28Smrg	      add="$libdir/$linklib"
2806ec713c28Smrg	    elif test "$hardcode_minus_L" = yes; then
2807ec713c28Smrg	      add_dir="-L$libdir"
2808ec713c28Smrg	      add="-l$name"
2809ec713c28Smrg	    elif test "$hardcode_shlibpath_var" = yes; then
2810ec713c28Smrg	      case :$finalize_shlibpath: in
2811ec713c28Smrg	      *":$libdir:"*) ;;
2812ec713c28Smrg	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
2813ec713c28Smrg	      esac
2814ec713c28Smrg	      add="-l$name"
2815ec713c28Smrg	    elif test "$hardcode_automatic" = yes; then
2816ec713c28Smrg	      if test -n "$inst_prefix_dir" &&
2817ec713c28Smrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
2818ec713c28Smrg	        add="$inst_prefix_dir$libdir/$linklib"
2819ec713c28Smrg	      else
2820ec713c28Smrg	        add="$libdir/$linklib"
2821ec713c28Smrg	      fi
2822ec713c28Smrg	    else
2823ec713c28Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
2824ec713c28Smrg	      add_dir="-L$libdir"
2825ec713c28Smrg	      # Try looking first in the location we're being installed to.
2826ec713c28Smrg	      if test -n "$inst_prefix_dir"; then
2827ec713c28Smrg		case $libdir in
2828ec713c28Smrg		  [\\/]*)
2829ec713c28Smrg		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
2830ec713c28Smrg		    ;;
2831ec713c28Smrg		esac
2832ec713c28Smrg	      fi
2833ec713c28Smrg	      add="-l$name"
2834ec713c28Smrg	    fi
2835786a6f21Smrg
2836ec713c28Smrg	    if test "$linkmode" = prog; then
2837ec713c28Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
2838ec713c28Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
2839ec713c28Smrg	    else
2840ec713c28Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
2841ec713c28Smrg	      test -n "$add" && deplibs="$add $deplibs"
2842ec713c28Smrg	    fi
2843ec713c28Smrg	  fi
2844ec713c28Smrg	elif test "$linkmode" = prog; then
2845ec713c28Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
2846ec713c28Smrg	  # is not unsupported.  This is valid on all known static and
2847ec713c28Smrg	  # shared platforms.
2848ec713c28Smrg	  if test "$hardcode_direct" != unsupported; then
2849ec713c28Smrg	    test -n "$old_library" && linklib="$old_library"
2850ec713c28Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
2851ec713c28Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
2852ec713c28Smrg	  else
2853ec713c28Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
2854ec713c28Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
2855ec713c28Smrg	  fi
2856ec713c28Smrg	elif test "$build_libtool_libs" = yes; then
2857ec713c28Smrg	  # Not a shared library
2858ec713c28Smrg	  if test "$deplibs_check_method" != pass_all; then
2859ec713c28Smrg	    # We're trying link a shared library against a static one
2860ec713c28Smrg	    # but the system doesn't support it.
2861786a6f21Smrg
2862ec713c28Smrg	    # Just print a warning and add the library to dependency_libs so
2863ec713c28Smrg	    # that the program can be linked against the static library.
2864ec713c28Smrg	    $echo
2865ec713c28Smrg	    $echo "*** Warning: This system can not link to static lib archive $lib."
2866ec713c28Smrg	    $echo "*** I have the capability to make that library automatically link in when"
2867ec713c28Smrg	    $echo "*** you link to this library.  But I can only do this if you have a"
2868ec713c28Smrg	    $echo "*** shared version of the library, which you do not appear to have."
2869ec713c28Smrg	    if test "$module" = yes; then
2870ec713c28Smrg	      $echo "*** But as you try to build a module library, libtool will still create "
2871ec713c28Smrg	      $echo "*** a static module, that should work as long as the dlopening application"
2872ec713c28Smrg	      $echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
2873ec713c28Smrg	      if test -z "$global_symbol_pipe"; then
2874ec713c28Smrg		$echo
2875ec713c28Smrg		$echo "*** However, this would only work if libtool was able to extract symbol"
2876ec713c28Smrg		$echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
2877ec713c28Smrg		$echo "*** not find such a program.  So, this module is probably useless."
2878ec713c28Smrg		$echo "*** \`nm' from GNU binutils and a full rebuild may help."
2879ec713c28Smrg	      fi
2880ec713c28Smrg	      if test "$build_old_libs" = no; then
2881ec713c28Smrg		build_libtool_libs=module
2882ec713c28Smrg		build_old_libs=yes
2883ec713c28Smrg	      else
2884ec713c28Smrg		build_libtool_libs=no
2885ec713c28Smrg	      fi
2886ec713c28Smrg	    fi
2887ec713c28Smrg	  else
2888ec713c28Smrg	    deplibs="$dir/$old_library $deplibs"
2889ec713c28Smrg	    link_static=yes
2890ec713c28Smrg	  fi
2891ec713c28Smrg	fi # link shared/static library?
2892786a6f21Smrg
2893ec713c28Smrg	if test "$linkmode" = lib; then
2894ec713c28Smrg	  if test -n "$dependency_libs" &&
2895ec713c28Smrg	     { test "$hardcode_into_libs" != yes ||
2896ec713c28Smrg	       test "$build_old_libs" = yes ||
2897ec713c28Smrg	       test "$link_static" = yes; }; then
2898ec713c28Smrg	    # Extract -R from dependency_libs
2899ec713c28Smrg	    temp_deplibs=
2900ec713c28Smrg	    for libdir in $dependency_libs; do
2901ec713c28Smrg	      case $libdir in
2902ec713c28Smrg	      -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'`
2903ec713c28Smrg		   case " $xrpath " in
2904ec713c28Smrg		   *" $temp_xrpath "*) ;;
2905ec713c28Smrg		   *) xrpath="$xrpath $temp_xrpath";;
2906ec713c28Smrg		   esac;;
2907ec713c28Smrg	      *) temp_deplibs="$temp_deplibs $libdir";;
2908ec713c28Smrg	      esac
2909ec713c28Smrg	    done
2910ec713c28Smrg	    dependency_libs="$temp_deplibs"
2911ec713c28Smrg	  fi
2912786a6f21Smrg
2913ec713c28Smrg	  newlib_search_path="$newlib_search_path $absdir"
2914ec713c28Smrg	  # Link against this library
2915ec713c28Smrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
2916ec713c28Smrg	  # ... and its dependency_libs
2917ec713c28Smrg	  tmp_libs=
2918ec713c28Smrg	  for deplib in $dependency_libs; do
2919ec713c28Smrg	    newdependency_libs="$deplib $newdependency_libs"
2920ec713c28Smrg	    if test "X$duplicate_deps" = "Xyes" ; then
2921ec713c28Smrg	      case "$tmp_libs " in
2922ec713c28Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2923ec713c28Smrg	      esac
2924ec713c28Smrg	    fi
2925ec713c28Smrg	    tmp_libs="$tmp_libs $deplib"
2926ec713c28Smrg	  done
29271d54945dSmrg
2928ec713c28Smrg	  if test "$link_all_deplibs" != no; then
2929ec713c28Smrg	    # Add the search paths of all dependency libraries
2930ec713c28Smrg	    for deplib in $dependency_libs; do
2931ec713c28Smrg	      case $deplib in
2932ec713c28Smrg	      -L*) path="$deplib" ;;
2933ec713c28Smrg	      *.la)
2934ec713c28Smrg		dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
2935ec713c28Smrg		test "X$dir" = "X$deplib" && dir="."
2936ec713c28Smrg		# We need an absolute path.
2937ec713c28Smrg		case $dir in
2938ec713c28Smrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
2939ec713c28Smrg		*)
2940ec713c28Smrg		  absdir=`cd "$dir" && pwd`
2941ec713c28Smrg		  if test -z "$absdir"; then
2942ec713c28Smrg		    $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
2943ec713c28Smrg		    absdir="$dir"
2944ec713c28Smrg		  fi
2945ec713c28Smrg		  ;;
2946ec713c28Smrg		esac
2947ec713c28Smrg		if grep "^installed=no" $deplib > /dev/null; then
2948ec713c28Smrg		  path="$absdir/$objdir"
2949ec713c28Smrg		else
2950ec713c28Smrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
2951ec713c28Smrg		  if test -z "$libdir"; then
2952ec713c28Smrg		    $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
2953ec713c28Smrg		    exit $EXIT_FAILURE
2954ec713c28Smrg		  fi
2955ec713c28Smrg		  if test "$absdir" != "$libdir"; then
2956ec713c28Smrg		    $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
2957ec713c28Smrg		  fi
2958ec713c28Smrg		  path="$absdir"
2959ec713c28Smrg		fi
2960ec713c28Smrg		depdepl=
2961ec713c28Smrg		case $host in
2962ec713c28Smrg		*-*-darwin*)
2963ec713c28Smrg		  # we do not want to link against static libs,
2964ec713c28Smrg		  # but need to link against shared
2965ec713c28Smrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
2966ec713c28Smrg		  eval deplibdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
2967ec713c28Smrg		  if test -n "$deplibrary_names" ; then
2968ec713c28Smrg		    for tmp in $deplibrary_names ; do
2969ec713c28Smrg		      depdepl=$tmp
2970ec713c28Smrg		    done
2971ec713c28Smrg		    if test -f "$deplibdir/$depdepl" ; then
2972ec713c28Smrg		      depdepl="$deplibdir/$depdepl"
2973ec713c28Smrg	      	    elif test -f "$path/$depdepl" ; then
2974ec713c28Smrg		      depdepl="$path/$depdepl"
2975ec713c28Smrg		    else
2976ec713c28Smrg		      # Can't find it, oh well...
2977ec713c28Smrg		      depdepl=
2978ec713c28Smrg		    fi
2979ec713c28Smrg		    # do not add paths which are already there
2980ec713c28Smrg		    case " $newlib_search_path " in
2981ec713c28Smrg		    *" $path "*) ;;
2982ec713c28Smrg		    *) newlib_search_path="$newlib_search_path $path";;
2983ec713c28Smrg		    esac
2984ec713c28Smrg		  fi
2985ec713c28Smrg		  path=""
2986ec713c28Smrg		  ;;
2987ec713c28Smrg		*)
2988ec713c28Smrg		  path="-L$path"
2989ec713c28Smrg		  ;;
2990ec713c28Smrg		esac
2991ec713c28Smrg		;;
2992ec713c28Smrg	      -l*)
2993ec713c28Smrg		case $host in
2994ec713c28Smrg		*-*-darwin*)
2995ec713c28Smrg		  # Again, we only want to link against shared libraries
2996ec713c28Smrg		  eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
2997ec713c28Smrg		  for tmp in $newlib_search_path ; do
2998ec713c28Smrg		    if test -f "$tmp/lib$tmp_libs.dylib" ; then
2999ec713c28Smrg		      eval depdepl="$tmp/lib$tmp_libs.dylib"
3000ec713c28Smrg		      break
3001ec713c28Smrg		    fi
3002ec713c28Smrg		  done
3003ec713c28Smrg		  path=""
3004ec713c28Smrg		  ;;
3005ec713c28Smrg		*) continue ;;
3006ec713c28Smrg		esac
3007ec713c28Smrg		;;
3008ec713c28Smrg	      *) continue ;;
3009ec713c28Smrg	      esac
3010ec713c28Smrg	      case " $deplibs " in
3011ec713c28Smrg	      *" $path "*) ;;
3012ec713c28Smrg	      *) deplibs="$path $deplibs" ;;
3013ec713c28Smrg	      esac
3014ec713c28Smrg	      case " $deplibs " in
3015ec713c28Smrg	      *" $depdepl "*) ;;
3016ec713c28Smrg	      *) deplibs="$depdepl $deplibs" ;;
3017ec713c28Smrg	      esac
3018ec713c28Smrg	    done
3019ec713c28Smrg	  fi # link_all_deplibs != no
3020ec713c28Smrg	fi # linkmode = lib
3021ec713c28Smrg      done # for deplib in $libs
3022ec713c28Smrg      dependency_libs="$newdependency_libs"
3023ec713c28Smrg      if test "$pass" = dlpreopen; then
3024ec713c28Smrg	# Link the dlpreopened libraries before other libraries
3025ec713c28Smrg	for deplib in $save_deplibs; do
3026ec713c28Smrg	  deplibs="$deplib $deplibs"
3027ec713c28Smrg	done
3028ec713c28Smrg      fi
3029ec713c28Smrg      if test "$pass" != dlopen; then
3030ec713c28Smrg	if test "$pass" != conv; then
3031ec713c28Smrg	  # Make sure lib_search_path contains only unique directories.
3032ec713c28Smrg	  lib_search_path=
3033ec713c28Smrg	  for dir in $newlib_search_path; do
3034ec713c28Smrg	    case "$lib_search_path " in
3035ec713c28Smrg	    *" $dir "*) ;;
3036ec713c28Smrg	    *) lib_search_path="$lib_search_path $dir" ;;
3037ec713c28Smrg	    esac
3038ec713c28Smrg	  done
3039ec713c28Smrg	  newlib_search_path=
3040ec713c28Smrg	fi
3041ec713c28Smrg
3042ec713c28Smrg	if test "$linkmode,$pass" != "prog,link"; then
3043ec713c28Smrg	  vars="deplibs"
3044ec713c28Smrg	else
3045ec713c28Smrg	  vars="compile_deplibs finalize_deplibs"
3046ec713c28Smrg	fi
3047ec713c28Smrg	for var in $vars dependency_libs; do
3048ec713c28Smrg	  # Add libraries to $var in reverse order
3049ec713c28Smrg	  eval tmp_libs=\"\$$var\"
3050ec713c28Smrg	  new_libs=
3051ec713c28Smrg	  for deplib in $tmp_libs; do
3052ec713c28Smrg	    # FIXME: Pedantically, this is the right thing to do, so
3053ec713c28Smrg	    #        that some nasty dependency loop isn't accidentally
3054ec713c28Smrg	    #        broken:
3055ec713c28Smrg	    #new_libs="$deplib $new_libs"
3056ec713c28Smrg	    # Pragmatically, this seems to cause very few problems in
3057ec713c28Smrg	    # practice:
3058ec713c28Smrg	    case $deplib in
3059ec713c28Smrg	    -L*) new_libs="$deplib $new_libs" ;;
3060ec713c28Smrg	    -R*) ;;
3061ec713c28Smrg	    *)
3062ec713c28Smrg	      # And here is the reason: when a library appears more
3063ec713c28Smrg	      # than once as an explicit dependence of a library, or
3064ec713c28Smrg	      # is implicitly linked in more than once by the
3065ec713c28Smrg	      # compiler, it is considered special, and multiple
3066ec713c28Smrg	      # occurrences thereof are not removed.  Compare this
3067ec713c28Smrg	      # with having the same library being listed as a
3068ec713c28Smrg	      # dependency of multiple other libraries: in this case,
3069ec713c28Smrg	      # we know (pedantically, we assume) the library does not
3070ec713c28Smrg	      # need to be listed more than once, so we keep only the
3071ec713c28Smrg	      # last copy.  This is not always right, but it is rare
3072ec713c28Smrg	      # enough that we require users that really mean to play
3073ec713c28Smrg	      # such unportable linking tricks to link the library
3074ec713c28Smrg	      # using -Wl,-lname, so that libtool does not consider it
3075ec713c28Smrg	      # for duplicate removal.
3076ec713c28Smrg	      case " $specialdeplibs " in
3077ec713c28Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
3078ec713c28Smrg	      *)
3079ec713c28Smrg		case " $new_libs " in
3080ec713c28Smrg		*" $deplib "*) ;;
3081ec713c28Smrg		*) new_libs="$deplib $new_libs" ;;
3082ec713c28Smrg		esac
3083ec713c28Smrg		;;
3084ec713c28Smrg	      esac
3085ec713c28Smrg	      ;;
3086ec713c28Smrg	    esac
3087ec713c28Smrg	  done
3088ec713c28Smrg	  tmp_libs=
3089ec713c28Smrg	  for deplib in $new_libs; do
3090ec713c28Smrg	    case $deplib in
3091ec713c28Smrg	    -L*)
3092ec713c28Smrg	      case " $tmp_libs " in
3093ec713c28Smrg	      *" $deplib "*) ;;
3094ec713c28Smrg	      *) tmp_libs="$tmp_libs $deplib" ;;
3095ec713c28Smrg	      esac
3096ec713c28Smrg	      ;;
3097ec713c28Smrg	    *) tmp_libs="$tmp_libs $deplib" ;;
3098ec713c28Smrg	    esac
3099ec713c28Smrg	  done
3100ec713c28Smrg	  eval $var=\"$tmp_libs\"
3101ec713c28Smrg	done # for var
3102ec713c28Smrg      fi
3103ec713c28Smrg      # Last step: remove runtime libs from dependency_libs
3104ec713c28Smrg      # (they stay in deplibs)
3105ec713c28Smrg      tmp_libs=
3106ec713c28Smrg      for i in $dependency_libs ; do
3107ec713c28Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
3108ec713c28Smrg	*" $i "*)
3109ec713c28Smrg	  i=""
31101d54945dSmrg	  ;;
31111d54945dSmrg	esac
3112ec713c28Smrg	if test -n "$i" ; then
3113ec713c28Smrg	  tmp_libs="$tmp_libs $i"
3114ec713c28Smrg	fi
3115ec713c28Smrg      done
3116ec713c28Smrg      dependency_libs=$tmp_libs
3117ec713c28Smrg    done # for pass
3118ec713c28Smrg    if test "$linkmode" = prog; then
3119ec713c28Smrg      dlfiles="$newdlfiles"
3120ec713c28Smrg      dlprefiles="$newdlprefiles"
3121786a6f21Smrg    fi
31221d54945dSmrg
3123ec713c28Smrg    case $linkmode in
3124ec713c28Smrg    oldlib)
3125ec713c28Smrg      case " $deplibs" in
3126ec713c28Smrg      *\ -l* | *\ -L*)
3127ec713c28Smrg	$echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2 ;;
3128ec713c28Smrg      esac
31291d54945dSmrg
3130ec713c28Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
3131ec713c28Smrg	$echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
3132ec713c28Smrg      fi
31331d54945dSmrg
3134ec713c28Smrg      if test -n "$rpath"; then
3135ec713c28Smrg	$echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
3136ec713c28Smrg      fi
31371d54945dSmrg
3138ec713c28Smrg      if test -n "$xrpath"; then
3139ec713c28Smrg	$echo "$modename: warning: \`-R' is ignored for archives" 1>&2
3140ec713c28Smrg      fi
31411d54945dSmrg
3142ec713c28Smrg      if test -n "$vinfo"; then
3143ec713c28Smrg	$echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2
3144ec713c28Smrg      fi
31451d54945dSmrg
3146ec713c28Smrg      if test -n "$release"; then
3147ec713c28Smrg	$echo "$modename: warning: \`-release' is ignored for archives" 1>&2
3148ec713c28Smrg      fi
31491d54945dSmrg
3150ec713c28Smrg      if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
3151ec713c28Smrg	$echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
3152ec713c28Smrg      fi
31531d54945dSmrg
3154ec713c28Smrg      # Now set the variables for building old libraries.
3155ec713c28Smrg      build_libtool_libs=no
3156ec713c28Smrg      oldlibs="$output"
3157ec713c28Smrg      objs="$objs$old_deplibs"
3158ec713c28Smrg      ;;
31591d54945dSmrg
3160ec713c28Smrg    lib)
3161ec713c28Smrg      # Make sure we only generate libraries of the form `libNAME.la'.
3162ec713c28Smrg      case $outputname in
3163ec713c28Smrg      lib*)
3164ec713c28Smrg	name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
3165ec713c28Smrg	eval shared_ext=\"$shrext_cmds\"
3166ec713c28Smrg	eval libname=\"$libname_spec\"
3167ec713c28Smrg	;;
3168ec713c28Smrg      *)
3169ec713c28Smrg	if test "$module" = no; then
3170ec713c28Smrg	  $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
3171ec713c28Smrg	  $echo "$help" 1>&2
3172ec713c28Smrg	  exit $EXIT_FAILURE
3173ec713c28Smrg	fi
3174ec713c28Smrg	if test "$need_lib_prefix" != no; then
3175ec713c28Smrg	  # Add the "lib" prefix for modules if required
3176ec713c28Smrg	  name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
3177ec713c28Smrg	  eval shared_ext=\"$shrext_cmds\"
3178ec713c28Smrg	  eval libname=\"$libname_spec\"
3179ec713c28Smrg	else
3180ec713c28Smrg	  libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
3181ec713c28Smrg	fi
3182ec713c28Smrg	;;
3183ec713c28Smrg      esac
31841d54945dSmrg
3185ec713c28Smrg      if test -n "$objs"; then
3186ec713c28Smrg	if test "$deplibs_check_method" != pass_all; then
3187ec713c28Smrg	  $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
3188ec713c28Smrg	  exit $EXIT_FAILURE
3189ec713c28Smrg	else
3190ec713c28Smrg	  $echo
3191ec713c28Smrg	  $echo "*** Warning: Linking the shared library $output against the non-libtool"
3192ec713c28Smrg	  $echo "*** objects $objs is not portable!"
3193ec713c28Smrg	  libobjs="$libobjs $objs"
3194ec713c28Smrg	fi
3195ec713c28Smrg      fi
3196786a6f21Smrg
3197ec713c28Smrg      if test "$dlself" != no; then
3198ec713c28Smrg	$echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2
3199ec713c28Smrg      fi
3200786a6f21Smrg
3201ec713c28Smrg      set dummy $rpath
3202ec713c28Smrg      if test "$#" -gt 2; then
3203ec713c28Smrg	$echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
3204ec713c28Smrg      fi
3205ec713c28Smrg      install_libdir="$2"
3206786a6f21Smrg
3207ec713c28Smrg      oldlibs=
3208ec713c28Smrg      if test -z "$rpath"; then
3209ec713c28Smrg	if test "$build_libtool_libs" = yes; then
3210ec713c28Smrg	  # Building a libtool convenience library.
3211ec713c28Smrg	  # Some compilers have problems with a `.al' extension so
3212ec713c28Smrg	  # convenience libraries should have the same extension an
3213ec713c28Smrg	  # archive normally would.
3214ec713c28Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
3215ec713c28Smrg	  build_libtool_libs=convenience
3216ec713c28Smrg	  build_old_libs=yes
3217ec713c28Smrg	fi
3218786a6f21Smrg
3219ec713c28Smrg	if test -n "$vinfo"; then
3220ec713c28Smrg	  $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2
3221ec713c28Smrg	fi
3222786a6f21Smrg
3223ec713c28Smrg	if test -n "$release"; then
3224ec713c28Smrg	  $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
3225ec713c28Smrg	fi
3226ec713c28Smrg      else
3227786a6f21Smrg
3228ec713c28Smrg	# Parse the version information argument.
3229ec713c28Smrg	save_ifs="$IFS"; IFS=':'
3230ec713c28Smrg	set dummy $vinfo 0 0 0
3231ec713c28Smrg	IFS="$save_ifs"
3232786a6f21Smrg
3233ec713c28Smrg	if test -n "$8"; then
3234ec713c28Smrg	  $echo "$modename: too many parameters to \`-version-info'" 1>&2
3235ec713c28Smrg	  $echo "$help" 1>&2
3236ec713c28Smrg	  exit $EXIT_FAILURE
3237ec713c28Smrg	fi
3238786a6f21Smrg
3239ec713c28Smrg	# convert absolute version numbers to libtool ages
3240ec713c28Smrg	# this retains compatibility with .la files and attempts
3241ec713c28Smrg	# to make the code below a bit more comprehensible
3242786a6f21Smrg
3243ec713c28Smrg	case $vinfo_number in
3244ec713c28Smrg	yes)
3245ec713c28Smrg	  number_major="$2"
3246ec713c28Smrg	  number_minor="$3"
3247ec713c28Smrg	  number_revision="$4"
3248ec713c28Smrg	  #
3249ec713c28Smrg	  # There are really only two kinds -- those that
3250ec713c28Smrg	  # use the current revision as the major version
3251ec713c28Smrg	  # and those that subtract age and use age as
3252ec713c28Smrg	  # a minor version.  But, then there is irix
3253ec713c28Smrg	  # which has an extra 1 added just for fun
3254ec713c28Smrg	  #
3255ec713c28Smrg	  case $version_type in
3256ec713c28Smrg	  darwin|linux|osf|windows|none)
3257ec713c28Smrg	    current=`expr $number_major + $number_minor`
3258ec713c28Smrg	    age="$number_minor"
3259ec713c28Smrg	    revision="$number_revision"
3260ec713c28Smrg	    ;;
3261ec713c28Smrg	  freebsd-aout|freebsd-elf|sunos)
3262ec713c28Smrg	    current="$number_major"
3263ec713c28Smrg	    revision="$number_minor"
3264ec713c28Smrg	    age="0"
3265ec713c28Smrg	    ;;
3266ec713c28Smrg	  irix|nonstopux)
3267ec713c28Smrg	    current=`expr $number_major + $number_minor`
3268ec713c28Smrg	    age="$number_minor"
3269ec713c28Smrg	    revision="$number_minor"
3270ec713c28Smrg	    lt_irix_increment=no
3271ec713c28Smrg	    ;;
3272ec713c28Smrg	  esac
3273ec713c28Smrg	  ;;
3274ec713c28Smrg	no)
3275ec713c28Smrg	  current="$2"
3276ec713c28Smrg	  revision="$3"
3277ec713c28Smrg	  age="$4"
3278ec713c28Smrg	  ;;
3279ec713c28Smrg	esac
3280786a6f21Smrg
3281ec713c28Smrg	# Check that each of the things are valid numbers.
3282ec713c28Smrg	case $current in
3283ec713c28Smrg	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]) ;;
3284ec713c28Smrg	*)
3285ec713c28Smrg	  $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2
3286ec713c28Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3287ec713c28Smrg	  exit $EXIT_FAILURE
3288ec713c28Smrg	  ;;
3289ec713c28Smrg	esac
3290786a6f21Smrg
3291ec713c28Smrg	case $revision in
3292ec713c28Smrg	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]) ;;
3293ec713c28Smrg	*)
3294ec713c28Smrg	  $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2
3295ec713c28Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3296ec713c28Smrg	  exit $EXIT_FAILURE
3297ec713c28Smrg	  ;;
3298ec713c28Smrg	esac
3299786a6f21Smrg
3300ec713c28Smrg	case $age in
3301ec713c28Smrg	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]) ;;
3302ec713c28Smrg	*)
3303ec713c28Smrg	  $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2
3304ec713c28Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3305ec713c28Smrg	  exit $EXIT_FAILURE
3306ec713c28Smrg	  ;;
3307ec713c28Smrg	esac
3308786a6f21Smrg
3309ec713c28Smrg	if test "$age" -gt "$current"; then
3310ec713c28Smrg	  $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
3311ec713c28Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3312ec713c28Smrg	  exit $EXIT_FAILURE
3313ec713c28Smrg	fi
3314786a6f21Smrg
3315ec713c28Smrg	# Calculate the version variables.
3316ec713c28Smrg	major=
3317ec713c28Smrg	versuffix=
3318ec713c28Smrg	verstring=
3319ec713c28Smrg	case $version_type in
3320ec713c28Smrg	none) ;;
3321786a6f21Smrg
3322ec713c28Smrg	darwin)
3323ec713c28Smrg	  # Like Linux, but with the current version available in
3324ec713c28Smrg	  # verstring for coding it into the library header
3325ec713c28Smrg	  major=.`expr $current - $age`
3326ec713c28Smrg	  versuffix="$major.$age.$revision"
3327ec713c28Smrg	  # Darwin ld doesn't like 0 for these options...
3328ec713c28Smrg	  minor_current=`expr $current + 1`
3329ec713c28Smrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
3330ec713c28Smrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
3331ec713c28Smrg	  ;;
3332786a6f21Smrg
3333ec713c28Smrg	freebsd-aout)
3334ec713c28Smrg	  major=".$current"
3335ec713c28Smrg	  versuffix=".$current.$revision";
3336ec713c28Smrg	  ;;
3337786a6f21Smrg
3338ec713c28Smrg	freebsd-elf)
3339ec713c28Smrg	  major=".$current"
3340ec713c28Smrg	  versuffix=".$current";
3341ec713c28Smrg	  ;;
3342786a6f21Smrg
3343ec713c28Smrg	irix | nonstopux)
3344ec713c28Smrg	  if test "X$lt_irix_increment" = "Xno"; then
3345ec713c28Smrg	    major=`expr $current - $age`
3346ec713c28Smrg	  else
3347ec713c28Smrg	    major=`expr $current - $age + 1`
3348ec713c28Smrg	  fi
3349ec713c28Smrg	  case $version_type in
3350ec713c28Smrg	    nonstopux) verstring_prefix=nonstopux ;;
3351ec713c28Smrg	    *)         verstring_prefix=sgi ;;
3352ec713c28Smrg	  esac
3353ec713c28Smrg	  verstring="$verstring_prefix$major.$revision"
33541d54945dSmrg
3355ec713c28Smrg	  # Add in all the interfaces that we are compatible with.
3356ec713c28Smrg	  loop=$revision
3357ec713c28Smrg	  while test "$loop" -ne 0; do
3358ec713c28Smrg	    iface=`expr $revision - $loop`
3359ec713c28Smrg	    loop=`expr $loop - 1`
3360ec713c28Smrg	    verstring="$verstring_prefix$major.$iface:$verstring"
3361ec713c28Smrg	  done
33621d54945dSmrg
3363ec713c28Smrg	  # Before this point, $major must not contain `.'.
3364ec713c28Smrg	  major=.$major
3365ec713c28Smrg	  versuffix="$major.$revision"
3366ec713c28Smrg	  ;;
33671d54945dSmrg
3368ec713c28Smrg	linux)
3369ec713c28Smrg	  major=.`expr $current - $age`
3370ec713c28Smrg	  versuffix="$major.$age.$revision"
3371ec713c28Smrg	  ;;
33721d54945dSmrg
3373ec713c28Smrg	osf)
3374ec713c28Smrg	  major=.`expr $current - $age`
3375ec713c28Smrg	  versuffix=".$current.$age.$revision"
3376ec713c28Smrg	  verstring="$current.$age.$revision"
33771d54945dSmrg
3378ec713c28Smrg	  # Add in all the interfaces that we are compatible with.
3379ec713c28Smrg	  loop=$age
3380ec713c28Smrg	  while test "$loop" -ne 0; do
3381ec713c28Smrg	    iface=`expr $current - $loop`
3382ec713c28Smrg	    loop=`expr $loop - 1`
3383ec713c28Smrg	    verstring="$verstring:${iface}.0"
3384ec713c28Smrg	  done
33851d54945dSmrg
3386ec713c28Smrg	  # Make executables depend on our current version.
3387ec713c28Smrg	  verstring="$verstring:${current}.0"
3388ec713c28Smrg	  ;;
33891d54945dSmrg
3390ec713c28Smrg	sunos)
3391ec713c28Smrg	  major=".$current"
3392ec713c28Smrg	  versuffix=".$current.$revision"
3393ec713c28Smrg	  ;;
33941d54945dSmrg
3395ec713c28Smrg	windows)
3396ec713c28Smrg	  # Use '-' rather than '.', since we only want one
3397ec713c28Smrg	  # extension on DOS 8.3 filesystems.
3398ec713c28Smrg	  major=`expr $current - $age`
3399ec713c28Smrg	  versuffix="-$major"
3400ec713c28Smrg	  ;;
34011d54945dSmrg
3402ec713c28Smrg	*)
3403ec713c28Smrg	  $echo "$modename: unknown library version type \`$version_type'" 1>&2
3404ec713c28Smrg	  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
3405ec713c28Smrg	  exit $EXIT_FAILURE
3406ec713c28Smrg	  ;;
3407ec713c28Smrg	esac
34081d54945dSmrg
3409ec713c28Smrg	# Clear the version info if we defaulted, and they specified a release.
3410ec713c28Smrg	if test -z "$vinfo" && test -n "$release"; then
3411ec713c28Smrg	  major=
3412ec713c28Smrg	  case $version_type in
3413ec713c28Smrg	  darwin)
3414ec713c28Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
3415ec713c28Smrg	    # problems, so we reset it completely
3416ec713c28Smrg	    verstring=
3417786a6f21Smrg	    ;;
3418ec713c28Smrg	  *)
3419ec713c28Smrg	    verstring="0.0"
3420ec713c28Smrg	    ;;
3421ec713c28Smrg	  esac
3422ec713c28Smrg	  if test "$need_version" = no; then
3423ec713c28Smrg	    versuffix=
3424ec713c28Smrg	  else
3425ec713c28Smrg	    versuffix=".0.0"
3426ec713c28Smrg	  fi
3427ec713c28Smrg	fi
34281d54945dSmrg
3429ec713c28Smrg	# Remove version info from name if versioning should be avoided
3430ec713c28Smrg	if test "$avoid_version" = yes && test "$need_version" = no; then
3431ec713c28Smrg	  major=
3432ec713c28Smrg	  versuffix=
3433ec713c28Smrg	  verstring=""
3434ec713c28Smrg	fi
34351d54945dSmrg
3436ec713c28Smrg	# Check to see if the archive will have undefined symbols.
3437ec713c28Smrg	if test "$allow_undefined" = yes; then
3438ec713c28Smrg	  if test "$allow_undefined_flag" = unsupported; then
3439ec713c28Smrg	    $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
3440ec713c28Smrg	    build_libtool_libs=no
3441ec713c28Smrg	    build_old_libs=yes
3442ec713c28Smrg	  fi
3443ec713c28Smrg	else
3444ec713c28Smrg	  # Don't allow undefined symbols.
3445ec713c28Smrg	  allow_undefined_flag="$no_undefined_flag"
3446ec713c28Smrg	fi
3447ec713c28Smrg      fi
34481d54945dSmrg
3449ec713c28Smrg      if test "$mode" != relink; then
3450ec713c28Smrg	# Remove our outputs, but don't remove object files since they
3451ec713c28Smrg	# may have been created when compiling PIC objects.
3452ec713c28Smrg	removelist=
3453ec713c28Smrg	tempremovelist=`$echo "$output_objdir/*"`
3454ec713c28Smrg	for p in $tempremovelist; do
3455ec713c28Smrg	  case $p in
3456ec713c28Smrg	    *.$objext)
3457ec713c28Smrg	       ;;
3458ec713c28Smrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
3459ec713c28Smrg	       if test "X$precious_files_regex" != "X"; then
3460ec713c28Smrg	         if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
3461ec713c28Smrg	         then
3462ec713c28Smrg		   continue
3463ec713c28Smrg		 fi
3464ec713c28Smrg	       fi
3465ec713c28Smrg	       removelist="$removelist $p"
3466ec713c28Smrg	       ;;
3467ec713c28Smrg	    *) ;;
3468ec713c28Smrg	  esac
3469ec713c28Smrg	done
3470ec713c28Smrg	if test -n "$removelist"; then
3471ec713c28Smrg	  $show "${rm}r $removelist"
3472ec713c28Smrg	  $run ${rm}r $removelist
3473ec713c28Smrg	fi
3474ec713c28Smrg      fi
34751d54945dSmrg
3476ec713c28Smrg      # Now set the variables for building old libraries.
3477ec713c28Smrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
3478ec713c28Smrg	oldlibs="$oldlibs $output_objdir/$libname.$libext"
34791d54945dSmrg
3480ec713c28Smrg	# Transform .lo files to .o files.
3481ec713c28Smrg	oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
3482ec713c28Smrg      fi
34831d54945dSmrg
3484ec713c28Smrg      # Eliminate all temporary directories.
3485ec713c28Smrg      #for path in $notinst_path; do
3486ec713c28Smrg      #	lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
3487ec713c28Smrg      #	deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
3488ec713c28Smrg      #	dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
3489ec713c28Smrg      #done
34901d54945dSmrg
3491ec713c28Smrg      if test -n "$xrpath"; then
3492ec713c28Smrg	# If the user specified any rpath flags, then add them.
3493ec713c28Smrg	temp_xrpath=
3494ec713c28Smrg	for libdir in $xrpath; do
3495ec713c28Smrg	  temp_xrpath="$temp_xrpath -R$libdir"
3496ec713c28Smrg	  case "$finalize_rpath " in
3497ec713c28Smrg	  *" $libdir "*) ;;
3498ec713c28Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
3499ec713c28Smrg	  esac
3500ec713c28Smrg	done
3501ec713c28Smrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
3502ec713c28Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
3503ec713c28Smrg	fi
3504ec713c28Smrg      fi
35051d54945dSmrg
3506ec713c28Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
3507ec713c28Smrg      old_dlfiles="$dlfiles"
3508ec713c28Smrg      dlfiles=
3509ec713c28Smrg      for lib in $old_dlfiles; do
3510ec713c28Smrg	case " $dlprefiles $dlfiles " in
3511ec713c28Smrg	*" $lib "*) ;;
3512ec713c28Smrg	*) dlfiles="$dlfiles $lib" ;;
3513ec713c28Smrg	esac
3514ec713c28Smrg      done
35151d54945dSmrg
3516ec713c28Smrg      # Make sure dlprefiles contains only unique files
3517ec713c28Smrg      old_dlprefiles="$dlprefiles"
3518ec713c28Smrg      dlprefiles=
3519ec713c28Smrg      for lib in $old_dlprefiles; do
3520ec713c28Smrg	case "$dlprefiles " in
3521ec713c28Smrg	*" $lib "*) ;;
3522ec713c28Smrg	*) dlprefiles="$dlprefiles $lib" ;;
3523ec713c28Smrg	esac
3524ec713c28Smrg      done
35251d54945dSmrg
3526ec713c28Smrg      if test "$build_libtool_libs" = yes; then
3527ec713c28Smrg	if test -n "$rpath"; then
3528ec713c28Smrg	  case $host in
3529ec713c28Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
3530ec713c28Smrg	    # these systems don't actually have a c library (as such)!
3531ec713c28Smrg	    ;;
3532ec713c28Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
3533ec713c28Smrg	    # Rhapsody C library is in the System framework
3534ec713c28Smrg	    deplibs="$deplibs -framework System"
3535ec713c28Smrg	    ;;
3536ec713c28Smrg	  *-*-netbsd*)
3537ec713c28Smrg	    # Don't link with libc until the a.out ld.so is fixed.
3538ec713c28Smrg	    ;;
3539ec713c28Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
3540ec713c28Smrg	    # Do not include libc due to us having libc/libc_r.
3541ec713c28Smrg	    ;;
3542ec713c28Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
3543ec713c28Smrg	    # Causes problems with __ctype
3544ec713c28Smrg	    ;;
3545ec713c28Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
3546ec713c28Smrg	    # Compiler inserts libc in the correct place for threads to work
3547ec713c28Smrg	    ;;
3548ec713c28Smrg 	  *)
3549ec713c28Smrg	    # Add libc to deplibs on all other systems if necessary.
3550ec713c28Smrg	    if test "$build_libtool_need_lc" = "yes"; then
3551ec713c28Smrg	      deplibs="$deplibs -lc"
3552ec713c28Smrg	    fi
3553ec713c28Smrg	    ;;
3554ec713c28Smrg	  esac
3555ec713c28Smrg	fi
35561d54945dSmrg
3557ec713c28Smrg	# Transform deplibs into only deplibs that can be linked in shared.
3558ec713c28Smrg	name_save=$name
3559ec713c28Smrg	libname_save=$libname
3560ec713c28Smrg	release_save=$release
3561ec713c28Smrg	versuffix_save=$versuffix
3562ec713c28Smrg	major_save=$major
3563ec713c28Smrg	# I'm not sure if I'm treating the release correctly.  I think
3564ec713c28Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
3565ec713c28Smrg	# add it in twice.  Is that correct?
3566ec713c28Smrg	release=""
3567ec713c28Smrg	versuffix=""
3568ec713c28Smrg	major=""
3569ec713c28Smrg	newdeplibs=
3570ec713c28Smrg	droppeddeps=no
3571ec713c28Smrg	case $deplibs_check_method in
3572ec713c28Smrg	pass_all)
3573ec713c28Smrg	  # Don't check for shared/static.  Everything works.
3574ec713c28Smrg	  # This might be a little naive.  We might want to check
3575ec713c28Smrg	  # whether the library exists or not.  But this is on
3576ec713c28Smrg	  # osf3 & osf4 and I'm not really sure... Just
3577ec713c28Smrg	  # implementing what was already the behavior.
3578ec713c28Smrg	  newdeplibs=$deplibs
3579ec713c28Smrg	  ;;
3580ec713c28Smrg	test_compile)
3581ec713c28Smrg	  # This code stresses the "libraries are programs" paradigm to its
3582ec713c28Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
3583ec713c28Smrg	  # against the deplibs as a proxy for the library.  Then we can check
3584ec713c28Smrg	  # whether they linked in statically or dynamically with ldd.
3585ec713c28Smrg	  $rm conftest.c
3586ec713c28Smrg	  cat > conftest.c <<EOF
3587ec713c28Smrg	  int main() { return 0; }
3588ec713c28SmrgEOF
3589ec713c28Smrg	  $rm conftest
3590ec713c28Smrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
3591ec713c28Smrg	    ldd_output=`ldd conftest`
3592ec713c28Smrg	    for i in $deplibs; do
3593ec713c28Smrg	      name=`expr $i : '-l\(.*\)'`
3594ec713c28Smrg	      # If $name is empty we are operating on a -L argument.
3595ec713c28Smrg              if test "$name" != "" && test "$name" != "0"; then
3596ec713c28Smrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3597ec713c28Smrg		  case " $predeps $postdeps " in
3598ec713c28Smrg		  *" $i "*)
3599ec713c28Smrg		    newdeplibs="$newdeplibs $i"
3600ec713c28Smrg		    i=""
3601ec713c28Smrg		    ;;
3602ec713c28Smrg		  esac
3603ec713c28Smrg	        fi
3604ec713c28Smrg		if test -n "$i" ; then
3605ec713c28Smrg		  libname=`eval \\$echo \"$libname_spec\"`
3606ec713c28Smrg		  deplib_matches=`eval \\$echo \"$library_names_spec\"`
3607ec713c28Smrg		  set dummy $deplib_matches
3608ec713c28Smrg		  deplib_match=$2
3609ec713c28Smrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
3610ec713c28Smrg		    newdeplibs="$newdeplibs $i"
3611ec713c28Smrg		  else
3612ec713c28Smrg		    droppeddeps=yes
3613ec713c28Smrg		    $echo
3614ec713c28Smrg		    $echo "*** Warning: dynamic linker does not accept needed library $i."
3615ec713c28Smrg		    $echo "*** I have the capability to make that library automatically link in when"
3616ec713c28Smrg		    $echo "*** you link to this library.  But I can only do this if you have a"
3617ec713c28Smrg		    $echo "*** shared version of the library, which I believe you do not have"
3618ec713c28Smrg		    $echo "*** because a test_compile did reveal that the linker did not use it for"
3619ec713c28Smrg		    $echo "*** its dynamic dependency list that programs get resolved with at runtime."
3620ec713c28Smrg		  fi
3621ec713c28Smrg		fi
3622ec713c28Smrg	      else
3623ec713c28Smrg		newdeplibs="$newdeplibs $i"
3624ec713c28Smrg	      fi
3625ec713c28Smrg	    done
3626ec713c28Smrg	  else
3627ec713c28Smrg	    # Error occurred in the first compile.  Let's try to salvage
3628ec713c28Smrg	    # the situation: Compile a separate program for each library.
3629ec713c28Smrg	    for i in $deplibs; do
3630ec713c28Smrg	      name=`expr $i : '-l\(.*\)'`
3631ec713c28Smrg	      # If $name is empty we are operating on a -L argument.
3632ec713c28Smrg              if test "$name" != "" && test "$name" != "0"; then
3633ec713c28Smrg		$rm conftest
3634ec713c28Smrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
3635ec713c28Smrg		  ldd_output=`ldd conftest`
3636ec713c28Smrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3637ec713c28Smrg		    case " $predeps $postdeps " in
3638ec713c28Smrg		    *" $i "*)
3639ec713c28Smrg		      newdeplibs="$newdeplibs $i"
3640ec713c28Smrg		      i=""
3641ec713c28Smrg		      ;;
3642ec713c28Smrg		    esac
3643ec713c28Smrg		  fi
3644ec713c28Smrg		  if test -n "$i" ; then
3645ec713c28Smrg		    libname=`eval \\$echo \"$libname_spec\"`
3646ec713c28Smrg		    deplib_matches=`eval \\$echo \"$library_names_spec\"`
3647ec713c28Smrg		    set dummy $deplib_matches
3648ec713c28Smrg		    deplib_match=$2
3649ec713c28Smrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
3650ec713c28Smrg		      newdeplibs="$newdeplibs $i"
3651ec713c28Smrg		    else
3652ec713c28Smrg		      droppeddeps=yes
3653ec713c28Smrg		      $echo
3654ec713c28Smrg		      $echo "*** Warning: dynamic linker does not accept needed library $i."
3655ec713c28Smrg		      $echo "*** I have the capability to make that library automatically link in when"
3656ec713c28Smrg		      $echo "*** you link to this library.  But I can only do this if you have a"
3657ec713c28Smrg		      $echo "*** shared version of the library, which you do not appear to have"
3658ec713c28Smrg		      $echo "*** because a test_compile did reveal that the linker did not use this one"
3659ec713c28Smrg		      $echo "*** as a dynamic dependency that programs can get resolved with at runtime."
3660ec713c28Smrg		    fi
3661ec713c28Smrg		  fi
3662ec713c28Smrg		else
3663ec713c28Smrg		  droppeddeps=yes
3664ec713c28Smrg		  $echo
3665ec713c28Smrg		  $echo "*** Warning!  Library $i is needed by this library but I was not able to"
3666ec713c28Smrg		  $echo "*** make it link in!  You will probably need to install it or some"
3667ec713c28Smrg		  $echo "*** library that it depends on before this library will be fully"
3668ec713c28Smrg		  $echo "*** functional.  Installing it before continuing would be even better."
3669ec713c28Smrg		fi
3670ec713c28Smrg	      else
3671ec713c28Smrg		newdeplibs="$newdeplibs $i"
3672ec713c28Smrg	      fi
3673ec713c28Smrg	    done
3674ec713c28Smrg	  fi
3675ec713c28Smrg	  ;;
3676ec713c28Smrg	file_magic*)
3677ec713c28Smrg	  set dummy $deplibs_check_method
3678ec713c28Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
3679ec713c28Smrg	  for a_deplib in $deplibs; do
3680ec713c28Smrg	    name=`expr $a_deplib : '-l\(.*\)'`
3681ec713c28Smrg	    # If $name is empty we are operating on a -L argument.
3682ec713c28Smrg            if test "$name" != "" && test  "$name" != "0"; then
3683ec713c28Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3684ec713c28Smrg		case " $predeps $postdeps " in
3685ec713c28Smrg		*" $a_deplib "*)
3686ec713c28Smrg		  newdeplibs="$newdeplibs $a_deplib"
3687ec713c28Smrg		  a_deplib=""
3688ec713c28Smrg		  ;;
3689ec713c28Smrg		esac
3690ec713c28Smrg	      fi
3691ec713c28Smrg	      if test -n "$a_deplib" ; then
3692ec713c28Smrg		libname=`eval \\$echo \"$libname_spec\"`
3693ec713c28Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
3694ec713c28Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
3695ec713c28Smrg		  for potent_lib in $potential_libs; do
3696ec713c28Smrg		      # Follow soft links.
3697ec713c28Smrg		      if ls -lLd "$potent_lib" 2>/dev/null \
3698ec713c28Smrg			 | grep " -> " >/dev/null; then
3699ec713c28Smrg			continue
3700ec713c28Smrg		      fi
3701ec713c28Smrg		      # The statement above tries to avoid entering an
3702ec713c28Smrg		      # endless loop below, in case of cyclic links.
3703ec713c28Smrg		      # We might still enter an endless loop, since a link
3704ec713c28Smrg		      # loop can be closed while we follow links,
3705ec713c28Smrg		      # but so what?
3706ec713c28Smrg		      potlib="$potent_lib"
3707ec713c28Smrg		      while test -h "$potlib" 2>/dev/null; do
3708ec713c28Smrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
3709ec713c28Smrg			case $potliblink in
3710ec713c28Smrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
3711ec713c28Smrg			*) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
3712ec713c28Smrg			esac
3713ec713c28Smrg		      done
3714ec713c28Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
3715ec713c28Smrg			 | ${SED} 10q \
3716ec713c28Smrg			 | $EGREP "$file_magic_regex" > /dev/null; then
3717ec713c28Smrg			newdeplibs="$newdeplibs $a_deplib"
3718ec713c28Smrg			a_deplib=""
3719ec713c28Smrg			break 2
3720ec713c28Smrg		      fi
3721ec713c28Smrg		  done
3722ec713c28Smrg		done
3723ec713c28Smrg	      fi
3724ec713c28Smrg	      if test -n "$a_deplib" ; then
3725ec713c28Smrg		droppeddeps=yes
3726ec713c28Smrg		$echo
3727ec713c28Smrg		$echo "*** Warning: linker path does not have real file for library $a_deplib."
3728ec713c28Smrg		$echo "*** I have the capability to make that library automatically link in when"
3729ec713c28Smrg		$echo "*** you link to this library.  But I can only do this if you have a"
3730ec713c28Smrg		$echo "*** shared version of the library, which you do not appear to have"
3731ec713c28Smrg		$echo "*** because I did check the linker path looking for a file starting"
3732ec713c28Smrg		if test -z "$potlib" ; then
3733ec713c28Smrg		  $echo "*** with $libname but no candidates were found. (...for file magic test)"
3734ec713c28Smrg		else
3735ec713c28Smrg		  $echo "*** with $libname and none of the candidates passed a file format test"
3736ec713c28Smrg		  $echo "*** using a file magic. Last file checked: $potlib"
3737ec713c28Smrg		fi
3738ec713c28Smrg	      fi
3739ec713c28Smrg	    else
3740ec713c28Smrg	      # Add a -L argument.
3741ec713c28Smrg	      newdeplibs="$newdeplibs $a_deplib"
3742ec713c28Smrg	    fi
3743ec713c28Smrg	  done # Gone through all deplibs.
3744ec713c28Smrg	  ;;
3745ec713c28Smrg	match_pattern*)
3746ec713c28Smrg	  set dummy $deplibs_check_method
3747ec713c28Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
3748ec713c28Smrg	  for a_deplib in $deplibs; do
3749ec713c28Smrg	    name=`expr $a_deplib : '-l\(.*\)'`
3750ec713c28Smrg	    # If $name is empty we are operating on a -L argument.
3751ec713c28Smrg	    if test -n "$name" && test "$name" != "0"; then
3752ec713c28Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3753ec713c28Smrg		case " $predeps $postdeps " in
3754ec713c28Smrg		*" $a_deplib "*)
3755ec713c28Smrg		  newdeplibs="$newdeplibs $a_deplib"
3756ec713c28Smrg		  a_deplib=""
3757ec713c28Smrg		  ;;
3758ec713c28Smrg		esac
3759ec713c28Smrg	      fi
3760ec713c28Smrg	      if test -n "$a_deplib" ; then
3761ec713c28Smrg		libname=`eval \\$echo \"$libname_spec\"`
3762ec713c28Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
3763ec713c28Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
3764ec713c28Smrg		  for potent_lib in $potential_libs; do
3765ec713c28Smrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
3766ec713c28Smrg		    if eval $echo \"$potent_lib\" 2>/dev/null \
3767ec713c28Smrg		        | ${SED} 10q \
3768ec713c28Smrg		        | $EGREP "$match_pattern_regex" > /dev/null; then
3769ec713c28Smrg		      newdeplibs="$newdeplibs $a_deplib"
3770ec713c28Smrg		      a_deplib=""
3771ec713c28Smrg		      break 2
3772ec713c28Smrg		    fi
3773ec713c28Smrg		  done
3774ec713c28Smrg		done
3775ec713c28Smrg	      fi
3776ec713c28Smrg	      if test -n "$a_deplib" ; then
3777ec713c28Smrg		droppeddeps=yes
3778ec713c28Smrg		$echo
3779ec713c28Smrg		$echo "*** Warning: linker path does not have real file for library $a_deplib."
3780ec713c28Smrg		$echo "*** I have the capability to make that library automatically link in when"
3781ec713c28Smrg		$echo "*** you link to this library.  But I can only do this if you have a"
3782ec713c28Smrg		$echo "*** shared version of the library, which you do not appear to have"
3783ec713c28Smrg		$echo "*** because I did check the linker path looking for a file starting"
3784ec713c28Smrg		if test -z "$potlib" ; then
3785ec713c28Smrg		  $echo "*** with $libname but no candidates were found. (...for regex pattern test)"
3786ec713c28Smrg		else
3787ec713c28Smrg		  $echo "*** with $libname and none of the candidates passed a file format test"
3788ec713c28Smrg		  $echo "*** using a regex pattern. Last file checked: $potlib"
3789ec713c28Smrg		fi
3790ec713c28Smrg	      fi
3791ec713c28Smrg	    else
3792ec713c28Smrg	      # Add a -L argument.
3793ec713c28Smrg	      newdeplibs="$newdeplibs $a_deplib"
3794ec713c28Smrg	    fi
3795ec713c28Smrg	  done # Gone through all deplibs.
3796ec713c28Smrg	  ;;
3797ec713c28Smrg	none | unknown | *)
3798ec713c28Smrg	  newdeplibs=""
3799ec713c28Smrg	  tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
3800ec713c28Smrg	    -e 's/ -[LR][^ ]*//g'`
3801ec713c28Smrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3802ec713c28Smrg	    for i in $predeps $postdeps ; do
3803ec713c28Smrg	      # can't use Xsed below, because $i might contain '/'
3804ec713c28Smrg	      tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"`
3805ec713c28Smrg	    done
3806ec713c28Smrg	  fi
3807ec713c28Smrg	  if $echo "X $tmp_deplibs" | $Xsed -e 's/[ 	]//g' \
3808ec713c28Smrg	    | grep . >/dev/null; then
3809ec713c28Smrg	    $echo
3810ec713c28Smrg	    if test "X$deplibs_check_method" = "Xnone"; then
3811ec713c28Smrg	      $echo "*** Warning: inter-library dependencies are not supported in this platform."
3812ec713c28Smrg	    else
3813ec713c28Smrg	      $echo "*** Warning: inter-library dependencies are not known to be supported."
3814ec713c28Smrg	    fi
3815ec713c28Smrg	    $echo "*** All declared inter-library dependencies are being dropped."
3816ec713c28Smrg	    droppeddeps=yes
3817ec713c28Smrg	  fi
3818ec713c28Smrg	  ;;
3819ec713c28Smrg	esac
3820ec713c28Smrg	versuffix=$versuffix_save
3821ec713c28Smrg	major=$major_save
3822ec713c28Smrg	release=$release_save
3823ec713c28Smrg	libname=$libname_save
3824ec713c28Smrg	name=$name_save
38251d54945dSmrg
3826ec713c28Smrg	case $host in
3827ec713c28Smrg	*-*-rhapsody* | *-*-darwin1.[012])
3828ec713c28Smrg	  # On Rhapsody replace the C library is the System framework
3829ec713c28Smrg	  newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'`
3830ec713c28Smrg	  ;;
3831ec713c28Smrg	esac
38321d54945dSmrg
3833ec713c28Smrg	if test "$droppeddeps" = yes; then
3834ec713c28Smrg	  if test "$module" = yes; then
3835ec713c28Smrg	    $echo
3836ec713c28Smrg	    $echo "*** Warning: libtool could not satisfy all declared inter-library"
3837ec713c28Smrg	    $echo "*** dependencies of module $libname.  Therefore, libtool will create"
3838ec713c28Smrg	    $echo "*** a static module, that should work as long as the dlopening"
3839ec713c28Smrg	    $echo "*** application is linked with the -dlopen flag."
3840ec713c28Smrg	    if test -z "$global_symbol_pipe"; then
3841ec713c28Smrg	      $echo
3842ec713c28Smrg	      $echo "*** However, this would only work if libtool was able to extract symbol"
3843ec713c28Smrg	      $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
3844ec713c28Smrg	      $echo "*** not find such a program.  So, this module is probably useless."
3845ec713c28Smrg	      $echo "*** \`nm' from GNU binutils and a full rebuild may help."
3846ec713c28Smrg	    fi
3847ec713c28Smrg	    if test "$build_old_libs" = no; then
3848ec713c28Smrg	      oldlibs="$output_objdir/$libname.$libext"
3849ec713c28Smrg	      build_libtool_libs=module
3850ec713c28Smrg	      build_old_libs=yes
3851ec713c28Smrg	    else
3852ec713c28Smrg	      build_libtool_libs=no
3853ec713c28Smrg	    fi
3854ec713c28Smrg	  else
3855ec713c28Smrg	    $echo "*** The inter-library dependencies that have been dropped here will be"
3856ec713c28Smrg	    $echo "*** automatically added whenever a program is linked with this library"
3857ec713c28Smrg	    $echo "*** or is declared to -dlopen it."
38581d54945dSmrg
3859ec713c28Smrg	    if test "$allow_undefined" = no; then
3860ec713c28Smrg	      $echo
3861ec713c28Smrg	      $echo "*** Since this library must not contain undefined symbols,"
3862ec713c28Smrg	      $echo "*** because either the platform does not support them or"
3863ec713c28Smrg	      $echo "*** it was explicitly requested with -no-undefined,"
3864ec713c28Smrg	      $echo "*** libtool will only create a static version of it."
3865ec713c28Smrg	      if test "$build_old_libs" = no; then
3866ec713c28Smrg		oldlibs="$output_objdir/$libname.$libext"
3867ec713c28Smrg		build_libtool_libs=module
3868ec713c28Smrg		build_old_libs=yes
3869ec713c28Smrg	      else
3870ec713c28Smrg		build_libtool_libs=no
3871ec713c28Smrg	      fi
3872ec713c28Smrg	    fi
3873ec713c28Smrg	  fi
3874ec713c28Smrg	fi
3875ec713c28Smrg	# Done checking deplibs!
3876ec713c28Smrg	deplibs=$newdeplibs
3877ec713c28Smrg      fi
38781d54945dSmrg
38791d54945dSmrg
3880ec713c28Smrg      # move library search paths that coincide with paths to not yet
3881ec713c28Smrg      # installed libraries to the beginning of the library search list
3882ec713c28Smrg      new_libs=
3883ec713c28Smrg      for path in $notinst_path; do
3884ec713c28Smrg	case " $new_libs " in
3885ec713c28Smrg	*" -L$path/$objdir "*) ;;
3886ec713c28Smrg	*)
3887ec713c28Smrg	  case " $deplibs " in
3888ec713c28Smrg	  *" -L$path/$objdir "*)
3889ec713c28Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
3890ec713c28Smrg	  esac
3891ec713c28Smrg	  ;;
3892ec713c28Smrg	esac
3893ec713c28Smrg      done
3894ec713c28Smrg      for deplib in $deplibs; do
3895ec713c28Smrg	case $deplib in
3896ec713c28Smrg	-L*)
3897ec713c28Smrg	  case " $new_libs " in
3898ec713c28Smrg	  *" $deplib "*) ;;
3899ec713c28Smrg	  *) new_libs="$new_libs $deplib" ;;
3900ec713c28Smrg	  esac
3901ec713c28Smrg	  ;;
3902ec713c28Smrg	*) new_libs="$new_libs $deplib" ;;
3903ec713c28Smrg	esac
3904ec713c28Smrg      done
3905ec713c28Smrg      deplibs="$new_libs"
39061d54945dSmrg
39071d54945dSmrg
3908ec713c28Smrg      # All the library-specific variables (install_libdir is set above).
3909ec713c28Smrg      library_names=
3910ec713c28Smrg      old_library=
3911ec713c28Smrg      dlname=
39121d54945dSmrg
3913ec713c28Smrg      # Test again, we may have decided not to build it any more
3914ec713c28Smrg      if test "$build_libtool_libs" = yes; then
3915ec713c28Smrg	if test "$hardcode_into_libs" = yes; then
3916ec713c28Smrg	  # Hardcode the library paths
3917ec713c28Smrg	  hardcode_libdirs=
3918ec713c28Smrg	  dep_rpath=
3919ec713c28Smrg	  rpath="$finalize_rpath"
3920ec713c28Smrg	  test "$mode" != relink && rpath="$compile_rpath$rpath"
3921ec713c28Smrg	  for libdir in $rpath; do
3922ec713c28Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
3923ec713c28Smrg	      if test -n "$hardcode_libdir_separator"; then
3924ec713c28Smrg		if test -z "$hardcode_libdirs"; then
3925ec713c28Smrg		  hardcode_libdirs="$libdir"
3926ec713c28Smrg		else
3927ec713c28Smrg		  # Just accumulate the unique libdirs.
3928ec713c28Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
3929ec713c28Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
3930ec713c28Smrg		    ;;
3931ec713c28Smrg		  *)
3932ec713c28Smrg		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
3933ec713c28Smrg		    ;;
3934ec713c28Smrg		  esac
3935ec713c28Smrg		fi
3936ec713c28Smrg	      else
3937ec713c28Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
3938ec713c28Smrg		dep_rpath="$dep_rpath $flag"
3939ec713c28Smrg	      fi
3940ec713c28Smrg	    elif test -n "$runpath_var"; then
3941ec713c28Smrg	      case "$perm_rpath " in
3942ec713c28Smrg	      *" $libdir "*) ;;
3943ec713c28Smrg	      *) perm_rpath="$perm_rpath $libdir" ;;
3944ec713c28Smrg	      esac
3945ec713c28Smrg	    fi
3946ec713c28Smrg	  done
3947ec713c28Smrg	  # Substitute the hardcoded libdirs into the rpath.
3948ec713c28Smrg	  if test -n "$hardcode_libdir_separator" &&
3949ec713c28Smrg	     test -n "$hardcode_libdirs"; then
3950ec713c28Smrg	    libdir="$hardcode_libdirs"
3951ec713c28Smrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
3952ec713c28Smrg	      case $archive_cmds in
3953ec713c28Smrg	      *\$LD*) eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" ;;
3954ec713c28Smrg	      *)      eval dep_rpath=\"$hardcode_libdir_flag_spec\" ;;
3955ec713c28Smrg	      esac
3956ec713c28Smrg	    else
3957ec713c28Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
3958ec713c28Smrg	    fi
3959ec713c28Smrg	  fi
3960ec713c28Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
3961ec713c28Smrg	    # We should set the runpath_var.
3962ec713c28Smrg	    rpath=
3963ec713c28Smrg	    for dir in $perm_rpath; do
3964ec713c28Smrg	      rpath="$rpath$dir:"
3965ec713c28Smrg	    done
3966ec713c28Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
3967ec713c28Smrg	  fi
3968ec713c28Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
3969ec713c28Smrg	fi
39701d54945dSmrg
3971ec713c28Smrg	shlibpath="$finalize_shlibpath"
3972ec713c28Smrg	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
3973ec713c28Smrg	if test -n "$shlibpath"; then
3974ec713c28Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
3975ec713c28Smrg	fi
39761d54945dSmrg
3977ec713c28Smrg	# Get the real and link names of the library.
3978ec713c28Smrg	eval shared_ext=\"$shrext_cmds\"
3979ec713c28Smrg	eval library_names=\"$library_names_spec\"
3980ec713c28Smrg	set dummy $library_names
3981ec713c28Smrg	realname="$2"
3982ec713c28Smrg	shift; shift
39831d54945dSmrg
3984ec713c28Smrg	if test -n "$soname_spec"; then
3985ec713c28Smrg	  eval soname=\"$soname_spec\"
3986ec713c28Smrg	else
3987ec713c28Smrg	  soname="$realname"
3988ec713c28Smrg	fi
3989ec713c28Smrg	if test -z "$dlname"; then
3990ec713c28Smrg	  dlname=$soname
3991ec713c28Smrg	fi
39921d54945dSmrg
3993ec713c28Smrg	lib="$output_objdir/$realname"
3994ec713c28Smrg	linknames=
3995ec713c28Smrg	for link
3996ec713c28Smrg	do
3997ec713c28Smrg	  linknames="$linknames $link"
3998ec713c28Smrg	done
39991d54945dSmrg
4000ec713c28Smrg	# Use standard objects if they are pic
4001ec713c28Smrg	test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
40021d54945dSmrg
4003ec713c28Smrg	# Prepare the list of exported symbols
4004ec713c28Smrg	if test -z "$export_symbols"; then
4005ec713c28Smrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
4006ec713c28Smrg	    $show "generating symbol list for \`$libname.la'"
4007ec713c28Smrg	    export_symbols="$output_objdir/$libname.exp"
4008ec713c28Smrg	    $run $rm $export_symbols
4009ec713c28Smrg	    cmds=$export_symbols_cmds
4010ec713c28Smrg	    save_ifs="$IFS"; IFS='~'
4011ec713c28Smrg	    for cmd in $cmds; do
4012ec713c28Smrg	      IFS="$save_ifs"
4013ec713c28Smrg	      eval cmd=\"$cmd\"
4014ec713c28Smrg	      if len=`expr "X$cmd" : ".*"` &&
4015ec713c28Smrg	       test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
4016ec713c28Smrg	        $show "$cmd"
4017ec713c28Smrg	        $run eval "$cmd" || exit $?
4018ec713c28Smrg	        skipped_export=false
4019ec713c28Smrg	      else
4020ec713c28Smrg	        # The command line is too long to execute in one step.
4021ec713c28Smrg	        $show "using reloadable object file for export list..."
4022ec713c28Smrg	        skipped_export=:
4023ec713c28Smrg		# Break out early, otherwise skipped_export may be
4024ec713c28Smrg		# set to false by a later but shorter cmd.
4025ec713c28Smrg		break
4026ec713c28Smrg	      fi
4027ec713c28Smrg	    done
4028ec713c28Smrg	    IFS="$save_ifs"
4029ec713c28Smrg	    if test -n "$export_symbols_regex"; then
4030ec713c28Smrg	      $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
4031ec713c28Smrg	      $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
4032ec713c28Smrg	      $show "$mv \"${export_symbols}T\" \"$export_symbols\""
4033ec713c28Smrg	      $run eval '$mv "${export_symbols}T" "$export_symbols"'
4034ec713c28Smrg	    fi
4035ec713c28Smrg	  fi
4036ec713c28Smrg	fi
40371d54945dSmrg
4038ec713c28Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
4039ec713c28Smrg	  $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
4040ec713c28Smrg	fi
40411d54945dSmrg
4042ec713c28Smrg	tmp_deplibs=
4043ec713c28Smrg	for test_deplib in $deplibs; do
4044ec713c28Smrg		case " $convenience " in
4045ec713c28Smrg		*" $test_deplib "*) ;;
4046ec713c28Smrg		*)
4047ec713c28Smrg			tmp_deplibs="$tmp_deplibs $test_deplib"
4048ec713c28Smrg			;;
4049ec713c28Smrg		esac
4050ec713c28Smrg	done
4051ec713c28Smrg	deplibs="$tmp_deplibs"
40521d54945dSmrg
4053ec713c28Smrg	if test -n "$convenience"; then
4054ec713c28Smrg	  if test -n "$whole_archive_flag_spec"; then
4055ec713c28Smrg	    save_libobjs=$libobjs
4056ec713c28Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
4057ec713c28Smrg	  else
4058ec713c28Smrg	    gentop="$output_objdir/${outputname}x"
4059ec713c28Smrg	    generated="$generated $gentop"
40601d54945dSmrg
4061ec713c28Smrg	    func_extract_archives $gentop $convenience
4062ec713c28Smrg	    libobjs="$libobjs $func_extract_archives_result"
4063ec713c28Smrg	  fi
4064ec713c28Smrg	fi
4065ec713c28Smrg	
4066ec713c28Smrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
4067ec713c28Smrg	  eval flag=\"$thread_safe_flag_spec\"
4068ec713c28Smrg	  linker_flags="$linker_flags $flag"
4069ec713c28Smrg	fi
40701d54945dSmrg
4071ec713c28Smrg	# Make a backup of the uninstalled library when relinking
4072ec713c28Smrg	if test "$mode" = relink; then
4073ec713c28Smrg	  $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $?
4074ec713c28Smrg	fi
40751d54945dSmrg
4076ec713c28Smrg	# Do each of the archive commands.
4077ec713c28Smrg	if test "$module" = yes && test -n "$module_cmds" ; then
4078ec713c28Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
4079ec713c28Smrg	    eval test_cmds=\"$module_expsym_cmds\"
4080ec713c28Smrg	    cmds=$module_expsym_cmds
4081ec713c28Smrg	  else
4082ec713c28Smrg	    eval test_cmds=\"$module_cmds\"
4083ec713c28Smrg	    cmds=$module_cmds
4084ec713c28Smrg	  fi
4085ec713c28Smrg	else
4086ec713c28Smrg	if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
4087ec713c28Smrg	  eval test_cmds=\"$archive_expsym_cmds\"
4088ec713c28Smrg	  cmds=$archive_expsym_cmds
4089ec713c28Smrg	else
4090ec713c28Smrg	  eval test_cmds=\"$archive_cmds\"
4091ec713c28Smrg	  cmds=$archive_cmds
4092ec713c28Smrg	  fi
4093ec713c28Smrg	fi
40941d54945dSmrg
4095ec713c28Smrg	if test "X$skipped_export" != "X:" &&
4096ec713c28Smrg	   len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
4097ec713c28Smrg	   test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
4098ec713c28Smrg	  :
4099ec713c28Smrg	else
4100ec713c28Smrg	  # The command line is too long to link in one step, link piecewise.
4101ec713c28Smrg	  $echo "creating reloadable object files..."
41021d54945dSmrg
4103ec713c28Smrg	  # Save the value of $output and $libobjs because we want to
4104ec713c28Smrg	  # use them later.  If we have whole_archive_flag_spec, we
4105ec713c28Smrg	  # want to use save_libobjs as it was before
4106ec713c28Smrg	  # whole_archive_flag_spec was expanded, because we can't
4107ec713c28Smrg	  # assume the linker understands whole_archive_flag_spec.
4108ec713c28Smrg	  # This may have to be revisited, in case too many
4109ec713c28Smrg	  # convenience libraries get linked in and end up exceeding
4110ec713c28Smrg	  # the spec.
4111ec713c28Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
4112ec713c28Smrg	    save_libobjs=$libobjs
4113ec713c28Smrg	  fi
4114ec713c28Smrg	  save_output=$output
4115ec713c28Smrg	  output_la=`$echo "X$output" | $Xsed -e "$basename"`
41161d54945dSmrg
4117ec713c28Smrg	  # Clear the reloadable object creation command queue and
4118ec713c28Smrg	  # initialize k to one.
4119ec713c28Smrg	  test_cmds=
4120ec713c28Smrg	  concat_cmds=
4121ec713c28Smrg	  objlist=
4122ec713c28Smrg	  delfiles=
4123ec713c28Smrg	  last_robj=
4124ec713c28Smrg	  k=1
4125ec713c28Smrg	  output=$output_objdir/$output_la-${k}.$objext
4126ec713c28Smrg	  # Loop over the list of objects to be linked.
4127ec713c28Smrg	  for obj in $save_libobjs
4128ec713c28Smrg	  do
4129ec713c28Smrg	    eval test_cmds=\"$reload_cmds $objlist $last_robj\"
4130ec713c28Smrg	    if test "X$objlist" = X ||
4131ec713c28Smrg	       { len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
4132ec713c28Smrg		 test "$len" -le "$max_cmd_len"; }; then
4133ec713c28Smrg	      objlist="$objlist $obj"
4134ec713c28Smrg	    else
4135ec713c28Smrg	      # The command $test_cmds is almost too long, add a
4136ec713c28Smrg	      # command to the queue.
4137ec713c28Smrg	      if test "$k" -eq 1 ; then
4138ec713c28Smrg		# The first file doesn't have a previous command to add.
4139ec713c28Smrg		eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
4140ec713c28Smrg	      else
4141ec713c28Smrg		# All subsequent reloadable object files will link in
4142ec713c28Smrg		# the last one created.
4143ec713c28Smrg		eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
4144ec713c28Smrg	      fi
4145ec713c28Smrg	      last_robj=$output_objdir/$output_la-${k}.$objext
4146ec713c28Smrg	      k=`expr $k + 1`
4147ec713c28Smrg	      output=$output_objdir/$output_la-${k}.$objext
4148ec713c28Smrg	      objlist=$obj
4149ec713c28Smrg	      len=1
4150ec713c28Smrg	    fi
4151ec713c28Smrg	  done
4152ec713c28Smrg	  # Handle the remaining objects by creating one last
4153ec713c28Smrg	  # reloadable object file.  All subsequent reloadable object
4154ec713c28Smrg	  # files will link in the last one created.
4155ec713c28Smrg	  test -z "$concat_cmds" || concat_cmds=$concat_cmds~
4156ec713c28Smrg	  eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
4157ec713c28Smrg
4158ec713c28Smrg	  if ${skipped_export-false}; then
4159ec713c28Smrg	    $show "generating symbol list for \`$libname.la'"
4160ec713c28Smrg	    export_symbols="$output_objdir/$libname.exp"
4161ec713c28Smrg	    $run $rm $export_symbols
4162ec713c28Smrg	    libobjs=$output
4163ec713c28Smrg	    # Append the command to create the export file.
4164ec713c28Smrg	    eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
4165ec713c28Smrg          fi
4166ec713c28Smrg
4167ec713c28Smrg	  # Set up a command to remove the reloadable object files
4168ec713c28Smrg	  # after they are used.
4169ec713c28Smrg	  i=0
4170ec713c28Smrg	  while test "$i" -lt "$k"
4171ec713c28Smrg	  do
4172ec713c28Smrg	    i=`expr $i + 1`
4173ec713c28Smrg	    delfiles="$delfiles $output_objdir/$output_la-${i}.$objext"
4174ec713c28Smrg	  done
41751d54945dSmrg
4176ec713c28Smrg	  $echo "creating a temporary reloadable object file: $output"
41771d54945dSmrg
4178ec713c28Smrg	  # Loop through the commands generated above and execute them.
4179ec713c28Smrg	  save_ifs="$IFS"; IFS='~'
4180ec713c28Smrg	  for cmd in $concat_cmds; do
4181ec713c28Smrg	    IFS="$save_ifs"
4182ec713c28Smrg	    $show "$cmd"
4183ec713c28Smrg	    $run eval "$cmd" || exit $?
4184ec713c28Smrg	  done
4185ec713c28Smrg	  IFS="$save_ifs"
41861d54945dSmrg
4187ec713c28Smrg	  libobjs=$output
4188ec713c28Smrg	  # Restore the value of output.
4189ec713c28Smrg	  output=$save_output
41901d54945dSmrg
4191ec713c28Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
4192ec713c28Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
4193ec713c28Smrg	  fi
4194ec713c28Smrg	  # Expand the library linking commands again to reset the
4195ec713c28Smrg	  # value of $libobjs for piecewise linking.
41961d54945dSmrg
4197ec713c28Smrg	  # Do each of the archive commands.
4198ec713c28Smrg	  if test "$module" = yes && test -n "$module_cmds" ; then
4199ec713c28Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
4200ec713c28Smrg	      cmds=$module_expsym_cmds
4201ec713c28Smrg	    else
4202ec713c28Smrg	      cmds=$module_cmds
4203ec713c28Smrg	    fi
4204ec713c28Smrg	  else
4205ec713c28Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
4206ec713c28Smrg	    cmds=$archive_expsym_cmds
4207ec713c28Smrg	  else
4208ec713c28Smrg	    cmds=$archive_cmds
4209ec713c28Smrg	    fi
4210ec713c28Smrg	  fi
42111d54945dSmrg
4212ec713c28Smrg	  # Append the command to remove the reloadable object files
4213ec713c28Smrg	  # to the just-reset $cmds.
4214ec713c28Smrg	  eval cmds=\"\$cmds~\$rm $delfiles\"
4215ec713c28Smrg	fi
4216ec713c28Smrg	save_ifs="$IFS"; IFS='~'
4217ec713c28Smrg	for cmd in $cmds; do
4218ec713c28Smrg	  IFS="$save_ifs"
4219ec713c28Smrg	  eval cmd=\"$cmd\"
4220ec713c28Smrg	  $show "$cmd"
4221ec713c28Smrg	  $run eval "$cmd" || {
4222ec713c28Smrg	    lt_exit=$?
42231d54945dSmrg
4224ec713c28Smrg	    # Restore the uninstalled library and exit
4225ec713c28Smrg	    if test "$mode" = relink; then
4226ec713c28Smrg	      $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
4227ec713c28Smrg	    fi
42281d54945dSmrg
4229ec713c28Smrg	    exit $lt_exit
4230ec713c28Smrg	  }
4231ec713c28Smrg	done
4232ec713c28Smrg	IFS="$save_ifs"
4233ec713c28Smrg
4234ec713c28Smrg	# Restore the uninstalled library and exit
4235ec713c28Smrg	if test "$mode" = relink; then
4236ec713c28Smrg	  $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
4237ec713c28Smrg
4238ec713c28Smrg	  if test -n "$convenience"; then
4239ec713c28Smrg	    if test -z "$whole_archive_flag_spec"; then
4240ec713c28Smrg	      $show "${rm}r $gentop"
4241ec713c28Smrg	      $run ${rm}r "$gentop"
4242ec713c28Smrg	    fi
4243ec713c28Smrg	  fi
4244ec713c28Smrg
4245ec713c28Smrg	  exit $EXIT_SUCCESS
4246ec713c28Smrg	fi
4247ec713c28Smrg
4248ec713c28Smrg	# Create links to the real library.
4249ec713c28Smrg	for linkname in $linknames; do
4250ec713c28Smrg	  if test "$realname" != "$linkname"; then
4251ec713c28Smrg	    $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
4252ec713c28Smrg	    $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
4253ec713c28Smrg	  fi
4254ec713c28Smrg	done
4255ec713c28Smrg
4256ec713c28Smrg	# If -module or -export-dynamic was specified, set the dlname.
4257ec713c28Smrg	if test "$module" = yes || test "$export_dynamic" = yes; then
4258ec713c28Smrg	  # On all known operating systems, these are identical.
4259ec713c28Smrg	  dlname="$soname"
4260ec713c28Smrg	fi
4261ec713c28Smrg      fi
4262786a6f21Smrg      ;;
42631d54945dSmrg
4264ec713c28Smrg    obj)
4265ec713c28Smrg      case " $deplibs" in
4266ec713c28Smrg      *\ -l* | *\ -L*)
4267ec713c28Smrg	$echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 ;;
4268ec713c28Smrg      esac
42691d54945dSmrg
4270ec713c28Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
4271ec713c28Smrg	$echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
4272ec713c28Smrg      fi
42731d54945dSmrg
4274ec713c28Smrg      if test -n "$rpath"; then
4275ec713c28Smrg	$echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
4276ec713c28Smrg      fi
4277ec713c28Smrg
4278ec713c28Smrg      if test -n "$xrpath"; then
4279ec713c28Smrg	$echo "$modename: warning: \`-R' is ignored for objects" 1>&2
4280ec713c28Smrg      fi
4281ec713c28Smrg
4282ec713c28Smrg      if test -n "$vinfo"; then
4283ec713c28Smrg	$echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
4284ec713c28Smrg      fi
4285ec713c28Smrg
4286ec713c28Smrg      if test -n "$release"; then
4287ec713c28Smrg	$echo "$modename: warning: \`-release' is ignored for objects" 1>&2
4288ec713c28Smrg      fi
4289ec713c28Smrg
4290ec713c28Smrg      case $output in
4291ec713c28Smrg      *.lo)
4292ec713c28Smrg	if test -n "$objs$old_deplibs"; then
4293ec713c28Smrg	  $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
4294ec713c28Smrg	  exit $EXIT_FAILURE
4295ec713c28Smrg	fi
4296ec713c28Smrg	libobj="$output"
4297ec713c28Smrg	obj=`$echo "X$output" | $Xsed -e "$lo2o"`
4298786a6f21Smrg	;;
4299ec713c28Smrg      *)
4300ec713c28Smrg	libobj=
4301ec713c28Smrg	obj="$output"
4302786a6f21Smrg	;;
4303786a6f21Smrg      esac
43041d54945dSmrg
4305ec713c28Smrg      # Delete the old objects.
4306ec713c28Smrg      $run $rm $obj $libobj
43071d54945dSmrg
4308ec713c28Smrg      # Objects from convenience libraries.  This assumes
4309ec713c28Smrg      # single-version convenience libraries.  Whenever we create
4310ec713c28Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
4311ec713c28Smrg      # the extraction.
4312ec713c28Smrg      reload_conv_objs=
4313ec713c28Smrg      gentop=
4314ec713c28Smrg      # reload_cmds runs $LD directly, so let us get rid of
4315ec713c28Smrg      # -Wl from whole_archive_flag_spec and hope we can get by with
4316ec713c28Smrg      # turning comma into space..
4317ec713c28Smrg      wl=
43181d54945dSmrg
4319ec713c28Smrg      if test -n "$convenience"; then
4320ec713c28Smrg	if test -n "$whole_archive_flag_spec"; then
4321ec713c28Smrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
4322ec713c28Smrg	  reload_conv_objs=$reload_objs\ `$echo "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
4323ec713c28Smrg	else
4324ec713c28Smrg	  gentop="$output_objdir/${obj}x"
4325ec713c28Smrg	  generated="$generated $gentop"
43261d54945dSmrg
4327ec713c28Smrg	  func_extract_archives $gentop $convenience
4328ec713c28Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
4329ec713c28Smrg	fi
4330ec713c28Smrg      fi
43311d54945dSmrg
4332ec713c28Smrg      # Create the old-style object.
4333ec713c28Smrg      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
43341d54945dSmrg
4335ec713c28Smrg      output="$obj"
4336ec713c28Smrg      cmds=$reload_cmds
4337ec713c28Smrg      save_ifs="$IFS"; IFS='~'
4338ec713c28Smrg      for cmd in $cmds; do
4339ec713c28Smrg	IFS="$save_ifs"
4340ec713c28Smrg	eval cmd=\"$cmd\"
4341ec713c28Smrg	$show "$cmd"
4342ec713c28Smrg	$run eval "$cmd" || exit $?
4343ec713c28Smrg      done
4344ec713c28Smrg      IFS="$save_ifs"
43451d54945dSmrg
4346ec713c28Smrg      # Exit if we aren't doing a library object file.
4347ec713c28Smrg      if test -z "$libobj"; then
4348ec713c28Smrg	if test -n "$gentop"; then
4349ec713c28Smrg	  $show "${rm}r $gentop"
4350ec713c28Smrg	  $run ${rm}r $gentop
4351ec713c28Smrg	fi
43521d54945dSmrg
4353ec713c28Smrg	exit $EXIT_SUCCESS
4354ec713c28Smrg      fi
43551d54945dSmrg
4356ec713c28Smrg      if test "$build_libtool_libs" != yes; then
4357ec713c28Smrg	if test -n "$gentop"; then
4358ec713c28Smrg	  $show "${rm}r $gentop"
4359ec713c28Smrg	  $run ${rm}r $gentop
4360ec713c28Smrg	fi
43611d54945dSmrg
4362ec713c28Smrg	# Create an invalid libtool object if no PIC, so that we don't
4363ec713c28Smrg	# accidentally link it into a program.
4364ec713c28Smrg	# $show "echo timestamp > $libobj"
4365ec713c28Smrg	# $run eval "echo timestamp > $libobj" || exit $?
4366ec713c28Smrg	exit $EXIT_SUCCESS
4367ec713c28Smrg      fi
43681d54945dSmrg
4369ec713c28Smrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
4370ec713c28Smrg	# Only do commands if we really have different PIC objects.
4371ec713c28Smrg	reload_objs="$libobjs $reload_conv_objs"
4372ec713c28Smrg	output="$libobj"
4373ec713c28Smrg	cmds=$reload_cmds
4374ec713c28Smrg	save_ifs="$IFS"; IFS='~'
4375ec713c28Smrg	for cmd in $cmds; do
4376ec713c28Smrg	  IFS="$save_ifs"
4377ec713c28Smrg	  eval cmd=\"$cmd\"
4378ec713c28Smrg	  $show "$cmd"
4379ec713c28Smrg	  $run eval "$cmd" || exit $?
4380ec713c28Smrg	done
4381ec713c28Smrg	IFS="$save_ifs"
4382ec713c28Smrg      fi
43831d54945dSmrg
4384ec713c28Smrg      if test -n "$gentop"; then
4385ec713c28Smrg	$show "${rm}r $gentop"
4386ec713c28Smrg	$run ${rm}r $gentop
4387ec713c28Smrg      fi
43881d54945dSmrg
4389ec713c28Smrg      exit $EXIT_SUCCESS
4390ec713c28Smrg      ;;
43911d54945dSmrg
4392ec713c28Smrg    prog)
4393ec713c28Smrg      case $host in
4394ec713c28Smrg	*cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
4395ec713c28Smrg      esac
4396ec713c28Smrg      if test -n "$vinfo"; then
4397ec713c28Smrg	$echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
4398ec713c28Smrg      fi
43991d54945dSmrg
4400ec713c28Smrg      if test -n "$release"; then
4401ec713c28Smrg	$echo "$modename: warning: \`-release' is ignored for programs" 1>&2
4402ec713c28Smrg      fi
44031d54945dSmrg
4404ec713c28Smrg      if test "$preload" = yes; then
4405ec713c28Smrg	if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown &&
4406ec713c28Smrg	   test "$dlopen_self_static" = unknown; then
4407ec713c28Smrg	  $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
4408786a6f21Smrg	fi
4409ec713c28Smrg      fi
44101d54945dSmrg
4411ec713c28Smrg      case $host in
4412ec713c28Smrg      *-*-rhapsody* | *-*-darwin1.[012])
4413ec713c28Smrg	# On Rhapsody replace the C library is the System framework
4414ec713c28Smrg	compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
4415ec713c28Smrg	finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
4416786a6f21Smrg	;;
4417ec713c28Smrg      esac
44181d54945dSmrg
4419ec713c28Smrg      case $host in
4420ec713c28Smrg      *darwin*)
4421ec713c28Smrg        # Don't allow lazy linking, it breaks C++ global constructors
4422ec713c28Smrg        if test "$tagname" = CXX ; then
4423ec713c28Smrg        compile_command="$compile_command ${wl}-bind_at_load"
4424ec713c28Smrg        finalize_command="$finalize_command ${wl}-bind_at_load"
4425ec713c28Smrg        fi
4426ec713c28Smrg        ;;
4427ec713c28Smrg      esac
44281d54945dSmrg
44291d54945dSmrg
4430ec713c28Smrg      # move library search paths that coincide with paths to not yet
4431ec713c28Smrg      # installed libraries to the beginning of the library search list
4432ec713c28Smrg      new_libs=
4433ec713c28Smrg      for path in $notinst_path; do
4434ec713c28Smrg	case " $new_libs " in
4435ec713c28Smrg	*" -L$path/$objdir "*) ;;
4436ec713c28Smrg	*)
4437ec713c28Smrg	  case " $compile_deplibs " in
4438ec713c28Smrg	  *" -L$path/$objdir "*)
4439ec713c28Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
4440ec713c28Smrg	  esac
4441ec713c28Smrg	  ;;
4442ec713c28Smrg	esac
4443ec713c28Smrg      done
4444ec713c28Smrg      for deplib in $compile_deplibs; do
4445ec713c28Smrg	case $deplib in
4446ec713c28Smrg	-L*)
4447ec713c28Smrg	  case " $new_libs " in
4448ec713c28Smrg	  *" $deplib "*) ;;
4449ec713c28Smrg	  *) new_libs="$new_libs $deplib" ;;
4450ec713c28Smrg	  esac
4451ec713c28Smrg	  ;;
4452ec713c28Smrg	*) new_libs="$new_libs $deplib" ;;
4453ec713c28Smrg	esac
4454ec713c28Smrg      done
4455ec713c28Smrg      compile_deplibs="$new_libs"
44561d54945dSmrg
44571d54945dSmrg
4458ec713c28Smrg      compile_command="$compile_command $compile_deplibs"
4459ec713c28Smrg      finalize_command="$finalize_command $finalize_deplibs"
44601d54945dSmrg
4461ec713c28Smrg      if test -n "$rpath$xrpath"; then
4462ec713c28Smrg	# If the user specified any rpath flags, then add them.
4463ec713c28Smrg	for libdir in $rpath $xrpath; do
4464ec713c28Smrg	  # This is the magic to use -rpath.
4465ec713c28Smrg	  case "$finalize_rpath " in
4466ec713c28Smrg	  *" $libdir "*) ;;
4467ec713c28Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
4468ec713c28Smrg	  esac
4469ec713c28Smrg	done
4470ec713c28Smrg      fi
44711d54945dSmrg
4472ec713c28Smrg      # Now hardcode the library paths
4473ec713c28Smrg      rpath=
4474ec713c28Smrg      hardcode_libdirs=
4475ec713c28Smrg      for libdir in $compile_rpath $finalize_rpath; do
4476ec713c28Smrg	if test -n "$hardcode_libdir_flag_spec"; then
4477ec713c28Smrg	  if test -n "$hardcode_libdir_separator"; then
4478ec713c28Smrg	    if test -z "$hardcode_libdirs"; then
4479ec713c28Smrg	      hardcode_libdirs="$libdir"
4480ec713c28Smrg	    else
4481ec713c28Smrg	      # Just accumulate the unique libdirs.
4482ec713c28Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
4483ec713c28Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
4484ec713c28Smrg		;;
4485ec713c28Smrg	      *)
4486ec713c28Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
4487ec713c28Smrg		;;
4488ec713c28Smrg	      esac
4489ec713c28Smrg	    fi
4490786a6f21Smrg	  else
4491ec713c28Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
4492ec713c28Smrg	    rpath="$rpath $flag"
4493786a6f21Smrg	  fi
4494ec713c28Smrg	elif test -n "$runpath_var"; then
4495ec713c28Smrg	  case "$perm_rpath " in
4496ec713c28Smrg	  *" $libdir "*) ;;
4497ec713c28Smrg	  *) perm_rpath="$perm_rpath $libdir" ;;
4498ec713c28Smrg	  esac
4499786a6f21Smrg	fi
4500786a6f21Smrg	case $host in
4501ec713c28Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
4502ec713c28Smrg	  testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'`
4503786a6f21Smrg	  case :$dllsearchpath: in
4504ec713c28Smrg	  *":$libdir:"*) ;;
4505ec713c28Smrg	  *) dllsearchpath="$dllsearchpath:$libdir";;
4506786a6f21Smrg	  esac
4507786a6f21Smrg	  case :$dllsearchpath: in
4508786a6f21Smrg	  *":$testbindir:"*) ;;
4509786a6f21Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
4510786a6f21Smrg	  esac
4511786a6f21Smrg	  ;;
4512786a6f21Smrg	esac
4513ec713c28Smrg      done
4514ec713c28Smrg      # Substitute the hardcoded libdirs into the rpath.
4515ec713c28Smrg      if test -n "$hardcode_libdir_separator" &&
4516ec713c28Smrg	 test -n "$hardcode_libdirs"; then
4517ec713c28Smrg	libdir="$hardcode_libdirs"
4518ec713c28Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
4519ec713c28Smrg      fi
4520ec713c28Smrg      compile_rpath="$rpath"
45211d54945dSmrg
4522ec713c28Smrg      rpath=
4523ec713c28Smrg      hardcode_libdirs=
4524ec713c28Smrg      for libdir in $finalize_rpath; do
4525ec713c28Smrg	if test -n "$hardcode_libdir_flag_spec"; then
4526ec713c28Smrg	  if test -n "$hardcode_libdir_separator"; then
4527ec713c28Smrg	    if test -z "$hardcode_libdirs"; then
4528ec713c28Smrg	      hardcode_libdirs="$libdir"
4529ec713c28Smrg	    else
4530ec713c28Smrg	      # Just accumulate the unique libdirs.
4531ec713c28Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
4532ec713c28Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
4533ec713c28Smrg		;;
4534ec713c28Smrg	      *)
4535ec713c28Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
4536ec713c28Smrg		;;
4537ec713c28Smrg	      esac
4538ec713c28Smrg	    fi
4539ec713c28Smrg	  else
4540ec713c28Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
4541ec713c28Smrg	    rpath="$rpath $flag"
4542ec713c28Smrg	  fi
4543ec713c28Smrg	elif test -n "$runpath_var"; then
4544ec713c28Smrg	  case "$finalize_perm_rpath " in
4545ec713c28Smrg	  *" $libdir "*) ;;
4546ec713c28Smrg	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
4547786a6f21Smrg	  esac
4548786a6f21Smrg	fi
4549ec713c28Smrg      done
4550ec713c28Smrg      # Substitute the hardcoded libdirs into the rpath.
4551ec713c28Smrg      if test -n "$hardcode_libdir_separator" &&
4552ec713c28Smrg	 test -n "$hardcode_libdirs"; then
4553ec713c28Smrg	libdir="$hardcode_libdirs"
4554ec713c28Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
4555ec713c28Smrg      fi
4556ec713c28Smrg      finalize_rpath="$rpath"
45571d54945dSmrg
4558ec713c28Smrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
4559ec713c28Smrg	# Transform all the library objects into standard objects.
4560ec713c28Smrg	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
4561ec713c28Smrg	finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
4562ec713c28Smrg      fi
45631d54945dSmrg
4564ec713c28Smrg      dlsyms=
4565ec713c28Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
4566ec713c28Smrg	if test -n "$NM" && test -n "$global_symbol_pipe"; then
4567ec713c28Smrg	  dlsyms="${outputname}S.c"
4568ec713c28Smrg	else
4569ec713c28Smrg	  $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
4570ec713c28Smrg	fi
4571ec713c28Smrg      fi
45721d54945dSmrg
4573ec713c28Smrg      if test -n "$dlsyms"; then
4574ec713c28Smrg	case $dlsyms in
4575ec713c28Smrg	"") ;;
4576ec713c28Smrg	*.c)
4577ec713c28Smrg	  # Discover the nlist of each of the dlfiles.
4578ec713c28Smrg	  nlist="$output_objdir/${outputname}.nm"
45791d54945dSmrg
4580ec713c28Smrg	  $show "$rm $nlist ${nlist}S ${nlist}T"
4581ec713c28Smrg	  $run $rm "$nlist" "${nlist}S" "${nlist}T"
45821d54945dSmrg
4583ec713c28Smrg	  # Parse the name list into a source file.
4584ec713c28Smrg	  $show "creating $output_objdir/$dlsyms"
45851d54945dSmrg
4586ec713c28Smrg	  test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
4587ec713c28Smrg/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
4588ec713c28Smrg/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
45891d54945dSmrg
4590ec713c28Smrg#ifdef __cplusplus
4591ec713c28Smrgextern \"C\" {
4592ec713c28Smrg#endif
45931d54945dSmrg
4594ec713c28Smrg/* Prevent the only kind of declaration conflicts we can make. */
4595ec713c28Smrg#define lt_preloaded_symbols some_other_symbol
45961d54945dSmrg
4597ec713c28Smrg/* External symbol declarations for the compiler. */\
4598ec713c28Smrg"
45991d54945dSmrg
4600ec713c28Smrg	  if test "$dlself" = yes; then
4601ec713c28Smrg	    $show "generating symbol list for \`$output'"
46021d54945dSmrg
4603ec713c28Smrg	    test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
46041d54945dSmrg
4605ec713c28Smrg	    # Add our own program objects to the symbol list.
4606ec713c28Smrg	    progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
4607ec713c28Smrg	    for arg in $progfiles; do
4608ec713c28Smrg	      $show "extracting global C symbols from \`$arg'"
4609ec713c28Smrg	      $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
4610ec713c28Smrg	    done
46111d54945dSmrg
4612ec713c28Smrg	    if test -n "$exclude_expsyms"; then
4613ec713c28Smrg	      $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
4614ec713c28Smrg	      $run eval '$mv "$nlist"T "$nlist"'
4615ec713c28Smrg	    fi
46161d54945dSmrg
4617ec713c28Smrg	    if test -n "$export_symbols_regex"; then
4618ec713c28Smrg	      $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
4619ec713c28Smrg	      $run eval '$mv "$nlist"T "$nlist"'
4620ec713c28Smrg	    fi
46211d54945dSmrg
4622ec713c28Smrg	    # Prepare the list of exported symbols
4623ec713c28Smrg	    if test -z "$export_symbols"; then
4624ec713c28Smrg	      export_symbols="$output_objdir/$outputname.exp"
4625ec713c28Smrg	      $run $rm $export_symbols
4626ec713c28Smrg	      $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4627ec713c28Smrg              case $host in
4628ec713c28Smrg              *cygwin* | *mingw* )
4629ec713c28Smrg	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4630ec713c28Smrg		$run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
4631ec713c28Smrg                ;;
4632ec713c28Smrg              esac
4633ec713c28Smrg	    else
4634ec713c28Smrg	      $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4635ec713c28Smrg	      $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
4636ec713c28Smrg	      $run eval 'mv "$nlist"T "$nlist"'
4637ec713c28Smrg              case $host in
4638ec713c28Smrg              *cygwin* | *mingw* )
4639ec713c28Smrg	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4640ec713c28Smrg		$run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
4641ec713c28Smrg                ;;
4642ec713c28Smrg              esac
4643ec713c28Smrg	    fi
4644ec713c28Smrg	  fi
46451d54945dSmrg
4646ec713c28Smrg	  for arg in $dlprefiles; do
4647ec713c28Smrg	    $show "extracting global C symbols from \`$arg'"
4648ec713c28Smrg	    name=`$echo "$arg" | ${SED} -e 's%^.*/%%'`
4649ec713c28Smrg	    $run eval '$echo ": $name " >> "$nlist"'
4650ec713c28Smrg	    $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
4651ec713c28Smrg	  done
46521d54945dSmrg
4653ec713c28Smrg	  if test -z "$run"; then
4654ec713c28Smrg	    # Make sure we have at least an empty file.
4655ec713c28Smrg	    test -f "$nlist" || : > "$nlist"
46561d54945dSmrg
4657ec713c28Smrg	    if test -n "$exclude_expsyms"; then
4658ec713c28Smrg	      $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
4659ec713c28Smrg	      $mv "$nlist"T "$nlist"
4660ec713c28Smrg	    fi
46611d54945dSmrg
4662ec713c28Smrg	    # Try sorting and uniquifying the output.
4663ec713c28Smrg	    if grep -v "^: " < "$nlist" |
4664ec713c28Smrg		if sort -k 3 </dev/null >/dev/null 2>&1; then
4665ec713c28Smrg		  sort -k 3
4666ec713c28Smrg		else
4667ec713c28Smrg		  sort +2
4668ec713c28Smrg		fi |
4669ec713c28Smrg		uniq > "$nlist"S; then
4670ec713c28Smrg	      :
4671ec713c28Smrg	    else
4672ec713c28Smrg	      grep -v "^: " < "$nlist" > "$nlist"S
4673ec713c28Smrg	    fi
46741d54945dSmrg
4675ec713c28Smrg	    if test -f "$nlist"S; then
4676ec713c28Smrg	      eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
4677ec713c28Smrg	    else
4678ec713c28Smrg	      $echo '/* NONE */' >> "$output_objdir/$dlsyms"
4679ec713c28Smrg	    fi
46801d54945dSmrg
4681ec713c28Smrg	    $echo >> "$output_objdir/$dlsyms" "\
46821d54945dSmrg
4683ec713c28Smrg#undef lt_preloaded_symbols
4684ba85709eSmrg
4685ec713c28Smrg#if defined (__STDC__) && __STDC__
4686ec713c28Smrg# define lt_ptr void *
4687ec713c28Smrg#else
4688ec713c28Smrg# define lt_ptr char *
4689ec713c28Smrg# define const
4690ec713c28Smrg#endif
46911d54945dSmrg
4692ec713c28Smrg/* The mapping between symbol names and symbols. */
4693ec713c28Smrg"
46941d54945dSmrg
4695ec713c28Smrg	    case $host in
4696ec713c28Smrg	    *cygwin* | *mingw* )
4697ec713c28Smrg	  $echo >> "$output_objdir/$dlsyms" "\
4698ec713c28Smrg/* DATA imports from DLLs on WIN32 can't be const, because
4699ec713c28Smrg   runtime relocations are performed -- see ld's documentation
4700ec713c28Smrg   on pseudo-relocs */
4701ec713c28Smrgstruct {
4702ec713c28Smrg"
4703ec713c28Smrg	      ;;
4704ec713c28Smrg	    * )
4705ec713c28Smrg	  $echo >> "$output_objdir/$dlsyms" "\
4706ec713c28Smrgconst struct {
4707ec713c28Smrg"
4708ec713c28Smrg	      ;;
4709ec713c28Smrg	    esac
47101d54945dSmrg
47111d54945dSmrg
4712ec713c28Smrg	  $echo >> "$output_objdir/$dlsyms" "\
4713ec713c28Smrg  const char *name;
4714ec713c28Smrg  lt_ptr address;
4715ec713c28Smrg}
4716ec713c28Smrglt_preloaded_symbols[] =
4717ec713c28Smrg{\
4718ec713c28Smrg"
47191d54945dSmrg
4720ec713c28Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
47211d54945dSmrg
4722ec713c28Smrg	    $echo >> "$output_objdir/$dlsyms" "\
4723ec713c28Smrg  {0, (lt_ptr) 0}
4724ec713c28Smrg};
47251d54945dSmrg
4726ec713c28Smrg/* This works around a problem in FreeBSD linker */
4727ec713c28Smrg#ifdef FREEBSD_WORKAROUND
4728ec713c28Smrgstatic const void *lt_preloaded_setup() {
4729ec713c28Smrg  return lt_preloaded_symbols;
4730ec713c28Smrg}
4731ec713c28Smrg#endif
47321d54945dSmrg
4733ec713c28Smrg#ifdef __cplusplus
4734ec713c28Smrg}
4735ec713c28Smrg#endif\
4736ec713c28Smrg"
4737786a6f21Smrg	  fi
47381d54945dSmrg
4739ec713c28Smrg	  pic_flag_for_symtable=
4740ec713c28Smrg	  case $host in
4741ec713c28Smrg	  # compiling the symbol table file with pic_flag works around
4742ec713c28Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
4743ec713c28Smrg	  # linked before any other PIC object.  But we must not use
4744ec713c28Smrg	  # pic_flag when linking with -static.  The problem exists in
4745ec713c28Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
4746ec713c28Smrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
4747ec713c28Smrg	    case "$compile_command " in
4748ec713c28Smrg	    *" -static "*) ;;
4749ec713c28Smrg	    *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";;
4750ec713c28Smrg	    esac;;
4751ec713c28Smrg	  *-*-hpux*)
4752ec713c28Smrg	    case "$compile_command " in
4753ec713c28Smrg	    *" -static "*) ;;
4754ec713c28Smrg	    *) pic_flag_for_symtable=" $pic_flag";;
4755ec713c28Smrg	    esac
4756ec713c28Smrg	  esac
4757786a6f21Smrg
4758ec713c28Smrg	  # Now compile the dynamic symbol file.
4759ec713c28Smrg	  $show "(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
4760ec713c28Smrg	  $run eval '(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
47611d54945dSmrg
4762ec713c28Smrg	  # Clean up the generated files.
4763ec713c28Smrg	  $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
4764ec713c28Smrg	  $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
47651d54945dSmrg
4766ec713c28Smrg	  # Transform the symbol file into the correct name.
4767ec713c28Smrg          case $host in
4768ec713c28Smrg          *cygwin* | *mingw* )
4769ec713c28Smrg            if test -f "$output_objdir/${outputname}.def" ; then
4770ec713c28Smrg              compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP`
4771ec713c28Smrg              finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP`
4772ec713c28Smrg            else
4773ec713c28Smrg              compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
4774ec713c28Smrg              finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
4775ec713c28Smrg             fi
4776ec713c28Smrg            ;;
4777ec713c28Smrg          * )
4778ec713c28Smrg            compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
4779ec713c28Smrg            finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
4780ec713c28Smrg            ;;
4781ec713c28Smrg          esac
4782ec713c28Smrg	  ;;
4783ec713c28Smrg	*)
4784ec713c28Smrg	  $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
4785ec713c28Smrg	  exit $EXIT_FAILURE
4786ec713c28Smrg	  ;;
4787ec713c28Smrg	esac
4788ec713c28Smrg      else
4789ec713c28Smrg	# We keep going just in case the user didn't refer to
4790ec713c28Smrg	# lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
4791ec713c28Smrg	# really was required.
47921d54945dSmrg
4793ec713c28Smrg	# Nullify the symbol file.
4794ec713c28Smrg	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP`
4795ec713c28Smrg	finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP`
4796ec713c28Smrg      fi
47971d54945dSmrg
4798ec713c28Smrg      if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
4799ec713c28Smrg	# Replace the output file specification.
4800ec713c28Smrg	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$output"'%g' | $NL2SP`
4801ec713c28Smrg	link_command="$compile_command$compile_rpath"
48021d54945dSmrg
4803ec713c28Smrg	# We have no uninstalled library dependencies, so finalize right now.
4804ec713c28Smrg	$show "$link_command"
4805ec713c28Smrg	$run eval "$link_command"
4806ec713c28Smrg	exit_status=$?
48071d54945dSmrg
4808ec713c28Smrg	# Delete the generated files.
4809ec713c28Smrg	if test -n "$dlsyms"; then
4810ec713c28Smrg	  $show "$rm $output_objdir/${outputname}S.${objext}"
4811ec713c28Smrg	  $run $rm "$output_objdir/${outputname}S.${objext}"
4812786a6f21Smrg	fi
48131d54945dSmrg
4814ec713c28Smrg	exit $exit_status
4815ec713c28Smrg      fi
48161d54945dSmrg
4817ec713c28Smrg      if test -n "$shlibpath_var"; then
4818ec713c28Smrg	# We should set the shlibpath_var
4819ec713c28Smrg	rpath=
4820ec713c28Smrg	for dir in $temp_rpath; do
4821ec713c28Smrg	  case $dir in
4822ec713c28Smrg	  [\\/]* | [A-Za-z]:[\\/]*)
4823ec713c28Smrg	    # Absolute path.
4824ec713c28Smrg	    rpath="$rpath$dir:"
4825ec713c28Smrg	    ;;
4826ec713c28Smrg	  *)
4827ec713c28Smrg	    # Relative path: add a thisdir entry.
4828ec713c28Smrg	    rpath="$rpath\$thisdir/$dir:"
4829ec713c28Smrg	    ;;
4830ec713c28Smrg	  esac
4831ec713c28Smrg	done
4832ec713c28Smrg	temp_rpath="$rpath"
4833786a6f21Smrg      fi
48341d54945dSmrg
4835ec713c28Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
4836ec713c28Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
4837ec713c28Smrg      fi
4838ec713c28Smrg      if test -n "$finalize_shlibpath"; then
4839ec713c28Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
4840ec713c28Smrg      fi
4841786a6f21Smrg
4842ec713c28Smrg      compile_var=
4843ec713c28Smrg      finalize_var=
4844ec713c28Smrg      if test -n "$runpath_var"; then
4845ec713c28Smrg	if test -n "$perm_rpath"; then
4846ec713c28Smrg	  # We should set the runpath_var.
4847ec713c28Smrg	  rpath=
4848ec713c28Smrg	  for dir in $perm_rpath; do
4849ec713c28Smrg	    rpath="$rpath$dir:"
4850ec713c28Smrg	  done
4851ec713c28Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
4852ec713c28Smrg	fi
4853ec713c28Smrg	if test -n "$finalize_perm_rpath"; then
4854ec713c28Smrg	  # We should set the runpath_var.
4855ec713c28Smrg	  rpath=
4856ec713c28Smrg	  for dir in $finalize_perm_rpath; do
4857ec713c28Smrg	    rpath="$rpath$dir:"
4858ec713c28Smrg	  done
4859ec713c28Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
4860ec713c28Smrg	fi
4861ec713c28Smrg      fi
4862786a6f21Smrg
4863ec713c28Smrg      if test "$no_install" = yes; then
4864ec713c28Smrg	# We don't need to create a wrapper script.
4865ec713c28Smrg	link_command="$compile_var$compile_command$compile_rpath"
4866ec713c28Smrg	# Replace the output file specification.
4867ec713c28Smrg	link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
4868ec713c28Smrg	# Delete the old output file.
4869ec713c28Smrg	$run $rm $output
4870ec713c28Smrg	# Link the executable and exit
4871ec713c28Smrg	$show "$link_command"
4872ec713c28Smrg	$run eval "$link_command" || exit $?
4873ec713c28Smrg	exit $EXIT_SUCCESS
4874ec713c28Smrg      fi
4875786a6f21Smrg
4876ec713c28Smrg      if test "$hardcode_action" = relink; then
4877ec713c28Smrg	# Fast installation is not supported
4878ec713c28Smrg	link_command="$compile_var$compile_command$compile_rpath"
4879ec713c28Smrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
4880786a6f21Smrg
4881ec713c28Smrg	$echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
4882ec713c28Smrg	$echo "$modename: \`$output' will be relinked during installation" 1>&2
4883ec713c28Smrg      else
4884ec713c28Smrg	if test "$fast_install" != no; then
4885ec713c28Smrg	  link_command="$finalize_var$compile_command$finalize_rpath"
4886ec713c28Smrg	  if test "$fast_install" = yes; then
4887ec713c28Smrg	    relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $SP2NL | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g' | $NL2SP`
4888ec713c28Smrg	  else
4889ec713c28Smrg	    # fast_install is set to needless
4890ec713c28Smrg	    relink_command=
4891ec713c28Smrg	  fi
4892ec713c28Smrg	else
4893ec713c28Smrg	  link_command="$compile_var$compile_command$compile_rpath"
4894ec713c28Smrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
4895ec713c28Smrg	fi
4896786a6f21Smrg      fi
4897786a6f21Smrg
4898ec713c28Smrg      # Replace the output file specification.
4899ec713c28Smrg      link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
4900786a6f21Smrg
4901ec713c28Smrg      # Delete the old output files.
4902ec713c28Smrg      $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
4903786a6f21Smrg
4904ec713c28Smrg      $show "$link_command"
4905ec713c28Smrg      $run eval "$link_command" || exit $?
4906786a6f21Smrg
4907ec713c28Smrg      # Now create the wrapper script.
4908ec713c28Smrg      $show "creating $output"
4909786a6f21Smrg
4910ec713c28Smrg      # Quote the relink command for shipping.
4911ec713c28Smrg      if test -n "$relink_command"; then
4912ec713c28Smrg	# Preserve any variables that may affect compiler behavior
4913ec713c28Smrg	for var in $variables_saved_for_relink; do
4914ec713c28Smrg	  if eval test -z \"\${$var+set}\"; then
4915ec713c28Smrg	    relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
4916ec713c28Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
4917ec713c28Smrg	    relink_command="$var=; export $var; $relink_command"
4918ec713c28Smrg	  else
4919ec713c28Smrg	    var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
4920ec713c28Smrg	    relink_command="$var=\"$var_value\"; export $var; $relink_command"
4921ec713c28Smrg	  fi
4922786a6f21Smrg	done
4923ec713c28Smrg	relink_command="(cd `pwd`; $relink_command)"
4924ec713c28Smrg	relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e "$sed_quote_subst" | $NL2SP`
4925786a6f21Smrg      fi
4926786a6f21Smrg
4927ec713c28Smrg      # Quote $echo for shipping.
4928ec713c28Smrg      if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then
4929ec713c28Smrg	case $progpath in
4930ec713c28Smrg	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
4931ec713c28Smrg	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
4932786a6f21Smrg	esac
4933ec713c28Smrg	qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
4934ec713c28Smrg      else
4935ec713c28Smrg	qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
4936786a6f21Smrg      fi
4937786a6f21Smrg
4938ec713c28Smrg      # Only actually do things if our run command is non-null.
4939ec713c28Smrg      if test -z "$run"; then
4940ec713c28Smrg	# win32 will think the script is a binary if it has
4941ec713c28Smrg	# a .exe suffix, so we strip it off here.
4942ec713c28Smrg	case $output in
4943ec713c28Smrg	  *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;;
4944ec713c28Smrg	esac
4945ec713c28Smrg	# test for cygwin because mv fails w/o .exe extensions
4946ec713c28Smrg	case $host in
4947ec713c28Smrg	  *cygwin*)
4948ec713c28Smrg	    exeext=.exe
4949ec713c28Smrg	    outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;;
4950ec713c28Smrg	  *) exeext= ;;
4951ec713c28Smrg	esac
4952ec713c28Smrg	case $host in
4953ec713c28Smrg	  *cygwin* | *mingw* )
4954ec713c28Smrg            output_name=`basename $output`
4955ec713c28Smrg            output_path=`dirname $output`
4956ec713c28Smrg            cwrappersource="$output_path/$objdir/lt-$output_name.c"
4957ec713c28Smrg            cwrapper="$output_path/$output_name.exe"
4958ec713c28Smrg            $rm $cwrappersource $cwrapper
4959ec713c28Smrg            trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
4960786a6f21Smrg
4961ec713c28Smrg	    cat > $cwrappersource <<EOF
4962786a6f21Smrg
4963ec713c28Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
4964ec713c28Smrg   Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
4965786a6f21Smrg
4966ec713c28Smrg   The $output program cannot be directly executed until all the libtool
4967ec713c28Smrg   libraries that it depends on are installed.
4968786a6f21Smrg
4969ec713c28Smrg   This wrapper executable should never be moved out of the build directory.
4970ec713c28Smrg   If it is, it will not operate correctly.
4971786a6f21Smrg
4972ec713c28Smrg   Currently, it simply execs the wrapper *script* "/bin/sh $output",
4973ec713c28Smrg   but could eventually absorb all of the scripts functionality and
4974ec713c28Smrg   exec $objdir/$outputname directly.
4975ec713c28Smrg*/
4976ec713c28SmrgEOF
4977ec713c28Smrg	    cat >> $cwrappersource<<"EOF"
4978ec713c28Smrg#include <stdio.h>
4979ec713c28Smrg#include <stdlib.h>
4980ec713c28Smrg#include <unistd.h>
4981ec713c28Smrg#include <malloc.h>
4982ec713c28Smrg#include <stdarg.h>
4983ec713c28Smrg#include <assert.h>
4984ec713c28Smrg#include <string.h>
4985ec713c28Smrg#include <ctype.h>
4986ec713c28Smrg#include <sys/stat.h>
4987786a6f21Smrg
4988ec713c28Smrg#if defined(PATH_MAX)
4989ec713c28Smrg# define LT_PATHMAX PATH_MAX
4990ec713c28Smrg#elif defined(MAXPATHLEN)
4991ec713c28Smrg# define LT_PATHMAX MAXPATHLEN
4992ec713c28Smrg#else
4993ec713c28Smrg# define LT_PATHMAX 1024
4994ec713c28Smrg#endif
4995786a6f21Smrg
4996ec713c28Smrg#ifndef DIR_SEPARATOR
4997ec713c28Smrg# define DIR_SEPARATOR '/'
4998ec713c28Smrg# define PATH_SEPARATOR ':'
4999ec713c28Smrg#endif
5000786a6f21Smrg
5001ec713c28Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
5002ec713c28Smrg  defined (__OS2__)
5003ec713c28Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
5004ec713c28Smrg# ifndef DIR_SEPARATOR_2
5005ec713c28Smrg#  define DIR_SEPARATOR_2 '\\'
5006ec713c28Smrg# endif
5007ec713c28Smrg# ifndef PATH_SEPARATOR_2
5008ec713c28Smrg#  define PATH_SEPARATOR_2 ';'
5009ec713c28Smrg# endif
5010ec713c28Smrg#endif
5011786a6f21Smrg
5012ec713c28Smrg#ifndef DIR_SEPARATOR_2
5013ec713c28Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
5014ec713c28Smrg#else /* DIR_SEPARATOR_2 */
5015ec713c28Smrg# define IS_DIR_SEPARATOR(ch) \
5016ec713c28Smrg        (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
5017ec713c28Smrg#endif /* DIR_SEPARATOR_2 */
5018786a6f21Smrg
5019ec713c28Smrg#ifndef PATH_SEPARATOR_2
5020ec713c28Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
5021ec713c28Smrg#else /* PATH_SEPARATOR_2 */
5022ec713c28Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
5023ec713c28Smrg#endif /* PATH_SEPARATOR_2 */
5024786a6f21Smrg
5025ec713c28Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
5026ec713c28Smrg#define XFREE(stale) do { \
5027ec713c28Smrg  if (stale) { free ((void *) stale); stale = 0; } \
5028ec713c28Smrg} while (0)
5029786a6f21Smrg
5030ec713c28Smrg/* -DDEBUG is fairly common in CFLAGS.  */
5031ec713c28Smrg#undef DEBUG
5032ec713c28Smrg#if defined DEBUGWRAPPER
5033ec713c28Smrg# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
5034ec713c28Smrg#else
5035ec713c28Smrg# define DEBUG(format, ...)
5036ec713c28Smrg#endif
5037786a6f21Smrg
5038ec713c28Smrgconst char *program_name = NULL;
5039786a6f21Smrg
5040ec713c28Smrgvoid * xmalloc (size_t num);
5041ec713c28Smrgchar * xstrdup (const char *string);
5042ec713c28Smrgconst char * base_name (const char *name);
5043ec713c28Smrgchar * find_executable(const char *wrapper);
5044ec713c28Smrgint    check_executable(const char *path);
5045ec713c28Smrgchar * strendzap(char *str, const char *pat);
5046ec713c28Smrgvoid lt_fatal (const char *message, ...);
5047786a6f21Smrg
5048ec713c28Smrgint
5049ec713c28Smrgmain (int argc, char *argv[])
5050ec713c28Smrg{
5051ec713c28Smrg  char **newargz;
5052ec713c28Smrg  int i;
5053786a6f21Smrg
5054ec713c28Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
5055ec713c28Smrg  DEBUG("(main) argv[0]      : %s\n",argv[0]);
5056ec713c28Smrg  DEBUG("(main) program_name : %s\n",program_name);
5057ec713c28Smrg  newargz = XMALLOC(char *, argc+2);
5058ec713c28SmrgEOF
5059786a6f21Smrg
5060ec713c28Smrg            cat >> $cwrappersource <<EOF
5061ec713c28Smrg  newargz[0] = (char *) xstrdup("$SHELL");
5062ec713c28SmrgEOF
5063786a6f21Smrg
5064ec713c28Smrg            cat >> $cwrappersource <<"EOF"
5065ec713c28Smrg  newargz[1] = find_executable(argv[0]);
5066ec713c28Smrg  if (newargz[1] == NULL)
5067ec713c28Smrg    lt_fatal("Couldn't find %s", argv[0]);
5068ec713c28Smrg  DEBUG("(main) found exe at : %s\n",newargz[1]);
5069ec713c28Smrg  /* we know the script has the same name, without the .exe */
5070ec713c28Smrg  /* so make sure newargz[1] doesn't end in .exe */
5071ec713c28Smrg  strendzap(newargz[1],".exe");
5072ec713c28Smrg  for (i = 1; i < argc; i++)
5073ec713c28Smrg    newargz[i+1] = xstrdup(argv[i]);
5074ec713c28Smrg  newargz[argc+1] = NULL;
5075786a6f21Smrg
5076ec713c28Smrg  for (i=0; i<argc+1; i++)
5077ec713c28Smrg  {
5078ec713c28Smrg    DEBUG("(main) newargz[%d]   : %s\n",i,newargz[i]);
5079ec713c28Smrg    ;
5080ec713c28Smrg  }
5081786a6f21Smrg
5082ec713c28SmrgEOF
5083786a6f21Smrg
5084ec713c28Smrg            case $host_os in
5085ec713c28Smrg              mingw*)
5086ec713c28Smrg                cat >> $cwrappersource <<EOF
5087ec713c28Smrg  execv("$SHELL",(char const **)newargz);
5088ec713c28SmrgEOF
5089ec713c28Smrg              ;;
5090ec713c28Smrg              *)
5091ec713c28Smrg                cat >> $cwrappersource <<EOF
5092ec713c28Smrg  execv("$SHELL",newargz);
5093ec713c28SmrgEOF
5094ec713c28Smrg              ;;
5095ec713c28Smrg            esac
5096786a6f21Smrg
5097ec713c28Smrg            cat >> $cwrappersource <<"EOF"
5098ec713c28Smrg  return 127;
5099ec713c28Smrg}
5100786a6f21Smrg
5101ec713c28Smrgvoid *
5102ec713c28Smrgxmalloc (size_t num)
5103ec713c28Smrg{
5104ec713c28Smrg  void * p = (void *) malloc (num);
5105ec713c28Smrg  if (!p)
5106ec713c28Smrg    lt_fatal ("Memory exhausted");
5107786a6f21Smrg
5108ec713c28Smrg  return p;
5109ec713c28Smrg}
5110786a6f21Smrg
5111ec713c28Smrgchar *
5112ec713c28Smrgxstrdup (const char *string)
5113ec713c28Smrg{
5114ec713c28Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL
5115ec713c28Smrg;
5116ec713c28Smrg}
5117786a6f21Smrg
5118ec713c28Smrgconst char *
5119ec713c28Smrgbase_name (const char *name)
5120ec713c28Smrg{
5121ec713c28Smrg  const char *base;
5122786a6f21Smrg
5123ec713c28Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5124ec713c28Smrg  /* Skip over the disk name in MSDOS pathnames. */
5125ec713c28Smrg  if (isalpha ((unsigned char)name[0]) && name[1] == ':')
5126ec713c28Smrg    name += 2;
5127ec713c28Smrg#endif
5128786a6f21Smrg
5129ec713c28Smrg  for (base = name; *name; name++)
5130ec713c28Smrg    if (IS_DIR_SEPARATOR (*name))
5131ec713c28Smrg      base = name + 1;
5132ec713c28Smrg  return base;
5133ec713c28Smrg}
5134786a6f21Smrg
5135ec713c28Smrgint
5136ec713c28Smrgcheck_executable(const char * path)
5137ec713c28Smrg{
5138ec713c28Smrg  struct stat st;
5139786a6f21Smrg
5140ec713c28Smrg  DEBUG("(check_executable)  : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
5141ec713c28Smrg  if ((!path) || (!*path))
5142ec713c28Smrg    return 0;
5143786a6f21Smrg
5144ec713c28Smrg  if ((stat (path, &st) >= 0) &&
5145ec713c28Smrg      (
5146ec713c28Smrg        /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
5147ec713c28Smrg#if defined (S_IXOTH)
5148ec713c28Smrg       ((st.st_mode & S_IXOTH) == S_IXOTH) ||
5149ec713c28Smrg#endif
5150ec713c28Smrg#if defined (S_IXGRP)
5151ec713c28Smrg       ((st.st_mode & S_IXGRP) == S_IXGRP) ||
5152ec713c28Smrg#endif
5153ec713c28Smrg       ((st.st_mode & S_IXUSR) == S_IXUSR))
5154ec713c28Smrg      )
5155ec713c28Smrg    return 1;
5156ec713c28Smrg  else
5157ec713c28Smrg    return 0;
5158ec713c28Smrg}
51591d54945dSmrg
5160ec713c28Smrg/* Searches for the full path of the wrapper.  Returns
5161ec713c28Smrg   newly allocated full path name if found, NULL otherwise */
5162ec713c28Smrgchar *
5163ec713c28Smrgfind_executable (const char* wrapper)
5164ec713c28Smrg{
5165ec713c28Smrg  int has_slash = 0;
5166ec713c28Smrg  const char* p;
5167ec713c28Smrg  const char* p_next;
5168ec713c28Smrg  /* static buffer for getcwd */
5169ec713c28Smrg  char tmp[LT_PATHMAX + 1];
5170ec713c28Smrg  int tmp_len;
5171ec713c28Smrg  char* concat_name;
51721d54945dSmrg
5173ec713c28Smrg  DEBUG("(find_executable)  : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
51741d54945dSmrg
5175ec713c28Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
5176ec713c28Smrg    return NULL;
51771d54945dSmrg
5178ec713c28Smrg  /* Absolute path? */
5179ec713c28Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5180ec713c28Smrg  if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
5181ec713c28Smrg  {
5182ec713c28Smrg    concat_name = xstrdup (wrapper);
5183ec713c28Smrg    if (check_executable(concat_name))
5184ec713c28Smrg      return concat_name;
5185ec713c28Smrg    XFREE(concat_name);
5186ec713c28Smrg  }
5187ec713c28Smrg  else
5188ec713c28Smrg  {
5189ec713c28Smrg#endif
5190ec713c28Smrg    if (IS_DIR_SEPARATOR (wrapper[0]))
5191ec713c28Smrg    {
5192ec713c28Smrg      concat_name = xstrdup (wrapper);
5193ec713c28Smrg      if (check_executable(concat_name))
5194ec713c28Smrg        return concat_name;
5195ec713c28Smrg      XFREE(concat_name);
5196ec713c28Smrg    }
5197ec713c28Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5198ec713c28Smrg  }
5199ec713c28Smrg#endif
5200ec713c28Smrg
5201ec713c28Smrg  for (p = wrapper; *p; p++)
5202ec713c28Smrg    if (*p == '/')
5203ec713c28Smrg    {
5204ec713c28Smrg      has_slash = 1;
5205ec713c28Smrg      break;
5206ec713c28Smrg    }
5207ec713c28Smrg  if (!has_slash)
5208ec713c28Smrg  {
5209ec713c28Smrg    /* no slashes; search PATH */
5210ec713c28Smrg    const char* path = getenv ("PATH");
5211ec713c28Smrg    if (path != NULL)
5212ec713c28Smrg    {
5213ec713c28Smrg      for (p = path; *p; p = p_next)
5214ec713c28Smrg      {
5215ec713c28Smrg        const char* q;
5216ec713c28Smrg        size_t p_len;
5217ec713c28Smrg        for (q = p; *q; q++)
5218ec713c28Smrg          if (IS_PATH_SEPARATOR(*q))
5219ec713c28Smrg            break;
5220ec713c28Smrg        p_len = q - p;
5221ec713c28Smrg        p_next = (*q == '\0' ? q : q + 1);
5222ec713c28Smrg        if (p_len == 0)
5223ec713c28Smrg        {
5224ec713c28Smrg          /* empty path: current directory */
5225ec713c28Smrg          if (getcwd (tmp, LT_PATHMAX) == NULL)
5226ec713c28Smrg            lt_fatal ("getcwd failed");
5227ec713c28Smrg          tmp_len = strlen(tmp);
5228ec713c28Smrg          concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
5229ec713c28Smrg          memcpy (concat_name, tmp, tmp_len);
5230ec713c28Smrg          concat_name[tmp_len] = '/';
5231ec713c28Smrg          strcpy (concat_name + tmp_len + 1, wrapper);
5232ec713c28Smrg        }
5233ec713c28Smrg        else
5234ec713c28Smrg        {
5235ec713c28Smrg          concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
5236ec713c28Smrg          memcpy (concat_name, p, p_len);
5237ec713c28Smrg          concat_name[p_len] = '/';
5238ec713c28Smrg          strcpy (concat_name + p_len + 1, wrapper);
5239ec713c28Smrg        }
5240ec713c28Smrg        if (check_executable(concat_name))
5241ec713c28Smrg          return concat_name;
5242ec713c28Smrg        XFREE(concat_name);
5243ec713c28Smrg      }
5244ec713c28Smrg    }
5245ec713c28Smrg    /* not found in PATH; assume curdir */
5246ec713c28Smrg  }
5247ec713c28Smrg  /* Relative path | not found in path: prepend cwd */
5248ec713c28Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
5249ec713c28Smrg    lt_fatal ("getcwd failed");
5250ec713c28Smrg  tmp_len = strlen(tmp);
5251ec713c28Smrg  concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
5252ec713c28Smrg  memcpy (concat_name, tmp, tmp_len);
5253ec713c28Smrg  concat_name[tmp_len] = '/';
5254ec713c28Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
5255ec713c28Smrg
5256ec713c28Smrg  if (check_executable(concat_name))
5257ec713c28Smrg    return concat_name;
5258ec713c28Smrg  XFREE(concat_name);
5259ec713c28Smrg  return NULL;
5260ec713c28Smrg}
5261ec713c28Smrg
5262ec713c28Smrgchar *
5263ec713c28Smrgstrendzap(char *str, const char *pat)
5264ec713c28Smrg{
5265ec713c28Smrg  size_t len, patlen;
5266ec713c28Smrg
5267ec713c28Smrg  assert(str != NULL);
5268ec713c28Smrg  assert(pat != NULL);
5269ec713c28Smrg
5270ec713c28Smrg  len = strlen(str);
5271ec713c28Smrg  patlen = strlen(pat);
5272ec713c28Smrg
5273ec713c28Smrg  if (patlen <= len)
5274ec713c28Smrg  {
5275ec713c28Smrg    str += len - patlen;
5276ec713c28Smrg    if (strcmp(str, pat) == 0)
5277ec713c28Smrg      *str = '\0';
5278ec713c28Smrg  }
5279ec713c28Smrg  return str;
5280ec713c28Smrg}
5281ec713c28Smrg
5282ec713c28Smrgstatic void
5283ec713c28Smrglt_error_core (int exit_status, const char * mode,
5284ec713c28Smrg          const char * message, va_list ap)
5285ec713c28Smrg{
5286ec713c28Smrg  fprintf (stderr, "%s: %s: ", program_name, mode);
5287ec713c28Smrg  vfprintf (stderr, message, ap);
5288ec713c28Smrg  fprintf (stderr, ".\n");
5289ec713c28Smrg
5290ec713c28Smrg  if (exit_status >= 0)
5291ec713c28Smrg    exit (exit_status);
5292ec713c28Smrg}
5293ec713c28Smrg
5294ec713c28Smrgvoid
5295ec713c28Smrglt_fatal (const char *message, ...)
5296ec713c28Smrg{
5297ec713c28Smrg  va_list ap;
5298ec713c28Smrg  va_start (ap, message);
5299ec713c28Smrg  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
5300ec713c28Smrg  va_end (ap);
5301ec713c28Smrg}
5302ec713c28SmrgEOF
5303ec713c28Smrg          # we should really use a build-platform specific compiler
5304ec713c28Smrg          # here, but OTOH, the wrappers (shell script and this C one)
5305ec713c28Smrg          # are only useful if you want to execute the "real" binary.
5306ec713c28Smrg          # Since the "real" binary is built for $host, then this
5307ec713c28Smrg          # wrapper might as well be built for $host, too.
5308ec713c28Smrg          $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
5309ec713c28Smrg          ;;
5310ec713c28Smrg        esac
5311ec713c28Smrg        $rm $output
5312ec713c28Smrg        trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
5313ec713c28Smrg
5314ec713c28Smrg	$echo > $output "\
5315ec713c28Smrg#! $SHELL
5316ec713c28Smrg
5317ec713c28Smrg# $output - temporary wrapper script for $objdir/$outputname
5318ec713c28Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
5319ec713c28Smrg#
5320ec713c28Smrg# The $output program cannot be directly executed until all the libtool
5321ec713c28Smrg# libraries that it depends on are installed.
5322ec713c28Smrg#
5323ec713c28Smrg# This wrapper script should never be moved out of the build directory.
5324ec713c28Smrg# If it is, it will not operate correctly.
5325ec713c28Smrg
5326ec713c28Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
5327ec713c28Smrg# metacharacters that are still active within double-quoted strings.
5328ec713c28SmrgXsed='${SED} -e 1s/^X//'
5329ec713c28Smrgsed_quote_subst='$sed_quote_subst'
5330ec713c28Smrg
5331ec713c28Smrg# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE).
5332ec713c28Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
5333ec713c28Smrg  emulate sh
5334ec713c28Smrg  NULLCMD=:
5335ec713c28Smrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
5336ec713c28Smrg  # is contrary to our usage.  Disable this feature.
5337ec713c28Smrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
5338ec713c28Smrg  setopt NO_GLOB_SUBST
5339ec713c28Smrgelse
5340ec713c28Smrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
5341ec713c28Smrgfi
5342ec713c28SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
5343ec713c28SmrgDUALCASE=1; export DUALCASE # for MKS sh
5344ec713c28Smrg
5345ec713c28Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
5346ec713c28Smrg# if CDPATH is set.
5347ec713c28Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
5348ec713c28Smrg
5349ec713c28Smrgrelink_command=\"$relink_command\"
5350ec713c28Smrg
5351ec713c28Smrg# This environment variable determines our operation mode.
5352ec713c28Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
5353ec713c28Smrg  # install mode needs the following variable:
5354ec713c28Smrg  notinst_deplibs='$notinst_deplibs'
5355ec713c28Smrgelse
5356ec713c28Smrg  # When we are sourced in execute mode, \$file and \$echo are already set.
5357ec713c28Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
5358ec713c28Smrg    echo=\"$qecho\"
5359ec713c28Smrg    file=\"\$0\"
5360ec713c28Smrg    # Make sure echo works.
5361ec713c28Smrg    if test \"X\$1\" = X--no-reexec; then
5362ec713c28Smrg      # Discard the --no-reexec flag, and continue.
5363ec713c28Smrg      shift
5364ec713c28Smrg    elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
5365ec713c28Smrg      # Yippee, \$echo works!
5366ec713c28Smrg      :
5367ec713c28Smrg    else
5368ec713c28Smrg      # Restart under the correct shell, and then maybe \$echo will work.
5369ec713c28Smrg      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
5370ec713c28Smrg    fi
5371ec713c28Smrg  fi\
5372ec713c28Smrg"
5373ec713c28Smrg	$echo >> $output "\
53741d54945dSmrg
5375ec713c28Smrg  # Find the directory that this script lives in.
5376ec713c28Smrg  thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
5377ec713c28Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
53781d54945dSmrg
5379ec713c28Smrg  # Follow symbolic links until we get to the real thisdir.
5380ec713c28Smrg  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
5381ec713c28Smrg  while test -n \"\$file\"; do
5382ec713c28Smrg    destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
53831d54945dSmrg
5384ec713c28Smrg    # If there was a directory component, then change thisdir.
5385ec713c28Smrg    if test \"x\$destdir\" != \"x\$file\"; then
5386ec713c28Smrg      case \"\$destdir\" in
5387ec713c28Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
5388ec713c28Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
5389ec713c28Smrg      esac
5390ec713c28Smrg    fi
5391786a6f21Smrg
5392ec713c28Smrg    file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
5393ec713c28Smrg    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
5394ec713c28Smrg  done
5395786a6f21Smrg
5396ec713c28Smrg  # Try to get the absolute directory name.
5397ec713c28Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
5398ec713c28Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
5399ec713c28Smrg"
54001d54945dSmrg
5401ec713c28Smrg	if test "$fast_install" = yes; then
5402ec713c28Smrg	  $echo >> $output "\
5403ec713c28Smrg  program=lt-'$outputname'$exeext
5404ec713c28Smrg  progdir=\"\$thisdir/$objdir\"
54051d54945dSmrg
5406ec713c28Smrg  if test ! -f \"\$progdir/\$program\" || \\
5407ec713c28Smrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
5408ec713c28Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
54091d54945dSmrg
5410ec713c28Smrg    file=\"\$\$-\$program\"
54111d54945dSmrg
5412ec713c28Smrg    if test ! -d \"\$progdir\"; then
5413ec713c28Smrg      $mkdir \"\$progdir\"
5414ec713c28Smrg    else
5415ec713c28Smrg      $rm \"\$progdir/\$file\"
5416ec713c28Smrg    fi"
54171d54945dSmrg
5418ec713c28Smrg	  $echo >> $output "\
5419786a6f21Smrg
5420ec713c28Smrg    # relink executable if necessary
5421ec713c28Smrg    if test -n \"\$relink_command\"; then
5422ec713c28Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
5423ec713c28Smrg      else
5424ec713c28Smrg	$echo \"\$relink_command_output\" >&2
5425ec713c28Smrg	$rm \"\$progdir/\$file\"
5426ec713c28Smrg	exit $EXIT_FAILURE
5427ec713c28Smrg      fi
5428ec713c28Smrg    fi
5429786a6f21Smrg
5430ec713c28Smrg    $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
5431ec713c28Smrg    { $rm \"\$progdir/\$program\";
5432ec713c28Smrg      $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
5433ec713c28Smrg    $rm \"\$progdir/\$file\"
5434ec713c28Smrg  fi"
5435ec713c28Smrg	else
5436ec713c28Smrg	  $echo >> $output "\
5437ec713c28Smrg  program='$outputname'
5438ec713c28Smrg  progdir=\"\$thisdir/$objdir\"
5439ec713c28Smrg"
54401d54945dSmrg	fi
54411d54945dSmrg
5442ec713c28Smrg	$echo >> $output "\
54431d54945dSmrg
5444ec713c28Smrg  if test -f \"\$progdir/\$program\"; then"
54451d54945dSmrg
5446ec713c28Smrg	# Export our shlibpath_var if we have one.
5447ec713c28Smrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5448ec713c28Smrg	  $echo >> $output "\
5449ec713c28Smrg    # Add our own library path to $shlibpath_var
5450ec713c28Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
54511d54945dSmrg
5452ec713c28Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
5453ec713c28Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
5454ec713c28Smrg    $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
54551d54945dSmrg
5456ec713c28Smrg    export $shlibpath_var
5457ec713c28Smrg"
5458ec713c28Smrg	fi
5459786a6f21Smrg
5460ec713c28Smrg	# fixup the dll searchpath if we need to.
5461ec713c28Smrg	if test -n "$dllsearchpath"; then
5462ec713c28Smrg	  $echo >> $output "\
5463ec713c28Smrg    # Add the dll search path components to the executable PATH
5464ec713c28Smrg    PATH=$dllsearchpath:\$PATH
5465ec713c28Smrg"
5466ec713c28Smrg	fi
5467786a6f21Smrg
5468ec713c28Smrg	$echo >> $output "\
5469ec713c28Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
5470ec713c28Smrg      # Run the actual program with our arguments.
5471ec713c28Smrg"
5472ec713c28Smrg	case $host in
5473ec713c28Smrg	# Backslashes separate directories on plain windows
5474ec713c28Smrg	*-*-mingw | *-*-os2*)
5475ec713c28Smrg	  $echo >> $output "\
5476ec713c28Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
5477ec713c28Smrg"
5478ec713c28Smrg	  ;;
5479786a6f21Smrg
5480ec713c28Smrg	*)
5481ec713c28Smrg	  $echo >> $output "\
5482ec713c28Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
5483ec713c28Smrg"
5484ec713c28Smrg	  ;;
5485ec713c28Smrg	esac
5486ec713c28Smrg	$echo >> $output "\
5487ec713c28Smrg      \$echo \"\$0: cannot exec \$program \$*\"
5488ec713c28Smrg      exit $EXIT_FAILURE
5489ec713c28Smrg    fi
5490ec713c28Smrg  else
5491ec713c28Smrg    # The program doesn't exist.
5492ec713c28Smrg    \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
5493ec713c28Smrg    \$echo \"This script is just a wrapper for \$program.\" 1>&2
5494ec713c28Smrg    $echo \"See the $PACKAGE documentation for more information.\" 1>&2
5495ec713c28Smrg    exit $EXIT_FAILURE
5496ec713c28Smrg  fi
5497ec713c28Smrgfi\
5498ec713c28Smrg"
5499ec713c28Smrg	chmod +x $output
5500ec713c28Smrg      fi
5501ec713c28Smrg      exit $EXIT_SUCCESS
5502ec713c28Smrg      ;;
5503ec713c28Smrg    esac
5504786a6f21Smrg
5505ec713c28Smrg    # See if we need to build an old-fashioned archive.
5506ec713c28Smrg    for oldlib in $oldlibs; do
5507786a6f21Smrg
5508ec713c28Smrg      if test "$build_libtool_libs" = convenience; then
5509ec713c28Smrg	oldobjs="$libobjs_save"
5510ec713c28Smrg	addlibs="$convenience"
5511ec713c28Smrg	build_libtool_libs=no
5512ec713c28Smrg      else
5513ec713c28Smrg	if test "$build_libtool_libs" = module; then
5514ec713c28Smrg	  oldobjs="$libobjs_save"
5515ec713c28Smrg	  build_libtool_libs=no
5516ec713c28Smrg	else
5517ec713c28Smrg	  oldobjs="$old_deplibs $non_pic_objects"
5518ec713c28Smrg	fi
5519ec713c28Smrg	addlibs="$old_convenience"
5520ec713c28Smrg      fi
5521786a6f21Smrg
5522ec713c28Smrg      if test -n "$addlibs"; then
5523ec713c28Smrg	gentop="$output_objdir/${outputname}x"
5524ec713c28Smrg	generated="$generated $gentop"
5525786a6f21Smrg
5526ec713c28Smrg	func_extract_archives $gentop $addlibs
5527ec713c28Smrg	oldobjs="$oldobjs $func_extract_archives_result"
5528ec713c28Smrg      fi
5529786a6f21Smrg
5530ec713c28Smrg      # Do each command in the archive commands.
5531ec713c28Smrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
5532ec713c28Smrg       cmds=$old_archive_from_new_cmds
5533ec713c28Smrg      else
5534ec713c28Smrg	# POSIX demands no paths to be encoded in archives.  We have
5535ec713c28Smrg	# to avoid creating archives with duplicate basenames if we
5536ec713c28Smrg	# might have to extract them afterwards, e.g., when creating a
5537ec713c28Smrg	# static archive out of a convenience library, or when linking
5538ec713c28Smrg	# the entirety of a libtool archive into another (currently
5539ec713c28Smrg	# not supported by libtool).
5540ec713c28Smrg	if (for obj in $oldobjs
5541ec713c28Smrg	    do
5542ec713c28Smrg	      $echo "X$obj" | $Xsed -e 's%^.*/%%'
5543ec713c28Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
5544ec713c28Smrg	  :
5545ec713c28Smrg	else
5546ec713c28Smrg	  $echo "copying selected object files to avoid basename conflicts..."
55471d54945dSmrg
5548ec713c28Smrg	  if test -z "$gentop"; then
5549ec713c28Smrg	    gentop="$output_objdir/${outputname}x"
5550ec713c28Smrg	    generated="$generated $gentop"
55511d54945dSmrg
5552ec713c28Smrg	    $show "${rm}r $gentop"
5553ec713c28Smrg	    $run ${rm}r "$gentop"
5554ec713c28Smrg	    $show "$mkdir $gentop"
5555ec713c28Smrg	    $run $mkdir "$gentop"
5556ec713c28Smrg	    exit_status=$?
5557ec713c28Smrg	    if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
5558ec713c28Smrg	      exit $exit_status
5559786a6f21Smrg	    fi
5560786a6f21Smrg	  fi
55611d54945dSmrg
5562ec713c28Smrg	  save_oldobjs=$oldobjs
5563ec713c28Smrg	  oldobjs=
5564ec713c28Smrg	  counter=1
5565ec713c28Smrg	  for obj in $save_oldobjs
5566ec713c28Smrg	  do
5567ec713c28Smrg	    objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
5568ec713c28Smrg	    case " $oldobjs " in
5569ec713c28Smrg	    " ") oldobjs=$obj ;;
5570ec713c28Smrg	    *[\ /]"$objbase "*)
5571ec713c28Smrg	      while :; do
5572ec713c28Smrg		# Make sure we don't pick an alternate name that also
5573ec713c28Smrg		# overlaps.
5574ec713c28Smrg		newobj=lt$counter-$objbase
5575ec713c28Smrg		counter=`expr $counter + 1`
5576ec713c28Smrg		case " $oldobjs " in
5577ec713c28Smrg		*[\ /]"$newobj "*) ;;
5578ec713c28Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
5579ec713c28Smrg		esac
5580ec713c28Smrg	      done
5581ec713c28Smrg	      $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
5582ec713c28Smrg	      $run ln "$obj" "$gentop/$newobj" ||
5583ec713c28Smrg	      $run cp "$obj" "$gentop/$newobj"
5584ec713c28Smrg	      oldobjs="$oldobjs $gentop/$newobj"
5585ec713c28Smrg	      ;;
5586ec713c28Smrg	    *) oldobjs="$oldobjs $obj" ;;
5587ec713c28Smrg	    esac
5588ec713c28Smrg	  done
5589ec713c28Smrg	fi
55901d54945dSmrg
5591ec713c28Smrg	eval cmds=\"$old_archive_cmds\"
55921d54945dSmrg
5593ec713c28Smrg	if len=`expr "X$cmds" : ".*"` &&
5594ec713c28Smrg	     test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
5595ec713c28Smrg	  cmds=$old_archive_cmds
5596ec713c28Smrg	else
5597ec713c28Smrg	  # the command line is too long to link in one step, link in parts
5598ec713c28Smrg	  $echo "using piecewise archive linking..."
5599ec713c28Smrg	  save_RANLIB=$RANLIB
5600ec713c28Smrg	  RANLIB=:
5601ec713c28Smrg	  objlist=
5602ec713c28Smrg	  concat_cmds=
5603ec713c28Smrg	  save_oldobjs=$oldobjs
5604ec713c28Smrg
5605ec713c28Smrg	  # Is there a better way of finding the last object in the list?
5606ec713c28Smrg	  for obj in $save_oldobjs
5607ec713c28Smrg	  do
5608ec713c28Smrg	    last_oldobj=$obj
5609ec713c28Smrg	  done
5610ec713c28Smrg	  for obj in $save_oldobjs
5611ec713c28Smrg	  do
5612ec713c28Smrg	    oldobjs="$objlist $obj"
5613ec713c28Smrg	    objlist="$objlist $obj"
5614ec713c28Smrg	    eval test_cmds=\"$old_archive_cmds\"
5615ec713c28Smrg	    if len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
5616ec713c28Smrg	       test "$len" -le "$max_cmd_len"; then
5617ec713c28Smrg	      :
5618786a6f21Smrg	    else
5619ec713c28Smrg	      # the above command should be used before it gets too long
5620ec713c28Smrg	      oldobjs=$objlist
5621ec713c28Smrg	      if test "$obj" = "$last_oldobj" ; then
5622ec713c28Smrg	        RANLIB=$save_RANLIB
5623ec713c28Smrg	      fi
5624ec713c28Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
5625ec713c28Smrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
5626ec713c28Smrg	      objlist=
5627786a6f21Smrg	    fi
5628ec713c28Smrg	  done
5629ec713c28Smrg	  RANLIB=$save_RANLIB
5630ec713c28Smrg	  oldobjs=$objlist
5631ec713c28Smrg	  if test "X$oldobjs" = "X" ; then
5632ec713c28Smrg	    eval cmds=\"\$concat_cmds\"
5633786a6f21Smrg	  else
5634ec713c28Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
5635786a6f21Smrg	  fi
5636786a6f21Smrg	fi
5637ec713c28Smrg      fi
5638ec713c28Smrg      save_ifs="$IFS"; IFS='~'
5639ec713c28Smrg      for cmd in $cmds; do
5640ec713c28Smrg        eval cmd=\"$cmd\"
5641786a6f21Smrg	IFS="$save_ifs"
5642ec713c28Smrg	$show "$cmd"
5643ec713c28Smrg	$run eval "$cmd" || exit $?
5644ec713c28Smrg      done
5645ec713c28Smrg      IFS="$save_ifs"
5646ec713c28Smrg    done
56471d54945dSmrg
5648ec713c28Smrg    if test -n "$generated"; then
5649ec713c28Smrg      $show "${rm}r$generated"
5650ec713c28Smrg      $run ${rm}r$generated
5651ec713c28Smrg    fi
56521d54945dSmrg
5653ec713c28Smrg    # Now create the libtool archive.
5654ec713c28Smrg    case $output in
5655ec713c28Smrg    *.la)
5656ec713c28Smrg      old_library=
5657ec713c28Smrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
5658ec713c28Smrg      $show "creating $output"
5659786a6f21Smrg
5660ec713c28Smrg      # Preserve any variables that may affect compiler behavior
5661ec713c28Smrg      for var in $variables_saved_for_relink; do
5662ec713c28Smrg	if eval test -z \"\${$var+set}\"; then
5663ec713c28Smrg	  relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
5664ec713c28Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
5665ec713c28Smrg	  relink_command="$var=; export $var; $relink_command"
5666ec713c28Smrg	else
5667ec713c28Smrg	  var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
5668ec713c28Smrg	  relink_command="$var=\"$var_value\"; export $var; $relink_command"
5669786a6f21Smrg	fi
5670ec713c28Smrg      done
5671ec713c28Smrg      # Quote the link command for shipping.
5672ec713c28Smrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
5673ec713c28Smrg      relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e "$sed_quote_subst" | $NL2SP`
5674ec713c28Smrg      if test "$hardcode_automatic" = yes ; then
5675ec713c28Smrg	relink_command=
5676786a6f21Smrg      fi
56771d54945dSmrg
56781d54945dSmrg
5679ec713c28Smrg      # Only create the output if not a dry run.
5680ec713c28Smrg      if test -z "$run"; then
5681ec713c28Smrg	for installed in no yes; do
5682ec713c28Smrg	  if test "$installed" = yes; then
5683ec713c28Smrg	    if test -z "$install_libdir"; then
5684ec713c28Smrg	      break
5685ec713c28Smrg	    fi
5686ec713c28Smrg	    output="$output_objdir/$outputname"i
5687ec713c28Smrg	    # Replace all uninstalled libtool libraries with the installed ones
5688ec713c28Smrg	    newdependency_libs=
5689ec713c28Smrg	    for deplib in $dependency_libs; do
5690ec713c28Smrg	      case $deplib in
5691ec713c28Smrg	      *.la)
5692ec713c28Smrg		name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
5693ec713c28Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
5694ec713c28Smrg		if test -z "$libdir"; then
5695ec713c28Smrg		  $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
5696ec713c28Smrg		  exit $EXIT_FAILURE
5697ec713c28Smrg		fi
5698ec713c28Smrg		newdependency_libs="$newdependency_libs $libdir/$name"
5699ec713c28Smrg		;;
5700ec713c28Smrg	      *) newdependency_libs="$newdependency_libs $deplib" ;;
5701ec713c28Smrg	      esac
5702ec713c28Smrg	    done
5703ec713c28Smrg	    dependency_libs="$newdependency_libs"
5704ec713c28Smrg	    newdlfiles=
5705ec713c28Smrg	    for lib in $dlfiles; do
5706ec713c28Smrg	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
5707ec713c28Smrg	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
5708ec713c28Smrg	      if test -z "$libdir"; then
5709ec713c28Smrg		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
5710ec713c28Smrg		exit $EXIT_FAILURE
5711ec713c28Smrg	      fi
5712ec713c28Smrg	      newdlfiles="$newdlfiles $libdir/$name"
5713ec713c28Smrg	    done
5714ec713c28Smrg	    dlfiles="$newdlfiles"
5715ec713c28Smrg	    newdlprefiles=
5716ec713c28Smrg	    for lib in $dlprefiles; do
5717ec713c28Smrg	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
5718ec713c28Smrg	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
5719ec713c28Smrg	      if test -z "$libdir"; then
5720ec713c28Smrg		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
5721ec713c28Smrg		exit $EXIT_FAILURE
5722ec713c28Smrg	      fi
5723ec713c28Smrg	      newdlprefiles="$newdlprefiles $libdir/$name"
5724ec713c28Smrg	    done
5725ec713c28Smrg	    dlprefiles="$newdlprefiles"
5726ec713c28Smrg	  else
5727ec713c28Smrg	    newdlfiles=
5728ec713c28Smrg	    for lib in $dlfiles; do
5729ec713c28Smrg	      case $lib in
5730ec713c28Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
5731ec713c28Smrg		*) abs=`pwd`"/$lib" ;;
5732ec713c28Smrg	      esac
5733ec713c28Smrg	      newdlfiles="$newdlfiles $abs"
5734ec713c28Smrg	    done
5735ec713c28Smrg	    dlfiles="$newdlfiles"
5736ec713c28Smrg	    newdlprefiles=
5737ec713c28Smrg	    for lib in $dlprefiles; do
5738ec713c28Smrg	      case $lib in
5739ec713c28Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
5740ec713c28Smrg		*) abs=`pwd`"/$lib" ;;
5741ec713c28Smrg	      esac
5742ec713c28Smrg	      newdlprefiles="$newdlprefiles $abs"
5743ec713c28Smrg	    done
5744ec713c28Smrg	    dlprefiles="$newdlprefiles"
5745ec713c28Smrg	  fi
5746ec713c28Smrg	  $rm $output
5747ec713c28Smrg	  # place dlname in correct position for cygwin
5748ec713c28Smrg	  tdlname=$dlname
5749ec713c28Smrg	  case $host,$output,$installed,$module,$dlname in
5750ec713c28Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
5751ec713c28Smrg	  esac
5752ec713c28Smrg	  $echo > $output "\
5753ec713c28Smrg# $outputname - a libtool library file
5754ec713c28Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
5755ec713c28Smrg#
5756ec713c28Smrg# Please DO NOT delete this file!
5757ec713c28Smrg# It is necessary for linking the library.
57581d54945dSmrg
5759ec713c28Smrg# The name that we can dlopen(3).
5760ec713c28Smrgdlname='$tdlname'
57611d54945dSmrg
5762ec713c28Smrg# Names of this library.
5763ec713c28Smrglibrary_names='$library_names'
57641d54945dSmrg
5765ec713c28Smrg# The name of the static archive.
5766ec713c28Smrgold_library='$old_library'
57671d54945dSmrg
5768ec713c28Smrg# Libraries that this one depends upon.
5769ec713c28Smrgdependency_libs='$dependency_libs'
5770786a6f21Smrg
5771ec713c28Smrg# Version information for $libname.
5772ec713c28Smrgcurrent=$current
5773ec713c28Smrgage=$age
5774ec713c28Smrgrevision=$revision
5775786a6f21Smrg
5776ec713c28Smrg# Is this an already installed library?
5777ec713c28Smrginstalled=$installed
5778786a6f21Smrg
5779ec713c28Smrg# Should we warn about portability when linking against -modules?
5780ec713c28Smrgshouldnotlink=$module
5781786a6f21Smrg
5782ec713c28Smrg# Files to dlopen/dlpreopen
5783ec713c28Smrgdlopen='$dlfiles'
5784ec713c28Smrgdlpreopen='$dlprefiles'
5785786a6f21Smrg
5786ec713c28Smrg# Directory that this library needs to be installed in:
5787ec713c28Smrglibdir='$install_libdir'"
5788ec713c28Smrg	  if test "$installed" = no && test "$need_relink" = yes; then
5789ec713c28Smrg	    $echo >> $output "\
5790ec713c28Smrgrelink_command=\"$relink_command\""
5791ec713c28Smrg	  fi
5792ec713c28Smrg	done
5793786a6f21Smrg      fi
5794786a6f21Smrg
5795ec713c28Smrg      # Do a symbolic link so that the libtool archive can be found in
5796ec713c28Smrg      # LD_LIBRARY_PATH before the program is installed.
5797ec713c28Smrg      $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
5798ec713c28Smrg      $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $?
57991d54945dSmrg      ;;
5800ec713c28Smrg    esac
5801ec713c28Smrg    exit $EXIT_SUCCESS
5802ec713c28Smrg    ;;
58031d54945dSmrg
5804ec713c28Smrg  # libtool install mode
5805ec713c28Smrg  install)
5806ec713c28Smrg    modename="$modename: install"
5807ec713c28Smrg
5808ec713c28Smrg    # There may be an optional sh(1) argument at the beginning of
5809ec713c28Smrg    # install_prog (especially on Windows NT).
5810ec713c28Smrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
5811ec713c28Smrg       # Allow the use of GNU shtool's install command.
5812ec713c28Smrg       $echo "X$nonopt" | grep shtool > /dev/null; then
5813ec713c28Smrg      # Aesthetically quote it.
5814ec713c28Smrg      arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
5815ec713c28Smrg      case $arg in
5816ec713c28Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
5817ec713c28Smrg	arg="\"$arg\""
5818ec713c28Smrg	;;
5819786a6f21Smrg      esac
5820ec713c28Smrg      install_prog="$arg "
5821ec713c28Smrg      arg="$1"
5822ec713c28Smrg      shift
5823ec713c28Smrg    else
5824ec713c28Smrg      install_prog=
5825ec713c28Smrg      arg=$nonopt
5826ec713c28Smrg    fi
58271d54945dSmrg
5828ec713c28Smrg    # The real first argument should be the name of the installation program.
5829ec713c28Smrg    # Aesthetically quote it.
5830ec713c28Smrg    arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
5831ec713c28Smrg    case $arg in
5832ec713c28Smrg    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
5833ec713c28Smrg      arg="\"$arg\""
5834ec713c28Smrg      ;;
5835ec713c28Smrg    esac
5836ec713c28Smrg    install_prog="$install_prog$arg"
58371d54945dSmrg
5838ec713c28Smrg    # We need to accept at least all the BSD install flags.
5839ec713c28Smrg    dest=
5840ec713c28Smrg    files=
5841ec713c28Smrg    opts=
5842ec713c28Smrg    prev=
5843ec713c28Smrg    install_type=
5844ec713c28Smrg    isdir=no
5845ec713c28Smrg    stripme=
5846ec713c28Smrg    for arg
5847ec713c28Smrg    do
5848ec713c28Smrg      if test -n "$dest"; then
5849ec713c28Smrg	files="$files $dest"
5850ec713c28Smrg	dest=$arg
5851ec713c28Smrg	continue
5852ec713c28Smrg      fi
5853786a6f21Smrg
5854ec713c28Smrg      case $arg in
5855ec713c28Smrg      -d) isdir=yes ;;
5856ec713c28Smrg      -f) 
5857ec713c28Smrg      	case " $install_prog " in
5858ec713c28Smrg	*[\\\ /]cp\ *) ;;
5859ec713c28Smrg	*) prev=$arg ;;
5860ec713c28Smrg	esac
5861ec713c28Smrg	;;
5862ec713c28Smrg      -g | -m | -o) prev=$arg ;;
5863ec713c28Smrg      -s)
5864ec713c28Smrg	stripme=" -s"
5865ec713c28Smrg	continue
5866ec713c28Smrg	;;
5867ec713c28Smrg      -*)
5868ec713c28Smrg	;;
5869ec713c28Smrg      *)
5870ec713c28Smrg	# If the previous option needed an argument, then skip it.
5871ec713c28Smrg	if test -n "$prev"; then
5872ec713c28Smrg	  prev=
5873ec713c28Smrg	else
5874ec713c28Smrg	  dest=$arg
5875ec713c28Smrg	  continue
5876ec713c28Smrg	fi
58771d54945dSmrg	;;
5878786a6f21Smrg      esac
58791d54945dSmrg
5880ec713c28Smrg      # Aesthetically quote the argument.
5881ec713c28Smrg      arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
5882ec713c28Smrg      case $arg in
5883ec713c28Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
5884ec713c28Smrg	arg="\"$arg\""
5885786a6f21Smrg	;;
5886786a6f21Smrg      esac
5887ec713c28Smrg      install_prog="$install_prog $arg"
5888ec713c28Smrg    done
58891d54945dSmrg
5890ec713c28Smrg    if test -z "$install_prog"; then
5891ec713c28Smrg      $echo "$modename: you must specify an install program" 1>&2
5892ec713c28Smrg      $echo "$help" 1>&2
5893ec713c28Smrg      exit $EXIT_FAILURE
5894ec713c28Smrg    fi
58951d54945dSmrg
5896ec713c28Smrg    if test -n "$prev"; then
5897ec713c28Smrg      $echo "$modename: the \`$prev' option requires an argument" 1>&2
5898ec713c28Smrg      $echo "$help" 1>&2
5899ec713c28Smrg      exit $EXIT_FAILURE
5900ec713c28Smrg    fi
5901ec713c28Smrg
5902ec713c28Smrg    if test -z "$files"; then
5903ec713c28Smrg      if test -z "$dest"; then
5904ec713c28Smrg	$echo "$modename: no file or destination specified" 1>&2
5905ec713c28Smrg      else
5906ec713c28Smrg	$echo "$modename: you must specify a destination" 1>&2
5907ec713c28Smrg      fi
5908ec713c28Smrg      $echo "$help" 1>&2
5909ec713c28Smrg      exit $EXIT_FAILURE
5910ec713c28Smrg    fi
5911ec713c28Smrg
5912ec713c28Smrg    # Strip any trailing slash from the destination.
5913ec713c28Smrg    dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
5914ec713c28Smrg
5915ec713c28Smrg    # Check to see that the destination is a directory.
5916ec713c28Smrg    test -d "$dest" && isdir=yes
5917ec713c28Smrg    if test "$isdir" = yes; then
5918ec713c28Smrg      destdir="$dest"
5919ec713c28Smrg      destname=
5920ec713c28Smrg    else
5921ec713c28Smrg      destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
5922ec713c28Smrg      test "X$destdir" = "X$dest" && destdir=.
5923ec713c28Smrg      destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
5924ec713c28Smrg
5925ec713c28Smrg      # Not a directory, so check to see that there is only one file specified.
5926ec713c28Smrg      set dummy $files
5927ec713c28Smrg      if test "$#" -gt 2; then
5928ec713c28Smrg	$echo "$modename: \`$dest' is not a directory" 1>&2
5929ec713c28Smrg	$echo "$help" 1>&2
5930ec713c28Smrg	exit $EXIT_FAILURE
5931ec713c28Smrg      fi
5932ec713c28Smrg    fi
5933ec713c28Smrg    case $destdir in
5934ec713c28Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
5935ec713c28Smrg    *)
5936ec713c28Smrg      for file in $files; do
5937ec713c28Smrg	case $file in
5938ec713c28Smrg	*.lo) ;;
5939786a6f21Smrg	*)
5940ec713c28Smrg	  $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
5941ec713c28Smrg	  $echo "$help" 1>&2
5942ec713c28Smrg	  exit $EXIT_FAILURE
5943786a6f21Smrg	  ;;
5944786a6f21Smrg	esac
5945786a6f21Smrg      done
5946ec713c28Smrg      ;;
5947ec713c28Smrg    esac
59481d54945dSmrg
5949ec713c28Smrg    # This variable tells wrapper scripts just to set variables rather
5950ec713c28Smrg    # than running their programs.
5951ec713c28Smrg    libtool_install_magic="$magic"
59521d54945dSmrg
5953ec713c28Smrg    staticlibs=
5954ec713c28Smrg    future_libdirs=
5955ec713c28Smrg    current_libdirs=
5956ec713c28Smrg    for file in $files; do
59571d54945dSmrg
5958ec713c28Smrg      # Do each installation.
5959ec713c28Smrg      case $file in
5960ec713c28Smrg      *.$libext)
5961ec713c28Smrg	# Do the static libraries later.
5962ec713c28Smrg	staticlibs="$staticlibs $file"
5963ec713c28Smrg	;;
5964ec713c28Smrg
5965ec713c28Smrg      *.la)
5966ec713c28Smrg	# Check to see that this really is a libtool archive.
5967ec713c28Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
5968ec713c28Smrg	else
5969ec713c28Smrg	  $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
5970ec713c28Smrg	  $echo "$help" 1>&2
5971ec713c28Smrg	  exit $EXIT_FAILURE
5972ec713c28Smrg	fi
5973ec713c28Smrg
5974ec713c28Smrg	library_names=
5975ec713c28Smrg	old_library=
5976ec713c28Smrg	relink_command=
5977ec713c28Smrg	# If there is no directory component, then add one.
5978ec713c28Smrg	case $file in
5979ec713c28Smrg	*/* | *\\*) . $file ;;
5980ec713c28Smrg	*) . ./$file ;;
5981ec713c28Smrg	esac
5982ec713c28Smrg
5983ec713c28Smrg	# Add the libdir to current_libdirs if it is the destination.
5984ec713c28Smrg	if test "X$destdir" = "X$libdir"; then
5985ec713c28Smrg	  case "$current_libdirs " in
5986786a6f21Smrg	  *" $libdir "*) ;;
5987ec713c28Smrg	  *) current_libdirs="$current_libdirs $libdir" ;;
5988786a6f21Smrg	  esac
5989ec713c28Smrg	else
5990ec713c28Smrg	  # Note the libdir as a future libdir.
5991ec713c28Smrg	  case "$future_libdirs " in
5992786a6f21Smrg	  *" $libdir "*) ;;
5993ec713c28Smrg	  *) future_libdirs="$future_libdirs $libdir" ;;
5994786a6f21Smrg	  esac
5995786a6f21Smrg	fi
59961d54945dSmrg
5997ec713c28Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/
5998ec713c28Smrg	test "X$dir" = "X$file/" && dir=
5999ec713c28Smrg	dir="$dir$objdir"
6000ec713c28Smrg
6001ec713c28Smrg	if test -n "$relink_command"; then
6002ec713c28Smrg	  # Determine the prefix the user has applied to our future dir.
6003ec713c28Smrg	  inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"`
6004ec713c28Smrg
6005ec713c28Smrg	  # Don't allow the user to place us outside of our expected
6006ec713c28Smrg	  # location b/c this prevents finding dependent libraries that
6007ec713c28Smrg	  # are installed to the same prefix.
6008ec713c28Smrg	  # At present, this check doesn't affect windows .dll's that
6009ec713c28Smrg	  # are installed into $libdir/../bin (currently, that works fine)
6010ec713c28Smrg	  # but it's something to keep an eye on.
6011ec713c28Smrg	  if test "$inst_prefix_dir" = "$destdir"; then
6012ec713c28Smrg	    $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
6013ec713c28Smrg	    exit $EXIT_FAILURE
6014ec713c28Smrg	  fi
6015ec713c28Smrg
6016ec713c28Smrg	  if test -n "$inst_prefix_dir"; then
6017ec713c28Smrg	    # Stick the inst_prefix_dir data into the link command.
6018ec713c28Smrg	    relink_command=`$echo "$relink_command" | $SP2NL | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%" | $NL2SP`
6019ec713c28Smrg	  else
6020ec713c28Smrg	    relink_command=`$echo "$relink_command" | $SP2NL | $SED "s%@inst_prefix_dir@%%" | $NL2SP`
6021ec713c28Smrg	  fi
6022ec713c28Smrg
6023ec713c28Smrg	  $echo "$modename: warning: relinking \`$file'" 1>&2
6024ec713c28Smrg	  $show "$relink_command"
6025ec713c28Smrg	  if $run eval "$relink_command"; then :
60261d54945dSmrg	  else
6027ec713c28Smrg	    $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
6028ec713c28Smrg	    exit $EXIT_FAILURE
60291d54945dSmrg	  fi
60301d54945dSmrg	fi
60311d54945dSmrg
6032ec713c28Smrg	# See the names of the shared library.
6033ec713c28Smrg	set dummy $library_names
6034ec713c28Smrg	if test -n "$2"; then
6035ec713c28Smrg	  realname="$2"
6036ec713c28Smrg	  shift
6037ec713c28Smrg	  shift
60381d54945dSmrg
6039ec713c28Smrg	  srcname="$realname"
6040ec713c28Smrg	  test -n "$relink_command" && srcname="$realname"T
60411d54945dSmrg
6042ec713c28Smrg	  # Install the shared library and build the symlinks.
6043ec713c28Smrg	  $show "$install_prog $dir/$srcname $destdir/$realname"
6044ec713c28Smrg	  $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $?
6045ec713c28Smrg	  if test -n "$stripme" && test -n "$striplib"; then
6046ec713c28Smrg	    $show "$striplib $destdir/$realname"
6047ec713c28Smrg	    $run eval "$striplib $destdir/$realname" || exit $?
6048ec713c28Smrg	  fi
60491d54945dSmrg
6050ec713c28Smrg	  if test "$#" -gt 0; then
6051ec713c28Smrg	    # Delete the old symlinks, and create new ones.
6052ec713c28Smrg	    # Try `ln -sf' first, because the `ln' binary might depend on
6053ec713c28Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
6054ec713c28Smrg	    # so we also need to try rm && ln -s.
6055ec713c28Smrg	    for linkname
6056ec713c28Smrg	    do
6057ec713c28Smrg	      if test "$linkname" != "$realname"; then
6058ec713c28Smrg                $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
6059ec713c28Smrg                $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
6060ec713c28Smrg	      fi
6061ec713c28Smrg	    done
6062ec713c28Smrg	  fi
60631d54945dSmrg
6064ec713c28Smrg	  # Do each command in the postinstall commands.
6065ec713c28Smrg	  lib="$destdir/$realname"
6066ec713c28Smrg	  cmds=$postinstall_cmds
6067ec713c28Smrg	  save_ifs="$IFS"; IFS='~'
6068ec713c28Smrg	  for cmd in $cmds; do
6069ec713c28Smrg	    IFS="$save_ifs"
6070ec713c28Smrg	    eval cmd=\"$cmd\"
6071ec713c28Smrg	    $show "$cmd"
6072ec713c28Smrg	    $run eval "$cmd" || {
6073ec713c28Smrg	      lt_exit=$?
6074ec713c28Smrg
6075ec713c28Smrg	      # Restore the uninstalled library and exit
6076ec713c28Smrg	      if test "$mode" = relink; then
6077ec713c28Smrg		$run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
6078ec713c28Smrg	      fi
60791d54945dSmrg
6080ec713c28Smrg	      exit $lt_exit
6081ec713c28Smrg	    }
6082ec713c28Smrg	  done
6083ec713c28Smrg	  IFS="$save_ifs"
60841d54945dSmrg	fi
60851d54945dSmrg
6086ec713c28Smrg	# Install the pseudo-library for information purposes.
6087ec713c28Smrg	name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
6088ec713c28Smrg	instname="$dir/$name"i
6089ec713c28Smrg	$show "$install_prog $instname $destdir/$name"
6090ec713c28Smrg	$run eval "$install_prog $instname $destdir/$name" || exit $?
60911d54945dSmrg
6092ec713c28Smrg	# Maybe install the static library, too.
6093ec713c28Smrg	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
6094ec713c28Smrg	;;
60951d54945dSmrg
6096ec713c28Smrg      *.lo)
6097ec713c28Smrg	# Install (i.e. copy) a libtool object.
6098ec713c28Smrg
6099ec713c28Smrg	# Figure out destination file name, if it wasn't already specified.
6100ec713c28Smrg	if test -n "$destname"; then
6101ec713c28Smrg	  destfile="$destdir/$destname"
6102ec713c28Smrg	else
6103ec713c28Smrg	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
6104ec713c28Smrg	  destfile="$destdir/$destfile"
61051d54945dSmrg	fi
6106ec713c28Smrg
6107ec713c28Smrg	# Deduce the name of the destination old-style object file.
6108ec713c28Smrg	case $destfile in
6109ec713c28Smrg	*.lo)
6110ec713c28Smrg	  staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
6111ec713c28Smrg	  ;;
6112ec713c28Smrg	*.$objext)
6113ec713c28Smrg	  staticdest="$destfile"
6114ec713c28Smrg	  destfile=
6115ec713c28Smrg	  ;;
6116ec713c28Smrg	*)
6117ec713c28Smrg	  $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
6118ec713c28Smrg	  $echo "$help" 1>&2
6119ec713c28Smrg	  exit $EXIT_FAILURE
6120ec713c28Smrg	  ;;
6121ec713c28Smrg	esac
6122ec713c28Smrg
6123ec713c28Smrg	# Install the libtool object if requested.
6124ec713c28Smrg	if test -n "$destfile"; then
6125ec713c28Smrg	  $show "$install_prog $file $destfile"
6126ec713c28Smrg	  $run eval "$install_prog $file $destfile" || exit $?
61271d54945dSmrg	fi
61281d54945dSmrg
6129ec713c28Smrg	# Install the old object if enabled.
6130ec713c28Smrg	if test "$build_old_libs" = yes; then
6131ec713c28Smrg	  # Deduce the name of the old-style object file.
6132ec713c28Smrg	  staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
61331d54945dSmrg
6134ec713c28Smrg	  $show "$install_prog $staticobj $staticdest"
6135ec713c28Smrg	  $run eval "$install_prog \$staticobj \$staticdest" || exit $?
6136ec713c28Smrg	fi
6137ec713c28Smrg	exit $EXIT_SUCCESS
6138ec713c28Smrg	;;
6139786a6f21Smrg
6140ec713c28Smrg      *)
6141ec713c28Smrg	# Figure out destination file name, if it wasn't already specified.
6142ec713c28Smrg	if test -n "$destname"; then
6143ec713c28Smrg	  destfile="$destdir/$destname"
61441d54945dSmrg	else
6145ec713c28Smrg	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
6146ec713c28Smrg	  destfile="$destdir/$destfile"
61471d54945dSmrg	fi
61481d54945dSmrg
6149ec713c28Smrg	# If the file is missing, and there is a .exe on the end, strip it
6150ec713c28Smrg	# because it is most likely a libtool script we actually want to
6151ec713c28Smrg	# install
6152ec713c28Smrg	stripped_ext=""
6153ec713c28Smrg	case $file in
6154ec713c28Smrg	  *.exe)
6155ec713c28Smrg	    if test ! -f "$file"; then
6156ec713c28Smrg	      file=`$echo $file|${SED} 's,.exe$,,'`
6157ec713c28Smrg	      stripped_ext=".exe"
6158ec713c28Smrg	    fi
6159ec713c28Smrg	    ;;
6160ec713c28Smrg	esac
61611d54945dSmrg
6162ec713c28Smrg	# Do a test to see if this is really a libtool program.
6163ec713c28Smrg	case $host in
6164ec713c28Smrg	*cygwin*|*mingw*)
6165ec713c28Smrg	    wrapper=`$echo $file | ${SED} -e 's,.exe$,,'`
6166ec713c28Smrg	    ;;
6167ec713c28Smrg	*)
6168ec713c28Smrg	    wrapper=$file
6169ec713c28Smrg	    ;;
6170ec713c28Smrg	esac
6171ec713c28Smrg	if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then
6172ec713c28Smrg	  notinst_deplibs=
6173ec713c28Smrg	  relink_command=
61741d54945dSmrg
6175ec713c28Smrg	  # Note that it is not necessary on cygwin/mingw to append a dot to
6176ec713c28Smrg	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
6177ec713c28Smrg	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
6178ec713c28Smrg	  # `FILE.' does not work on cygwin managed mounts.
6179ec713c28Smrg	  #
6180ec713c28Smrg	  # If there is no directory component, then add one.
6181ec713c28Smrg	  case $wrapper in
6182ec713c28Smrg	  */* | *\\*) . ${wrapper} ;;
6183ec713c28Smrg	  *) . ./${wrapper} ;;
6184ec713c28Smrg	  esac
61851d54945dSmrg
6186ec713c28Smrg	  # Check the variables that should have been set.
6187ec713c28Smrg	  if test -z "$notinst_deplibs"; then
6188ec713c28Smrg	    $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2
6189ec713c28Smrg	    exit $EXIT_FAILURE
6190ec713c28Smrg	  fi
61911d54945dSmrg
6192ec713c28Smrg	  finalize=yes
6193ec713c28Smrg	  for lib in $notinst_deplibs; do
6194ec713c28Smrg	    # Check to see that each library is installed.
6195ec713c28Smrg	    libdir=
6196ec713c28Smrg	    if test -f "$lib"; then
6197ec713c28Smrg	      # If there is no directory component, then add one.
6198ec713c28Smrg	      case $lib in
6199ec713c28Smrg	      */* | *\\*) . $lib ;;
6200ec713c28Smrg	      *) . ./$lib ;;
6201ec713c28Smrg	      esac
6202ec713c28Smrg	    fi
6203ec713c28Smrg	    libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
6204ec713c28Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
6205ec713c28Smrg	      $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
6206ec713c28Smrg	      finalize=no
6207ec713c28Smrg	    fi
6208ec713c28Smrg	  done
6209ec713c28Smrg
6210ec713c28Smrg	  relink_command=
6211ec713c28Smrg	  # Note that it is not necessary on cygwin/mingw to append a dot to
6212ec713c28Smrg	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
6213ec713c28Smrg	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
6214ec713c28Smrg	  # `FILE.' does not work on cygwin managed mounts.
6215ec713c28Smrg	  #
6216ec713c28Smrg	  # If there is no directory component, then add one.
6217ec713c28Smrg	  case $wrapper in
6218ec713c28Smrg	  */* | *\\*) . ${wrapper} ;;
6219ec713c28Smrg	  *) . ./${wrapper} ;;
6220ec713c28Smrg	  esac
6221ec713c28Smrg
6222ec713c28Smrg	  outputname=
6223ec713c28Smrg	  if test "$fast_install" = no && test -n "$relink_command"; then
6224ec713c28Smrg	    if test "$finalize" = yes && test -z "$run"; then
6225ec713c28Smrg	      tmpdir=`func_mktempdir`
6226ec713c28Smrg	      file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
6227ec713c28Smrg	      outputname="$tmpdir/$file"
6228ec713c28Smrg	      # Replace the output file specification.
6229ec713c28Smrg	      relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g' | $NL2SP`
6230ec713c28Smrg
6231ec713c28Smrg	      $show "$relink_command"
6232ec713c28Smrg	      if $run eval "$relink_command"; then :
6233ec713c28Smrg	      else
6234ec713c28Smrg		$echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
6235ec713c28Smrg		${rm}r "$tmpdir"
6236ec713c28Smrg		continue
6237ec713c28Smrg	      fi
6238ec713c28Smrg	      file="$outputname"
6239ec713c28Smrg	    else
6240ec713c28Smrg	      $echo "$modename: warning: cannot relink \`$file'" 1>&2
6241ec713c28Smrg	    fi
62421d54945dSmrg	  else
6243ec713c28Smrg	    # Install the binary that we compiled earlier.
6244ec713c28Smrg	    file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
62451d54945dSmrg	  fi
6246ec713c28Smrg	fi
6247786a6f21Smrg
6248ec713c28Smrg	# remove .exe since cygwin /usr/bin/install will append another
6249ec713c28Smrg	# one anyway 
6250ec713c28Smrg	case $install_prog,$host in
6251ec713c28Smrg	*/usr/bin/install*,*cygwin*)
6252ec713c28Smrg	  case $file:$destfile in
6253ec713c28Smrg	  *.exe:*.exe)
6254ec713c28Smrg	    # this is ok
6255ec713c28Smrg	    ;;
6256ec713c28Smrg	  *.exe:*)
6257ec713c28Smrg	    destfile=$destfile.exe
6258ec713c28Smrg	    ;;
6259ec713c28Smrg	  *:*.exe)
6260ec713c28Smrg	    destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'`
6261ec713c28Smrg	    ;;
6262ec713c28Smrg	  esac
6263ec713c28Smrg	  ;;
6264786a6f21Smrg	esac
6265ec713c28Smrg	$show "$install_prog$stripme $file $destfile"
6266ec713c28Smrg	$run eval "$install_prog\$stripme \$file \$destfile" || exit $?
6267ec713c28Smrg	test -n "$outputname" && ${rm}r "$tmpdir"
6268ec713c28Smrg	;;
6269ec713c28Smrg      esac
6270ec713c28Smrg    done
62711d54945dSmrg
6272ec713c28Smrg    for file in $staticlibs; do
6273ec713c28Smrg      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
62741d54945dSmrg
6275ec713c28Smrg      # Set up the ranlib parameters.
6276ec713c28Smrg      oldlib="$destdir/$name"
62771d54945dSmrg
6278ec713c28Smrg      $show "$install_prog $file $oldlib"
6279ec713c28Smrg      $run eval "$install_prog \$file \$oldlib" || exit $?
62801d54945dSmrg
6281ec713c28Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
6282ec713c28Smrg	$show "$old_striplib $oldlib"
6283ec713c28Smrg	$run eval "$old_striplib $oldlib" || exit $?
62841d54945dSmrg      fi
62851d54945dSmrg
6286ec713c28Smrg      # Do each command in the postinstall commands.
6287ec713c28Smrg      cmds=$old_postinstall_cmds
6288ec713c28Smrg      save_ifs="$IFS"; IFS='~'
6289ec713c28Smrg      for cmd in $cmds; do
6290ec713c28Smrg	IFS="$save_ifs"
6291ec713c28Smrg	eval cmd=\"$cmd\"
6292ec713c28Smrg	$show "$cmd"
6293ec713c28Smrg	$run eval "$cmd" || exit $?
6294ec713c28Smrg      done
6295ec713c28Smrg      IFS="$save_ifs"
6296ec713c28Smrg    done
62971d54945dSmrg
6298ec713c28Smrg    if test -n "$future_libdirs"; then
6299ec713c28Smrg      $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
6300ec713c28Smrg    fi
63011d54945dSmrg
6302ec713c28Smrg    if test -n "$current_libdirs"; then
6303ec713c28Smrg      # Maybe just do a dry run.
6304ec713c28Smrg      test -n "$run" && current_libdirs=" -n$current_libdirs"
6305ec713c28Smrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
6306ec713c28Smrg    else
6307ec713c28Smrg      exit $EXIT_SUCCESS
6308ec713c28Smrg    fi
6309ec713c28Smrg    ;;
63101d54945dSmrg
6311ec713c28Smrg  # libtool finish mode
6312ec713c28Smrg  finish)
6313ec713c28Smrg    modename="$modename: finish"
6314ec713c28Smrg    libdirs="$nonopt"
6315ec713c28Smrg    admincmds=
63161d54945dSmrg
6317ec713c28Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
6318ec713c28Smrg      for dir
6319ec713c28Smrg      do
6320ec713c28Smrg	libdirs="$libdirs $dir"
6321ec713c28Smrg      done
63221d54945dSmrg
6323ec713c28Smrg      for libdir in $libdirs; do
6324ec713c28Smrg	if test -n "$finish_cmds"; then
6325ec713c28Smrg	  # Do each command in the finish commands.
6326ec713c28Smrg	  cmds=$finish_cmds
6327ec713c28Smrg	  save_ifs="$IFS"; IFS='~'
6328ec713c28Smrg	  for cmd in $cmds; do
6329ec713c28Smrg	    IFS="$save_ifs"
6330ec713c28Smrg	    eval cmd=\"$cmd\"
6331ec713c28Smrg	    $show "$cmd"
6332ec713c28Smrg	    $run eval "$cmd" || admincmds="$admincmds
6333ec713c28Smrg       $cmd"
63341d54945dSmrg	  done
6335ec713c28Smrg	  IFS="$save_ifs"
63361d54945dSmrg	fi
6337ec713c28Smrg	if test -n "$finish_eval"; then
6338ec713c28Smrg	  # Do the single finish_eval.
6339ec713c28Smrg	  eval cmds=\"$finish_eval\"
6340ec713c28Smrg	  $run eval "$cmds" || admincmds="$admincmds
6341ec713c28Smrg       $cmds"
6342786a6f21Smrg	fi
6343ec713c28Smrg      done
6344ec713c28Smrg    fi
6345ec713c28Smrg
6346ec713c28Smrg    # Exit here if they wanted silent mode.
6347ec713c28Smrg    test "$show" = : && exit $EXIT_SUCCESS
6348ec713c28Smrg
6349ec713c28Smrg    $echo "X----------------------------------------------------------------------" | $Xsed
6350ec713c28Smrg    $echo "Libraries have been installed in:"
6351ec713c28Smrg    for libdir in $libdirs; do
6352ec713c28Smrg      $echo "   $libdir"
63531d54945dSmrg    done
6354ec713c28Smrg    $echo
6355ec713c28Smrg    $echo "If you ever happen to want to link against installed libraries"
6356ec713c28Smrg    $echo "in a given directory, LIBDIR, you must either use libtool, and"
6357ec713c28Smrg    $echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
6358ec713c28Smrg    $echo "flag during linking and do at least one of the following:"
6359ec713c28Smrg    if test -n "$shlibpath_var"; then
6360ec713c28Smrg      $echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
6361ec713c28Smrg      $echo "     during execution"
6362ec713c28Smrg    fi
6363ec713c28Smrg    if test -n "$runpath_var"; then
6364ec713c28Smrg      $echo "   - add LIBDIR to the \`$runpath_var' environment variable"
6365ec713c28Smrg      $echo "     during linking"
6366ec713c28Smrg    fi
6367ec713c28Smrg    if test -n "$hardcode_libdir_flag_spec"; then
6368ec713c28Smrg      libdir=LIBDIR
6369ec713c28Smrg      eval flag=\"$hardcode_libdir_flag_spec\"
63701d54945dSmrg
6371ec713c28Smrg      $echo "   - use the \`$flag' linker flag"
6372ec713c28Smrg    fi
6373ec713c28Smrg    if test -n "$admincmds"; then
6374ec713c28Smrg      $echo "   - have your system administrator run these commands:$admincmds"
6375ec713c28Smrg    fi
6376ec713c28Smrg    if test -f /etc/ld.so.conf; then
6377ec713c28Smrg      $echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
6378ec713c28Smrg    fi
6379ec713c28Smrg    $echo
6380ec713c28Smrg    $echo "See any operating system documentation about shared libraries for"
6381ec713c28Smrg    $echo "more information, such as the ld(1) and ld.so(8) manual pages."
6382ec713c28Smrg    $echo "X----------------------------------------------------------------------" | $Xsed
6383ec713c28Smrg    exit $EXIT_SUCCESS
6384ec713c28Smrg    ;;
63851d54945dSmrg
6386ec713c28Smrg  # libtool execute mode
6387ec713c28Smrg  execute)
6388ec713c28Smrg    modename="$modename: execute"
63891d54945dSmrg
6390ec713c28Smrg    # The first argument is the command name.
6391ec713c28Smrg    cmd="$nonopt"
6392ec713c28Smrg    if test -z "$cmd"; then
6393ec713c28Smrg      $echo "$modename: you must specify a COMMAND" 1>&2
6394ec713c28Smrg      $echo "$help"
6395ec713c28Smrg      exit $EXIT_FAILURE
6396ec713c28Smrg    fi
63971d54945dSmrg
6398ec713c28Smrg    # Handle -dlopen flags immediately.
6399ec713c28Smrg    for file in $execute_dlfiles; do
6400ec713c28Smrg      if test ! -f "$file"; then
6401ec713c28Smrg	$echo "$modename: \`$file' is not a file" 1>&2
6402ec713c28Smrg	$echo "$help" 1>&2
6403ec713c28Smrg	exit $EXIT_FAILURE
6404ec713c28Smrg      fi
64051d54945dSmrg
6406ec713c28Smrg      dir=
6407ec713c28Smrg      case $file in
6408ec713c28Smrg      *.la)
6409ec713c28Smrg	# Check to see that this really is a libtool archive.
6410ec713c28Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
6411ec713c28Smrg	else
6412ec713c28Smrg	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
6413ec713c28Smrg	  $echo "$help" 1>&2
6414ec713c28Smrg	  exit $EXIT_FAILURE
6415ec713c28Smrg	fi
64161d54945dSmrg
6417ec713c28Smrg	# Read the libtool library.
6418ec713c28Smrg	dlname=
6419ec713c28Smrg	library_names=
64201d54945dSmrg
6421ec713c28Smrg	# If there is no directory component, then add one.
6422ec713c28Smrg	case $file in
6423ec713c28Smrg	*/* | *\\*) . $file ;;
6424ec713c28Smrg	*) . ./$file ;;
6425ec713c28Smrg	esac
64261d54945dSmrg
6427ec713c28Smrg	# Skip this library if it cannot be dlopened.
6428ec713c28Smrg	if test -z "$dlname"; then
6429ec713c28Smrg	  # Warn if it was a shared library.
6430ec713c28Smrg	  test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
6431ec713c28Smrg	  continue
6432ec713c28Smrg	fi
64331d54945dSmrg
6434ec713c28Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
6435ec713c28Smrg	test "X$dir" = "X$file" && dir=.
64361d54945dSmrg
6437ec713c28Smrg	if test -f "$dir/$objdir/$dlname"; then
6438ec713c28Smrg	  dir="$dir/$objdir"
6439ec713c28Smrg	else
6440ec713c28Smrg	  if test ! -f "$dir/$dlname"; then
6441ec713c28Smrg	    $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
6442ec713c28Smrg	    exit $EXIT_FAILURE
6443ec713c28Smrg	  fi
6444ec713c28Smrg	fi
6445ec713c28Smrg	;;
64461d54945dSmrg
6447ec713c28Smrg      *.lo)
6448ec713c28Smrg	# Just add the directory containing the .lo file.
6449ec713c28Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
6450ec713c28Smrg	test "X$dir" = "X$file" && dir=.
6451ec713c28Smrg	;;
64521d54945dSmrg
6453ec713c28Smrg      *)
6454ec713c28Smrg	$echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
6455ec713c28Smrg	continue
6456ec713c28Smrg	;;
6457ec713c28Smrg      esac
64581d54945dSmrg
6459ec713c28Smrg      # Get the absolute pathname.
6460ec713c28Smrg      absdir=`cd "$dir" && pwd`
6461ec713c28Smrg      test -n "$absdir" && dir="$absdir"
64621d54945dSmrg
6463ec713c28Smrg      # Now add the directory to shlibpath_var.
6464ec713c28Smrg      if eval "test -z \"\$$shlibpath_var\""; then
6465ec713c28Smrg	eval "$shlibpath_var=\"\$dir\""
6466ec713c28Smrg      else
6467ec713c28Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
6468ec713c28Smrg      fi
6469ec713c28Smrg    done
64701d54945dSmrg
6471ec713c28Smrg    # This variable tells wrapper scripts just to set shlibpath_var
6472ec713c28Smrg    # rather than running their programs.
6473ec713c28Smrg    libtool_execute_magic="$magic"
64741d54945dSmrg
6475ec713c28Smrg    # Check if any of the arguments is a wrapper script.
6476ec713c28Smrg    args=
6477ec713c28Smrg    for file
6478ec713c28Smrg    do
6479ec713c28Smrg      case $file in
6480ec713c28Smrg      -*) ;;
6481ec713c28Smrg      *)
6482ec713c28Smrg	# Do a test to see if this is really a libtool program.
6483ec713c28Smrg	if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
6484ec713c28Smrg	  # If there is no directory component, then add one.
6485ec713c28Smrg	  case $file in
6486ec713c28Smrg	  */* | *\\*) . $file ;;
6487ec713c28Smrg	  *) . ./$file ;;
6488ec713c28Smrg	  esac
64891d54945dSmrg
6490ec713c28Smrg	  # Transform arg to wrapped name.
6491ec713c28Smrg	  file="$progdir/$program"
6492ec713c28Smrg	fi
6493ec713c28Smrg	;;
6494ec713c28Smrg      esac
6495ec713c28Smrg      # Quote arguments (to preserve shell metacharacters).
6496ec713c28Smrg      file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
6497ec713c28Smrg      args="$args \"$file\""
6498ec713c28Smrg    done
6499ba85709eSmrg
6500ec713c28Smrg    if test -z "$run"; then
6501ec713c28Smrg      if test -n "$shlibpath_var"; then
6502ec713c28Smrg	# Export the shlibpath_var.
6503ec713c28Smrg	eval "export $shlibpath_var"
6504ec713c28Smrg      fi
6505ec713c28Smrg
6506ec713c28Smrg      # Restore saved environment variables
6507ec713c28Smrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
6508ec713c28Smrg      do
6509ec713c28Smrg	eval "if test \"\${save_$lt_var+set}\" = set; then
6510ec713c28Smrg		$lt_var=\$save_$lt_var; export $lt_var
6511ec713c28Smrg	      fi"
6512ec713c28Smrg      done
65131d54945dSmrg
6514ec713c28Smrg      # Now prepare to actually exec the command.
6515ec713c28Smrg      exec_cmd="\$cmd$args"
6516ec713c28Smrg    else
6517ec713c28Smrg      # Display what would be done.
6518ec713c28Smrg      if test -n "$shlibpath_var"; then
6519ec713c28Smrg	eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
6520ec713c28Smrg	$echo "export $shlibpath_var"
6521ec713c28Smrg      fi
6522ec713c28Smrg      $echo "$cmd$args"
6523ec713c28Smrg      exit $EXIT_SUCCESS
6524ec713c28Smrg    fi
6525ec713c28Smrg    ;;
65261d54945dSmrg
6527ec713c28Smrg  # libtool clean and uninstall mode
6528ec713c28Smrg  clean | uninstall)
6529ec713c28Smrg    modename="$modename: $mode"
6530ec713c28Smrg    rm="$nonopt"
65311d54945dSmrg    files=
65321d54945dSmrg    rmforce=
65331d54945dSmrg    exit_status=0
65341d54945dSmrg
65351d54945dSmrg    # This variable tells wrapper scripts just to set variables rather
65361d54945dSmrg    # than running their programs.
65371d54945dSmrg    libtool_install_magic="$magic"
65381d54945dSmrg
65391d54945dSmrg    for arg
65401d54945dSmrg    do
65411d54945dSmrg      case $arg in
6542ec713c28Smrg      -f) rm="$rm $arg"; rmforce=yes ;;
6543ec713c28Smrg      -*) rm="$rm $arg" ;;
65441d54945dSmrg      *) files="$files $arg" ;;
65451d54945dSmrg      esac
65461d54945dSmrg    done
65471d54945dSmrg
6548ec713c28Smrg    if test -z "$rm"; then
6549ec713c28Smrg      $echo "$modename: you must specify an RM program" 1>&2
6550ec713c28Smrg      $echo "$help" 1>&2
6551ec713c28Smrg      exit $EXIT_FAILURE
6552ec713c28Smrg    fi
65531d54945dSmrg
65541d54945dSmrg    rmdirs=
65551d54945dSmrg
65561d54945dSmrg    origobjdir="$objdir"
65571d54945dSmrg    for file in $files; do
6558ec713c28Smrg      dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
6559ec713c28Smrg      if test "X$dir" = "X$file"; then
6560ec713c28Smrg	dir=.
65611d54945dSmrg	objdir="$origobjdir"
65621d54945dSmrg      else
65631d54945dSmrg	objdir="$dir/$origobjdir"
65641d54945dSmrg      fi
6565ec713c28Smrg      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
65661d54945dSmrg      test "$mode" = uninstall && objdir="$dir"
65671d54945dSmrg
65681d54945dSmrg      # Remember objdir for removal later, being careful to avoid duplicates
65691d54945dSmrg      if test "$mode" = clean; then
65701d54945dSmrg	case " $rmdirs " in
65711d54945dSmrg	  *" $objdir "*) ;;
65721d54945dSmrg	  *) rmdirs="$rmdirs $objdir" ;;
65731d54945dSmrg	esac
65741d54945dSmrg      fi
65751d54945dSmrg
65761d54945dSmrg      # Don't error if the file doesn't exist and rm -f was used.
6577ec713c28Smrg      if (test -L "$file") >/dev/null 2>&1 \
6578ec713c28Smrg	|| (test -h "$file") >/dev/null 2>&1 \
6579ec713c28Smrg	|| test -f "$file"; then
65801d54945dSmrg	:
65811d54945dSmrg      elif test -d "$file"; then
65821d54945dSmrg	exit_status=1
65831d54945dSmrg	continue
65841d54945dSmrg      elif test "$rmforce" = yes; then
65851d54945dSmrg	continue
65861d54945dSmrg      fi
65871d54945dSmrg
65881d54945dSmrg      rmfiles="$file"
65891d54945dSmrg
65901d54945dSmrg      case $name in
65911d54945dSmrg      *.la)
65921d54945dSmrg	# Possibly a libtool archive, so verify it.
6593ec713c28Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
6594ec713c28Smrg	  . $dir/$name
65951d54945dSmrg
65961d54945dSmrg	  # Delete the libtool libraries and symlinks.
65971d54945dSmrg	  for n in $library_names; do
65981d54945dSmrg	    rmfiles="$rmfiles $objdir/$n"
65991d54945dSmrg	  done
66001d54945dSmrg	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
66011d54945dSmrg
66021d54945dSmrg	  case "$mode" in
66031d54945dSmrg	  clean)
66041d54945dSmrg	    case "  $library_names " in
66051d54945dSmrg	    # "  " in the beginning catches empty $dlname
66061d54945dSmrg	    *" $dlname "*) ;;
66071d54945dSmrg	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
66081d54945dSmrg	    esac
6609ec713c28Smrg	     test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
66101d54945dSmrg	    ;;
66111d54945dSmrg	  uninstall)
66121d54945dSmrg	    if test -n "$library_names"; then
66131d54945dSmrg	      # Do each command in the postuninstall commands.
6614ec713c28Smrg	      cmds=$postuninstall_cmds
6615ec713c28Smrg	      save_ifs="$IFS"; IFS='~'
6616ec713c28Smrg	      for cmd in $cmds; do
6617ec713c28Smrg		IFS="$save_ifs"
6618ec713c28Smrg		eval cmd=\"$cmd\"
6619ec713c28Smrg		$show "$cmd"
6620ec713c28Smrg		$run eval "$cmd"
6621ec713c28Smrg		if test "$?" -ne 0 && test "$rmforce" != yes; then
6622ec713c28Smrg		  exit_status=1
6623ec713c28Smrg		fi
6624ec713c28Smrg	      done
6625ec713c28Smrg	      IFS="$save_ifs"
66261d54945dSmrg	    fi
66271d54945dSmrg
66281d54945dSmrg	    if test -n "$old_library"; then
66291d54945dSmrg	      # Do each command in the old_postuninstall commands.
6630ec713c28Smrg	      cmds=$old_postuninstall_cmds
6631ec713c28Smrg	      save_ifs="$IFS"; IFS='~'
6632ec713c28Smrg	      for cmd in $cmds; do
6633ec713c28Smrg		IFS="$save_ifs"
6634ec713c28Smrg		eval cmd=\"$cmd\"
6635ec713c28Smrg		$show "$cmd"
6636ec713c28Smrg		$run eval "$cmd"
6637ec713c28Smrg		if test "$?" -ne 0 && test "$rmforce" != yes; then
6638ec713c28Smrg		  exit_status=1
6639ec713c28Smrg		fi
6640ec713c28Smrg	      done
6641ec713c28Smrg	      IFS="$save_ifs"
66421d54945dSmrg	    fi
66431d54945dSmrg	    # FIXME: should reinstall the best remaining shared library.
66441d54945dSmrg	    ;;
66451d54945dSmrg	  esac
66461d54945dSmrg	fi
66471d54945dSmrg	;;
66481d54945dSmrg
66491d54945dSmrg      *.lo)
66501d54945dSmrg	# Possibly a libtool object, so verify it.
6651ec713c28Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
66521d54945dSmrg
66531d54945dSmrg	  # Read the .lo file
6654ec713c28Smrg	  . $dir/$name
66551d54945dSmrg
66561d54945dSmrg	  # Add PIC object to the list of files to remove.
6657ec713c28Smrg	  if test -n "$pic_object" \
6658ec713c28Smrg	     && test "$pic_object" != none; then
66591d54945dSmrg	    rmfiles="$rmfiles $dir/$pic_object"
66601d54945dSmrg	  fi
66611d54945dSmrg
66621d54945dSmrg	  # Add non-PIC object to the list of files to remove.
6663ec713c28Smrg	  if test -n "$non_pic_object" \
6664ec713c28Smrg	     && test "$non_pic_object" != none; then
66651d54945dSmrg	    rmfiles="$rmfiles $dir/$non_pic_object"
66661d54945dSmrg	  fi
66671d54945dSmrg	fi
66681d54945dSmrg	;;
66691d54945dSmrg
66701d54945dSmrg      *)
66711d54945dSmrg	if test "$mode" = clean ; then
66721d54945dSmrg	  noexename=$name
66731d54945dSmrg	  case $file in
66741d54945dSmrg	  *.exe)
6675ec713c28Smrg	    file=`$echo $file|${SED} 's,.exe$,,'`
6676ec713c28Smrg	    noexename=`$echo $name|${SED} 's,.exe$,,'`
66771d54945dSmrg	    # $file with .exe has already been added to rmfiles,
66781d54945dSmrg	    # add $file without .exe
66791d54945dSmrg	    rmfiles="$rmfiles $file"
66801d54945dSmrg	    ;;
66811d54945dSmrg	  esac
66821d54945dSmrg	  # Do a test to see if this is a libtool program.
6683ec713c28Smrg	  if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
6684ec713c28Smrg	    relink_command=
6685ec713c28Smrg	    . $dir/$noexename
66861d54945dSmrg
66871d54945dSmrg	    # note $name still contains .exe if it was in $file originally
66881d54945dSmrg	    # as does the version of $file that was added into $rmfiles
66891d54945dSmrg	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
66901d54945dSmrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
66911d54945dSmrg	      rmfiles="$rmfiles $objdir/lt-$name"
66921d54945dSmrg	    fi
66931d54945dSmrg	    if test "X$noexename" != "X$name" ; then
66941d54945dSmrg	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
66951d54945dSmrg	    fi
66961d54945dSmrg	  fi
66971d54945dSmrg	fi
66981d54945dSmrg	;;
66991d54945dSmrg      esac
6700ec713c28Smrg      $show "$rm $rmfiles"
6701ec713c28Smrg      $run $rm $rmfiles || exit_status=1
67021d54945dSmrg    done
67031d54945dSmrg    objdir="$origobjdir"
67041d54945dSmrg
67051d54945dSmrg    # Try to remove the ${objdir}s in the directories where we deleted files
67061d54945dSmrg    for dir in $rmdirs; do
67071d54945dSmrg      if test -d "$dir"; then
6708ec713c28Smrg	$show "rmdir $dir"
6709ec713c28Smrg	$run rmdir $dir >/dev/null 2>&1
67101d54945dSmrg      fi
67111d54945dSmrg    done
67121d54945dSmrg
67131d54945dSmrg    exit $exit_status
6714ec713c28Smrg    ;;
67151d54945dSmrg
6716ec713c28Smrg  "")
6717ec713c28Smrg    $echo "$modename: you must specify a MODE" 1>&2
6718ec713c28Smrg    $echo "$generic_help" 1>&2
6719ec713c28Smrg    exit $EXIT_FAILURE
6720ec713c28Smrg    ;;
6721ec713c28Smrg  esac
6722786a6f21Smrg
6723ec713c28Smrg  if test -z "$exec_cmd"; then
6724ec713c28Smrg    $echo "$modename: invalid operation mode \`$mode'" 1>&2
6725ec713c28Smrg    $echo "$generic_help" 1>&2
6726ec713c28Smrg    exit $EXIT_FAILURE
6727ec713c28Smrg  fi
6728ec713c28Smrgfi # test -z "$show_help"
67291d54945dSmrg
67301d54945dSmrgif test -n "$exec_cmd"; then
6731ec713c28Smrg  eval exec $exec_cmd
67321d54945dSmrg  exit $EXIT_FAILURE
67331d54945dSmrgfi
67341d54945dSmrg
6735ec713c28Smrg# We need to display help for each of the modes.
6736ec713c28Smrgcase $mode in
6737ec713c28Smrg"") $echo \
6738ec713c28Smrg"Usage: $modename [OPTION]... [MODE-ARG]...
6739ec713c28Smrg
6740ec713c28SmrgProvide generalized library-building support services.
6741ec713c28Smrg
6742ec713c28Smrg    --config          show all configuration variables
6743ec713c28Smrg    --debug           enable verbose shell tracing
6744ec713c28Smrg-n, --dry-run         display commands without modifying any files
6745ec713c28Smrg    --features        display basic configuration information and exit
6746ec713c28Smrg    --finish          same as \`--mode=finish'
6747ec713c28Smrg    --help            display this help message and exit
6748ec713c28Smrg    --mode=MODE       use operation mode MODE [default=inferred from MODE-ARGS]
6749ec713c28Smrg    --quiet           same as \`--silent'
6750ec713c28Smrg    --silent          don't print informational messages
6751ec713c28Smrg    --tag=TAG         use configuration variables from tag TAG
6752ec713c28Smrg    --version         print version information
6753ec713c28Smrg
6754ec713c28SmrgMODE must be one of the following:
6755ec713c28Smrg
6756ec713c28Smrg      clean           remove files from the build directory
6757ec713c28Smrg      compile         compile a source file into a libtool object
6758ec713c28Smrg      execute         automatically set library path, then run a program
6759ec713c28Smrg      finish          complete the installation of libtool libraries
6760ec713c28Smrg      install         install libraries or executables
6761ec713c28Smrg      link            create a library or an executable
6762ec713c28Smrg      uninstall       remove libraries from an installed directory
6763ec713c28Smrg
6764ec713c28SmrgMODE-ARGS vary depending on the MODE.  Try \`$modename --help --mode=MODE' for
6765ec713c28Smrga more detailed description of MODE.
6766ec713c28Smrg
6767ec713c28SmrgReport bugs to <bug-libtool@gnu.org>."
6768ec713c28Smrg  exit $EXIT_SUCCESS
6769ec713c28Smrg  ;;
6770ec713c28Smrg
6771ec713c28Smrgclean)
6772ec713c28Smrg  $echo \
6773ec713c28Smrg"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
6774ec713c28Smrg
6775ec713c28SmrgRemove files from the build directory.
6776ec713c28Smrg
6777ec713c28SmrgRM is the name of the program to use to delete files associated with each FILE
6778ec713c28Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
6779ec713c28Smrgto RM.
6780ec713c28Smrg
6781ec713c28SmrgIf FILE is a libtool library, object or program, all the files associated
6782ec713c28Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
6783ec713c28Smrg  ;;
6784ec713c28Smrg
6785ec713c28Smrgcompile)
6786ec713c28Smrg  $echo \
6787ec713c28Smrg"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
6788ec713c28Smrg
6789ec713c28SmrgCompile a source file into a libtool library object.
6790ec713c28Smrg
6791ec713c28SmrgThis mode accepts the following additional options:
6792ec713c28Smrg
6793ec713c28Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
6794ec713c28Smrg  -prefer-pic       try to building PIC objects only
6795ec713c28Smrg  -prefer-non-pic   try to building non-PIC objects only
6796ec713c28Smrg  -static           always build a \`.o' file suitable for static linking
6797ec713c28Smrg
6798ec713c28SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
6799ec713c28Smrgfrom the given SOURCEFILE.
6800ec713c28Smrg
6801ec713c28SmrgThe output file name is determined by removing the directory component from
6802ec713c28SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
6803ec713c28Smrglibrary object suffix, \`.lo'."
6804ec713c28Smrg  ;;
6805ec713c28Smrg
6806ec713c28Smrgexecute)
6807ec713c28Smrg  $echo \
6808ec713c28Smrg"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
6809ec713c28Smrg
6810ec713c28SmrgAutomatically set library path, then run a program.
6811ec713c28Smrg
6812ec713c28SmrgThis mode accepts the following additional options:
6813ec713c28Smrg
6814ec713c28Smrg  -dlopen FILE      add the directory containing FILE to the library path
6815ec713c28Smrg
6816ec713c28SmrgThis mode sets the library path environment variable according to \`-dlopen'
6817ec713c28Smrgflags.
6818ec713c28Smrg
6819ec713c28SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
6820ec713c28Smrginto their corresponding uninstalled binary, and any of their required library
6821ec713c28Smrgdirectories are added to the library path.
6822ec713c28Smrg
6823ec713c28SmrgThen, COMMAND is executed, with ARGS as arguments."
6824ec713c28Smrg  ;;
6825ec713c28Smrg
6826ec713c28Smrgfinish)
6827ec713c28Smrg  $echo \
6828ec713c28Smrg"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
6829ec713c28Smrg
6830ec713c28SmrgComplete the installation of libtool libraries.
6831ec713c28Smrg
6832ec713c28SmrgEach LIBDIR is a directory that contains libtool libraries.
6833ec713c28Smrg
6834ec713c28SmrgThe commands that this mode executes may require superuser privileges.  Use
6835ec713c28Smrgthe \`--dry-run' option if you just want to see what would be executed."
6836ec713c28Smrg  ;;
6837ec713c28Smrg
6838ec713c28Smrginstall)
6839ec713c28Smrg  $echo \
6840ec713c28Smrg"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
6841ec713c28Smrg
6842ec713c28SmrgInstall executables or libraries.
6843ec713c28Smrg
6844ec713c28SmrgINSTALL-COMMAND is the installation command.  The first component should be
6845ec713c28Smrgeither the \`install' or \`cp' program.
6846ec713c28Smrg
6847ec713c28SmrgThe rest of the components are interpreted as arguments to that command (only
6848ec713c28SmrgBSD-compatible install options are recognized)."
6849ec713c28Smrg  ;;
6850ec713c28Smrg
6851ec713c28Smrglink)
6852ec713c28Smrg  $echo \
6853ec713c28Smrg"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
6854ec713c28Smrg
6855ec713c28SmrgLink object files or libraries together to form another library, or to
6856ec713c28Smrgcreate an executable program.
68571d54945dSmrg
6858ec713c28SmrgLINK-COMMAND is a command using the C compiler that you would use to create
6859ec713c28Smrga program from several object files.
6860ec713c28Smrg
6861ec713c28SmrgThe following components of LINK-COMMAND are treated specially:
6862ec713c28Smrg
6863ec713c28Smrg  -all-static       do not do any dynamic linking at all
6864ec713c28Smrg  -avoid-version    do not add a version suffix if possible
6865ec713c28Smrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
6866ec713c28Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
6867ec713c28Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
6868ec713c28Smrg  -export-symbols SYMFILE
6869ec713c28Smrg                    try to export only the symbols listed in SYMFILE
6870ec713c28Smrg  -export-symbols-regex REGEX
6871ec713c28Smrg                    try to export only the symbols matching REGEX
6872ec713c28Smrg  -LLIBDIR          search LIBDIR for required installed libraries
6873ec713c28Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
6874ec713c28Smrg  -module           build a library that can dlopened
6875ec713c28Smrg  -no-fast-install  disable the fast-install mode
6876ec713c28Smrg  -no-install       link a not-installable executable
6877ec713c28Smrg  -no-undefined     declare that a library does not refer to external symbols
6878ec713c28Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
6879ec713c28Smrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
6880ec713c28Smrg  -precious-files-regex REGEX
6881ec713c28Smrg                    don't remove output files matching REGEX
6882ec713c28Smrg  -release RELEASE  specify package release information
6883ec713c28Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
6884ec713c28Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
6885ec713c28Smrg  -static           do not do any dynamic linking of uninstalled libtool libraries
6886ec713c28Smrg  -static-libtool-libs
6887ec713c28Smrg                    do not do any dynamic linking of libtool libraries
6888ec713c28Smrg  -version-info CURRENT[:REVISION[:AGE]]
6889ec713c28Smrg                    specify library version info [each variable defaults to 0]
6890ec713c28Smrg
6891ec713c28SmrgAll other options (arguments beginning with \`-') are ignored.
6892ec713c28Smrg
6893ec713c28SmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
6894ec713c28Smrgtreated as uninstalled libtool libraries, other files are standard or library
6895ec713c28Smrgobject files.
6896ec713c28Smrg
6897ec713c28SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
6898ec713c28Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
6899ec713c28Smrgrequired, except when creating a convenience library.
6900ec713c28Smrg
6901ec713c28SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
6902ec713c28Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
6903ec713c28Smrg
6904ec713c28SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
6905ec713c28Smrgis created, otherwise an executable program is created."
6906ec713c28Smrg  ;;
6907ec713c28Smrg
6908ec713c28Smrguninstall)
6909ec713c28Smrg  $echo \
6910ec713c28Smrg"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
6911ec713c28Smrg
6912ec713c28SmrgRemove libraries from an installation directory.
6913ec713c28Smrg
6914ec713c28SmrgRM is the name of the program to use to delete files associated with each FILE
6915ec713c28Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
6916ec713c28Smrgto RM.
6917ec713c28Smrg
6918ec713c28SmrgIf FILE is a libtool library, all the files associated with it are deleted.
6919ec713c28SmrgOtherwise, only FILE itself is deleted using RM."
6920ec713c28Smrg  ;;
6921ec713c28Smrg
6922ec713c28Smrg*)
6923ec713c28Smrg  $echo "$modename: invalid operation mode \`$mode'" 1>&2
6924ec713c28Smrg  $echo "$help" 1>&2
6925ec713c28Smrg  exit $EXIT_FAILURE
6926ec713c28Smrg  ;;
6927ec713c28Smrgesac
6928ec713c28Smrg
6929ec713c28Smrg$echo
6930ec713c28Smrg$echo "Try \`$modename --help' for more information about other modes."
6931ec713c28Smrg
6932ec713c28Smrgexit $?
69331d54945dSmrg
69341d54945dSmrg# The TAGs below are defined such that we never get into a situation
69351d54945dSmrg# in which we disable both kinds of libraries.  Given conflicting
69361d54945dSmrg# choices, we go for a static library, that is the most portable,
69371d54945dSmrg# since we can't tell whether shared libraries were disabled because
69381d54945dSmrg# the user asked for that or because the platform doesn't support
69391d54945dSmrg# them.  This is particularly important on AIX, because we don't
69401d54945dSmrg# support having both static and shared libraries enabled at the same
69411d54945dSmrg# time on that platform, so we default to a shared-only configuration.
69421d54945dSmrg# If a disable-shared tag is given, we'll fallback to a static-only
69431d54945dSmrg# configuration.  But we'll never go from static-only to shared-only.
69441d54945dSmrg
69451d54945dSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
6946ec713c28Smrgdisable_libs=shared
69471d54945dSmrg# ### END LIBTOOL TAG CONFIG: disable-shared
69481d54945dSmrg
69491d54945dSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
6950ec713c28Smrgdisable_libs=static
69511d54945dSmrg# ### END LIBTOOL TAG CONFIG: disable-static
69521d54945dSmrg
69531d54945dSmrg# Local Variables:
69541d54945dSmrg# mode:shell-script
69551d54945dSmrg# sh-indentation:2
69561d54945dSmrg# End:
6957