ltmain.sh revision 6aab59a7
1659607e0Smrg# ltmain.sh - Provide generalized library-building support services.
2659607e0Smrg# NOTE: Changing this file will not affect anything until you rerun configure.
3659607e0Smrg#
46aab59a7Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
56aab59a7Smrg# Free Software Foundation, Inc.
6659607e0Smrg# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
7659607e0Smrg#
8659607e0Smrg# This program is free software; you can redistribute it and/or modify
9659607e0Smrg# it under the terms of the GNU General Public License as published by
10659607e0Smrg# the Free Software Foundation; either version 2 of the License, or
11659607e0Smrg# (at your option) any later version.
12659607e0Smrg#
13659607e0Smrg# This program is distributed in the hope that it will be useful, but
14659607e0Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
15659607e0Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16659607e0Smrg# General Public License for more details.
17659607e0Smrg#
18659607e0Smrg# You should have received a copy of the GNU General Public License
19659607e0Smrg# along with this program; if not, write to the Free Software
20659607e0Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21659607e0Smrg#
22659607e0Smrg# As a special exception to the GNU General Public License, if you
23659607e0Smrg# distribute this file as part of a program that contains a
24659607e0Smrg# configuration script generated by Autoconf, you may include it under
25659607e0Smrg# the same distribution terms that you use for the rest of that program.
26659607e0Smrg
27659607e0Smrgbasename="s,^.*/,,g"
28659607e0Smrg
29659607e0Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
30659607e0Smrg# is ksh but when the shell is invoked as "sh" and the current value of
31659607e0Smrg# the _XPG environment variable is not equal to 1 (one), the special
32659607e0Smrg# positional parameter $0, within a function call, is the name of the
33659607e0Smrg# function.
34659607e0Smrgprogpath="$0"
35659607e0Smrg
36659607e0Smrg# The name of this program:
37659607e0Smrgprogname=`echo "$progpath" | $SED $basename`
38659607e0Smrgmodename="$progname"
39659607e0Smrg
40659607e0Smrg# Global variables:
41659607e0SmrgEXIT_SUCCESS=0
42659607e0SmrgEXIT_FAILURE=1
43659607e0Smrg
44659607e0SmrgPROGRAM=ltmain.sh
45659607e0SmrgPACKAGE=libtool
466aab59a7SmrgVERSION=1.5.22
476aab59a7SmrgTIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)"
486aab59a7Smrg
496aab59a7Smrg# See if we are running on zsh, and set the options which allow our
506aab59a7Smrg# commands through without removal of \ escapes.
516aab59a7Smrgif test -n "${ZSH_VERSION+set}" ; then
52659607e0Smrg  setopt NO_GLOB_SUBST
53659607e0Smrgfi
54659607e0Smrg
55659607e0Smrg# Check that we have a working $echo.
56659607e0Smrgif test "X$1" = X--no-reexec; then
57659607e0Smrg  # Discard the --no-reexec flag, and continue.
58659607e0Smrg  shift
59659607e0Smrgelif test "X$1" = X--fallback-echo; then
60659607e0Smrg  # Avoid inline document here, it may be left over
61659607e0Smrg  :
62659607e0Smrgelif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
63659607e0Smrg  # Yippee, $echo works!
64659607e0Smrg  :
65659607e0Smrgelse
66659607e0Smrg  # Restart under the correct shell, and then maybe $echo will work.
67659607e0Smrg  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
68659607e0Smrgfi
69659607e0Smrg
70659607e0Smrgif test "X$1" = X--fallback-echo; then
71659607e0Smrg  # used as fallback echo
72659607e0Smrg  shift
73659607e0Smrg  cat <<EOF
74659607e0Smrg$*
75659607e0SmrgEOF
76659607e0Smrg  exit $EXIT_SUCCESS
77659607e0Smrgfi
78659607e0Smrg
79659607e0Smrgdefault_mode=
80659607e0Smrghelp="Try \`$progname --help' for more information."
81659607e0Smrgmagic="%%%MAGIC variable%%%"
82659607e0Smrgmkdir="mkdir"
83659607e0Smrgmv="mv -f"
84659607e0Smrgrm="rm -f"
85659607e0Smrg
86659607e0Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
87659607e0Smrg# metacharacters that are still active within double-quoted strings.
88659607e0SmrgXsed="${SED}"' -e 1s/^X//'
89659607e0Smrgsed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
90659607e0Smrg# test EBCDIC or ASCII
91659607e0Smrgcase `echo X|tr X '\101'` in
92659607e0Smrg A) # ASCII based system
93659607e0Smrg    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
94659607e0Smrg  SP2NL='tr \040 \012'
95659607e0Smrg  NL2SP='tr \015\012 \040\040'
96659607e0Smrg  ;;
97659607e0Smrg *) # EBCDIC based system
98659607e0Smrg  SP2NL='tr \100 \n'
99659607e0Smrg  NL2SP='tr \r\n \100\100'
100659607e0Smrg  ;;
101659607e0Smrgesac
102659607e0Smrg
103659607e0Smrg# NLS nuisances.
104659607e0Smrg# Only set LANG and LC_ALL to C if already set.
105659607e0Smrg# These must not be set unconditionally because not all systems understand
106659607e0Smrg# e.g. LANG=C (notably SCO).
107659607e0Smrg# We save the old values to restore during execute mode.
1086aab59a7Smrgif test "${LC_ALL+set}" = set; then
1096aab59a7Smrg  save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
1106aab59a7Smrgfi
1116aab59a7Smrgif test "${LANG+set}" = set; then
1126aab59a7Smrg  save_LANG="$LANG"; LANG=C; export LANG
1136aab59a7Smrgfi
114659607e0Smrg
115659607e0Smrg# Make sure IFS has a sensible default
116659607e0Smrglt_nl='
117659607e0Smrg'
118659607e0SmrgIFS=" 	$lt_nl"
119659607e0Smrg
120659607e0Smrgif test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
121659607e0Smrg  $echo "$modename: not configured to build any kind of library" 1>&2
122659607e0Smrg  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
123659607e0Smrg  exit $EXIT_FAILURE
124659607e0Smrgfi
125659607e0Smrg
126659607e0Smrg# Global variables.
127659607e0Smrgmode=$default_mode
128659607e0Smrgnonopt=
129659607e0Smrgprev=
130659607e0Smrgprevopt=
131659607e0Smrgrun=
132659607e0Smrgshow="$echo"
133659607e0Smrgshow_help=
134659607e0Smrgexecute_dlfiles=
135659607e0Smrgduplicate_deps=no
136659607e0Smrgpreserve_args=
137659607e0Smrglo2o="s/\\.lo\$/.${objext}/"
138659607e0Smrgo2lo="s/\\.${objext}\$/.lo/"
139659607e0Smrg
140659607e0Smrg#####################################
141659607e0Smrg# Shell function definitions:
142659607e0Smrg# This seems to be the best place for them
143659607e0Smrg
144659607e0Smrg# func_mktempdir [string]
145659607e0Smrg# Make a temporary directory that won't clash with other running
146659607e0Smrg# libtool processes, and avoids race conditions if possible.  If
147659607e0Smrg# given, STRING is the basename for that directory.
148659607e0Smrgfunc_mktempdir ()
149659607e0Smrg{
150659607e0Smrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
151659607e0Smrg
152659607e0Smrg    if test "$run" = ":"; then
153659607e0Smrg      # Return a directory name, but don't create it in dry-run mode
154659607e0Smrg      my_tmpdir="${my_template}-$$"
155659607e0Smrg    else
156659607e0Smrg
157659607e0Smrg      # If mktemp works, use that first and foremost
158659607e0Smrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
159659607e0Smrg
160659607e0Smrg      if test ! -d "$my_tmpdir"; then
161659607e0Smrg	# Failing that, at least try and use $RANDOM to avoid a race
162659607e0Smrg	my_tmpdir="${my_template}-${RANDOM-0}$$"
163659607e0Smrg
164659607e0Smrg	save_mktempdir_umask=`umask`
165659607e0Smrg	umask 0077
166659607e0Smrg	$mkdir "$my_tmpdir"
167659607e0Smrg	umask $save_mktempdir_umask
168659607e0Smrg      fi
169659607e0Smrg
170659607e0Smrg      # If we're not in dry-run mode, bomb out on failure
171659607e0Smrg      test -d "$my_tmpdir" || {
172659607e0Smrg        $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
173659607e0Smrg	exit $EXIT_FAILURE
174659607e0Smrg      }
175659607e0Smrg    fi
176659607e0Smrg
177659607e0Smrg    $echo "X$my_tmpdir" | $Xsed
178659607e0Smrg}
179659607e0Smrg
180659607e0Smrg
181659607e0Smrg# func_win32_libid arg
182659607e0Smrg# return the library type of file 'arg'
183659607e0Smrg#
184659607e0Smrg# Need a lot of goo to handle *both* DLLs and import libs
185659607e0Smrg# Has to be a shell function in order to 'eat' the argument
186659607e0Smrg# that is supplied when $file_magic_command is called.
187659607e0Smrgfunc_win32_libid ()
188659607e0Smrg{
189659607e0Smrg  win32_libid_type="unknown"
190659607e0Smrg  win32_fileres=`file -L $1 2>/dev/null`
191659607e0Smrg  case $win32_fileres in
192659607e0Smrg  *ar\ archive\ import\ library*) # definitely import
193659607e0Smrg    win32_libid_type="x86 archive import"
194659607e0Smrg    ;;
195659607e0Smrg  *ar\ archive*) # could be an import, or static
196659607e0Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
197659607e0Smrg      $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
198659607e0Smrg      win32_nmres=`eval $NM -f posix -A $1 | \
1996aab59a7Smrg	$SED -n -e '1,100{/ I /{s,.*,import,;p;q;};}'`
200659607e0Smrg      case $win32_nmres in
201659607e0Smrg      import*)  win32_libid_type="x86 archive import";;
202659607e0Smrg      *)        win32_libid_type="x86 archive static";;
203659607e0Smrg      esac
204659607e0Smrg    fi
205659607e0Smrg    ;;
206659607e0Smrg  *DLL*)
207659607e0Smrg    win32_libid_type="x86 DLL"
208659607e0Smrg    ;;
209659607e0Smrg  *executable*) # but shell scripts are "executable" too...
210659607e0Smrg    case $win32_fileres in
211659607e0Smrg    *MS\ Windows\ PE\ Intel*)
212659607e0Smrg      win32_libid_type="x86 DLL"
213659607e0Smrg      ;;
214659607e0Smrg    esac
215659607e0Smrg    ;;
216659607e0Smrg  esac
217659607e0Smrg  $echo $win32_libid_type
218659607e0Smrg}
219659607e0Smrg
220659607e0Smrg
221659607e0Smrg# func_infer_tag arg
222659607e0Smrg# Infer tagged configuration to use if any are available and
223659607e0Smrg# if one wasn't chosen via the "--tag" command line option.
224659607e0Smrg# Only attempt this if the compiler in the base compile
225659607e0Smrg# command doesn't match the default compiler.
226659607e0Smrg# arg is usually of the form 'gcc ...'
227659607e0Smrgfunc_infer_tag ()
228659607e0Smrg{
229659607e0Smrg    if test -n "$available_tags" && test -z "$tagname"; then
230659607e0Smrg      CC_quoted=
231659607e0Smrg      for arg in $CC; do
232659607e0Smrg	case $arg in
233659607e0Smrg	  *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
234659607e0Smrg	  arg="\"$arg\""
235659607e0Smrg	  ;;
236659607e0Smrg	esac
237659607e0Smrg	CC_quoted="$CC_quoted $arg"
238659607e0Smrg      done
239659607e0Smrg      case $@ in
240659607e0Smrg      # Blanks in the command may have been stripped by the calling shell,
241659607e0Smrg      # but not from the CC environment variable when configure was run.
242659607e0Smrg      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
243659607e0Smrg      # Blanks at the start of $base_compile will cause this to fail
244659607e0Smrg      # if we don't check for them as well.
245659607e0Smrg      *)
246659607e0Smrg	for z in $available_tags; do
247659607e0Smrg	  if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
248659607e0Smrg	    # Evaluate the configuration.
249659607e0Smrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
250659607e0Smrg	    CC_quoted=
251659607e0Smrg	    for arg in $CC; do
252659607e0Smrg	    # Double-quote args containing other shell metacharacters.
253659607e0Smrg	    case $arg in
254659607e0Smrg	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
255659607e0Smrg	      arg="\"$arg\""
256659607e0Smrg	      ;;
257659607e0Smrg	    esac
258659607e0Smrg	    CC_quoted="$CC_quoted $arg"
259659607e0Smrg	  done
260659607e0Smrg	    case "$@ " in
261659607e0Smrg	      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
262659607e0Smrg	      # The compiler in the base compile command matches
263659607e0Smrg	      # the one in the tagged configuration.
264659607e0Smrg	      # Assume this is the tagged configuration we want.
265659607e0Smrg	      tagname=$z
266659607e0Smrg	      break
267659607e0Smrg	      ;;
268659607e0Smrg	    esac
269659607e0Smrg	  fi
270659607e0Smrg	done
271659607e0Smrg	# If $tagname still isn't set, then no tagged configuration
272659607e0Smrg	# was found and let the user know that the "--tag" command
273659607e0Smrg	# line option must be used.
274659607e0Smrg	if test -z "$tagname"; then
275659607e0Smrg	  $echo "$modename: unable to infer tagged configuration"
276659607e0Smrg	  $echo "$modename: specify a tag with \`--tag'" 1>&2
277659607e0Smrg	  exit $EXIT_FAILURE
278659607e0Smrg#        else
279659607e0Smrg#          $echo "$modename: using $tagname tagged configuration"
280659607e0Smrg	fi
281659607e0Smrg	;;
282659607e0Smrg      esac
283659607e0Smrg    fi
284659607e0Smrg}
285659607e0Smrg
286659607e0Smrg
287659607e0Smrg# func_extract_an_archive dir oldlib
288659607e0Smrgfunc_extract_an_archive ()
289659607e0Smrg{
290659607e0Smrg    f_ex_an_ar_dir="$1"; shift
291659607e0Smrg    f_ex_an_ar_oldlib="$1"
292659607e0Smrg
293659607e0Smrg    $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
294659607e0Smrg    $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
295659607e0Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
296659607e0Smrg     :
297659607e0Smrg    else
298659607e0Smrg      $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
299659607e0Smrg      exit $EXIT_FAILURE
300659607e0Smrg    fi
301659607e0Smrg}
302659607e0Smrg
303659607e0Smrg# func_extract_archives gentop oldlib ...
304659607e0Smrgfunc_extract_archives ()
305659607e0Smrg{
306659607e0Smrg    my_gentop="$1"; shift
307659607e0Smrg    my_oldlibs=${1+"$@"}
308659607e0Smrg    my_oldobjs=""
309659607e0Smrg    my_xlib=""
310659607e0Smrg    my_xabs=""
311659607e0Smrg    my_xdir=""
312659607e0Smrg    my_status=""
313659607e0Smrg
314659607e0Smrg    $show "${rm}r $my_gentop"
315659607e0Smrg    $run ${rm}r "$my_gentop"
316659607e0Smrg    $show "$mkdir $my_gentop"
317659607e0Smrg    $run $mkdir "$my_gentop"
318659607e0Smrg    my_status=$?
319659607e0Smrg    if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
320659607e0Smrg      exit $my_status
321659607e0Smrg    fi
322659607e0Smrg
323659607e0Smrg    for my_xlib in $my_oldlibs; do
324659607e0Smrg      # Extract the objects.
325659607e0Smrg      case $my_xlib in
326659607e0Smrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
327659607e0Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
328659607e0Smrg      esac
329659607e0Smrg      my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
3306aab59a7Smrg      my_xdir="$my_gentop/$my_xlib"
331659607e0Smrg
332659607e0Smrg      $show "${rm}r $my_xdir"
333659607e0Smrg      $run ${rm}r "$my_xdir"
334659607e0Smrg      $show "$mkdir $my_xdir"
335659607e0Smrg      $run $mkdir "$my_xdir"
336659607e0Smrg      exit_status=$?
337659607e0Smrg      if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
338659607e0Smrg	exit $exit_status
339659607e0Smrg      fi
340659607e0Smrg      case $host in
341659607e0Smrg      *-darwin*)
342659607e0Smrg	$show "Extracting $my_xabs"
343659607e0Smrg	# Do not bother doing anything if just a dry run
344659607e0Smrg	if test -z "$run"; then
345659607e0Smrg	  darwin_orig_dir=`pwd`
346659607e0Smrg	  cd $my_xdir || exit $?
347659607e0Smrg	  darwin_archive=$my_xabs
348659607e0Smrg	  darwin_curdir=`pwd`
349659607e0Smrg	  darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
350659607e0Smrg	  darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
351659607e0Smrg	  if test -n "$darwin_arches"; then 
352659607e0Smrg	    darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
353659607e0Smrg	    darwin_arch=
354659607e0Smrg	    $show "$darwin_base_archive has multiple architectures $darwin_arches"
355659607e0Smrg	    for darwin_arch in  $darwin_arches ; do
356659607e0Smrg	      mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
357659607e0Smrg	      lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
358659607e0Smrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
359659607e0Smrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
360659607e0Smrg	      cd "$darwin_curdir"
361659607e0Smrg	      $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
362659607e0Smrg	    done # $darwin_arches
363659607e0Smrg      ## Okay now we have a bunch of thin objects, gotta fatten them up :)
364659607e0Smrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
365659607e0Smrg	    darwin_file=
366659607e0Smrg	    darwin_files=
367659607e0Smrg	    for darwin_file in $darwin_filelist; do
368659607e0Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
369659607e0Smrg	      lipo -create -output "$darwin_file" $darwin_files
370659607e0Smrg	    done # $darwin_filelist
371659607e0Smrg	    ${rm}r unfat-$$
372659607e0Smrg	    cd "$darwin_orig_dir"
373659607e0Smrg	  else
374659607e0Smrg	    cd "$darwin_orig_dir"
375659607e0Smrg 	    func_extract_an_archive "$my_xdir" "$my_xabs"
376659607e0Smrg	  fi # $darwin_arches
377659607e0Smrg	fi # $run
378659607e0Smrg	;;
379659607e0Smrg      *)
380659607e0Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
381659607e0Smrg        ;;
382659607e0Smrg      esac
383659607e0Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
384659607e0Smrg    done
385659607e0Smrg    func_extract_archives_result="$my_oldobjs"
386659607e0Smrg}
387659607e0Smrg# End of Shell function definitions
388659607e0Smrg#####################################
389659607e0Smrg
390659607e0Smrg# Darwin sucks
391659607e0Smrgeval std_shrext=\"$shrext_cmds\"
392659607e0Smrg
393659607e0Smrgdisable_libs=no
394659607e0Smrg
395659607e0Smrg# Parse our command line options once, thoroughly.
396659607e0Smrgwhile test "$#" -gt 0
397659607e0Smrgdo
398659607e0Smrg  arg="$1"
399659607e0Smrg  shift
400659607e0Smrg
401659607e0Smrg  case $arg in
402659607e0Smrg  -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
403659607e0Smrg  *) optarg= ;;
404659607e0Smrg  esac
405659607e0Smrg
406659607e0Smrg  # If the previous option needs an argument, assign it.
407659607e0Smrg  if test -n "$prev"; then
408659607e0Smrg    case $prev in
409659607e0Smrg    execute_dlfiles)
410659607e0Smrg      execute_dlfiles="$execute_dlfiles $arg"
411659607e0Smrg      ;;
412659607e0Smrg    tag)
413659607e0Smrg      tagname="$arg"
414659607e0Smrg      preserve_args="${preserve_args}=$arg"
415659607e0Smrg
416659607e0Smrg      # Check whether tagname contains only valid characters
417659607e0Smrg      case $tagname in
418659607e0Smrg      *[!-_A-Za-z0-9,/]*)
419659607e0Smrg	$echo "$progname: invalid tag name: $tagname" 1>&2
420659607e0Smrg	exit $EXIT_FAILURE
421659607e0Smrg	;;
422659607e0Smrg      esac
423659607e0Smrg
424659607e0Smrg      case $tagname in
425659607e0Smrg      CC)
426659607e0Smrg	# Don't test for the "default" C tag, as we know, it's there, but
427659607e0Smrg	# not specially marked.
428659607e0Smrg	;;
429659607e0Smrg      *)
430659607e0Smrg	if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
431659607e0Smrg	  taglist="$taglist $tagname"
432659607e0Smrg	  # Evaluate the configuration.
433659607e0Smrg	  eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
434659607e0Smrg	else
435659607e0Smrg	  $echo "$progname: ignoring unknown tag $tagname" 1>&2
436659607e0Smrg	fi
437659607e0Smrg	;;
438659607e0Smrg      esac
439659607e0Smrg      ;;
440659607e0Smrg    *)
441659607e0Smrg      eval "$prev=\$arg"
442659607e0Smrg      ;;
443659607e0Smrg    esac
444659607e0Smrg
445659607e0Smrg    prev=
446659607e0Smrg    prevopt=
447659607e0Smrg    continue
448659607e0Smrg  fi
449659607e0Smrg
450659607e0Smrg  # Have we seen a non-optional argument yet?
451659607e0Smrg  case $arg in
452659607e0Smrg  --help)
453659607e0Smrg    show_help=yes
454659607e0Smrg    ;;
455659607e0Smrg
456659607e0Smrg  --version)
4576aab59a7Smrg    $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
4586aab59a7Smrg    $echo
4596aab59a7Smrg    $echo "Copyright (C) 2005  Free Software Foundation, Inc."
4606aab59a7Smrg    $echo "This is free software; see the source for copying conditions.  There is NO"
4616aab59a7Smrg    $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
462659607e0Smrg    exit $?
463659607e0Smrg    ;;
464659607e0Smrg
465659607e0Smrg  --config)
466659607e0Smrg    ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
467659607e0Smrg    # Now print the configurations for the tags.
468659607e0Smrg    for tagname in $taglist; do
469659607e0Smrg      ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
470659607e0Smrg    done
471659607e0Smrg    exit $?
472659607e0Smrg    ;;
473659607e0Smrg
474659607e0Smrg  --debug)
475659607e0Smrg    $echo "$progname: enabling shell trace mode"
476659607e0Smrg    set -x
477659607e0Smrg    preserve_args="$preserve_args $arg"
478659607e0Smrg    ;;
479659607e0Smrg
480659607e0Smrg  --dry-run | -n)
481659607e0Smrg    run=:
482659607e0Smrg    ;;
483659607e0Smrg
484659607e0Smrg  --features)
485659607e0Smrg    $echo "host: $host"
486659607e0Smrg    if test "$build_libtool_libs" = yes; then
487659607e0Smrg      $echo "enable shared libraries"
488659607e0Smrg    else
489659607e0Smrg      $echo "disable shared libraries"
490659607e0Smrg    fi
491659607e0Smrg    if test "$build_old_libs" = yes; then
492659607e0Smrg      $echo "enable static libraries"
493659607e0Smrg    else
494659607e0Smrg      $echo "disable static libraries"
495659607e0Smrg    fi
496659607e0Smrg    exit $?
497659607e0Smrg    ;;
498659607e0Smrg
499659607e0Smrg  --finish) mode="finish" ;;
500659607e0Smrg
501659607e0Smrg  --mode) prevopt="--mode" prev=mode ;;
502659607e0Smrg  --mode=*) mode="$optarg" ;;
503659607e0Smrg
504659607e0Smrg  --preserve-dup-deps) duplicate_deps="yes" ;;
505659607e0Smrg
506659607e0Smrg  --quiet | --silent)
507659607e0Smrg    show=:
508659607e0Smrg    preserve_args="$preserve_args $arg"
509659607e0Smrg    ;;
510659607e0Smrg
511659607e0Smrg  --tag)
512659607e0Smrg    prevopt="--tag"
513659607e0Smrg    prev=tag
514659607e0Smrg    preserve_args="$preserve_args --tag"
515659607e0Smrg    ;;
516659607e0Smrg  --tag=*)
517659607e0Smrg    set tag "$optarg" ${1+"$@"}
518659607e0Smrg    shift
519659607e0Smrg    prev=tag
520659607e0Smrg    preserve_args="$preserve_args --tag"
521659607e0Smrg    ;;
522659607e0Smrg
523659607e0Smrg  -dlopen)
524659607e0Smrg    prevopt="-dlopen"
525659607e0Smrg    prev=execute_dlfiles
526659607e0Smrg    ;;
527659607e0Smrg
528659607e0Smrg  -*)
529659607e0Smrg    $echo "$modename: unrecognized option \`$arg'" 1>&2
530659607e0Smrg    $echo "$help" 1>&2
531659607e0Smrg    exit $EXIT_FAILURE
532659607e0Smrg    ;;
533659607e0Smrg
534659607e0Smrg  *)
535659607e0Smrg    nonopt="$arg"
536659607e0Smrg    break
537659607e0Smrg    ;;
538659607e0Smrg  esac
539659607e0Smrgdone
540659607e0Smrg
541659607e0Smrgif test -n "$prevopt"; then
542659607e0Smrg  $echo "$modename: option \`$prevopt' requires an argument" 1>&2
543659607e0Smrg  $echo "$help" 1>&2
544659607e0Smrg  exit $EXIT_FAILURE
545659607e0Smrgfi
546659607e0Smrg
547659607e0Smrgcase $disable_libs in
548659607e0Smrgno) 
549659607e0Smrg  ;;
550659607e0Smrgshared)
551659607e0Smrg  build_libtool_libs=no
552659607e0Smrg  build_old_libs=yes
553659607e0Smrg  ;;
554659607e0Smrgstatic)
555659607e0Smrg  build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
556659607e0Smrg  ;;
557659607e0Smrgesac
558659607e0Smrg
559659607e0Smrg# If this variable is set in any of the actions, the command in it
560659607e0Smrg# will be execed at the end.  This prevents here-documents from being
561659607e0Smrg# left over by shells.
562659607e0Smrgexec_cmd=
563659607e0Smrg
564659607e0Smrgif test -z "$show_help"; then
565659607e0Smrg
566659607e0Smrg  # Infer the operation mode.
567659607e0Smrg  if test -z "$mode"; then
568659607e0Smrg    $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
569659607e0Smrg    $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
570659607e0Smrg    case $nonopt in
571659607e0Smrg    *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
572659607e0Smrg      mode=link
573659607e0Smrg      for arg
574659607e0Smrg      do
575659607e0Smrg	case $arg in
576659607e0Smrg	-c)
577659607e0Smrg	   mode=compile
578659607e0Smrg	   break
579659607e0Smrg	   ;;
580659607e0Smrg	esac
581659607e0Smrg      done
582659607e0Smrg      ;;
583659607e0Smrg    *db | *dbx | *strace | *truss)
584659607e0Smrg      mode=execute
585659607e0Smrg      ;;
586659607e0Smrg    *install*|cp|mv)
587659607e0Smrg      mode=install
588659607e0Smrg      ;;
589659607e0Smrg    *rm)
590659607e0Smrg      mode=uninstall
591659607e0Smrg      ;;
592659607e0Smrg    *)
593659607e0Smrg      # If we have no mode, but dlfiles were specified, then do execute mode.
594659607e0Smrg      test -n "$execute_dlfiles" && mode=execute
595659607e0Smrg
596659607e0Smrg      # Just use the default operation mode.
597659607e0Smrg      if test -z "$mode"; then
598659607e0Smrg	if test -n "$nonopt"; then
599659607e0Smrg	  $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
600659607e0Smrg	else
601659607e0Smrg	  $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
602659607e0Smrg	fi
603659607e0Smrg      fi
604659607e0Smrg      ;;
605659607e0Smrg    esac
606659607e0Smrg  fi
607659607e0Smrg
608659607e0Smrg  # Only execute mode is allowed to have -dlopen flags.
609659607e0Smrg  if test -n "$execute_dlfiles" && test "$mode" != execute; then
610659607e0Smrg    $echo "$modename: unrecognized option \`-dlopen'" 1>&2
611659607e0Smrg    $echo "$help" 1>&2
612659607e0Smrg    exit $EXIT_FAILURE
613659607e0Smrg  fi
614659607e0Smrg
615659607e0Smrg  # Change the help message to a mode-specific one.
616659607e0Smrg  generic_help="$help"
617659607e0Smrg  help="Try \`$modename --help --mode=$mode' for more information."
618659607e0Smrg
619659607e0Smrg  # These modes are in order of execution frequency so that they run quickly.
620659607e0Smrg  case $mode in
621659607e0Smrg  # libtool compile mode
622659607e0Smrg  compile)
623659607e0Smrg    modename="$modename: compile"
624659607e0Smrg    # Get the compilation command and the source file.
625659607e0Smrg    base_compile=
626659607e0Smrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
627659607e0Smrg    suppress_opt=yes
628659607e0Smrg    suppress_output=
629659607e0Smrg    arg_mode=normal
630659607e0Smrg    libobj=
631659607e0Smrg    later=
632659607e0Smrg
633659607e0Smrg    for arg
634659607e0Smrg    do
635659607e0Smrg      case $arg_mode in
636659607e0Smrg      arg  )
637659607e0Smrg	# do not "continue".  Instead, add this to base_compile
638659607e0Smrg	lastarg="$arg"
639659607e0Smrg	arg_mode=normal
640659607e0Smrg	;;
641659607e0Smrg
642659607e0Smrg      target )
643659607e0Smrg	libobj="$arg"
644659607e0Smrg	arg_mode=normal
645659607e0Smrg	continue
646659607e0Smrg	;;
647659607e0Smrg
648659607e0Smrg      normal )
649659607e0Smrg	# Accept any command-line options.
650659607e0Smrg	case $arg in
651659607e0Smrg	-o)
652659607e0Smrg	  if test -n "$libobj" ; then
653659607e0Smrg	    $echo "$modename: you cannot specify \`-o' more than once" 1>&2
654659607e0Smrg	    exit $EXIT_FAILURE
655659607e0Smrg	  fi
656659607e0Smrg	  arg_mode=target
657659607e0Smrg	  continue
658659607e0Smrg	  ;;
659659607e0Smrg
660659607e0Smrg	-static | -prefer-pic | -prefer-non-pic)
661659607e0Smrg	  later="$later $arg"
662659607e0Smrg	  continue
663659607e0Smrg	  ;;
664659607e0Smrg
665659607e0Smrg	-no-suppress)
666659607e0Smrg	  suppress_opt=no
667659607e0Smrg	  continue
668659607e0Smrg	  ;;
669659607e0Smrg
670659607e0Smrg	-Xcompiler)
671659607e0Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
672659607e0Smrg	  continue      #  The current "srcfile" will either be retained or
673659607e0Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
674659607e0Smrg
675659607e0Smrg	-Wc,*)
676659607e0Smrg	  args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
677659607e0Smrg	  lastarg=
678659607e0Smrg	  save_ifs="$IFS"; IFS=','
679659607e0Smrg 	  for arg in $args; do
680659607e0Smrg	    IFS="$save_ifs"
681659607e0Smrg
682659607e0Smrg	    # Double-quote args containing other shell metacharacters.
683659607e0Smrg	    # Many Bourne shells cannot handle close brackets correctly
684659607e0Smrg	    # in scan sets, so we specify it separately.
685659607e0Smrg	    case $arg in
686659607e0Smrg	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
687659607e0Smrg	      arg="\"$arg\""
688659607e0Smrg	      ;;
689659607e0Smrg	    esac
690659607e0Smrg	    lastarg="$lastarg $arg"
691659607e0Smrg	  done
692659607e0Smrg	  IFS="$save_ifs"
693659607e0Smrg	  lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
694659607e0Smrg
695659607e0Smrg	  # Add the arguments to base_compile.
696659607e0Smrg	  base_compile="$base_compile $lastarg"
697659607e0Smrg	  continue
698659607e0Smrg	  ;;
699659607e0Smrg
700659607e0Smrg	* )
701659607e0Smrg	  # Accept the current argument as the source file.
702659607e0Smrg	  # The previous "srcfile" becomes the current argument.
703659607e0Smrg	  #
704659607e0Smrg	  lastarg="$srcfile"
705659607e0Smrg	  srcfile="$arg"
706659607e0Smrg	  ;;
707659607e0Smrg	esac  #  case $arg
708659607e0Smrg	;;
709659607e0Smrg      esac    #  case $arg_mode
710659607e0Smrg
711659607e0Smrg      # Aesthetically quote the previous argument.
712659607e0Smrg      lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
713659607e0Smrg
714659607e0Smrg      case $lastarg in
715659607e0Smrg      # Double-quote args containing other shell metacharacters.
716659607e0Smrg      # Many Bourne shells cannot handle close brackets correctly
717659607e0Smrg      # in scan sets, and some SunOS ksh mistreat backslash-escaping
718659607e0Smrg      # in scan sets (worked around with variable expansion),
719659607e0Smrg      # and furthermore cannot handle '|' '&' '(' ')' in scan sets 
720659607e0Smrg      # at all, so we specify them separately.
721659607e0Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
722659607e0Smrg	lastarg="\"$lastarg\""
723659607e0Smrg	;;
724659607e0Smrg      esac
725659607e0Smrg
726659607e0Smrg      base_compile="$base_compile $lastarg"
727659607e0Smrg    done # for arg
728659607e0Smrg
729659607e0Smrg    case $arg_mode in
730659607e0Smrg    arg)
731659607e0Smrg      $echo "$modename: you must specify an argument for -Xcompile"
732659607e0Smrg      exit $EXIT_FAILURE
733659607e0Smrg      ;;
734659607e0Smrg    target)
735659607e0Smrg      $echo "$modename: you must specify a target with \`-o'" 1>&2
736659607e0Smrg      exit $EXIT_FAILURE
737659607e0Smrg      ;;
738659607e0Smrg    *)
739659607e0Smrg      # Get the name of the library object.
740659607e0Smrg      [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
741659607e0Smrg      ;;
742659607e0Smrg    esac
743659607e0Smrg
744659607e0Smrg    # Recognize several different file suffixes.
745659607e0Smrg    # If the user specifies -o file.o, it is replaced with file.lo
746659607e0Smrg    xform='[cCFSifmso]'
747659607e0Smrg    case $libobj in
748659607e0Smrg    *.ada) xform=ada ;;
749659607e0Smrg    *.adb) xform=adb ;;
750659607e0Smrg    *.ads) xform=ads ;;
751659607e0Smrg    *.asm) xform=asm ;;
752659607e0Smrg    *.c++) xform=c++ ;;
753659607e0Smrg    *.cc) xform=cc ;;
754659607e0Smrg    *.ii) xform=ii ;;
755659607e0Smrg    *.class) xform=class ;;
756659607e0Smrg    *.cpp) xform=cpp ;;
757659607e0Smrg    *.cxx) xform=cxx ;;
7586aab59a7Smrg    *.f90) xform=f90 ;;
759659607e0Smrg    *.for) xform=for ;;
760659607e0Smrg    *.java) xform=java ;;
761659607e0Smrg    esac
762659607e0Smrg
763659607e0Smrg    libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
764659607e0Smrg
765659607e0Smrg    case $libobj in
766659607e0Smrg    *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
767659607e0Smrg    *)
768659607e0Smrg      $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
769659607e0Smrg      exit $EXIT_FAILURE
770659607e0Smrg      ;;
771659607e0Smrg    esac
772659607e0Smrg
773659607e0Smrg    func_infer_tag $base_compile
774659607e0Smrg
775659607e0Smrg    for arg in $later; do
776659607e0Smrg      case $arg in
777659607e0Smrg      -static)
778659607e0Smrg	build_old_libs=yes
779659607e0Smrg	continue
780659607e0Smrg	;;
781659607e0Smrg
782659607e0Smrg      -prefer-pic)
783659607e0Smrg	pic_mode=yes
784659607e0Smrg	continue
785659607e0Smrg	;;
786659607e0Smrg
787659607e0Smrg      -prefer-non-pic)
788659607e0Smrg	pic_mode=no
789659607e0Smrg	continue
790659607e0Smrg	;;
791659607e0Smrg      esac
792659607e0Smrg    done
793659607e0Smrg
794659607e0Smrg    qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
795659607e0Smrg    case $qlibobj in
796659607e0Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
797659607e0Smrg	qlibobj="\"$qlibobj\"" ;;
798659607e0Smrg    esac
799659607e0Smrg    test "X$libobj" != "X$qlibobj" \
800659607e0Smrg	&& $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' 	&()|`$[]' \
801659607e0Smrg	&& $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
802659607e0Smrg    objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
803659607e0Smrg    xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
804659607e0Smrg    if test "X$xdir" = "X$obj"; then
805659607e0Smrg      xdir=
806659607e0Smrg    else
807659607e0Smrg      xdir=$xdir/
808659607e0Smrg    fi
809659607e0Smrg    lobj=${xdir}$objdir/$objname
810659607e0Smrg
811659607e0Smrg    if test -z "$base_compile"; then
812659607e0Smrg      $echo "$modename: you must specify a compilation command" 1>&2
813659607e0Smrg      $echo "$help" 1>&2
814659607e0Smrg      exit $EXIT_FAILURE
815659607e0Smrg    fi
816659607e0Smrg
817659607e0Smrg    # Delete any leftover library objects.
818659607e0Smrg    if test "$build_old_libs" = yes; then
819659607e0Smrg      removelist="$obj $lobj $libobj ${libobj}T"
820659607e0Smrg    else
821659607e0Smrg      removelist="$lobj $libobj ${libobj}T"
822659607e0Smrg    fi
823659607e0Smrg
824659607e0Smrg    $run $rm $removelist
825659607e0Smrg    trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
826659607e0Smrg
827659607e0Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
828659607e0Smrg    case $host_os in
829659607e0Smrg    cygwin* | mingw* | pw32* | os2*)
830659607e0Smrg      pic_mode=default
831659607e0Smrg      ;;
832659607e0Smrg    esac
833659607e0Smrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
834659607e0Smrg      # non-PIC code in shared libraries is not supported
835659607e0Smrg      pic_mode=default
836659607e0Smrg    fi
837659607e0Smrg
838659607e0Smrg    # Calculate the filename of the output object if compiler does
839659607e0Smrg    # not support -o with -c
840659607e0Smrg    if test "$compiler_c_o" = no; then
841659607e0Smrg      output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
842659607e0Smrg      lockfile="$output_obj.lock"
843659607e0Smrg      removelist="$removelist $output_obj $lockfile"
844659607e0Smrg      trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
845659607e0Smrg    else
846659607e0Smrg      output_obj=
847659607e0Smrg      need_locks=no
848659607e0Smrg      lockfile=
849659607e0Smrg    fi
850659607e0Smrg
851659607e0Smrg    # Lock this critical section if it is needed
852659607e0Smrg    # We use this script file to make the link, it avoids creating a new file
853659607e0Smrg    if test "$need_locks" = yes; then
854659607e0Smrg      until $run ln "$progpath" "$lockfile" 2>/dev/null; do
855659607e0Smrg	$show "Waiting for $lockfile to be removed"
856659607e0Smrg	sleep 2
857659607e0Smrg      done
858659607e0Smrg    elif test "$need_locks" = warn; then
859659607e0Smrg      if test -f "$lockfile"; then
860659607e0Smrg	$echo "\
861659607e0Smrg*** ERROR, $lockfile exists and contains:
862659607e0Smrg`cat $lockfile 2>/dev/null`
863659607e0Smrg
864659607e0SmrgThis indicates that another process is trying to use the same
865659607e0Smrgtemporary object file, and libtool could not work around it because
866659607e0Smrgyour compiler does not support \`-c' and \`-o' together.  If you
867659607e0Smrgrepeat this compilation, it may succeed, by chance, but you had better
868659607e0Smrgavoid parallel builds (make -j) in this platform, or get a better
869659607e0Smrgcompiler."
870659607e0Smrg
871659607e0Smrg	$run $rm $removelist
872659607e0Smrg	exit $EXIT_FAILURE
873659607e0Smrg      fi
874659607e0Smrg      $echo "$srcfile" > "$lockfile"
875659607e0Smrg    fi
876659607e0Smrg
877659607e0Smrg    if test -n "$fix_srcfile_path"; then
878659607e0Smrg      eval srcfile=\"$fix_srcfile_path\"
879659607e0Smrg    fi
880659607e0Smrg    qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"`
881659607e0Smrg    case $qsrcfile in
882659607e0Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
883659607e0Smrg      qsrcfile="\"$qsrcfile\"" ;;
884659607e0Smrg    esac
885659607e0Smrg
886659607e0Smrg    $run $rm "$libobj" "${libobj}T"
887659607e0Smrg
888659607e0Smrg    # Create a libtool object file (analogous to a ".la" file),
889659607e0Smrg    # but don't create it if we're doing a dry run.
890659607e0Smrg    test -z "$run" && cat > ${libobj}T <<EOF
891659607e0Smrg# $libobj - a libtool object file
892659607e0Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
893659607e0Smrg#
894659607e0Smrg# Please DO NOT delete this file!
895659607e0Smrg# It is necessary for linking the library.
896659607e0Smrg
897659607e0Smrg# Name of the PIC object.
898659607e0SmrgEOF
899659607e0Smrg
900659607e0Smrg    # Only build a PIC object if we are building libtool libraries.
901659607e0Smrg    if test "$build_libtool_libs" = yes; then
902659607e0Smrg      # Without this assignment, base_compile gets emptied.
903659607e0Smrg      fbsd_hideous_sh_bug=$base_compile
904659607e0Smrg
905659607e0Smrg      if test "$pic_mode" != no; then
906659607e0Smrg	command="$base_compile $qsrcfile $pic_flag"
907659607e0Smrg      else
908659607e0Smrg	# Don't build PIC code
909659607e0Smrg	command="$base_compile $qsrcfile"
910659607e0Smrg      fi
911659607e0Smrg
912659607e0Smrg      if test ! -d "${xdir}$objdir"; then
913659607e0Smrg	$show "$mkdir ${xdir}$objdir"
914659607e0Smrg	$run $mkdir ${xdir}$objdir
915659607e0Smrg	exit_status=$?
916659607e0Smrg	if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
917659607e0Smrg	  exit $exit_status
918659607e0Smrg	fi
919659607e0Smrg      fi
920659607e0Smrg
921659607e0Smrg      if test -z "$output_obj"; then
922659607e0Smrg	# Place PIC objects in $objdir
923659607e0Smrg	command="$command -o $lobj"
924659607e0Smrg      fi
925659607e0Smrg
926659607e0Smrg      $run $rm "$lobj" "$output_obj"
927659607e0Smrg
928659607e0Smrg      $show "$command"
929659607e0Smrg      if $run eval "$command"; then :
930659607e0Smrg      else
931659607e0Smrg	test -n "$output_obj" && $run $rm $removelist
932659607e0Smrg	exit $EXIT_FAILURE
933659607e0Smrg      fi
934659607e0Smrg
935659607e0Smrg      if test "$need_locks" = warn &&
936659607e0Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
937659607e0Smrg	$echo "\
938659607e0Smrg*** ERROR, $lockfile contains:
939659607e0Smrg`cat $lockfile 2>/dev/null`
940659607e0Smrg
941659607e0Smrgbut it should contain:
942659607e0Smrg$srcfile
943659607e0Smrg
944659607e0SmrgThis indicates that another process is trying to use the same
945659607e0Smrgtemporary object file, and libtool could not work around it because
946659607e0Smrgyour compiler does not support \`-c' and \`-o' together.  If you
947659607e0Smrgrepeat this compilation, it may succeed, by chance, but you had better
948659607e0Smrgavoid parallel builds (make -j) in this platform, or get a better
949659607e0Smrgcompiler."
950659607e0Smrg
951659607e0Smrg	$run $rm $removelist
952659607e0Smrg	exit $EXIT_FAILURE
953659607e0Smrg      fi
954659607e0Smrg
955659607e0Smrg      # Just move the object if needed, then go on to compile the next one
956659607e0Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
957659607e0Smrg	$show "$mv $output_obj $lobj"
958659607e0Smrg	if $run $mv $output_obj $lobj; then :
959659607e0Smrg	else
960659607e0Smrg	  error=$?
961659607e0Smrg	  $run $rm $removelist
962659607e0Smrg	  exit $error
963659607e0Smrg	fi
964659607e0Smrg      fi
965659607e0Smrg
966659607e0Smrg      # Append the name of the PIC object to the libtool object file.
967659607e0Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
968659607e0Smrgpic_object='$objdir/$objname'
969659607e0Smrg
970659607e0SmrgEOF
971659607e0Smrg
972659607e0Smrg      # Allow error messages only from the first compilation.
973659607e0Smrg      if test "$suppress_opt" = yes; then
974659607e0Smrg        suppress_output=' >/dev/null 2>&1'
975659607e0Smrg      fi
976659607e0Smrg    else
977659607e0Smrg      # No PIC object so indicate it doesn't exist in the libtool
978659607e0Smrg      # object file.
979659607e0Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
980659607e0Smrgpic_object=none
981659607e0Smrg
982659607e0SmrgEOF
983659607e0Smrg    fi
984659607e0Smrg
985659607e0Smrg    # Only build a position-dependent object if we build old libraries.
986659607e0Smrg    if test "$build_old_libs" = yes; then
987659607e0Smrg      if test "$pic_mode" != yes; then
988659607e0Smrg	# Don't build PIC code
989659607e0Smrg	command="$base_compile $qsrcfile"
990659607e0Smrg      else
991659607e0Smrg	command="$base_compile $qsrcfile $pic_flag"
992659607e0Smrg      fi
993659607e0Smrg      if test "$compiler_c_o" = yes; then
994659607e0Smrg	command="$command -o $obj"
995659607e0Smrg      fi
996659607e0Smrg
997659607e0Smrg      # Suppress compiler output if we already did a PIC compilation.
998659607e0Smrg      command="$command$suppress_output"
999659607e0Smrg      $run $rm "$obj" "$output_obj"
1000659607e0Smrg      $show "$command"
1001659607e0Smrg      if $run eval "$command"; then :
1002659607e0Smrg      else
1003659607e0Smrg	$run $rm $removelist
1004659607e0Smrg	exit $EXIT_FAILURE
1005659607e0Smrg      fi
1006659607e0Smrg
1007659607e0Smrg      if test "$need_locks" = warn &&
1008659607e0Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1009659607e0Smrg	$echo "\
1010659607e0Smrg*** ERROR, $lockfile contains:
1011659607e0Smrg`cat $lockfile 2>/dev/null`
1012659607e0Smrg
1013659607e0Smrgbut it should contain:
1014659607e0Smrg$srcfile
1015659607e0Smrg
1016659607e0SmrgThis indicates that another process is trying to use the same
1017659607e0Smrgtemporary object file, and libtool could not work around it because
1018659607e0Smrgyour compiler does not support \`-c' and \`-o' together.  If you
1019659607e0Smrgrepeat this compilation, it may succeed, by chance, but you had better
1020659607e0Smrgavoid parallel builds (make -j) in this platform, or get a better
1021659607e0Smrgcompiler."
1022659607e0Smrg
1023659607e0Smrg	$run $rm $removelist
1024659607e0Smrg	exit $EXIT_FAILURE
1025659607e0Smrg      fi
1026659607e0Smrg
1027659607e0Smrg      # Just move the object if needed
1028659607e0Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
1029659607e0Smrg	$show "$mv $output_obj $obj"
1030659607e0Smrg	if $run $mv $output_obj $obj; then :
1031659607e0Smrg	else
1032659607e0Smrg	  error=$?
1033659607e0Smrg	  $run $rm $removelist
1034659607e0Smrg	  exit $error
1035659607e0Smrg	fi
1036659607e0Smrg      fi
1037659607e0Smrg
1038659607e0Smrg      # Append the name of the non-PIC object the libtool object file.
1039659607e0Smrg      # Only append if the libtool object file exists.
1040659607e0Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
1041659607e0Smrg# Name of the non-PIC object.
1042659607e0Smrgnon_pic_object='$objname'
1043659607e0Smrg
1044659607e0SmrgEOF
1045659607e0Smrg    else
1046659607e0Smrg      # Append the name of the non-PIC object the libtool object file.
1047659607e0Smrg      # Only append if the libtool object file exists.
1048659607e0Smrg      test -z "$run" && cat >> ${libobj}T <<EOF
1049659607e0Smrg# Name of the non-PIC object.
1050659607e0Smrgnon_pic_object=none
1051659607e0Smrg
1052659607e0SmrgEOF
1053659607e0Smrg    fi
1054659607e0Smrg
1055659607e0Smrg    $run $mv "${libobj}T" "${libobj}"
1056659607e0Smrg
1057659607e0Smrg    # Unlock the critical section if it was locked
1058659607e0Smrg    if test "$need_locks" != no; then
1059659607e0Smrg      $run $rm "$lockfile"
1060659607e0Smrg    fi
1061659607e0Smrg
1062659607e0Smrg    exit $EXIT_SUCCESS
1063659607e0Smrg    ;;
1064659607e0Smrg
1065659607e0Smrg  # libtool link mode
1066659607e0Smrg  link | relink)
1067659607e0Smrg    modename="$modename: link"
1068659607e0Smrg    case $host in
1069659607e0Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
1070659607e0Smrg      # It is impossible to link a dll without this setting, and
1071659607e0Smrg      # we shouldn't force the makefile maintainer to figure out
1072659607e0Smrg      # which system we are compiling for in order to pass an extra
1073659607e0Smrg      # flag for every libtool invocation.
1074659607e0Smrg      # allow_undefined=no
1075659607e0Smrg
1076659607e0Smrg      # FIXME: Unfortunately, there are problems with the above when trying
1077659607e0Smrg      # to make a dll which has undefined symbols, in which case not
1078659607e0Smrg      # even a static library is built.  For now, we need to specify
1079659607e0Smrg      # -no-undefined on the libtool link line when we can be certain
1080659607e0Smrg      # that all symbols are satisfied, otherwise we get a static library.
1081659607e0Smrg      allow_undefined=yes
1082659607e0Smrg      ;;
1083659607e0Smrg    *)
1084659607e0Smrg      allow_undefined=yes
1085659607e0Smrg      ;;
1086659607e0Smrg    esac
1087659607e0Smrg    libtool_args="$nonopt"
1088659607e0Smrg    base_compile="$nonopt $@"
1089659607e0Smrg    compile_command="$nonopt"
1090659607e0Smrg    finalize_command="$nonopt"
1091659607e0Smrg
1092659607e0Smrg    compile_rpath=
1093659607e0Smrg    finalize_rpath=
1094659607e0Smrg    compile_shlibpath=
1095659607e0Smrg    finalize_shlibpath=
1096659607e0Smrg    convenience=
1097659607e0Smrg    old_convenience=
1098659607e0Smrg    deplibs=
1099659607e0Smrg    old_deplibs=
1100659607e0Smrg    compiler_flags=
1101659607e0Smrg    linker_flags=
1102659607e0Smrg    dllsearchpath=
1103659607e0Smrg    lib_search_path=`pwd`
1104659607e0Smrg    inst_prefix_dir=
1105659607e0Smrg
1106659607e0Smrg    avoid_version=no
1107659607e0Smrg    dlfiles=
1108659607e0Smrg    dlprefiles=
1109659607e0Smrg    dlself=no
1110659607e0Smrg    export_dynamic=no
1111659607e0Smrg    export_symbols=
1112659607e0Smrg    export_symbols_regex=
1113659607e0Smrg    generated=
1114659607e0Smrg    libobjs=
1115659607e0Smrg    ltlibs=
1116659607e0Smrg    module=no
1117659607e0Smrg    no_install=no
1118659607e0Smrg    objs=
1119659607e0Smrg    non_pic_objects=
1120659607e0Smrg    notinst_path= # paths that contain not-installed libtool libraries
1121659607e0Smrg    precious_files_regex=
1122659607e0Smrg    prefer_static_libs=no
1123659607e0Smrg    preload=no
1124659607e0Smrg    prev=
1125659607e0Smrg    prevarg=
1126659607e0Smrg    release=
1127659607e0Smrg    rpath=
1128659607e0Smrg    xrpath=
1129659607e0Smrg    perm_rpath=
1130659607e0Smrg    temp_rpath=
1131659607e0Smrg    thread_safe=no
1132659607e0Smrg    vinfo=
1133659607e0Smrg    vinfo_number=no
1134659607e0Smrg
1135659607e0Smrg    func_infer_tag $base_compile
1136659607e0Smrg
1137659607e0Smrg    # We need to know -static, to get the right output filenames.
1138659607e0Smrg    for arg
1139659607e0Smrg    do
1140659607e0Smrg      case $arg in
11416aab59a7Smrg      -all-static | -static)
11426aab59a7Smrg	if test "X$arg" = "X-all-static"; then
1143659607e0Smrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
1144659607e0Smrg	    $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
1145659607e0Smrg	  fi
1146659607e0Smrg	  if test -n "$link_static_flag"; then
1147659607e0Smrg	    dlopen_self=$dlopen_self_static
1148659607e0Smrg	  fi
1149659607e0Smrg	  prefer_static_libs=yes
11506aab59a7Smrg	else
1151659607e0Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
1152659607e0Smrg	    dlopen_self=$dlopen_self_static
1153659607e0Smrg	  fi
1154659607e0Smrg	  prefer_static_libs=built
11556aab59a7Smrg	fi
1156659607e0Smrg	build_libtool_libs=no
1157659607e0Smrg	build_old_libs=yes
1158659607e0Smrg	break
1159659607e0Smrg	;;
1160659607e0Smrg      esac
1161659607e0Smrg    done
1162659607e0Smrg
1163659607e0Smrg    # See if our shared archives depend on static archives.
1164659607e0Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
1165659607e0Smrg
1166659607e0Smrg    # Go through the arguments, transforming them on the way.
1167659607e0Smrg    while test "$#" -gt 0; do
1168659607e0Smrg      arg="$1"
1169659607e0Smrg      shift
1170659607e0Smrg      case $arg in
1171659607e0Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1172659607e0Smrg	qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
1173659607e0Smrg	;;
1174659607e0Smrg      *) qarg=$arg ;;
1175659607e0Smrg      esac
1176659607e0Smrg      libtool_args="$libtool_args $qarg"
1177659607e0Smrg
1178659607e0Smrg      # If the previous option needs an argument, assign it.
1179659607e0Smrg      if test -n "$prev"; then
1180659607e0Smrg	case $prev in
1181659607e0Smrg	output)
1182659607e0Smrg	  compile_command="$compile_command @OUTPUT@"
1183659607e0Smrg	  finalize_command="$finalize_command @OUTPUT@"
1184659607e0Smrg	  ;;
1185659607e0Smrg	esac
1186659607e0Smrg
1187659607e0Smrg	case $prev in
1188659607e0Smrg	dlfiles|dlprefiles)
1189659607e0Smrg	  if test "$preload" = no; then
1190659607e0Smrg	    # Add the symbol object into the linking commands.
1191659607e0Smrg	    compile_command="$compile_command @SYMFILE@"
1192659607e0Smrg	    finalize_command="$finalize_command @SYMFILE@"
1193659607e0Smrg	    preload=yes
1194659607e0Smrg	  fi
1195659607e0Smrg	  case $arg in
1196659607e0Smrg	  *.la | *.lo) ;;  # We handle these cases below.
1197659607e0Smrg	  force)
1198659607e0Smrg	    if test "$dlself" = no; then
1199659607e0Smrg	      dlself=needless
1200659607e0Smrg	      export_dynamic=yes
1201659607e0Smrg	    fi
1202659607e0Smrg	    prev=
1203659607e0Smrg	    continue
1204659607e0Smrg	    ;;
1205659607e0Smrg	  self)
1206659607e0Smrg	    if test "$prev" = dlprefiles; then
1207659607e0Smrg	      dlself=yes
1208659607e0Smrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
1209659607e0Smrg	      dlself=yes
1210659607e0Smrg	    else
1211659607e0Smrg	      dlself=needless
1212659607e0Smrg	      export_dynamic=yes
1213659607e0Smrg	    fi
1214659607e0Smrg	    prev=
1215659607e0Smrg	    continue
1216659607e0Smrg	    ;;
1217659607e0Smrg	  *)
1218659607e0Smrg	    if test "$prev" = dlfiles; then
1219659607e0Smrg	      dlfiles="$dlfiles $arg"
1220659607e0Smrg	    else
1221659607e0Smrg	      dlprefiles="$dlprefiles $arg"
1222659607e0Smrg	    fi
1223659607e0Smrg	    prev=
1224659607e0Smrg	    continue
1225659607e0Smrg	    ;;
1226659607e0Smrg	  esac
1227659607e0Smrg	  ;;
1228659607e0Smrg	expsyms)
1229659607e0Smrg	  export_symbols="$arg"
1230659607e0Smrg	  if test ! -f "$arg"; then
1231659607e0Smrg	    $echo "$modename: symbol file \`$arg' does not exist"
1232659607e0Smrg	    exit $EXIT_FAILURE
1233659607e0Smrg	  fi
1234659607e0Smrg	  prev=
1235659607e0Smrg	  continue
1236659607e0Smrg	  ;;
1237659607e0Smrg	expsyms_regex)
1238659607e0Smrg	  export_symbols_regex="$arg"
1239659607e0Smrg	  prev=
1240659607e0Smrg	  continue
1241659607e0Smrg	  ;;
1242659607e0Smrg	inst_prefix)
1243659607e0Smrg	  inst_prefix_dir="$arg"
1244659607e0Smrg	  prev=
1245659607e0Smrg	  continue
1246659607e0Smrg	  ;;
1247659607e0Smrg	precious_regex)
1248659607e0Smrg	  precious_files_regex="$arg"
1249659607e0Smrg	  prev=
1250659607e0Smrg	  continue
1251659607e0Smrg	  ;;
1252659607e0Smrg	release)
1253659607e0Smrg	  release="-$arg"
1254659607e0Smrg	  prev=
1255659607e0Smrg	  continue
1256659607e0Smrg	  ;;
1257659607e0Smrg	objectlist)
1258659607e0Smrg	  if test -f "$arg"; then
1259659607e0Smrg	    save_arg=$arg
1260659607e0Smrg	    moreargs=
1261659607e0Smrg	    for fil in `cat $save_arg`
1262659607e0Smrg	    do
1263659607e0Smrg#	      moreargs="$moreargs $fil"
1264659607e0Smrg	      arg=$fil
1265659607e0Smrg	      # A libtool-controlled object.
1266659607e0Smrg
1267659607e0Smrg	      # Check to see that this really is a libtool object.
1268659607e0Smrg	      if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
1269659607e0Smrg		pic_object=
1270659607e0Smrg		non_pic_object=
1271659607e0Smrg
1272659607e0Smrg		# Read the .lo file
1273659607e0Smrg		# If there is no directory component, then add one.
1274659607e0Smrg		case $arg in
1275659607e0Smrg		*/* | *\\*) . $arg ;;
1276659607e0Smrg		*) . ./$arg ;;
1277659607e0Smrg		esac
1278659607e0Smrg
1279659607e0Smrg		if test -z "$pic_object" || \
1280659607e0Smrg		   test -z "$non_pic_object" ||
1281659607e0Smrg		   test "$pic_object" = none && \
1282659607e0Smrg		   test "$non_pic_object" = none; then
1283659607e0Smrg		  $echo "$modename: cannot find name of object for \`$arg'" 1>&2
1284659607e0Smrg		  exit $EXIT_FAILURE
1285659607e0Smrg		fi
1286659607e0Smrg
1287659607e0Smrg		# Extract subdirectory from the argument.
1288659607e0Smrg		xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1289659607e0Smrg		if test "X$xdir" = "X$arg"; then
1290659607e0Smrg		  xdir=
1291659607e0Smrg		else
1292659607e0Smrg		  xdir="$xdir/"
1293659607e0Smrg		fi
1294659607e0Smrg
1295659607e0Smrg		if test "$pic_object" != none; then
1296659607e0Smrg		  # Prepend the subdirectory the object is found in.
1297659607e0Smrg		  pic_object="$xdir$pic_object"
1298659607e0Smrg
1299659607e0Smrg		  if test "$prev" = dlfiles; then
1300659607e0Smrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
1301659607e0Smrg		      dlfiles="$dlfiles $pic_object"
1302659607e0Smrg		      prev=
1303659607e0Smrg		      continue
1304659607e0Smrg		    else
1305659607e0Smrg		      # If libtool objects are unsupported, then we need to preload.
1306659607e0Smrg		      prev=dlprefiles
1307659607e0Smrg		    fi
1308659607e0Smrg		  fi
1309659607e0Smrg
1310659607e0Smrg		  # CHECK ME:  I think I busted this.  -Ossama
1311659607e0Smrg		  if test "$prev" = dlprefiles; then
1312659607e0Smrg		    # Preload the old-style object.
1313659607e0Smrg		    dlprefiles="$dlprefiles $pic_object"
1314659607e0Smrg		    prev=
1315659607e0Smrg		  fi
1316659607e0Smrg
1317659607e0Smrg		  # A PIC object.
1318659607e0Smrg		  libobjs="$libobjs $pic_object"
1319659607e0Smrg		  arg="$pic_object"
1320659607e0Smrg		fi
1321659607e0Smrg
1322659607e0Smrg		# Non-PIC object.
1323659607e0Smrg		if test "$non_pic_object" != none; then
1324659607e0Smrg		  # Prepend the subdirectory the object is found in.
1325659607e0Smrg		  non_pic_object="$xdir$non_pic_object"
1326659607e0Smrg
1327659607e0Smrg		  # A standard non-PIC object
1328659607e0Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
1329659607e0Smrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
1330659607e0Smrg		    arg="$non_pic_object"
1331659607e0Smrg		  fi
1332659607e0Smrg		else
1333659607e0Smrg		  # If the PIC object exists, use it instead.
1334659607e0Smrg		  # $xdir was prepended to $pic_object above.
1335659607e0Smrg		  non_pic_object="$pic_object"
1336659607e0Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
1337659607e0Smrg		fi
1338659607e0Smrg	      else
1339659607e0Smrg		# Only an error if not doing a dry-run.
1340659607e0Smrg		if test -z "$run"; then
1341659607e0Smrg		  $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
1342659607e0Smrg		  exit $EXIT_FAILURE
1343659607e0Smrg		else
1344659607e0Smrg		  # Dry-run case.
1345659607e0Smrg
1346659607e0Smrg		  # Extract subdirectory from the argument.
1347659607e0Smrg		  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1348659607e0Smrg		  if test "X$xdir" = "X$arg"; then
1349659607e0Smrg		    xdir=
1350659607e0Smrg		  else
1351659607e0Smrg		    xdir="$xdir/"
1352659607e0Smrg		  fi
1353659607e0Smrg
1354659607e0Smrg		  pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
1355659607e0Smrg		  non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
1356659607e0Smrg		  libobjs="$libobjs $pic_object"
1357659607e0Smrg		  non_pic_objects="$non_pic_objects $non_pic_object"
1358659607e0Smrg		fi
1359659607e0Smrg	      fi
1360659607e0Smrg	    done
1361659607e0Smrg	  else
1362659607e0Smrg	    $echo "$modename: link input file \`$save_arg' does not exist"
1363659607e0Smrg	    exit $EXIT_FAILURE
1364659607e0Smrg	  fi
1365659607e0Smrg	  arg=$save_arg
1366659607e0Smrg	  prev=
1367659607e0Smrg	  continue
1368659607e0Smrg	  ;;
1369659607e0Smrg	rpath | xrpath)
1370659607e0Smrg	  # We need an absolute path.
1371659607e0Smrg	  case $arg in
1372659607e0Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
1373659607e0Smrg	  *)
1374659607e0Smrg	    $echo "$modename: only absolute run-paths are allowed" 1>&2
1375659607e0Smrg	    exit $EXIT_FAILURE
1376659607e0Smrg	    ;;
1377659607e0Smrg	  esac
1378659607e0Smrg	  if test "$prev" = rpath; then
1379659607e0Smrg	    case "$rpath " in
1380659607e0Smrg	    *" $arg "*) ;;
1381659607e0Smrg	    *) rpath="$rpath $arg" ;;
1382659607e0Smrg	    esac
1383659607e0Smrg	  else
1384659607e0Smrg	    case "$xrpath " in
1385659607e0Smrg	    *" $arg "*) ;;
1386659607e0Smrg	    *) xrpath="$xrpath $arg" ;;
1387659607e0Smrg	    esac
1388659607e0Smrg	  fi
1389659607e0Smrg	  prev=
1390659607e0Smrg	  continue
1391659607e0Smrg	  ;;
1392659607e0Smrg	xcompiler)
1393659607e0Smrg	  compiler_flags="$compiler_flags $qarg"
1394659607e0Smrg	  prev=
1395659607e0Smrg	  compile_command="$compile_command $qarg"
1396659607e0Smrg	  finalize_command="$finalize_command $qarg"
1397659607e0Smrg	  continue
1398659607e0Smrg	  ;;
1399659607e0Smrg	xlinker)
1400659607e0Smrg	  linker_flags="$linker_flags $qarg"
1401659607e0Smrg	  compiler_flags="$compiler_flags $wl$qarg"
1402659607e0Smrg	  prev=
1403659607e0Smrg	  compile_command="$compile_command $wl$qarg"
1404659607e0Smrg	  finalize_command="$finalize_command $wl$qarg"
1405659607e0Smrg	  continue
1406659607e0Smrg	  ;;
1407659607e0Smrg	xcclinker)
1408659607e0Smrg	  linker_flags="$linker_flags $qarg"
1409659607e0Smrg	  compiler_flags="$compiler_flags $qarg"
1410659607e0Smrg	  prev=
1411659607e0Smrg	  compile_command="$compile_command $qarg"
1412659607e0Smrg	  finalize_command="$finalize_command $qarg"
1413659607e0Smrg	  continue
1414659607e0Smrg	  ;;
1415659607e0Smrg	shrext)
1416659607e0Smrg  	  shrext_cmds="$arg"
1417659607e0Smrg	  prev=
1418659607e0Smrg	  continue
1419659607e0Smrg	  ;;
1420659607e0Smrg	darwin_framework|darwin_framework_skip)
1421659607e0Smrg	  test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg"
1422659607e0Smrg	  compile_command="$compile_command $arg"
1423659607e0Smrg	  finalize_command="$finalize_command $arg"
1424659607e0Smrg	  prev=
1425659607e0Smrg	  continue
1426659607e0Smrg	  ;;
1427659607e0Smrg	*)
1428659607e0Smrg	  eval "$prev=\"\$arg\""
1429659607e0Smrg	  prev=
1430659607e0Smrg	  continue
1431659607e0Smrg	  ;;
1432659607e0Smrg	esac
1433659607e0Smrg      fi # test -n "$prev"
1434659607e0Smrg
1435659607e0Smrg      prevarg="$arg"
1436659607e0Smrg
1437659607e0Smrg      case $arg in
1438659607e0Smrg      -all-static)
1439659607e0Smrg	if test -n "$link_static_flag"; then
1440659607e0Smrg	  compile_command="$compile_command $link_static_flag"
1441659607e0Smrg	  finalize_command="$finalize_command $link_static_flag"
1442659607e0Smrg	fi
1443659607e0Smrg	continue
1444659607e0Smrg	;;
1445659607e0Smrg
1446659607e0Smrg      -allow-undefined)
1447659607e0Smrg	# FIXME: remove this flag sometime in the future.
1448659607e0Smrg	$echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
1449659607e0Smrg	continue
1450659607e0Smrg	;;
1451659607e0Smrg
1452659607e0Smrg      -avoid-version)
1453659607e0Smrg	avoid_version=yes
1454659607e0Smrg	continue
1455659607e0Smrg	;;
1456659607e0Smrg
1457659607e0Smrg      -dlopen)
1458659607e0Smrg	prev=dlfiles
1459659607e0Smrg	continue
1460659607e0Smrg	;;
1461659607e0Smrg
1462659607e0Smrg      -dlpreopen)
1463659607e0Smrg	prev=dlprefiles
1464659607e0Smrg	continue
1465659607e0Smrg	;;
1466659607e0Smrg
1467659607e0Smrg      -export-dynamic)
1468659607e0Smrg	export_dynamic=yes
1469659607e0Smrg	continue
1470659607e0Smrg	;;
1471659607e0Smrg
1472659607e0Smrg      -export-symbols | -export-symbols-regex)
1473659607e0Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
1474659607e0Smrg	  $echo "$modename: more than one -exported-symbols argument is not allowed"
1475659607e0Smrg	  exit $EXIT_FAILURE
1476659607e0Smrg	fi
1477659607e0Smrg	if test "X$arg" = "X-export-symbols"; then
1478659607e0Smrg	  prev=expsyms
1479659607e0Smrg	else
1480659607e0Smrg	  prev=expsyms_regex
1481659607e0Smrg	fi
1482659607e0Smrg	continue
1483659607e0Smrg	;;
1484659607e0Smrg
1485659607e0Smrg      -framework|-arch|-isysroot)
1486659607e0Smrg	case " $CC " in
1487659607e0Smrg	  *" ${arg} ${1} "* | *" ${arg}	${1} "*) 
1488659607e0Smrg		prev=darwin_framework_skip ;;
1489659607e0Smrg	  *) compiler_flags="$compiler_flags $arg"
1490659607e0Smrg	     prev=darwin_framework ;;
1491659607e0Smrg	esac
1492659607e0Smrg	compile_command="$compile_command $arg"
1493659607e0Smrg	finalize_command="$finalize_command $arg"
1494659607e0Smrg	continue
1495659607e0Smrg	;;
1496659607e0Smrg
1497659607e0Smrg      -inst-prefix-dir)
1498659607e0Smrg	prev=inst_prefix
1499659607e0Smrg	continue
1500659607e0Smrg	;;
1501659607e0Smrg
1502659607e0Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
1503659607e0Smrg      # so, if we see these flags be careful not to treat them like -L
1504659607e0Smrg      -L[A-Z][A-Z]*:*)
1505659607e0Smrg	case $with_gcc/$host in
1506659607e0Smrg	no/*-*-irix* | /*-*-irix*)
1507659607e0Smrg	  compile_command="$compile_command $arg"
1508659607e0Smrg	  finalize_command="$finalize_command $arg"
1509659607e0Smrg	  ;;
1510659607e0Smrg	esac
1511659607e0Smrg	continue
1512659607e0Smrg	;;
1513659607e0Smrg
1514659607e0Smrg      -L*)
1515659607e0Smrg	dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
1516659607e0Smrg	# We need an absolute path.
1517659607e0Smrg	case $dir in
1518659607e0Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
1519659607e0Smrg	*)
1520659607e0Smrg	  absdir=`cd "$dir" && pwd`
1521659607e0Smrg	  if test -z "$absdir"; then
1522659607e0Smrg	    $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
1523659607e0Smrg	    absdir="$dir"
1524659607e0Smrg	    notinst_path="$notinst_path $dir"
1525659607e0Smrg	  fi
1526659607e0Smrg	  dir="$absdir"
1527659607e0Smrg	  ;;
1528659607e0Smrg	esac
1529659607e0Smrg	case "$deplibs " in
1530659607e0Smrg	*" -L$dir "*) ;;
1531659607e0Smrg	*)
1532659607e0Smrg	  deplibs="$deplibs -L$dir"
1533659607e0Smrg	  lib_search_path="$lib_search_path $dir"
1534659607e0Smrg	  ;;
1535659607e0Smrg	esac
1536659607e0Smrg	case $host in
1537659607e0Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
1538659607e0Smrg	  testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'`
1539659607e0Smrg	  case :$dllsearchpath: in
1540659607e0Smrg	  *":$dir:"*) ;;
1541659607e0Smrg	  *) dllsearchpath="$dllsearchpath:$dir";;
1542659607e0Smrg	  esac
1543659607e0Smrg	  case :$dllsearchpath: in
1544659607e0Smrg	  *":$testbindir:"*) ;;
1545659607e0Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
1546659607e0Smrg	  esac
1547659607e0Smrg	  ;;
1548659607e0Smrg	esac
1549659607e0Smrg	continue
1550659607e0Smrg	;;
1551659607e0Smrg
1552659607e0Smrg      -l*)
1553659607e0Smrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
1554659607e0Smrg	  case $host in
1555659607e0Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
1556659607e0Smrg	    # These systems don't actually have a C or math library (as such)
1557659607e0Smrg	    continue
1558659607e0Smrg	    ;;
1559659607e0Smrg	  *-*-os2*)
1560659607e0Smrg	    # These systems don't actually have a C library (as such)
1561659607e0Smrg	    test "X$arg" = "X-lc" && continue
1562659607e0Smrg	    ;;
1563659607e0Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
1564659607e0Smrg	    # Do not include libc due to us having libc/libc_r.
1565659607e0Smrg	    test "X$arg" = "X-lc" && continue
1566659607e0Smrg	    ;;
1567659607e0Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
1568659607e0Smrg	    # Rhapsody C and math libraries are in the System framework
1569659607e0Smrg	    deplibs="$deplibs -framework System"
1570659607e0Smrg	    continue
1571659607e0Smrg	    ;;
1572659607e0Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
1573659607e0Smrg	    # Causes problems with __ctype
1574659607e0Smrg	    test "X$arg" = "X-lc" && continue
1575659607e0Smrg	    ;;
1576659607e0Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
1577659607e0Smrg	    # Compiler inserts libc in the correct place for threads to work
1578659607e0Smrg	    test "X$arg" = "X-lc" && continue
1579659607e0Smrg	    ;;
1580659607e0Smrg	  esac
1581659607e0Smrg	elif test "X$arg" = "X-lc_r"; then
1582659607e0Smrg	 case $host in
1583659607e0Smrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
1584659607e0Smrg	   # Do not include libc_r directly, use -pthread flag.
1585659607e0Smrg	   continue
1586659607e0Smrg	   ;;
1587659607e0Smrg	 esac
1588659607e0Smrg	fi
1589659607e0Smrg	deplibs="$deplibs $arg"
1590659607e0Smrg	continue
1591659607e0Smrg	;;
1592659607e0Smrg
1593659607e0Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
1594659607e0Smrg      # classes, name mangling, and exception handling.
1595659607e0Smrg      -model)
1596659607e0Smrg	compile_command="$compile_command $arg"
1597659607e0Smrg	compiler_flags="$compiler_flags $arg"
1598659607e0Smrg	finalize_command="$finalize_command $arg"
1599659607e0Smrg	prev=xcompiler
1600659607e0Smrg	continue
1601659607e0Smrg	;;
1602659607e0Smrg
16036aab59a7Smrg     -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
1604659607e0Smrg	compiler_flags="$compiler_flags $arg"
1605659607e0Smrg	compile_command="$compile_command $arg"
1606659607e0Smrg	finalize_command="$finalize_command $arg"
1607659607e0Smrg	continue
1608659607e0Smrg	;;
1609659607e0Smrg
1610659607e0Smrg      -module)
1611659607e0Smrg	module=yes
1612659607e0Smrg	continue
1613659607e0Smrg	;;
1614659607e0Smrg
1615659607e0Smrg      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
1616659607e0Smrg      # -r[0-9][0-9]* specifies the processor on the SGI compiler
1617659607e0Smrg      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
1618659607e0Smrg      # +DA*, +DD* enable 64-bit mode on the HP compiler
1619659607e0Smrg      # -q* pass through compiler args for the IBM compiler
1620659607e0Smrg      # -m* pass through architecture-specific compiler args for GCC
1621659607e0Smrg      # -m*, -t[45]*, -txscale* pass through architecture-specific
1622659607e0Smrg      # compiler args for GCC
16236aab59a7Smrg      # -pg pass through profiling flag for GCC
1624659607e0Smrg      # @file GCC response files
16256aab59a7Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*|-pg| \
16266aab59a7Smrg      -t[45]*|-txscale*|@*)
1627659607e0Smrg
1628659607e0Smrg	# Unknown arguments in both finalize_command and compile_command need
1629659607e0Smrg	# to be aesthetically quoted because they are evaled later.
1630659607e0Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1631659607e0Smrg	case $arg in
1632659607e0Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1633659607e0Smrg	  arg="\"$arg\""
1634659607e0Smrg	  ;;
1635659607e0Smrg	esac
1636659607e0Smrg        compile_command="$compile_command $arg"
1637659607e0Smrg        finalize_command="$finalize_command $arg"
1638659607e0Smrg        compiler_flags="$compiler_flags $arg"
1639659607e0Smrg        continue
1640659607e0Smrg        ;;
1641659607e0Smrg
1642659607e0Smrg      -shrext)
1643659607e0Smrg	prev=shrext
1644659607e0Smrg	continue
1645659607e0Smrg	;;
1646659607e0Smrg
1647659607e0Smrg      -no-fast-install)
1648659607e0Smrg	fast_install=no
1649659607e0Smrg	continue
1650659607e0Smrg	;;
1651659607e0Smrg
1652659607e0Smrg      -no-install)
1653659607e0Smrg	case $host in
16546aab59a7Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
1655659607e0Smrg	  # The PATH hackery in wrapper scripts is required on Windows
16566aab59a7Smrg	  # in order for the loader to find any dlls it needs.
1657659607e0Smrg	  $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
1658659607e0Smrg	  $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
1659659607e0Smrg	  fast_install=no
1660659607e0Smrg	  ;;
1661659607e0Smrg	*) no_install=yes ;;
1662659607e0Smrg	esac
1663659607e0Smrg	continue
1664659607e0Smrg	;;
1665659607e0Smrg
1666659607e0Smrg      -no-undefined)
1667659607e0Smrg	allow_undefined=no
1668659607e0Smrg	continue
1669659607e0Smrg	;;
1670659607e0Smrg
1671659607e0Smrg      -objectlist)
1672659607e0Smrg	prev=objectlist
1673659607e0Smrg	continue
1674659607e0Smrg	;;
1675659607e0Smrg
1676659607e0Smrg      -o) prev=output ;;
1677659607e0Smrg
1678659607e0Smrg      -precious-files-regex)
1679659607e0Smrg	prev=precious_regex
1680659607e0Smrg	continue
1681659607e0Smrg	;;
1682659607e0Smrg
1683659607e0Smrg      -release)
1684659607e0Smrg	prev=release
1685659607e0Smrg	continue
1686659607e0Smrg	;;
1687659607e0Smrg
1688659607e0Smrg      -rpath)
1689659607e0Smrg	prev=rpath
1690659607e0Smrg	continue
1691659607e0Smrg	;;
1692659607e0Smrg
1693659607e0Smrg      -R)
1694659607e0Smrg	prev=xrpath
1695659607e0Smrg	continue
1696659607e0Smrg	;;
1697659607e0Smrg
1698659607e0Smrg      -R*)
1699659607e0Smrg	dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
1700659607e0Smrg	# We need an absolute path.
1701659607e0Smrg	case $dir in
1702659607e0Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
1703659607e0Smrg	*)
1704659607e0Smrg	  $echo "$modename: only absolute run-paths are allowed" 1>&2
1705659607e0Smrg	  exit $EXIT_FAILURE
1706659607e0Smrg	  ;;
1707659607e0Smrg	esac
1708659607e0Smrg	case "$xrpath " in
1709659607e0Smrg	*" $dir "*) ;;
1710659607e0Smrg	*) xrpath="$xrpath $dir" ;;
1711659607e0Smrg	esac
1712659607e0Smrg	continue
1713659607e0Smrg	;;
1714659607e0Smrg
17156aab59a7Smrg      -static)
1716659607e0Smrg	# The effects of -static are defined in a previous loop.
1717659607e0Smrg	# We used to do the same as -all-static on platforms that
1718659607e0Smrg	# didn't have a PIC flag, but the assumption that the effects
1719659607e0Smrg	# would be equivalent was wrong.  It would break on at least
1720659607e0Smrg	# Digital Unix and AIX.
1721659607e0Smrg	continue
1722659607e0Smrg	;;
1723659607e0Smrg
1724659607e0Smrg      -thread-safe)
1725659607e0Smrg	thread_safe=yes
1726659607e0Smrg	continue
1727659607e0Smrg	;;
1728659607e0Smrg
1729659607e0Smrg      -version-info)
1730659607e0Smrg	prev=vinfo
1731659607e0Smrg	continue
1732659607e0Smrg	;;
1733659607e0Smrg      -version-number)
1734659607e0Smrg	prev=vinfo
1735659607e0Smrg	vinfo_number=yes
1736659607e0Smrg	continue
1737659607e0Smrg	;;
1738659607e0Smrg
1739659607e0Smrg      -Wc,*)
1740659607e0Smrg	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
1741659607e0Smrg	arg=
1742659607e0Smrg	save_ifs="$IFS"; IFS=','
1743659607e0Smrg	for flag in $args; do
1744659607e0Smrg	  IFS="$save_ifs"
1745659607e0Smrg	  case $flag in
1746659607e0Smrg	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1747659607e0Smrg	    flag="\"$flag\""
1748659607e0Smrg	    ;;
1749659607e0Smrg	  esac
1750659607e0Smrg	  arg="$arg $wl$flag"
1751659607e0Smrg	  compiler_flags="$compiler_flags $flag"
1752659607e0Smrg	done
1753659607e0Smrg	IFS="$save_ifs"
1754659607e0Smrg	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
1755659607e0Smrg	;;
1756659607e0Smrg
1757659607e0Smrg      -Wl,*)
1758659607e0Smrg	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
1759659607e0Smrg	arg=
1760659607e0Smrg	save_ifs="$IFS"; IFS=','
1761659607e0Smrg	for flag in $args; do
1762659607e0Smrg	  IFS="$save_ifs"
1763659607e0Smrg	  case $flag in
1764659607e0Smrg	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1765659607e0Smrg	    flag="\"$flag\""
1766659607e0Smrg	    ;;
1767659607e0Smrg	  esac
1768659607e0Smrg	  arg="$arg $wl$flag"
1769659607e0Smrg	  compiler_flags="$compiler_flags $wl$flag"
1770659607e0Smrg	  linker_flags="$linker_flags $flag"
1771659607e0Smrg	done
1772659607e0Smrg	IFS="$save_ifs"
1773659607e0Smrg	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
1774659607e0Smrg	;;
1775659607e0Smrg
1776659607e0Smrg      -Xcompiler)
1777659607e0Smrg	prev=xcompiler
1778659607e0Smrg	continue
1779659607e0Smrg	;;
1780659607e0Smrg
1781659607e0Smrg      -Xlinker)
1782659607e0Smrg	prev=xlinker
1783659607e0Smrg	continue
1784659607e0Smrg	;;
1785659607e0Smrg
1786659607e0Smrg      -XCClinker)
1787659607e0Smrg	prev=xcclinker
1788659607e0Smrg	continue
1789659607e0Smrg	;;
1790659607e0Smrg
1791659607e0Smrg      # Some other compiler flag.
1792659607e0Smrg      -* | +*)
1793659607e0Smrg	# Unknown arguments in both finalize_command and compile_command need
1794659607e0Smrg	# to be aesthetically quoted because they are evaled later.
1795659607e0Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1796659607e0Smrg	case $arg in
1797659607e0Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1798659607e0Smrg	  arg="\"$arg\""
1799659607e0Smrg	  ;;
1800659607e0Smrg	esac
1801659607e0Smrg	;;
1802659607e0Smrg
1803659607e0Smrg      *.$objext)
1804659607e0Smrg	# A standard object.
1805659607e0Smrg	objs="$objs $arg"
1806659607e0Smrg	;;
1807659607e0Smrg
1808659607e0Smrg      *.lo)
1809659607e0Smrg	# A libtool-controlled object.
1810659607e0Smrg
1811659607e0Smrg	# Check to see that this really is a libtool object.
1812659607e0Smrg	if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
1813659607e0Smrg	  pic_object=
1814659607e0Smrg	  non_pic_object=
1815659607e0Smrg
1816659607e0Smrg	  # Read the .lo file
1817659607e0Smrg	  # If there is no directory component, then add one.
1818659607e0Smrg	  case $arg in
1819659607e0Smrg	  */* | *\\*) . $arg ;;
1820659607e0Smrg	  *) . ./$arg ;;
1821659607e0Smrg	  esac
1822659607e0Smrg
1823659607e0Smrg	  if test -z "$pic_object" || \
1824659607e0Smrg	     test -z "$non_pic_object" ||
1825659607e0Smrg	     test "$pic_object" = none && \
1826659607e0Smrg	     test "$non_pic_object" = none; then
1827659607e0Smrg	    $echo "$modename: cannot find name of object for \`$arg'" 1>&2
1828659607e0Smrg	    exit $EXIT_FAILURE
1829659607e0Smrg	  fi
1830659607e0Smrg
1831659607e0Smrg	  # Extract subdirectory from the argument.
1832659607e0Smrg	  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1833659607e0Smrg	  if test "X$xdir" = "X$arg"; then
1834659607e0Smrg	    xdir=
1835659607e0Smrg 	  else
1836659607e0Smrg	    xdir="$xdir/"
1837659607e0Smrg	  fi
1838659607e0Smrg
1839659607e0Smrg	  if test "$pic_object" != none; then
1840659607e0Smrg	    # Prepend the subdirectory the object is found in.
1841659607e0Smrg	    pic_object="$xdir$pic_object"
1842659607e0Smrg
1843659607e0Smrg	    if test "$prev" = dlfiles; then
1844659607e0Smrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
1845659607e0Smrg		dlfiles="$dlfiles $pic_object"
1846659607e0Smrg		prev=
1847659607e0Smrg		continue
1848659607e0Smrg	      else
1849659607e0Smrg		# If libtool objects are unsupported, then we need to preload.
1850659607e0Smrg		prev=dlprefiles
1851659607e0Smrg	      fi
1852659607e0Smrg	    fi
1853659607e0Smrg
1854659607e0Smrg	    # CHECK ME:  I think I busted this.  -Ossama
1855659607e0Smrg	    if test "$prev" = dlprefiles; then
1856659607e0Smrg	      # Preload the old-style object.
1857659607e0Smrg	      dlprefiles="$dlprefiles $pic_object"
1858659607e0Smrg	      prev=
1859659607e0Smrg	    fi
1860659607e0Smrg
1861659607e0Smrg	    # A PIC object.
1862659607e0Smrg	    libobjs="$libobjs $pic_object"
1863659607e0Smrg	    arg="$pic_object"
1864659607e0Smrg	  fi
1865659607e0Smrg
1866659607e0Smrg	  # Non-PIC object.
1867659607e0Smrg	  if test "$non_pic_object" != none; then
1868659607e0Smrg	    # Prepend the subdirectory the object is found in.
1869659607e0Smrg	    non_pic_object="$xdir$non_pic_object"
1870659607e0Smrg
1871659607e0Smrg	    # A standard non-PIC object
1872659607e0Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
1873659607e0Smrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
1874659607e0Smrg	      arg="$non_pic_object"
1875659607e0Smrg	    fi
1876659607e0Smrg	  else
1877659607e0Smrg	    # If the PIC object exists, use it instead.
1878659607e0Smrg	    # $xdir was prepended to $pic_object above.
1879659607e0Smrg	    non_pic_object="$pic_object"
1880659607e0Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
1881659607e0Smrg	  fi
1882659607e0Smrg	else
1883659607e0Smrg	  # Only an error if not doing a dry-run.
1884659607e0Smrg	  if test -z "$run"; then
1885659607e0Smrg	    $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
1886659607e0Smrg	    exit $EXIT_FAILURE
1887659607e0Smrg	  else
1888659607e0Smrg	    # Dry-run case.
1889659607e0Smrg
1890659607e0Smrg	    # Extract subdirectory from the argument.
1891659607e0Smrg	    xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1892659607e0Smrg	    if test "X$xdir" = "X$arg"; then
1893659607e0Smrg	      xdir=
1894659607e0Smrg	    else
1895659607e0Smrg	      xdir="$xdir/"
1896659607e0Smrg	    fi
1897659607e0Smrg
1898659607e0Smrg	    pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
1899659607e0Smrg	    non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
1900659607e0Smrg	    libobjs="$libobjs $pic_object"
1901659607e0Smrg	    non_pic_objects="$non_pic_objects $non_pic_object"
1902659607e0Smrg	  fi
1903659607e0Smrg	fi
1904659607e0Smrg	;;
1905659607e0Smrg
1906659607e0Smrg      *.$libext)
1907659607e0Smrg	# An archive.
1908659607e0Smrg	deplibs="$deplibs $arg"
1909659607e0Smrg	old_deplibs="$old_deplibs $arg"
1910659607e0Smrg	continue
1911659607e0Smrg	;;
1912659607e0Smrg
1913659607e0Smrg      *.la)
1914659607e0Smrg	# A libtool-controlled library.
1915659607e0Smrg
1916659607e0Smrg	if test "$prev" = dlfiles; then
1917659607e0Smrg	  # This library was specified with -dlopen.
1918659607e0Smrg	  dlfiles="$dlfiles $arg"
1919659607e0Smrg	  prev=
1920659607e0Smrg	elif test "$prev" = dlprefiles; then
1921659607e0Smrg	  # The library was specified with -dlpreopen.
1922659607e0Smrg	  dlprefiles="$dlprefiles $arg"
1923659607e0Smrg	  prev=
1924659607e0Smrg	else
1925659607e0Smrg	  deplibs="$deplibs $arg"
1926659607e0Smrg	fi
1927659607e0Smrg	continue
1928659607e0Smrg	;;
1929659607e0Smrg
1930659607e0Smrg      # Some other compiler argument.
1931659607e0Smrg      *)
1932659607e0Smrg	# Unknown arguments in both finalize_command and compile_command need
1933659607e0Smrg	# to be aesthetically quoted because they are evaled later.
1934659607e0Smrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1935659607e0Smrg	case $arg in
1936659607e0Smrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1937659607e0Smrg	  arg="\"$arg\""
1938659607e0Smrg	  ;;
1939659607e0Smrg	esac
1940659607e0Smrg	;;
1941659607e0Smrg      esac # arg
1942659607e0Smrg
1943659607e0Smrg      # Now actually substitute the argument into the commands.
1944659607e0Smrg      if test -n "$arg"; then
1945659607e0Smrg	compile_command="$compile_command $arg"
1946659607e0Smrg	finalize_command="$finalize_command $arg"
1947659607e0Smrg      fi
1948659607e0Smrg    done # argument parsing loop
1949659607e0Smrg
1950659607e0Smrg    if test -n "$prev"; then
1951659607e0Smrg      $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
1952659607e0Smrg      $echo "$help" 1>&2
1953659607e0Smrg      exit $EXIT_FAILURE
1954659607e0Smrg    fi
1955659607e0Smrg
1956659607e0Smrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
1957659607e0Smrg      eval arg=\"$export_dynamic_flag_spec\"
1958659607e0Smrg      compile_command="$compile_command $arg"
1959659607e0Smrg      finalize_command="$finalize_command $arg"
1960659607e0Smrg    fi
1961659607e0Smrg
1962659607e0Smrg    oldlibs=
1963659607e0Smrg    # calculate the name of the file, without its directory
1964659607e0Smrg    outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
1965659607e0Smrg    libobjs_save="$libobjs"
1966659607e0Smrg
1967659607e0Smrg    if test -n "$shlibpath_var"; then
1968659607e0Smrg      # get the directories listed in $shlibpath_var
1969659607e0Smrg      eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
1970659607e0Smrg    else
1971659607e0Smrg      shlib_search_path=
1972659607e0Smrg    fi
1973659607e0Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
1974659607e0Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
1975659607e0Smrg
1976659607e0Smrg    output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
1977659607e0Smrg    if test "X$output_objdir" = "X$output"; then
1978659607e0Smrg      output_objdir="$objdir"
1979659607e0Smrg    else
1980659607e0Smrg      output_objdir="$output_objdir/$objdir"
1981659607e0Smrg    fi
1982659607e0Smrg    # Create the object directory.
1983659607e0Smrg    if test ! -d "$output_objdir"; then
1984659607e0Smrg      $show "$mkdir $output_objdir"
1985659607e0Smrg      $run $mkdir $output_objdir
1986659607e0Smrg      exit_status=$?
1987659607e0Smrg      if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then
1988659607e0Smrg	exit $exit_status
1989659607e0Smrg      fi
1990659607e0Smrg    fi
1991659607e0Smrg
1992659607e0Smrg    # Determine the type of output
1993659607e0Smrg    case $output in
1994659607e0Smrg    "")
1995659607e0Smrg      $echo "$modename: you must specify an output file" 1>&2
1996659607e0Smrg      $echo "$help" 1>&2
1997659607e0Smrg      exit $EXIT_FAILURE
1998659607e0Smrg      ;;
1999659607e0Smrg    *.$libext) linkmode=oldlib ;;
2000659607e0Smrg    *.lo | *.$objext) linkmode=obj ;;
2001659607e0Smrg    *.la) linkmode=lib ;;
2002659607e0Smrg    *) linkmode=prog ;; # Anything else should be a program.
2003659607e0Smrg    esac
2004659607e0Smrg
2005659607e0Smrg    case $host in
2006659607e0Smrg    *cygwin* | *mingw* | *pw32*)
2007659607e0Smrg      # don't eliminate duplications in $postdeps and $predeps
2008659607e0Smrg      duplicate_compiler_generated_deps=yes
2009659607e0Smrg      ;;
2010659607e0Smrg    *)
2011659607e0Smrg      duplicate_compiler_generated_deps=$duplicate_deps
2012659607e0Smrg      ;;
2013659607e0Smrg    esac
2014659607e0Smrg    specialdeplibs=
2015659607e0Smrg
2016659607e0Smrg    libs=
2017659607e0Smrg    # Find all interdependent deplibs by searching for libraries
2018659607e0Smrg    # that are linked more than once (e.g. -la -lb -la)
2019659607e0Smrg    for deplib in $deplibs; do
2020659607e0Smrg      if test "X$duplicate_deps" = "Xyes" ; then
2021659607e0Smrg	case "$libs " in
2022659607e0Smrg	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2023659607e0Smrg	esac
2024659607e0Smrg      fi
2025659607e0Smrg      libs="$libs $deplib"
2026659607e0Smrg    done
2027659607e0Smrg
2028659607e0Smrg    if test "$linkmode" = lib; then
2029659607e0Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
2030659607e0Smrg
2031659607e0Smrg      # Compute libraries that are listed more than once in $predeps
2032659607e0Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
2033659607e0Smrg      # not to be eliminated).
2034659607e0Smrg      pre_post_deps=
2035659607e0Smrg      if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
2036659607e0Smrg	for pre_post_dep in $predeps $postdeps; do
2037659607e0Smrg	  case "$pre_post_deps " in
2038659607e0Smrg	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
2039659607e0Smrg	  esac
2040659607e0Smrg	  pre_post_deps="$pre_post_deps $pre_post_dep"
2041659607e0Smrg	done
2042659607e0Smrg      fi
2043659607e0Smrg      pre_post_deps=
2044659607e0Smrg    fi
2045659607e0Smrg
2046659607e0Smrg    deplibs=
2047659607e0Smrg    newdependency_libs=
2048659607e0Smrg    newlib_search_path=
2049659607e0Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
2050659607e0Smrg    notinst_deplibs= # not-installed libtool libraries
2051659607e0Smrg    case $linkmode in
2052659607e0Smrg    lib)
2053659607e0Smrg	passes="conv link"
2054659607e0Smrg	for file in $dlfiles $dlprefiles; do
2055659607e0Smrg	  case $file in
2056659607e0Smrg	  *.la) ;;
2057659607e0Smrg	  *)
2058659607e0Smrg	    $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
2059659607e0Smrg	    exit $EXIT_FAILURE
2060659607e0Smrg	    ;;
2061659607e0Smrg	  esac
2062659607e0Smrg	done
2063659607e0Smrg	;;
2064659607e0Smrg    prog)
2065659607e0Smrg	compile_deplibs=
2066659607e0Smrg	finalize_deplibs=
2067659607e0Smrg	alldeplibs=no
2068659607e0Smrg	newdlfiles=
2069659607e0Smrg	newdlprefiles=
2070659607e0Smrg	passes="conv scan dlopen dlpreopen link"
2071659607e0Smrg	;;
2072659607e0Smrg    *)  passes="conv"
2073659607e0Smrg	;;
2074659607e0Smrg    esac
2075659607e0Smrg    for pass in $passes; do
2076659607e0Smrg      if test "$linkmode,$pass" = "lib,link" ||
2077659607e0Smrg	 test "$linkmode,$pass" = "prog,scan"; then
2078659607e0Smrg	libs="$deplibs"
2079659607e0Smrg	deplibs=
2080659607e0Smrg      fi
2081659607e0Smrg      if test "$linkmode" = prog; then
2082659607e0Smrg	case $pass in
2083659607e0Smrg	dlopen) libs="$dlfiles" ;;
2084659607e0Smrg	dlpreopen) libs="$dlprefiles" ;;
2085659607e0Smrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
2086659607e0Smrg	esac
2087659607e0Smrg      fi
2088659607e0Smrg      if test "$pass" = dlopen; then
2089659607e0Smrg	# Collect dlpreopened libraries
2090659607e0Smrg	save_deplibs="$deplibs"
2091659607e0Smrg	deplibs=
2092659607e0Smrg      fi
2093659607e0Smrg      for deplib in $libs; do
2094659607e0Smrg	lib=
2095659607e0Smrg	found=no
2096659607e0Smrg	case $deplib in
20976aab59a7Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
2098659607e0Smrg	  if test "$linkmode,$pass" = "prog,link"; then
2099659607e0Smrg	    compile_deplibs="$deplib $compile_deplibs"
2100659607e0Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
2101659607e0Smrg	  else
2102659607e0Smrg	    compiler_flags="$compiler_flags $deplib"
2103659607e0Smrg	  fi
2104659607e0Smrg	  continue
2105659607e0Smrg	  ;;
2106659607e0Smrg	-l*)
2107659607e0Smrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
2108659607e0Smrg	    $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
2109659607e0Smrg	    continue
2110659607e0Smrg	  fi
2111659607e0Smrg	  name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
2112659607e0Smrg	  for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
2113659607e0Smrg	    for search_ext in .la $std_shrext .so .a; do
2114659607e0Smrg	      # Search the libtool library
2115659607e0Smrg	      lib="$searchdir/lib${name}${search_ext}"
2116659607e0Smrg	      if test -f "$lib"; then
2117659607e0Smrg		if test "$search_ext" = ".la"; then
2118659607e0Smrg		  found=yes
2119659607e0Smrg		else
2120659607e0Smrg		  found=no
2121659607e0Smrg		fi
2122659607e0Smrg		break 2
2123659607e0Smrg	      fi
2124659607e0Smrg	    done
2125659607e0Smrg	  done
2126659607e0Smrg	  if test "$found" != yes; then
2127659607e0Smrg	    # deplib doesn't seem to be a libtool library
2128659607e0Smrg	    if test "$linkmode,$pass" = "prog,link"; then
2129659607e0Smrg	      compile_deplibs="$deplib $compile_deplibs"
2130659607e0Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
2131659607e0Smrg	    else
2132659607e0Smrg	      deplibs="$deplib $deplibs"
2133659607e0Smrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
2134659607e0Smrg	    fi
2135659607e0Smrg	    continue
2136659607e0Smrg	  else # deplib is a libtool library
2137659607e0Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
2138659607e0Smrg	    # We need to do some special things here, and not later.
2139659607e0Smrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
2140659607e0Smrg	      case " $predeps $postdeps " in
2141659607e0Smrg	      *" $deplib "*)
2142659607e0Smrg		if (${SED} -e '2q' $lib |
2143659607e0Smrg                    grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
2144659607e0Smrg		  library_names=
2145659607e0Smrg		  old_library=
2146659607e0Smrg		  case $lib in
2147659607e0Smrg		  */* | *\\*) . $lib ;;
2148659607e0Smrg		  *) . ./$lib ;;
2149659607e0Smrg		  esac
2150659607e0Smrg		  for l in $old_library $library_names; do
2151659607e0Smrg		    ll="$l"
2152659607e0Smrg		  done
2153659607e0Smrg		  if test "X$ll" = "X$old_library" ; then # only static version available
2154659607e0Smrg		    found=no
2155659607e0Smrg		    ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
2156659607e0Smrg		    test "X$ladir" = "X$lib" && ladir="."
2157659607e0Smrg		    lib=$ladir/$old_library
2158659607e0Smrg		    if test "$linkmode,$pass" = "prog,link"; then
2159659607e0Smrg		      compile_deplibs="$deplib $compile_deplibs"
2160659607e0Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
2161659607e0Smrg		    else
2162659607e0Smrg		      deplibs="$deplib $deplibs"
2163659607e0Smrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
2164659607e0Smrg		    fi
2165659607e0Smrg		    continue
2166659607e0Smrg		  fi
2167659607e0Smrg		fi
2168659607e0Smrg	        ;;
2169659607e0Smrg	      *) ;;
2170659607e0Smrg	      esac
2171659607e0Smrg	    fi
2172659607e0Smrg	  fi
2173659607e0Smrg	  ;; # -l
2174659607e0Smrg	-L*)
2175659607e0Smrg	  case $linkmode in
2176659607e0Smrg	  lib)
2177659607e0Smrg	    deplibs="$deplib $deplibs"
2178659607e0Smrg	    test "$pass" = conv && continue
2179659607e0Smrg	    newdependency_libs="$deplib $newdependency_libs"
2180659607e0Smrg	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
2181659607e0Smrg	    ;;
2182659607e0Smrg	  prog)
2183659607e0Smrg	    if test "$pass" = conv; then
2184659607e0Smrg	      deplibs="$deplib $deplibs"
2185659607e0Smrg	      continue
2186659607e0Smrg	    fi
2187659607e0Smrg	    if test "$pass" = scan; then
2188659607e0Smrg	      deplibs="$deplib $deplibs"
2189659607e0Smrg	    else
2190659607e0Smrg	      compile_deplibs="$deplib $compile_deplibs"
2191659607e0Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
2192659607e0Smrg	    fi
2193659607e0Smrg	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
2194659607e0Smrg	    ;;
2195659607e0Smrg	  *)
2196659607e0Smrg	    $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
2197659607e0Smrg	    ;;
2198659607e0Smrg	  esac # linkmode
2199659607e0Smrg	  continue
2200659607e0Smrg	  ;; # -L
2201659607e0Smrg	-R*)
2202659607e0Smrg	  if test "$pass" = link; then
2203659607e0Smrg	    dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
2204659607e0Smrg	    # Make sure the xrpath contains only unique directories.
2205659607e0Smrg	    case "$xrpath " in
2206659607e0Smrg	    *" $dir "*) ;;
2207659607e0Smrg	    *) xrpath="$xrpath $dir" ;;
2208659607e0Smrg	    esac
2209659607e0Smrg	  fi
2210659607e0Smrg	  deplibs="$deplib $deplibs"
2211659607e0Smrg	  continue
2212659607e0Smrg	  ;;
2213659607e0Smrg	*.la) lib="$deplib" ;;
2214659607e0Smrg	*.$libext)
2215659607e0Smrg	  if test "$pass" = conv; then
2216659607e0Smrg	    deplibs="$deplib $deplibs"
2217659607e0Smrg	    continue
2218659607e0Smrg	  fi
2219659607e0Smrg	  case $linkmode in
2220659607e0Smrg	  lib)
2221659607e0Smrg	    valid_a_lib=no
2222659607e0Smrg	    case $deplibs_check_method in
2223659607e0Smrg	      match_pattern*)
2224659607e0Smrg		set dummy $deplibs_check_method
2225659607e0Smrg	        match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
2226659607e0Smrg		if eval $echo \"$deplib\" 2>/dev/null \
2227659607e0Smrg		    | $SED 10q \
2228659607e0Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
2229659607e0Smrg		  valid_a_lib=yes
2230659607e0Smrg		fi
2231659607e0Smrg		;;
2232659607e0Smrg	      pass_all)
2233659607e0Smrg		valid_a_lib=yes
2234659607e0Smrg		;;
2235659607e0Smrg            esac
2236659607e0Smrg	    if test "$valid_a_lib" != yes; then
2237659607e0Smrg	      $echo
2238659607e0Smrg	      $echo "*** Warning: Trying to link with static lib archive $deplib."
2239659607e0Smrg	      $echo "*** I have the capability to make that library automatically link in when"
2240659607e0Smrg	      $echo "*** you link to this library.  But I can only do this if you have a"
2241659607e0Smrg	      $echo "*** shared version of the library, which you do not appear to have"
2242659607e0Smrg	      $echo "*** because the file extensions .$libext of this argument makes me believe"
2243659607e0Smrg	      $echo "*** that it is just a static archive that I should not used here."
2244659607e0Smrg	    else
2245659607e0Smrg	      $echo
2246659607e0Smrg	      $echo "*** Warning: Linking the shared library $output against the"
2247659607e0Smrg	      $echo "*** static library $deplib is not portable!"
2248659607e0Smrg	      deplibs="$deplib $deplibs"
2249659607e0Smrg	    fi
2250659607e0Smrg	    continue
2251659607e0Smrg	    ;;
2252659607e0Smrg	  prog)
2253659607e0Smrg	    if test "$pass" != link; then
2254659607e0Smrg	      deplibs="$deplib $deplibs"
2255659607e0Smrg	    else
2256659607e0Smrg	      compile_deplibs="$deplib $compile_deplibs"
2257659607e0Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
2258659607e0Smrg	    fi
2259659607e0Smrg	    continue
2260659607e0Smrg	    ;;
2261659607e0Smrg	  esac # linkmode
2262659607e0Smrg	  ;; # *.$libext
2263659607e0Smrg	*.lo | *.$objext)
2264659607e0Smrg	  if test "$pass" = conv; then
2265659607e0Smrg	    deplibs="$deplib $deplibs"
2266659607e0Smrg	  elif test "$linkmode" = prog; then
2267659607e0Smrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
2268659607e0Smrg	      # If there is no dlopen support or we're linking statically,
2269659607e0Smrg	      # we need to preload.
2270659607e0Smrg	      newdlprefiles="$newdlprefiles $deplib"
2271659607e0Smrg	      compile_deplibs="$deplib $compile_deplibs"
2272659607e0Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
2273659607e0Smrg	    else
2274659607e0Smrg	      newdlfiles="$newdlfiles $deplib"
2275659607e0Smrg	    fi
2276659607e0Smrg	  fi
2277659607e0Smrg	  continue
2278659607e0Smrg	  ;;
2279659607e0Smrg	%DEPLIBS%)
2280659607e0Smrg	  alldeplibs=yes
2281659607e0Smrg	  continue
2282659607e0Smrg	  ;;
2283659607e0Smrg	esac # case $deplib
2284659607e0Smrg	if test "$found" = yes || test -f "$lib"; then :
2285659607e0Smrg	else
2286659607e0Smrg	  $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2
2287659607e0Smrg	  exit $EXIT_FAILURE
2288659607e0Smrg	fi
2289659607e0Smrg
2290659607e0Smrg	# Check to see that this really is a libtool archive.
2291659607e0Smrg	if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
2292659607e0Smrg	else
2293659607e0Smrg	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
2294659607e0Smrg	  exit $EXIT_FAILURE
2295659607e0Smrg	fi
2296659607e0Smrg
2297659607e0Smrg	ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
2298659607e0Smrg	test "X$ladir" = "X$lib" && ladir="."
2299659607e0Smrg
2300659607e0Smrg	dlname=
2301659607e0Smrg	dlopen=
2302659607e0Smrg	dlpreopen=
2303659607e0Smrg	libdir=
2304659607e0Smrg	library_names=
2305659607e0Smrg	old_library=
2306659607e0Smrg	# If the library was installed with an old release of libtool,
2307659607e0Smrg	# it will not redefine variables installed, or shouldnotlink
2308659607e0Smrg	installed=yes
2309659607e0Smrg	shouldnotlink=no
2310659607e0Smrg	avoidtemprpath=
2311659607e0Smrg
2312659607e0Smrg
2313659607e0Smrg	# Read the .la file
2314659607e0Smrg	case $lib in
2315659607e0Smrg	*/* | *\\*) . $lib ;;
2316659607e0Smrg	*) . ./$lib ;;
2317659607e0Smrg	esac
2318659607e0Smrg
2319659607e0Smrg	if test "$linkmode,$pass" = "lib,link" ||
2320659607e0Smrg	   test "$linkmode,$pass" = "prog,scan" ||
2321659607e0Smrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
2322659607e0Smrg	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
2323659607e0Smrg	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
2324659607e0Smrg	fi
2325659607e0Smrg
2326659607e0Smrg	if test "$pass" = conv; then
2327659607e0Smrg	  # Only check for convenience libraries
2328659607e0Smrg	  deplibs="$lib $deplibs"
2329659607e0Smrg	  if test -z "$libdir"; then
2330659607e0Smrg	    if test -z "$old_library"; then
2331659607e0Smrg	      $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
2332659607e0Smrg	      exit $EXIT_FAILURE
2333659607e0Smrg	    fi
2334659607e0Smrg	    # It is a libtool convenience library, so add in its objects.
2335659607e0Smrg	    convenience="$convenience $ladir/$objdir/$old_library"
2336659607e0Smrg	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
2337659607e0Smrg	    tmp_libs=
2338659607e0Smrg	    for deplib in $dependency_libs; do
2339659607e0Smrg	      deplibs="$deplib $deplibs"
2340659607e0Smrg              if test "X$duplicate_deps" = "Xyes" ; then
2341659607e0Smrg	        case "$tmp_libs " in
2342659607e0Smrg	        *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2343659607e0Smrg	        esac
2344659607e0Smrg              fi
2345659607e0Smrg	      tmp_libs="$tmp_libs $deplib"
2346659607e0Smrg	    done
2347659607e0Smrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
2348659607e0Smrg	    $echo "$modename: \`$lib' is not a convenience library" 1>&2
2349659607e0Smrg	    exit $EXIT_FAILURE
2350659607e0Smrg	  fi
2351659607e0Smrg	  continue
2352659607e0Smrg	fi # $pass = conv
2353659607e0Smrg
2354659607e0Smrg
2355659607e0Smrg	# Get the name of the library we link against.
2356659607e0Smrg	linklib=
2357659607e0Smrg	for l in $old_library $library_names; do
2358659607e0Smrg	  linklib="$l"
2359659607e0Smrg	done
2360659607e0Smrg	if test -z "$linklib"; then
2361659607e0Smrg	  $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
2362659607e0Smrg	  exit $EXIT_FAILURE
2363659607e0Smrg	fi
2364659607e0Smrg
2365659607e0Smrg	# This library was specified with -dlopen.
2366659607e0Smrg	if test "$pass" = dlopen; then
2367659607e0Smrg	  if test -z "$libdir"; then
2368659607e0Smrg	    $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
2369659607e0Smrg	    exit $EXIT_FAILURE
2370659607e0Smrg	  fi
2371659607e0Smrg	  if test -z "$dlname" ||
2372659607e0Smrg	     test "$dlopen_support" != yes ||
2373659607e0Smrg	     test "$build_libtool_libs" = no; then
2374659607e0Smrg	    # If there is no dlname, no dlopen support or we're linking
2375659607e0Smrg	    # statically, we need to preload.  We also need to preload any
2376659607e0Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
2377659607e0Smrg	    # bomb out in the load deplibs phase.
2378659607e0Smrg	    dlprefiles="$dlprefiles $lib $dependency_libs"
2379659607e0Smrg	  else
2380659607e0Smrg	    newdlfiles="$newdlfiles $lib"
2381659607e0Smrg	  fi
2382659607e0Smrg	  continue
2383659607e0Smrg	fi # $pass = dlopen
2384659607e0Smrg
2385659607e0Smrg	# We need an absolute path.
2386659607e0Smrg	case $ladir in
2387659607e0Smrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
2388659607e0Smrg	*)
2389659607e0Smrg	  abs_ladir=`cd "$ladir" && pwd`
2390659607e0Smrg	  if test -z "$abs_ladir"; then
2391659607e0Smrg	    $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2
2392659607e0Smrg	    $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
2393659607e0Smrg	    abs_ladir="$ladir"
2394659607e0Smrg	  fi
2395659607e0Smrg	  ;;
2396659607e0Smrg	esac
2397659607e0Smrg	laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
2398659607e0Smrg
2399659607e0Smrg	# Find the relevant object directory and library name.
2400659607e0Smrg	if test "X$installed" = Xyes; then
2401659607e0Smrg	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
2402659607e0Smrg	    $echo "$modename: warning: library \`$lib' was moved." 1>&2
2403659607e0Smrg	    dir="$ladir"
2404659607e0Smrg	    absdir="$abs_ladir"
2405659607e0Smrg	    libdir="$abs_ladir"
2406659607e0Smrg	  else
2407659607e0Smrg	    dir="$libdir"
2408659607e0Smrg	    absdir="$libdir"
2409659607e0Smrg	  fi
2410659607e0Smrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
2411659607e0Smrg	else
2412659607e0Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
2413659607e0Smrg	    dir="$ladir"
2414659607e0Smrg	    absdir="$abs_ladir"
2415659607e0Smrg	    # Remove this search path later
2416659607e0Smrg	    notinst_path="$notinst_path $abs_ladir"
2417659607e0Smrg	  else
2418659607e0Smrg	    dir="$ladir/$objdir"
2419659607e0Smrg	    absdir="$abs_ladir/$objdir"
2420659607e0Smrg	    # Remove this search path later
2421659607e0Smrg	    notinst_path="$notinst_path $abs_ladir"
2422659607e0Smrg	  fi
2423659607e0Smrg	fi # $installed = yes
2424659607e0Smrg	name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
2425659607e0Smrg
2426659607e0Smrg	# This library was specified with -dlpreopen.
2427659607e0Smrg	if test "$pass" = dlpreopen; then
2428659607e0Smrg	  if test -z "$libdir"; then
2429659607e0Smrg	    $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
2430659607e0Smrg	    exit $EXIT_FAILURE
2431659607e0Smrg	  fi
2432659607e0Smrg	  # Prefer using a static library (so that no silly _DYNAMIC symbols
2433659607e0Smrg	  # are required to link).
2434659607e0Smrg	  if test -n "$old_library"; then
2435659607e0Smrg	    newdlprefiles="$newdlprefiles $dir/$old_library"
2436659607e0Smrg	  # Otherwise, use the dlname, so that lt_dlopen finds it.
2437659607e0Smrg	  elif test -n "$dlname"; then
2438659607e0Smrg	    newdlprefiles="$newdlprefiles $dir/$dlname"
2439659607e0Smrg	  else
2440659607e0Smrg	    newdlprefiles="$newdlprefiles $dir/$linklib"
2441659607e0Smrg	  fi
2442659607e0Smrg	fi # $pass = dlpreopen
2443659607e0Smrg
2444659607e0Smrg	if test -z "$libdir"; then
2445659607e0Smrg	  # Link the convenience library
2446659607e0Smrg	  if test "$linkmode" = lib; then
2447659607e0Smrg	    deplibs="$dir/$old_library $deplibs"
2448659607e0Smrg	  elif test "$linkmode,$pass" = "prog,link"; then
2449659607e0Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
2450659607e0Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
2451659607e0Smrg	  else
2452659607e0Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
2453659607e0Smrg	  fi
2454659607e0Smrg	  continue
2455659607e0Smrg	fi
2456659607e0Smrg
2457659607e0Smrg
2458659607e0Smrg	if test "$linkmode" = prog && test "$pass" != link; then
2459659607e0Smrg	  newlib_search_path="$newlib_search_path $ladir"
2460659607e0Smrg	  deplibs="$lib $deplibs"
2461659607e0Smrg
2462659607e0Smrg	  linkalldeplibs=no
2463659607e0Smrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
2464659607e0Smrg	     test "$build_libtool_libs" = no; then
2465659607e0Smrg	    linkalldeplibs=yes
2466659607e0Smrg	  fi
2467659607e0Smrg
2468659607e0Smrg	  tmp_libs=
2469659607e0Smrg	  for deplib in $dependency_libs; do
2470659607e0Smrg	    case $deplib in
2471659607e0Smrg	    -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
2472659607e0Smrg	    esac
2473659607e0Smrg	    # Need to link against all dependency_libs?
2474659607e0Smrg	    if test "$linkalldeplibs" = yes; then
2475659607e0Smrg	      deplibs="$deplib $deplibs"
2476659607e0Smrg	    else
2477659607e0Smrg	      # Need to hardcode shared library paths
2478659607e0Smrg	      # or/and link against static libraries
2479659607e0Smrg	      newdependency_libs="$deplib $newdependency_libs"
2480659607e0Smrg	    fi
2481659607e0Smrg	    if test "X$duplicate_deps" = "Xyes" ; then
2482659607e0Smrg	      case "$tmp_libs " in
2483659607e0Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2484659607e0Smrg	      esac
2485659607e0Smrg	    fi
2486659607e0Smrg	    tmp_libs="$tmp_libs $deplib"
2487659607e0Smrg	  done # for deplib
2488659607e0Smrg	  continue
2489659607e0Smrg	fi # $linkmode = prog...
2490659607e0Smrg
2491659607e0Smrg	if test "$linkmode,$pass" = "prog,link"; then
2492659607e0Smrg	  if test -n "$library_names" &&
24936aab59a7Smrg	     { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
2494659607e0Smrg	    # We need to hardcode the library path
2495659607e0Smrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
2496659607e0Smrg	      # Make sure the rpath contains only unique directories.
2497659607e0Smrg	      case "$temp_rpath " in
2498659607e0Smrg	      *" $dir "*) ;;
2499659607e0Smrg	      *" $absdir "*) ;;
2500659607e0Smrg	      *) temp_rpath="$temp_rpath $absdir" ;;
2501659607e0Smrg	      esac
2502659607e0Smrg	    fi
2503659607e0Smrg
2504659607e0Smrg	    # Hardcode the library path.
2505659607e0Smrg	    # Skip directories that are in the system default run-time
2506659607e0Smrg	    # search path.
2507659607e0Smrg	    case " $sys_lib_dlsearch_path " in
2508659607e0Smrg	    *" $absdir "*) ;;
2509659607e0Smrg	    *)
2510659607e0Smrg	      case "$compile_rpath " in
2511659607e0Smrg	      *" $absdir "*) ;;
2512659607e0Smrg	      *) compile_rpath="$compile_rpath $absdir"
2513659607e0Smrg	      esac
2514659607e0Smrg	      ;;
2515659607e0Smrg	    esac
2516659607e0Smrg	    case " $sys_lib_dlsearch_path " in
2517659607e0Smrg	    *" $libdir "*) ;;
2518659607e0Smrg	    *)
2519659607e0Smrg	      case "$finalize_rpath " in
2520659607e0Smrg	      *" $libdir "*) ;;
2521659607e0Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
2522659607e0Smrg	      esac
2523659607e0Smrg	      ;;
2524659607e0Smrg	    esac
2525659607e0Smrg	  fi # $linkmode,$pass = prog,link...
2526659607e0Smrg
2527659607e0Smrg	  if test "$alldeplibs" = yes &&
2528659607e0Smrg	     { test "$deplibs_check_method" = pass_all ||
2529659607e0Smrg	       { test "$build_libtool_libs" = yes &&
2530659607e0Smrg		 test -n "$library_names"; }; }; then
2531659607e0Smrg	    # We only need to search for static libraries
2532659607e0Smrg	    continue
2533659607e0Smrg	  fi
2534659607e0Smrg	fi
2535659607e0Smrg
2536659607e0Smrg	link_static=no # Whether the deplib will be linked statically
2537659607e0Smrg	use_static_libs=$prefer_static_libs
2538659607e0Smrg	if test "$use_static_libs" = built && test "$installed" = yes ; then
2539659607e0Smrg	  use_static_libs=no
2540659607e0Smrg	fi
2541659607e0Smrg	if test -n "$library_names" &&
2542659607e0Smrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
2543659607e0Smrg	  if test "$installed" = no; then
2544659607e0Smrg	    notinst_deplibs="$notinst_deplibs $lib"
2545659607e0Smrg	    need_relink=yes
2546659607e0Smrg	  fi
2547659607e0Smrg	  # This is a shared library
2548659607e0Smrg
2549659607e0Smrg	  # Warn about portability, can't link against -module's on
2550659607e0Smrg	  # some systems (darwin)
2551659607e0Smrg	  if test "$shouldnotlink" = yes && test "$pass" = link ; then
2552659607e0Smrg	    $echo
2553659607e0Smrg	    if test "$linkmode" = prog; then
2554659607e0Smrg	      $echo "*** Warning: Linking the executable $output against the loadable module"
2555659607e0Smrg	    else
2556659607e0Smrg	      $echo "*** Warning: Linking the shared library $output against the loadable module"
2557659607e0Smrg	    fi
2558659607e0Smrg	    $echo "*** $linklib is not portable!"
2559659607e0Smrg	  fi
2560659607e0Smrg	  if test "$linkmode" = lib &&
2561659607e0Smrg	     test "$hardcode_into_libs" = yes; then
2562659607e0Smrg	    # Hardcode the library path.
2563659607e0Smrg	    # Skip directories that are in the system default run-time
2564659607e0Smrg	    # search path.
2565659607e0Smrg	    case " $sys_lib_dlsearch_path " in
2566659607e0Smrg	    *" $absdir "*) ;;
2567659607e0Smrg	    *)
2568659607e0Smrg	      case "$compile_rpath " in
2569659607e0Smrg	      *" $absdir "*) ;;
2570659607e0Smrg	      *) compile_rpath="$compile_rpath $absdir"
2571659607e0Smrg	      esac
2572659607e0Smrg	      ;;
2573659607e0Smrg	    esac
2574659607e0Smrg	    case " $sys_lib_dlsearch_path " in
2575659607e0Smrg	    *" $libdir "*) ;;
2576659607e0Smrg	    *)
2577659607e0Smrg	      case "$finalize_rpath " in
2578659607e0Smrg	      *" $libdir "*) ;;
2579659607e0Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
2580659607e0Smrg	      esac
2581659607e0Smrg	      ;;
2582659607e0Smrg	    esac
2583659607e0Smrg	  fi
2584659607e0Smrg
2585659607e0Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
2586659607e0Smrg	    # figure out the soname
2587659607e0Smrg	    set dummy $library_names
2588659607e0Smrg	    realname="$2"
2589659607e0Smrg	    shift; shift
2590659607e0Smrg	    libname=`eval \\$echo \"$libname_spec\"`
2591659607e0Smrg	    # use dlname if we got it. it's perfectly good, no?
2592659607e0Smrg	    if test -n "$dlname"; then
2593659607e0Smrg	      soname="$dlname"
2594659607e0Smrg	    elif test -n "$soname_spec"; then
2595659607e0Smrg	      # bleh windows
2596659607e0Smrg	      case $host in
2597659607e0Smrg	      *cygwin* | mingw*)
2598659607e0Smrg		major=`expr $current - $age`
2599659607e0Smrg		versuffix="-$major"
2600659607e0Smrg		;;
2601659607e0Smrg	      esac
2602659607e0Smrg	      eval soname=\"$soname_spec\"
2603659607e0Smrg	    else
2604659607e0Smrg	      soname="$realname"
2605659607e0Smrg	    fi
2606659607e0Smrg
2607659607e0Smrg	    # Make a new name for the extract_expsyms_cmds to use
2608659607e0Smrg	    soroot="$soname"
2609659607e0Smrg	    soname=`$echo $soroot | ${SED} -e 's/^.*\///'`
2610659607e0Smrg	    newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
2611659607e0Smrg
2612659607e0Smrg	    # If the library has no export list, then create one now
2613659607e0Smrg	    if test -f "$output_objdir/$soname-def"; then :
2614659607e0Smrg	    else
2615659607e0Smrg	      $show "extracting exported symbol list from \`$soname'"
2616659607e0Smrg	      save_ifs="$IFS"; IFS='~'
2617659607e0Smrg	      cmds=$extract_expsyms_cmds
2618659607e0Smrg	      for cmd in $cmds; do
2619659607e0Smrg		IFS="$save_ifs"
2620659607e0Smrg		eval cmd=\"$cmd\"
2621659607e0Smrg		$show "$cmd"
2622659607e0Smrg		$run eval "$cmd" || exit $?
2623659607e0Smrg	      done
2624659607e0Smrg	      IFS="$save_ifs"
2625659607e0Smrg	    fi
2626659607e0Smrg
2627659607e0Smrg	    # Create $newlib
2628659607e0Smrg	    if test -f "$output_objdir/$newlib"; then :; else
2629659607e0Smrg	      $show "generating import library for \`$soname'"
2630659607e0Smrg	      save_ifs="$IFS"; IFS='~'
2631659607e0Smrg	      cmds=$old_archive_from_expsyms_cmds
2632659607e0Smrg	      for cmd in $cmds; do
2633659607e0Smrg		IFS="$save_ifs"
2634659607e0Smrg		eval cmd=\"$cmd\"
2635659607e0Smrg		$show "$cmd"
2636659607e0Smrg		$run eval "$cmd" || exit $?
2637659607e0Smrg	      done
2638659607e0Smrg	      IFS="$save_ifs"
2639659607e0Smrg	    fi
2640659607e0Smrg	    # make sure the library variables are pointing to the new library
2641659607e0Smrg	    dir=$output_objdir
2642659607e0Smrg	    linklib=$newlib
2643659607e0Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
2644659607e0Smrg
2645659607e0Smrg	  if test "$linkmode" = prog || test "$mode" != relink; then
2646659607e0Smrg	    add_shlibpath=
2647659607e0Smrg	    add_dir=
2648659607e0Smrg	    add=
2649659607e0Smrg	    lib_linked=yes
2650659607e0Smrg	    case $hardcode_action in
2651659607e0Smrg	    immediate | unsupported)
2652659607e0Smrg	      if test "$hardcode_direct" = no; then
2653659607e0Smrg		add="$dir/$linklib"
2654659607e0Smrg		case $host in
2655659607e0Smrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
2656659607e0Smrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
2657659607e0Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
2658659607e0Smrg		    *-*-unixware7*) add_dir="-L$dir" ;;
2659659607e0Smrg		  *-*-darwin* )
2660659607e0Smrg		    # if the lib is a module then we can not link against
2661659607e0Smrg		    # it, someone is ignoring the new warnings I added
2662659607e0Smrg		    if /usr/bin/file -L $add 2> /dev/null |
2663659607e0Smrg                      $EGREP ": [^:]* bundle" >/dev/null ; then
2664659607e0Smrg		      $echo "** Warning, lib $linklib is a module, not a shared library"
2665659607e0Smrg		      if test -z "$old_library" ; then
2666659607e0Smrg		        $echo
2667659607e0Smrg		        $echo "** And there doesn't seem to be a static archive available"
2668659607e0Smrg		        $echo "** The link will probably fail, sorry"
2669659607e0Smrg		      else
2670659607e0Smrg		        add="$dir/$old_library"
2671659607e0Smrg		      fi
2672659607e0Smrg		    fi
2673659607e0Smrg		esac
2674659607e0Smrg	      elif test "$hardcode_minus_L" = no; then
2675659607e0Smrg		case $host in
2676659607e0Smrg		*-*-sunos*) add_shlibpath="$dir" ;;
2677659607e0Smrg		esac
2678659607e0Smrg		add_dir="-L$dir"
2679659607e0Smrg		add="-l$name"
2680659607e0Smrg	      elif test "$hardcode_shlibpath_var" = no; then
2681659607e0Smrg		add_shlibpath="$dir"
2682659607e0Smrg		add="-l$name"
2683659607e0Smrg	      else
2684659607e0Smrg		lib_linked=no
2685659607e0Smrg	      fi
2686659607e0Smrg	      ;;
2687659607e0Smrg	    relink)
2688659607e0Smrg	      if test "$hardcode_direct" = yes; then
2689659607e0Smrg		add="$dir/$linklib"
2690659607e0Smrg	      elif test "$hardcode_minus_L" = yes; then
2691659607e0Smrg		add_dir="-L$dir"
2692659607e0Smrg		# Try looking first in the location we're being installed to.
2693659607e0Smrg		if test -n "$inst_prefix_dir"; then
2694659607e0Smrg		  case $libdir in
2695659607e0Smrg		    [\\/]*)
2696659607e0Smrg		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
2697659607e0Smrg		      ;;
2698659607e0Smrg		  esac
2699659607e0Smrg		fi
2700659607e0Smrg		add="-l$name"
2701659607e0Smrg	      elif test "$hardcode_shlibpath_var" = yes; then
2702659607e0Smrg		add_shlibpath="$dir"
2703659607e0Smrg		add="-l$name"
2704659607e0Smrg	      else
2705659607e0Smrg		lib_linked=no
2706659607e0Smrg	      fi
2707659607e0Smrg	      ;;
2708659607e0Smrg	    *) lib_linked=no ;;
2709659607e0Smrg	    esac
2710659607e0Smrg
2711659607e0Smrg	    if test "$lib_linked" != yes; then
2712659607e0Smrg	      $echo "$modename: configuration error: unsupported hardcode properties"
2713659607e0Smrg	      exit $EXIT_FAILURE
2714659607e0Smrg	    fi
2715659607e0Smrg
2716659607e0Smrg	    if test -n "$add_shlibpath"; then
2717659607e0Smrg	      case :$compile_shlibpath: in
2718659607e0Smrg	      *":$add_shlibpath:"*) ;;
2719659607e0Smrg	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
2720659607e0Smrg	      esac
2721659607e0Smrg	    fi
2722659607e0Smrg	    if test "$linkmode" = prog; then
2723659607e0Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
2724659607e0Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
2725659607e0Smrg	    else
2726659607e0Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
2727659607e0Smrg	      test -n "$add" && deplibs="$add $deplibs"
2728659607e0Smrg	      if test "$hardcode_direct" != yes && \
2729659607e0Smrg		 test "$hardcode_minus_L" != yes && \
2730659607e0Smrg		 test "$hardcode_shlibpath_var" = yes; then
2731659607e0Smrg		case :$finalize_shlibpath: in
2732659607e0Smrg		*":$libdir:"*) ;;
2733659607e0Smrg		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
2734659607e0Smrg		esac
2735659607e0Smrg	      fi
2736659607e0Smrg	    fi
2737659607e0Smrg	  fi
2738659607e0Smrg
2739659607e0Smrg	  if test "$linkmode" = prog || test "$mode" = relink; then
2740659607e0Smrg	    add_shlibpath=
2741659607e0Smrg	    add_dir=
2742659607e0Smrg	    add=
2743659607e0Smrg	    # Finalize command for both is simple: just hardcode it.
2744659607e0Smrg	    if test "$hardcode_direct" = yes; then
2745659607e0Smrg	      add="$libdir/$linklib"
2746659607e0Smrg	    elif test "$hardcode_minus_L" = yes; then
2747659607e0Smrg	      add_dir="-L$libdir"
2748659607e0Smrg	      add="-l$name"
2749659607e0Smrg	    elif test "$hardcode_shlibpath_var" = yes; then
2750659607e0Smrg	      case :$finalize_shlibpath: in
2751659607e0Smrg	      *":$libdir:"*) ;;
2752659607e0Smrg	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
2753659607e0Smrg	      esac
2754659607e0Smrg	      add="-l$name"
2755659607e0Smrg	    elif test "$hardcode_automatic" = yes; then
2756659607e0Smrg	      if test -n "$inst_prefix_dir" &&
2757659607e0Smrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
2758659607e0Smrg	        add="$inst_prefix_dir$libdir/$linklib"
2759659607e0Smrg	      else
2760659607e0Smrg	        add="$libdir/$linklib"
2761659607e0Smrg	      fi
2762659607e0Smrg	    else
2763659607e0Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
2764659607e0Smrg	      add_dir="-L$libdir"
2765659607e0Smrg	      # Try looking first in the location we're being installed to.
2766659607e0Smrg	      if test -n "$inst_prefix_dir"; then
2767659607e0Smrg		case $libdir in
2768659607e0Smrg		  [\\/]*)
2769659607e0Smrg		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
2770659607e0Smrg		    ;;
2771659607e0Smrg		esac
2772659607e0Smrg	      fi
2773659607e0Smrg	      add="-l$name"
2774659607e0Smrg	    fi
2775659607e0Smrg
2776659607e0Smrg	    if test "$linkmode" = prog; then
2777659607e0Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
2778659607e0Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
2779659607e0Smrg	    else
2780659607e0Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
2781659607e0Smrg	      test -n "$add" && deplibs="$add $deplibs"
2782659607e0Smrg	    fi
2783659607e0Smrg	  fi
2784659607e0Smrg	elif test "$linkmode" = prog; then
2785659607e0Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
2786659607e0Smrg	  # is not unsupported.  This is valid on all known static and
2787659607e0Smrg	  # shared platforms.
2788659607e0Smrg	  if test "$hardcode_direct" != unsupported; then
2789659607e0Smrg	    test -n "$old_library" && linklib="$old_library"
2790659607e0Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
2791659607e0Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
2792659607e0Smrg	  else
2793659607e0Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
2794659607e0Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
2795659607e0Smrg	  fi
2796659607e0Smrg	elif test "$build_libtool_libs" = yes; then
2797659607e0Smrg	  # Not a shared library
2798659607e0Smrg	  if test "$deplibs_check_method" != pass_all; then
2799659607e0Smrg	    # We're trying link a shared library against a static one
2800659607e0Smrg	    # but the system doesn't support it.
2801659607e0Smrg
2802659607e0Smrg	    # Just print a warning and add the library to dependency_libs so
2803659607e0Smrg	    # that the program can be linked against the static library.
2804659607e0Smrg	    $echo
2805659607e0Smrg	    $echo "*** Warning: This system can not link to static lib archive $lib."
2806659607e0Smrg	    $echo "*** I have the capability to make that library automatically link in when"
2807659607e0Smrg	    $echo "*** you link to this library.  But I can only do this if you have a"
2808659607e0Smrg	    $echo "*** shared version of the library, which you do not appear to have."
2809659607e0Smrg	    if test "$module" = yes; then
2810659607e0Smrg	      $echo "*** But as you try to build a module library, libtool will still create "
2811659607e0Smrg	      $echo "*** a static module, that should work as long as the dlopening application"
2812659607e0Smrg	      $echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
2813659607e0Smrg	      if test -z "$global_symbol_pipe"; then
2814659607e0Smrg		$echo
2815659607e0Smrg		$echo "*** However, this would only work if libtool was able to extract symbol"
2816659607e0Smrg		$echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
2817659607e0Smrg		$echo "*** not find such a program.  So, this module is probably useless."
2818659607e0Smrg		$echo "*** \`nm' from GNU binutils and a full rebuild may help."
2819659607e0Smrg	      fi
2820659607e0Smrg	      if test "$build_old_libs" = no; then
2821659607e0Smrg		build_libtool_libs=module
2822659607e0Smrg		build_old_libs=yes
2823659607e0Smrg	      else
2824659607e0Smrg		build_libtool_libs=no
2825659607e0Smrg	      fi
2826659607e0Smrg	    fi
2827659607e0Smrg	  else
2828659607e0Smrg	    deplibs="$dir/$old_library $deplibs"
2829659607e0Smrg	    link_static=yes
2830659607e0Smrg	  fi
2831659607e0Smrg	fi # link shared/static library?
2832659607e0Smrg
2833659607e0Smrg	if test "$linkmode" = lib; then
2834659607e0Smrg	  if test -n "$dependency_libs" &&
2835659607e0Smrg	     { test "$hardcode_into_libs" != yes ||
2836659607e0Smrg	       test "$build_old_libs" = yes ||
2837659607e0Smrg	       test "$link_static" = yes; }; then
2838659607e0Smrg	    # Extract -R from dependency_libs
2839659607e0Smrg	    temp_deplibs=
2840659607e0Smrg	    for libdir in $dependency_libs; do
2841659607e0Smrg	      case $libdir in
2842659607e0Smrg	      -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'`
2843659607e0Smrg		   case " $xrpath " in
2844659607e0Smrg		   *" $temp_xrpath "*) ;;
2845659607e0Smrg		   *) xrpath="$xrpath $temp_xrpath";;
2846659607e0Smrg		   esac;;
2847659607e0Smrg	      *) temp_deplibs="$temp_deplibs $libdir";;
2848659607e0Smrg	      esac
2849659607e0Smrg	    done
2850659607e0Smrg	    dependency_libs="$temp_deplibs"
2851659607e0Smrg	  fi
2852659607e0Smrg
2853659607e0Smrg	  newlib_search_path="$newlib_search_path $absdir"
2854659607e0Smrg	  # Link against this library
2855659607e0Smrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
2856659607e0Smrg	  # ... and its dependency_libs
2857659607e0Smrg	  tmp_libs=
2858659607e0Smrg	  for deplib in $dependency_libs; do
2859659607e0Smrg	    newdependency_libs="$deplib $newdependency_libs"
2860659607e0Smrg	    if test "X$duplicate_deps" = "Xyes" ; then
2861659607e0Smrg	      case "$tmp_libs " in
2862659607e0Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2863659607e0Smrg	      esac
2864659607e0Smrg	    fi
2865659607e0Smrg	    tmp_libs="$tmp_libs $deplib"
2866659607e0Smrg	  done
2867659607e0Smrg
2868659607e0Smrg	  if test "$link_all_deplibs" != no; then
2869659607e0Smrg	    # Add the search paths of all dependency libraries
2870659607e0Smrg	    for deplib in $dependency_libs; do
2871659607e0Smrg	      case $deplib in
2872659607e0Smrg	      -L*) path="$deplib" ;;
2873659607e0Smrg	      *.la)
2874659607e0Smrg		dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
2875659607e0Smrg		test "X$dir" = "X$deplib" && dir="."
2876659607e0Smrg		# We need an absolute path.
2877659607e0Smrg		case $dir in
2878659607e0Smrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
2879659607e0Smrg		*)
2880659607e0Smrg		  absdir=`cd "$dir" && pwd`
2881659607e0Smrg		  if test -z "$absdir"; then
2882659607e0Smrg		    $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
2883659607e0Smrg		    absdir="$dir"
2884659607e0Smrg		  fi
2885659607e0Smrg		  ;;
2886659607e0Smrg		esac
2887659607e0Smrg		if grep "^installed=no" $deplib > /dev/null; then
2888659607e0Smrg		  path="$absdir/$objdir"
2889659607e0Smrg		else
2890659607e0Smrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
2891659607e0Smrg		  if test -z "$libdir"; then
2892659607e0Smrg		    $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
2893659607e0Smrg		    exit $EXIT_FAILURE
2894659607e0Smrg		  fi
2895659607e0Smrg		  if test "$absdir" != "$libdir"; then
2896659607e0Smrg		    $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
2897659607e0Smrg		  fi
2898659607e0Smrg		  path="$absdir"
2899659607e0Smrg		fi
2900659607e0Smrg		depdepl=
2901659607e0Smrg		case $host in
2902659607e0Smrg		*-*-darwin*)
2903659607e0Smrg		  # we do not want to link against static libs,
2904659607e0Smrg		  # but need to link against shared
2905659607e0Smrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
2906659607e0Smrg		  if test -n "$deplibrary_names" ; then
2907659607e0Smrg		    for tmp in $deplibrary_names ; do
2908659607e0Smrg		      depdepl=$tmp
2909659607e0Smrg		    done
2910659607e0Smrg		    if test -f "$path/$depdepl" ; then
2911659607e0Smrg		      depdepl="$path/$depdepl"
2912659607e0Smrg		    fi
2913659607e0Smrg		    # do not add paths which are already there
2914659607e0Smrg		    case " $newlib_search_path " in
2915659607e0Smrg		    *" $path "*) ;;
2916659607e0Smrg		    *) newlib_search_path="$newlib_search_path $path";;
2917659607e0Smrg		    esac
2918659607e0Smrg		  fi
2919659607e0Smrg		  path=""
2920659607e0Smrg		  ;;
2921659607e0Smrg		*)
2922659607e0Smrg		  path="-L$path"
2923659607e0Smrg		  ;;
2924659607e0Smrg		esac
2925659607e0Smrg		;;
2926659607e0Smrg	      -l*)
2927659607e0Smrg		case $host in
2928659607e0Smrg		*-*-darwin*)
2929659607e0Smrg		  # Again, we only want to link against shared libraries
2930659607e0Smrg		  eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
2931659607e0Smrg		  for tmp in $newlib_search_path ; do
2932659607e0Smrg		    if test -f "$tmp/lib$tmp_libs.dylib" ; then
2933659607e0Smrg		      eval depdepl="$tmp/lib$tmp_libs.dylib"
2934659607e0Smrg		      break
2935659607e0Smrg		    fi
2936659607e0Smrg		  done
2937659607e0Smrg		  path=""
2938659607e0Smrg		  ;;
2939659607e0Smrg		*) continue ;;
2940659607e0Smrg		esac
2941659607e0Smrg		;;
2942659607e0Smrg	      *) continue ;;
2943659607e0Smrg	      esac
2944659607e0Smrg	      case " $deplibs " in
2945659607e0Smrg	      *" $path "*) ;;
2946659607e0Smrg	      *) deplibs="$path $deplibs" ;;
2947659607e0Smrg	      esac
2948659607e0Smrg	      case " $deplibs " in
2949659607e0Smrg	      *" $depdepl "*) ;;
2950659607e0Smrg	      *) deplibs="$depdepl $deplibs" ;;
2951659607e0Smrg	      esac
2952659607e0Smrg	    done
2953659607e0Smrg	  fi # link_all_deplibs != no
2954659607e0Smrg	fi # linkmode = lib
2955659607e0Smrg      done # for deplib in $libs
2956659607e0Smrg      dependency_libs="$newdependency_libs"
2957659607e0Smrg      if test "$pass" = dlpreopen; then
2958659607e0Smrg	# Link the dlpreopened libraries before other libraries
2959659607e0Smrg	for deplib in $save_deplibs; do
2960659607e0Smrg	  deplibs="$deplib $deplibs"
2961659607e0Smrg	done
2962659607e0Smrg      fi
2963659607e0Smrg      if test "$pass" != dlopen; then
2964659607e0Smrg	if test "$pass" != conv; then
2965659607e0Smrg	  # Make sure lib_search_path contains only unique directories.
2966659607e0Smrg	  lib_search_path=
2967659607e0Smrg	  for dir in $newlib_search_path; do
2968659607e0Smrg	    case "$lib_search_path " in
2969659607e0Smrg	    *" $dir "*) ;;
2970659607e0Smrg	    *) lib_search_path="$lib_search_path $dir" ;;
2971659607e0Smrg	    esac
2972659607e0Smrg	  done
2973659607e0Smrg	  newlib_search_path=
2974659607e0Smrg	fi
2975659607e0Smrg
2976659607e0Smrg	if test "$linkmode,$pass" != "prog,link"; then
2977659607e0Smrg	  vars="deplibs"
2978659607e0Smrg	else
2979659607e0Smrg	  vars="compile_deplibs finalize_deplibs"
2980659607e0Smrg	fi
2981659607e0Smrg	for var in $vars dependency_libs; do
2982659607e0Smrg	  # Add libraries to $var in reverse order
2983659607e0Smrg	  eval tmp_libs=\"\$$var\"
2984659607e0Smrg	  new_libs=
2985659607e0Smrg	  for deplib in $tmp_libs; do
2986659607e0Smrg	    # FIXME: Pedantically, this is the right thing to do, so
2987659607e0Smrg	    #        that some nasty dependency loop isn't accidentally
2988659607e0Smrg	    #        broken:
2989659607e0Smrg	    #new_libs="$deplib $new_libs"
2990659607e0Smrg	    # Pragmatically, this seems to cause very few problems in
2991659607e0Smrg	    # practice:
2992659607e0Smrg	    case $deplib in
2993659607e0Smrg	    -L*) new_libs="$deplib $new_libs" ;;
2994659607e0Smrg	    -R*) ;;
2995659607e0Smrg	    *)
2996659607e0Smrg	      # And here is the reason: when a library appears more
2997659607e0Smrg	      # than once as an explicit dependence of a library, or
2998659607e0Smrg	      # is implicitly linked in more than once by the
2999659607e0Smrg	      # compiler, it is considered special, and multiple
3000659607e0Smrg	      # occurrences thereof are not removed.  Compare this
3001659607e0Smrg	      # with having the same library being listed as a
3002659607e0Smrg	      # dependency of multiple other libraries: in this case,
3003659607e0Smrg	      # we know (pedantically, we assume) the library does not
3004659607e0Smrg	      # need to be listed more than once, so we keep only the
3005659607e0Smrg	      # last copy.  This is not always right, but it is rare
3006659607e0Smrg	      # enough that we require users that really mean to play
3007659607e0Smrg	      # such unportable linking tricks to link the library
3008659607e0Smrg	      # using -Wl,-lname, so that libtool does not consider it
3009659607e0Smrg	      # for duplicate removal.
3010659607e0Smrg	      case " $specialdeplibs " in
3011659607e0Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
3012659607e0Smrg	      *)
3013659607e0Smrg		case " $new_libs " in
3014659607e0Smrg		*" $deplib "*) ;;
3015659607e0Smrg		*) new_libs="$deplib $new_libs" ;;
3016659607e0Smrg		esac
3017659607e0Smrg		;;
3018659607e0Smrg	      esac
3019659607e0Smrg	      ;;
3020659607e0Smrg	    esac
3021659607e0Smrg	  done
3022659607e0Smrg	  tmp_libs=
3023659607e0Smrg	  for deplib in $new_libs; do
3024659607e0Smrg	    case $deplib in
3025659607e0Smrg	    -L*)
3026659607e0Smrg	      case " $tmp_libs " in
3027659607e0Smrg	      *" $deplib "*) ;;
3028659607e0Smrg	      *) tmp_libs="$tmp_libs $deplib" ;;
3029659607e0Smrg	      esac
3030659607e0Smrg	      ;;
3031659607e0Smrg	    *) tmp_libs="$tmp_libs $deplib" ;;
3032659607e0Smrg	    esac
3033659607e0Smrg	  done
3034659607e0Smrg	  eval $var=\"$tmp_libs\"
3035659607e0Smrg	done # for var
3036659607e0Smrg      fi
3037659607e0Smrg      # Last step: remove runtime libs from dependency_libs
3038659607e0Smrg      # (they stay in deplibs)
3039659607e0Smrg      tmp_libs=
3040659607e0Smrg      for i in $dependency_libs ; do
3041659607e0Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
3042659607e0Smrg	*" $i "*)
3043659607e0Smrg	  i=""
3044659607e0Smrg	  ;;
3045659607e0Smrg	esac
3046659607e0Smrg	if test -n "$i" ; then
3047659607e0Smrg	  tmp_libs="$tmp_libs $i"
3048659607e0Smrg	fi
3049659607e0Smrg      done
3050659607e0Smrg      dependency_libs=$tmp_libs
3051659607e0Smrg    done # for pass
3052659607e0Smrg    if test "$linkmode" = prog; then
3053659607e0Smrg      dlfiles="$newdlfiles"
3054659607e0Smrg      dlprefiles="$newdlprefiles"
3055659607e0Smrg    fi
3056659607e0Smrg
3057659607e0Smrg    case $linkmode in
3058659607e0Smrg    oldlib)
3059659607e0Smrg      if test -n "$deplibs"; then
3060659607e0Smrg	$echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
3061659607e0Smrg      fi
3062659607e0Smrg
3063659607e0Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
3064659607e0Smrg	$echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
3065659607e0Smrg      fi
3066659607e0Smrg
3067659607e0Smrg      if test -n "$rpath"; then
3068659607e0Smrg	$echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
3069659607e0Smrg      fi
3070659607e0Smrg
3071659607e0Smrg      if test -n "$xrpath"; then
3072659607e0Smrg	$echo "$modename: warning: \`-R' is ignored for archives" 1>&2
3073659607e0Smrg      fi
3074659607e0Smrg
3075659607e0Smrg      if test -n "$vinfo"; then
3076659607e0Smrg	$echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2
3077659607e0Smrg      fi
3078659607e0Smrg
3079659607e0Smrg      if test -n "$release"; then
3080659607e0Smrg	$echo "$modename: warning: \`-release' is ignored for archives" 1>&2
3081659607e0Smrg      fi
3082659607e0Smrg
3083659607e0Smrg      if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
3084659607e0Smrg	$echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
3085659607e0Smrg      fi
3086659607e0Smrg
3087659607e0Smrg      # Now set the variables for building old libraries.
3088659607e0Smrg      build_libtool_libs=no
3089659607e0Smrg      oldlibs="$output"
3090659607e0Smrg      objs="$objs$old_deplibs"
3091659607e0Smrg      ;;
3092659607e0Smrg
3093659607e0Smrg    lib)
3094659607e0Smrg      # Make sure we only generate libraries of the form `libNAME.la'.
3095659607e0Smrg      case $outputname in
3096659607e0Smrg      lib*)
3097659607e0Smrg	name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
3098659607e0Smrg	eval shared_ext=\"$shrext_cmds\"
3099659607e0Smrg	eval libname=\"$libname_spec\"
3100659607e0Smrg	;;
3101659607e0Smrg      *)
3102659607e0Smrg	if test "$module" = no; then
3103659607e0Smrg	  $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
3104659607e0Smrg	  $echo "$help" 1>&2
3105659607e0Smrg	  exit $EXIT_FAILURE
3106659607e0Smrg	fi
3107659607e0Smrg	if test "$need_lib_prefix" != no; then
3108659607e0Smrg	  # Add the "lib" prefix for modules if required
3109659607e0Smrg	  name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
3110659607e0Smrg	  eval shared_ext=\"$shrext_cmds\"
3111659607e0Smrg	  eval libname=\"$libname_spec\"
3112659607e0Smrg	else
3113659607e0Smrg	  libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
3114659607e0Smrg	fi
3115659607e0Smrg	;;
3116659607e0Smrg      esac
3117659607e0Smrg
3118659607e0Smrg      if test -n "$objs"; then
3119659607e0Smrg	if test "$deplibs_check_method" != pass_all; then
3120659607e0Smrg	  $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
3121659607e0Smrg	  exit $EXIT_FAILURE
3122659607e0Smrg	else
3123659607e0Smrg	  $echo
3124659607e0Smrg	  $echo "*** Warning: Linking the shared library $output against the non-libtool"
3125659607e0Smrg	  $echo "*** objects $objs is not portable!"
3126659607e0Smrg	  libobjs="$libobjs $objs"
3127659607e0Smrg	fi
3128659607e0Smrg      fi
3129659607e0Smrg
3130659607e0Smrg      if test "$dlself" != no; then
3131659607e0Smrg	$echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2
3132659607e0Smrg      fi
3133659607e0Smrg
3134659607e0Smrg      set dummy $rpath
3135659607e0Smrg      if test "$#" -gt 2; then
3136659607e0Smrg	$echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
3137659607e0Smrg      fi
3138659607e0Smrg      install_libdir="$2"
3139659607e0Smrg
3140659607e0Smrg      oldlibs=
3141659607e0Smrg      if test -z "$rpath"; then
3142659607e0Smrg	if test "$build_libtool_libs" = yes; then
3143659607e0Smrg	  # Building a libtool convenience library.
3144659607e0Smrg	  # Some compilers have problems with a `.al' extension so
3145659607e0Smrg	  # convenience libraries should have the same extension an
3146659607e0Smrg	  # archive normally would.
3147659607e0Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
3148659607e0Smrg	  build_libtool_libs=convenience
3149659607e0Smrg	  build_old_libs=yes
3150659607e0Smrg	fi
3151659607e0Smrg
3152659607e0Smrg	if test -n "$vinfo"; then
3153659607e0Smrg	  $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2
3154659607e0Smrg	fi
3155659607e0Smrg
3156659607e0Smrg	if test -n "$release"; then
3157659607e0Smrg	  $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
3158659607e0Smrg	fi
3159659607e0Smrg      else
3160659607e0Smrg
3161659607e0Smrg	# Parse the version information argument.
3162659607e0Smrg	save_ifs="$IFS"; IFS=':'
3163659607e0Smrg	set dummy $vinfo 0 0 0
3164659607e0Smrg	IFS="$save_ifs"
3165659607e0Smrg
3166659607e0Smrg	if test -n "$8"; then
3167659607e0Smrg	  $echo "$modename: too many parameters to \`-version-info'" 1>&2
3168659607e0Smrg	  $echo "$help" 1>&2
3169659607e0Smrg	  exit $EXIT_FAILURE
3170659607e0Smrg	fi
3171659607e0Smrg
3172659607e0Smrg	# convert absolute version numbers to libtool ages
3173659607e0Smrg	# this retains compatibility with .la files and attempts
3174659607e0Smrg	# to make the code below a bit more comprehensible
3175659607e0Smrg
3176659607e0Smrg	case $vinfo_number in
3177659607e0Smrg	yes)
3178659607e0Smrg	  number_major="$2"
3179659607e0Smrg	  number_minor="$3"
3180659607e0Smrg	  number_revision="$4"
3181659607e0Smrg	  #
3182659607e0Smrg	  # There are really only two kinds -- those that
3183659607e0Smrg	  # use the current revision as the major version
3184659607e0Smrg	  # and those that subtract age and use age as
3185659607e0Smrg	  # a minor version.  But, then there is irix
3186659607e0Smrg	  # which has an extra 1 added just for fun
3187659607e0Smrg	  #
3188659607e0Smrg	  case $version_type in
31896aab59a7Smrg	  darwin|linux|osf|windows)
3190659607e0Smrg	    current=`expr $number_major + $number_minor`
3191659607e0Smrg	    age="$number_minor"
3192659607e0Smrg	    revision="$number_revision"
3193659607e0Smrg	    ;;
3194659607e0Smrg	  freebsd-aout|freebsd-elf|sunos)
3195659607e0Smrg	    current="$number_major"
3196659607e0Smrg	    revision="$number_minor"
3197659607e0Smrg	    age="0"
3198659607e0Smrg	    ;;
3199659607e0Smrg	  irix|nonstopux)
32006aab59a7Smrg	    current=`expr $number_major + $number_minor - 1`
3201659607e0Smrg	    age="$number_minor"
3202659607e0Smrg	    revision="$number_minor"
3203659607e0Smrg	    ;;
3204659607e0Smrg	  esac
3205659607e0Smrg	  ;;
3206659607e0Smrg	no)
3207659607e0Smrg	  current="$2"
3208659607e0Smrg	  revision="$3"
3209659607e0Smrg	  age="$4"
3210659607e0Smrg	  ;;
3211659607e0Smrg	esac
3212659607e0Smrg
3213659607e0Smrg	# Check that each of the things are valid numbers.
3214659607e0Smrg	case $current in
3215659607e0Smrg	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]) ;;
3216659607e0Smrg	*)
3217659607e0Smrg	  $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2
3218659607e0Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3219659607e0Smrg	  exit $EXIT_FAILURE
3220659607e0Smrg	  ;;
3221659607e0Smrg	esac
3222659607e0Smrg
3223659607e0Smrg	case $revision in
3224659607e0Smrg	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]) ;;
3225659607e0Smrg	*)
3226659607e0Smrg	  $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2
3227659607e0Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3228659607e0Smrg	  exit $EXIT_FAILURE
3229659607e0Smrg	  ;;
3230659607e0Smrg	esac
3231659607e0Smrg
3232659607e0Smrg	case $age in
3233659607e0Smrg	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]) ;;
3234659607e0Smrg	*)
3235659607e0Smrg	  $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2
3236659607e0Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3237659607e0Smrg	  exit $EXIT_FAILURE
3238659607e0Smrg	  ;;
3239659607e0Smrg	esac
3240659607e0Smrg
3241659607e0Smrg	if test "$age" -gt "$current"; then
3242659607e0Smrg	  $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
3243659607e0Smrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3244659607e0Smrg	  exit $EXIT_FAILURE
3245659607e0Smrg	fi
3246659607e0Smrg
3247659607e0Smrg	# Calculate the version variables.
3248659607e0Smrg	major=
3249659607e0Smrg	versuffix=
3250659607e0Smrg	verstring=
3251659607e0Smrg	case $version_type in
3252659607e0Smrg	none) ;;
3253659607e0Smrg
3254659607e0Smrg	darwin)
3255659607e0Smrg	  # Like Linux, but with the current version available in
3256659607e0Smrg	  # verstring for coding it into the library header
3257659607e0Smrg	  major=.`expr $current - $age`
3258659607e0Smrg	  versuffix="$major.$age.$revision"
3259659607e0Smrg	  # Darwin ld doesn't like 0 for these options...
3260659607e0Smrg	  minor_current=`expr $current + 1`
32616aab59a7Smrg	  verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
3262659607e0Smrg	  ;;
3263659607e0Smrg
3264659607e0Smrg	freebsd-aout)
3265659607e0Smrg	  major=".$current"
3266659607e0Smrg	  versuffix=".$current.$revision";
3267659607e0Smrg	  ;;
3268659607e0Smrg
3269659607e0Smrg	freebsd-elf)
3270659607e0Smrg	  major=".$current"
3271659607e0Smrg	  versuffix=".$current";
3272659607e0Smrg	  ;;
3273659607e0Smrg
3274659607e0Smrg	irix | nonstopux)
32756aab59a7Smrg	  major=`expr $current - $age + 1`
32766aab59a7Smrg
3277659607e0Smrg	  case $version_type in
3278659607e0Smrg	    nonstopux) verstring_prefix=nonstopux ;;
3279659607e0Smrg	    *)         verstring_prefix=sgi ;;
3280659607e0Smrg	  esac
3281659607e0Smrg	  verstring="$verstring_prefix$major.$revision"
3282659607e0Smrg
3283659607e0Smrg	  # Add in all the interfaces that we are compatible with.
3284659607e0Smrg	  loop=$revision
3285659607e0Smrg	  while test "$loop" -ne 0; do
3286659607e0Smrg	    iface=`expr $revision - $loop`
3287659607e0Smrg	    loop=`expr $loop - 1`
3288659607e0Smrg	    verstring="$verstring_prefix$major.$iface:$verstring"
3289659607e0Smrg	  done
3290659607e0Smrg
3291659607e0Smrg	  # Before this point, $major must not contain `.'.
3292659607e0Smrg	  major=.$major
3293659607e0Smrg	  versuffix="$major.$revision"
3294659607e0Smrg	  ;;
3295659607e0Smrg
3296659607e0Smrg	linux)
3297659607e0Smrg	  major=.`expr $current - $age`
3298659607e0Smrg	  versuffix="$major.$age.$revision"
3299659607e0Smrg	  ;;
3300659607e0Smrg
3301659607e0Smrg	osf)
3302659607e0Smrg	  major=.`expr $current - $age`
3303659607e0Smrg	  versuffix=".$current.$age.$revision"
3304659607e0Smrg	  verstring="$current.$age.$revision"
3305659607e0Smrg
3306659607e0Smrg	  # Add in all the interfaces that we are compatible with.
3307659607e0Smrg	  loop=$age
3308659607e0Smrg	  while test "$loop" -ne 0; do
3309659607e0Smrg	    iface=`expr $current - $loop`
3310659607e0Smrg	    loop=`expr $loop - 1`
3311659607e0Smrg	    verstring="$verstring:${iface}.0"
3312659607e0Smrg	  done
3313659607e0Smrg
3314659607e0Smrg	  # Make executables depend on our current version.
3315659607e0Smrg	  verstring="$verstring:${current}.0"
3316659607e0Smrg	  ;;
3317659607e0Smrg
3318659607e0Smrg	sunos)
3319659607e0Smrg	  major=".$current"
3320659607e0Smrg	  versuffix=".$current.$revision"
3321659607e0Smrg	  ;;
3322659607e0Smrg
3323659607e0Smrg	windows)
3324659607e0Smrg	  # Use '-' rather than '.', since we only want one
3325659607e0Smrg	  # extension on DOS 8.3 filesystems.
3326659607e0Smrg	  major=`expr $current - $age`
3327659607e0Smrg	  versuffix="-$major"
3328659607e0Smrg	  ;;
3329659607e0Smrg
3330659607e0Smrg	*)
3331659607e0Smrg	  $echo "$modename: unknown library version type \`$version_type'" 1>&2
3332659607e0Smrg	  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
3333659607e0Smrg	  exit $EXIT_FAILURE
3334659607e0Smrg	  ;;
3335659607e0Smrg	esac
3336659607e0Smrg
3337659607e0Smrg	# Clear the version info if we defaulted, and they specified a release.
3338659607e0Smrg	if test -z "$vinfo" && test -n "$release"; then
3339659607e0Smrg	  major=
3340659607e0Smrg	  case $version_type in
3341659607e0Smrg	  darwin)
3342659607e0Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
3343659607e0Smrg	    # problems, so we reset it completely
3344659607e0Smrg	    verstring=
3345659607e0Smrg	    ;;
3346659607e0Smrg	  *)
3347659607e0Smrg	    verstring="0.0"
3348659607e0Smrg	    ;;
3349659607e0Smrg	  esac
3350659607e0Smrg	  if test "$need_version" = no; then
3351659607e0Smrg	    versuffix=
3352659607e0Smrg	  else
3353659607e0Smrg	    versuffix=".0.0"
3354659607e0Smrg	  fi
3355659607e0Smrg	fi
3356659607e0Smrg
3357659607e0Smrg	# Remove version info from name if versioning should be avoided
3358659607e0Smrg	if test "$avoid_version" = yes && test "$need_version" = no; then
3359659607e0Smrg	  major=
3360659607e0Smrg	  versuffix=
3361659607e0Smrg	  verstring=""
3362659607e0Smrg	fi
3363659607e0Smrg
3364659607e0Smrg	# Check to see if the archive will have undefined symbols.
3365659607e0Smrg	if test "$allow_undefined" = yes; then
3366659607e0Smrg	  if test "$allow_undefined_flag" = unsupported; then
3367659607e0Smrg	    $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
3368659607e0Smrg	    build_libtool_libs=no
3369659607e0Smrg	    build_old_libs=yes
3370659607e0Smrg	  fi
3371659607e0Smrg	else
3372659607e0Smrg	  # Don't allow undefined symbols.
3373659607e0Smrg	  allow_undefined_flag="$no_undefined_flag"
3374659607e0Smrg	fi
3375659607e0Smrg      fi
3376659607e0Smrg
3377659607e0Smrg      if test "$mode" != relink; then
3378659607e0Smrg	# Remove our outputs, but don't remove object files since they
3379659607e0Smrg	# may have been created when compiling PIC objects.
3380659607e0Smrg	removelist=
3381659607e0Smrg	tempremovelist=`$echo "$output_objdir/*"`
3382659607e0Smrg	for p in $tempremovelist; do
3383659607e0Smrg	  case $p in
3384659607e0Smrg	    *.$objext)
3385659607e0Smrg	       ;;
3386659607e0Smrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
3387659607e0Smrg	       if test "X$precious_files_regex" != "X"; then
3388659607e0Smrg	         if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
3389659607e0Smrg	         then
3390659607e0Smrg		   continue
3391659607e0Smrg		 fi
3392659607e0Smrg	       fi
3393659607e0Smrg	       removelist="$removelist $p"
3394659607e0Smrg	       ;;
3395659607e0Smrg	    *) ;;
3396659607e0Smrg	  esac
3397659607e0Smrg	done
3398659607e0Smrg	if test -n "$removelist"; then
3399659607e0Smrg	  $show "${rm}r $removelist"
3400659607e0Smrg	  $run ${rm}r $removelist
3401659607e0Smrg	fi
3402659607e0Smrg      fi
3403659607e0Smrg
3404659607e0Smrg      # Now set the variables for building old libraries.
3405659607e0Smrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
3406659607e0Smrg	oldlibs="$oldlibs $output_objdir/$libname.$libext"
3407659607e0Smrg
3408659607e0Smrg	# Transform .lo files to .o files.
3409659607e0Smrg	oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
3410659607e0Smrg      fi
3411659607e0Smrg
3412659607e0Smrg      # Eliminate all temporary directories.
34136aab59a7Smrg      for path in $notinst_path; do
34146aab59a7Smrg	lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
34156aab59a7Smrg	deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
34166aab59a7Smrg	dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
34176aab59a7Smrg      done
3418659607e0Smrg
3419659607e0Smrg      if test -n "$xrpath"; then
3420659607e0Smrg	# If the user specified any rpath flags, then add them.
3421659607e0Smrg	temp_xrpath=
3422659607e0Smrg	for libdir in $xrpath; do
3423659607e0Smrg	  temp_xrpath="$temp_xrpath -R$libdir"
3424659607e0Smrg	  case "$finalize_rpath " in
3425659607e0Smrg	  *" $libdir "*) ;;
3426659607e0Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
3427659607e0Smrg	  esac
3428659607e0Smrg	done
3429659607e0Smrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
3430659607e0Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
3431659607e0Smrg	fi
3432659607e0Smrg      fi
3433659607e0Smrg
3434659607e0Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
3435659607e0Smrg      old_dlfiles="$dlfiles"
3436659607e0Smrg      dlfiles=
3437659607e0Smrg      for lib in $old_dlfiles; do
3438659607e0Smrg	case " $dlprefiles $dlfiles " in
3439659607e0Smrg	*" $lib "*) ;;
3440659607e0Smrg	*) dlfiles="$dlfiles $lib" ;;
3441659607e0Smrg	esac
3442659607e0Smrg      done
3443659607e0Smrg
3444659607e0Smrg      # Make sure dlprefiles contains only unique files
3445659607e0Smrg      old_dlprefiles="$dlprefiles"
3446659607e0Smrg      dlprefiles=
3447659607e0Smrg      for lib in $old_dlprefiles; do
3448659607e0Smrg	case "$dlprefiles " in
3449659607e0Smrg	*" $lib "*) ;;
3450659607e0Smrg	*) dlprefiles="$dlprefiles $lib" ;;
3451659607e0Smrg	esac
3452659607e0Smrg      done
3453659607e0Smrg
3454659607e0Smrg      if test "$build_libtool_libs" = yes; then
3455659607e0Smrg	if test -n "$rpath"; then
3456659607e0Smrg	  case $host in
3457659607e0Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
3458659607e0Smrg	    # these systems don't actually have a c library (as such)!
3459659607e0Smrg	    ;;
3460659607e0Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
3461659607e0Smrg	    # Rhapsody C library is in the System framework
3462659607e0Smrg	    deplibs="$deplibs -framework System"
3463659607e0Smrg	    ;;
3464659607e0Smrg	  *-*-netbsd*)
3465659607e0Smrg	    # Don't link with libc until the a.out ld.so is fixed.
3466659607e0Smrg	    ;;
3467659607e0Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
3468659607e0Smrg	    # Do not include libc due to us having libc/libc_r.
3469659607e0Smrg	    ;;
3470659607e0Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
3471659607e0Smrg	    # Causes problems with __ctype
3472659607e0Smrg	    ;;
3473659607e0Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
3474659607e0Smrg	    # Compiler inserts libc in the correct place for threads to work
3475659607e0Smrg	    ;;
3476659607e0Smrg 	  *)
3477659607e0Smrg	    # Add libc to deplibs on all other systems if necessary.
3478659607e0Smrg	    if test "$build_libtool_need_lc" = "yes"; then
3479659607e0Smrg	      deplibs="$deplibs -lc"
3480659607e0Smrg	    fi
3481659607e0Smrg	    ;;
3482659607e0Smrg	  esac
3483659607e0Smrg	fi
3484659607e0Smrg
3485659607e0Smrg	# Transform deplibs into only deplibs that can be linked in shared.
3486659607e0Smrg	name_save=$name
3487659607e0Smrg	libname_save=$libname
3488659607e0Smrg	release_save=$release
3489659607e0Smrg	versuffix_save=$versuffix
3490659607e0Smrg	major_save=$major
3491659607e0Smrg	# I'm not sure if I'm treating the release correctly.  I think
3492659607e0Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
3493659607e0Smrg	# add it in twice.  Is that correct?
3494659607e0Smrg	release=""
3495659607e0Smrg	versuffix=""
3496659607e0Smrg	major=""
3497659607e0Smrg	newdeplibs=
3498659607e0Smrg	droppeddeps=no
3499659607e0Smrg	case $deplibs_check_method in
3500659607e0Smrg	pass_all)
3501659607e0Smrg	  # Don't check for shared/static.  Everything works.
3502659607e0Smrg	  # This might be a little naive.  We might want to check
3503659607e0Smrg	  # whether the library exists or not.  But this is on
3504659607e0Smrg	  # osf3 & osf4 and I'm not really sure... Just
3505659607e0Smrg	  # implementing what was already the behavior.
3506659607e0Smrg	  newdeplibs=$deplibs
3507659607e0Smrg	  ;;
3508659607e0Smrg	test_compile)
3509659607e0Smrg	  # This code stresses the "libraries are programs" paradigm to its
3510659607e0Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
3511659607e0Smrg	  # against the deplibs as a proxy for the library.  Then we can check
3512659607e0Smrg	  # whether they linked in statically or dynamically with ldd.
3513659607e0Smrg	  $rm conftest.c
3514659607e0Smrg	  cat > conftest.c <<EOF
3515659607e0Smrg	  int main() { return 0; }
3516659607e0SmrgEOF
3517659607e0Smrg	  $rm conftest
35186aab59a7Smrg	  $LTCC $LTCFLAGS -o conftest conftest.c $deplibs
35196aab59a7Smrg	  if test "$?" -eq 0 ; then
3520659607e0Smrg	    ldd_output=`ldd conftest`
3521659607e0Smrg	    for i in $deplibs; do
3522659607e0Smrg	      name=`expr $i : '-l\(.*\)'`
3523659607e0Smrg	      # If $name is empty we are operating on a -L argument.
35246aab59a7Smrg              if test "$name" != "" && test "$name" -ne "0"; then
3525659607e0Smrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3526659607e0Smrg		  case " $predeps $postdeps " in
3527659607e0Smrg		  *" $i "*)
3528659607e0Smrg		    newdeplibs="$newdeplibs $i"
3529659607e0Smrg		    i=""
3530659607e0Smrg		    ;;
3531659607e0Smrg		  esac
3532659607e0Smrg	        fi
3533659607e0Smrg		if test -n "$i" ; then
3534659607e0Smrg		  libname=`eval \\$echo \"$libname_spec\"`
3535659607e0Smrg		  deplib_matches=`eval \\$echo \"$library_names_spec\"`
3536659607e0Smrg		  set dummy $deplib_matches
3537659607e0Smrg		  deplib_match=$2
3538659607e0Smrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
3539659607e0Smrg		    newdeplibs="$newdeplibs $i"
3540659607e0Smrg		  else
3541659607e0Smrg		    droppeddeps=yes
3542659607e0Smrg		    $echo
3543659607e0Smrg		    $echo "*** Warning: dynamic linker does not accept needed library $i."
3544659607e0Smrg		    $echo "*** I have the capability to make that library automatically link in when"
3545659607e0Smrg		    $echo "*** you link to this library.  But I can only do this if you have a"
3546659607e0Smrg		    $echo "*** shared version of the library, which I believe you do not have"
3547659607e0Smrg		    $echo "*** because a test_compile did reveal that the linker did not use it for"
3548659607e0Smrg		    $echo "*** its dynamic dependency list that programs get resolved with at runtime."
3549659607e0Smrg		  fi
3550659607e0Smrg		fi
3551659607e0Smrg	      else
3552659607e0Smrg		newdeplibs="$newdeplibs $i"
3553659607e0Smrg	      fi
3554659607e0Smrg	    done
3555659607e0Smrg	  else
3556659607e0Smrg	    # Error occurred in the first compile.  Let's try to salvage
3557659607e0Smrg	    # the situation: Compile a separate program for each library.
3558659607e0Smrg	    for i in $deplibs; do
3559659607e0Smrg	      name=`expr $i : '-l\(.*\)'`
3560659607e0Smrg	      # If $name is empty we are operating on a -L argument.
3561659607e0Smrg              if test "$name" != "" && test "$name" != "0"; then
3562659607e0Smrg		$rm conftest
35636aab59a7Smrg		$LTCC $LTCFLAGS -o conftest conftest.c $i
35646aab59a7Smrg		# Did it work?
35656aab59a7Smrg		if test "$?" -eq 0 ; then
3566659607e0Smrg		  ldd_output=`ldd conftest`
3567659607e0Smrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3568659607e0Smrg		    case " $predeps $postdeps " in
3569659607e0Smrg		    *" $i "*)
3570659607e0Smrg		      newdeplibs="$newdeplibs $i"
3571659607e0Smrg		      i=""
3572659607e0Smrg		      ;;
3573659607e0Smrg		    esac
3574659607e0Smrg		  fi
3575659607e0Smrg		  if test -n "$i" ; then
3576659607e0Smrg		    libname=`eval \\$echo \"$libname_spec\"`
3577659607e0Smrg		    deplib_matches=`eval \\$echo \"$library_names_spec\"`
3578659607e0Smrg		    set dummy $deplib_matches
3579659607e0Smrg		    deplib_match=$2
3580659607e0Smrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
3581659607e0Smrg		      newdeplibs="$newdeplibs $i"
3582659607e0Smrg		    else
3583659607e0Smrg		      droppeddeps=yes
3584659607e0Smrg		      $echo
3585659607e0Smrg		      $echo "*** Warning: dynamic linker does not accept needed library $i."
3586659607e0Smrg		      $echo "*** I have the capability to make that library automatically link in when"
3587659607e0Smrg		      $echo "*** you link to this library.  But I can only do this if you have a"
3588659607e0Smrg		      $echo "*** shared version of the library, which you do not appear to have"
3589659607e0Smrg		      $echo "*** because a test_compile did reveal that the linker did not use this one"
3590659607e0Smrg		      $echo "*** as a dynamic dependency that programs can get resolved with at runtime."
3591659607e0Smrg		    fi
3592659607e0Smrg		  fi
3593659607e0Smrg		else
3594659607e0Smrg		  droppeddeps=yes
3595659607e0Smrg		  $echo
3596659607e0Smrg		  $echo "*** Warning!  Library $i is needed by this library but I was not able to"
35976aab59a7Smrg		  $echo "***  make it link in!  You will probably need to install it or some"
3598659607e0Smrg		  $echo "*** library that it depends on before this library will be fully"
3599659607e0Smrg		  $echo "*** functional.  Installing it before continuing would be even better."
3600659607e0Smrg		fi
3601659607e0Smrg	      else
3602659607e0Smrg		newdeplibs="$newdeplibs $i"
3603659607e0Smrg	      fi
3604659607e0Smrg	    done
3605659607e0Smrg	  fi
3606659607e0Smrg	  ;;
3607659607e0Smrg	file_magic*)
3608659607e0Smrg	  set dummy $deplibs_check_method
3609659607e0Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
3610659607e0Smrg	  for a_deplib in $deplibs; do
3611659607e0Smrg	    name=`expr $a_deplib : '-l\(.*\)'`
3612659607e0Smrg	    # If $name is empty we are operating on a -L argument.
3613659607e0Smrg            if test "$name" != "" && test  "$name" != "0"; then
3614659607e0Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3615659607e0Smrg		case " $predeps $postdeps " in
3616659607e0Smrg		*" $a_deplib "*)
3617659607e0Smrg		  newdeplibs="$newdeplibs $a_deplib"
3618659607e0Smrg		  a_deplib=""
3619659607e0Smrg		  ;;
3620659607e0Smrg		esac
3621659607e0Smrg	      fi
3622659607e0Smrg	      if test -n "$a_deplib" ; then
3623659607e0Smrg		libname=`eval \\$echo \"$libname_spec\"`
3624659607e0Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
3625659607e0Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
3626659607e0Smrg		  for potent_lib in $potential_libs; do
3627659607e0Smrg		      # Follow soft links.
3628659607e0Smrg		      if ls -lLd "$potent_lib" 2>/dev/null \
3629659607e0Smrg			 | grep " -> " >/dev/null; then
3630659607e0Smrg			continue
3631659607e0Smrg		      fi
3632659607e0Smrg		      # The statement above tries to avoid entering an
3633659607e0Smrg		      # endless loop below, in case of cyclic links.
3634659607e0Smrg		      # We might still enter an endless loop, since a link
3635659607e0Smrg		      # loop can be closed while we follow links,
3636659607e0Smrg		      # but so what?
3637659607e0Smrg		      potlib="$potent_lib"
3638659607e0Smrg		      while test -h "$potlib" 2>/dev/null; do
3639659607e0Smrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
3640659607e0Smrg			case $potliblink in
3641659607e0Smrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
3642659607e0Smrg			*) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
3643659607e0Smrg			esac
3644659607e0Smrg		      done
3645659607e0Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
3646659607e0Smrg			 | ${SED} 10q \
3647659607e0Smrg			 | $EGREP "$file_magic_regex" > /dev/null; then
3648659607e0Smrg			newdeplibs="$newdeplibs $a_deplib"
3649659607e0Smrg			a_deplib=""
3650659607e0Smrg			break 2
3651659607e0Smrg		      fi
3652659607e0Smrg		  done
3653659607e0Smrg		done
3654659607e0Smrg	      fi
3655659607e0Smrg	      if test -n "$a_deplib" ; then
3656659607e0Smrg		droppeddeps=yes
3657659607e0Smrg		$echo
3658659607e0Smrg		$echo "*** Warning: linker path does not have real file for library $a_deplib."
3659659607e0Smrg		$echo "*** I have the capability to make that library automatically link in when"
3660659607e0Smrg		$echo "*** you link to this library.  But I can only do this if you have a"
3661659607e0Smrg		$echo "*** shared version of the library, which you do not appear to have"
3662659607e0Smrg		$echo "*** because I did check the linker path looking for a file starting"
3663659607e0Smrg		if test -z "$potlib" ; then
3664659607e0Smrg		  $echo "*** with $libname but no candidates were found. (...for file magic test)"
3665659607e0Smrg		else
3666659607e0Smrg		  $echo "*** with $libname and none of the candidates passed a file format test"
3667659607e0Smrg		  $echo "*** using a file magic. Last file checked: $potlib"
3668659607e0Smrg		fi
3669659607e0Smrg	      fi
3670659607e0Smrg	    else
3671659607e0Smrg	      # Add a -L argument.
3672659607e0Smrg	      newdeplibs="$newdeplibs $a_deplib"
3673659607e0Smrg	    fi
3674659607e0Smrg	  done # Gone through all deplibs.
3675659607e0Smrg	  ;;
3676659607e0Smrg	match_pattern*)
3677659607e0Smrg	  set dummy $deplibs_check_method
3678659607e0Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
3679659607e0Smrg	  for a_deplib in $deplibs; do
3680659607e0Smrg	    name=`expr $a_deplib : '-l\(.*\)'`
3681659607e0Smrg	    # If $name is empty we are operating on a -L argument.
3682659607e0Smrg	    if test -n "$name" && test "$name" != "0"; then
3683659607e0Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3684659607e0Smrg		case " $predeps $postdeps " in
3685659607e0Smrg		*" $a_deplib "*)
3686659607e0Smrg		  newdeplibs="$newdeplibs $a_deplib"
3687659607e0Smrg		  a_deplib=""
3688659607e0Smrg		  ;;
3689659607e0Smrg		esac
3690659607e0Smrg	      fi
3691659607e0Smrg	      if test -n "$a_deplib" ; then
3692659607e0Smrg		libname=`eval \\$echo \"$libname_spec\"`
3693659607e0Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
3694659607e0Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
3695659607e0Smrg		  for potent_lib in $potential_libs; do
3696659607e0Smrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
3697659607e0Smrg		    if eval $echo \"$potent_lib\" 2>/dev/null \
3698659607e0Smrg		        | ${SED} 10q \
3699659607e0Smrg		        | $EGREP "$match_pattern_regex" > /dev/null; then
3700659607e0Smrg		      newdeplibs="$newdeplibs $a_deplib"
3701659607e0Smrg		      a_deplib=""
3702659607e0Smrg		      break 2
3703659607e0Smrg		    fi
3704659607e0Smrg		  done
3705659607e0Smrg		done
3706659607e0Smrg	      fi
3707659607e0Smrg	      if test -n "$a_deplib" ; then
3708659607e0Smrg		droppeddeps=yes
3709659607e0Smrg		$echo
3710659607e0Smrg		$echo "*** Warning: linker path does not have real file for library $a_deplib."
3711659607e0Smrg		$echo "*** I have the capability to make that library automatically link in when"
3712659607e0Smrg		$echo "*** you link to this library.  But I can only do this if you have a"
3713659607e0Smrg		$echo "*** shared version of the library, which you do not appear to have"
3714659607e0Smrg		$echo "*** because I did check the linker path looking for a file starting"
3715659607e0Smrg		if test -z "$potlib" ; then
3716659607e0Smrg		  $echo "*** with $libname but no candidates were found. (...for regex pattern test)"
3717659607e0Smrg		else
3718659607e0Smrg		  $echo "*** with $libname and none of the candidates passed a file format test"
3719659607e0Smrg		  $echo "*** using a regex pattern. Last file checked: $potlib"
3720659607e0Smrg		fi
3721659607e0Smrg	      fi
3722659607e0Smrg	    else
3723659607e0Smrg	      # Add a -L argument.
3724659607e0Smrg	      newdeplibs="$newdeplibs $a_deplib"
3725659607e0Smrg	    fi
3726659607e0Smrg	  done # Gone through all deplibs.
3727659607e0Smrg	  ;;
3728659607e0Smrg	none | unknown | *)
3729659607e0Smrg	  newdeplibs=""
3730659607e0Smrg	  tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
3731659607e0Smrg	    -e 's/ -[LR][^ ]*//g'`
3732659607e0Smrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3733659607e0Smrg	    for i in $predeps $postdeps ; do
3734659607e0Smrg	      # can't use Xsed below, because $i might contain '/'
3735659607e0Smrg	      tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"`
3736659607e0Smrg	    done
3737659607e0Smrg	  fi
3738659607e0Smrg	  if $echo "X $tmp_deplibs" | $Xsed -e 's/[ 	]//g' \
3739659607e0Smrg	    | grep . >/dev/null; then
3740659607e0Smrg	    $echo
3741659607e0Smrg	    if test "X$deplibs_check_method" = "Xnone"; then
3742659607e0Smrg	      $echo "*** Warning: inter-library dependencies are not supported in this platform."
3743659607e0Smrg	    else
3744659607e0Smrg	      $echo "*** Warning: inter-library dependencies are not known to be supported."
3745659607e0Smrg	    fi
3746659607e0Smrg	    $echo "*** All declared inter-library dependencies are being dropped."
3747659607e0Smrg	    droppeddeps=yes
3748659607e0Smrg	  fi
3749659607e0Smrg	  ;;
3750659607e0Smrg	esac
3751659607e0Smrg	versuffix=$versuffix_save
3752659607e0Smrg	major=$major_save
3753659607e0Smrg	release=$release_save
3754659607e0Smrg	libname=$libname_save
3755659607e0Smrg	name=$name_save
3756659607e0Smrg
3757659607e0Smrg	case $host in
3758659607e0Smrg	*-*-rhapsody* | *-*-darwin1.[012])
3759659607e0Smrg	  # On Rhapsody replace the C library is the System framework
3760659607e0Smrg	  newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'`
3761659607e0Smrg	  ;;
3762659607e0Smrg	esac
3763659607e0Smrg
3764659607e0Smrg	if test "$droppeddeps" = yes; then
3765659607e0Smrg	  if test "$module" = yes; then
3766659607e0Smrg	    $echo
3767659607e0Smrg	    $echo "*** Warning: libtool could not satisfy all declared inter-library"
3768659607e0Smrg	    $echo "*** dependencies of module $libname.  Therefore, libtool will create"
3769659607e0Smrg	    $echo "*** a static module, that should work as long as the dlopening"
3770659607e0Smrg	    $echo "*** application is linked with the -dlopen flag."
3771659607e0Smrg	    if test -z "$global_symbol_pipe"; then
3772659607e0Smrg	      $echo
3773659607e0Smrg	      $echo "*** However, this would only work if libtool was able to extract symbol"
3774659607e0Smrg	      $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
3775659607e0Smrg	      $echo "*** not find such a program.  So, this module is probably useless."
3776659607e0Smrg	      $echo "*** \`nm' from GNU binutils and a full rebuild may help."
3777659607e0Smrg	    fi
3778659607e0Smrg	    if test "$build_old_libs" = no; then
3779659607e0Smrg	      oldlibs="$output_objdir/$libname.$libext"
3780659607e0Smrg	      build_libtool_libs=module
3781659607e0Smrg	      build_old_libs=yes
3782659607e0Smrg	    else
3783659607e0Smrg	      build_libtool_libs=no
3784659607e0Smrg	    fi
3785659607e0Smrg	  else
3786659607e0Smrg	    $echo "*** The inter-library dependencies that have been dropped here will be"
3787659607e0Smrg	    $echo "*** automatically added whenever a program is linked with this library"
3788659607e0Smrg	    $echo "*** or is declared to -dlopen it."
3789659607e0Smrg
3790659607e0Smrg	    if test "$allow_undefined" = no; then
3791659607e0Smrg	      $echo
3792659607e0Smrg	      $echo "*** Since this library must not contain undefined symbols,"
3793659607e0Smrg	      $echo "*** because either the platform does not support them or"
3794659607e0Smrg	      $echo "*** it was explicitly requested with -no-undefined,"
3795659607e0Smrg	      $echo "*** libtool will only create a static version of it."
3796659607e0Smrg	      if test "$build_old_libs" = no; then
3797659607e0Smrg		oldlibs="$output_objdir/$libname.$libext"
3798659607e0Smrg		build_libtool_libs=module
3799659607e0Smrg		build_old_libs=yes
3800659607e0Smrg	      else
3801659607e0Smrg		build_libtool_libs=no
3802659607e0Smrg	      fi
3803659607e0Smrg	    fi
3804659607e0Smrg	  fi
3805659607e0Smrg	fi
3806659607e0Smrg	# Done checking deplibs!
3807659607e0Smrg	deplibs=$newdeplibs
3808659607e0Smrg      fi
3809659607e0Smrg
3810659607e0Smrg
3811659607e0Smrg      # move library search paths that coincide with paths to not yet
3812659607e0Smrg      # installed libraries to the beginning of the library search list
3813659607e0Smrg      new_libs=
3814659607e0Smrg      for path in $notinst_path; do
3815659607e0Smrg	case " $new_libs " in
3816659607e0Smrg	*" -L$path/$objdir "*) ;;
3817659607e0Smrg	*)
3818659607e0Smrg	  case " $deplibs " in
3819659607e0Smrg	  *" -L$path/$objdir "*)
3820659607e0Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
3821659607e0Smrg	  esac
3822659607e0Smrg	  ;;
3823659607e0Smrg	esac
3824659607e0Smrg      done
3825659607e0Smrg      for deplib in $deplibs; do
3826659607e0Smrg	case $deplib in
3827659607e0Smrg	-L*)
3828659607e0Smrg	  case " $new_libs " in
3829659607e0Smrg	  *" $deplib "*) ;;
3830659607e0Smrg	  *) new_libs="$new_libs $deplib" ;;
3831659607e0Smrg	  esac
3832659607e0Smrg	  ;;
3833659607e0Smrg	*) new_libs="$new_libs $deplib" ;;
3834659607e0Smrg	esac
3835659607e0Smrg      done
3836659607e0Smrg      deplibs="$new_libs"
3837659607e0Smrg
3838659607e0Smrg
3839659607e0Smrg      # All the library-specific variables (install_libdir is set above).
3840659607e0Smrg      library_names=
3841659607e0Smrg      old_library=
3842659607e0Smrg      dlname=
3843659607e0Smrg
3844659607e0Smrg      # Test again, we may have decided not to build it any more
3845659607e0Smrg      if test "$build_libtool_libs" = yes; then
3846659607e0Smrg	if test "$hardcode_into_libs" = yes; then
3847659607e0Smrg	  # Hardcode the library paths
3848659607e0Smrg	  hardcode_libdirs=
3849659607e0Smrg	  dep_rpath=
3850659607e0Smrg	  rpath="$finalize_rpath"
3851659607e0Smrg	  test "$mode" != relink && rpath="$compile_rpath$rpath"
3852659607e0Smrg	  for libdir in $rpath; do
3853659607e0Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
3854659607e0Smrg	      if test -n "$hardcode_libdir_separator"; then
3855659607e0Smrg		if test -z "$hardcode_libdirs"; then
3856659607e0Smrg		  hardcode_libdirs="$libdir"
3857659607e0Smrg		else
3858659607e0Smrg		  # Just accumulate the unique libdirs.
3859659607e0Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
3860659607e0Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
3861659607e0Smrg		    ;;
3862659607e0Smrg		  *)
3863659607e0Smrg		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
3864659607e0Smrg		    ;;
3865659607e0Smrg		  esac
3866659607e0Smrg		fi
3867659607e0Smrg	      else
3868659607e0Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
3869659607e0Smrg		dep_rpath="$dep_rpath $flag"
3870659607e0Smrg	      fi
3871659607e0Smrg	    elif test -n "$runpath_var"; then
3872659607e0Smrg	      case "$perm_rpath " in
3873659607e0Smrg	      *" $libdir "*) ;;
3874659607e0Smrg	      *) perm_rpath="$perm_rpath $libdir" ;;
3875659607e0Smrg	      esac
3876659607e0Smrg	    fi
3877659607e0Smrg	  done
3878659607e0Smrg	  # Substitute the hardcoded libdirs into the rpath.
3879659607e0Smrg	  if test -n "$hardcode_libdir_separator" &&
3880659607e0Smrg	     test -n "$hardcode_libdirs"; then
3881659607e0Smrg	    libdir="$hardcode_libdirs"
3882659607e0Smrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
38836aab59a7Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
3884659607e0Smrg	    else
3885659607e0Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
3886659607e0Smrg	    fi
3887659607e0Smrg	  fi
3888659607e0Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
3889659607e0Smrg	    # We should set the runpath_var.
3890659607e0Smrg	    rpath=
3891659607e0Smrg	    for dir in $perm_rpath; do
3892659607e0Smrg	      rpath="$rpath$dir:"
3893659607e0Smrg	    done
3894659607e0Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
3895659607e0Smrg	  fi
3896659607e0Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
3897659607e0Smrg	fi
3898659607e0Smrg
3899659607e0Smrg	shlibpath="$finalize_shlibpath"
3900659607e0Smrg	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
3901659607e0Smrg	if test -n "$shlibpath"; then
3902659607e0Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
3903659607e0Smrg	fi
3904659607e0Smrg
3905659607e0Smrg	# Get the real and link names of the library.
3906659607e0Smrg	eval shared_ext=\"$shrext_cmds\"
3907659607e0Smrg	eval library_names=\"$library_names_spec\"
3908659607e0Smrg	set dummy $library_names
3909659607e0Smrg	realname="$2"
3910659607e0Smrg	shift; shift
3911659607e0Smrg
3912659607e0Smrg	if test -n "$soname_spec"; then
3913659607e0Smrg	  eval soname=\"$soname_spec\"
3914659607e0Smrg	else
3915659607e0Smrg	  soname="$realname"
3916659607e0Smrg	fi
3917659607e0Smrg	if test -z "$dlname"; then
3918659607e0Smrg	  dlname=$soname
3919659607e0Smrg	fi
3920659607e0Smrg
3921659607e0Smrg	lib="$output_objdir/$realname"
3922659607e0Smrg	linknames=
3923659607e0Smrg	for link
3924659607e0Smrg	do
3925659607e0Smrg	  linknames="$linknames $link"
3926659607e0Smrg	done
3927659607e0Smrg
3928659607e0Smrg	# Use standard objects if they are pic
3929659607e0Smrg	test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
3930659607e0Smrg
3931659607e0Smrg	# Prepare the list of exported symbols
3932659607e0Smrg	if test -z "$export_symbols"; then
3933659607e0Smrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
3934659607e0Smrg	    $show "generating symbol list for \`$libname.la'"
3935659607e0Smrg	    export_symbols="$output_objdir/$libname.exp"
3936659607e0Smrg	    $run $rm $export_symbols
3937659607e0Smrg	    cmds=$export_symbols_cmds
3938659607e0Smrg	    save_ifs="$IFS"; IFS='~'
3939659607e0Smrg	    for cmd in $cmds; do
3940659607e0Smrg	      IFS="$save_ifs"
3941659607e0Smrg	      eval cmd=\"$cmd\"
3942659607e0Smrg	      if len=`expr "X$cmd" : ".*"` &&
3943659607e0Smrg	       test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
3944659607e0Smrg	        $show "$cmd"
3945659607e0Smrg	        $run eval "$cmd" || exit $?
3946659607e0Smrg	        skipped_export=false
3947659607e0Smrg	      else
3948659607e0Smrg	        # The command line is too long to execute in one step.
3949659607e0Smrg	        $show "using reloadable object file for export list..."
3950659607e0Smrg	        skipped_export=:
3951659607e0Smrg		# Break out early, otherwise skipped_export may be
3952659607e0Smrg		# set to false by a later but shorter cmd.
3953659607e0Smrg		break
3954659607e0Smrg	      fi
3955659607e0Smrg	    done
3956659607e0Smrg	    IFS="$save_ifs"
3957659607e0Smrg	    if test -n "$export_symbols_regex"; then
3958659607e0Smrg	      $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
3959659607e0Smrg	      $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
3960659607e0Smrg	      $show "$mv \"${export_symbols}T\" \"$export_symbols\""
3961659607e0Smrg	      $run eval '$mv "${export_symbols}T" "$export_symbols"'
3962659607e0Smrg	    fi
3963659607e0Smrg	  fi
3964659607e0Smrg	fi
3965659607e0Smrg
3966659607e0Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
3967659607e0Smrg	  $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
3968659607e0Smrg	fi
3969659607e0Smrg
3970659607e0Smrg	tmp_deplibs=
3971659607e0Smrg	for test_deplib in $deplibs; do
3972659607e0Smrg		case " $convenience " in
3973659607e0Smrg		*" $test_deplib "*) ;;
3974659607e0Smrg		*)
3975659607e0Smrg			tmp_deplibs="$tmp_deplibs $test_deplib"
3976659607e0Smrg			;;
3977659607e0Smrg		esac
3978659607e0Smrg	done
3979659607e0Smrg	deplibs="$tmp_deplibs"
3980659607e0Smrg
3981659607e0Smrg	if test -n "$convenience"; then
3982659607e0Smrg	  if test -n "$whole_archive_flag_spec"; then
3983659607e0Smrg	    save_libobjs=$libobjs
3984659607e0Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
3985659607e0Smrg	  else
3986659607e0Smrg	    gentop="$output_objdir/${outputname}x"
3987659607e0Smrg	    generated="$generated $gentop"
3988659607e0Smrg
3989659607e0Smrg	    func_extract_archives $gentop $convenience
3990659607e0Smrg	    libobjs="$libobjs $func_extract_archives_result"
3991659607e0Smrg	  fi
3992659607e0Smrg	fi
3993659607e0Smrg	
3994659607e0Smrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
3995659607e0Smrg	  eval flag=\"$thread_safe_flag_spec\"
3996659607e0Smrg	  linker_flags="$linker_flags $flag"
3997659607e0Smrg	fi
3998659607e0Smrg
3999659607e0Smrg	# Make a backup of the uninstalled library when relinking
4000659607e0Smrg	if test "$mode" = relink; then
4001659607e0Smrg	  $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $?
4002659607e0Smrg	fi
4003659607e0Smrg
4004659607e0Smrg	# Do each of the archive commands.
4005659607e0Smrg	if test "$module" = yes && test -n "$module_cmds" ; then
4006659607e0Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
4007659607e0Smrg	    eval test_cmds=\"$module_expsym_cmds\"
4008659607e0Smrg	    cmds=$module_expsym_cmds
4009659607e0Smrg	  else
4010659607e0Smrg	    eval test_cmds=\"$module_cmds\"
4011659607e0Smrg	    cmds=$module_cmds
4012659607e0Smrg	  fi
4013659607e0Smrg	else
4014659607e0Smrg	if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
4015659607e0Smrg	  eval test_cmds=\"$archive_expsym_cmds\"
4016659607e0Smrg	  cmds=$archive_expsym_cmds
4017659607e0Smrg	else
4018659607e0Smrg	  eval test_cmds=\"$archive_cmds\"
4019659607e0Smrg	  cmds=$archive_cmds
4020659607e0Smrg	  fi
4021659607e0Smrg	fi
4022659607e0Smrg
4023659607e0Smrg	if test "X$skipped_export" != "X:" &&
4024659607e0Smrg	   len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
4025659607e0Smrg	   test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
4026659607e0Smrg	  :
4027659607e0Smrg	else
4028659607e0Smrg	  # The command line is too long to link in one step, link piecewise.
4029659607e0Smrg	  $echo "creating reloadable object files..."
4030659607e0Smrg
4031659607e0Smrg	  # Save the value of $output and $libobjs because we want to
4032659607e0Smrg	  # use them later.  If we have whole_archive_flag_spec, we
4033659607e0Smrg	  # want to use save_libobjs as it was before
4034659607e0Smrg	  # whole_archive_flag_spec was expanded, because we can't
4035659607e0Smrg	  # assume the linker understands whole_archive_flag_spec.
4036659607e0Smrg	  # This may have to be revisited, in case too many
4037659607e0Smrg	  # convenience libraries get linked in and end up exceeding
4038659607e0Smrg	  # the spec.
4039659607e0Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
4040659607e0Smrg	    save_libobjs=$libobjs
4041659607e0Smrg	  fi
4042659607e0Smrg	  save_output=$output
4043659607e0Smrg	  output_la=`$echo "X$output" | $Xsed -e "$basename"`
4044659607e0Smrg
4045659607e0Smrg	  # Clear the reloadable object creation command queue and
4046659607e0Smrg	  # initialize k to one.
4047659607e0Smrg	  test_cmds=
4048659607e0Smrg	  concat_cmds=
4049659607e0Smrg	  objlist=
4050659607e0Smrg	  delfiles=
4051659607e0Smrg	  last_robj=
4052659607e0Smrg	  k=1
4053659607e0Smrg	  output=$output_objdir/$output_la-${k}.$objext
4054659607e0Smrg	  # Loop over the list of objects to be linked.
4055659607e0Smrg	  for obj in $save_libobjs
4056659607e0Smrg	  do
4057659607e0Smrg	    eval test_cmds=\"$reload_cmds $objlist $last_robj\"
4058659607e0Smrg	    if test "X$objlist" = X ||
4059659607e0Smrg	       { len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
4060659607e0Smrg		 test "$len" -le "$max_cmd_len"; }; then
4061659607e0Smrg	      objlist="$objlist $obj"
4062659607e0Smrg	    else
4063659607e0Smrg	      # The command $test_cmds is almost too long, add a
4064659607e0Smrg	      # command to the queue.
4065659607e0Smrg	      if test "$k" -eq 1 ; then
4066659607e0Smrg		# The first file doesn't have a previous command to add.
4067659607e0Smrg		eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
4068659607e0Smrg	      else
4069659607e0Smrg		# All subsequent reloadable object files will link in
4070659607e0Smrg		# the last one created.
4071659607e0Smrg		eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
4072659607e0Smrg	      fi
4073659607e0Smrg	      last_robj=$output_objdir/$output_la-${k}.$objext
4074659607e0Smrg	      k=`expr $k + 1`
4075659607e0Smrg	      output=$output_objdir/$output_la-${k}.$objext
4076659607e0Smrg	      objlist=$obj
4077659607e0Smrg	      len=1
4078659607e0Smrg	    fi
4079659607e0Smrg	  done
4080659607e0Smrg	  # Handle the remaining objects by creating one last
4081659607e0Smrg	  # reloadable object file.  All subsequent reloadable object
4082659607e0Smrg	  # files will link in the last one created.
4083659607e0Smrg	  test -z "$concat_cmds" || concat_cmds=$concat_cmds~
4084659607e0Smrg	  eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
4085659607e0Smrg
4086659607e0Smrg	  if ${skipped_export-false}; then
4087659607e0Smrg	    $show "generating symbol list for \`$libname.la'"
4088659607e0Smrg	    export_symbols="$output_objdir/$libname.exp"
4089659607e0Smrg	    $run $rm $export_symbols
4090659607e0Smrg	    libobjs=$output
4091659607e0Smrg	    # Append the command to create the export file.
4092659607e0Smrg	    eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
4093659607e0Smrg          fi
4094659607e0Smrg
4095659607e0Smrg	  # Set up a command to remove the reloadable object files
4096659607e0Smrg	  # after they are used.
4097659607e0Smrg	  i=0
4098659607e0Smrg	  while test "$i" -lt "$k"
4099659607e0Smrg	  do
4100659607e0Smrg	    i=`expr $i + 1`
4101659607e0Smrg	    delfiles="$delfiles $output_objdir/$output_la-${i}.$objext"
4102659607e0Smrg	  done
4103659607e0Smrg
4104659607e0Smrg	  $echo "creating a temporary reloadable object file: $output"
4105659607e0Smrg
4106659607e0Smrg	  # Loop through the commands generated above and execute them.
4107659607e0Smrg	  save_ifs="$IFS"; IFS='~'
4108659607e0Smrg	  for cmd in $concat_cmds; do
4109659607e0Smrg	    IFS="$save_ifs"
4110659607e0Smrg	    $show "$cmd"
4111659607e0Smrg	    $run eval "$cmd" || exit $?
4112659607e0Smrg	  done
4113659607e0Smrg	  IFS="$save_ifs"
4114659607e0Smrg
4115659607e0Smrg	  libobjs=$output
4116659607e0Smrg	  # Restore the value of output.
4117659607e0Smrg	  output=$save_output
4118659607e0Smrg
4119659607e0Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
4120659607e0Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
4121659607e0Smrg	  fi
4122659607e0Smrg	  # Expand the library linking commands again to reset the
4123659607e0Smrg	  # value of $libobjs for piecewise linking.
4124659607e0Smrg
4125659607e0Smrg	  # Do each of the archive commands.
4126659607e0Smrg	  if test "$module" = yes && test -n "$module_cmds" ; then
4127659607e0Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
4128659607e0Smrg	      cmds=$module_expsym_cmds
4129659607e0Smrg	    else
4130659607e0Smrg	      cmds=$module_cmds
4131659607e0Smrg	    fi
4132659607e0Smrg	  else
4133659607e0Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
4134659607e0Smrg	    cmds=$archive_expsym_cmds
4135659607e0Smrg	  else
4136659607e0Smrg	    cmds=$archive_cmds
4137659607e0Smrg	    fi
4138659607e0Smrg	  fi
4139659607e0Smrg
4140659607e0Smrg	  # Append the command to remove the reloadable object files
4141659607e0Smrg	  # to the just-reset $cmds.
4142659607e0Smrg	  eval cmds=\"\$cmds~\$rm $delfiles\"
4143659607e0Smrg	fi
4144659607e0Smrg	save_ifs="$IFS"; IFS='~'
4145659607e0Smrg	for cmd in $cmds; do
4146659607e0Smrg	  IFS="$save_ifs"
4147659607e0Smrg	  eval cmd=\"$cmd\"
4148659607e0Smrg	  $show "$cmd"
4149659607e0Smrg	  $run eval "$cmd" || {
4150659607e0Smrg	    lt_exit=$?
4151659607e0Smrg
4152659607e0Smrg	    # Restore the uninstalled library and exit
4153659607e0Smrg	    if test "$mode" = relink; then
4154659607e0Smrg	      $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
4155659607e0Smrg	    fi
4156659607e0Smrg
4157659607e0Smrg	    exit $lt_exit
4158659607e0Smrg	  }
4159659607e0Smrg	done
4160659607e0Smrg	IFS="$save_ifs"
4161659607e0Smrg
4162659607e0Smrg	# Restore the uninstalled library and exit
4163659607e0Smrg	if test "$mode" = relink; then
4164659607e0Smrg	  $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
4165659607e0Smrg
4166659607e0Smrg	  if test -n "$convenience"; then
4167659607e0Smrg	    if test -z "$whole_archive_flag_spec"; then
4168659607e0Smrg	      $show "${rm}r $gentop"
4169659607e0Smrg	      $run ${rm}r "$gentop"
4170659607e0Smrg	    fi
4171659607e0Smrg	  fi
4172659607e0Smrg
4173659607e0Smrg	  exit $EXIT_SUCCESS
4174659607e0Smrg	fi
4175659607e0Smrg
4176659607e0Smrg	# Create links to the real library.
4177659607e0Smrg	for linkname in $linknames; do
4178659607e0Smrg	  if test "$realname" != "$linkname"; then
4179659607e0Smrg	    $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
4180659607e0Smrg	    $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
4181659607e0Smrg	  fi
4182659607e0Smrg	done
4183659607e0Smrg
4184659607e0Smrg	# If -module or -export-dynamic was specified, set the dlname.
4185659607e0Smrg	if test "$module" = yes || test "$export_dynamic" = yes; then
4186659607e0Smrg	  # On all known operating systems, these are identical.
4187659607e0Smrg	  dlname="$soname"
4188659607e0Smrg	fi
4189659607e0Smrg      fi
4190659607e0Smrg      ;;
4191659607e0Smrg
4192659607e0Smrg    obj)
4193659607e0Smrg      if test -n "$deplibs"; then
4194659607e0Smrg	$echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
4195659607e0Smrg      fi
4196659607e0Smrg
4197659607e0Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
4198659607e0Smrg	$echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
4199659607e0Smrg      fi
4200659607e0Smrg
4201659607e0Smrg      if test -n "$rpath"; then
4202659607e0Smrg	$echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
4203659607e0Smrg      fi
4204659607e0Smrg
4205659607e0Smrg      if test -n "$xrpath"; then
4206659607e0Smrg	$echo "$modename: warning: \`-R' is ignored for objects" 1>&2
4207659607e0Smrg      fi
4208659607e0Smrg
4209659607e0Smrg      if test -n "$vinfo"; then
4210659607e0Smrg	$echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
4211659607e0Smrg      fi
4212659607e0Smrg
4213659607e0Smrg      if test -n "$release"; then
4214659607e0Smrg	$echo "$modename: warning: \`-release' is ignored for objects" 1>&2
4215659607e0Smrg      fi
4216659607e0Smrg
4217659607e0Smrg      case $output in
4218659607e0Smrg      *.lo)
4219659607e0Smrg	if test -n "$objs$old_deplibs"; then
4220659607e0Smrg	  $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
4221659607e0Smrg	  exit $EXIT_FAILURE
4222659607e0Smrg	fi
4223659607e0Smrg	libobj="$output"
4224659607e0Smrg	obj=`$echo "X$output" | $Xsed -e "$lo2o"`
4225659607e0Smrg	;;
4226659607e0Smrg      *)
4227659607e0Smrg	libobj=
4228659607e0Smrg	obj="$output"
4229659607e0Smrg	;;
4230659607e0Smrg      esac
4231659607e0Smrg
4232659607e0Smrg      # Delete the old objects.
4233659607e0Smrg      $run $rm $obj $libobj
4234659607e0Smrg
4235659607e0Smrg      # Objects from convenience libraries.  This assumes
4236659607e0Smrg      # single-version convenience libraries.  Whenever we create
4237659607e0Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
4238659607e0Smrg      # the extraction.
4239659607e0Smrg      reload_conv_objs=
4240659607e0Smrg      gentop=
4241659607e0Smrg      # reload_cmds runs $LD directly, so let us get rid of
42426aab59a7Smrg      # -Wl from whole_archive_flag_spec
4243659607e0Smrg      wl=
4244659607e0Smrg
4245659607e0Smrg      if test -n "$convenience"; then
4246659607e0Smrg	if test -n "$whole_archive_flag_spec"; then
42476aab59a7Smrg	  eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
4248659607e0Smrg	else
4249659607e0Smrg	  gentop="$output_objdir/${obj}x"
4250659607e0Smrg	  generated="$generated $gentop"
4251659607e0Smrg
4252659607e0Smrg	  func_extract_archives $gentop $convenience
4253659607e0Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
4254659607e0Smrg	fi
4255659607e0Smrg      fi
4256659607e0Smrg
4257659607e0Smrg      # Create the old-style object.
4258659607e0Smrg      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
4259659607e0Smrg
4260659607e0Smrg      output="$obj"
4261659607e0Smrg      cmds=$reload_cmds
4262659607e0Smrg      save_ifs="$IFS"; IFS='~'
4263659607e0Smrg      for cmd in $cmds; do
4264659607e0Smrg	IFS="$save_ifs"
4265659607e0Smrg	eval cmd=\"$cmd\"
4266659607e0Smrg	$show "$cmd"
4267659607e0Smrg	$run eval "$cmd" || exit $?
4268659607e0Smrg      done
4269659607e0Smrg      IFS="$save_ifs"
4270659607e0Smrg
4271659607e0Smrg      # Exit if we aren't doing a library object file.
4272659607e0Smrg      if test -z "$libobj"; then
4273659607e0Smrg	if test -n "$gentop"; then
4274659607e0Smrg	  $show "${rm}r $gentop"
4275659607e0Smrg	  $run ${rm}r $gentop
4276659607e0Smrg	fi
4277659607e0Smrg
4278659607e0Smrg	exit $EXIT_SUCCESS
4279659607e0Smrg      fi
4280659607e0Smrg
4281659607e0Smrg      if test "$build_libtool_libs" != yes; then
4282659607e0Smrg	if test -n "$gentop"; then
4283659607e0Smrg	  $show "${rm}r $gentop"
4284659607e0Smrg	  $run ${rm}r $gentop
4285659607e0Smrg	fi
4286659607e0Smrg
4287659607e0Smrg	# Create an invalid libtool object if no PIC, so that we don't
4288659607e0Smrg	# accidentally link it into a program.
4289659607e0Smrg	# $show "echo timestamp > $libobj"
4290659607e0Smrg	# $run eval "echo timestamp > $libobj" || exit $?
4291659607e0Smrg	exit $EXIT_SUCCESS
4292659607e0Smrg      fi
4293659607e0Smrg
4294659607e0Smrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
4295659607e0Smrg	# Only do commands if we really have different PIC objects.
4296659607e0Smrg	reload_objs="$libobjs $reload_conv_objs"
4297659607e0Smrg	output="$libobj"
4298659607e0Smrg	cmds=$reload_cmds
4299659607e0Smrg	save_ifs="$IFS"; IFS='~'
4300659607e0Smrg	for cmd in $cmds; do
4301659607e0Smrg	  IFS="$save_ifs"
4302659607e0Smrg	  eval cmd=\"$cmd\"
4303659607e0Smrg	  $show "$cmd"
4304659607e0Smrg	  $run eval "$cmd" || exit $?
4305659607e0Smrg	done
4306659607e0Smrg	IFS="$save_ifs"
4307659607e0Smrg      fi
4308659607e0Smrg
4309659607e0Smrg      if test -n "$gentop"; then
4310659607e0Smrg	$show "${rm}r $gentop"
4311659607e0Smrg	$run ${rm}r $gentop
4312659607e0Smrg      fi
4313659607e0Smrg
4314659607e0Smrg      exit $EXIT_SUCCESS
4315659607e0Smrg      ;;
4316659607e0Smrg
4317659607e0Smrg    prog)
4318659607e0Smrg      case $host in
4319659607e0Smrg	*cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
4320659607e0Smrg      esac
4321659607e0Smrg      if test -n "$vinfo"; then
4322659607e0Smrg	$echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
4323659607e0Smrg      fi
4324659607e0Smrg
4325659607e0Smrg      if test -n "$release"; then
4326659607e0Smrg	$echo "$modename: warning: \`-release' is ignored for programs" 1>&2
4327659607e0Smrg      fi
4328659607e0Smrg
4329659607e0Smrg      if test "$preload" = yes; then
4330659607e0Smrg	if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown &&
4331659607e0Smrg	   test "$dlopen_self_static" = unknown; then
4332659607e0Smrg	  $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
4333659607e0Smrg	fi
4334659607e0Smrg      fi
4335659607e0Smrg
4336659607e0Smrg      case $host in
4337659607e0Smrg      *-*-rhapsody* | *-*-darwin1.[012])
4338659607e0Smrg	# On Rhapsody replace the C library is the System framework
4339659607e0Smrg	compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
4340659607e0Smrg	finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
4341659607e0Smrg	;;
4342659607e0Smrg      esac
4343659607e0Smrg
4344659607e0Smrg      case $host in
4345659607e0Smrg      *darwin*)
4346659607e0Smrg        # Don't allow lazy linking, it breaks C++ global constructors
4347659607e0Smrg        if test "$tagname" = CXX ; then
4348659607e0Smrg        compile_command="$compile_command ${wl}-bind_at_load"
4349659607e0Smrg        finalize_command="$finalize_command ${wl}-bind_at_load"
4350659607e0Smrg        fi
4351659607e0Smrg        ;;
4352659607e0Smrg      esac
4353659607e0Smrg
4354659607e0Smrg
4355659607e0Smrg      # move library search paths that coincide with paths to not yet
4356659607e0Smrg      # installed libraries to the beginning of the library search list
4357659607e0Smrg      new_libs=
4358659607e0Smrg      for path in $notinst_path; do
4359659607e0Smrg	case " $new_libs " in
4360659607e0Smrg	*" -L$path/$objdir "*) ;;
4361659607e0Smrg	*)
4362659607e0Smrg	  case " $compile_deplibs " in
4363659607e0Smrg	  *" -L$path/$objdir "*)
4364659607e0Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
4365659607e0Smrg	  esac
4366659607e0Smrg	  ;;
4367659607e0Smrg	esac
4368659607e0Smrg      done
4369659607e0Smrg      for deplib in $compile_deplibs; do
4370659607e0Smrg	case $deplib in
4371659607e0Smrg	-L*)
4372659607e0Smrg	  case " $new_libs " in
4373659607e0Smrg	  *" $deplib "*) ;;
4374659607e0Smrg	  *) new_libs="$new_libs $deplib" ;;
4375659607e0Smrg	  esac
4376659607e0Smrg	  ;;
4377659607e0Smrg	*) new_libs="$new_libs $deplib" ;;
4378659607e0Smrg	esac
4379659607e0Smrg      done
4380659607e0Smrg      compile_deplibs="$new_libs"
4381659607e0Smrg
4382659607e0Smrg
4383659607e0Smrg      compile_command="$compile_command $compile_deplibs"
4384659607e0Smrg      finalize_command="$finalize_command $finalize_deplibs"
4385659607e0Smrg
4386659607e0Smrg      if test -n "$rpath$xrpath"; then
4387659607e0Smrg	# If the user specified any rpath flags, then add them.
4388659607e0Smrg	for libdir in $rpath $xrpath; do
4389659607e0Smrg	  # This is the magic to use -rpath.
4390659607e0Smrg	  case "$finalize_rpath " in
4391659607e0Smrg	  *" $libdir "*) ;;
4392659607e0Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
4393659607e0Smrg	  esac
4394659607e0Smrg	done
4395659607e0Smrg      fi
4396659607e0Smrg
4397659607e0Smrg      # Now hardcode the library paths
4398659607e0Smrg      rpath=
4399659607e0Smrg      hardcode_libdirs=
4400659607e0Smrg      for libdir in $compile_rpath $finalize_rpath; do
4401659607e0Smrg	if test -n "$hardcode_libdir_flag_spec"; then
4402659607e0Smrg	  if test -n "$hardcode_libdir_separator"; then
4403659607e0Smrg	    if test -z "$hardcode_libdirs"; then
4404659607e0Smrg	      hardcode_libdirs="$libdir"
4405659607e0Smrg	    else
4406659607e0Smrg	      # Just accumulate the unique libdirs.
4407659607e0Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
4408659607e0Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
4409659607e0Smrg		;;
4410659607e0Smrg	      *)
4411659607e0Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
4412659607e0Smrg		;;
4413659607e0Smrg	      esac
4414659607e0Smrg	    fi
4415659607e0Smrg	  else
4416659607e0Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
4417659607e0Smrg	    rpath="$rpath $flag"
4418659607e0Smrg	  fi
4419659607e0Smrg	elif test -n "$runpath_var"; then
4420659607e0Smrg	  case "$perm_rpath " in
4421659607e0Smrg	  *" $libdir "*) ;;
4422659607e0Smrg	  *) perm_rpath="$perm_rpath $libdir" ;;
4423659607e0Smrg	  esac
4424659607e0Smrg	fi
4425659607e0Smrg	case $host in
4426659607e0Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
4427659607e0Smrg	  testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'`
4428659607e0Smrg	  case :$dllsearchpath: in
4429659607e0Smrg	  *":$libdir:"*) ;;
4430659607e0Smrg	  *) dllsearchpath="$dllsearchpath:$libdir";;
4431659607e0Smrg	  esac
4432659607e0Smrg	  case :$dllsearchpath: in
4433659607e0Smrg	  *":$testbindir:"*) ;;
4434659607e0Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
4435659607e0Smrg	  esac
4436659607e0Smrg	  ;;
4437659607e0Smrg	esac
4438659607e0Smrg      done
4439659607e0Smrg      # Substitute the hardcoded libdirs into the rpath.
4440659607e0Smrg      if test -n "$hardcode_libdir_separator" &&
4441659607e0Smrg	 test -n "$hardcode_libdirs"; then
4442659607e0Smrg	libdir="$hardcode_libdirs"
4443659607e0Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
4444659607e0Smrg      fi
4445659607e0Smrg      compile_rpath="$rpath"
4446659607e0Smrg
4447659607e0Smrg      rpath=
4448659607e0Smrg      hardcode_libdirs=
4449659607e0Smrg      for libdir in $finalize_rpath; do
4450659607e0Smrg	if test -n "$hardcode_libdir_flag_spec"; then
4451659607e0Smrg	  if test -n "$hardcode_libdir_separator"; then
4452659607e0Smrg	    if test -z "$hardcode_libdirs"; then
4453659607e0Smrg	      hardcode_libdirs="$libdir"
4454659607e0Smrg	    else
4455659607e0Smrg	      # Just accumulate the unique libdirs.
4456659607e0Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
4457659607e0Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
4458659607e0Smrg		;;
4459659607e0Smrg	      *)
4460659607e0Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
4461659607e0Smrg		;;
4462659607e0Smrg	      esac
4463659607e0Smrg	    fi
4464659607e0Smrg	  else
4465659607e0Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
4466659607e0Smrg	    rpath="$rpath $flag"
4467659607e0Smrg	  fi
4468659607e0Smrg	elif test -n "$runpath_var"; then
4469659607e0Smrg	  case "$finalize_perm_rpath " in
4470659607e0Smrg	  *" $libdir "*) ;;
4471659607e0Smrg	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
4472659607e0Smrg	  esac
4473659607e0Smrg	fi
4474659607e0Smrg      done
4475659607e0Smrg      # Substitute the hardcoded libdirs into the rpath.
4476659607e0Smrg      if test -n "$hardcode_libdir_separator" &&
4477659607e0Smrg	 test -n "$hardcode_libdirs"; then
4478659607e0Smrg	libdir="$hardcode_libdirs"
4479659607e0Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
4480659607e0Smrg      fi
4481659607e0Smrg      finalize_rpath="$rpath"
4482659607e0Smrg
4483659607e0Smrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
4484659607e0Smrg	# Transform all the library objects into standard objects.
4485659607e0Smrg	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
4486659607e0Smrg	finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
4487659607e0Smrg      fi
4488659607e0Smrg
4489659607e0Smrg      dlsyms=
4490659607e0Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
4491659607e0Smrg	if test -n "$NM" && test -n "$global_symbol_pipe"; then
4492659607e0Smrg	  dlsyms="${outputname}S.c"
4493659607e0Smrg	else
4494659607e0Smrg	  $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
4495659607e0Smrg	fi
4496659607e0Smrg      fi
4497659607e0Smrg
4498659607e0Smrg      if test -n "$dlsyms"; then
4499659607e0Smrg	case $dlsyms in
4500659607e0Smrg	"") ;;
4501659607e0Smrg	*.c)
4502659607e0Smrg	  # Discover the nlist of each of the dlfiles.
4503659607e0Smrg	  nlist="$output_objdir/${outputname}.nm"
4504659607e0Smrg
4505659607e0Smrg	  $show "$rm $nlist ${nlist}S ${nlist}T"
4506659607e0Smrg	  $run $rm "$nlist" "${nlist}S" "${nlist}T"
4507659607e0Smrg
4508659607e0Smrg	  # Parse the name list into a source file.
4509659607e0Smrg	  $show "creating $output_objdir/$dlsyms"
4510659607e0Smrg
4511659607e0Smrg	  test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
4512659607e0Smrg/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
4513659607e0Smrg/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
4514659607e0Smrg
4515659607e0Smrg#ifdef __cplusplus
4516659607e0Smrgextern \"C\" {
4517659607e0Smrg#endif
4518659607e0Smrg
4519659607e0Smrg/* Prevent the only kind of declaration conflicts we can make. */
4520659607e0Smrg#define lt_preloaded_symbols some_other_symbol
4521659607e0Smrg
4522659607e0Smrg/* External symbol declarations for the compiler. */\
4523659607e0Smrg"
4524659607e0Smrg
4525659607e0Smrg	  if test "$dlself" = yes; then
4526659607e0Smrg	    $show "generating symbol list for \`$output'"
4527659607e0Smrg
4528659607e0Smrg	    test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
4529659607e0Smrg
4530659607e0Smrg	    # Add our own program objects to the symbol list.
4531659607e0Smrg	    progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
4532659607e0Smrg	    for arg in $progfiles; do
4533659607e0Smrg	      $show "extracting global C symbols from \`$arg'"
4534659607e0Smrg	      $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
4535659607e0Smrg	    done
4536659607e0Smrg
4537659607e0Smrg	    if test -n "$exclude_expsyms"; then
4538659607e0Smrg	      $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
4539659607e0Smrg	      $run eval '$mv "$nlist"T "$nlist"'
4540659607e0Smrg	    fi
4541659607e0Smrg
4542659607e0Smrg	    if test -n "$export_symbols_regex"; then
4543659607e0Smrg	      $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
4544659607e0Smrg	      $run eval '$mv "$nlist"T "$nlist"'
4545659607e0Smrg	    fi
4546659607e0Smrg
4547659607e0Smrg	    # Prepare the list of exported symbols
4548659607e0Smrg	    if test -z "$export_symbols"; then
4549659607e0Smrg	      export_symbols="$output_objdir/$outputname.exp"
4550659607e0Smrg	      $run $rm $export_symbols
4551659607e0Smrg	      $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4552659607e0Smrg              case $host in
4553659607e0Smrg              *cygwin* | *mingw* )
4554659607e0Smrg	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4555659607e0Smrg		$run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
4556659607e0Smrg                ;;
4557659607e0Smrg              esac
4558659607e0Smrg	    else
4559659607e0Smrg	      $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4560659607e0Smrg	      $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
4561659607e0Smrg	      $run eval 'mv "$nlist"T "$nlist"'
4562659607e0Smrg              case $host in
4563659607e0Smrg              *cygwin* | *mingw* )
4564659607e0Smrg	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4565659607e0Smrg		$run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
4566659607e0Smrg                ;;
4567659607e0Smrg              esac
4568659607e0Smrg	    fi
4569659607e0Smrg	  fi
4570659607e0Smrg
4571659607e0Smrg	  for arg in $dlprefiles; do
4572659607e0Smrg	    $show "extracting global C symbols from \`$arg'"
4573659607e0Smrg	    name=`$echo "$arg" | ${SED} -e 's%^.*/%%'`
4574659607e0Smrg	    $run eval '$echo ": $name " >> "$nlist"'
4575659607e0Smrg	    $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
4576659607e0Smrg	  done
4577659607e0Smrg
4578659607e0Smrg	  if test -z "$run"; then
4579659607e0Smrg	    # Make sure we have at least an empty file.
4580659607e0Smrg	    test -f "$nlist" || : > "$nlist"
4581659607e0Smrg
4582659607e0Smrg	    if test -n "$exclude_expsyms"; then
4583659607e0Smrg	      $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
4584659607e0Smrg	      $mv "$nlist"T "$nlist"
4585659607e0Smrg	    fi
4586659607e0Smrg
4587659607e0Smrg	    # Try sorting and uniquifying the output.
4588659607e0Smrg	    if grep -v "^: " < "$nlist" |
4589659607e0Smrg		if sort -k 3 </dev/null >/dev/null 2>&1; then
4590659607e0Smrg		  sort -k 3
4591659607e0Smrg		else
4592659607e0Smrg		  sort +2
4593659607e0Smrg		fi |
4594659607e0Smrg		uniq > "$nlist"S; then
4595659607e0Smrg	      :
4596659607e0Smrg	    else
4597659607e0Smrg	      grep -v "^: " < "$nlist" > "$nlist"S
4598659607e0Smrg	    fi
4599659607e0Smrg
4600659607e0Smrg	    if test -f "$nlist"S; then
4601659607e0Smrg	      eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
4602659607e0Smrg	    else
4603659607e0Smrg	      $echo '/* NONE */' >> "$output_objdir/$dlsyms"
4604659607e0Smrg	    fi
4605659607e0Smrg
4606659607e0Smrg	    $echo >> "$output_objdir/$dlsyms" "\
4607659607e0Smrg
4608659607e0Smrg#undef lt_preloaded_symbols
4609659607e0Smrg
4610659607e0Smrg#if defined (__STDC__) && __STDC__
4611659607e0Smrg# define lt_ptr void *
4612659607e0Smrg#else
4613659607e0Smrg# define lt_ptr char *
4614659607e0Smrg# define const
4615659607e0Smrg#endif
4616659607e0Smrg
4617659607e0Smrg/* The mapping between symbol names and symbols. */
4618659607e0Smrg"
4619659607e0Smrg
4620659607e0Smrg	    case $host in
4621659607e0Smrg	    *cygwin* | *mingw* )
4622659607e0Smrg	  $echo >> "$output_objdir/$dlsyms" "\
4623659607e0Smrg/* DATA imports from DLLs on WIN32 can't be const, because
4624659607e0Smrg   runtime relocations are performed -- see ld's documentation
4625659607e0Smrg   on pseudo-relocs */
4626659607e0Smrgstruct {
4627659607e0Smrg"
4628659607e0Smrg	      ;;
4629659607e0Smrg	    * )
4630659607e0Smrg	  $echo >> "$output_objdir/$dlsyms" "\
4631659607e0Smrgconst struct {
4632659607e0Smrg"
4633659607e0Smrg	      ;;
4634659607e0Smrg	    esac
4635659607e0Smrg
4636659607e0Smrg
4637659607e0Smrg	  $echo >> "$output_objdir/$dlsyms" "\
4638659607e0Smrg  const char *name;
4639659607e0Smrg  lt_ptr address;
4640659607e0Smrg}
4641659607e0Smrglt_preloaded_symbols[] =
4642659607e0Smrg{\
4643659607e0Smrg"
4644659607e0Smrg
4645659607e0Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
4646659607e0Smrg
4647659607e0Smrg	    $echo >> "$output_objdir/$dlsyms" "\
4648659607e0Smrg  {0, (lt_ptr) 0}
4649659607e0Smrg};
4650659607e0Smrg
4651659607e0Smrg/* This works around a problem in FreeBSD linker */
4652659607e0Smrg#ifdef FREEBSD_WORKAROUND
4653659607e0Smrgstatic const void *lt_preloaded_setup() {
4654659607e0Smrg  return lt_preloaded_symbols;
4655659607e0Smrg}
4656659607e0Smrg#endif
4657659607e0Smrg
4658659607e0Smrg#ifdef __cplusplus
4659659607e0Smrg}
4660659607e0Smrg#endif\
4661659607e0Smrg"
4662659607e0Smrg	  fi
4663659607e0Smrg
4664659607e0Smrg	  pic_flag_for_symtable=
4665659607e0Smrg	  case $host in
4666659607e0Smrg	  # compiling the symbol table file with pic_flag works around
4667659607e0Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
4668659607e0Smrg	  # linked before any other PIC object.  But we must not use
4669659607e0Smrg	  # pic_flag when linking with -static.  The problem exists in
4670659607e0Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
4671659607e0Smrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
4672659607e0Smrg	    case "$compile_command " in
4673659607e0Smrg	    *" -static "*) ;;
4674659607e0Smrg	    *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";;
4675659607e0Smrg	    esac;;
4676659607e0Smrg	  *-*-hpux*)
4677659607e0Smrg	    case "$compile_command " in
4678659607e0Smrg	    *" -static "*) ;;
4679659607e0Smrg	    *) pic_flag_for_symtable=" $pic_flag";;
4680659607e0Smrg	    esac
4681659607e0Smrg	  esac
4682659607e0Smrg
4683659607e0Smrg	  # Now compile the dynamic symbol file.
4684659607e0Smrg	  $show "(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
4685659607e0Smrg	  $run eval '(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
4686659607e0Smrg
4687659607e0Smrg	  # Clean up the generated files.
4688659607e0Smrg	  $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
4689659607e0Smrg	  $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
4690659607e0Smrg
4691659607e0Smrg	  # Transform the symbol file into the correct name.
4692659607e0Smrg          case $host in
4693659607e0Smrg          *cygwin* | *mingw* )
4694659607e0Smrg            if test -f "$output_objdir/${outputname}.def" ; then
46956aab59a7Smrg              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
46966aab59a7Smrg              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
4697659607e0Smrg            else
46986aab59a7Smrg              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
46996aab59a7Smrg              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4700659607e0Smrg             fi
4701659607e0Smrg            ;;
4702659607e0Smrg          * )
47036aab59a7Smrg            compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
47046aab59a7Smrg            finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4705659607e0Smrg            ;;
4706659607e0Smrg          esac
4707659607e0Smrg	  ;;
4708659607e0Smrg	*)
4709659607e0Smrg	  $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
4710659607e0Smrg	  exit $EXIT_FAILURE
4711659607e0Smrg	  ;;
4712659607e0Smrg	esac
4713659607e0Smrg      else
4714659607e0Smrg	# We keep going just in case the user didn't refer to
4715659607e0Smrg	# lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
4716659607e0Smrg	# really was required.
4717659607e0Smrg
4718659607e0Smrg	# Nullify the symbol file.
47196aab59a7Smrg	compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
47206aab59a7Smrg	finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
4721659607e0Smrg      fi
4722659607e0Smrg
4723659607e0Smrg      if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
4724659607e0Smrg	# Replace the output file specification.
47256aab59a7Smrg	compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
4726659607e0Smrg	link_command="$compile_command$compile_rpath"
4727659607e0Smrg
4728659607e0Smrg	# We have no uninstalled library dependencies, so finalize right now.
4729659607e0Smrg	$show "$link_command"
4730659607e0Smrg	$run eval "$link_command"
4731659607e0Smrg	exit_status=$?
4732659607e0Smrg
4733659607e0Smrg	# Delete the generated files.
4734659607e0Smrg	if test -n "$dlsyms"; then
4735659607e0Smrg	  $show "$rm $output_objdir/${outputname}S.${objext}"
4736659607e0Smrg	  $run $rm "$output_objdir/${outputname}S.${objext}"
4737659607e0Smrg	fi
4738659607e0Smrg
4739659607e0Smrg	exit $exit_status
4740659607e0Smrg      fi
4741659607e0Smrg
4742659607e0Smrg      if test -n "$shlibpath_var"; then
4743659607e0Smrg	# We should set the shlibpath_var
4744659607e0Smrg	rpath=
4745659607e0Smrg	for dir in $temp_rpath; do
4746659607e0Smrg	  case $dir in
4747659607e0Smrg	  [\\/]* | [A-Za-z]:[\\/]*)
4748659607e0Smrg	    # Absolute path.
4749659607e0Smrg	    rpath="$rpath$dir:"
4750659607e0Smrg	    ;;
4751659607e0Smrg	  *)
4752659607e0Smrg	    # Relative path: add a thisdir entry.
4753659607e0Smrg	    rpath="$rpath\$thisdir/$dir:"
4754659607e0Smrg	    ;;
4755659607e0Smrg	  esac
4756659607e0Smrg	done
4757659607e0Smrg	temp_rpath="$rpath"
4758659607e0Smrg      fi
4759659607e0Smrg
4760659607e0Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
4761659607e0Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
4762659607e0Smrg      fi
4763659607e0Smrg      if test -n "$finalize_shlibpath"; then
4764659607e0Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
4765659607e0Smrg      fi
4766659607e0Smrg
4767659607e0Smrg      compile_var=
4768659607e0Smrg      finalize_var=
4769659607e0Smrg      if test -n "$runpath_var"; then
4770659607e0Smrg	if test -n "$perm_rpath"; then
4771659607e0Smrg	  # We should set the runpath_var.
4772659607e0Smrg	  rpath=
4773659607e0Smrg	  for dir in $perm_rpath; do
4774659607e0Smrg	    rpath="$rpath$dir:"
4775659607e0Smrg	  done
4776659607e0Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
4777659607e0Smrg	fi
4778659607e0Smrg	if test -n "$finalize_perm_rpath"; then
4779659607e0Smrg	  # We should set the runpath_var.
4780659607e0Smrg	  rpath=
4781659607e0Smrg	  for dir in $finalize_perm_rpath; do
4782659607e0Smrg	    rpath="$rpath$dir:"
4783659607e0Smrg	  done
4784659607e0Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
4785659607e0Smrg	fi
4786659607e0Smrg      fi
4787659607e0Smrg
4788659607e0Smrg      if test "$no_install" = yes; then
4789659607e0Smrg	# We don't need to create a wrapper script.
4790659607e0Smrg	link_command="$compile_var$compile_command$compile_rpath"
4791659607e0Smrg	# Replace the output file specification.
4792659607e0Smrg	link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
4793659607e0Smrg	# Delete the old output file.
4794659607e0Smrg	$run $rm $output
4795659607e0Smrg	# Link the executable and exit
4796659607e0Smrg	$show "$link_command"
4797659607e0Smrg	$run eval "$link_command" || exit $?
4798659607e0Smrg	exit $EXIT_SUCCESS
4799659607e0Smrg      fi
4800659607e0Smrg
4801659607e0Smrg      if test "$hardcode_action" = relink; then
4802659607e0Smrg	# Fast installation is not supported
4803659607e0Smrg	link_command="$compile_var$compile_command$compile_rpath"
4804659607e0Smrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
4805659607e0Smrg
4806659607e0Smrg	$echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
4807659607e0Smrg	$echo "$modename: \`$output' will be relinked during installation" 1>&2
4808659607e0Smrg      else
4809659607e0Smrg	if test "$fast_install" != no; then
4810659607e0Smrg	  link_command="$finalize_var$compile_command$finalize_rpath"
4811659607e0Smrg	  if test "$fast_install" = yes; then
48126aab59a7Smrg	    relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
4813659607e0Smrg	  else
4814659607e0Smrg	    # fast_install is set to needless
4815659607e0Smrg	    relink_command=
4816659607e0Smrg	  fi
4817659607e0Smrg	else
4818659607e0Smrg	  link_command="$compile_var$compile_command$compile_rpath"
4819659607e0Smrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
4820659607e0Smrg	fi
4821659607e0Smrg      fi
4822659607e0Smrg
4823659607e0Smrg      # Replace the output file specification.
4824659607e0Smrg      link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
4825659607e0Smrg
4826659607e0Smrg      # Delete the old output files.
4827659607e0Smrg      $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
4828659607e0Smrg
4829659607e0Smrg      $show "$link_command"
4830659607e0Smrg      $run eval "$link_command" || exit $?
4831659607e0Smrg
4832659607e0Smrg      # Now create the wrapper script.
4833659607e0Smrg      $show "creating $output"
4834659607e0Smrg
4835659607e0Smrg      # Quote the relink command for shipping.
4836659607e0Smrg      if test -n "$relink_command"; then
4837659607e0Smrg	# Preserve any variables that may affect compiler behavior
4838659607e0Smrg	for var in $variables_saved_for_relink; do
4839659607e0Smrg	  if eval test -z \"\${$var+set}\"; then
4840659607e0Smrg	    relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
4841659607e0Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
4842659607e0Smrg	    relink_command="$var=; export $var; $relink_command"
4843659607e0Smrg	  else
4844659607e0Smrg	    var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
4845659607e0Smrg	    relink_command="$var=\"$var_value\"; export $var; $relink_command"
4846659607e0Smrg	  fi
4847659607e0Smrg	done
4848659607e0Smrg	relink_command="(cd `pwd`; $relink_command)"
48496aab59a7Smrg	relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
4850659607e0Smrg      fi
4851659607e0Smrg
4852659607e0Smrg      # Quote $echo for shipping.
4853659607e0Smrg      if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then
4854659607e0Smrg	case $progpath in
4855659607e0Smrg	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
4856659607e0Smrg	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
4857659607e0Smrg	esac
4858659607e0Smrg	qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
4859659607e0Smrg      else
4860659607e0Smrg	qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
4861659607e0Smrg      fi
4862659607e0Smrg
4863659607e0Smrg      # Only actually do things if our run command is non-null.
4864659607e0Smrg      if test -z "$run"; then
4865659607e0Smrg	# win32 will think the script is a binary if it has
4866659607e0Smrg	# a .exe suffix, so we strip it off here.
4867659607e0Smrg	case $output in
4868659607e0Smrg	  *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;;
4869659607e0Smrg	esac
4870659607e0Smrg	# test for cygwin because mv fails w/o .exe extensions
4871659607e0Smrg	case $host in
4872659607e0Smrg	  *cygwin*)
4873659607e0Smrg	    exeext=.exe
4874659607e0Smrg	    outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;;
4875659607e0Smrg	  *) exeext= ;;
4876659607e0Smrg	esac
4877659607e0Smrg	case $host in
4878659607e0Smrg	  *cygwin* | *mingw* )
4879659607e0Smrg            output_name=`basename $output`
4880659607e0Smrg            output_path=`dirname $output`
4881659607e0Smrg            cwrappersource="$output_path/$objdir/lt-$output_name.c"
4882659607e0Smrg            cwrapper="$output_path/$output_name.exe"
4883659607e0Smrg            $rm $cwrappersource $cwrapper
4884659607e0Smrg            trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
4885659607e0Smrg
4886659607e0Smrg	    cat > $cwrappersource <<EOF
4887659607e0Smrg
4888659607e0Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
4889659607e0Smrg   Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
4890659607e0Smrg
4891659607e0Smrg   The $output program cannot be directly executed until all the libtool
4892659607e0Smrg   libraries that it depends on are installed.
4893659607e0Smrg
4894659607e0Smrg   This wrapper executable should never be moved out of the build directory.
4895659607e0Smrg   If it is, it will not operate correctly.
4896659607e0Smrg
4897659607e0Smrg   Currently, it simply execs the wrapper *script* "/bin/sh $output",
4898659607e0Smrg   but could eventually absorb all of the scripts functionality and
4899659607e0Smrg   exec $objdir/$outputname directly.
4900659607e0Smrg*/
4901659607e0SmrgEOF
4902659607e0Smrg	    cat >> $cwrappersource<<"EOF"
4903659607e0Smrg#include <stdio.h>
4904659607e0Smrg#include <stdlib.h>
4905659607e0Smrg#include <unistd.h>
4906659607e0Smrg#include <malloc.h>
4907659607e0Smrg#include <stdarg.h>
4908659607e0Smrg#include <assert.h>
4909659607e0Smrg#include <string.h>
4910659607e0Smrg#include <ctype.h>
4911659607e0Smrg#include <sys/stat.h>
4912659607e0Smrg
4913659607e0Smrg#if defined(PATH_MAX)
4914659607e0Smrg# define LT_PATHMAX PATH_MAX
4915659607e0Smrg#elif defined(MAXPATHLEN)
4916659607e0Smrg# define LT_PATHMAX MAXPATHLEN
4917659607e0Smrg#else
4918659607e0Smrg# define LT_PATHMAX 1024
4919659607e0Smrg#endif
4920659607e0Smrg
4921659607e0Smrg#ifndef DIR_SEPARATOR
4922659607e0Smrg# define DIR_SEPARATOR '/'
4923659607e0Smrg# define PATH_SEPARATOR ':'
4924659607e0Smrg#endif
4925659607e0Smrg
4926659607e0Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
4927659607e0Smrg  defined (__OS2__)
4928659607e0Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
4929659607e0Smrg# ifndef DIR_SEPARATOR_2
4930659607e0Smrg#  define DIR_SEPARATOR_2 '\\'
4931659607e0Smrg# endif
4932659607e0Smrg# ifndef PATH_SEPARATOR_2
4933659607e0Smrg#  define PATH_SEPARATOR_2 ';'
4934659607e0Smrg# endif
4935659607e0Smrg#endif
4936659607e0Smrg
4937659607e0Smrg#ifndef DIR_SEPARATOR_2
4938659607e0Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
4939659607e0Smrg#else /* DIR_SEPARATOR_2 */
4940659607e0Smrg# define IS_DIR_SEPARATOR(ch) \
4941659607e0Smrg        (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4942659607e0Smrg#endif /* DIR_SEPARATOR_2 */
4943659607e0Smrg
4944659607e0Smrg#ifndef PATH_SEPARATOR_2
4945659607e0Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
4946659607e0Smrg#else /* PATH_SEPARATOR_2 */
4947659607e0Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
4948659607e0Smrg#endif /* PATH_SEPARATOR_2 */
4949659607e0Smrg
4950659607e0Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
4951659607e0Smrg#define XFREE(stale) do { \
4952659607e0Smrg  if (stale) { free ((void *) stale); stale = 0; } \
4953659607e0Smrg} while (0)
4954659607e0Smrg
4955659607e0Smrg/* -DDEBUG is fairly common in CFLAGS.  */
4956659607e0Smrg#undef DEBUG
4957659607e0Smrg#if defined DEBUGWRAPPER
4958659607e0Smrg# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
4959659607e0Smrg#else
4960659607e0Smrg# define DEBUG(format, ...)
4961659607e0Smrg#endif
4962659607e0Smrg
4963659607e0Smrgconst char *program_name = NULL;
4964659607e0Smrg
4965659607e0Smrgvoid * xmalloc (size_t num);
4966659607e0Smrgchar * xstrdup (const char *string);
4967659607e0Smrgconst char * base_name (const char *name);
4968659607e0Smrgchar * find_executable(const char *wrapper);
4969659607e0Smrgint    check_executable(const char *path);
4970659607e0Smrgchar * strendzap(char *str, const char *pat);
4971659607e0Smrgvoid lt_fatal (const char *message, ...);
4972659607e0Smrg
4973659607e0Smrgint
4974659607e0Smrgmain (int argc, char *argv[])
4975659607e0Smrg{
4976659607e0Smrg  char **newargz;
4977659607e0Smrg  int i;
4978659607e0Smrg
4979659607e0Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
4980659607e0Smrg  DEBUG("(main) argv[0]      : %s\n",argv[0]);
4981659607e0Smrg  DEBUG("(main) program_name : %s\n",program_name);
4982659607e0Smrg  newargz = XMALLOC(char *, argc+2);
4983659607e0SmrgEOF
4984659607e0Smrg
4985659607e0Smrg            cat >> $cwrappersource <<EOF
4986659607e0Smrg  newargz[0] = (char *) xstrdup("$SHELL");
4987659607e0SmrgEOF
4988659607e0Smrg
4989659607e0Smrg            cat >> $cwrappersource <<"EOF"
4990659607e0Smrg  newargz[1] = find_executable(argv[0]);
4991659607e0Smrg  if (newargz[1] == NULL)
4992659607e0Smrg    lt_fatal("Couldn't find %s", argv[0]);
4993659607e0Smrg  DEBUG("(main) found exe at : %s\n",newargz[1]);
4994659607e0Smrg  /* we know the script has the same name, without the .exe */
4995659607e0Smrg  /* so make sure newargz[1] doesn't end in .exe */
4996659607e0Smrg  strendzap(newargz[1],".exe");
4997659607e0Smrg  for (i = 1; i < argc; i++)
4998659607e0Smrg    newargz[i+1] = xstrdup(argv[i]);
4999659607e0Smrg  newargz[argc+1] = NULL;
5000659607e0Smrg
5001659607e0Smrg  for (i=0; i<argc+1; i++)
5002659607e0Smrg  {
5003659607e0Smrg    DEBUG("(main) newargz[%d]   : %s\n",i,newargz[i]);
5004659607e0Smrg    ;
5005659607e0Smrg  }
5006659607e0Smrg
5007659607e0SmrgEOF
5008659607e0Smrg
5009659607e0Smrg            case $host_os in
5010659607e0Smrg              mingw*)
5011659607e0Smrg                cat >> $cwrappersource <<EOF
5012659607e0Smrg  execv("$SHELL",(char const **)newargz);
5013659607e0SmrgEOF
5014659607e0Smrg              ;;
5015659607e0Smrg              *)
5016659607e0Smrg                cat >> $cwrappersource <<EOF
5017659607e0Smrg  execv("$SHELL",newargz);
5018659607e0SmrgEOF
5019659607e0Smrg              ;;
5020659607e0Smrg            esac
5021659607e0Smrg
5022659607e0Smrg            cat >> $cwrappersource <<"EOF"
5023659607e0Smrg  return 127;
5024659607e0Smrg}
5025659607e0Smrg
5026659607e0Smrgvoid *
5027659607e0Smrgxmalloc (size_t num)
5028659607e0Smrg{
5029659607e0Smrg  void * p = (void *) malloc (num);
5030659607e0Smrg  if (!p)
5031659607e0Smrg    lt_fatal ("Memory exhausted");
5032659607e0Smrg
5033659607e0Smrg  return p;
5034659607e0Smrg}
5035659607e0Smrg
5036659607e0Smrgchar *
5037659607e0Smrgxstrdup (const char *string)
5038659607e0Smrg{
5039659607e0Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL
5040659607e0Smrg;
5041659607e0Smrg}
5042659607e0Smrg
5043659607e0Smrgconst char *
5044659607e0Smrgbase_name (const char *name)
5045659607e0Smrg{
5046659607e0Smrg  const char *base;
5047659607e0Smrg
5048659607e0Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5049659607e0Smrg  /* Skip over the disk name in MSDOS pathnames. */
5050659607e0Smrg  if (isalpha ((unsigned char)name[0]) && name[1] == ':')
5051659607e0Smrg    name += 2;
5052659607e0Smrg#endif
5053659607e0Smrg
5054659607e0Smrg  for (base = name; *name; name++)
5055659607e0Smrg    if (IS_DIR_SEPARATOR (*name))
5056659607e0Smrg      base = name + 1;
5057659607e0Smrg  return base;
5058659607e0Smrg}
5059659607e0Smrg
5060659607e0Smrgint
5061659607e0Smrgcheck_executable(const char * path)
5062659607e0Smrg{
5063659607e0Smrg  struct stat st;
5064659607e0Smrg
5065659607e0Smrg  DEBUG("(check_executable)  : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
5066659607e0Smrg  if ((!path) || (!*path))
5067659607e0Smrg    return 0;
5068659607e0Smrg
5069659607e0Smrg  if ((stat (path, &st) >= 0) &&
5070659607e0Smrg      (
5071659607e0Smrg        /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
5072659607e0Smrg#if defined (S_IXOTH)
5073659607e0Smrg       ((st.st_mode & S_IXOTH) == S_IXOTH) ||
5074659607e0Smrg#endif
5075659607e0Smrg#if defined (S_IXGRP)
5076659607e0Smrg       ((st.st_mode & S_IXGRP) == S_IXGRP) ||
5077659607e0Smrg#endif
5078659607e0Smrg       ((st.st_mode & S_IXUSR) == S_IXUSR))
5079659607e0Smrg      )
5080659607e0Smrg    return 1;
5081659607e0Smrg  else
5082659607e0Smrg    return 0;
5083659607e0Smrg}
5084659607e0Smrg
5085659607e0Smrg/* Searches for the full path of the wrapper.  Returns
5086659607e0Smrg   newly allocated full path name if found, NULL otherwise */
5087659607e0Smrgchar *
5088659607e0Smrgfind_executable (const char* wrapper)
5089659607e0Smrg{
5090659607e0Smrg  int has_slash = 0;
5091659607e0Smrg  const char* p;
5092659607e0Smrg  const char* p_next;
5093659607e0Smrg  /* static buffer for getcwd */
5094659607e0Smrg  char tmp[LT_PATHMAX + 1];
5095659607e0Smrg  int tmp_len;
5096659607e0Smrg  char* concat_name;
5097659607e0Smrg
5098659607e0Smrg  DEBUG("(find_executable)  : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
5099659607e0Smrg
5100659607e0Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
5101659607e0Smrg    return NULL;
5102659607e0Smrg
5103659607e0Smrg  /* Absolute path? */
5104659607e0Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5105659607e0Smrg  if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
5106659607e0Smrg  {
5107659607e0Smrg    concat_name = xstrdup (wrapper);
5108659607e0Smrg    if (check_executable(concat_name))
5109659607e0Smrg      return concat_name;
5110659607e0Smrg    XFREE(concat_name);
5111659607e0Smrg  }
5112659607e0Smrg  else
5113659607e0Smrg  {
5114659607e0Smrg#endif
5115659607e0Smrg    if (IS_DIR_SEPARATOR (wrapper[0]))
5116659607e0Smrg    {
5117659607e0Smrg      concat_name = xstrdup (wrapper);
5118659607e0Smrg      if (check_executable(concat_name))
5119659607e0Smrg        return concat_name;
5120659607e0Smrg      XFREE(concat_name);
5121659607e0Smrg    }
5122659607e0Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5123659607e0Smrg  }
5124659607e0Smrg#endif
5125659607e0Smrg
5126659607e0Smrg  for (p = wrapper; *p; p++)
5127659607e0Smrg    if (*p == '/')
5128659607e0Smrg    {
5129659607e0Smrg      has_slash = 1;
5130659607e0Smrg      break;
5131659607e0Smrg    }
5132659607e0Smrg  if (!has_slash)
5133659607e0Smrg  {
5134659607e0Smrg    /* no slashes; search PATH */
5135659607e0Smrg    const char* path = getenv ("PATH");
5136659607e0Smrg    if (path != NULL)
5137659607e0Smrg    {
5138659607e0Smrg      for (p = path; *p; p = p_next)
5139659607e0Smrg      {
5140659607e0Smrg        const char* q;
5141659607e0Smrg        size_t p_len;
5142659607e0Smrg        for (q = p; *q; q++)
5143659607e0Smrg          if (IS_PATH_SEPARATOR(*q))
5144659607e0Smrg            break;
5145659607e0Smrg        p_len = q - p;
5146659607e0Smrg        p_next = (*q == '\0' ? q : q + 1);
5147659607e0Smrg        if (p_len == 0)
5148659607e0Smrg        {
5149659607e0Smrg          /* empty path: current directory */
5150659607e0Smrg          if (getcwd (tmp, LT_PATHMAX) == NULL)
5151659607e0Smrg            lt_fatal ("getcwd failed");
5152659607e0Smrg          tmp_len = strlen(tmp);
5153659607e0Smrg          concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
5154659607e0Smrg          memcpy (concat_name, tmp, tmp_len);
5155659607e0Smrg          concat_name[tmp_len] = '/';
5156659607e0Smrg          strcpy (concat_name + tmp_len + 1, wrapper);
5157659607e0Smrg        }
5158659607e0Smrg        else
5159659607e0Smrg        {
5160659607e0Smrg          concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
5161659607e0Smrg          memcpy (concat_name, p, p_len);
5162659607e0Smrg          concat_name[p_len] = '/';
5163659607e0Smrg          strcpy (concat_name + p_len + 1, wrapper);
5164659607e0Smrg        }
5165659607e0Smrg        if (check_executable(concat_name))
5166659607e0Smrg          return concat_name;
5167659607e0Smrg        XFREE(concat_name);
5168659607e0Smrg      }
5169659607e0Smrg    }
5170659607e0Smrg    /* not found in PATH; assume curdir */
5171659607e0Smrg  }
5172659607e0Smrg  /* Relative path | not found in path: prepend cwd */
5173659607e0Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
5174659607e0Smrg    lt_fatal ("getcwd failed");
5175659607e0Smrg  tmp_len = strlen(tmp);
5176659607e0Smrg  concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
5177659607e0Smrg  memcpy (concat_name, tmp, tmp_len);
5178659607e0Smrg  concat_name[tmp_len] = '/';
5179659607e0Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
5180659607e0Smrg
5181659607e0Smrg  if (check_executable(concat_name))
5182659607e0Smrg    return concat_name;
5183659607e0Smrg  XFREE(concat_name);
5184659607e0Smrg  return NULL;
5185659607e0Smrg}
5186659607e0Smrg
5187659607e0Smrgchar *
5188659607e0Smrgstrendzap(char *str, const char *pat)
5189659607e0Smrg{
5190659607e0Smrg  size_t len, patlen;
5191659607e0Smrg
5192659607e0Smrg  assert(str != NULL);
5193659607e0Smrg  assert(pat != NULL);
5194659607e0Smrg
5195659607e0Smrg  len = strlen(str);
5196659607e0Smrg  patlen = strlen(pat);
5197659607e0Smrg
5198659607e0Smrg  if (patlen <= len)
5199659607e0Smrg  {
5200659607e0Smrg    str += len - patlen;
5201659607e0Smrg    if (strcmp(str, pat) == 0)
5202659607e0Smrg      *str = '\0';
5203659607e0Smrg  }
5204659607e0Smrg  return str;
5205659607e0Smrg}
5206659607e0Smrg
5207659607e0Smrgstatic void
5208659607e0Smrglt_error_core (int exit_status, const char * mode,
5209659607e0Smrg          const char * message, va_list ap)
5210659607e0Smrg{
5211659607e0Smrg  fprintf (stderr, "%s: %s: ", program_name, mode);
5212659607e0Smrg  vfprintf (stderr, message, ap);
5213659607e0Smrg  fprintf (stderr, ".\n");
5214659607e0Smrg
5215659607e0Smrg  if (exit_status >= 0)
5216659607e0Smrg    exit (exit_status);
5217659607e0Smrg}
5218659607e0Smrg
5219659607e0Smrgvoid
5220659607e0Smrglt_fatal (const char *message, ...)
5221659607e0Smrg{
5222659607e0Smrg  va_list ap;
5223659607e0Smrg  va_start (ap, message);
5224659607e0Smrg  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
5225659607e0Smrg  va_end (ap);
5226659607e0Smrg}
5227659607e0SmrgEOF
5228659607e0Smrg          # we should really use a build-platform specific compiler
5229659607e0Smrg          # here, but OTOH, the wrappers (shell script and this C one)
5230659607e0Smrg          # are only useful if you want to execute the "real" binary.
5231659607e0Smrg          # Since the "real" binary is built for $host, then this
5232659607e0Smrg          # wrapper might as well be built for $host, too.
5233659607e0Smrg          $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
5234659607e0Smrg          ;;
5235659607e0Smrg        esac
5236659607e0Smrg        $rm $output
5237659607e0Smrg        trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
5238659607e0Smrg
5239659607e0Smrg	$echo > $output "\
5240659607e0Smrg#! $SHELL
5241659607e0Smrg
5242659607e0Smrg# $output - temporary wrapper script for $objdir/$outputname
5243659607e0Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
5244659607e0Smrg#
5245659607e0Smrg# The $output program cannot be directly executed until all the libtool
5246659607e0Smrg# libraries that it depends on are installed.
5247659607e0Smrg#
5248659607e0Smrg# This wrapper script should never be moved out of the build directory.
5249659607e0Smrg# If it is, it will not operate correctly.
5250659607e0Smrg
5251659607e0Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
5252659607e0Smrg# metacharacters that are still active within double-quoted strings.
5253659607e0SmrgXsed='${SED} -e 1s/^X//'
5254659607e0Smrgsed_quote_subst='$sed_quote_subst'
5255659607e0Smrg
5256659607e0Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
5257659607e0Smrg# if CDPATH is set.
5258659607e0Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
5259659607e0Smrg
5260659607e0Smrgrelink_command=\"$relink_command\"
5261659607e0Smrg
5262659607e0Smrg# This environment variable determines our operation mode.
5263659607e0Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
5264659607e0Smrg  # install mode needs the following variable:
5265659607e0Smrg  notinst_deplibs='$notinst_deplibs'
5266659607e0Smrgelse
5267659607e0Smrg  # When we are sourced in execute mode, \$file and \$echo are already set.
5268659607e0Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
5269659607e0Smrg    echo=\"$qecho\"
5270659607e0Smrg    file=\"\$0\"
5271659607e0Smrg    # Make sure echo works.
5272659607e0Smrg    if test \"X\$1\" = X--no-reexec; then
5273659607e0Smrg      # Discard the --no-reexec flag, and continue.
5274659607e0Smrg      shift
5275659607e0Smrg    elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
5276659607e0Smrg      # Yippee, \$echo works!
5277659607e0Smrg      :
5278659607e0Smrg    else
5279659607e0Smrg      # Restart under the correct shell, and then maybe \$echo will work.
5280659607e0Smrg      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
5281659607e0Smrg    fi
5282659607e0Smrg  fi\
5283659607e0Smrg"
5284659607e0Smrg	$echo >> $output "\
5285659607e0Smrg
5286659607e0Smrg  # Find the directory that this script lives in.
5287659607e0Smrg  thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
5288659607e0Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
5289659607e0Smrg
5290659607e0Smrg  # Follow symbolic links until we get to the real thisdir.
5291659607e0Smrg  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
5292659607e0Smrg  while test -n \"\$file\"; do
5293659607e0Smrg    destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
5294659607e0Smrg
5295659607e0Smrg    # If there was a directory component, then change thisdir.
5296659607e0Smrg    if test \"x\$destdir\" != \"x\$file\"; then
5297659607e0Smrg      case \"\$destdir\" in
5298659607e0Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
5299659607e0Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
5300659607e0Smrg      esac
5301659607e0Smrg    fi
5302659607e0Smrg
5303659607e0Smrg    file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
5304659607e0Smrg    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
5305659607e0Smrg  done
5306659607e0Smrg
5307659607e0Smrg  # Try to get the absolute directory name.
5308659607e0Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
5309659607e0Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
5310659607e0Smrg"
5311659607e0Smrg
5312659607e0Smrg	if test "$fast_install" = yes; then
5313659607e0Smrg	  $echo >> $output "\
5314659607e0Smrg  program=lt-'$outputname'$exeext
5315659607e0Smrg  progdir=\"\$thisdir/$objdir\"
5316659607e0Smrg
5317659607e0Smrg  if test ! -f \"\$progdir/\$program\" || \\
5318659607e0Smrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
5319659607e0Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
5320659607e0Smrg
5321659607e0Smrg    file=\"\$\$-\$program\"
5322659607e0Smrg
5323659607e0Smrg    if test ! -d \"\$progdir\"; then
5324659607e0Smrg      $mkdir \"\$progdir\"
5325659607e0Smrg    else
5326659607e0Smrg      $rm \"\$progdir/\$file\"
5327659607e0Smrg    fi"
5328659607e0Smrg
5329659607e0Smrg	  $echo >> $output "\
5330659607e0Smrg
5331659607e0Smrg    # relink executable if necessary
5332659607e0Smrg    if test -n \"\$relink_command\"; then
5333659607e0Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
5334659607e0Smrg      else
5335659607e0Smrg	$echo \"\$relink_command_output\" >&2
5336659607e0Smrg	$rm \"\$progdir/\$file\"
5337659607e0Smrg	exit $EXIT_FAILURE
5338659607e0Smrg      fi
5339659607e0Smrg    fi
5340659607e0Smrg
5341659607e0Smrg    $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
5342659607e0Smrg    { $rm \"\$progdir/\$program\";
5343659607e0Smrg      $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
5344659607e0Smrg    $rm \"\$progdir/\$file\"
5345659607e0Smrg  fi"
5346659607e0Smrg	else
5347659607e0Smrg	  $echo >> $output "\
5348659607e0Smrg  program='$outputname'
5349659607e0Smrg  progdir=\"\$thisdir/$objdir\"
5350659607e0Smrg"
5351659607e0Smrg	fi
5352659607e0Smrg
5353659607e0Smrg	$echo >> $output "\
5354659607e0Smrg
5355659607e0Smrg  if test -f \"\$progdir/\$program\"; then"
5356659607e0Smrg
5357659607e0Smrg	# Export our shlibpath_var if we have one.
5358659607e0Smrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5359659607e0Smrg	  $echo >> $output "\
5360659607e0Smrg    # Add our own library path to $shlibpath_var
5361659607e0Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
5362659607e0Smrg
5363659607e0Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
5364659607e0Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
5365659607e0Smrg    $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
5366659607e0Smrg
5367659607e0Smrg    export $shlibpath_var
5368659607e0Smrg"
5369659607e0Smrg	fi
5370659607e0Smrg
5371659607e0Smrg	# fixup the dll searchpath if we need to.
5372659607e0Smrg	if test -n "$dllsearchpath"; then
5373659607e0Smrg	  $echo >> $output "\
5374659607e0Smrg    # Add the dll search path components to the executable PATH
5375659607e0Smrg    PATH=$dllsearchpath:\$PATH
5376659607e0Smrg"
5377659607e0Smrg	fi
5378659607e0Smrg
5379659607e0Smrg	$echo >> $output "\
5380659607e0Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
5381659607e0Smrg      # Run the actual program with our arguments.
5382659607e0Smrg"
5383659607e0Smrg	case $host in
5384659607e0Smrg	# Backslashes separate directories on plain windows
5385659607e0Smrg	*-*-mingw | *-*-os2*)
5386659607e0Smrg	  $echo >> $output "\
5387659607e0Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
5388659607e0Smrg"
5389659607e0Smrg	  ;;
5390659607e0Smrg
5391659607e0Smrg	*)
5392659607e0Smrg	  $echo >> $output "\
5393659607e0Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
5394659607e0Smrg"
5395659607e0Smrg	  ;;
5396659607e0Smrg	esac
5397659607e0Smrg	$echo >> $output "\
53986aab59a7Smrg      \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
5399659607e0Smrg      exit $EXIT_FAILURE
5400659607e0Smrg    fi
5401659607e0Smrg  else
5402659607e0Smrg    # The program doesn't exist.
5403659607e0Smrg    \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
5404659607e0Smrg    \$echo \"This script is just a wrapper for \$program.\" 1>&2
5405659607e0Smrg    $echo \"See the $PACKAGE documentation for more information.\" 1>&2
5406659607e0Smrg    exit $EXIT_FAILURE
5407659607e0Smrg  fi
5408659607e0Smrgfi\
5409659607e0Smrg"
5410659607e0Smrg	chmod +x $output
5411659607e0Smrg      fi
5412659607e0Smrg      exit $EXIT_SUCCESS
5413659607e0Smrg      ;;
5414659607e0Smrg    esac
5415659607e0Smrg
5416659607e0Smrg    # See if we need to build an old-fashioned archive.
5417659607e0Smrg    for oldlib in $oldlibs; do
5418659607e0Smrg
5419659607e0Smrg      if test "$build_libtool_libs" = convenience; then
5420659607e0Smrg	oldobjs="$libobjs_save"
5421659607e0Smrg	addlibs="$convenience"
5422659607e0Smrg	build_libtool_libs=no
5423659607e0Smrg      else
5424659607e0Smrg	if test "$build_libtool_libs" = module; then
5425659607e0Smrg	  oldobjs="$libobjs_save"
5426659607e0Smrg	  build_libtool_libs=no
5427659607e0Smrg	else
5428659607e0Smrg	  oldobjs="$old_deplibs $non_pic_objects"
5429659607e0Smrg	fi
5430659607e0Smrg	addlibs="$old_convenience"
5431659607e0Smrg      fi
5432659607e0Smrg
5433659607e0Smrg      if test -n "$addlibs"; then
5434659607e0Smrg	gentop="$output_objdir/${outputname}x"
5435659607e0Smrg	generated="$generated $gentop"
5436659607e0Smrg
5437659607e0Smrg	func_extract_archives $gentop $addlibs
5438659607e0Smrg	oldobjs="$oldobjs $func_extract_archives_result"
5439659607e0Smrg      fi
5440659607e0Smrg
5441659607e0Smrg      # Do each command in the archive commands.
5442659607e0Smrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
5443659607e0Smrg       cmds=$old_archive_from_new_cmds
5444659607e0Smrg      else
5445659607e0Smrg	# POSIX demands no paths to be encoded in archives.  We have
5446659607e0Smrg	# to avoid creating archives with duplicate basenames if we
5447659607e0Smrg	# might have to extract them afterwards, e.g., when creating a
5448659607e0Smrg	# static archive out of a convenience library, or when linking
5449659607e0Smrg	# the entirety of a libtool archive into another (currently
5450659607e0Smrg	# not supported by libtool).
5451659607e0Smrg	if (for obj in $oldobjs
5452659607e0Smrg	    do
5453659607e0Smrg	      $echo "X$obj" | $Xsed -e 's%^.*/%%'
5454659607e0Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
5455659607e0Smrg	  :
5456659607e0Smrg	else
5457659607e0Smrg	  $echo "copying selected object files to avoid basename conflicts..."
5458659607e0Smrg
5459659607e0Smrg	  if test -z "$gentop"; then
5460659607e0Smrg	    gentop="$output_objdir/${outputname}x"
5461659607e0Smrg	    generated="$generated $gentop"
5462659607e0Smrg
5463659607e0Smrg	    $show "${rm}r $gentop"
5464659607e0Smrg	    $run ${rm}r "$gentop"
5465659607e0Smrg	    $show "$mkdir $gentop"
5466659607e0Smrg	    $run $mkdir "$gentop"
5467659607e0Smrg	    exit_status=$?
5468659607e0Smrg	    if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
5469659607e0Smrg	      exit $exit_status
5470659607e0Smrg	    fi
5471659607e0Smrg	  fi
5472659607e0Smrg
5473659607e0Smrg	  save_oldobjs=$oldobjs
5474659607e0Smrg	  oldobjs=
5475659607e0Smrg	  counter=1
5476659607e0Smrg	  for obj in $save_oldobjs
5477659607e0Smrg	  do
5478659607e0Smrg	    objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
5479659607e0Smrg	    case " $oldobjs " in
5480659607e0Smrg	    " ") oldobjs=$obj ;;
5481659607e0Smrg	    *[\ /]"$objbase "*)
5482659607e0Smrg	      while :; do
5483659607e0Smrg		# Make sure we don't pick an alternate name that also
5484659607e0Smrg		# overlaps.
5485659607e0Smrg		newobj=lt$counter-$objbase
5486659607e0Smrg		counter=`expr $counter + 1`
5487659607e0Smrg		case " $oldobjs " in
5488659607e0Smrg		*[\ /]"$newobj "*) ;;
5489659607e0Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
5490659607e0Smrg		esac
5491659607e0Smrg	      done
5492659607e0Smrg	      $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
5493659607e0Smrg	      $run ln "$obj" "$gentop/$newobj" ||
5494659607e0Smrg	      $run cp "$obj" "$gentop/$newobj"
5495659607e0Smrg	      oldobjs="$oldobjs $gentop/$newobj"
5496659607e0Smrg	      ;;
5497659607e0Smrg	    *) oldobjs="$oldobjs $obj" ;;
5498659607e0Smrg	    esac
5499659607e0Smrg	  done
5500659607e0Smrg	fi
5501659607e0Smrg
5502659607e0Smrg	eval cmds=\"$old_archive_cmds\"
5503659607e0Smrg
5504659607e0Smrg	if len=`expr "X$cmds" : ".*"` &&
5505659607e0Smrg	     test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
5506659607e0Smrg	  cmds=$old_archive_cmds
5507659607e0Smrg	else
5508659607e0Smrg	  # the command line is too long to link in one step, link in parts
5509659607e0Smrg	  $echo "using piecewise archive linking..."
5510659607e0Smrg	  save_RANLIB=$RANLIB
5511659607e0Smrg	  RANLIB=:
5512659607e0Smrg	  objlist=
5513659607e0Smrg	  concat_cmds=
5514659607e0Smrg	  save_oldobjs=$oldobjs
5515659607e0Smrg
5516659607e0Smrg	  # Is there a better way of finding the last object in the list?
5517659607e0Smrg	  for obj in $save_oldobjs
5518659607e0Smrg	  do
5519659607e0Smrg	    last_oldobj=$obj
5520659607e0Smrg	  done
5521659607e0Smrg	  for obj in $save_oldobjs
5522659607e0Smrg	  do
5523659607e0Smrg	    oldobjs="$objlist $obj"
5524659607e0Smrg	    objlist="$objlist $obj"
5525659607e0Smrg	    eval test_cmds=\"$old_archive_cmds\"
5526659607e0Smrg	    if len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
5527659607e0Smrg	       test "$len" -le "$max_cmd_len"; then
5528659607e0Smrg	      :
5529659607e0Smrg	    else
5530659607e0Smrg	      # the above command should be used before it gets too long
5531659607e0Smrg	      oldobjs=$objlist
5532659607e0Smrg	      if test "$obj" = "$last_oldobj" ; then
5533659607e0Smrg	        RANLIB=$save_RANLIB
5534659607e0Smrg	      fi
5535659607e0Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
5536659607e0Smrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
5537659607e0Smrg	      objlist=
5538659607e0Smrg	    fi
5539659607e0Smrg	  done
5540659607e0Smrg	  RANLIB=$save_RANLIB
5541659607e0Smrg	  oldobjs=$objlist
5542659607e0Smrg	  if test "X$oldobjs" = "X" ; then
5543659607e0Smrg	    eval cmds=\"\$concat_cmds\"
5544659607e0Smrg	  else
5545659607e0Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
5546659607e0Smrg	  fi
5547659607e0Smrg	fi
5548659607e0Smrg      fi
5549659607e0Smrg      save_ifs="$IFS"; IFS='~'
5550659607e0Smrg      for cmd in $cmds; do
5551659607e0Smrg        eval cmd=\"$cmd\"
5552659607e0Smrg	IFS="$save_ifs"
5553659607e0Smrg	$show "$cmd"
5554659607e0Smrg	$run eval "$cmd" || exit $?
5555659607e0Smrg      done
5556659607e0Smrg      IFS="$save_ifs"
5557659607e0Smrg    done
5558659607e0Smrg
5559659607e0Smrg    if test -n "$generated"; then
5560659607e0Smrg      $show "${rm}r$generated"
5561659607e0Smrg      $run ${rm}r$generated
5562659607e0Smrg    fi
5563659607e0Smrg
5564659607e0Smrg    # Now create the libtool archive.
5565659607e0Smrg    case $output in
5566659607e0Smrg    *.la)
5567659607e0Smrg      old_library=
5568659607e0Smrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
5569659607e0Smrg      $show "creating $output"
5570659607e0Smrg
5571659607e0Smrg      # Preserve any variables that may affect compiler behavior
5572659607e0Smrg      for var in $variables_saved_for_relink; do
5573659607e0Smrg	if eval test -z \"\${$var+set}\"; then
5574659607e0Smrg	  relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
5575659607e0Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
5576659607e0Smrg	  relink_command="$var=; export $var; $relink_command"
5577659607e0Smrg	else
5578659607e0Smrg	  var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
5579659607e0Smrg	  relink_command="$var=\"$var_value\"; export $var; $relink_command"
5580659607e0Smrg	fi
5581659607e0Smrg      done
5582659607e0Smrg      # Quote the link command for shipping.
5583659607e0Smrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
55846aab59a7Smrg      relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
5585659607e0Smrg      if test "$hardcode_automatic" = yes ; then
5586659607e0Smrg	relink_command=
5587659607e0Smrg      fi
5588659607e0Smrg
5589659607e0Smrg
5590659607e0Smrg      # Only create the output if not a dry run.
5591659607e0Smrg      if test -z "$run"; then
5592659607e0Smrg	for installed in no yes; do
5593659607e0Smrg	  if test "$installed" = yes; then
5594659607e0Smrg	    if test -z "$install_libdir"; then
5595659607e0Smrg	      break
5596659607e0Smrg	    fi
5597659607e0Smrg	    output="$output_objdir/$outputname"i
5598659607e0Smrg	    # Replace all uninstalled libtool libraries with the installed ones
5599659607e0Smrg	    newdependency_libs=
5600659607e0Smrg	    for deplib in $dependency_libs; do
5601659607e0Smrg	      case $deplib in
5602659607e0Smrg	      *.la)
5603659607e0Smrg		name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
5604659607e0Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
5605659607e0Smrg		if test -z "$libdir"; then
5606659607e0Smrg		  $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
5607659607e0Smrg		  exit $EXIT_FAILURE
5608659607e0Smrg		fi
5609659607e0Smrg		newdependency_libs="$newdependency_libs $libdir/$name"
5610659607e0Smrg		;;
5611659607e0Smrg	      *) newdependency_libs="$newdependency_libs $deplib" ;;
5612659607e0Smrg	      esac
5613659607e0Smrg	    done
5614659607e0Smrg	    dependency_libs="$newdependency_libs"
5615659607e0Smrg	    newdlfiles=
5616659607e0Smrg	    for lib in $dlfiles; do
5617659607e0Smrg	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
5618659607e0Smrg	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
5619659607e0Smrg	      if test -z "$libdir"; then
5620659607e0Smrg		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
5621659607e0Smrg		exit $EXIT_FAILURE
5622659607e0Smrg	      fi
5623659607e0Smrg	      newdlfiles="$newdlfiles $libdir/$name"
5624659607e0Smrg	    done
5625659607e0Smrg	    dlfiles="$newdlfiles"
5626659607e0Smrg	    newdlprefiles=
5627659607e0Smrg	    for lib in $dlprefiles; do
5628659607e0Smrg	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
5629659607e0Smrg	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
5630659607e0Smrg	      if test -z "$libdir"; then
5631659607e0Smrg		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
5632659607e0Smrg		exit $EXIT_FAILURE
5633659607e0Smrg	      fi
5634659607e0Smrg	      newdlprefiles="$newdlprefiles $libdir/$name"
5635659607e0Smrg	    done
5636659607e0Smrg	    dlprefiles="$newdlprefiles"
5637659607e0Smrg	  else
5638659607e0Smrg	    newdlfiles=
5639659607e0Smrg	    for lib in $dlfiles; do
5640659607e0Smrg	      case $lib in
5641659607e0Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
5642659607e0Smrg		*) abs=`pwd`"/$lib" ;;
5643659607e0Smrg	      esac
5644659607e0Smrg	      newdlfiles="$newdlfiles $abs"
5645659607e0Smrg	    done
5646659607e0Smrg	    dlfiles="$newdlfiles"
5647659607e0Smrg	    newdlprefiles=
5648659607e0Smrg	    for lib in $dlprefiles; do
5649659607e0Smrg	      case $lib in
5650659607e0Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
5651659607e0Smrg		*) abs=`pwd`"/$lib" ;;
5652659607e0Smrg	      esac
5653659607e0Smrg	      newdlprefiles="$newdlprefiles $abs"
5654659607e0Smrg	    done
5655659607e0Smrg	    dlprefiles="$newdlprefiles"
5656659607e0Smrg	  fi
5657659607e0Smrg	  $rm $output
5658659607e0Smrg	  # place dlname in correct position for cygwin
5659659607e0Smrg	  tdlname=$dlname
5660659607e0Smrg	  case $host,$output,$installed,$module,$dlname in
5661659607e0Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
5662659607e0Smrg	  esac
5663659607e0Smrg	  $echo > $output "\
5664659607e0Smrg# $outputname - a libtool library file
5665659607e0Smrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
5666659607e0Smrg#
5667659607e0Smrg# Please DO NOT delete this file!
5668659607e0Smrg# It is necessary for linking the library.
5669659607e0Smrg
5670659607e0Smrg# The name that we can dlopen(3).
5671659607e0Smrgdlname='$tdlname'
5672659607e0Smrg
5673659607e0Smrg# Names of this library.
5674659607e0Smrglibrary_names='$library_names'
5675659607e0Smrg
5676659607e0Smrg# The name of the static archive.
5677659607e0Smrgold_library='$old_library'
5678659607e0Smrg
5679659607e0Smrg# Libraries that this one depends upon.
5680659607e0Smrgdependency_libs='$dependency_libs'
5681659607e0Smrg
5682659607e0Smrg# Version information for $libname.
5683659607e0Smrgcurrent=$current
5684659607e0Smrgage=$age
5685659607e0Smrgrevision=$revision
5686659607e0Smrg
5687659607e0Smrg# Is this an already installed library?
5688659607e0Smrginstalled=$installed
5689659607e0Smrg
5690659607e0Smrg# Should we warn about portability when linking against -modules?
5691659607e0Smrgshouldnotlink=$module
5692659607e0Smrg
5693659607e0Smrg# Files to dlopen/dlpreopen
5694659607e0Smrgdlopen='$dlfiles'
5695659607e0Smrgdlpreopen='$dlprefiles'
5696659607e0Smrg
5697659607e0Smrg# Directory that this library needs to be installed in:
5698659607e0Smrglibdir='$install_libdir'"
5699659607e0Smrg	  if test "$installed" = no && test "$need_relink" = yes; then
5700659607e0Smrg	    $echo >> $output "\
5701659607e0Smrgrelink_command=\"$relink_command\""
5702659607e0Smrg	  fi
5703659607e0Smrg	done
5704659607e0Smrg      fi
5705659607e0Smrg
5706659607e0Smrg      # Do a symbolic link so that the libtool archive can be found in
5707659607e0Smrg      # LD_LIBRARY_PATH before the program is installed.
5708659607e0Smrg      $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
5709659607e0Smrg      $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $?
5710659607e0Smrg      ;;
5711659607e0Smrg    esac
5712659607e0Smrg    exit $EXIT_SUCCESS
5713659607e0Smrg    ;;
5714659607e0Smrg
5715659607e0Smrg  # libtool install mode
5716659607e0Smrg  install)
5717659607e0Smrg    modename="$modename: install"
5718659607e0Smrg
5719659607e0Smrg    # There may be an optional sh(1) argument at the beginning of
5720659607e0Smrg    # install_prog (especially on Windows NT).
5721659607e0Smrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
5722659607e0Smrg       # Allow the use of GNU shtool's install command.
5723659607e0Smrg       $echo "X$nonopt" | grep shtool > /dev/null; then
5724659607e0Smrg      # Aesthetically quote it.
5725659607e0Smrg      arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
5726659607e0Smrg      case $arg in
5727659607e0Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
5728659607e0Smrg	arg="\"$arg\""
5729659607e0Smrg	;;
5730659607e0Smrg      esac
5731659607e0Smrg      install_prog="$arg "
5732659607e0Smrg      arg="$1"
5733659607e0Smrg      shift
5734659607e0Smrg    else
5735659607e0Smrg      install_prog=
5736659607e0Smrg      arg=$nonopt
5737659607e0Smrg    fi
5738659607e0Smrg
5739659607e0Smrg    # The real first argument should be the name of the installation program.
5740659607e0Smrg    # Aesthetically quote it.
5741659607e0Smrg    arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
5742659607e0Smrg    case $arg in
5743659607e0Smrg    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
5744659607e0Smrg      arg="\"$arg\""
5745659607e0Smrg      ;;
5746659607e0Smrg    esac
5747659607e0Smrg    install_prog="$install_prog$arg"
5748659607e0Smrg
5749659607e0Smrg    # We need to accept at least all the BSD install flags.
5750659607e0Smrg    dest=
5751659607e0Smrg    files=
5752659607e0Smrg    opts=
5753659607e0Smrg    prev=
5754659607e0Smrg    install_type=
5755659607e0Smrg    isdir=no
5756659607e0Smrg    stripme=
5757659607e0Smrg    for arg
5758659607e0Smrg    do
5759659607e0Smrg      if test -n "$dest"; then
5760659607e0Smrg	files="$files $dest"
5761659607e0Smrg	dest=$arg
5762659607e0Smrg	continue
5763659607e0Smrg      fi
5764659607e0Smrg
5765659607e0Smrg      case $arg in
5766659607e0Smrg      -d) isdir=yes ;;
5767659607e0Smrg      -f) 
5768659607e0Smrg      	case " $install_prog " in
5769659607e0Smrg	*[\\\ /]cp\ *) ;;
5770659607e0Smrg	*) prev=$arg ;;
5771659607e0Smrg	esac
5772659607e0Smrg	;;
5773659607e0Smrg      -g | -m | -o) prev=$arg ;;
5774659607e0Smrg      -s)
5775659607e0Smrg	stripme=" -s"
5776659607e0Smrg	continue
5777659607e0Smrg	;;
5778659607e0Smrg      -*)
5779659607e0Smrg	;;
5780659607e0Smrg      *)
5781659607e0Smrg	# If the previous option needed an argument, then skip it.
5782659607e0Smrg	if test -n "$prev"; then
5783659607e0Smrg	  prev=
5784659607e0Smrg	else
5785659607e0Smrg	  dest=$arg
5786659607e0Smrg	  continue
5787659607e0Smrg	fi
5788659607e0Smrg	;;
5789659607e0Smrg      esac
5790659607e0Smrg
5791659607e0Smrg      # Aesthetically quote the argument.
5792659607e0Smrg      arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
5793659607e0Smrg      case $arg in
5794659607e0Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
5795659607e0Smrg	arg="\"$arg\""
5796659607e0Smrg	;;
5797659607e0Smrg      esac
5798659607e0Smrg      install_prog="$install_prog $arg"
5799659607e0Smrg    done
5800659607e0Smrg
5801659607e0Smrg    if test -z "$install_prog"; then
5802659607e0Smrg      $echo "$modename: you must specify an install program" 1>&2
5803659607e0Smrg      $echo "$help" 1>&2
5804659607e0Smrg      exit $EXIT_FAILURE
5805659607e0Smrg    fi
5806659607e0Smrg
5807659607e0Smrg    if test -n "$prev"; then
5808659607e0Smrg      $echo "$modename: the \`$prev' option requires an argument" 1>&2
5809659607e0Smrg      $echo "$help" 1>&2
5810659607e0Smrg      exit $EXIT_FAILURE
5811659607e0Smrg    fi
5812659607e0Smrg
5813659607e0Smrg    if test -z "$files"; then
5814659607e0Smrg      if test -z "$dest"; then
5815659607e0Smrg	$echo "$modename: no file or destination specified" 1>&2
5816659607e0Smrg      else
5817659607e0Smrg	$echo "$modename: you must specify a destination" 1>&2
5818659607e0Smrg      fi
5819659607e0Smrg      $echo "$help" 1>&2
5820659607e0Smrg      exit $EXIT_FAILURE
5821659607e0Smrg    fi
5822659607e0Smrg
5823659607e0Smrg    # Strip any trailing slash from the destination.
5824659607e0Smrg    dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
5825659607e0Smrg
5826659607e0Smrg    # Check to see that the destination is a directory.
5827659607e0Smrg    test -d "$dest" && isdir=yes
5828659607e0Smrg    if test "$isdir" = yes; then
5829659607e0Smrg      destdir="$dest"
5830659607e0Smrg      destname=
5831659607e0Smrg    else
5832659607e0Smrg      destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
5833659607e0Smrg      test "X$destdir" = "X$dest" && destdir=.
5834659607e0Smrg      destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
5835659607e0Smrg
5836659607e0Smrg      # Not a directory, so check to see that there is only one file specified.
5837659607e0Smrg      set dummy $files
5838659607e0Smrg      if test "$#" -gt 2; then
5839659607e0Smrg	$echo "$modename: \`$dest' is not a directory" 1>&2
5840659607e0Smrg	$echo "$help" 1>&2
5841659607e0Smrg	exit $EXIT_FAILURE
5842659607e0Smrg      fi
5843659607e0Smrg    fi
5844659607e0Smrg    case $destdir in
5845659607e0Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
5846659607e0Smrg    *)
5847659607e0Smrg      for file in $files; do
5848659607e0Smrg	case $file in
5849659607e0Smrg	*.lo) ;;
5850659607e0Smrg	*)
5851659607e0Smrg	  $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
5852659607e0Smrg	  $echo "$help" 1>&2
5853659607e0Smrg	  exit $EXIT_FAILURE
5854659607e0Smrg	  ;;
5855659607e0Smrg	esac
5856659607e0Smrg      done
5857659607e0Smrg      ;;
5858659607e0Smrg    esac
5859659607e0Smrg
5860659607e0Smrg    # This variable tells wrapper scripts just to set variables rather
5861659607e0Smrg    # than running their programs.
5862659607e0Smrg    libtool_install_magic="$magic"
5863659607e0Smrg
5864659607e0Smrg    staticlibs=
5865659607e0Smrg    future_libdirs=
5866659607e0Smrg    current_libdirs=
5867659607e0Smrg    for file in $files; do
5868659607e0Smrg
5869659607e0Smrg      # Do each installation.
5870659607e0Smrg      case $file in
5871659607e0Smrg      *.$libext)
5872659607e0Smrg	# Do the static libraries later.
5873659607e0Smrg	staticlibs="$staticlibs $file"
5874659607e0Smrg	;;
5875659607e0Smrg
5876659607e0Smrg      *.la)
5877659607e0Smrg	# Check to see that this really is a libtool archive.
5878659607e0Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
5879659607e0Smrg	else
5880659607e0Smrg	  $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
5881659607e0Smrg	  $echo "$help" 1>&2
5882659607e0Smrg	  exit $EXIT_FAILURE
5883659607e0Smrg	fi
5884659607e0Smrg
5885659607e0Smrg	library_names=
5886659607e0Smrg	old_library=
5887659607e0Smrg	relink_command=
5888659607e0Smrg	# If there is no directory component, then add one.
5889659607e0Smrg	case $file in
5890659607e0Smrg	*/* | *\\*) . $file ;;
5891659607e0Smrg	*) . ./$file ;;
5892659607e0Smrg	esac
5893659607e0Smrg
5894659607e0Smrg	# Add the libdir to current_libdirs if it is the destination.
5895659607e0Smrg	if test "X$destdir" = "X$libdir"; then
5896659607e0Smrg	  case "$current_libdirs " in
5897659607e0Smrg	  *" $libdir "*) ;;
5898659607e0Smrg	  *) current_libdirs="$current_libdirs $libdir" ;;
5899659607e0Smrg	  esac
5900659607e0Smrg	else
5901659607e0Smrg	  # Note the libdir as a future libdir.
5902659607e0Smrg	  case "$future_libdirs " in
5903659607e0Smrg	  *" $libdir "*) ;;
5904659607e0Smrg	  *) future_libdirs="$future_libdirs $libdir" ;;
5905659607e0Smrg	  esac
5906659607e0Smrg	fi
5907659607e0Smrg
5908659607e0Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/
5909659607e0Smrg	test "X$dir" = "X$file/" && dir=
5910659607e0Smrg	dir="$dir$objdir"
5911659607e0Smrg
5912659607e0Smrg	if test -n "$relink_command"; then
5913659607e0Smrg	  # Determine the prefix the user has applied to our future dir.
5914659607e0Smrg	  inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"`
5915659607e0Smrg
5916659607e0Smrg	  # Don't allow the user to place us outside of our expected
5917659607e0Smrg	  # location b/c this prevents finding dependent libraries that
5918659607e0Smrg	  # are installed to the same prefix.
5919659607e0Smrg	  # At present, this check doesn't affect windows .dll's that
5920659607e0Smrg	  # are installed into $libdir/../bin (currently, that works fine)
5921659607e0Smrg	  # but it's something to keep an eye on.
5922659607e0Smrg	  if test "$inst_prefix_dir" = "$destdir"; then
5923659607e0Smrg	    $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
5924659607e0Smrg	    exit $EXIT_FAILURE
5925659607e0Smrg	  fi
5926659607e0Smrg
5927659607e0Smrg	  if test -n "$inst_prefix_dir"; then
5928659607e0Smrg	    # Stick the inst_prefix_dir data into the link command.
59296aab59a7Smrg	    relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
5930659607e0Smrg	  else
59316aab59a7Smrg	    relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
5932659607e0Smrg	  fi
5933659607e0Smrg
5934659607e0Smrg	  $echo "$modename: warning: relinking \`$file'" 1>&2
5935659607e0Smrg	  $show "$relink_command"
5936659607e0Smrg	  if $run eval "$relink_command"; then :
5937659607e0Smrg	  else
5938659607e0Smrg	    $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
5939659607e0Smrg	    exit $EXIT_FAILURE
5940659607e0Smrg	  fi
5941659607e0Smrg	fi
5942659607e0Smrg
5943659607e0Smrg	# See the names of the shared library.
5944659607e0Smrg	set dummy $library_names
5945659607e0Smrg	if test -n "$2"; then
5946659607e0Smrg	  realname="$2"
5947659607e0Smrg	  shift
5948659607e0Smrg	  shift
5949659607e0Smrg
5950659607e0Smrg	  srcname="$realname"
5951659607e0Smrg	  test -n "$relink_command" && srcname="$realname"T
5952659607e0Smrg
5953659607e0Smrg	  # Install the shared library and build the symlinks.
5954659607e0Smrg	  $show "$install_prog $dir/$srcname $destdir/$realname"
5955659607e0Smrg	  $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $?
5956659607e0Smrg	  if test -n "$stripme" && test -n "$striplib"; then
5957659607e0Smrg	    $show "$striplib $destdir/$realname"
5958659607e0Smrg	    $run eval "$striplib $destdir/$realname" || exit $?
5959659607e0Smrg	  fi
5960659607e0Smrg
5961659607e0Smrg	  if test "$#" -gt 0; then
5962659607e0Smrg	    # Delete the old symlinks, and create new ones.
5963659607e0Smrg	    # Try `ln -sf' first, because the `ln' binary might depend on
5964659607e0Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
5965659607e0Smrg	    # so we also need to try rm && ln -s.
5966659607e0Smrg	    for linkname
5967659607e0Smrg	    do
5968659607e0Smrg	      if test "$linkname" != "$realname"; then
5969659607e0Smrg                $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
5970659607e0Smrg                $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
5971659607e0Smrg	      fi
5972659607e0Smrg	    done
5973659607e0Smrg	  fi
5974659607e0Smrg
5975659607e0Smrg	  # Do each command in the postinstall commands.
5976659607e0Smrg	  lib="$destdir/$realname"
5977659607e0Smrg	  cmds=$postinstall_cmds
5978659607e0Smrg	  save_ifs="$IFS"; IFS='~'
5979659607e0Smrg	  for cmd in $cmds; do
5980659607e0Smrg	    IFS="$save_ifs"
5981659607e0Smrg	    eval cmd=\"$cmd\"
5982659607e0Smrg	    $show "$cmd"
5983659607e0Smrg	    $run eval "$cmd" || {
5984659607e0Smrg	      lt_exit=$?
5985659607e0Smrg
5986659607e0Smrg	      # Restore the uninstalled library and exit
5987659607e0Smrg	      if test "$mode" = relink; then
5988659607e0Smrg		$run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
5989659607e0Smrg	      fi
5990659607e0Smrg
5991659607e0Smrg	      exit $lt_exit
5992659607e0Smrg	    }
5993659607e0Smrg	  done
5994659607e0Smrg	  IFS="$save_ifs"
5995659607e0Smrg	fi
5996659607e0Smrg
5997659607e0Smrg	# Install the pseudo-library for information purposes.
5998659607e0Smrg	name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
5999659607e0Smrg	instname="$dir/$name"i
6000659607e0Smrg	$show "$install_prog $instname $destdir/$name"
6001659607e0Smrg	$run eval "$install_prog $instname $destdir/$name" || exit $?
6002659607e0Smrg
6003659607e0Smrg	# Maybe install the static library, too.
6004659607e0Smrg	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
6005659607e0Smrg	;;
6006659607e0Smrg
6007659607e0Smrg      *.lo)
6008659607e0Smrg	# Install (i.e. copy) a libtool object.
6009659607e0Smrg
6010659607e0Smrg	# Figure out destination file name, if it wasn't already specified.
6011659607e0Smrg	if test -n "$destname"; then
6012659607e0Smrg	  destfile="$destdir/$destname"
6013659607e0Smrg	else
6014659607e0Smrg	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
6015659607e0Smrg	  destfile="$destdir/$destfile"
6016659607e0Smrg	fi
6017659607e0Smrg
6018659607e0Smrg	# Deduce the name of the destination old-style object file.
6019659607e0Smrg	case $destfile in
6020659607e0Smrg	*.lo)
6021659607e0Smrg	  staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
6022659607e0Smrg	  ;;
6023659607e0Smrg	*.$objext)
6024659607e0Smrg	  staticdest="$destfile"
6025659607e0Smrg	  destfile=
6026659607e0Smrg	  ;;
6027659607e0Smrg	*)
6028659607e0Smrg	  $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
6029659607e0Smrg	  $echo "$help" 1>&2
6030659607e0Smrg	  exit $EXIT_FAILURE
6031659607e0Smrg	  ;;
6032659607e0Smrg	esac
6033659607e0Smrg
6034659607e0Smrg	# Install the libtool object if requested.
6035659607e0Smrg	if test -n "$destfile"; then
6036659607e0Smrg	  $show "$install_prog $file $destfile"
6037659607e0Smrg	  $run eval "$install_prog $file $destfile" || exit $?
6038659607e0Smrg	fi
6039659607e0Smrg
6040659607e0Smrg	# Install the old object if enabled.
6041659607e0Smrg	if test "$build_old_libs" = yes; then
6042659607e0Smrg	  # Deduce the name of the old-style object file.
6043659607e0Smrg	  staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
6044659607e0Smrg
6045659607e0Smrg	  $show "$install_prog $staticobj $staticdest"
6046659607e0Smrg	  $run eval "$install_prog \$staticobj \$staticdest" || exit $?
6047659607e0Smrg	fi
6048659607e0Smrg	exit $EXIT_SUCCESS
6049659607e0Smrg	;;
6050659607e0Smrg
6051659607e0Smrg      *)
6052659607e0Smrg	# Figure out destination file name, if it wasn't already specified.
6053659607e0Smrg	if test -n "$destname"; then
6054659607e0Smrg	  destfile="$destdir/$destname"
6055659607e0Smrg	else
6056659607e0Smrg	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
6057659607e0Smrg	  destfile="$destdir/$destfile"
6058659607e0Smrg	fi
6059659607e0Smrg
6060659607e0Smrg	# If the file is missing, and there is a .exe on the end, strip it
6061659607e0Smrg	# because it is most likely a libtool script we actually want to
6062659607e0Smrg	# install
6063659607e0Smrg	stripped_ext=""
6064659607e0Smrg	case $file in
6065659607e0Smrg	  *.exe)
6066659607e0Smrg	    if test ! -f "$file"; then
6067659607e0Smrg	      file=`$echo $file|${SED} 's,.exe$,,'`
6068659607e0Smrg	      stripped_ext=".exe"
6069659607e0Smrg	    fi
6070659607e0Smrg	    ;;
6071659607e0Smrg	esac
6072659607e0Smrg
6073659607e0Smrg	# Do a test to see if this is really a libtool program.
6074659607e0Smrg	case $host in
6075659607e0Smrg	*cygwin*|*mingw*)
6076659607e0Smrg	    wrapper=`$echo $file | ${SED} -e 's,.exe$,,'`
6077659607e0Smrg	    ;;
6078659607e0Smrg	*)
6079659607e0Smrg	    wrapper=$file
6080659607e0Smrg	    ;;
6081659607e0Smrg	esac
6082659607e0Smrg	if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then
6083659607e0Smrg	  notinst_deplibs=
6084659607e0Smrg	  relink_command=
6085659607e0Smrg
6086659607e0Smrg	  # Note that it is not necessary on cygwin/mingw to append a dot to
6087659607e0Smrg	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
6088659607e0Smrg	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
6089659607e0Smrg	  # `FILE.' does not work on cygwin managed mounts.
6090659607e0Smrg	  #
6091659607e0Smrg	  # If there is no directory component, then add one.
6092659607e0Smrg	  case $wrapper in
6093659607e0Smrg	  */* | *\\*) . ${wrapper} ;;
6094659607e0Smrg	  *) . ./${wrapper} ;;
6095659607e0Smrg	  esac
6096659607e0Smrg
6097659607e0Smrg	  # Check the variables that should have been set.
6098659607e0Smrg	  if test -z "$notinst_deplibs"; then
6099659607e0Smrg	    $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2
6100659607e0Smrg	    exit $EXIT_FAILURE
6101659607e0Smrg	  fi
6102659607e0Smrg
6103659607e0Smrg	  finalize=yes
6104659607e0Smrg	  for lib in $notinst_deplibs; do
6105659607e0Smrg	    # Check to see that each library is installed.
6106659607e0Smrg	    libdir=
6107659607e0Smrg	    if test -f "$lib"; then
6108659607e0Smrg	      # If there is no directory component, then add one.
6109659607e0Smrg	      case $lib in
6110659607e0Smrg	      */* | *\\*) . $lib ;;
6111659607e0Smrg	      *) . ./$lib ;;
6112659607e0Smrg	      esac
6113659607e0Smrg	    fi
6114659607e0Smrg	    libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
6115659607e0Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
6116659607e0Smrg	      $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
6117659607e0Smrg	      finalize=no
6118659607e0Smrg	    fi
6119659607e0Smrg	  done
6120659607e0Smrg
6121659607e0Smrg	  relink_command=
6122659607e0Smrg	  # Note that it is not necessary on cygwin/mingw to append a dot to
6123659607e0Smrg	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
6124659607e0Smrg	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
6125659607e0Smrg	  # `FILE.' does not work on cygwin managed mounts.
6126659607e0Smrg	  #
6127659607e0Smrg	  # If there is no directory component, then add one.
6128659607e0Smrg	  case $wrapper in
6129659607e0Smrg	  */* | *\\*) . ${wrapper} ;;
6130659607e0Smrg	  *) . ./${wrapper} ;;
6131659607e0Smrg	  esac
6132659607e0Smrg
6133659607e0Smrg	  outputname=
6134659607e0Smrg	  if test "$fast_install" = no && test -n "$relink_command"; then
6135659607e0Smrg	    if test "$finalize" = yes && test -z "$run"; then
6136659607e0Smrg	      tmpdir=`func_mktempdir`
6137659607e0Smrg	      file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
6138659607e0Smrg	      outputname="$tmpdir/$file"
6139659607e0Smrg	      # Replace the output file specification.
61406aab59a7Smrg	      relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
6141659607e0Smrg
6142659607e0Smrg	      $show "$relink_command"
6143659607e0Smrg	      if $run eval "$relink_command"; then :
6144659607e0Smrg	      else
6145659607e0Smrg		$echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
6146659607e0Smrg		${rm}r "$tmpdir"
6147659607e0Smrg		continue
6148659607e0Smrg	      fi
6149659607e0Smrg	      file="$outputname"
6150659607e0Smrg	    else
6151659607e0Smrg	      $echo "$modename: warning: cannot relink \`$file'" 1>&2
6152659607e0Smrg	    fi
6153659607e0Smrg	  else
6154659607e0Smrg	    # Install the binary that we compiled earlier.
6155659607e0Smrg	    file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
6156659607e0Smrg	  fi
6157659607e0Smrg	fi
6158659607e0Smrg
6159659607e0Smrg	# remove .exe since cygwin /usr/bin/install will append another
6160659607e0Smrg	# one anyway 
6161659607e0Smrg	case $install_prog,$host in
6162659607e0Smrg	*/usr/bin/install*,*cygwin*)
6163659607e0Smrg	  case $file:$destfile in
6164659607e0Smrg	  *.exe:*.exe)
6165659607e0Smrg	    # this is ok
6166659607e0Smrg	    ;;
6167659607e0Smrg	  *.exe:*)
6168659607e0Smrg	    destfile=$destfile.exe
6169659607e0Smrg	    ;;
6170659607e0Smrg	  *:*.exe)
6171659607e0Smrg	    destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'`
6172659607e0Smrg	    ;;
6173659607e0Smrg	  esac
6174659607e0Smrg	  ;;
6175659607e0Smrg	esac
6176659607e0Smrg	$show "$install_prog$stripme $file $destfile"
6177659607e0Smrg	$run eval "$install_prog\$stripme \$file \$destfile" || exit $?
6178659607e0Smrg	test -n "$outputname" && ${rm}r "$tmpdir"
6179659607e0Smrg	;;
6180659607e0Smrg      esac
6181659607e0Smrg    done
6182659607e0Smrg
6183659607e0Smrg    for file in $staticlibs; do
6184659607e0Smrg      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
6185659607e0Smrg
6186659607e0Smrg      # Set up the ranlib parameters.
6187659607e0Smrg      oldlib="$destdir/$name"
6188659607e0Smrg
6189659607e0Smrg      $show "$install_prog $file $oldlib"
6190659607e0Smrg      $run eval "$install_prog \$file \$oldlib" || exit $?
6191659607e0Smrg
6192659607e0Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
6193659607e0Smrg	$show "$old_striplib $oldlib"
6194659607e0Smrg	$run eval "$old_striplib $oldlib" || exit $?
6195659607e0Smrg      fi
6196659607e0Smrg
6197659607e0Smrg      # Do each command in the postinstall commands.
6198659607e0Smrg      cmds=$old_postinstall_cmds
6199659607e0Smrg      save_ifs="$IFS"; IFS='~'
6200659607e0Smrg      for cmd in $cmds; do
6201659607e0Smrg	IFS="$save_ifs"
6202659607e0Smrg	eval cmd=\"$cmd\"
6203659607e0Smrg	$show "$cmd"
6204659607e0Smrg	$run eval "$cmd" || exit $?
6205659607e0Smrg      done
6206659607e0Smrg      IFS="$save_ifs"
6207659607e0Smrg    done
6208659607e0Smrg
6209659607e0Smrg    if test -n "$future_libdirs"; then
6210659607e0Smrg      $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
6211659607e0Smrg    fi
6212659607e0Smrg
6213659607e0Smrg    if test -n "$current_libdirs"; then
6214659607e0Smrg      # Maybe just do a dry run.
6215659607e0Smrg      test -n "$run" && current_libdirs=" -n$current_libdirs"
6216659607e0Smrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
6217659607e0Smrg    else
6218659607e0Smrg      exit $EXIT_SUCCESS
6219659607e0Smrg    fi
6220659607e0Smrg    ;;
6221659607e0Smrg
6222659607e0Smrg  # libtool finish mode
6223659607e0Smrg  finish)
6224659607e0Smrg    modename="$modename: finish"
6225659607e0Smrg    libdirs="$nonopt"
6226659607e0Smrg    admincmds=
6227659607e0Smrg
6228659607e0Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
6229659607e0Smrg      for dir
6230659607e0Smrg      do
6231659607e0Smrg	libdirs="$libdirs $dir"
6232659607e0Smrg      done
6233659607e0Smrg
6234659607e0Smrg      for libdir in $libdirs; do
6235659607e0Smrg	if test -n "$finish_cmds"; then
6236659607e0Smrg	  # Do each command in the finish commands.
6237659607e0Smrg	  cmds=$finish_cmds
6238659607e0Smrg	  save_ifs="$IFS"; IFS='~'
6239659607e0Smrg	  for cmd in $cmds; do
6240659607e0Smrg	    IFS="$save_ifs"
6241659607e0Smrg	    eval cmd=\"$cmd\"
6242659607e0Smrg	    $show "$cmd"
6243659607e0Smrg	    $run eval "$cmd" || admincmds="$admincmds
6244659607e0Smrg       $cmd"
6245659607e0Smrg	  done
6246659607e0Smrg	  IFS="$save_ifs"
6247659607e0Smrg	fi
6248659607e0Smrg	if test -n "$finish_eval"; then
6249659607e0Smrg	  # Do the single finish_eval.
6250659607e0Smrg	  eval cmds=\"$finish_eval\"
6251659607e0Smrg	  $run eval "$cmds" || admincmds="$admincmds
6252659607e0Smrg       $cmds"
6253659607e0Smrg	fi
6254659607e0Smrg      done
6255659607e0Smrg    fi
6256659607e0Smrg
6257659607e0Smrg    # Exit here if they wanted silent mode.
6258659607e0Smrg    test "$show" = : && exit $EXIT_SUCCESS
6259659607e0Smrg
6260659607e0Smrg    $echo "X----------------------------------------------------------------------" | $Xsed
6261659607e0Smrg    $echo "Libraries have been installed in:"
6262659607e0Smrg    for libdir in $libdirs; do
6263659607e0Smrg      $echo "   $libdir"
6264659607e0Smrg    done
6265659607e0Smrg    $echo
6266659607e0Smrg    $echo "If you ever happen to want to link against installed libraries"
6267659607e0Smrg    $echo "in a given directory, LIBDIR, you must either use libtool, and"
6268659607e0Smrg    $echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
6269659607e0Smrg    $echo "flag during linking and do at least one of the following:"
6270659607e0Smrg    if test -n "$shlibpath_var"; then
6271659607e0Smrg      $echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
6272659607e0Smrg      $echo "     during execution"
6273659607e0Smrg    fi
6274659607e0Smrg    if test -n "$runpath_var"; then
6275659607e0Smrg      $echo "   - add LIBDIR to the \`$runpath_var' environment variable"
6276659607e0Smrg      $echo "     during linking"
6277659607e0Smrg    fi
6278659607e0Smrg    if test -n "$hardcode_libdir_flag_spec"; then
6279659607e0Smrg      libdir=LIBDIR
6280659607e0Smrg      eval flag=\"$hardcode_libdir_flag_spec\"
6281659607e0Smrg
6282659607e0Smrg      $echo "   - use the \`$flag' linker flag"
6283659607e0Smrg    fi
6284659607e0Smrg    if test -n "$admincmds"; then
6285659607e0Smrg      $echo "   - have your system administrator run these commands:$admincmds"
6286659607e0Smrg    fi
6287659607e0Smrg    if test -f /etc/ld.so.conf; then
6288659607e0Smrg      $echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
6289659607e0Smrg    fi
6290659607e0Smrg    $echo
6291659607e0Smrg    $echo "See any operating system documentation about shared libraries for"
6292659607e0Smrg    $echo "more information, such as the ld(1) and ld.so(8) manual pages."
6293659607e0Smrg    $echo "X----------------------------------------------------------------------" | $Xsed
6294659607e0Smrg    exit $EXIT_SUCCESS
6295659607e0Smrg    ;;
6296659607e0Smrg
6297659607e0Smrg  # libtool execute mode
6298659607e0Smrg  execute)
6299659607e0Smrg    modename="$modename: execute"
6300659607e0Smrg
6301659607e0Smrg    # The first argument is the command name.
6302659607e0Smrg    cmd="$nonopt"
6303659607e0Smrg    if test -z "$cmd"; then
6304659607e0Smrg      $echo "$modename: you must specify a COMMAND" 1>&2
6305659607e0Smrg      $echo "$help"
6306659607e0Smrg      exit $EXIT_FAILURE
6307659607e0Smrg    fi
6308659607e0Smrg
6309659607e0Smrg    # Handle -dlopen flags immediately.
6310659607e0Smrg    for file in $execute_dlfiles; do
6311659607e0Smrg      if test ! -f "$file"; then
6312659607e0Smrg	$echo "$modename: \`$file' is not a file" 1>&2
6313659607e0Smrg	$echo "$help" 1>&2
6314659607e0Smrg	exit $EXIT_FAILURE
6315659607e0Smrg      fi
6316659607e0Smrg
6317659607e0Smrg      dir=
6318659607e0Smrg      case $file in
6319659607e0Smrg      *.la)
6320659607e0Smrg	# Check to see that this really is a libtool archive.
6321659607e0Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
6322659607e0Smrg	else
6323659607e0Smrg	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
6324659607e0Smrg	  $echo "$help" 1>&2
6325659607e0Smrg	  exit $EXIT_FAILURE
6326659607e0Smrg	fi
6327659607e0Smrg
6328659607e0Smrg	# Read the libtool library.
6329659607e0Smrg	dlname=
6330659607e0Smrg	library_names=
6331659607e0Smrg
6332659607e0Smrg	# If there is no directory component, then add one.
6333659607e0Smrg	case $file in
6334659607e0Smrg	*/* | *\\*) . $file ;;
6335659607e0Smrg	*) . ./$file ;;
6336659607e0Smrg	esac
6337659607e0Smrg
6338659607e0Smrg	# Skip this library if it cannot be dlopened.
6339659607e0Smrg	if test -z "$dlname"; then
6340659607e0Smrg	  # Warn if it was a shared library.
6341659607e0Smrg	  test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
6342659607e0Smrg	  continue
6343659607e0Smrg	fi
6344659607e0Smrg
6345659607e0Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
6346659607e0Smrg	test "X$dir" = "X$file" && dir=.
6347659607e0Smrg
6348659607e0Smrg	if test -f "$dir/$objdir/$dlname"; then
6349659607e0Smrg	  dir="$dir/$objdir"
6350659607e0Smrg	else
63516aab59a7Smrg	  $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
63526aab59a7Smrg	  exit $EXIT_FAILURE
6353659607e0Smrg	fi
6354659607e0Smrg	;;
6355659607e0Smrg
6356659607e0Smrg      *.lo)
6357659607e0Smrg	# Just add the directory containing the .lo file.
6358659607e0Smrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
6359659607e0Smrg	test "X$dir" = "X$file" && dir=.
6360659607e0Smrg	;;
6361659607e0Smrg
6362659607e0Smrg      *)
6363659607e0Smrg	$echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
6364659607e0Smrg	continue
6365659607e0Smrg	;;
6366659607e0Smrg      esac
6367659607e0Smrg
6368659607e0Smrg      # Get the absolute pathname.
6369659607e0Smrg      absdir=`cd "$dir" && pwd`
6370659607e0Smrg      test -n "$absdir" && dir="$absdir"
6371659607e0Smrg
6372659607e0Smrg      # Now add the directory to shlibpath_var.
6373659607e0Smrg      if eval "test -z \"\$$shlibpath_var\""; then
6374659607e0Smrg	eval "$shlibpath_var=\"\$dir\""
6375659607e0Smrg      else
6376659607e0Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
6377659607e0Smrg      fi
6378659607e0Smrg    done
6379659607e0Smrg
6380659607e0Smrg    # This variable tells wrapper scripts just to set shlibpath_var
6381659607e0Smrg    # rather than running their programs.
6382659607e0Smrg    libtool_execute_magic="$magic"
6383659607e0Smrg
6384659607e0Smrg    # Check if any of the arguments is a wrapper script.
6385659607e0Smrg    args=
6386659607e0Smrg    for file
6387659607e0Smrg    do
6388659607e0Smrg      case $file in
6389659607e0Smrg      -*) ;;
6390659607e0Smrg      *)
6391659607e0Smrg	# Do a test to see if this is really a libtool program.
6392659607e0Smrg	if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
6393659607e0Smrg	  # If there is no directory component, then add one.
6394659607e0Smrg	  case $file in
6395659607e0Smrg	  */* | *\\*) . $file ;;
6396659607e0Smrg	  *) . ./$file ;;
6397659607e0Smrg	  esac
6398659607e0Smrg
6399659607e0Smrg	  # Transform arg to wrapped name.
6400659607e0Smrg	  file="$progdir/$program"
6401659607e0Smrg	fi
6402659607e0Smrg	;;
6403659607e0Smrg      esac
6404659607e0Smrg      # Quote arguments (to preserve shell metacharacters).
6405659607e0Smrg      file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
6406659607e0Smrg      args="$args \"$file\""
6407659607e0Smrg    done
6408659607e0Smrg
6409659607e0Smrg    if test -z "$run"; then
6410659607e0Smrg      if test -n "$shlibpath_var"; then
6411659607e0Smrg	# Export the shlibpath_var.
6412659607e0Smrg	eval "export $shlibpath_var"
6413659607e0Smrg      fi
6414659607e0Smrg
6415659607e0Smrg      # Restore saved environment variables
64166aab59a7Smrg      if test "${save_LC_ALL+set}" = set; then
64176aab59a7Smrg	LC_ALL="$save_LC_ALL"; export LC_ALL
64186aab59a7Smrg      fi
64196aab59a7Smrg      if test "${save_LANG+set}" = set; then
64206aab59a7Smrg	LANG="$save_LANG"; export LANG
64216aab59a7Smrg      fi
6422659607e0Smrg
6423659607e0Smrg      # Now prepare to actually exec the command.
6424659607e0Smrg      exec_cmd="\$cmd$args"
6425659607e0Smrg    else
6426659607e0Smrg      # Display what would be done.
6427659607e0Smrg      if test -n "$shlibpath_var"; then
6428659607e0Smrg	eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
6429659607e0Smrg	$echo "export $shlibpath_var"
6430659607e0Smrg      fi
6431659607e0Smrg      $echo "$cmd$args"
6432659607e0Smrg      exit $EXIT_SUCCESS
6433659607e0Smrg    fi
6434659607e0Smrg    ;;
6435659607e0Smrg
6436659607e0Smrg  # libtool clean and uninstall mode
6437659607e0Smrg  clean | uninstall)
6438659607e0Smrg    modename="$modename: $mode"
6439659607e0Smrg    rm="$nonopt"
6440659607e0Smrg    files=
6441659607e0Smrg    rmforce=
6442659607e0Smrg    exit_status=0
6443659607e0Smrg
6444659607e0Smrg    # This variable tells wrapper scripts just to set variables rather
6445659607e0Smrg    # than running their programs.
6446659607e0Smrg    libtool_install_magic="$magic"
6447659607e0Smrg
6448659607e0Smrg    for arg
6449659607e0Smrg    do
6450659607e0Smrg      case $arg in
6451659607e0Smrg      -f) rm="$rm $arg"; rmforce=yes ;;
6452659607e0Smrg      -*) rm="$rm $arg" ;;
6453659607e0Smrg      *) files="$files $arg" ;;
6454659607e0Smrg      esac
6455659607e0Smrg    done
6456659607e0Smrg
6457659607e0Smrg    if test -z "$rm"; then
6458659607e0Smrg      $echo "$modename: you must specify an RM program" 1>&2
6459659607e0Smrg      $echo "$help" 1>&2
6460659607e0Smrg      exit $EXIT_FAILURE
6461659607e0Smrg    fi
6462659607e0Smrg
6463659607e0Smrg    rmdirs=
6464659607e0Smrg
6465659607e0Smrg    origobjdir="$objdir"
6466659607e0Smrg    for file in $files; do
6467659607e0Smrg      dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
6468659607e0Smrg      if test "X$dir" = "X$file"; then
6469659607e0Smrg	dir=.
6470659607e0Smrg	objdir="$origobjdir"
6471659607e0Smrg      else
6472659607e0Smrg	objdir="$dir/$origobjdir"
6473659607e0Smrg      fi
6474659607e0Smrg      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
6475659607e0Smrg      test "$mode" = uninstall && objdir="$dir"
6476659607e0Smrg
6477659607e0Smrg      # Remember objdir for removal later, being careful to avoid duplicates
6478659607e0Smrg      if test "$mode" = clean; then
6479659607e0Smrg	case " $rmdirs " in
6480659607e0Smrg	  *" $objdir "*) ;;
6481659607e0Smrg	  *) rmdirs="$rmdirs $objdir" ;;
6482659607e0Smrg	esac
6483659607e0Smrg      fi
6484659607e0Smrg
6485659607e0Smrg      # Don't error if the file doesn't exist and rm -f was used.
6486659607e0Smrg      if (test -L "$file") >/dev/null 2>&1 \
6487659607e0Smrg	|| (test -h "$file") >/dev/null 2>&1 \
6488659607e0Smrg	|| test -f "$file"; then
6489659607e0Smrg	:
6490659607e0Smrg      elif test -d "$file"; then
6491659607e0Smrg	exit_status=1
6492659607e0Smrg	continue
6493659607e0Smrg      elif test "$rmforce" = yes; then
6494659607e0Smrg	continue
6495659607e0Smrg      fi
6496659607e0Smrg
6497659607e0Smrg      rmfiles="$file"
6498659607e0Smrg
6499659607e0Smrg      case $name in
6500659607e0Smrg      *.la)
6501659607e0Smrg	# Possibly a libtool archive, so verify it.
6502659607e0Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
6503659607e0Smrg	  . $dir/$name
6504659607e0Smrg
6505659607e0Smrg	  # Delete the libtool libraries and symlinks.
6506659607e0Smrg	  for n in $library_names; do
6507659607e0Smrg	    rmfiles="$rmfiles $objdir/$n"
6508659607e0Smrg	  done
6509659607e0Smrg	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
6510659607e0Smrg
6511659607e0Smrg	  case "$mode" in
6512659607e0Smrg	  clean)
6513659607e0Smrg	    case "  $library_names " in
6514659607e0Smrg	    # "  " in the beginning catches empty $dlname
6515659607e0Smrg	    *" $dlname "*) ;;
6516659607e0Smrg	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
6517659607e0Smrg	    esac
6518659607e0Smrg	     test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
6519659607e0Smrg	    ;;
6520659607e0Smrg	  uninstall)
6521659607e0Smrg	    if test -n "$library_names"; then
6522659607e0Smrg	      # Do each command in the postuninstall commands.
6523659607e0Smrg	      cmds=$postuninstall_cmds
6524659607e0Smrg	      save_ifs="$IFS"; IFS='~'
6525659607e0Smrg	      for cmd in $cmds; do
6526659607e0Smrg		IFS="$save_ifs"
6527659607e0Smrg		eval cmd=\"$cmd\"
6528659607e0Smrg		$show "$cmd"
6529659607e0Smrg		$run eval "$cmd"
6530659607e0Smrg		if test "$?" -ne 0 && test "$rmforce" != yes; then
6531659607e0Smrg		  exit_status=1
6532659607e0Smrg		fi
6533659607e0Smrg	      done
6534659607e0Smrg	      IFS="$save_ifs"
6535659607e0Smrg	    fi
6536659607e0Smrg
6537659607e0Smrg	    if test -n "$old_library"; then
6538659607e0Smrg	      # Do each command in the old_postuninstall commands.
6539659607e0Smrg	      cmds=$old_postuninstall_cmds
6540659607e0Smrg	      save_ifs="$IFS"; IFS='~'
6541659607e0Smrg	      for cmd in $cmds; do
6542659607e0Smrg		IFS="$save_ifs"
6543659607e0Smrg		eval cmd=\"$cmd\"
6544659607e0Smrg		$show "$cmd"
6545659607e0Smrg		$run eval "$cmd"
6546659607e0Smrg		if test "$?" -ne 0 && test "$rmforce" != yes; then
6547659607e0Smrg		  exit_status=1
6548659607e0Smrg		fi
6549659607e0Smrg	      done
6550659607e0Smrg	      IFS="$save_ifs"
6551659607e0Smrg	    fi
6552659607e0Smrg	    # FIXME: should reinstall the best remaining shared library.
6553659607e0Smrg	    ;;
6554659607e0Smrg	  esac
6555659607e0Smrg	fi
6556659607e0Smrg	;;
6557659607e0Smrg
6558659607e0Smrg      *.lo)
6559659607e0Smrg	# Possibly a libtool object, so verify it.
6560659607e0Smrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
6561659607e0Smrg
6562659607e0Smrg	  # Read the .lo file
6563659607e0Smrg	  . $dir/$name
6564659607e0Smrg
6565659607e0Smrg	  # Add PIC object to the list of files to remove.
6566659607e0Smrg	  if test -n "$pic_object" \
6567659607e0Smrg	     && test "$pic_object" != none; then
6568659607e0Smrg	    rmfiles="$rmfiles $dir/$pic_object"
6569659607e0Smrg	  fi
6570659607e0Smrg
6571659607e0Smrg	  # Add non-PIC object to the list of files to remove.
6572659607e0Smrg	  if test -n "$non_pic_object" \
6573659607e0Smrg	     && test "$non_pic_object" != none; then
6574659607e0Smrg	    rmfiles="$rmfiles $dir/$non_pic_object"
6575659607e0Smrg	  fi
6576659607e0Smrg	fi
6577659607e0Smrg	;;
6578659607e0Smrg
6579659607e0Smrg      *)
6580659607e0Smrg	if test "$mode" = clean ; then
6581659607e0Smrg	  noexename=$name
6582659607e0Smrg	  case $file in
6583659607e0Smrg	  *.exe)
6584659607e0Smrg	    file=`$echo $file|${SED} 's,.exe$,,'`
6585659607e0Smrg	    noexename=`$echo $name|${SED} 's,.exe$,,'`
6586659607e0Smrg	    # $file with .exe has already been added to rmfiles,
6587659607e0Smrg	    # add $file without .exe
6588659607e0Smrg	    rmfiles="$rmfiles $file"
6589659607e0Smrg	    ;;
6590659607e0Smrg	  esac
6591659607e0Smrg	  # Do a test to see if this is a libtool program.
6592659607e0Smrg	  if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
6593659607e0Smrg	    relink_command=
6594659607e0Smrg	    . $dir/$noexename
6595659607e0Smrg
6596659607e0Smrg	    # note $name still contains .exe if it was in $file originally
6597659607e0Smrg	    # as does the version of $file that was added into $rmfiles
6598659607e0Smrg	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
6599659607e0Smrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
6600659607e0Smrg	      rmfiles="$rmfiles $objdir/lt-$name"
6601659607e0Smrg	    fi
6602659607e0Smrg	    if test "X$noexename" != "X$name" ; then
6603659607e0Smrg	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
6604659607e0Smrg	    fi
6605659607e0Smrg	  fi
6606659607e0Smrg	fi
6607659607e0Smrg	;;
6608659607e0Smrg      esac
6609659607e0Smrg      $show "$rm $rmfiles"
6610659607e0Smrg      $run $rm $rmfiles || exit_status=1
6611659607e0Smrg    done
6612659607e0Smrg    objdir="$origobjdir"
6613659607e0Smrg
6614659607e0Smrg    # Try to remove the ${objdir}s in the directories where we deleted files
6615659607e0Smrg    for dir in $rmdirs; do
6616659607e0Smrg      if test -d "$dir"; then
6617659607e0Smrg	$show "rmdir $dir"
6618659607e0Smrg	$run rmdir $dir >/dev/null 2>&1
6619659607e0Smrg      fi
6620659607e0Smrg    done
6621659607e0Smrg
6622659607e0Smrg    exit $exit_status
6623659607e0Smrg    ;;
6624659607e0Smrg
6625659607e0Smrg  "")
6626659607e0Smrg    $echo "$modename: you must specify a MODE" 1>&2
6627659607e0Smrg    $echo "$generic_help" 1>&2
6628659607e0Smrg    exit $EXIT_FAILURE
6629659607e0Smrg    ;;
6630659607e0Smrg  esac
6631659607e0Smrg
6632659607e0Smrg  if test -z "$exec_cmd"; then
6633659607e0Smrg    $echo "$modename: invalid operation mode \`$mode'" 1>&2
6634659607e0Smrg    $echo "$generic_help" 1>&2
6635659607e0Smrg    exit $EXIT_FAILURE
6636659607e0Smrg  fi
6637659607e0Smrgfi # test -z "$show_help"
6638659607e0Smrg
6639659607e0Smrgif test -n "$exec_cmd"; then
6640659607e0Smrg  eval exec $exec_cmd
6641659607e0Smrg  exit $EXIT_FAILURE
6642659607e0Smrgfi
6643659607e0Smrg
6644659607e0Smrg# We need to display help for each of the modes.
6645659607e0Smrgcase $mode in
6646659607e0Smrg"") $echo \
6647659607e0Smrg"Usage: $modename [OPTION]... [MODE-ARG]...
6648659607e0Smrg
6649659607e0SmrgProvide generalized library-building support services.
6650659607e0Smrg
6651659607e0Smrg    --config          show all configuration variables
6652659607e0Smrg    --debug           enable verbose shell tracing
6653659607e0Smrg-n, --dry-run         display commands without modifying any files
6654659607e0Smrg    --features        display basic configuration information and exit
6655659607e0Smrg    --finish          same as \`--mode=finish'
6656659607e0Smrg    --help            display this help message and exit
6657659607e0Smrg    --mode=MODE       use operation mode MODE [default=inferred from MODE-ARGS]
6658659607e0Smrg    --quiet           same as \`--silent'
6659659607e0Smrg    --silent          don't print informational messages
6660659607e0Smrg    --tag=TAG         use configuration variables from tag TAG
6661659607e0Smrg    --version         print version information
6662659607e0Smrg
6663659607e0SmrgMODE must be one of the following:
6664659607e0Smrg
6665659607e0Smrg      clean           remove files from the build directory
6666659607e0Smrg      compile         compile a source file into a libtool object
6667659607e0Smrg      execute         automatically set library path, then run a program
6668659607e0Smrg      finish          complete the installation of libtool libraries
6669659607e0Smrg      install         install libraries or executables
6670659607e0Smrg      link            create a library or an executable
6671659607e0Smrg      uninstall       remove libraries from an installed directory
6672659607e0Smrg
6673659607e0SmrgMODE-ARGS vary depending on the MODE.  Try \`$modename --help --mode=MODE' for
6674659607e0Smrga more detailed description of MODE.
6675659607e0Smrg
6676659607e0SmrgReport bugs to <bug-libtool@gnu.org>."
6677659607e0Smrg  exit $EXIT_SUCCESS
6678659607e0Smrg  ;;
6679659607e0Smrg
6680659607e0Smrgclean)
6681659607e0Smrg  $echo \
6682659607e0Smrg"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
6683659607e0Smrg
6684659607e0SmrgRemove files from the build directory.
6685659607e0Smrg
6686659607e0SmrgRM is the name of the program to use to delete files associated with each FILE
6687659607e0Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
6688659607e0Smrgto RM.
6689659607e0Smrg
6690659607e0SmrgIf FILE is a libtool library, object or program, all the files associated
6691659607e0Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
6692659607e0Smrg  ;;
6693659607e0Smrg
6694659607e0Smrgcompile)
6695659607e0Smrg  $echo \
6696659607e0Smrg"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
6697659607e0Smrg
6698659607e0SmrgCompile a source file into a libtool library object.
6699659607e0Smrg
6700659607e0SmrgThis mode accepts the following additional options:
6701659607e0Smrg
6702659607e0Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
6703659607e0Smrg  -prefer-pic       try to building PIC objects only
6704659607e0Smrg  -prefer-non-pic   try to building non-PIC objects only
6705659607e0Smrg  -static           always build a \`.o' file suitable for static linking
6706659607e0Smrg
6707659607e0SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
6708659607e0Smrgfrom the given SOURCEFILE.
6709659607e0Smrg
6710659607e0SmrgThe output file name is determined by removing the directory component from
6711659607e0SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
6712659607e0Smrglibrary object suffix, \`.lo'."
6713659607e0Smrg  ;;
6714659607e0Smrg
6715659607e0Smrgexecute)
6716659607e0Smrg  $echo \
6717659607e0Smrg"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
6718659607e0Smrg
6719659607e0SmrgAutomatically set library path, then run a program.
6720659607e0Smrg
6721659607e0SmrgThis mode accepts the following additional options:
6722659607e0Smrg
6723659607e0Smrg  -dlopen FILE      add the directory containing FILE to the library path
6724659607e0Smrg
6725659607e0SmrgThis mode sets the library path environment variable according to \`-dlopen'
6726659607e0Smrgflags.
6727659607e0Smrg
6728659607e0SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
6729659607e0Smrginto their corresponding uninstalled binary, and any of their required library
6730659607e0Smrgdirectories are added to the library path.
6731659607e0Smrg
6732659607e0SmrgThen, COMMAND is executed, with ARGS as arguments."
6733659607e0Smrg  ;;
6734659607e0Smrg
6735659607e0Smrgfinish)
6736659607e0Smrg  $echo \
6737659607e0Smrg"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
6738659607e0Smrg
6739659607e0SmrgComplete the installation of libtool libraries.
6740659607e0Smrg
6741659607e0SmrgEach LIBDIR is a directory that contains libtool libraries.
6742659607e0Smrg
6743659607e0SmrgThe commands that this mode executes may require superuser privileges.  Use
6744659607e0Smrgthe \`--dry-run' option if you just want to see what would be executed."
6745659607e0Smrg  ;;
6746659607e0Smrg
6747659607e0Smrginstall)
6748659607e0Smrg  $echo \
6749659607e0Smrg"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
6750659607e0Smrg
6751659607e0SmrgInstall executables or libraries.
6752659607e0Smrg
6753659607e0SmrgINSTALL-COMMAND is the installation command.  The first component should be
6754659607e0Smrgeither the \`install' or \`cp' program.
6755659607e0Smrg
6756659607e0SmrgThe rest of the components are interpreted as arguments to that command (only
6757659607e0SmrgBSD-compatible install options are recognized)."
6758659607e0Smrg  ;;
6759659607e0Smrg
6760659607e0Smrglink)
6761659607e0Smrg  $echo \
6762659607e0Smrg"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
6763659607e0Smrg
6764659607e0SmrgLink object files or libraries together to form another library, or to
6765659607e0Smrgcreate an executable program.
6766659607e0Smrg
6767659607e0SmrgLINK-COMMAND is a command using the C compiler that you would use to create
6768659607e0Smrga program from several object files.
6769659607e0Smrg
6770659607e0SmrgThe following components of LINK-COMMAND are treated specially:
6771659607e0Smrg
6772659607e0Smrg  -all-static       do not do any dynamic linking at all
6773659607e0Smrg  -avoid-version    do not add a version suffix if possible
6774659607e0Smrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
6775659607e0Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
6776659607e0Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
6777659607e0Smrg  -export-symbols SYMFILE
67786aab59a7Smrg		    try to export only the symbols listed in SYMFILE
6779659607e0Smrg  -export-symbols-regex REGEX
67806aab59a7Smrg		    try to export only the symbols matching REGEX
6781659607e0Smrg  -LLIBDIR          search LIBDIR for required installed libraries
6782659607e0Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
6783659607e0Smrg  -module           build a library that can dlopened
6784659607e0Smrg  -no-fast-install  disable the fast-install mode
6785659607e0Smrg  -no-install       link a not-installable executable
6786659607e0Smrg  -no-undefined     declare that a library does not refer to external symbols
6787659607e0Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
6788659607e0Smrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
6789659607e0Smrg  -precious-files-regex REGEX
6790659607e0Smrg                    don't remove output files matching REGEX
6791659607e0Smrg  -release RELEASE  specify package release information
6792659607e0Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
6793659607e0Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
67946aab59a7Smrg  -static           do not do any dynamic linking of libtool libraries
6795659607e0Smrg  -version-info CURRENT[:REVISION[:AGE]]
67966aab59a7Smrg		    specify library version info [each variable defaults to 0]
6797659607e0Smrg
6798659607e0SmrgAll other options (arguments beginning with \`-') are ignored.
6799659607e0Smrg
6800659607e0SmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
6801659607e0Smrgtreated as uninstalled libtool libraries, other files are standard or library
6802659607e0Smrgobject files.
6803659607e0Smrg
6804659607e0SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
6805659607e0Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
6806659607e0Smrgrequired, except when creating a convenience library.
6807659607e0Smrg
6808659607e0SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
6809659607e0Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
6810659607e0Smrg
6811659607e0SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
6812659607e0Smrgis created, otherwise an executable program is created."
6813659607e0Smrg  ;;
6814659607e0Smrg
6815659607e0Smrguninstall)
6816659607e0Smrg  $echo \
6817659607e0Smrg"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
6818659607e0Smrg
6819659607e0SmrgRemove libraries from an installation directory.
6820659607e0Smrg
6821659607e0SmrgRM is the name of the program to use to delete files associated with each FILE
6822659607e0Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
6823659607e0Smrgto RM.
6824659607e0Smrg
6825659607e0SmrgIf FILE is a libtool library, all the files associated with it are deleted.
6826659607e0SmrgOtherwise, only FILE itself is deleted using RM."
6827659607e0Smrg  ;;
6828659607e0Smrg
6829659607e0Smrg*)
6830659607e0Smrg  $echo "$modename: invalid operation mode \`$mode'" 1>&2
6831659607e0Smrg  $echo "$help" 1>&2
6832659607e0Smrg  exit $EXIT_FAILURE
6833659607e0Smrg  ;;
6834659607e0Smrgesac
6835659607e0Smrg
6836659607e0Smrg$echo
6837659607e0Smrg$echo "Try \`$modename --help' for more information about other modes."
6838659607e0Smrg
6839659607e0Smrgexit $?
6840659607e0Smrg
6841659607e0Smrg# The TAGs below are defined such that we never get into a situation
6842659607e0Smrg# in which we disable both kinds of libraries.  Given conflicting
6843659607e0Smrg# choices, we go for a static library, that is the most portable,
6844659607e0Smrg# since we can't tell whether shared libraries were disabled because
6845659607e0Smrg# the user asked for that or because the platform doesn't support
6846659607e0Smrg# them.  This is particularly important on AIX, because we don't
6847659607e0Smrg# support having both static and shared libraries enabled at the same
6848659607e0Smrg# time on that platform, so we default to a shared-only configuration.
6849659607e0Smrg# If a disable-shared tag is given, we'll fallback to a static-only
6850659607e0Smrg# configuration.  But we'll never go from static-only to shared-only.
6851659607e0Smrg
6852659607e0Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
6853659607e0Smrgdisable_libs=shared
6854659607e0Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
6855659607e0Smrg
6856659607e0Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
6857659607e0Smrgdisable_libs=static
6858659607e0Smrg# ### END LIBTOOL TAG CONFIG: disable-static
6859659607e0Smrg
6860659607e0Smrg# Local Variables:
6861659607e0Smrg# mode:shell-script
6862659607e0Smrg# sh-indentation:2
6863659607e0Smrg# End:
6864