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