1382ff0afSmrg# ltmain.sh - Provide generalized library-building support services.
2382ff0afSmrg# NOTE: Changing this file will not affect anything until you rerun configure.
3382ff0afSmrg#
4382ff0afSmrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
5382ff0afSmrg# Free Software Foundation, Inc.
6382ff0afSmrg# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
7382ff0afSmrg#
8382ff0afSmrg# This program is free software; you can redistribute it and/or modify
9382ff0afSmrg# it under the terms of the GNU General Public License as published by
10382ff0afSmrg# the Free Software Foundation; either version 2 of the License, or
11382ff0afSmrg# (at your option) any later version.
12382ff0afSmrg#
13382ff0afSmrg# This program is distributed in the hope that it will be useful, but
14382ff0afSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
15382ff0afSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16382ff0afSmrg# General Public License for more details.
17382ff0afSmrg#
18382ff0afSmrg# You should have received a copy of the GNU General Public License
19382ff0afSmrg# along with this program; if not, write to the Free Software
20382ff0afSmrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21382ff0afSmrg#
22382ff0afSmrg# As a special exception to the GNU General Public License, if you
23382ff0afSmrg# distribute this file as part of a program that contains a
24382ff0afSmrg# configuration script generated by Autoconf, you may include it under
25382ff0afSmrg# the same distribution terms that you use for the rest of that program.
26382ff0afSmrg
27382ff0afSmrgbasename="s,^.*/,,g"
28382ff0afSmrg
29382ff0afSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
30382ff0afSmrg# is ksh but when the shell is invoked as "sh" and the current value of
31382ff0afSmrg# the _XPG environment variable is not equal to 1 (one), the special
32382ff0afSmrg# positional parameter $0, within a function call, is the name of the
33382ff0afSmrg# function.
34382ff0afSmrgprogpath="$0"
35382ff0afSmrg
36382ff0afSmrg# The name of this program:
37382ff0afSmrgprogname=`echo "$progpath" | $SED $basename`
38382ff0afSmrgmodename="$progname"
39382ff0afSmrg
40382ff0afSmrg# Global variables:
41382ff0afSmrgEXIT_SUCCESS=0
42382ff0afSmrgEXIT_FAILURE=1
43382ff0afSmrg
44382ff0afSmrgPROGRAM=ltmain.sh
45382ff0afSmrgPACKAGE=libtool
46382ff0afSmrgVERSION=1.5.22
47382ff0afSmrgTIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)"
48382ff0afSmrg
49382ff0afSmrg# See if we are running on zsh, and set the options which allow our
50382ff0afSmrg# commands through without removal of \ escapes.
51382ff0afSmrgif test -n "${ZSH_VERSION+set}" ; then
52382ff0afSmrg  setopt NO_GLOB_SUBST
53382ff0afSmrgfi
54382ff0afSmrg
55382ff0afSmrg# Check that we have a working $echo.
56382ff0afSmrgif test "X$1" = X--no-reexec; then
57382ff0afSmrg  # Discard the --no-reexec flag, and continue.
58382ff0afSmrg  shift
59382ff0afSmrgelif test "X$1" = X--fallback-echo; then
60382ff0afSmrg  # Avoid inline document here, it may be left over
61382ff0afSmrg  :
62382ff0afSmrgelif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
63382ff0afSmrg  # Yippee, $echo works!
64382ff0afSmrg  :
65382ff0afSmrgelse
66382ff0afSmrg  # Restart under the correct shell, and then maybe $echo will work.
67382ff0afSmrg  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
68382ff0afSmrgfi
69382ff0afSmrg
70382ff0afSmrgif test "X$1" = X--fallback-echo; then
71382ff0afSmrg  # used as fallback echo
72382ff0afSmrg  shift
73382ff0afSmrg  cat <<EOF
74382ff0afSmrg$*
75382ff0afSmrgEOF
76382ff0afSmrg  exit $EXIT_SUCCESS
77382ff0afSmrgfi
78382ff0afSmrg
79382ff0afSmrgdefault_mode=
80382ff0afSmrghelp="Try \`$progname --help' for more information."
81382ff0afSmrgmagic="%%%MAGIC variable%%%"
82382ff0afSmrgmkdir="mkdir"
83382ff0afSmrgmv="mv -f"
84382ff0afSmrgrm="rm -f"
85382ff0afSmrg
86382ff0afSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
87382ff0afSmrg# metacharacters that are still active within double-quoted strings.
88382ff0afSmrgXsed="${SED}"' -e 1s/^X//'
89382ff0afSmrgsed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
90382ff0afSmrg# test EBCDIC or ASCII
91382ff0afSmrgcase `echo X|tr X '\101'` in
92382ff0afSmrg A) # ASCII based system
93382ff0afSmrg    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
94382ff0afSmrg  SP2NL='tr \040 \012'
95382ff0afSmrg  NL2SP='tr \015\012 \040\040'
96382ff0afSmrg  ;;
97382ff0afSmrg *) # EBCDIC based system
98382ff0afSmrg  SP2NL='tr \100 \n'
99382ff0afSmrg  NL2SP='tr \r\n \100\100'
100382ff0afSmrg  ;;
101382ff0afSmrgesac
102382ff0afSmrg
103382ff0afSmrg# NLS nuisances.
104382ff0afSmrg# Only set LANG and LC_ALL to C if already set.
105382ff0afSmrg# These must not be set unconditionally because not all systems understand
106382ff0afSmrg# e.g. LANG=C (notably SCO).
107382ff0afSmrg# We save the old values to restore during execute mode.
108382ff0afSmrgif test "${LC_ALL+set}" = set; then
109382ff0afSmrg  save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
110382ff0afSmrgfi
111382ff0afSmrgif test "${LANG+set}" = set; then
112382ff0afSmrg  save_LANG="$LANG"; LANG=C; export LANG
113382ff0afSmrgfi
114382ff0afSmrg
115382ff0afSmrg# Make sure IFS has a sensible default
116382ff0afSmrglt_nl='
117382ff0afSmrg'
118382ff0afSmrgIFS=" 	$lt_nl"
119382ff0afSmrg
120382ff0afSmrgif test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
121382ff0afSmrg  $echo "$modename: not configured to build any kind of library" 1>&2
122382ff0afSmrg  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
123382ff0afSmrg  exit $EXIT_FAILURE
124382ff0afSmrgfi
125382ff0afSmrg
126382ff0afSmrg# Global variables.
127382ff0afSmrgmode=$default_mode
128382ff0afSmrgnonopt=
129382ff0afSmrgprev=
130382ff0afSmrgprevopt=
131382ff0afSmrgrun=
132382ff0afSmrgshow="$echo"
133382ff0afSmrgshow_help=
134382ff0afSmrgexecute_dlfiles=
135382ff0afSmrgduplicate_deps=no
136382ff0afSmrgpreserve_args=
137382ff0afSmrglo2o="s/\\.lo\$/.${objext}/"
138382ff0afSmrgo2lo="s/\\.${objext}\$/.lo/"
139382ff0afSmrg
140382ff0afSmrg#####################################
141382ff0afSmrg# Shell function definitions:
142382ff0afSmrg# This seems to be the best place for them
143382ff0afSmrg
144382ff0afSmrg# func_mktempdir [string]
145382ff0afSmrg# Make a temporary directory that won't clash with other running
146382ff0afSmrg# libtool processes, and avoids race conditions if possible.  If
147382ff0afSmrg# given, STRING is the basename for that directory.
148382ff0afSmrgfunc_mktempdir ()
149382ff0afSmrg{
150382ff0afSmrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
151382ff0afSmrg
152382ff0afSmrg    if test "$run" = ":"; then
153382ff0afSmrg      # Return a directory name, but don't create it in dry-run mode
154382ff0afSmrg      my_tmpdir="${my_template}-$$"
155382ff0afSmrg    else
156382ff0afSmrg
157382ff0afSmrg      # If mktemp works, use that first and foremost
158382ff0afSmrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
159382ff0afSmrg
160382ff0afSmrg      if test ! -d "$my_tmpdir"; then
161382ff0afSmrg	# Failing that, at least try and use $RANDOM to avoid a race
162382ff0afSmrg	my_tmpdir="${my_template}-${RANDOM-0}$$"
163382ff0afSmrg
164382ff0afSmrg	save_mktempdir_umask=`umask`
165382ff0afSmrg	umask 0077
166382ff0afSmrg	$mkdir "$my_tmpdir"
167382ff0afSmrg	umask $save_mktempdir_umask
168382ff0afSmrg      fi
169382ff0afSmrg
170382ff0afSmrg      # If we're not in dry-run mode, bomb out on failure
171382ff0afSmrg      test -d "$my_tmpdir" || {
172382ff0afSmrg        $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
173382ff0afSmrg	exit $EXIT_FAILURE
174382ff0afSmrg      }
175382ff0afSmrg    fi
176382ff0afSmrg
177382ff0afSmrg    $echo "X$my_tmpdir" | $Xsed
178382ff0afSmrg}
179382ff0afSmrg
180382ff0afSmrg
181382ff0afSmrg# func_win32_libid arg
182382ff0afSmrg# return the library type of file 'arg'
183382ff0afSmrg#
184382ff0afSmrg# Need a lot of goo to handle *both* DLLs and import libs
185382ff0afSmrg# Has to be a shell function in order to 'eat' the argument
186382ff0afSmrg# that is supplied when $file_magic_command is called.
187382ff0afSmrgfunc_win32_libid ()
188382ff0afSmrg{
189382ff0afSmrg  win32_libid_type="unknown"
190382ff0afSmrg  win32_fileres=`file -L $1 2>/dev/null`
191382ff0afSmrg  case $win32_fileres in
192382ff0afSmrg  *ar\ archive\ import\ library*) # definitely import
193382ff0afSmrg    win32_libid_type="x86 archive import"
194382ff0afSmrg    ;;
195382ff0afSmrg  *ar\ archive*) # could be an import, or static
196382ff0afSmrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
197382ff0afSmrg      $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
198382ff0afSmrg      win32_nmres=`eval $NM -f posix -A $1 | \
199382ff0afSmrg	$SED -n -e '1,100{/ I /{s,.*,import,;p;q;};}'`
200382ff0afSmrg      case $win32_nmres in
201382ff0afSmrg      import*)  win32_libid_type="x86 archive import";;
202382ff0afSmrg      *)        win32_libid_type="x86 archive static";;
203382ff0afSmrg      esac
204382ff0afSmrg    fi
205382ff0afSmrg    ;;
206382ff0afSmrg  *DLL*)
207382ff0afSmrg    win32_libid_type="x86 DLL"
208382ff0afSmrg    ;;
209382ff0afSmrg  *executable*) # but shell scripts are "executable" too...
210382ff0afSmrg    case $win32_fileres in
211382ff0afSmrg    *MS\ Windows\ PE\ Intel*)
212382ff0afSmrg      win32_libid_type="x86 DLL"
213382ff0afSmrg      ;;
214382ff0afSmrg    esac
215382ff0afSmrg    ;;
216382ff0afSmrg  esac
217382ff0afSmrg  $echo $win32_libid_type
218382ff0afSmrg}
219382ff0afSmrg
220382ff0afSmrg
221382ff0afSmrg# func_infer_tag arg
222382ff0afSmrg# Infer tagged configuration to use if any are available and
223382ff0afSmrg# if one wasn't chosen via the "--tag" command line option.
224382ff0afSmrg# Only attempt this if the compiler in the base compile
225382ff0afSmrg# command doesn't match the default compiler.
226382ff0afSmrg# arg is usually of the form 'gcc ...'
227382ff0afSmrgfunc_infer_tag ()
228382ff0afSmrg{
229382ff0afSmrg    if test -n "$available_tags" && test -z "$tagname"; then
230382ff0afSmrg      CC_quoted=
231382ff0afSmrg      for arg in $CC; do
232382ff0afSmrg	case $arg in
233382ff0afSmrg	  *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
234382ff0afSmrg	  arg="\"$arg\""
235382ff0afSmrg	  ;;
236382ff0afSmrg	esac
237382ff0afSmrg	CC_quoted="$CC_quoted $arg"
238382ff0afSmrg      done
239382ff0afSmrg      case $@ in
240382ff0afSmrg      # Blanks in the command may have been stripped by the calling shell,
241382ff0afSmrg      # but not from the CC environment variable when configure was run.
242382ff0afSmrg      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
243382ff0afSmrg      # Blanks at the start of $base_compile will cause this to fail
244382ff0afSmrg      # if we don't check for them as well.
245382ff0afSmrg      *)
246382ff0afSmrg	for z in $available_tags; do
247382ff0afSmrg	  if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
248382ff0afSmrg	    # Evaluate the configuration.
249382ff0afSmrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
250382ff0afSmrg	    CC_quoted=
251382ff0afSmrg	    for arg in $CC; do
252382ff0afSmrg	    # Double-quote args containing other shell metacharacters.
253382ff0afSmrg	    case $arg in
254382ff0afSmrg	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
255382ff0afSmrg	      arg="\"$arg\""
256382ff0afSmrg	      ;;
257382ff0afSmrg	    esac
258382ff0afSmrg	    CC_quoted="$CC_quoted $arg"
259382ff0afSmrg	  done
260382ff0afSmrg	    case "$@ " in
261382ff0afSmrg	      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
262382ff0afSmrg	      # The compiler in the base compile command matches
263382ff0afSmrg	      # the one in the tagged configuration.
264382ff0afSmrg	      # Assume this is the tagged configuration we want.
265382ff0afSmrg	      tagname=$z
266382ff0afSmrg	      break
267382ff0afSmrg	      ;;
268382ff0afSmrg	    esac
269382ff0afSmrg	  fi
270382ff0afSmrg	done
271382ff0afSmrg	# If $tagname still isn't set, then no tagged configuration
272382ff0afSmrg	# was found and let the user know that the "--tag" command
273382ff0afSmrg	# line option must be used.
274382ff0afSmrg	if test -z "$tagname"; then
275382ff0afSmrg	  $echo "$modename: unable to infer tagged configuration"
276382ff0afSmrg	  $echo "$modename: specify a tag with \`--tag'" 1>&2
277382ff0afSmrg	  exit $EXIT_FAILURE
278382ff0afSmrg#        else
279382ff0afSmrg#          $echo "$modename: using $tagname tagged configuration"
280382ff0afSmrg	fi
281382ff0afSmrg	;;
282382ff0afSmrg      esac
283382ff0afSmrg    fi
284382ff0afSmrg}
285382ff0afSmrg
286382ff0afSmrg
287382ff0afSmrg# func_extract_an_archive dir oldlib
288382ff0afSmrgfunc_extract_an_archive ()
289382ff0afSmrg{
290382ff0afSmrg    f_ex_an_ar_dir="$1"; shift
291382ff0afSmrg    f_ex_an_ar_oldlib="$1"
292382ff0afSmrg
293382ff0afSmrg    $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
294382ff0afSmrg    $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
295382ff0afSmrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
296382ff0afSmrg     :
297382ff0afSmrg    else
298382ff0afSmrg      $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
299382ff0afSmrg      exit $EXIT_FAILURE
300382ff0afSmrg    fi
301382ff0afSmrg}
302382ff0afSmrg
303382ff0afSmrg# func_extract_archives gentop oldlib ...
304382ff0afSmrgfunc_extract_archives ()
305382ff0afSmrg{
306382ff0afSmrg    my_gentop="$1"; shift
307382ff0afSmrg    my_oldlibs=${1+"$@"}
308382ff0afSmrg    my_oldobjs=""
309382ff0afSmrg    my_xlib=""
310382ff0afSmrg    my_xabs=""
311382ff0afSmrg    my_xdir=""
312382ff0afSmrg    my_status=""
313382ff0afSmrg
314382ff0afSmrg    $show "${rm}r $my_gentop"
315382ff0afSmrg    $run ${rm}r "$my_gentop"
316382ff0afSmrg    $show "$mkdir $my_gentop"
317382ff0afSmrg    $run $mkdir "$my_gentop"
318382ff0afSmrg    my_status=$?
319382ff0afSmrg    if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
320382ff0afSmrg      exit $my_status
321382ff0afSmrg    fi
322382ff0afSmrg
323382ff0afSmrg    for my_xlib in $my_oldlibs; do
324382ff0afSmrg      # Extract the objects.
325382ff0afSmrg      case $my_xlib in
326382ff0afSmrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
327382ff0afSmrg	*) my_xabs=`pwd`"/$my_xlib" ;;
328382ff0afSmrg      esac
329382ff0afSmrg      my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
330382ff0afSmrg      my_xdir="$my_gentop/$my_xlib"
331382ff0afSmrg
332382ff0afSmrg      $show "${rm}r $my_xdir"
333382ff0afSmrg      $run ${rm}r "$my_xdir"
334382ff0afSmrg      $show "$mkdir $my_xdir"
335382ff0afSmrg      $run $mkdir "$my_xdir"
336382ff0afSmrg      exit_status=$?
337382ff0afSmrg      if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
338382ff0afSmrg	exit $exit_status
339382ff0afSmrg      fi
340382ff0afSmrg      case $host in
341382ff0afSmrg      *-darwin*)
342382ff0afSmrg	$show "Extracting $my_xabs"
343382ff0afSmrg	# Do not bother doing anything if just a dry run
344382ff0afSmrg	if test -z "$run"; then
345382ff0afSmrg	  darwin_orig_dir=`pwd`
346382ff0afSmrg	  cd $my_xdir || exit $?
347382ff0afSmrg	  darwin_archive=$my_xabs
348382ff0afSmrg	  darwin_curdir=`pwd`
349382ff0afSmrg	  darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
350382ff0afSmrg	  darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
351382ff0afSmrg	  if test -n "$darwin_arches"; then 
352382ff0afSmrg	    darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
353382ff0afSmrg	    darwin_arch=
354382ff0afSmrg	    $show "$darwin_base_archive has multiple architectures $darwin_arches"
355382ff0afSmrg	    for darwin_arch in  $darwin_arches ; do
356382ff0afSmrg	      mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
357382ff0afSmrg	      lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
358382ff0afSmrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
359382ff0afSmrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
360382ff0afSmrg	      cd "$darwin_curdir"
361382ff0afSmrg	      $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
362382ff0afSmrg	    done # $darwin_arches
363382ff0afSmrg      ## Okay now we have a bunch of thin objects, gotta fatten them up :)
364382ff0afSmrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
365382ff0afSmrg	    darwin_file=
366382ff0afSmrg	    darwin_files=
367382ff0afSmrg	    for darwin_file in $darwin_filelist; do
368382ff0afSmrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
369382ff0afSmrg	      lipo -create -output "$darwin_file" $darwin_files
370382ff0afSmrg	    done # $darwin_filelist
371382ff0afSmrg	    ${rm}r unfat-$$
372382ff0afSmrg	    cd "$darwin_orig_dir"
373382ff0afSmrg	  else
374382ff0afSmrg	    cd "$darwin_orig_dir"
375382ff0afSmrg 	    func_extract_an_archive "$my_xdir" "$my_xabs"
376382ff0afSmrg	  fi # $darwin_arches
377382ff0afSmrg	fi # $run
378382ff0afSmrg	;;
379382ff0afSmrg      *)
380382ff0afSmrg        func_extract_an_archive "$my_xdir" "$my_xabs"
381382ff0afSmrg        ;;
382382ff0afSmrg      esac
383382ff0afSmrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
384382ff0afSmrg    done
385382ff0afSmrg    func_extract_archives_result="$my_oldobjs"
386382ff0afSmrg}
387382ff0afSmrg# End of Shell function definitions
388382ff0afSmrg#####################################
389382ff0afSmrg
390382ff0afSmrg# Darwin sucks
391382ff0afSmrgeval std_shrext=\"$shrext_cmds\"
392382ff0afSmrg
393382ff0afSmrgdisable_libs=no
394382ff0afSmrg
395382ff0afSmrg# Parse our command line options once, thoroughly.
396382ff0afSmrgwhile test "$#" -gt 0
397382ff0afSmrgdo
398382ff0afSmrg  arg="$1"
399382ff0afSmrg  shift
400382ff0afSmrg
401382ff0afSmrg  case $arg in
402382ff0afSmrg  -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
403382ff0afSmrg  *) optarg= ;;
404382ff0afSmrg  esac
405382ff0afSmrg
406382ff0afSmrg  # If the previous option needs an argument, assign it.
407382ff0afSmrg  if test -n "$prev"; then
408382ff0afSmrg    case $prev in
409382ff0afSmrg    execute_dlfiles)
410382ff0afSmrg      execute_dlfiles="$execute_dlfiles $arg"
411382ff0afSmrg      ;;
412382ff0afSmrg    tag)
413382ff0afSmrg      tagname="$arg"
414382ff0afSmrg      preserve_args="${preserve_args}=$arg"
415382ff0afSmrg
416382ff0afSmrg      # Check whether tagname contains only valid characters
417382ff0afSmrg      case $tagname in
418382ff0afSmrg      *[!-_A-Za-z0-9,/]*)
419382ff0afSmrg	$echo "$progname: invalid tag name: $tagname" 1>&2
420382ff0afSmrg	exit $EXIT_FAILURE
421382ff0afSmrg	;;
422382ff0afSmrg      esac
423382ff0afSmrg
424382ff0afSmrg      case $tagname in
425382ff0afSmrg      CC)
426382ff0afSmrg	# Don't test for the "default" C tag, as we know, it's there, but
427382ff0afSmrg	# not specially marked.
428382ff0afSmrg	;;
429382ff0afSmrg      *)
430382ff0afSmrg	if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
431382ff0afSmrg	  taglist="$taglist $tagname"
432382ff0afSmrg	  # Evaluate the configuration.
433382ff0afSmrg	  eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
434382ff0afSmrg	else
435382ff0afSmrg	  $echo "$progname: ignoring unknown tag $tagname" 1>&2
436382ff0afSmrg	fi
437382ff0afSmrg	;;
438382ff0afSmrg      esac
439382ff0afSmrg      ;;
440382ff0afSmrg    *)
441382ff0afSmrg      eval "$prev=\$arg"
442382ff0afSmrg      ;;
443382ff0afSmrg    esac
444382ff0afSmrg
445382ff0afSmrg    prev=
446382ff0afSmrg    prevopt=
447382ff0afSmrg    continue
448382ff0afSmrg  fi
449382ff0afSmrg
450382ff0afSmrg  # Have we seen a non-optional argument yet?
451382ff0afSmrg  case $arg in
452382ff0afSmrg  --help)
453382ff0afSmrg    show_help=yes
454382ff0afSmrg    ;;
455382ff0afSmrg
456382ff0afSmrg  --version)
457382ff0afSmrg    $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
458382ff0afSmrg    $echo
459382ff0afSmrg    $echo "Copyright (C) 2005  Free Software Foundation, Inc."
460382ff0afSmrg    $echo "This is free software; see the source for copying conditions.  There is NO"
461382ff0afSmrg    $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
462382ff0afSmrg    exit $?
463382ff0afSmrg    ;;
464382ff0afSmrg
465382ff0afSmrg  --config)
466382ff0afSmrg    ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
467382ff0afSmrg    # Now print the configurations for the tags.
468382ff0afSmrg    for tagname in $taglist; do
469382ff0afSmrg      ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
470382ff0afSmrg    done
471382ff0afSmrg    exit $?
472382ff0afSmrg    ;;
473382ff0afSmrg
474382ff0afSmrg  --debug)
475382ff0afSmrg    $echo "$progname: enabling shell trace mode"
476382ff0afSmrg    set -x
477382ff0afSmrg    preserve_args="$preserve_args $arg"
478382ff0afSmrg    ;;
479382ff0afSmrg
480382ff0afSmrg  --dry-run | -n)
481382ff0afSmrg    run=:
482382ff0afSmrg    ;;
483382ff0afSmrg
484382ff0afSmrg  --features)
485382ff0afSmrg    $echo "host: $host"
486382ff0afSmrg    if test "$build_libtool_libs" = yes; then
487382ff0afSmrg      $echo "enable shared libraries"
488382ff0afSmrg    else
489382ff0afSmrg      $echo "disable shared libraries"
490382ff0afSmrg    fi
491382ff0afSmrg    if test "$build_old_libs" = yes; then
492382ff0afSmrg      $echo "enable static libraries"
493382ff0afSmrg    else
494382ff0afSmrg      $echo "disable static libraries"
495382ff0afSmrg    fi
496382ff0afSmrg    exit $?
497382ff0afSmrg    ;;
498382ff0afSmrg
499382ff0afSmrg  --finish) mode="finish" ;;
500382ff0afSmrg
501382ff0afSmrg  --mode) prevopt="--mode" prev=mode ;;
502382ff0afSmrg  --mode=*) mode="$optarg" ;;
503382ff0afSmrg
504382ff0afSmrg  --preserve-dup-deps) duplicate_deps="yes" ;;
505382ff0afSmrg
506382ff0afSmrg  --quiet | --silent)
507382ff0afSmrg    show=:
508382ff0afSmrg    preserve_args="$preserve_args $arg"
509382ff0afSmrg    ;;
510382ff0afSmrg
511382ff0afSmrg  --tag)
512382ff0afSmrg    prevopt="--tag"
513382ff0afSmrg    prev=tag
514382ff0afSmrg    preserve_args="$preserve_args --tag"
515382ff0afSmrg    ;;
516382ff0afSmrg  --tag=*)
517382ff0afSmrg    set tag "$optarg" ${1+"$@"}
518382ff0afSmrg    shift
519382ff0afSmrg    prev=tag
520382ff0afSmrg    preserve_args="$preserve_args --tag"
521382ff0afSmrg    ;;
522382ff0afSmrg
523382ff0afSmrg  -dlopen)
524382ff0afSmrg    prevopt="-dlopen"
525382ff0afSmrg    prev=execute_dlfiles
526382ff0afSmrg    ;;
527382ff0afSmrg
528382ff0afSmrg  -*)
529382ff0afSmrg    $echo "$modename: unrecognized option \`$arg'" 1>&2
530382ff0afSmrg    $echo "$help" 1>&2
531382ff0afSmrg    exit $EXIT_FAILURE
532382ff0afSmrg    ;;
533382ff0afSmrg
534382ff0afSmrg  *)
535382ff0afSmrg    nonopt="$arg"
536382ff0afSmrg    break
537382ff0afSmrg    ;;
538382ff0afSmrg  esac
539382ff0afSmrgdone
540382ff0afSmrg
541382ff0afSmrgif test -n "$prevopt"; then
542382ff0afSmrg  $echo "$modename: option \`$prevopt' requires an argument" 1>&2
543382ff0afSmrg  $echo "$help" 1>&2
544382ff0afSmrg  exit $EXIT_FAILURE
545382ff0afSmrgfi
546382ff0afSmrg
547382ff0afSmrgcase $disable_libs in
548382ff0afSmrgno) 
549382ff0afSmrg  ;;
550382ff0afSmrgshared)
551382ff0afSmrg  build_libtool_libs=no
552382ff0afSmrg  build_old_libs=yes
553382ff0afSmrg  ;;
554382ff0afSmrgstatic)
555382ff0afSmrg  build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
556382ff0afSmrg  ;;
557382ff0afSmrgesac
558382ff0afSmrg
559382ff0afSmrg# If this variable is set in any of the actions, the command in it
560382ff0afSmrg# will be execed at the end.  This prevents here-documents from being
561382ff0afSmrg# left over by shells.
562382ff0afSmrgexec_cmd=
563382ff0afSmrg
564382ff0afSmrgif test -z "$show_help"; then
565382ff0afSmrg
566382ff0afSmrg  # Infer the operation mode.
567382ff0afSmrg  if test -z "$mode"; then
568382ff0afSmrg    $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
569382ff0afSmrg    $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
570382ff0afSmrg    case $nonopt in
571382ff0afSmrg    *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
572382ff0afSmrg      mode=link
573382ff0afSmrg      for arg
574382ff0afSmrg      do
575382ff0afSmrg	case $arg in
576382ff0afSmrg	-c)
577382ff0afSmrg	   mode=compile
578382ff0afSmrg	   break
579382ff0afSmrg	   ;;
580382ff0afSmrg	esac
581382ff0afSmrg      done
582382ff0afSmrg      ;;
583382ff0afSmrg    *db | *dbx | *strace | *truss)
584382ff0afSmrg      mode=execute
585382ff0afSmrg      ;;
586382ff0afSmrg    *install*|cp|mv)
587382ff0afSmrg      mode=install
588382ff0afSmrg      ;;
589382ff0afSmrg    *rm)
590382ff0afSmrg      mode=uninstall
591382ff0afSmrg      ;;
592382ff0afSmrg    *)
593382ff0afSmrg      # If we have no mode, but dlfiles were specified, then do execute mode.
594382ff0afSmrg      test -n "$execute_dlfiles" && mode=execute
595382ff0afSmrg
596382ff0afSmrg      # Just use the default operation mode.
597382ff0afSmrg      if test -z "$mode"; then
598382ff0afSmrg	if test -n "$nonopt"; then
599382ff0afSmrg	  $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
600382ff0afSmrg	else
601382ff0afSmrg	  $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
602382ff0afSmrg	fi
603382ff0afSmrg      fi
604382ff0afSmrg      ;;
605382ff0afSmrg    esac
606382ff0afSmrg  fi
607382ff0afSmrg
608382ff0afSmrg  # Only execute mode is allowed to have -dlopen flags.
609382ff0afSmrg  if test -n "$execute_dlfiles" && test "$mode" != execute; then
610382ff0afSmrg    $echo "$modename: unrecognized option \`-dlopen'" 1>&2
611382ff0afSmrg    $echo "$help" 1>&2
612382ff0afSmrg    exit $EXIT_FAILURE
613382ff0afSmrg  fi
614382ff0afSmrg
615382ff0afSmrg  # Change the help message to a mode-specific one.
616382ff0afSmrg  generic_help="$help"
617382ff0afSmrg  help="Try \`$modename --help --mode=$mode' for more information."
618382ff0afSmrg
619382ff0afSmrg  # These modes are in order of execution frequency so that they run quickly.
620382ff0afSmrg  case $mode in
621382ff0afSmrg  # libtool compile mode
622382ff0afSmrg  compile)
623382ff0afSmrg    modename="$modename: compile"
624382ff0afSmrg    # Get the compilation command and the source file.
625382ff0afSmrg    base_compile=
626382ff0afSmrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
627382ff0afSmrg    suppress_opt=yes
628382ff0afSmrg    suppress_output=
629382ff0afSmrg    arg_mode=normal
630382ff0afSmrg    libobj=
631382ff0afSmrg    later=
632382ff0afSmrg
633382ff0afSmrg    for arg
634382ff0afSmrg    do
635382ff0afSmrg      case $arg_mode in
636382ff0afSmrg      arg  )
637382ff0afSmrg	# do not "continue".  Instead, add this to base_compile
638382ff0afSmrg	lastarg="$arg"
639382ff0afSmrg	arg_mode=normal
640382ff0afSmrg	;;
641382ff0afSmrg
642382ff0afSmrg      target )
643382ff0afSmrg	libobj="$arg"
644382ff0afSmrg	arg_mode=normal
645382ff0afSmrg	continue
646382ff0afSmrg	;;
647382ff0afSmrg
648382ff0afSmrg      normal )
649382ff0afSmrg	# Accept any command-line options.
650382ff0afSmrg	case $arg in
651382ff0afSmrg	-o)
652382ff0afSmrg	  if test -n "$libobj" ; then
653382ff0afSmrg	    $echo "$modename: you cannot specify \`-o' more than once" 1>&2
654382ff0afSmrg	    exit $EXIT_FAILURE
655382ff0afSmrg	  fi
656382ff0afSmrg	  arg_mode=target
657382ff0afSmrg	  continue
658382ff0afSmrg	  ;;
659382ff0afSmrg
660382ff0afSmrg	-static | -prefer-pic | -prefer-non-pic)
661382ff0afSmrg	  later="$later $arg"
662382ff0afSmrg	  continue
663382ff0afSmrg	  ;;
664382ff0afSmrg
665382ff0afSmrg	-no-suppress)
666382ff0afSmrg	  suppress_opt=no
667382ff0afSmrg	  continue
668382ff0afSmrg	  ;;
669382ff0afSmrg
670382ff0afSmrg	-Xcompiler)
671382ff0afSmrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
672382ff0afSmrg	  continue      #  The current "srcfile" will either be retained or
673382ff0afSmrg	  ;;            #  replaced later.  I would guess that would be a bug.
674382ff0afSmrg
675382ff0afSmrg	-Wc,*)
676382ff0afSmrg	  args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
677382ff0afSmrg	  lastarg=
678382ff0afSmrg	  save_ifs="$IFS"; IFS=','
679382ff0afSmrg 	  for arg in $args; do
680382ff0afSmrg	    IFS="$save_ifs"
681382ff0afSmrg
682382ff0afSmrg	    # Double-quote args containing other shell metacharacters.
683382ff0afSmrg	    # Many Bourne shells cannot handle close brackets correctly
684382ff0afSmrg	    # in scan sets, so we specify it separately.
685382ff0afSmrg	    case $arg in
686382ff0afSmrg	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
687382ff0afSmrg	      arg="\"$arg\""
688382ff0afSmrg	      ;;
689382ff0afSmrg	    esac
690382ff0afSmrg	    lastarg="$lastarg $arg"
691382ff0afSmrg	  done
692382ff0afSmrg	  IFS="$save_ifs"
693382ff0afSmrg	  lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
694382ff0afSmrg
695382ff0afSmrg	  # Add the arguments to base_compile.
696382ff0afSmrg	  base_compile="$base_compile $lastarg"
697382ff0afSmrg	  continue
698382ff0afSmrg	  ;;
699382ff0afSmrg
700382ff0afSmrg	* )
701382ff0afSmrg	  # Accept the current argument as the source file.
702382ff0afSmrg	  # The previous "srcfile" becomes the current argument.
703382ff0afSmrg	  #
704382ff0afSmrg	  lastarg="$srcfile"
705382ff0afSmrg	  srcfile="$arg"
706382ff0afSmrg	  ;;
707382ff0afSmrg	esac  #  case $arg
708382ff0afSmrg	;;
709382ff0afSmrg      esac    #  case $arg_mode
710382ff0afSmrg
711382ff0afSmrg      # Aesthetically quote the previous argument.
712382ff0afSmrg      lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
713382ff0afSmrg
714382ff0afSmrg      case $lastarg in
715382ff0afSmrg      # Double-quote args containing other shell metacharacters.
716382ff0afSmrg      # Many Bourne shells cannot handle close brackets correctly
717382ff0afSmrg      # in scan sets, and some SunOS ksh mistreat backslash-escaping
718382ff0afSmrg      # in scan sets (worked around with variable expansion),
719382ff0afSmrg      # and furthermore cannot handle '|' '&' '(' ')' in scan sets 
720382ff0afSmrg      # at all, so we specify them separately.
721382ff0afSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
722382ff0afSmrg	lastarg="\"$lastarg\""
723382ff0afSmrg	;;
724382ff0afSmrg      esac
725382ff0afSmrg
726382ff0afSmrg      base_compile="$base_compile $lastarg"
727382ff0afSmrg    done # for arg
728382ff0afSmrg
729382ff0afSmrg    case $arg_mode in
730382ff0afSmrg    arg)
731382ff0afSmrg      $echo "$modename: you must specify an argument for -Xcompile"
732382ff0afSmrg      exit $EXIT_FAILURE
733382ff0afSmrg      ;;
734382ff0afSmrg    target)
735382ff0afSmrg      $echo "$modename: you must specify a target with \`-o'" 1>&2
736382ff0afSmrg      exit $EXIT_FAILURE
737382ff0afSmrg      ;;
738382ff0afSmrg    *)
739382ff0afSmrg      # Get the name of the library object.
740382ff0afSmrg      [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
741382ff0afSmrg      ;;
742382ff0afSmrg    esac
743382ff0afSmrg
744382ff0afSmrg    # Recognize several different file suffixes.
745382ff0afSmrg    # If the user specifies -o file.o, it is replaced with file.lo
746382ff0afSmrg    xform='[cCFSifmso]'
747382ff0afSmrg    case $libobj in
748382ff0afSmrg    *.ada) xform=ada ;;
749382ff0afSmrg    *.adb) xform=adb ;;
750382ff0afSmrg    *.ads) xform=ads ;;
751382ff0afSmrg    *.asm) xform=asm ;;
752382ff0afSmrg    *.c++) xform=c++ ;;
753382ff0afSmrg    *.cc) xform=cc ;;
754382ff0afSmrg    *.ii) xform=ii ;;
755382ff0afSmrg    *.class) xform=class ;;
756382ff0afSmrg    *.cpp) xform=cpp ;;
757382ff0afSmrg    *.cxx) xform=cxx ;;
758382ff0afSmrg    *.f90) xform=f90 ;;
759382ff0afSmrg    *.for) xform=for ;;
760382ff0afSmrg    *.java) xform=java ;;
761382ff0afSmrg    esac
762382ff0afSmrg
763382ff0afSmrg    libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
764382ff0afSmrg
765382ff0afSmrg    case $libobj in
766382ff0afSmrg    *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
767382ff0afSmrg    *)
768382ff0afSmrg      $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
769382ff0afSmrg      exit $EXIT_FAILURE
770382ff0afSmrg      ;;
771382ff0afSmrg    esac
772382ff0afSmrg
773382ff0afSmrg    func_infer_tag $base_compile
774382ff0afSmrg
775382ff0afSmrg    for arg in $later; do
776382ff0afSmrg      case $arg in
777382ff0afSmrg      -static)
778382ff0afSmrg	build_old_libs=yes
779382ff0afSmrg	continue
780382ff0afSmrg	;;
781382ff0afSmrg
782382ff0afSmrg      -prefer-pic)
783382ff0afSmrg	pic_mode=yes
784382ff0afSmrg	continue
785382ff0afSmrg	;;
786382ff0afSmrg
787382ff0afSmrg      -prefer-non-pic)
788382ff0afSmrg	pic_mode=no
789382ff0afSmrg	continue
790382ff0afSmrg	;;
791382ff0afSmrg      esac
792382ff0afSmrg    done
793382ff0afSmrg
794382ff0afSmrg    qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
795382ff0afSmrg    case $qlibobj in
796382ff0afSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
797382ff0afSmrg	qlibobj="\"$qlibobj\"" ;;
798382ff0afSmrg    esac
799382ff0afSmrg    test "X$libobj" != "X$qlibobj" \
800382ff0afSmrg	&& $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' 	&()|`$[]' \
801382ff0afSmrg	&& $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
802382ff0afSmrg    objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
803382ff0afSmrg    xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
804382ff0afSmrg    if test "X$xdir" = "X$obj"; then
805382ff0afSmrg      xdir=
806382ff0afSmrg    else
807382ff0afSmrg      xdir=$xdir/
808382ff0afSmrg    fi
809382ff0afSmrg    lobj=${xdir}$objdir/$objname
810382ff0afSmrg
811382ff0afSmrg    if test -z "$base_compile"; then
812382ff0afSmrg      $echo "$modename: you must specify a compilation command" 1>&2
813382ff0afSmrg      $echo "$help" 1>&2
814382ff0afSmrg      exit $EXIT_FAILURE
815382ff0afSmrg    fi
816382ff0afSmrg
817382ff0afSmrg    # Delete any leftover library objects.
818382ff0afSmrg    if test "$build_old_libs" = yes; then
819382ff0afSmrg      removelist="$obj $lobj $libobj ${libobj}T"
820382ff0afSmrg    else
821382ff0afSmrg      removelist="$lobj $libobj ${libobj}T"
822382ff0afSmrg    fi
823382ff0afSmrg
824382ff0afSmrg    $run $rm $removelist
825382ff0afSmrg    trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
826382ff0afSmrg
827382ff0afSmrg    # On Cygwin there's no "real" PIC flag so we must build both object types
828382ff0afSmrg    case $host_os in
829382ff0afSmrg    cygwin* | mingw* | pw32* | os2*)
830382ff0afSmrg      pic_mode=default
831382ff0afSmrg      ;;
832382ff0afSmrg    esac
833382ff0afSmrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
834382ff0afSmrg      # non-PIC code in shared libraries is not supported
835382ff0afSmrg      pic_mode=default
836382ff0afSmrg    fi
837382ff0afSmrg
838382ff0afSmrg    # Calculate the filename of the output object if compiler does
839382ff0afSmrg    # not support -o with -c
840382ff0afSmrg    if test "$compiler_c_o" = no; then
841382ff0afSmrg      output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
842382ff0afSmrg      lockfile="$output_obj.lock"
843382ff0afSmrg      removelist="$removelist $output_obj $lockfile"
844382ff0afSmrg      trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
845382ff0afSmrg    else
846382ff0afSmrg      output_obj=
847382ff0afSmrg      need_locks=no
848382ff0afSmrg      lockfile=
849382ff0afSmrg    fi
850382ff0afSmrg
851382ff0afSmrg    # Lock this critical section if it is needed
852382ff0afSmrg    # We use this script file to make the link, it avoids creating a new file
853382ff0afSmrg    if test "$need_locks" = yes; then
854382ff0afSmrg      until $run ln "$progpath" "$lockfile" 2>/dev/null; do
855382ff0afSmrg	$show "Waiting for $lockfile to be removed"
856382ff0afSmrg	sleep 2
857382ff0afSmrg      done
858382ff0afSmrg    elif test "$need_locks" = warn; then
859382ff0afSmrg      if test -f "$lockfile"; then
860382ff0afSmrg	$echo "\
861382ff0afSmrg*** ERROR, $lockfile exists and contains:
862382ff0afSmrg`cat $lockfile 2>/dev/null`
863382ff0afSmrg
864382ff0afSmrgThis indicates that another process is trying to use the same
865382ff0afSmrgtemporary object file, and libtool could not work around it because
866382ff0afSmrgyour compiler does not support \`-c' and \`-o' together.  If you
867382ff0afSmrgrepeat this compilation, it may succeed, by chance, but you had better
868382ff0afSmrgavoid parallel builds (make -j) in this platform, or get a better
869382ff0afSmrgcompiler."
870382ff0afSmrg
871382ff0afSmrg	$run $rm $removelist
872382ff0afSmrg	exit $EXIT_FAILURE
873382ff0afSmrg      fi
874382ff0afSmrg      $echo "$srcfile" > "$lockfile"
875382ff0afSmrg    fi
876382ff0afSmrg
877382ff0afSmrg    if test -n "$fix_srcfile_path"; then
878382ff0afSmrg      eval srcfile=\"$fix_srcfile_path\"
879382ff0afSmrg    fi
880382ff0afSmrg    qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"`
881382ff0afSmrg    case $qsrcfile in
882382ff0afSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
883382ff0afSmrg      qsrcfile="\"$qsrcfile\"" ;;
884382ff0afSmrg    esac
885382ff0afSmrg
886382ff0afSmrg    $run $rm "$libobj" "${libobj}T"
887382ff0afSmrg
888382ff0afSmrg    # Create a libtool object file (analogous to a ".la" file),
889382ff0afSmrg    # but don't create it if we're doing a dry run.
890382ff0afSmrg    test -z "$run" && cat > ${libobj}T <<EOF
891382ff0afSmrg# $libobj - a libtool object file
892382ff0afSmrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
893382ff0afSmrg#
894382ff0afSmrg# Please DO NOT delete this file!
895382ff0afSmrg# It is necessary for linking the library.
896382ff0afSmrg
897382ff0afSmrg# Name of the PIC object.
898382ff0afSmrgEOF
899382ff0afSmrg
900382ff0afSmrg    # Only build a PIC object if we are building libtool libraries.
901382ff0afSmrg    if test "$build_libtool_libs" = yes; then
902382ff0afSmrg      # Without this assignment, base_compile gets emptied.
903382ff0afSmrg      fbsd_hideous_sh_bug=$base_compile
904382ff0afSmrg
905382ff0afSmrg      if test "$pic_mode" != no; then
906382ff0afSmrg	command="$base_compile $qsrcfile $pic_flag"
907382ff0afSmrg      else
908382ff0afSmrg	# Don't build PIC code
909382ff0afSmrg	command="$base_compile $qsrcfile"
910382ff0afSmrg      fi
911382ff0afSmrg
912382ff0afSmrg      if test ! -d "${xdir}$objdir"; then
913382ff0afSmrg	$show "$mkdir ${xdir}$objdir"
914382ff0afSmrg	$run $mkdir ${xdir}$objdir
915382ff0afSmrg	exit_status=$?
916382ff0afSmrg	if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
917382ff0afSmrg	  exit $exit_status
918382ff0afSmrg	fi
919382ff0afSmrg      fi
920382ff0afSmrg
921382ff0afSmrg      if test -z "$output_obj"; then
922382ff0afSmrg	# Place PIC objects in $objdir
923382ff0afSmrg	command="$command -o $lobj"
924382ff0afSmrg      fi
925382ff0afSmrg
926382ff0afSmrg      $run $rm "$lobj" "$output_obj"
927382ff0afSmrg
928382ff0afSmrg      $show "$command"
929382ff0afSmrg      if $run eval "$command"; then :
930382ff0afSmrg      else
931382ff0afSmrg	test -n "$output_obj" && $run $rm $removelist
932382ff0afSmrg	exit $EXIT_FAILURE
933382ff0afSmrg      fi
934382ff0afSmrg
935382ff0afSmrg      if test "$need_locks" = warn &&
936382ff0afSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
937382ff0afSmrg	$echo "\
938382ff0afSmrg*** ERROR, $lockfile contains:
939382ff0afSmrg`cat $lockfile 2>/dev/null`
940382ff0afSmrg
941382ff0afSmrgbut it should contain:
942382ff0afSmrg$srcfile
943382ff0afSmrg
944382ff0afSmrgThis indicates that another process is trying to use the same
945382ff0afSmrgtemporary object file, and libtool could not work around it because
946382ff0afSmrgyour compiler does not support \`-c' and \`-o' together.  If you
947382ff0afSmrgrepeat this compilation, it may succeed, by chance, but you had better
948382ff0afSmrgavoid parallel builds (make -j) in this platform, or get a better
949382ff0afSmrgcompiler."
950382ff0afSmrg
951382ff0afSmrg	$run $rm $removelist
952382ff0afSmrg	exit $EXIT_FAILURE
953382ff0afSmrg      fi
954382ff0afSmrg
955382ff0afSmrg      # Just move the object if needed, then go on to compile the next one
956382ff0afSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
957382ff0afSmrg	$show "$mv $output_obj $lobj"
958382ff0afSmrg	if $run $mv $output_obj $lobj; then :
959382ff0afSmrg	else
960382ff0afSmrg	  error=$?
961382ff0afSmrg	  $run $rm $removelist
962382ff0afSmrg	  exit $error
963382ff0afSmrg	fi
964382ff0afSmrg      fi
965382ff0afSmrg
966382ff0afSmrg      # Append the name of the PIC object to the libtool object file.
967382ff0afSmrg      test -z "$run" && cat >> ${libobj}T <<EOF
968382ff0afSmrgpic_object='$objdir/$objname'
969382ff0afSmrg
970382ff0afSmrgEOF
971382ff0afSmrg
972382ff0afSmrg      # Allow error messages only from the first compilation.
973382ff0afSmrg      if test "$suppress_opt" = yes; then
974382ff0afSmrg        suppress_output=' >/dev/null 2>&1'
975382ff0afSmrg      fi
976382ff0afSmrg    else
977382ff0afSmrg      # No PIC object so indicate it doesn't exist in the libtool
978382ff0afSmrg      # object file.
979382ff0afSmrg      test -z "$run" && cat >> ${libobj}T <<EOF
980382ff0afSmrgpic_object=none
981382ff0afSmrg
982382ff0afSmrgEOF
983382ff0afSmrg    fi
984382ff0afSmrg
985382ff0afSmrg    # Only build a position-dependent object if we build old libraries.
986382ff0afSmrg    if test "$build_old_libs" = yes; then
987382ff0afSmrg      if test "$pic_mode" != yes; then
988382ff0afSmrg	# Don't build PIC code
989382ff0afSmrg	command="$base_compile $qsrcfile"
990382ff0afSmrg      else
991382ff0afSmrg	command="$base_compile $qsrcfile $pic_flag"
992382ff0afSmrg      fi
993382ff0afSmrg      if test "$compiler_c_o" = yes; then
994382ff0afSmrg	command="$command -o $obj"
995382ff0afSmrg      fi
996382ff0afSmrg
997382ff0afSmrg      # Suppress compiler output if we already did a PIC compilation.
998382ff0afSmrg      command="$command$suppress_output"
999382ff0afSmrg      $run $rm "$obj" "$output_obj"
1000382ff0afSmrg      $show "$command"
1001382ff0afSmrg      if $run eval "$command"; then :
1002382ff0afSmrg      else
1003382ff0afSmrg	$run $rm $removelist
1004382ff0afSmrg	exit $EXIT_FAILURE
1005382ff0afSmrg      fi
1006382ff0afSmrg
1007382ff0afSmrg      if test "$need_locks" = warn &&
1008382ff0afSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1009382ff0afSmrg	$echo "\
1010382ff0afSmrg*** ERROR, $lockfile contains:
1011382ff0afSmrg`cat $lockfile 2>/dev/null`
1012382ff0afSmrg
1013382ff0afSmrgbut it should contain:
1014382ff0afSmrg$srcfile
1015382ff0afSmrg
1016382ff0afSmrgThis indicates that another process is trying to use the same
1017382ff0afSmrgtemporary object file, and libtool could not work around it because
1018382ff0afSmrgyour compiler does not support \`-c' and \`-o' together.  If you
1019382ff0afSmrgrepeat this compilation, it may succeed, by chance, but you had better
1020382ff0afSmrgavoid parallel builds (make -j) in this platform, or get a better
1021382ff0afSmrgcompiler."
1022382ff0afSmrg
1023382ff0afSmrg	$run $rm $removelist
1024382ff0afSmrg	exit $EXIT_FAILURE
1025382ff0afSmrg      fi
1026382ff0afSmrg
1027382ff0afSmrg      # Just move the object if needed
1028382ff0afSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
1029382ff0afSmrg	$show "$mv $output_obj $obj"
1030382ff0afSmrg	if $run $mv $output_obj $obj; then :
1031382ff0afSmrg	else
1032382ff0afSmrg	  error=$?
1033382ff0afSmrg	  $run $rm $removelist
1034382ff0afSmrg	  exit $error
1035382ff0afSmrg	fi
1036382ff0afSmrg      fi
1037382ff0afSmrg
1038382ff0afSmrg      # Append the name of the non-PIC object the libtool object file.
1039382ff0afSmrg      # Only append if the libtool object file exists.
1040382ff0afSmrg      test -z "$run" && cat >> ${libobj}T <<EOF
1041382ff0afSmrg# Name of the non-PIC object.
1042382ff0afSmrgnon_pic_object='$objname'
1043382ff0afSmrg
1044382ff0afSmrgEOF
1045382ff0afSmrg    else
1046382ff0afSmrg      # Append the name of the non-PIC object the libtool object file.
1047382ff0afSmrg      # Only append if the libtool object file exists.
1048382ff0afSmrg      test -z "$run" && cat >> ${libobj}T <<EOF
1049382ff0afSmrg# Name of the non-PIC object.
1050382ff0afSmrgnon_pic_object=none
1051382ff0afSmrg
1052382ff0afSmrgEOF
1053382ff0afSmrg    fi
1054382ff0afSmrg
1055382ff0afSmrg    $run $mv "${libobj}T" "${libobj}"
1056382ff0afSmrg
1057382ff0afSmrg    # Unlock the critical section if it was locked
1058382ff0afSmrg    if test "$need_locks" != no; then
1059382ff0afSmrg      $run $rm "$lockfile"
1060382ff0afSmrg    fi
1061382ff0afSmrg
1062382ff0afSmrg    exit $EXIT_SUCCESS
1063382ff0afSmrg    ;;
1064382ff0afSmrg
1065382ff0afSmrg  # libtool link mode
1066382ff0afSmrg  link | relink)
1067382ff0afSmrg    modename="$modename: link"
1068382ff0afSmrg    case $host in
1069382ff0afSmrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
1070382ff0afSmrg      # It is impossible to link a dll without this setting, and
1071382ff0afSmrg      # we shouldn't force the makefile maintainer to figure out
1072382ff0afSmrg      # which system we are compiling for in order to pass an extra
1073382ff0afSmrg      # flag for every libtool invocation.
1074382ff0afSmrg      # allow_undefined=no
1075382ff0afSmrg
1076382ff0afSmrg      # FIXME: Unfortunately, there are problems with the above when trying
1077382ff0afSmrg      # to make a dll which has undefined symbols, in which case not
1078382ff0afSmrg      # even a static library is built.  For now, we need to specify
1079382ff0afSmrg      # -no-undefined on the libtool link line when we can be certain
1080382ff0afSmrg      # that all symbols are satisfied, otherwise we get a static library.
1081382ff0afSmrg      allow_undefined=yes
1082382ff0afSmrg      ;;
1083382ff0afSmrg    *)
1084382ff0afSmrg      allow_undefined=yes
1085382ff0afSmrg      ;;
1086382ff0afSmrg    esac
1087382ff0afSmrg    libtool_args="$nonopt"
1088382ff0afSmrg    base_compile="$nonopt $@"
1089382ff0afSmrg    compile_command="$nonopt"
1090382ff0afSmrg    finalize_command="$nonopt"
1091382ff0afSmrg
1092382ff0afSmrg    compile_rpath=
1093382ff0afSmrg    finalize_rpath=
1094382ff0afSmrg    compile_shlibpath=
1095382ff0afSmrg    finalize_shlibpath=
1096382ff0afSmrg    convenience=
1097382ff0afSmrg    old_convenience=
1098382ff0afSmrg    deplibs=
1099382ff0afSmrg    old_deplibs=
1100382ff0afSmrg    compiler_flags=
1101382ff0afSmrg    linker_flags=
1102382ff0afSmrg    dllsearchpath=
1103382ff0afSmrg    lib_search_path=`pwd`
1104382ff0afSmrg    inst_prefix_dir=
1105382ff0afSmrg
1106382ff0afSmrg    avoid_version=no
1107382ff0afSmrg    dlfiles=
1108382ff0afSmrg    dlprefiles=
1109382ff0afSmrg    dlself=no
1110382ff0afSmrg    export_dynamic=no
1111382ff0afSmrg    export_symbols=
1112382ff0afSmrg    export_symbols_regex=
1113382ff0afSmrg    generated=
1114382ff0afSmrg    libobjs=
1115382ff0afSmrg    ltlibs=
1116382ff0afSmrg    module=no
1117382ff0afSmrg    no_install=no
1118382ff0afSmrg    objs=
1119382ff0afSmrg    non_pic_objects=
1120382ff0afSmrg    notinst_path= # paths that contain not-installed libtool libraries
1121382ff0afSmrg    precious_files_regex=
1122382ff0afSmrg    prefer_static_libs=no
1123382ff0afSmrg    preload=no
1124382ff0afSmrg    prev=
1125382ff0afSmrg    prevarg=
1126382ff0afSmrg    release=
1127382ff0afSmrg    rpath=
1128382ff0afSmrg    xrpath=
1129382ff0afSmrg    perm_rpath=
1130382ff0afSmrg    temp_rpath=
1131382ff0afSmrg    thread_safe=no
1132382ff0afSmrg    vinfo=
1133382ff0afSmrg    vinfo_number=no
1134382ff0afSmrg
1135382ff0afSmrg    func_infer_tag $base_compile
1136382ff0afSmrg
1137382ff0afSmrg    # We need to know -static, to get the right output filenames.
1138382ff0afSmrg    for arg
1139382ff0afSmrg    do
1140382ff0afSmrg      case $arg in
1141382ff0afSmrg      -all-static | -static)
1142382ff0afSmrg	if test "X$arg" = "X-all-static"; then
1143382ff0afSmrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
1144382ff0afSmrg	    $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
1145382ff0afSmrg	  fi
1146382ff0afSmrg	  if test -n "$link_static_flag"; then
1147382ff0afSmrg	    dlopen_self=$dlopen_self_static
1148382ff0afSmrg	  fi
1149382ff0afSmrg	  prefer_static_libs=yes
1150382ff0afSmrg	else
1151382ff0afSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
1152382ff0afSmrg	    dlopen_self=$dlopen_self_static
1153382ff0afSmrg	  fi
1154382ff0afSmrg	  prefer_static_libs=built
1155382ff0afSmrg	fi
1156382ff0afSmrg	build_libtool_libs=no
1157382ff0afSmrg	build_old_libs=yes
1158382ff0afSmrg	break
1159382ff0afSmrg	;;
1160382ff0afSmrg      esac
1161382ff0afSmrg    done
1162382ff0afSmrg
1163382ff0afSmrg    # See if our shared archives depend on static archives.
1164382ff0afSmrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
1165382ff0afSmrg
1166382ff0afSmrg    # Go through the arguments, transforming them on the way.
1167382ff0afSmrg    while test "$#" -gt 0; do
1168382ff0afSmrg      arg="$1"
1169382ff0afSmrg      shift
1170382ff0afSmrg      case $arg in
1171382ff0afSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1172382ff0afSmrg	qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
1173382ff0afSmrg	;;
1174382ff0afSmrg      *) qarg=$arg ;;
1175382ff0afSmrg      esac
1176382ff0afSmrg      libtool_args="$libtool_args $qarg"
1177382ff0afSmrg
1178382ff0afSmrg      # If the previous option needs an argument, assign it.
1179382ff0afSmrg      if test -n "$prev"; then
1180382ff0afSmrg	case $prev in
1181382ff0afSmrg	output)
1182382ff0afSmrg	  compile_command="$compile_command @OUTPUT@"
1183382ff0afSmrg	  finalize_command="$finalize_command @OUTPUT@"
1184382ff0afSmrg	  ;;
1185382ff0afSmrg	esac
1186382ff0afSmrg
1187382ff0afSmrg	case $prev in
1188382ff0afSmrg	dlfiles|dlprefiles)
1189382ff0afSmrg	  if test "$preload" = no; then
1190382ff0afSmrg	    # Add the symbol object into the linking commands.
1191382ff0afSmrg	    compile_command="$compile_command @SYMFILE@"
1192382ff0afSmrg	    finalize_command="$finalize_command @SYMFILE@"
1193382ff0afSmrg	    preload=yes
1194382ff0afSmrg	  fi
1195382ff0afSmrg	  case $arg in
1196382ff0afSmrg	  *.la | *.lo) ;;  # We handle these cases below.
1197382ff0afSmrg	  force)
1198382ff0afSmrg	    if test "$dlself" = no; then
1199382ff0afSmrg	      dlself=needless
1200382ff0afSmrg	      export_dynamic=yes
1201382ff0afSmrg	    fi
1202382ff0afSmrg	    prev=
1203382ff0afSmrg	    continue
1204382ff0afSmrg	    ;;
1205382ff0afSmrg	  self)
1206382ff0afSmrg	    if test "$prev" = dlprefiles; then
1207382ff0afSmrg	      dlself=yes
1208382ff0afSmrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
1209382ff0afSmrg	      dlself=yes
1210382ff0afSmrg	    else
1211382ff0afSmrg	      dlself=needless
1212382ff0afSmrg	      export_dynamic=yes
1213382ff0afSmrg	    fi
1214382ff0afSmrg	    prev=
1215382ff0afSmrg	    continue
1216382ff0afSmrg	    ;;
1217382ff0afSmrg	  *)
1218382ff0afSmrg	    if test "$prev" = dlfiles; then
1219382ff0afSmrg	      dlfiles="$dlfiles $arg"
1220382ff0afSmrg	    else
1221382ff0afSmrg	      dlprefiles="$dlprefiles $arg"
1222382ff0afSmrg	    fi
1223382ff0afSmrg	    prev=
1224382ff0afSmrg	    continue
1225382ff0afSmrg	    ;;
1226382ff0afSmrg	  esac
1227382ff0afSmrg	  ;;
1228382ff0afSmrg	expsyms)
1229382ff0afSmrg	  export_symbols="$arg"
1230382ff0afSmrg	  if test ! -f "$arg"; then
1231382ff0afSmrg	    $echo "$modename: symbol file \`$arg' does not exist"
1232382ff0afSmrg	    exit $EXIT_FAILURE
1233382ff0afSmrg	  fi
1234382ff0afSmrg	  prev=
1235382ff0afSmrg	  continue
1236382ff0afSmrg	  ;;
1237382ff0afSmrg	expsyms_regex)
1238382ff0afSmrg	  export_symbols_regex="$arg"
1239382ff0afSmrg	  prev=
1240382ff0afSmrg	  continue
1241382ff0afSmrg	  ;;
1242382ff0afSmrg	inst_prefix)
1243382ff0afSmrg	  inst_prefix_dir="$arg"
1244382ff0afSmrg	  prev=
1245382ff0afSmrg	  continue
1246382ff0afSmrg	  ;;
1247382ff0afSmrg	precious_regex)
1248382ff0afSmrg	  precious_files_regex="$arg"
1249382ff0afSmrg	  prev=
1250382ff0afSmrg	  continue
1251382ff0afSmrg	  ;;
1252382ff0afSmrg	release)
1253382ff0afSmrg	  release="-$arg"
1254382ff0afSmrg	  prev=
1255382ff0afSmrg	  continue
1256382ff0afSmrg	  ;;
1257382ff0afSmrg	objectlist)
1258382ff0afSmrg	  if test -f "$arg"; then
1259382ff0afSmrg	    save_arg=$arg
1260382ff0afSmrg	    moreargs=
1261382ff0afSmrg	    for fil in `cat $save_arg`
1262382ff0afSmrg	    do
1263382ff0afSmrg#	      moreargs="$moreargs $fil"
1264382ff0afSmrg	      arg=$fil
1265382ff0afSmrg	      # A libtool-controlled object.
1266382ff0afSmrg
1267382ff0afSmrg	      # Check to see that this really is a libtool object.
1268382ff0afSmrg	      if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
1269382ff0afSmrg		pic_object=
1270382ff0afSmrg		non_pic_object=
1271382ff0afSmrg
1272382ff0afSmrg		# Read the .lo file
1273382ff0afSmrg		# If there is no directory component, then add one.
1274382ff0afSmrg		case $arg in
1275382ff0afSmrg		*/* | *\\*) . $arg ;;
1276382ff0afSmrg		*) . ./$arg ;;
1277382ff0afSmrg		esac
1278382ff0afSmrg
1279382ff0afSmrg		if test -z "$pic_object" || \
1280382ff0afSmrg		   test -z "$non_pic_object" ||
1281382ff0afSmrg		   test "$pic_object" = none && \
1282382ff0afSmrg		   test "$non_pic_object" = none; then
1283382ff0afSmrg		  $echo "$modename: cannot find name of object for \`$arg'" 1>&2
1284382ff0afSmrg		  exit $EXIT_FAILURE
1285382ff0afSmrg		fi
1286382ff0afSmrg
1287382ff0afSmrg		# Extract subdirectory from the argument.
1288382ff0afSmrg		xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1289382ff0afSmrg		if test "X$xdir" = "X$arg"; then
1290382ff0afSmrg		  xdir=
1291382ff0afSmrg		else
1292382ff0afSmrg		  xdir="$xdir/"
1293382ff0afSmrg		fi
1294382ff0afSmrg
1295382ff0afSmrg		if test "$pic_object" != none; then
1296382ff0afSmrg		  # Prepend the subdirectory the object is found in.
1297382ff0afSmrg		  pic_object="$xdir$pic_object"
1298382ff0afSmrg
1299382ff0afSmrg		  if test "$prev" = dlfiles; then
1300382ff0afSmrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
1301382ff0afSmrg		      dlfiles="$dlfiles $pic_object"
1302382ff0afSmrg		      prev=
1303382ff0afSmrg		      continue
1304382ff0afSmrg		    else
1305382ff0afSmrg		      # If libtool objects are unsupported, then we need to preload.
1306382ff0afSmrg		      prev=dlprefiles
1307382ff0afSmrg		    fi
1308382ff0afSmrg		  fi
1309382ff0afSmrg
1310382ff0afSmrg		  # CHECK ME:  I think I busted this.  -Ossama
1311382ff0afSmrg		  if test "$prev" = dlprefiles; then
1312382ff0afSmrg		    # Preload the old-style object.
1313382ff0afSmrg		    dlprefiles="$dlprefiles $pic_object"
1314382ff0afSmrg		    prev=
1315382ff0afSmrg		  fi
1316382ff0afSmrg
1317382ff0afSmrg		  # A PIC object.
1318382ff0afSmrg		  libobjs="$libobjs $pic_object"
1319382ff0afSmrg		  arg="$pic_object"
1320382ff0afSmrg		fi
1321382ff0afSmrg
1322382ff0afSmrg		# Non-PIC object.
1323382ff0afSmrg		if test "$non_pic_object" != none; then
1324382ff0afSmrg		  # Prepend the subdirectory the object is found in.
1325382ff0afSmrg		  non_pic_object="$xdir$non_pic_object"
1326382ff0afSmrg
1327382ff0afSmrg		  # A standard non-PIC object
1328382ff0afSmrg		  non_pic_objects="$non_pic_objects $non_pic_object"
1329382ff0afSmrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
1330382ff0afSmrg		    arg="$non_pic_object"
1331382ff0afSmrg		  fi
1332382ff0afSmrg		else
1333382ff0afSmrg		  # If the PIC object exists, use it instead.
1334382ff0afSmrg		  # $xdir was prepended to $pic_object above.
1335382ff0afSmrg		  non_pic_object="$pic_object"
1336382ff0afSmrg		  non_pic_objects="$non_pic_objects $non_pic_object"
1337382ff0afSmrg		fi
1338382ff0afSmrg	      else
1339382ff0afSmrg		# Only an error if not doing a dry-run.
1340382ff0afSmrg		if test -z "$run"; then
1341382ff0afSmrg		  $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
1342382ff0afSmrg		  exit $EXIT_FAILURE
1343382ff0afSmrg		else
1344382ff0afSmrg		  # Dry-run case.
1345382ff0afSmrg
1346382ff0afSmrg		  # Extract subdirectory from the argument.
1347382ff0afSmrg		  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1348382ff0afSmrg		  if test "X$xdir" = "X$arg"; then
1349382ff0afSmrg		    xdir=
1350382ff0afSmrg		  else
1351382ff0afSmrg		    xdir="$xdir/"
1352382ff0afSmrg		  fi
1353382ff0afSmrg
1354382ff0afSmrg		  pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
1355382ff0afSmrg		  non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
1356382ff0afSmrg		  libobjs="$libobjs $pic_object"
1357382ff0afSmrg		  non_pic_objects="$non_pic_objects $non_pic_object"
1358382ff0afSmrg		fi
1359382ff0afSmrg	      fi
1360382ff0afSmrg	    done
1361382ff0afSmrg	  else
1362382ff0afSmrg	    $echo "$modename: link input file \`$save_arg' does not exist"
1363382ff0afSmrg	    exit $EXIT_FAILURE
1364382ff0afSmrg	  fi
1365382ff0afSmrg	  arg=$save_arg
1366382ff0afSmrg	  prev=
1367382ff0afSmrg	  continue
1368382ff0afSmrg	  ;;
1369382ff0afSmrg	rpath | xrpath)
1370382ff0afSmrg	  # We need an absolute path.
1371382ff0afSmrg	  case $arg in
1372382ff0afSmrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
1373382ff0afSmrg	  *)
1374382ff0afSmrg	    $echo "$modename: only absolute run-paths are allowed" 1>&2
1375382ff0afSmrg	    exit $EXIT_FAILURE
1376382ff0afSmrg	    ;;
1377382ff0afSmrg	  esac
1378382ff0afSmrg	  if test "$prev" = rpath; then
1379382ff0afSmrg	    case "$rpath " in
1380382ff0afSmrg	    *" $arg "*) ;;
1381382ff0afSmrg	    *) rpath="$rpath $arg" ;;
1382382ff0afSmrg	    esac
1383382ff0afSmrg	  else
1384382ff0afSmrg	    case "$xrpath " in
1385382ff0afSmrg	    *" $arg "*) ;;
1386382ff0afSmrg	    *) xrpath="$xrpath $arg" ;;
1387382ff0afSmrg	    esac
1388382ff0afSmrg	  fi
1389382ff0afSmrg	  prev=
1390382ff0afSmrg	  continue
1391382ff0afSmrg	  ;;
1392382ff0afSmrg	xcompiler)
1393382ff0afSmrg	  compiler_flags="$compiler_flags $qarg"
1394382ff0afSmrg	  prev=
1395382ff0afSmrg	  compile_command="$compile_command $qarg"
1396382ff0afSmrg	  finalize_command="$finalize_command $qarg"
1397382ff0afSmrg	  continue
1398382ff0afSmrg	  ;;
1399382ff0afSmrg	xlinker)
1400382ff0afSmrg	  linker_flags="$linker_flags $qarg"
1401382ff0afSmrg	  compiler_flags="$compiler_flags $wl$qarg"
1402382ff0afSmrg	  prev=
1403382ff0afSmrg	  compile_command="$compile_command $wl$qarg"
1404382ff0afSmrg	  finalize_command="$finalize_command $wl$qarg"
1405382ff0afSmrg	  continue
1406382ff0afSmrg	  ;;
1407382ff0afSmrg	xcclinker)
1408382ff0afSmrg	  linker_flags="$linker_flags $qarg"
1409382ff0afSmrg	  compiler_flags="$compiler_flags $qarg"
1410382ff0afSmrg	  prev=
1411382ff0afSmrg	  compile_command="$compile_command $qarg"
1412382ff0afSmrg	  finalize_command="$finalize_command $qarg"
1413382ff0afSmrg	  continue
1414382ff0afSmrg	  ;;
1415382ff0afSmrg	shrext)
1416382ff0afSmrg  	  shrext_cmds="$arg"
1417382ff0afSmrg	  prev=
1418382ff0afSmrg	  continue
1419382ff0afSmrg	  ;;
1420382ff0afSmrg	darwin_framework|darwin_framework_skip)
1421382ff0afSmrg	  test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg"
1422382ff0afSmrg	  compile_command="$compile_command $arg"
1423382ff0afSmrg	  finalize_command="$finalize_command $arg"
1424382ff0afSmrg	  prev=
1425382ff0afSmrg	  continue
1426382ff0afSmrg	  ;;
1427382ff0afSmrg	*)
1428382ff0afSmrg	  eval "$prev=\"\$arg\""
1429382ff0afSmrg	  prev=
1430382ff0afSmrg	  continue
1431382ff0afSmrg	  ;;
1432382ff0afSmrg	esac
1433382ff0afSmrg      fi # test -n "$prev"
1434382ff0afSmrg
1435382ff0afSmrg      prevarg="$arg"
1436382ff0afSmrg
1437382ff0afSmrg      case $arg in
1438382ff0afSmrg      -all-static)
1439382ff0afSmrg	if test -n "$link_static_flag"; then
1440382ff0afSmrg	  compile_command="$compile_command $link_static_flag"
1441382ff0afSmrg	  finalize_command="$finalize_command $link_static_flag"
1442382ff0afSmrg	fi
1443382ff0afSmrg	continue
1444382ff0afSmrg	;;
1445382ff0afSmrg
1446382ff0afSmrg      -allow-undefined)
1447382ff0afSmrg	# FIXME: remove this flag sometime in the future.
1448382ff0afSmrg	$echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
1449382ff0afSmrg	continue
1450382ff0afSmrg	;;
1451382ff0afSmrg
1452382ff0afSmrg      -avoid-version)
1453382ff0afSmrg	avoid_version=yes
1454382ff0afSmrg	continue
1455382ff0afSmrg	;;
1456382ff0afSmrg
1457382ff0afSmrg      -dlopen)
1458382ff0afSmrg	prev=dlfiles
1459382ff0afSmrg	continue
1460382ff0afSmrg	;;
1461382ff0afSmrg
1462382ff0afSmrg      -dlpreopen)
1463382ff0afSmrg	prev=dlprefiles
1464382ff0afSmrg	continue
1465382ff0afSmrg	;;
1466382ff0afSmrg
1467382ff0afSmrg      -export-dynamic)
1468382ff0afSmrg	export_dynamic=yes
1469382ff0afSmrg	continue
1470382ff0afSmrg	;;
1471382ff0afSmrg
1472382ff0afSmrg      -export-symbols | -export-symbols-regex)
1473382ff0afSmrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
1474382ff0afSmrg	  $echo "$modename: more than one -exported-symbols argument is not allowed"
1475382ff0afSmrg	  exit $EXIT_FAILURE
1476382ff0afSmrg	fi
1477382ff0afSmrg	if test "X$arg" = "X-export-symbols"; then
1478382ff0afSmrg	  prev=expsyms
1479382ff0afSmrg	else
1480382ff0afSmrg	  prev=expsyms_regex
1481382ff0afSmrg	fi
1482382ff0afSmrg	continue
1483382ff0afSmrg	;;
1484382ff0afSmrg
1485382ff0afSmrg      -framework|-arch|-isysroot)
1486382ff0afSmrg	case " $CC " in
1487382ff0afSmrg	  *" ${arg} ${1} "* | *" ${arg}	${1} "*) 
1488382ff0afSmrg		prev=darwin_framework_skip ;;
1489382ff0afSmrg	  *) compiler_flags="$compiler_flags $arg"
1490382ff0afSmrg	     prev=darwin_framework ;;
1491382ff0afSmrg	esac
1492382ff0afSmrg	compile_command="$compile_command $arg"
1493382ff0afSmrg	finalize_command="$finalize_command $arg"
1494382ff0afSmrg	continue
1495382ff0afSmrg	;;
1496382ff0afSmrg
1497382ff0afSmrg      -inst-prefix-dir)
1498382ff0afSmrg	prev=inst_prefix
1499382ff0afSmrg	continue
1500382ff0afSmrg	;;
1501382ff0afSmrg
1502382ff0afSmrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
1503382ff0afSmrg      # so, if we see these flags be careful not to treat them like -L
1504382ff0afSmrg      -L[A-Z][A-Z]*:*)
1505382ff0afSmrg	case $with_gcc/$host in
1506382ff0afSmrg	no/*-*-irix* | /*-*-irix*)
1507382ff0afSmrg	  compile_command="$compile_command $arg"
1508382ff0afSmrg	  finalize_command="$finalize_command $arg"
1509382ff0afSmrg	  ;;
1510382ff0afSmrg	esac
1511382ff0afSmrg	continue
1512382ff0afSmrg	;;
1513382ff0afSmrg
1514382ff0afSmrg      -L*)
1515382ff0afSmrg	dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
1516382ff0afSmrg	# We need an absolute path.
1517382ff0afSmrg	case $dir in
1518382ff0afSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
1519382ff0afSmrg	*)
1520382ff0afSmrg	  absdir=`cd "$dir" && pwd`
1521382ff0afSmrg	  if test -z "$absdir"; then
1522382ff0afSmrg	    $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
1523382ff0afSmrg	    absdir="$dir"
1524382ff0afSmrg	    notinst_path="$notinst_path $dir"
1525382ff0afSmrg	  fi
1526382ff0afSmrg	  dir="$absdir"
1527382ff0afSmrg	  ;;
1528382ff0afSmrg	esac
1529382ff0afSmrg	case "$deplibs " in
1530382ff0afSmrg	*" -L$dir "*) ;;
1531382ff0afSmrg	*)
1532382ff0afSmrg	  deplibs="$deplibs -L$dir"
1533382ff0afSmrg	  lib_search_path="$lib_search_path $dir"
1534382ff0afSmrg	  ;;
1535382ff0afSmrg	esac
1536382ff0afSmrg	case $host in
1537382ff0afSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
1538382ff0afSmrg	  testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'`
1539382ff0afSmrg	  case :$dllsearchpath: in
1540382ff0afSmrg	  *":$dir:"*) ;;
1541382ff0afSmrg	  *) dllsearchpath="$dllsearchpath:$dir";;
1542382ff0afSmrg	  esac
1543382ff0afSmrg	  case :$dllsearchpath: in
1544382ff0afSmrg	  *":$testbindir:"*) ;;
1545382ff0afSmrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
1546382ff0afSmrg	  esac
1547382ff0afSmrg	  ;;
1548382ff0afSmrg	esac
1549382ff0afSmrg	continue
1550382ff0afSmrg	;;
1551382ff0afSmrg
1552382ff0afSmrg      -l*)
1553382ff0afSmrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
1554382ff0afSmrg	  case $host in
1555382ff0afSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
1556382ff0afSmrg	    # These systems don't actually have a C or math library (as such)
1557382ff0afSmrg	    continue
1558382ff0afSmrg	    ;;
1559382ff0afSmrg	  *-*-os2*)
1560382ff0afSmrg	    # These systems don't actually have a C library (as such)
1561382ff0afSmrg	    test "X$arg" = "X-lc" && continue
1562382ff0afSmrg	    ;;
1563382ff0afSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
1564382ff0afSmrg	    # Do not include libc due to us having libc/libc_r.
1565382ff0afSmrg	    test "X$arg" = "X-lc" && continue
1566382ff0afSmrg	    ;;
1567382ff0afSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
1568382ff0afSmrg	    # Rhapsody C and math libraries are in the System framework
1569382ff0afSmrg	    deplibs="$deplibs -framework System"
1570382ff0afSmrg	    continue
1571382ff0afSmrg	    ;;
1572382ff0afSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
1573382ff0afSmrg	    # Causes problems with __ctype
1574382ff0afSmrg	    test "X$arg" = "X-lc" && continue
1575382ff0afSmrg	    ;;
1576382ff0afSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
1577382ff0afSmrg	    # Compiler inserts libc in the correct place for threads to work
1578382ff0afSmrg	    test "X$arg" = "X-lc" && continue
1579382ff0afSmrg	    ;;
1580382ff0afSmrg	  esac
1581382ff0afSmrg	elif test "X$arg" = "X-lc_r"; then
1582382ff0afSmrg	 case $host in
1583382ff0afSmrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
1584382ff0afSmrg	   # Do not include libc_r directly, use -pthread flag.
1585382ff0afSmrg	   continue
1586382ff0afSmrg	   ;;
1587382ff0afSmrg	 esac
1588382ff0afSmrg	fi
1589382ff0afSmrg	deplibs="$deplibs $arg"
1590382ff0afSmrg	continue
1591382ff0afSmrg	;;
1592382ff0afSmrg
1593382ff0afSmrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
1594382ff0afSmrg      # classes, name mangling, and exception handling.
1595382ff0afSmrg      -model)
1596382ff0afSmrg	compile_command="$compile_command $arg"
1597382ff0afSmrg	compiler_flags="$compiler_flags $arg"
1598382ff0afSmrg	finalize_command="$finalize_command $arg"
1599382ff0afSmrg	prev=xcompiler
1600382ff0afSmrg	continue
1601382ff0afSmrg	;;
1602382ff0afSmrg
1603382ff0afSmrg     -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
1604382ff0afSmrg	compiler_flags="$compiler_flags $arg"
1605382ff0afSmrg	compile_command="$compile_command $arg"
1606382ff0afSmrg	finalize_command="$finalize_command $arg"
1607382ff0afSmrg	continue
1608382ff0afSmrg	;;
1609382ff0afSmrg
1610382ff0afSmrg      -module)
1611382ff0afSmrg	module=yes
1612382ff0afSmrg	continue
1613382ff0afSmrg	;;
1614382ff0afSmrg
1615382ff0afSmrg      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
1616382ff0afSmrg      # -r[0-9][0-9]* specifies the processor on the SGI compiler
1617382ff0afSmrg      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
1618382ff0afSmrg      # +DA*, +DD* enable 64-bit mode on the HP compiler
1619382ff0afSmrg      # -q* pass through compiler args for the IBM compiler
1620382ff0afSmrg      # -m* pass through architecture-specific compiler args for GCC
1621382ff0afSmrg      # -m*, -t[45]*, -txscale* pass through architecture-specific
1622382ff0afSmrg      # compiler args for GCC
1623382ff0afSmrg      # -pg pass through profiling flag for GCC
1624382ff0afSmrg      # @file GCC response files
1625382ff0afSmrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*|-pg| \
1626382ff0afSmrg      -t[45]*|-txscale*|@*)
1627382ff0afSmrg
1628382ff0afSmrg	# Unknown arguments in both finalize_command and compile_command need
1629382ff0afSmrg	# to be aesthetically quoted because they are evaled later.
1630382ff0afSmrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1631382ff0afSmrg	case $arg in
1632382ff0afSmrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1633382ff0afSmrg	  arg="\"$arg\""
1634382ff0afSmrg	  ;;
1635382ff0afSmrg	esac
1636382ff0afSmrg        compile_command="$compile_command $arg"
1637382ff0afSmrg        finalize_command="$finalize_command $arg"
1638382ff0afSmrg        compiler_flags="$compiler_flags $arg"
1639382ff0afSmrg        continue
1640382ff0afSmrg        ;;
1641382ff0afSmrg
1642382ff0afSmrg      -shrext)
1643382ff0afSmrg	prev=shrext
1644382ff0afSmrg	continue
1645382ff0afSmrg	;;
1646382ff0afSmrg
1647382ff0afSmrg      -no-fast-install)
1648382ff0afSmrg	fast_install=no
1649382ff0afSmrg	continue
1650382ff0afSmrg	;;
1651382ff0afSmrg
1652382ff0afSmrg      -no-install)
1653382ff0afSmrg	case $host in
1654382ff0afSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
1655382ff0afSmrg	  # The PATH hackery in wrapper scripts is required on Windows
1656382ff0afSmrg	  # in order for the loader to find any dlls it needs.
1657382ff0afSmrg	  $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
1658382ff0afSmrg	  $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
1659382ff0afSmrg	  fast_install=no
1660382ff0afSmrg	  ;;
1661382ff0afSmrg	*) no_install=yes ;;
1662382ff0afSmrg	esac
1663382ff0afSmrg	continue
1664382ff0afSmrg	;;
1665382ff0afSmrg
1666382ff0afSmrg      -no-undefined)
1667382ff0afSmrg	allow_undefined=no
1668382ff0afSmrg	continue
1669382ff0afSmrg	;;
1670382ff0afSmrg
1671382ff0afSmrg      -objectlist)
1672382ff0afSmrg	prev=objectlist
1673382ff0afSmrg	continue
1674382ff0afSmrg	;;
1675382ff0afSmrg
1676382ff0afSmrg      -o) prev=output ;;
1677382ff0afSmrg
1678382ff0afSmrg      -precious-files-regex)
1679382ff0afSmrg	prev=precious_regex
1680382ff0afSmrg	continue
1681382ff0afSmrg	;;
1682382ff0afSmrg
1683382ff0afSmrg      -release)
1684382ff0afSmrg	prev=release
1685382ff0afSmrg	continue
1686382ff0afSmrg	;;
1687382ff0afSmrg
1688382ff0afSmrg      -rpath)
1689382ff0afSmrg	prev=rpath
1690382ff0afSmrg	continue
1691382ff0afSmrg	;;
1692382ff0afSmrg
1693382ff0afSmrg      -R)
1694382ff0afSmrg	prev=xrpath
1695382ff0afSmrg	continue
1696382ff0afSmrg	;;
1697382ff0afSmrg
1698382ff0afSmrg      -R*)
1699382ff0afSmrg	dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
1700382ff0afSmrg	# We need an absolute path.
1701382ff0afSmrg	case $dir in
1702382ff0afSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
1703382ff0afSmrg	*)
1704382ff0afSmrg	  $echo "$modename: only absolute run-paths are allowed" 1>&2
1705382ff0afSmrg	  exit $EXIT_FAILURE
1706382ff0afSmrg	  ;;
1707382ff0afSmrg	esac
1708382ff0afSmrg	case "$xrpath " in
1709382ff0afSmrg	*" $dir "*) ;;
1710382ff0afSmrg	*) xrpath="$xrpath $dir" ;;
1711382ff0afSmrg	esac
1712382ff0afSmrg	continue
1713382ff0afSmrg	;;
1714382ff0afSmrg
1715382ff0afSmrg      -static)
1716382ff0afSmrg	# The effects of -static are defined in a previous loop.
1717382ff0afSmrg	# We used to do the same as -all-static on platforms that
1718382ff0afSmrg	# didn't have a PIC flag, but the assumption that the effects
1719382ff0afSmrg	# would be equivalent was wrong.  It would break on at least
1720382ff0afSmrg	# Digital Unix and AIX.
1721382ff0afSmrg	continue
1722382ff0afSmrg	;;
1723382ff0afSmrg
1724382ff0afSmrg      -thread-safe)
1725382ff0afSmrg	thread_safe=yes
1726382ff0afSmrg	continue
1727382ff0afSmrg	;;
1728382ff0afSmrg
1729382ff0afSmrg      -version-info)
1730382ff0afSmrg	prev=vinfo
1731382ff0afSmrg	continue
1732382ff0afSmrg	;;
1733382ff0afSmrg      -version-number)
1734382ff0afSmrg	prev=vinfo
1735382ff0afSmrg	vinfo_number=yes
1736382ff0afSmrg	continue
1737382ff0afSmrg	;;
1738382ff0afSmrg
1739382ff0afSmrg      -Wc,*)
1740382ff0afSmrg	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
1741382ff0afSmrg	arg=
1742382ff0afSmrg	save_ifs="$IFS"; IFS=','
1743382ff0afSmrg	for flag in $args; do
1744382ff0afSmrg	  IFS="$save_ifs"
1745382ff0afSmrg	  case $flag in
1746382ff0afSmrg	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1747382ff0afSmrg	    flag="\"$flag\""
1748382ff0afSmrg	    ;;
1749382ff0afSmrg	  esac
1750382ff0afSmrg	  arg="$arg $wl$flag"
1751382ff0afSmrg	  compiler_flags="$compiler_flags $flag"
1752382ff0afSmrg	done
1753382ff0afSmrg	IFS="$save_ifs"
1754382ff0afSmrg	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
1755382ff0afSmrg	;;
1756382ff0afSmrg
1757382ff0afSmrg      -Wl,*)
1758382ff0afSmrg	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
1759382ff0afSmrg	arg=
1760382ff0afSmrg	save_ifs="$IFS"; IFS=','
1761382ff0afSmrg	for flag in $args; do
1762382ff0afSmrg	  IFS="$save_ifs"
1763382ff0afSmrg	  case $flag in
1764382ff0afSmrg	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1765382ff0afSmrg	    flag="\"$flag\""
1766382ff0afSmrg	    ;;
1767382ff0afSmrg	  esac
1768382ff0afSmrg	  arg="$arg $wl$flag"
1769382ff0afSmrg	  compiler_flags="$compiler_flags $wl$flag"
1770382ff0afSmrg	  linker_flags="$linker_flags $flag"
1771382ff0afSmrg	done
1772382ff0afSmrg	IFS="$save_ifs"
1773382ff0afSmrg	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
1774382ff0afSmrg	;;
1775382ff0afSmrg
1776382ff0afSmrg      -Xcompiler)
1777382ff0afSmrg	prev=xcompiler
1778382ff0afSmrg	continue
1779382ff0afSmrg	;;
1780382ff0afSmrg
1781382ff0afSmrg      -Xlinker)
1782382ff0afSmrg	prev=xlinker
1783382ff0afSmrg	continue
1784382ff0afSmrg	;;
1785382ff0afSmrg
1786382ff0afSmrg      -XCClinker)
1787382ff0afSmrg	prev=xcclinker
1788382ff0afSmrg	continue
1789382ff0afSmrg	;;
1790382ff0afSmrg
1791382ff0afSmrg      # Some other compiler flag.
1792382ff0afSmrg      -* | +*)
1793382ff0afSmrg	# Unknown arguments in both finalize_command and compile_command need
1794382ff0afSmrg	# to be aesthetically quoted because they are evaled later.
1795382ff0afSmrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1796382ff0afSmrg	case $arg in
1797382ff0afSmrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1798382ff0afSmrg	  arg="\"$arg\""
1799382ff0afSmrg	  ;;
1800382ff0afSmrg	esac
1801382ff0afSmrg	;;
1802382ff0afSmrg
1803382ff0afSmrg      *.$objext)
1804382ff0afSmrg	# A standard object.
1805382ff0afSmrg	objs="$objs $arg"
1806382ff0afSmrg	;;
1807382ff0afSmrg
1808382ff0afSmrg      *.lo)
1809382ff0afSmrg	# A libtool-controlled object.
1810382ff0afSmrg
1811382ff0afSmrg	# Check to see that this really is a libtool object.
1812382ff0afSmrg	if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
1813382ff0afSmrg	  pic_object=
1814382ff0afSmrg	  non_pic_object=
1815382ff0afSmrg
1816382ff0afSmrg	  # Read the .lo file
1817382ff0afSmrg	  # If there is no directory component, then add one.
1818382ff0afSmrg	  case $arg in
1819382ff0afSmrg	  */* | *\\*) . $arg ;;
1820382ff0afSmrg	  *) . ./$arg ;;
1821382ff0afSmrg	  esac
1822382ff0afSmrg
1823382ff0afSmrg	  if test -z "$pic_object" || \
1824382ff0afSmrg	     test -z "$non_pic_object" ||
1825382ff0afSmrg	     test "$pic_object" = none && \
1826382ff0afSmrg	     test "$non_pic_object" = none; then
1827382ff0afSmrg	    $echo "$modename: cannot find name of object for \`$arg'" 1>&2
1828382ff0afSmrg	    exit $EXIT_FAILURE
1829382ff0afSmrg	  fi
1830382ff0afSmrg
1831382ff0afSmrg	  # Extract subdirectory from the argument.
1832382ff0afSmrg	  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1833382ff0afSmrg	  if test "X$xdir" = "X$arg"; then
1834382ff0afSmrg	    xdir=
1835382ff0afSmrg 	  else
1836382ff0afSmrg	    xdir="$xdir/"
1837382ff0afSmrg	  fi
1838382ff0afSmrg
1839382ff0afSmrg	  if test "$pic_object" != none; then
1840382ff0afSmrg	    # Prepend the subdirectory the object is found in.
1841382ff0afSmrg	    pic_object="$xdir$pic_object"
1842382ff0afSmrg
1843382ff0afSmrg	    if test "$prev" = dlfiles; then
1844382ff0afSmrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
1845382ff0afSmrg		dlfiles="$dlfiles $pic_object"
1846382ff0afSmrg		prev=
1847382ff0afSmrg		continue
1848382ff0afSmrg	      else
1849382ff0afSmrg		# If libtool objects are unsupported, then we need to preload.
1850382ff0afSmrg		prev=dlprefiles
1851382ff0afSmrg	      fi
1852382ff0afSmrg	    fi
1853382ff0afSmrg
1854382ff0afSmrg	    # CHECK ME:  I think I busted this.  -Ossama
1855382ff0afSmrg	    if test "$prev" = dlprefiles; then
1856382ff0afSmrg	      # Preload the old-style object.
1857382ff0afSmrg	      dlprefiles="$dlprefiles $pic_object"
1858382ff0afSmrg	      prev=
1859382ff0afSmrg	    fi
1860382ff0afSmrg
1861382ff0afSmrg	    # A PIC object.
1862382ff0afSmrg	    libobjs="$libobjs $pic_object"
1863382ff0afSmrg	    arg="$pic_object"
1864382ff0afSmrg	  fi
1865382ff0afSmrg
1866382ff0afSmrg	  # Non-PIC object.
1867382ff0afSmrg	  if test "$non_pic_object" != none; then
1868382ff0afSmrg	    # Prepend the subdirectory the object is found in.
1869382ff0afSmrg	    non_pic_object="$xdir$non_pic_object"
1870382ff0afSmrg
1871382ff0afSmrg	    # A standard non-PIC object
1872382ff0afSmrg	    non_pic_objects="$non_pic_objects $non_pic_object"
1873382ff0afSmrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
1874382ff0afSmrg	      arg="$non_pic_object"
1875382ff0afSmrg	    fi
1876382ff0afSmrg	  else
1877382ff0afSmrg	    # If the PIC object exists, use it instead.
1878382ff0afSmrg	    # $xdir was prepended to $pic_object above.
1879382ff0afSmrg	    non_pic_object="$pic_object"
1880382ff0afSmrg	    non_pic_objects="$non_pic_objects $non_pic_object"
1881382ff0afSmrg	  fi
1882382ff0afSmrg	else
1883382ff0afSmrg	  # Only an error if not doing a dry-run.
1884382ff0afSmrg	  if test -z "$run"; then
1885382ff0afSmrg	    $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
1886382ff0afSmrg	    exit $EXIT_FAILURE
1887382ff0afSmrg	  else
1888382ff0afSmrg	    # Dry-run case.
1889382ff0afSmrg
1890382ff0afSmrg	    # Extract subdirectory from the argument.
1891382ff0afSmrg	    xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1892382ff0afSmrg	    if test "X$xdir" = "X$arg"; then
1893382ff0afSmrg	      xdir=
1894382ff0afSmrg	    else
1895382ff0afSmrg	      xdir="$xdir/"
1896382ff0afSmrg	    fi
1897382ff0afSmrg
1898382ff0afSmrg	    pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
1899382ff0afSmrg	    non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
1900382ff0afSmrg	    libobjs="$libobjs $pic_object"
1901382ff0afSmrg	    non_pic_objects="$non_pic_objects $non_pic_object"
1902382ff0afSmrg	  fi
1903382ff0afSmrg	fi
1904382ff0afSmrg	;;
1905382ff0afSmrg
1906382ff0afSmrg      *.$libext)
1907382ff0afSmrg	# An archive.
1908382ff0afSmrg	deplibs="$deplibs $arg"
1909382ff0afSmrg	old_deplibs="$old_deplibs $arg"
1910382ff0afSmrg	continue
1911382ff0afSmrg	;;
1912382ff0afSmrg
1913382ff0afSmrg      *.la)
1914382ff0afSmrg	# A libtool-controlled library.
1915382ff0afSmrg
1916382ff0afSmrg	if test "$prev" = dlfiles; then
1917382ff0afSmrg	  # This library was specified with -dlopen.
1918382ff0afSmrg	  dlfiles="$dlfiles $arg"
1919382ff0afSmrg	  prev=
1920382ff0afSmrg	elif test "$prev" = dlprefiles; then
1921382ff0afSmrg	  # The library was specified with -dlpreopen.
1922382ff0afSmrg	  dlprefiles="$dlprefiles $arg"
1923382ff0afSmrg	  prev=
1924382ff0afSmrg	else
1925382ff0afSmrg	  deplibs="$deplibs $arg"
1926382ff0afSmrg	fi
1927382ff0afSmrg	continue
1928382ff0afSmrg	;;
1929382ff0afSmrg
1930382ff0afSmrg      # Some other compiler argument.
1931382ff0afSmrg      *)
1932382ff0afSmrg	# Unknown arguments in both finalize_command and compile_command need
1933382ff0afSmrg	# to be aesthetically quoted because they are evaled later.
1934382ff0afSmrg	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1935382ff0afSmrg	case $arg in
1936382ff0afSmrg	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1937382ff0afSmrg	  arg="\"$arg\""
1938382ff0afSmrg	  ;;
1939382ff0afSmrg	esac
1940382ff0afSmrg	;;
1941382ff0afSmrg      esac # arg
1942382ff0afSmrg
1943382ff0afSmrg      # Now actually substitute the argument into the commands.
1944382ff0afSmrg      if test -n "$arg"; then
1945382ff0afSmrg	compile_command="$compile_command $arg"
1946382ff0afSmrg	finalize_command="$finalize_command $arg"
1947382ff0afSmrg      fi
1948382ff0afSmrg    done # argument parsing loop
1949382ff0afSmrg
1950382ff0afSmrg    if test -n "$prev"; then
1951382ff0afSmrg      $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
1952382ff0afSmrg      $echo "$help" 1>&2
1953382ff0afSmrg      exit $EXIT_FAILURE
1954382ff0afSmrg    fi
1955382ff0afSmrg
1956382ff0afSmrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
1957382ff0afSmrg      eval arg=\"$export_dynamic_flag_spec\"
1958382ff0afSmrg      compile_command="$compile_command $arg"
1959382ff0afSmrg      finalize_command="$finalize_command $arg"
1960382ff0afSmrg    fi
1961382ff0afSmrg
1962382ff0afSmrg    oldlibs=
1963382ff0afSmrg    # calculate the name of the file, without its directory
1964382ff0afSmrg    outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
1965382ff0afSmrg    libobjs_save="$libobjs"
1966382ff0afSmrg
1967382ff0afSmrg    if test -n "$shlibpath_var"; then
1968382ff0afSmrg      # get the directories listed in $shlibpath_var
1969382ff0afSmrg      eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
1970382ff0afSmrg    else
1971382ff0afSmrg      shlib_search_path=
1972382ff0afSmrg    fi
1973382ff0afSmrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
1974382ff0afSmrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
1975382ff0afSmrg
1976382ff0afSmrg    output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
1977382ff0afSmrg    if test "X$output_objdir" = "X$output"; then
1978382ff0afSmrg      output_objdir="$objdir"
1979382ff0afSmrg    else
1980382ff0afSmrg      output_objdir="$output_objdir/$objdir"
1981382ff0afSmrg    fi
1982382ff0afSmrg    # Create the object directory.
1983382ff0afSmrg    if test ! -d "$output_objdir"; then
1984382ff0afSmrg      $show "$mkdir $output_objdir"
1985382ff0afSmrg      $run $mkdir $output_objdir
1986382ff0afSmrg      exit_status=$?
1987382ff0afSmrg      if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then
1988382ff0afSmrg	exit $exit_status
1989382ff0afSmrg      fi
1990382ff0afSmrg    fi
1991382ff0afSmrg
1992382ff0afSmrg    # Determine the type of output
1993382ff0afSmrg    case $output in
1994382ff0afSmrg    "")
1995382ff0afSmrg      $echo "$modename: you must specify an output file" 1>&2
1996382ff0afSmrg      $echo "$help" 1>&2
1997382ff0afSmrg      exit $EXIT_FAILURE
1998382ff0afSmrg      ;;
1999382ff0afSmrg    *.$libext) linkmode=oldlib ;;
2000382ff0afSmrg    *.lo | *.$objext) linkmode=obj ;;
2001382ff0afSmrg    *.la) linkmode=lib ;;
2002382ff0afSmrg    *) linkmode=prog ;; # Anything else should be a program.
2003382ff0afSmrg    esac
2004382ff0afSmrg
2005382ff0afSmrg    case $host in
2006382ff0afSmrg    *cygwin* | *mingw* | *pw32*)
2007382ff0afSmrg      # don't eliminate duplications in $postdeps and $predeps
2008382ff0afSmrg      duplicate_compiler_generated_deps=yes
2009382ff0afSmrg      ;;
2010382ff0afSmrg    *)
2011382ff0afSmrg      duplicate_compiler_generated_deps=$duplicate_deps
2012382ff0afSmrg      ;;
2013382ff0afSmrg    esac
2014382ff0afSmrg    specialdeplibs=
2015382ff0afSmrg
2016382ff0afSmrg    libs=
2017382ff0afSmrg    # Find all interdependent deplibs by searching for libraries
2018382ff0afSmrg    # that are linked more than once (e.g. -la -lb -la)
2019382ff0afSmrg    for deplib in $deplibs; do
2020382ff0afSmrg      if test "X$duplicate_deps" = "Xyes" ; then
2021382ff0afSmrg	case "$libs " in
2022382ff0afSmrg	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2023382ff0afSmrg	esac
2024382ff0afSmrg      fi
2025382ff0afSmrg      libs="$libs $deplib"
2026382ff0afSmrg    done
2027382ff0afSmrg
2028382ff0afSmrg    if test "$linkmode" = lib; then
2029382ff0afSmrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
2030382ff0afSmrg
2031382ff0afSmrg      # Compute libraries that are listed more than once in $predeps
2032382ff0afSmrg      # $postdeps and mark them as special (i.e., whose duplicates are
2033382ff0afSmrg      # not to be eliminated).
2034382ff0afSmrg      pre_post_deps=
2035382ff0afSmrg      if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
2036382ff0afSmrg	for pre_post_dep in $predeps $postdeps; do
2037382ff0afSmrg	  case "$pre_post_deps " in
2038382ff0afSmrg	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
2039382ff0afSmrg	  esac
2040382ff0afSmrg	  pre_post_deps="$pre_post_deps $pre_post_dep"
2041382ff0afSmrg	done
2042382ff0afSmrg      fi
2043382ff0afSmrg      pre_post_deps=
2044382ff0afSmrg    fi
2045382ff0afSmrg
2046382ff0afSmrg    deplibs=
2047382ff0afSmrg    newdependency_libs=
2048382ff0afSmrg    newlib_search_path=
2049382ff0afSmrg    need_relink=no # whether we're linking any uninstalled libtool libraries
2050382ff0afSmrg    notinst_deplibs= # not-installed libtool libraries
2051382ff0afSmrg    case $linkmode in
2052382ff0afSmrg    lib)
2053382ff0afSmrg	passes="conv link"
2054382ff0afSmrg	for file in $dlfiles $dlprefiles; do
2055382ff0afSmrg	  case $file in
2056382ff0afSmrg	  *.la) ;;
2057382ff0afSmrg	  *)
2058382ff0afSmrg	    $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
2059382ff0afSmrg	    exit $EXIT_FAILURE
2060382ff0afSmrg	    ;;
2061382ff0afSmrg	  esac
2062382ff0afSmrg	done
2063382ff0afSmrg	;;
2064382ff0afSmrg    prog)
2065382ff0afSmrg	compile_deplibs=
2066382ff0afSmrg	finalize_deplibs=
2067382ff0afSmrg	alldeplibs=no
2068382ff0afSmrg	newdlfiles=
2069382ff0afSmrg	newdlprefiles=
2070382ff0afSmrg	passes="conv scan dlopen dlpreopen link"
2071382ff0afSmrg	;;
2072382ff0afSmrg    *)  passes="conv"
2073382ff0afSmrg	;;
2074382ff0afSmrg    esac
2075382ff0afSmrg    for pass in $passes; do
2076382ff0afSmrg      if test "$linkmode,$pass" = "lib,link" ||
2077382ff0afSmrg	 test "$linkmode,$pass" = "prog,scan"; then
2078382ff0afSmrg	libs="$deplibs"
2079382ff0afSmrg	deplibs=
2080382ff0afSmrg      fi
2081382ff0afSmrg      if test "$linkmode" = prog; then
2082382ff0afSmrg	case $pass in
2083382ff0afSmrg	dlopen) libs="$dlfiles" ;;
2084382ff0afSmrg	dlpreopen) libs="$dlprefiles" ;;
2085382ff0afSmrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
2086382ff0afSmrg	esac
2087382ff0afSmrg      fi
2088382ff0afSmrg      if test "$pass" = dlopen; then
2089382ff0afSmrg	# Collect dlpreopened libraries
2090382ff0afSmrg	save_deplibs="$deplibs"
2091382ff0afSmrg	deplibs=
2092382ff0afSmrg      fi
2093382ff0afSmrg      for deplib in $libs; do
2094382ff0afSmrg	lib=
2095382ff0afSmrg	found=no
2096382ff0afSmrg	case $deplib in
2097382ff0afSmrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
2098382ff0afSmrg	  if test "$linkmode,$pass" = "prog,link"; then
2099382ff0afSmrg	    compile_deplibs="$deplib $compile_deplibs"
2100382ff0afSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
2101382ff0afSmrg	  else
2102382ff0afSmrg	    compiler_flags="$compiler_flags $deplib"
2103382ff0afSmrg	  fi
2104382ff0afSmrg	  continue
2105382ff0afSmrg	  ;;
2106382ff0afSmrg	-l*)
2107382ff0afSmrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
2108382ff0afSmrg	    $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
2109382ff0afSmrg	    continue
2110382ff0afSmrg	  fi
2111382ff0afSmrg	  name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
2112382ff0afSmrg	  for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
2113382ff0afSmrg	    for search_ext in .la $std_shrext .so .a; do
2114382ff0afSmrg	      # Search the libtool library
2115382ff0afSmrg	      lib="$searchdir/lib${name}${search_ext}"
2116382ff0afSmrg	      if test -f "$lib"; then
2117382ff0afSmrg		if test "$search_ext" = ".la"; then
2118382ff0afSmrg		  found=yes
2119382ff0afSmrg		else
2120382ff0afSmrg		  found=no
2121382ff0afSmrg		fi
2122382ff0afSmrg		break 2
2123382ff0afSmrg	      fi
2124382ff0afSmrg	    done
2125382ff0afSmrg	  done
2126382ff0afSmrg	  if test "$found" != yes; then
2127382ff0afSmrg	    # deplib doesn't seem to be a libtool library
2128382ff0afSmrg	    if test "$linkmode,$pass" = "prog,link"; then
2129382ff0afSmrg	      compile_deplibs="$deplib $compile_deplibs"
2130382ff0afSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
2131382ff0afSmrg	    else
2132382ff0afSmrg	      deplibs="$deplib $deplibs"
2133382ff0afSmrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
2134382ff0afSmrg	    fi
2135382ff0afSmrg	    continue
2136382ff0afSmrg	  else # deplib is a libtool library
2137382ff0afSmrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
2138382ff0afSmrg	    # We need to do some special things here, and not later.
2139382ff0afSmrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
2140382ff0afSmrg	      case " $predeps $postdeps " in
2141382ff0afSmrg	      *" $deplib "*)
2142382ff0afSmrg		if (${SED} -e '2q' $lib |
2143382ff0afSmrg                    grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
2144382ff0afSmrg		  library_names=
2145382ff0afSmrg		  old_library=
2146382ff0afSmrg		  case $lib in
2147382ff0afSmrg		  */* | *\\*) . $lib ;;
2148382ff0afSmrg		  *) . ./$lib ;;
2149382ff0afSmrg		  esac
2150382ff0afSmrg		  for l in $old_library $library_names; do
2151382ff0afSmrg		    ll="$l"
2152382ff0afSmrg		  done
2153382ff0afSmrg		  if test "X$ll" = "X$old_library" ; then # only static version available
2154382ff0afSmrg		    found=no
2155382ff0afSmrg		    ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
2156382ff0afSmrg		    test "X$ladir" = "X$lib" && ladir="."
2157382ff0afSmrg		    lib=$ladir/$old_library
2158382ff0afSmrg		    if test "$linkmode,$pass" = "prog,link"; then
2159382ff0afSmrg		      compile_deplibs="$deplib $compile_deplibs"
2160382ff0afSmrg		      finalize_deplibs="$deplib $finalize_deplibs"
2161382ff0afSmrg		    else
2162382ff0afSmrg		      deplibs="$deplib $deplibs"
2163382ff0afSmrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
2164382ff0afSmrg		    fi
2165382ff0afSmrg		    continue
2166382ff0afSmrg		  fi
2167382ff0afSmrg		fi
2168382ff0afSmrg	        ;;
2169382ff0afSmrg	      *) ;;
2170382ff0afSmrg	      esac
2171382ff0afSmrg	    fi
2172382ff0afSmrg	  fi
2173382ff0afSmrg	  ;; # -l
2174382ff0afSmrg	-L*)
2175382ff0afSmrg	  case $linkmode in
2176382ff0afSmrg	  lib)
2177382ff0afSmrg	    deplibs="$deplib $deplibs"
2178382ff0afSmrg	    test "$pass" = conv && continue
2179382ff0afSmrg	    newdependency_libs="$deplib $newdependency_libs"
2180382ff0afSmrg	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
2181382ff0afSmrg	    ;;
2182382ff0afSmrg	  prog)
2183382ff0afSmrg	    if test "$pass" = conv; then
2184382ff0afSmrg	      deplibs="$deplib $deplibs"
2185382ff0afSmrg	      continue
2186382ff0afSmrg	    fi
2187382ff0afSmrg	    if test "$pass" = scan; then
2188382ff0afSmrg	      deplibs="$deplib $deplibs"
2189382ff0afSmrg	    else
2190382ff0afSmrg	      compile_deplibs="$deplib $compile_deplibs"
2191382ff0afSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
2192382ff0afSmrg	    fi
2193382ff0afSmrg	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
2194382ff0afSmrg	    ;;
2195382ff0afSmrg	  *)
2196382ff0afSmrg	    $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
2197382ff0afSmrg	    ;;
2198382ff0afSmrg	  esac # linkmode
2199382ff0afSmrg	  continue
2200382ff0afSmrg	  ;; # -L
2201382ff0afSmrg	-R*)
2202382ff0afSmrg	  if test "$pass" = link; then
2203382ff0afSmrg	    dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
2204382ff0afSmrg	    # Make sure the xrpath contains only unique directories.
2205382ff0afSmrg	    case "$xrpath " in
2206382ff0afSmrg	    *" $dir "*) ;;
2207382ff0afSmrg	    *) xrpath="$xrpath $dir" ;;
2208382ff0afSmrg	    esac
2209382ff0afSmrg	  fi
2210382ff0afSmrg	  deplibs="$deplib $deplibs"
2211382ff0afSmrg	  continue
2212382ff0afSmrg	  ;;
2213382ff0afSmrg	*.la) lib="$deplib" ;;
2214382ff0afSmrg	*.$libext)
2215382ff0afSmrg	  if test "$pass" = conv; then
2216382ff0afSmrg	    deplibs="$deplib $deplibs"
2217382ff0afSmrg	    continue
2218382ff0afSmrg	  fi
2219382ff0afSmrg	  case $linkmode in
2220382ff0afSmrg	  lib)
2221382ff0afSmrg	    valid_a_lib=no
2222382ff0afSmrg	    case $deplibs_check_method in
2223382ff0afSmrg	      match_pattern*)
2224382ff0afSmrg		set dummy $deplibs_check_method
2225382ff0afSmrg	        match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
2226382ff0afSmrg		if eval $echo \"$deplib\" 2>/dev/null \
2227382ff0afSmrg		    | $SED 10q \
2228382ff0afSmrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
2229382ff0afSmrg		  valid_a_lib=yes
2230382ff0afSmrg		fi
2231382ff0afSmrg		;;
2232382ff0afSmrg	      pass_all)
2233382ff0afSmrg		valid_a_lib=yes
2234382ff0afSmrg		;;
2235382ff0afSmrg            esac
2236382ff0afSmrg	    if test "$valid_a_lib" != yes; then
2237382ff0afSmrg	      $echo
2238382ff0afSmrg	      $echo "*** Warning: Trying to link with static lib archive $deplib."
2239382ff0afSmrg	      $echo "*** I have the capability to make that library automatically link in when"
2240382ff0afSmrg	      $echo "*** you link to this library.  But I can only do this if you have a"
2241382ff0afSmrg	      $echo "*** shared version of the library, which you do not appear to have"
2242382ff0afSmrg	      $echo "*** because the file extensions .$libext of this argument makes me believe"
2243382ff0afSmrg	      $echo "*** that it is just a static archive that I should not used here."
2244382ff0afSmrg	    else
2245382ff0afSmrg	      $echo
2246382ff0afSmrg	      $echo "*** Warning: Linking the shared library $output against the"
2247382ff0afSmrg	      $echo "*** static library $deplib is not portable!"
2248382ff0afSmrg	      deplibs="$deplib $deplibs"
2249382ff0afSmrg	    fi
2250382ff0afSmrg	    continue
2251382ff0afSmrg	    ;;
2252382ff0afSmrg	  prog)
2253382ff0afSmrg	    if test "$pass" != link; then
2254382ff0afSmrg	      deplibs="$deplib $deplibs"
2255382ff0afSmrg	    else
2256382ff0afSmrg	      compile_deplibs="$deplib $compile_deplibs"
2257382ff0afSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
2258382ff0afSmrg	    fi
2259382ff0afSmrg	    continue
2260382ff0afSmrg	    ;;
2261382ff0afSmrg	  esac # linkmode
2262382ff0afSmrg	  ;; # *.$libext
2263382ff0afSmrg	*.lo | *.$objext)
2264382ff0afSmrg	  if test "$pass" = conv; then
2265382ff0afSmrg	    deplibs="$deplib $deplibs"
2266382ff0afSmrg	  elif test "$linkmode" = prog; then
2267382ff0afSmrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
2268382ff0afSmrg	      # If there is no dlopen support or we're linking statically,
2269382ff0afSmrg	      # we need to preload.
2270382ff0afSmrg	      newdlprefiles="$newdlprefiles $deplib"
2271382ff0afSmrg	      compile_deplibs="$deplib $compile_deplibs"
2272382ff0afSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
2273382ff0afSmrg	    else
2274382ff0afSmrg	      newdlfiles="$newdlfiles $deplib"
2275382ff0afSmrg	    fi
2276382ff0afSmrg	  fi
2277382ff0afSmrg	  continue
2278382ff0afSmrg	  ;;
2279382ff0afSmrg	%DEPLIBS%)
2280382ff0afSmrg	  alldeplibs=yes
2281382ff0afSmrg	  continue
2282382ff0afSmrg	  ;;
2283382ff0afSmrg	esac # case $deplib
2284382ff0afSmrg	if test "$found" = yes || test -f "$lib"; then :
2285382ff0afSmrg	else
2286382ff0afSmrg	  $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2
2287382ff0afSmrg	  exit $EXIT_FAILURE
2288382ff0afSmrg	fi
2289382ff0afSmrg
2290382ff0afSmrg	# Check to see that this really is a libtool archive.
2291382ff0afSmrg	if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
2292382ff0afSmrg	else
2293382ff0afSmrg	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
2294382ff0afSmrg	  exit $EXIT_FAILURE
2295382ff0afSmrg	fi
2296382ff0afSmrg
2297382ff0afSmrg	ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
2298382ff0afSmrg	test "X$ladir" = "X$lib" && ladir="."
2299382ff0afSmrg
2300382ff0afSmrg	dlname=
2301382ff0afSmrg	dlopen=
2302382ff0afSmrg	dlpreopen=
2303382ff0afSmrg	libdir=
2304382ff0afSmrg	library_names=
2305382ff0afSmrg	old_library=
2306382ff0afSmrg	# If the library was installed with an old release of libtool,
2307382ff0afSmrg	# it will not redefine variables installed, or shouldnotlink
2308382ff0afSmrg	installed=yes
2309382ff0afSmrg	shouldnotlink=no
2310382ff0afSmrg	avoidtemprpath=
2311382ff0afSmrg
2312382ff0afSmrg
2313382ff0afSmrg	# Read the .la file
2314382ff0afSmrg	case $lib in
2315382ff0afSmrg	*/* | *\\*) . $lib ;;
2316382ff0afSmrg	*) . ./$lib ;;
2317382ff0afSmrg	esac
2318382ff0afSmrg
2319382ff0afSmrg	if test "$linkmode,$pass" = "lib,link" ||
2320382ff0afSmrg	   test "$linkmode,$pass" = "prog,scan" ||
2321382ff0afSmrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
2322382ff0afSmrg	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
2323382ff0afSmrg	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
2324382ff0afSmrg	fi
2325382ff0afSmrg
2326382ff0afSmrg	if test "$pass" = conv; then
2327382ff0afSmrg	  # Only check for convenience libraries
2328382ff0afSmrg	  deplibs="$lib $deplibs"
2329382ff0afSmrg	  if test -z "$libdir"; then
2330382ff0afSmrg	    if test -z "$old_library"; then
2331382ff0afSmrg	      $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
2332382ff0afSmrg	      exit $EXIT_FAILURE
2333382ff0afSmrg	    fi
2334382ff0afSmrg	    # It is a libtool convenience library, so add in its objects.
2335382ff0afSmrg	    convenience="$convenience $ladir/$objdir/$old_library"
2336382ff0afSmrg	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
2337382ff0afSmrg	    tmp_libs=
2338382ff0afSmrg	    for deplib in $dependency_libs; do
2339382ff0afSmrg	      deplibs="$deplib $deplibs"
2340382ff0afSmrg              if test "X$duplicate_deps" = "Xyes" ; then
2341382ff0afSmrg	        case "$tmp_libs " in
2342382ff0afSmrg	        *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2343382ff0afSmrg	        esac
2344382ff0afSmrg              fi
2345382ff0afSmrg	      tmp_libs="$tmp_libs $deplib"
2346382ff0afSmrg	    done
2347382ff0afSmrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
2348382ff0afSmrg	    $echo "$modename: \`$lib' is not a convenience library" 1>&2
2349382ff0afSmrg	    exit $EXIT_FAILURE
2350382ff0afSmrg	  fi
2351382ff0afSmrg	  continue
2352382ff0afSmrg	fi # $pass = conv
2353382ff0afSmrg
2354382ff0afSmrg
2355382ff0afSmrg	# Get the name of the library we link against.
2356382ff0afSmrg	linklib=
2357382ff0afSmrg	for l in $old_library $library_names; do
2358382ff0afSmrg	  linklib="$l"
2359382ff0afSmrg	done
2360382ff0afSmrg	if test -z "$linklib"; then
2361382ff0afSmrg	  $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
2362382ff0afSmrg	  exit $EXIT_FAILURE
2363382ff0afSmrg	fi
2364382ff0afSmrg
2365382ff0afSmrg	# This library was specified with -dlopen.
2366382ff0afSmrg	if test "$pass" = dlopen; then
2367382ff0afSmrg	  if test -z "$libdir"; then
2368382ff0afSmrg	    $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
2369382ff0afSmrg	    exit $EXIT_FAILURE
2370382ff0afSmrg	  fi
2371382ff0afSmrg	  if test -z "$dlname" ||
2372382ff0afSmrg	     test "$dlopen_support" != yes ||
2373382ff0afSmrg	     test "$build_libtool_libs" = no; then
2374382ff0afSmrg	    # If there is no dlname, no dlopen support or we're linking
2375382ff0afSmrg	    # statically, we need to preload.  We also need to preload any
2376382ff0afSmrg	    # dependent libraries so libltdl's deplib preloader doesn't
2377382ff0afSmrg	    # bomb out in the load deplibs phase.
2378382ff0afSmrg	    dlprefiles="$dlprefiles $lib $dependency_libs"
2379382ff0afSmrg	  else
2380382ff0afSmrg	    newdlfiles="$newdlfiles $lib"
2381382ff0afSmrg	  fi
2382382ff0afSmrg	  continue
2383382ff0afSmrg	fi # $pass = dlopen
2384382ff0afSmrg
2385382ff0afSmrg	# We need an absolute path.
2386382ff0afSmrg	case $ladir in
2387382ff0afSmrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
2388382ff0afSmrg	*)
2389382ff0afSmrg	  abs_ladir=`cd "$ladir" && pwd`
2390382ff0afSmrg	  if test -z "$abs_ladir"; then
2391382ff0afSmrg	    $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2
2392382ff0afSmrg	    $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
2393382ff0afSmrg	    abs_ladir="$ladir"
2394382ff0afSmrg	  fi
2395382ff0afSmrg	  ;;
2396382ff0afSmrg	esac
2397382ff0afSmrg	laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
2398382ff0afSmrg
2399382ff0afSmrg	# Find the relevant object directory and library name.
2400382ff0afSmrg	if test "X$installed" = Xyes; then
2401382ff0afSmrg	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
2402382ff0afSmrg	    $echo "$modename: warning: library \`$lib' was moved." 1>&2
2403382ff0afSmrg	    dir="$ladir"
2404382ff0afSmrg	    absdir="$abs_ladir"
2405382ff0afSmrg	    libdir="$abs_ladir"
2406382ff0afSmrg	  else
2407382ff0afSmrg	    dir="$libdir"
2408382ff0afSmrg	    absdir="$libdir"
2409382ff0afSmrg	  fi
2410382ff0afSmrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
2411382ff0afSmrg	else
2412382ff0afSmrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
2413382ff0afSmrg	    dir="$ladir"
2414382ff0afSmrg	    absdir="$abs_ladir"
2415382ff0afSmrg	    # Remove this search path later
2416382ff0afSmrg	    notinst_path="$notinst_path $abs_ladir"
2417382ff0afSmrg	  else
2418382ff0afSmrg	    dir="$ladir/$objdir"
2419382ff0afSmrg	    absdir="$abs_ladir/$objdir"
2420382ff0afSmrg	    # Remove this search path later
2421382ff0afSmrg	    notinst_path="$notinst_path $abs_ladir"
2422382ff0afSmrg	  fi
2423382ff0afSmrg	fi # $installed = yes
2424382ff0afSmrg	name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
2425382ff0afSmrg
2426382ff0afSmrg	# This library was specified with -dlpreopen.
2427382ff0afSmrg	if test "$pass" = dlpreopen; then
2428382ff0afSmrg	  if test -z "$libdir"; then
2429382ff0afSmrg	    $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
2430382ff0afSmrg	    exit $EXIT_FAILURE
2431382ff0afSmrg	  fi
2432382ff0afSmrg	  # Prefer using a static library (so that no silly _DYNAMIC symbols
2433382ff0afSmrg	  # are required to link).
2434382ff0afSmrg	  if test -n "$old_library"; then
2435382ff0afSmrg	    newdlprefiles="$newdlprefiles $dir/$old_library"
2436382ff0afSmrg	  # Otherwise, use the dlname, so that lt_dlopen finds it.
2437382ff0afSmrg	  elif test -n "$dlname"; then
2438382ff0afSmrg	    newdlprefiles="$newdlprefiles $dir/$dlname"
2439382ff0afSmrg	  else
2440382ff0afSmrg	    newdlprefiles="$newdlprefiles $dir/$linklib"
2441382ff0afSmrg	  fi
2442382ff0afSmrg	fi # $pass = dlpreopen
2443382ff0afSmrg
2444382ff0afSmrg	if test -z "$libdir"; then
2445382ff0afSmrg	  # Link the convenience library
2446382ff0afSmrg	  if test "$linkmode" = lib; then
2447382ff0afSmrg	    deplibs="$dir/$old_library $deplibs"
2448382ff0afSmrg	  elif test "$linkmode,$pass" = "prog,link"; then
2449382ff0afSmrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
2450382ff0afSmrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
2451382ff0afSmrg	  else
2452382ff0afSmrg	    deplibs="$lib $deplibs" # used for prog,scan pass
2453382ff0afSmrg	  fi
2454382ff0afSmrg	  continue
2455382ff0afSmrg	fi
2456382ff0afSmrg
2457382ff0afSmrg
2458382ff0afSmrg	if test "$linkmode" = prog && test "$pass" != link; then
2459382ff0afSmrg	  newlib_search_path="$newlib_search_path $ladir"
2460382ff0afSmrg	  deplibs="$lib $deplibs"
2461382ff0afSmrg
2462382ff0afSmrg	  linkalldeplibs=no
2463382ff0afSmrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
2464382ff0afSmrg	     test "$build_libtool_libs" = no; then
2465382ff0afSmrg	    linkalldeplibs=yes
2466382ff0afSmrg	  fi
2467382ff0afSmrg
2468382ff0afSmrg	  tmp_libs=
2469382ff0afSmrg	  for deplib in $dependency_libs; do
2470382ff0afSmrg	    case $deplib in
2471382ff0afSmrg	    -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
2472382ff0afSmrg	    esac
2473382ff0afSmrg	    # Need to link against all dependency_libs?
2474382ff0afSmrg	    if test "$linkalldeplibs" = yes; then
2475382ff0afSmrg	      deplibs="$deplib $deplibs"
2476382ff0afSmrg	    else
2477382ff0afSmrg	      # Need to hardcode shared library paths
2478382ff0afSmrg	      # or/and link against static libraries
2479382ff0afSmrg	      newdependency_libs="$deplib $newdependency_libs"
2480382ff0afSmrg	    fi
2481382ff0afSmrg	    if test "X$duplicate_deps" = "Xyes" ; then
2482382ff0afSmrg	      case "$tmp_libs " in
2483382ff0afSmrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2484382ff0afSmrg	      esac
2485382ff0afSmrg	    fi
2486382ff0afSmrg	    tmp_libs="$tmp_libs $deplib"
2487382ff0afSmrg	  done # for deplib
2488382ff0afSmrg	  continue
2489382ff0afSmrg	fi # $linkmode = prog...
2490382ff0afSmrg
2491382ff0afSmrg	if test "$linkmode,$pass" = "prog,link"; then
2492382ff0afSmrg	  if test -n "$library_names" &&
2493382ff0afSmrg	     { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
2494382ff0afSmrg	    # We need to hardcode the library path
2495382ff0afSmrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
2496382ff0afSmrg	      # Make sure the rpath contains only unique directories.
2497382ff0afSmrg	      case "$temp_rpath " in
2498382ff0afSmrg	      *" $dir "*) ;;
2499382ff0afSmrg	      *" $absdir "*) ;;
2500382ff0afSmrg	      *) temp_rpath="$temp_rpath $absdir" ;;
2501382ff0afSmrg	      esac
2502382ff0afSmrg	    fi
2503382ff0afSmrg
2504382ff0afSmrg	    # Hardcode the library path.
2505382ff0afSmrg	    # Skip directories that are in the system default run-time
2506382ff0afSmrg	    # search path.
2507382ff0afSmrg	    case " $sys_lib_dlsearch_path " in
2508382ff0afSmrg	    *" $absdir "*) ;;
2509382ff0afSmrg	    *)
2510382ff0afSmrg	      case "$compile_rpath " in
2511382ff0afSmrg	      *" $absdir "*) ;;
2512382ff0afSmrg	      *) compile_rpath="$compile_rpath $absdir"
2513382ff0afSmrg	      esac
2514382ff0afSmrg	      ;;
2515382ff0afSmrg	    esac
2516382ff0afSmrg	    case " $sys_lib_dlsearch_path " in
2517382ff0afSmrg	    *" $libdir "*) ;;
2518382ff0afSmrg	    *)
2519382ff0afSmrg	      case "$finalize_rpath " in
2520382ff0afSmrg	      *" $libdir "*) ;;
2521382ff0afSmrg	      *) finalize_rpath="$finalize_rpath $libdir"
2522382ff0afSmrg	      esac
2523382ff0afSmrg	      ;;
2524382ff0afSmrg	    esac
2525382ff0afSmrg	  fi # $linkmode,$pass = prog,link...
2526382ff0afSmrg
2527382ff0afSmrg	  if test "$alldeplibs" = yes &&
2528382ff0afSmrg	     { test "$deplibs_check_method" = pass_all ||
2529382ff0afSmrg	       { test "$build_libtool_libs" = yes &&
2530382ff0afSmrg		 test -n "$library_names"; }; }; then
2531382ff0afSmrg	    # We only need to search for static libraries
2532382ff0afSmrg	    continue
2533382ff0afSmrg	  fi
2534382ff0afSmrg	fi
2535382ff0afSmrg
2536382ff0afSmrg	link_static=no # Whether the deplib will be linked statically
2537382ff0afSmrg	use_static_libs=$prefer_static_libs
2538382ff0afSmrg	if test "$use_static_libs" = built && test "$installed" = yes ; then
2539382ff0afSmrg	  use_static_libs=no
2540382ff0afSmrg	fi
2541382ff0afSmrg	if test -n "$library_names" &&
2542382ff0afSmrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
2543382ff0afSmrg	  if test "$installed" = no; then
2544382ff0afSmrg	    notinst_deplibs="$notinst_deplibs $lib"
2545382ff0afSmrg	    need_relink=yes
2546382ff0afSmrg	  fi
2547382ff0afSmrg	  # This is a shared library
2548382ff0afSmrg
2549382ff0afSmrg	  # Warn about portability, can't link against -module's on
2550382ff0afSmrg	  # some systems (darwin)
2551382ff0afSmrg	  if test "$shouldnotlink" = yes && test "$pass" = link ; then
2552382ff0afSmrg	    $echo
2553382ff0afSmrg	    if test "$linkmode" = prog; then
2554382ff0afSmrg	      $echo "*** Warning: Linking the executable $output against the loadable module"
2555382ff0afSmrg	    else
2556382ff0afSmrg	      $echo "*** Warning: Linking the shared library $output against the loadable module"
2557382ff0afSmrg	    fi
2558382ff0afSmrg	    $echo "*** $linklib is not portable!"
2559382ff0afSmrg	  fi
2560382ff0afSmrg	  if test "$linkmode" = lib &&
2561382ff0afSmrg	     test "$hardcode_into_libs" = yes; then
2562382ff0afSmrg	    # Hardcode the library path.
2563382ff0afSmrg	    # Skip directories that are in the system default run-time
2564382ff0afSmrg	    # search path.
2565382ff0afSmrg	    case " $sys_lib_dlsearch_path " in
2566382ff0afSmrg	    *" $absdir "*) ;;
2567382ff0afSmrg	    *)
2568382ff0afSmrg	      case "$compile_rpath " in
2569382ff0afSmrg	      *" $absdir "*) ;;
2570382ff0afSmrg	      *) compile_rpath="$compile_rpath $absdir"
2571382ff0afSmrg	      esac
2572382ff0afSmrg	      ;;
2573382ff0afSmrg	    esac
2574382ff0afSmrg	    case " $sys_lib_dlsearch_path " in
2575382ff0afSmrg	    *" $libdir "*) ;;
2576382ff0afSmrg	    *)
2577382ff0afSmrg	      case "$finalize_rpath " in
2578382ff0afSmrg	      *" $libdir "*) ;;
2579382ff0afSmrg	      *) finalize_rpath="$finalize_rpath $libdir"
2580382ff0afSmrg	      esac
2581382ff0afSmrg	      ;;
2582382ff0afSmrg	    esac
2583382ff0afSmrg	  fi
2584382ff0afSmrg
2585382ff0afSmrg	  if test -n "$old_archive_from_expsyms_cmds"; then
2586382ff0afSmrg	    # figure out the soname
2587382ff0afSmrg	    set dummy $library_names
2588382ff0afSmrg	    realname="$2"
2589382ff0afSmrg	    shift; shift
2590382ff0afSmrg	    libname=`eval \\$echo \"$libname_spec\"`
2591382ff0afSmrg	    # use dlname if we got it. it's perfectly good, no?
2592382ff0afSmrg	    if test -n "$dlname"; then
2593382ff0afSmrg	      soname="$dlname"
2594382ff0afSmrg	    elif test -n "$soname_spec"; then
2595382ff0afSmrg	      # bleh windows
2596382ff0afSmrg	      case $host in
2597382ff0afSmrg	      *cygwin* | mingw*)
2598382ff0afSmrg		major=`expr $current - $age`
2599382ff0afSmrg		versuffix="-$major"
2600382ff0afSmrg		;;
2601382ff0afSmrg	      esac
2602382ff0afSmrg	      eval soname=\"$soname_spec\"
2603382ff0afSmrg	    else
2604382ff0afSmrg	      soname="$realname"
2605382ff0afSmrg	    fi
2606382ff0afSmrg
2607382ff0afSmrg	    # Make a new name for the extract_expsyms_cmds to use
2608382ff0afSmrg	    soroot="$soname"
2609382ff0afSmrg	    soname=`$echo $soroot | ${SED} -e 's/^.*\///'`
2610382ff0afSmrg	    newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
2611382ff0afSmrg
2612382ff0afSmrg	    # If the library has no export list, then create one now
2613382ff0afSmrg	    if test -f "$output_objdir/$soname-def"; then :
2614382ff0afSmrg	    else
2615382ff0afSmrg	      $show "extracting exported symbol list from \`$soname'"
2616382ff0afSmrg	      save_ifs="$IFS"; IFS='~'
2617382ff0afSmrg	      cmds=$extract_expsyms_cmds
2618382ff0afSmrg	      for cmd in $cmds; do
2619382ff0afSmrg		IFS="$save_ifs"
2620382ff0afSmrg		eval cmd=\"$cmd\"
2621382ff0afSmrg		$show "$cmd"
2622382ff0afSmrg		$run eval "$cmd" || exit $?
2623382ff0afSmrg	      done
2624382ff0afSmrg	      IFS="$save_ifs"
2625382ff0afSmrg	    fi
2626382ff0afSmrg
2627382ff0afSmrg	    # Create $newlib
2628382ff0afSmrg	    if test -f "$output_objdir/$newlib"; then :; else
2629382ff0afSmrg	      $show "generating import library for \`$soname'"
2630382ff0afSmrg	      save_ifs="$IFS"; IFS='~'
2631382ff0afSmrg	      cmds=$old_archive_from_expsyms_cmds
2632382ff0afSmrg	      for cmd in $cmds; do
2633382ff0afSmrg		IFS="$save_ifs"
2634382ff0afSmrg		eval cmd=\"$cmd\"
2635382ff0afSmrg		$show "$cmd"
2636382ff0afSmrg		$run eval "$cmd" || exit $?
2637382ff0afSmrg	      done
2638382ff0afSmrg	      IFS="$save_ifs"
2639382ff0afSmrg	    fi
2640382ff0afSmrg	    # make sure the library variables are pointing to the new library
2641382ff0afSmrg	    dir=$output_objdir
2642382ff0afSmrg	    linklib=$newlib
2643382ff0afSmrg	  fi # test -n "$old_archive_from_expsyms_cmds"
2644382ff0afSmrg
2645382ff0afSmrg	  if test "$linkmode" = prog || test "$mode" != relink; then
2646382ff0afSmrg	    add_shlibpath=
2647382ff0afSmrg	    add_dir=
2648382ff0afSmrg	    add=
2649382ff0afSmrg	    lib_linked=yes
2650382ff0afSmrg	    case $hardcode_action in
2651382ff0afSmrg	    immediate | unsupported)
2652382ff0afSmrg	      if test "$hardcode_direct" = no; then
2653382ff0afSmrg		add="$dir/$linklib"
2654382ff0afSmrg		case $host in
2655382ff0afSmrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
2656382ff0afSmrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
2657382ff0afSmrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
2658382ff0afSmrg		    *-*-unixware7*) add_dir="-L$dir" ;;
2659382ff0afSmrg		  *-*-darwin* )
2660382ff0afSmrg		    # if the lib is a module then we can not link against
2661382ff0afSmrg		    # it, someone is ignoring the new warnings I added
2662382ff0afSmrg		    if /usr/bin/file -L $add 2> /dev/null |
2663382ff0afSmrg                      $EGREP ": [^:]* bundle" >/dev/null ; then
2664382ff0afSmrg		      $echo "** Warning, lib $linklib is a module, not a shared library"
2665382ff0afSmrg		      if test -z "$old_library" ; then
2666382ff0afSmrg		        $echo
2667382ff0afSmrg		        $echo "** And there doesn't seem to be a static archive available"
2668382ff0afSmrg		        $echo "** The link will probably fail, sorry"
2669382ff0afSmrg		      else
2670382ff0afSmrg		        add="$dir/$old_library"
2671382ff0afSmrg		      fi
2672382ff0afSmrg		    fi
2673382ff0afSmrg		esac
2674382ff0afSmrg	      elif test "$hardcode_minus_L" = no; then
2675382ff0afSmrg		case $host in
2676382ff0afSmrg		*-*-sunos*) add_shlibpath="$dir" ;;
2677382ff0afSmrg		esac
2678382ff0afSmrg		add_dir="-L$dir"
2679382ff0afSmrg		add="-l$name"
2680382ff0afSmrg	      elif test "$hardcode_shlibpath_var" = no; then
2681382ff0afSmrg		add_shlibpath="$dir"
2682382ff0afSmrg		add="-l$name"
2683382ff0afSmrg	      else
2684382ff0afSmrg		lib_linked=no
2685382ff0afSmrg	      fi
2686382ff0afSmrg	      ;;
2687382ff0afSmrg	    relink)
2688382ff0afSmrg	      if test "$hardcode_direct" = yes; then
2689382ff0afSmrg		add="$dir/$linklib"
2690382ff0afSmrg	      elif test "$hardcode_minus_L" = yes; then
2691382ff0afSmrg		add_dir="-L$dir"
2692382ff0afSmrg		# Try looking first in the location we're being installed to.
2693382ff0afSmrg		if test -n "$inst_prefix_dir"; then
2694382ff0afSmrg		  case $libdir in
2695382ff0afSmrg		    [\\/]*)
2696382ff0afSmrg		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
2697382ff0afSmrg		      ;;
2698382ff0afSmrg		  esac
2699382ff0afSmrg		fi
2700382ff0afSmrg		add="-l$name"
2701382ff0afSmrg	      elif test "$hardcode_shlibpath_var" = yes; then
2702382ff0afSmrg		add_shlibpath="$dir"
2703382ff0afSmrg		add="-l$name"
2704382ff0afSmrg	      else
2705382ff0afSmrg		lib_linked=no
2706382ff0afSmrg	      fi
2707382ff0afSmrg	      ;;
2708382ff0afSmrg	    *) lib_linked=no ;;
2709382ff0afSmrg	    esac
2710382ff0afSmrg
2711382ff0afSmrg	    if test "$lib_linked" != yes; then
2712382ff0afSmrg	      $echo "$modename: configuration error: unsupported hardcode properties"
2713382ff0afSmrg	      exit $EXIT_FAILURE
2714382ff0afSmrg	    fi
2715382ff0afSmrg
2716382ff0afSmrg	    if test -n "$add_shlibpath"; then
2717382ff0afSmrg	      case :$compile_shlibpath: in
2718382ff0afSmrg	      *":$add_shlibpath:"*) ;;
2719382ff0afSmrg	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
2720382ff0afSmrg	      esac
2721382ff0afSmrg	    fi
2722382ff0afSmrg	    if test "$linkmode" = prog; then
2723382ff0afSmrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
2724382ff0afSmrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
2725382ff0afSmrg	    else
2726382ff0afSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
2727382ff0afSmrg	      test -n "$add" && deplibs="$add $deplibs"
2728382ff0afSmrg	      if test "$hardcode_direct" != yes && \
2729382ff0afSmrg		 test "$hardcode_minus_L" != yes && \
2730382ff0afSmrg		 test "$hardcode_shlibpath_var" = yes; then
2731382ff0afSmrg		case :$finalize_shlibpath: in
2732382ff0afSmrg		*":$libdir:"*) ;;
2733382ff0afSmrg		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
2734382ff0afSmrg		esac
2735382ff0afSmrg	      fi
2736382ff0afSmrg	    fi
2737382ff0afSmrg	  fi
2738382ff0afSmrg
2739382ff0afSmrg	  if test "$linkmode" = prog || test "$mode" = relink; then
2740382ff0afSmrg	    add_shlibpath=
2741382ff0afSmrg	    add_dir=
2742382ff0afSmrg	    add=
2743382ff0afSmrg	    # Finalize command for both is simple: just hardcode it.
2744382ff0afSmrg	    if test "$hardcode_direct" = yes; then
2745382ff0afSmrg	      add="$libdir/$linklib"
2746382ff0afSmrg	    elif test "$hardcode_minus_L" = yes; then
2747382ff0afSmrg	      add_dir="-L$libdir"
2748382ff0afSmrg	      add="-l$name"
2749382ff0afSmrg	    elif test "$hardcode_shlibpath_var" = yes; then
2750382ff0afSmrg	      case :$finalize_shlibpath: in
2751382ff0afSmrg	      *":$libdir:"*) ;;
2752382ff0afSmrg	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
2753382ff0afSmrg	      esac
2754382ff0afSmrg	      add="-l$name"
2755382ff0afSmrg	    elif test "$hardcode_automatic" = yes; then
2756382ff0afSmrg	      if test -n "$inst_prefix_dir" &&
2757382ff0afSmrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
2758382ff0afSmrg	        add="$inst_prefix_dir$libdir/$linklib"
2759382ff0afSmrg	      else
2760382ff0afSmrg	        add="$libdir/$linklib"
2761382ff0afSmrg	      fi
2762382ff0afSmrg	    else
2763382ff0afSmrg	      # We cannot seem to hardcode it, guess we'll fake it.
2764382ff0afSmrg	      add_dir="-L$libdir"
2765382ff0afSmrg	      # Try looking first in the location we're being installed to.
2766382ff0afSmrg	      if test -n "$inst_prefix_dir"; then
2767382ff0afSmrg		case $libdir in
2768382ff0afSmrg		  [\\/]*)
2769382ff0afSmrg		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
2770382ff0afSmrg		    ;;
2771382ff0afSmrg		esac
2772382ff0afSmrg	      fi
2773382ff0afSmrg	      add="-l$name"
2774382ff0afSmrg	    fi
2775382ff0afSmrg
2776382ff0afSmrg	    if test "$linkmode" = prog; then
2777382ff0afSmrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
2778382ff0afSmrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
2779382ff0afSmrg	    else
2780382ff0afSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
2781382ff0afSmrg	      test -n "$add" && deplibs="$add $deplibs"
2782382ff0afSmrg	    fi
2783382ff0afSmrg	  fi
2784382ff0afSmrg	elif test "$linkmode" = prog; then
2785382ff0afSmrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
2786382ff0afSmrg	  # is not unsupported.  This is valid on all known static and
2787382ff0afSmrg	  # shared platforms.
2788382ff0afSmrg	  if test "$hardcode_direct" != unsupported; then
2789382ff0afSmrg	    test -n "$old_library" && linklib="$old_library"
2790382ff0afSmrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
2791382ff0afSmrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
2792382ff0afSmrg	  else
2793382ff0afSmrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
2794382ff0afSmrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
2795382ff0afSmrg	  fi
2796382ff0afSmrg	elif test "$build_libtool_libs" = yes; then
2797382ff0afSmrg	  # Not a shared library
2798382ff0afSmrg	  if test "$deplibs_check_method" != pass_all; then
2799382ff0afSmrg	    # We're trying link a shared library against a static one
2800382ff0afSmrg	    # but the system doesn't support it.
2801382ff0afSmrg
2802382ff0afSmrg	    # Just print a warning and add the library to dependency_libs so
2803382ff0afSmrg	    # that the program can be linked against the static library.
2804382ff0afSmrg	    $echo
2805382ff0afSmrg	    $echo "*** Warning: This system can not link to static lib archive $lib."
2806382ff0afSmrg	    $echo "*** I have the capability to make that library automatically link in when"
2807382ff0afSmrg	    $echo "*** you link to this library.  But I can only do this if you have a"
2808382ff0afSmrg	    $echo "*** shared version of the library, which you do not appear to have."
2809382ff0afSmrg	    if test "$module" = yes; then
2810382ff0afSmrg	      $echo "*** But as you try to build a module library, libtool will still create "
2811382ff0afSmrg	      $echo "*** a static module, that should work as long as the dlopening application"
2812382ff0afSmrg	      $echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
2813382ff0afSmrg	      if test -z "$global_symbol_pipe"; then
2814382ff0afSmrg		$echo
2815382ff0afSmrg		$echo "*** However, this would only work if libtool was able to extract symbol"
2816382ff0afSmrg		$echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
2817382ff0afSmrg		$echo "*** not find such a program.  So, this module is probably useless."
2818382ff0afSmrg		$echo "*** \`nm' from GNU binutils and a full rebuild may help."
2819382ff0afSmrg	      fi
2820382ff0afSmrg	      if test "$build_old_libs" = no; then
2821382ff0afSmrg		build_libtool_libs=module
2822382ff0afSmrg		build_old_libs=yes
2823382ff0afSmrg	      else
2824382ff0afSmrg		build_libtool_libs=no
2825382ff0afSmrg	      fi
2826382ff0afSmrg	    fi
2827382ff0afSmrg	  else
2828382ff0afSmrg	    deplibs="$dir/$old_library $deplibs"
2829382ff0afSmrg	    link_static=yes
2830382ff0afSmrg	  fi
2831382ff0afSmrg	fi # link shared/static library?
2832382ff0afSmrg
2833382ff0afSmrg	if test "$linkmode" = lib; then
2834382ff0afSmrg	  if test -n "$dependency_libs" &&
2835382ff0afSmrg	     { test "$hardcode_into_libs" != yes ||
2836382ff0afSmrg	       test "$build_old_libs" = yes ||
2837382ff0afSmrg	       test "$link_static" = yes; }; then
2838382ff0afSmrg	    # Extract -R from dependency_libs
2839382ff0afSmrg	    temp_deplibs=
2840382ff0afSmrg	    for libdir in $dependency_libs; do
2841382ff0afSmrg	      case $libdir in
2842382ff0afSmrg	      -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'`
2843382ff0afSmrg		   case " $xrpath " in
2844382ff0afSmrg		   *" $temp_xrpath "*) ;;
2845382ff0afSmrg		   *) xrpath="$xrpath $temp_xrpath";;
2846382ff0afSmrg		   esac;;
2847382ff0afSmrg	      *) temp_deplibs="$temp_deplibs $libdir";;
2848382ff0afSmrg	      esac
2849382ff0afSmrg	    done
2850382ff0afSmrg	    dependency_libs="$temp_deplibs"
2851382ff0afSmrg	  fi
2852382ff0afSmrg
2853382ff0afSmrg	  newlib_search_path="$newlib_search_path $absdir"
2854382ff0afSmrg	  # Link against this library
2855382ff0afSmrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
2856382ff0afSmrg	  # ... and its dependency_libs
2857382ff0afSmrg	  tmp_libs=
2858382ff0afSmrg	  for deplib in $dependency_libs; do
2859382ff0afSmrg	    newdependency_libs="$deplib $newdependency_libs"
2860382ff0afSmrg	    if test "X$duplicate_deps" = "Xyes" ; then
2861382ff0afSmrg	      case "$tmp_libs " in
2862382ff0afSmrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2863382ff0afSmrg	      esac
2864382ff0afSmrg	    fi
2865382ff0afSmrg	    tmp_libs="$tmp_libs $deplib"
2866382ff0afSmrg	  done
2867382ff0afSmrg
2868382ff0afSmrg	  if test "$link_all_deplibs" != no; then
2869382ff0afSmrg	    # Add the search paths of all dependency libraries
2870382ff0afSmrg	    for deplib in $dependency_libs; do
2871382ff0afSmrg	      case $deplib in
2872382ff0afSmrg	      -L*) path="$deplib" ;;
2873382ff0afSmrg	      *.la)
2874382ff0afSmrg		dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
2875382ff0afSmrg		test "X$dir" = "X$deplib" && dir="."
2876382ff0afSmrg		# We need an absolute path.
2877382ff0afSmrg		case $dir in
2878382ff0afSmrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
2879382ff0afSmrg		*)
2880382ff0afSmrg		  absdir=`cd "$dir" && pwd`
2881382ff0afSmrg		  if test -z "$absdir"; then
2882382ff0afSmrg		    $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
2883382ff0afSmrg		    absdir="$dir"
2884382ff0afSmrg		  fi
2885382ff0afSmrg		  ;;
2886382ff0afSmrg		esac
2887382ff0afSmrg		if grep "^installed=no" $deplib > /dev/null; then
2888382ff0afSmrg		  path="$absdir/$objdir"
2889382ff0afSmrg		else
2890382ff0afSmrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
2891382ff0afSmrg		  if test -z "$libdir"; then
2892382ff0afSmrg		    $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
2893382ff0afSmrg		    exit $EXIT_FAILURE
2894382ff0afSmrg		  fi
2895382ff0afSmrg		  if test "$absdir" != "$libdir"; then
2896382ff0afSmrg		    $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
2897382ff0afSmrg		  fi
2898382ff0afSmrg		  path="$absdir"
2899382ff0afSmrg		fi
2900382ff0afSmrg		depdepl=
2901382ff0afSmrg		case $host in
2902382ff0afSmrg		*-*-darwin*)
2903382ff0afSmrg		  # we do not want to link against static libs,
2904382ff0afSmrg		  # but need to link against shared
2905382ff0afSmrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
2906382ff0afSmrg		  if test -n "$deplibrary_names" ; then
2907382ff0afSmrg		    for tmp in $deplibrary_names ; do
2908382ff0afSmrg		      depdepl=$tmp
2909382ff0afSmrg		    done
2910382ff0afSmrg		    if test -f "$path/$depdepl" ; then
2911382ff0afSmrg		      depdepl="$path/$depdepl"
2912382ff0afSmrg		    fi
2913382ff0afSmrg		    # do not add paths which are already there
2914382ff0afSmrg		    case " $newlib_search_path " in
2915382ff0afSmrg		    *" $path "*) ;;
2916382ff0afSmrg		    *) newlib_search_path="$newlib_search_path $path";;
2917382ff0afSmrg		    esac
2918382ff0afSmrg		  fi
2919382ff0afSmrg		  path=""
2920382ff0afSmrg		  ;;
2921382ff0afSmrg		*)
2922382ff0afSmrg		  path="-L$path"
2923382ff0afSmrg		  ;;
2924382ff0afSmrg		esac
2925382ff0afSmrg		;;
2926382ff0afSmrg	      -l*)
2927382ff0afSmrg		case $host in
2928382ff0afSmrg		*-*-darwin*)
2929382ff0afSmrg		  # Again, we only want to link against shared libraries
2930382ff0afSmrg		  eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
2931382ff0afSmrg		  for tmp in $newlib_search_path ; do
2932382ff0afSmrg		    if test -f "$tmp/lib$tmp_libs.dylib" ; then
2933382ff0afSmrg		      eval depdepl="$tmp/lib$tmp_libs.dylib"
2934382ff0afSmrg		      break
2935382ff0afSmrg		    fi
2936382ff0afSmrg		  done
2937382ff0afSmrg		  path=""
2938382ff0afSmrg		  ;;
2939382ff0afSmrg		*) continue ;;
2940382ff0afSmrg		esac
2941382ff0afSmrg		;;
2942382ff0afSmrg	      *) continue ;;
2943382ff0afSmrg	      esac
2944382ff0afSmrg	      case " $deplibs " in
2945382ff0afSmrg	      *" $path "*) ;;
2946382ff0afSmrg	      *) deplibs="$path $deplibs" ;;
2947382ff0afSmrg	      esac
2948382ff0afSmrg	      case " $deplibs " in
2949382ff0afSmrg	      *" $depdepl "*) ;;
2950382ff0afSmrg	      *) deplibs="$depdepl $deplibs" ;;
2951382ff0afSmrg	      esac
2952382ff0afSmrg	    done
2953382ff0afSmrg	  fi # link_all_deplibs != no
2954382ff0afSmrg	fi # linkmode = lib
2955382ff0afSmrg      done # for deplib in $libs
2956382ff0afSmrg      dependency_libs="$newdependency_libs"
2957382ff0afSmrg      if test "$pass" = dlpreopen; then
2958382ff0afSmrg	# Link the dlpreopened libraries before other libraries
2959382ff0afSmrg	for deplib in $save_deplibs; do
2960382ff0afSmrg	  deplibs="$deplib $deplibs"
2961382ff0afSmrg	done
2962382ff0afSmrg      fi
2963382ff0afSmrg      if test "$pass" != dlopen; then
2964382ff0afSmrg	if test "$pass" != conv; then
2965382ff0afSmrg	  # Make sure lib_search_path contains only unique directories.
2966382ff0afSmrg	  lib_search_path=
2967382ff0afSmrg	  for dir in $newlib_search_path; do
2968382ff0afSmrg	    case "$lib_search_path " in
2969382ff0afSmrg	    *" $dir "*) ;;
2970382ff0afSmrg	    *) lib_search_path="$lib_search_path $dir" ;;
2971382ff0afSmrg	    esac
2972382ff0afSmrg	  done
2973382ff0afSmrg	  newlib_search_path=
2974382ff0afSmrg	fi
2975382ff0afSmrg
2976382ff0afSmrg	if test "$linkmode,$pass" != "prog,link"; then
2977382ff0afSmrg	  vars="deplibs"
2978382ff0afSmrg	else
2979382ff0afSmrg	  vars="compile_deplibs finalize_deplibs"
2980382ff0afSmrg	fi
2981382ff0afSmrg	for var in $vars dependency_libs; do
2982382ff0afSmrg	  # Add libraries to $var in reverse order
2983382ff0afSmrg	  eval tmp_libs=\"\$$var\"
2984382ff0afSmrg	  new_libs=
2985382ff0afSmrg	  for deplib in $tmp_libs; do
2986382ff0afSmrg	    # FIXME: Pedantically, this is the right thing to do, so
2987382ff0afSmrg	    #        that some nasty dependency loop isn't accidentally
2988382ff0afSmrg	    #        broken:
2989382ff0afSmrg	    #new_libs="$deplib $new_libs"
2990382ff0afSmrg	    # Pragmatically, this seems to cause very few problems in
2991382ff0afSmrg	    # practice:
2992382ff0afSmrg	    case $deplib in
2993382ff0afSmrg	    -L*) new_libs="$deplib $new_libs" ;;
2994382ff0afSmrg	    -R*) ;;
2995382ff0afSmrg	    *)
2996382ff0afSmrg	      # And here is the reason: when a library appears more
2997382ff0afSmrg	      # than once as an explicit dependence of a library, or
2998382ff0afSmrg	      # is implicitly linked in more than once by the
2999382ff0afSmrg	      # compiler, it is considered special, and multiple
3000382ff0afSmrg	      # occurrences thereof are not removed.  Compare this
3001382ff0afSmrg	      # with having the same library being listed as a
3002382ff0afSmrg	      # dependency of multiple other libraries: in this case,
3003382ff0afSmrg	      # we know (pedantically, we assume) the library does not
3004382ff0afSmrg	      # need to be listed more than once, so we keep only the
3005382ff0afSmrg	      # last copy.  This is not always right, but it is rare
3006382ff0afSmrg	      # enough that we require users that really mean to play
3007382ff0afSmrg	      # such unportable linking tricks to link the library
3008382ff0afSmrg	      # using -Wl,-lname, so that libtool does not consider it
3009382ff0afSmrg	      # for duplicate removal.
3010382ff0afSmrg	      case " $specialdeplibs " in
3011382ff0afSmrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
3012382ff0afSmrg	      *)
3013382ff0afSmrg		case " $new_libs " in
3014382ff0afSmrg		*" $deplib "*) ;;
3015382ff0afSmrg		*) new_libs="$deplib $new_libs" ;;
3016382ff0afSmrg		esac
3017382ff0afSmrg		;;
3018382ff0afSmrg	      esac
3019382ff0afSmrg	      ;;
3020382ff0afSmrg	    esac
3021382ff0afSmrg	  done
3022382ff0afSmrg	  tmp_libs=
3023382ff0afSmrg	  for deplib in $new_libs; do
3024382ff0afSmrg	    case $deplib in
3025382ff0afSmrg	    -L*)
3026382ff0afSmrg	      case " $tmp_libs " in
3027382ff0afSmrg	      *" $deplib "*) ;;
3028382ff0afSmrg	      *) tmp_libs="$tmp_libs $deplib" ;;
3029382ff0afSmrg	      esac
3030382ff0afSmrg	      ;;
3031382ff0afSmrg	    *) tmp_libs="$tmp_libs $deplib" ;;
3032382ff0afSmrg	    esac
3033382ff0afSmrg	  done
3034382ff0afSmrg	  eval $var=\"$tmp_libs\"
3035382ff0afSmrg	done # for var
3036382ff0afSmrg      fi
3037382ff0afSmrg      # Last step: remove runtime libs from dependency_libs
3038382ff0afSmrg      # (they stay in deplibs)
3039382ff0afSmrg      tmp_libs=
3040382ff0afSmrg      for i in $dependency_libs ; do
3041382ff0afSmrg	case " $predeps $postdeps $compiler_lib_search_path " in
3042382ff0afSmrg	*" $i "*)
3043382ff0afSmrg	  i=""
3044382ff0afSmrg	  ;;
3045382ff0afSmrg	esac
3046382ff0afSmrg	if test -n "$i" ; then
3047382ff0afSmrg	  tmp_libs="$tmp_libs $i"
3048382ff0afSmrg	fi
3049382ff0afSmrg      done
3050382ff0afSmrg      dependency_libs=$tmp_libs
3051382ff0afSmrg    done # for pass
3052382ff0afSmrg    if test "$linkmode" = prog; then
3053382ff0afSmrg      dlfiles="$newdlfiles"
3054382ff0afSmrg      dlprefiles="$newdlprefiles"
3055382ff0afSmrg    fi
3056382ff0afSmrg
3057382ff0afSmrg    case $linkmode in
3058382ff0afSmrg    oldlib)
3059382ff0afSmrg      if test -n "$deplibs"; then
3060382ff0afSmrg	$echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
3061382ff0afSmrg      fi
3062382ff0afSmrg
3063382ff0afSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
3064382ff0afSmrg	$echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
3065382ff0afSmrg      fi
3066382ff0afSmrg
3067382ff0afSmrg      if test -n "$rpath"; then
3068382ff0afSmrg	$echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
3069382ff0afSmrg      fi
3070382ff0afSmrg
3071382ff0afSmrg      if test -n "$xrpath"; then
3072382ff0afSmrg	$echo "$modename: warning: \`-R' is ignored for archives" 1>&2
3073382ff0afSmrg      fi
3074382ff0afSmrg
3075382ff0afSmrg      if test -n "$vinfo"; then
3076382ff0afSmrg	$echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2
3077382ff0afSmrg      fi
3078382ff0afSmrg
3079382ff0afSmrg      if test -n "$release"; then
3080382ff0afSmrg	$echo "$modename: warning: \`-release' is ignored for archives" 1>&2
3081382ff0afSmrg      fi
3082382ff0afSmrg
3083382ff0afSmrg      if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
3084382ff0afSmrg	$echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
3085382ff0afSmrg      fi
3086382ff0afSmrg
3087382ff0afSmrg      # Now set the variables for building old libraries.
3088382ff0afSmrg      build_libtool_libs=no
3089382ff0afSmrg      oldlibs="$output"
3090382ff0afSmrg      objs="$objs$old_deplibs"
3091382ff0afSmrg      ;;
3092382ff0afSmrg
3093382ff0afSmrg    lib)
3094382ff0afSmrg      # Make sure we only generate libraries of the form `libNAME.la'.
3095382ff0afSmrg      case $outputname in
3096382ff0afSmrg      lib*)
3097382ff0afSmrg	name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
3098382ff0afSmrg	eval shared_ext=\"$shrext_cmds\"
3099382ff0afSmrg	eval libname=\"$libname_spec\"
3100382ff0afSmrg	;;
3101382ff0afSmrg      *)
3102382ff0afSmrg	if test "$module" = no; then
3103382ff0afSmrg	  $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
3104382ff0afSmrg	  $echo "$help" 1>&2
3105382ff0afSmrg	  exit $EXIT_FAILURE
3106382ff0afSmrg	fi
3107382ff0afSmrg	if test "$need_lib_prefix" != no; then
3108382ff0afSmrg	  # Add the "lib" prefix for modules if required
3109382ff0afSmrg	  name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
3110382ff0afSmrg	  eval shared_ext=\"$shrext_cmds\"
3111382ff0afSmrg	  eval libname=\"$libname_spec\"
3112382ff0afSmrg	else
3113382ff0afSmrg	  libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
3114382ff0afSmrg	fi
3115382ff0afSmrg	;;
3116382ff0afSmrg      esac
3117382ff0afSmrg
3118382ff0afSmrg      if test -n "$objs"; then
3119382ff0afSmrg	if test "$deplibs_check_method" != pass_all; then
3120382ff0afSmrg	  $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
3121382ff0afSmrg	  exit $EXIT_FAILURE
3122382ff0afSmrg	else
3123382ff0afSmrg	  $echo
3124382ff0afSmrg	  $echo "*** Warning: Linking the shared library $output against the non-libtool"
3125382ff0afSmrg	  $echo "*** objects $objs is not portable!"
3126382ff0afSmrg	  libobjs="$libobjs $objs"
3127382ff0afSmrg	fi
3128382ff0afSmrg      fi
3129382ff0afSmrg
3130382ff0afSmrg      if test "$dlself" != no; then
3131382ff0afSmrg	$echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2
3132382ff0afSmrg      fi
3133382ff0afSmrg
3134382ff0afSmrg      set dummy $rpath
3135382ff0afSmrg      if test "$#" -gt 2; then
3136382ff0afSmrg	$echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
3137382ff0afSmrg      fi
3138382ff0afSmrg      install_libdir="$2"
3139382ff0afSmrg
3140382ff0afSmrg      oldlibs=
3141382ff0afSmrg      if test -z "$rpath"; then
3142382ff0afSmrg	if test "$build_libtool_libs" = yes; then
3143382ff0afSmrg	  # Building a libtool convenience library.
3144382ff0afSmrg	  # Some compilers have problems with a `.al' extension so
3145382ff0afSmrg	  # convenience libraries should have the same extension an
3146382ff0afSmrg	  # archive normally would.
3147382ff0afSmrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
3148382ff0afSmrg	  build_libtool_libs=convenience
3149382ff0afSmrg	  build_old_libs=yes
3150382ff0afSmrg	fi
3151382ff0afSmrg
3152382ff0afSmrg	if test -n "$vinfo"; then
3153382ff0afSmrg	  $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2
3154382ff0afSmrg	fi
3155382ff0afSmrg
3156382ff0afSmrg	if test -n "$release"; then
3157382ff0afSmrg	  $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
3158382ff0afSmrg	fi
3159382ff0afSmrg      else
3160382ff0afSmrg
3161382ff0afSmrg	# Parse the version information argument.
3162382ff0afSmrg	save_ifs="$IFS"; IFS=':'
3163382ff0afSmrg	set dummy $vinfo 0 0 0
3164382ff0afSmrg	IFS="$save_ifs"
3165382ff0afSmrg
3166382ff0afSmrg	if test -n "$8"; then
3167382ff0afSmrg	  $echo "$modename: too many parameters to \`-version-info'" 1>&2
3168382ff0afSmrg	  $echo "$help" 1>&2
3169382ff0afSmrg	  exit $EXIT_FAILURE
3170382ff0afSmrg	fi
3171382ff0afSmrg
3172382ff0afSmrg	# convert absolute version numbers to libtool ages
3173382ff0afSmrg	# this retains compatibility with .la files and attempts
3174382ff0afSmrg	# to make the code below a bit more comprehensible
3175382ff0afSmrg
3176382ff0afSmrg	case $vinfo_number in
3177382ff0afSmrg	yes)
3178382ff0afSmrg	  number_major="$2"
3179382ff0afSmrg	  number_minor="$3"
3180382ff0afSmrg	  number_revision="$4"
3181382ff0afSmrg	  #
3182382ff0afSmrg	  # There are really only two kinds -- those that
3183382ff0afSmrg	  # use the current revision as the major version
3184382ff0afSmrg	  # and those that subtract age and use age as
3185382ff0afSmrg	  # a minor version.  But, then there is irix
3186382ff0afSmrg	  # which has an extra 1 added just for fun
3187382ff0afSmrg	  #
3188382ff0afSmrg	  case $version_type in
3189382ff0afSmrg	  darwin|linux|osf|windows)
3190382ff0afSmrg	    current=`expr $number_major + $number_minor`
3191382ff0afSmrg	    age="$number_minor"
3192382ff0afSmrg	    revision="$number_revision"
3193382ff0afSmrg	    ;;
3194382ff0afSmrg	  freebsd-aout|freebsd-elf|sunos)
3195382ff0afSmrg	    current="$number_major"
3196382ff0afSmrg	    revision="$number_minor"
3197382ff0afSmrg	    age="0"
3198382ff0afSmrg	    ;;
3199382ff0afSmrg	  irix|nonstopux)
3200382ff0afSmrg	    current=`expr $number_major + $number_minor - 1`
3201382ff0afSmrg	    age="$number_minor"
3202382ff0afSmrg	    revision="$number_minor"
3203382ff0afSmrg	    ;;
3204382ff0afSmrg	  esac
3205382ff0afSmrg	  ;;
3206382ff0afSmrg	no)
3207382ff0afSmrg	  current="$2"
3208382ff0afSmrg	  revision="$3"
3209382ff0afSmrg	  age="$4"
3210382ff0afSmrg	  ;;
3211382ff0afSmrg	esac
3212382ff0afSmrg
3213382ff0afSmrg	# Check that each of the things are valid numbers.
3214382ff0afSmrg	case $current in
3215382ff0afSmrg	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]) ;;
3216382ff0afSmrg	*)
3217382ff0afSmrg	  $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2
3218382ff0afSmrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3219382ff0afSmrg	  exit $EXIT_FAILURE
3220382ff0afSmrg	  ;;
3221382ff0afSmrg	esac
3222382ff0afSmrg
3223382ff0afSmrg	case $revision in
3224382ff0afSmrg	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]) ;;
3225382ff0afSmrg	*)
3226382ff0afSmrg	  $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2
3227382ff0afSmrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3228382ff0afSmrg	  exit $EXIT_FAILURE
3229382ff0afSmrg	  ;;
3230382ff0afSmrg	esac
3231382ff0afSmrg
3232382ff0afSmrg	case $age in
3233382ff0afSmrg	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]) ;;
3234382ff0afSmrg	*)
3235382ff0afSmrg	  $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2
3236382ff0afSmrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3237382ff0afSmrg	  exit $EXIT_FAILURE
3238382ff0afSmrg	  ;;
3239382ff0afSmrg	esac
3240382ff0afSmrg
3241382ff0afSmrg	if test "$age" -gt "$current"; then
3242382ff0afSmrg	  $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
3243382ff0afSmrg	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3244382ff0afSmrg	  exit $EXIT_FAILURE
3245382ff0afSmrg	fi
3246382ff0afSmrg
3247382ff0afSmrg	# Calculate the version variables.
3248382ff0afSmrg	major=
3249382ff0afSmrg	versuffix=
3250382ff0afSmrg	verstring=
3251382ff0afSmrg	case $version_type in
3252382ff0afSmrg	none) ;;
3253382ff0afSmrg
3254382ff0afSmrg	darwin)
3255382ff0afSmrg	  # Like Linux, but with the current version available in
3256382ff0afSmrg	  # verstring for coding it into the library header
3257382ff0afSmrg	  major=.`expr $current - $age`
3258382ff0afSmrg	  versuffix="$major.$age.$revision"
3259382ff0afSmrg	  # Darwin ld doesn't like 0 for these options...
3260382ff0afSmrg	  minor_current=`expr $current + 1`
3261382ff0afSmrg	  verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
3262382ff0afSmrg	  ;;
3263382ff0afSmrg
3264382ff0afSmrg	freebsd-aout)
3265382ff0afSmrg	  major=".$current"
3266382ff0afSmrg	  versuffix=".$current.$revision";
3267382ff0afSmrg	  ;;
3268382ff0afSmrg
3269382ff0afSmrg	freebsd-elf)
3270382ff0afSmrg	  major=".$current"
3271382ff0afSmrg	  versuffix=".$current";
3272382ff0afSmrg	  ;;
3273382ff0afSmrg
3274382ff0afSmrg	irix | nonstopux)
3275382ff0afSmrg	  major=`expr $current - $age + 1`
3276382ff0afSmrg
3277382ff0afSmrg	  case $version_type in
3278382ff0afSmrg	    nonstopux) verstring_prefix=nonstopux ;;
3279382ff0afSmrg	    *)         verstring_prefix=sgi ;;
3280382ff0afSmrg	  esac
3281382ff0afSmrg	  verstring="$verstring_prefix$major.$revision"
3282382ff0afSmrg
3283382ff0afSmrg	  # Add in all the interfaces that we are compatible with.
3284382ff0afSmrg	  loop=$revision
3285382ff0afSmrg	  while test "$loop" -ne 0; do
3286382ff0afSmrg	    iface=`expr $revision - $loop`
3287382ff0afSmrg	    loop=`expr $loop - 1`
3288382ff0afSmrg	    verstring="$verstring_prefix$major.$iface:$verstring"
3289382ff0afSmrg	  done
3290382ff0afSmrg
3291382ff0afSmrg	  # Before this point, $major must not contain `.'.
3292382ff0afSmrg	  major=.$major
3293382ff0afSmrg	  versuffix="$major.$revision"
3294382ff0afSmrg	  ;;
3295382ff0afSmrg
3296382ff0afSmrg	linux)
3297382ff0afSmrg	  major=.`expr $current - $age`
3298382ff0afSmrg	  versuffix="$major.$age.$revision"
3299382ff0afSmrg	  ;;
3300382ff0afSmrg
3301382ff0afSmrg	osf)
3302382ff0afSmrg	  major=.`expr $current - $age`
3303382ff0afSmrg	  versuffix=".$current.$age.$revision"
3304382ff0afSmrg	  verstring="$current.$age.$revision"
3305382ff0afSmrg
3306382ff0afSmrg	  # Add in all the interfaces that we are compatible with.
3307382ff0afSmrg	  loop=$age
3308382ff0afSmrg	  while test "$loop" -ne 0; do
3309382ff0afSmrg	    iface=`expr $current - $loop`
3310382ff0afSmrg	    loop=`expr $loop - 1`
3311382ff0afSmrg	    verstring="$verstring:${iface}.0"
3312382ff0afSmrg	  done
3313382ff0afSmrg
3314382ff0afSmrg	  # Make executables depend on our current version.
3315382ff0afSmrg	  verstring="$verstring:${current}.0"
3316382ff0afSmrg	  ;;
3317382ff0afSmrg
3318382ff0afSmrg	sunos)
3319382ff0afSmrg	  major=".$current"
3320382ff0afSmrg	  versuffix=".$current.$revision"
3321382ff0afSmrg	  ;;
3322382ff0afSmrg
3323382ff0afSmrg	windows)
3324382ff0afSmrg	  # Use '-' rather than '.', since we only want one
3325382ff0afSmrg	  # extension on DOS 8.3 filesystems.
3326382ff0afSmrg	  major=`expr $current - $age`
3327382ff0afSmrg	  versuffix="-$major"
3328382ff0afSmrg	  ;;
3329382ff0afSmrg
3330382ff0afSmrg	*)
3331382ff0afSmrg	  $echo "$modename: unknown library version type \`$version_type'" 1>&2
3332382ff0afSmrg	  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
3333382ff0afSmrg	  exit $EXIT_FAILURE
3334382ff0afSmrg	  ;;
3335382ff0afSmrg	esac
3336382ff0afSmrg
3337382ff0afSmrg	# Clear the version info if we defaulted, and they specified a release.
3338382ff0afSmrg	if test -z "$vinfo" && test -n "$release"; then
3339382ff0afSmrg	  major=
3340382ff0afSmrg	  case $version_type in
3341382ff0afSmrg	  darwin)
3342382ff0afSmrg	    # we can't check for "0.0" in archive_cmds due to quoting
3343382ff0afSmrg	    # problems, so we reset it completely
3344382ff0afSmrg	    verstring=
3345382ff0afSmrg	    ;;
3346382ff0afSmrg	  *)
3347382ff0afSmrg	    verstring="0.0"
3348382ff0afSmrg	    ;;
3349382ff0afSmrg	  esac
3350382ff0afSmrg	  if test "$need_version" = no; then
3351382ff0afSmrg	    versuffix=
3352382ff0afSmrg	  else
3353382ff0afSmrg	    versuffix=".0.0"
3354382ff0afSmrg	  fi
3355382ff0afSmrg	fi
3356382ff0afSmrg
3357382ff0afSmrg	# Remove version info from name if versioning should be avoided
3358382ff0afSmrg	if test "$avoid_version" = yes && test "$need_version" = no; then
3359382ff0afSmrg	  major=
3360382ff0afSmrg	  versuffix=
3361382ff0afSmrg	  verstring=""
3362382ff0afSmrg	fi
3363382ff0afSmrg
3364382ff0afSmrg	# Check to see if the archive will have undefined symbols.
3365382ff0afSmrg	if test "$allow_undefined" = yes; then
3366382ff0afSmrg	  if test "$allow_undefined_flag" = unsupported; then
3367382ff0afSmrg	    $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
3368382ff0afSmrg	    build_libtool_libs=no
3369382ff0afSmrg	    build_old_libs=yes
3370382ff0afSmrg	  fi
3371382ff0afSmrg	else
3372382ff0afSmrg	  # Don't allow undefined symbols.
3373382ff0afSmrg	  allow_undefined_flag="$no_undefined_flag"
3374382ff0afSmrg	fi
3375382ff0afSmrg      fi
3376382ff0afSmrg
3377382ff0afSmrg      if test "$mode" != relink; then
3378382ff0afSmrg	# Remove our outputs, but don't remove object files since they
3379382ff0afSmrg	# may have been created when compiling PIC objects.
3380382ff0afSmrg	removelist=
3381382ff0afSmrg	tempremovelist=`$echo "$output_objdir/*"`
3382382ff0afSmrg	for p in $tempremovelist; do
3383382ff0afSmrg	  case $p in
3384382ff0afSmrg	    *.$objext)
3385382ff0afSmrg	       ;;
3386382ff0afSmrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
3387382ff0afSmrg	       if test "X$precious_files_regex" != "X"; then
3388382ff0afSmrg	         if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
3389382ff0afSmrg	         then
3390382ff0afSmrg		   continue
3391382ff0afSmrg		 fi
3392382ff0afSmrg	       fi
3393382ff0afSmrg	       removelist="$removelist $p"
3394382ff0afSmrg	       ;;
3395382ff0afSmrg	    *) ;;
3396382ff0afSmrg	  esac
3397382ff0afSmrg	done
3398382ff0afSmrg	if test -n "$removelist"; then
3399382ff0afSmrg	  $show "${rm}r $removelist"
3400382ff0afSmrg	  $run ${rm}r $removelist
3401382ff0afSmrg	fi
3402382ff0afSmrg      fi
3403382ff0afSmrg
3404382ff0afSmrg      # Now set the variables for building old libraries.
3405382ff0afSmrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
3406382ff0afSmrg	oldlibs="$oldlibs $output_objdir/$libname.$libext"
3407382ff0afSmrg
3408382ff0afSmrg	# Transform .lo files to .o files.
3409382ff0afSmrg	oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
3410382ff0afSmrg      fi
3411382ff0afSmrg
3412382ff0afSmrg      # Eliminate all temporary directories.
3413382ff0afSmrg      for path in $notinst_path; do
3414382ff0afSmrg	lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
3415382ff0afSmrg	deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
3416382ff0afSmrg	dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
3417382ff0afSmrg      done
3418382ff0afSmrg
3419382ff0afSmrg      if test -n "$xrpath"; then
3420382ff0afSmrg	# If the user specified any rpath flags, then add them.
3421382ff0afSmrg	temp_xrpath=
3422382ff0afSmrg	for libdir in $xrpath; do
3423382ff0afSmrg	  temp_xrpath="$temp_xrpath -R$libdir"
3424382ff0afSmrg	  case "$finalize_rpath " in
3425382ff0afSmrg	  *" $libdir "*) ;;
3426382ff0afSmrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
3427382ff0afSmrg	  esac
3428382ff0afSmrg	done
3429382ff0afSmrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
3430382ff0afSmrg	  dependency_libs="$temp_xrpath $dependency_libs"
3431382ff0afSmrg	fi
3432382ff0afSmrg      fi
3433382ff0afSmrg
3434382ff0afSmrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
3435382ff0afSmrg      old_dlfiles="$dlfiles"
3436382ff0afSmrg      dlfiles=
3437382ff0afSmrg      for lib in $old_dlfiles; do
3438382ff0afSmrg	case " $dlprefiles $dlfiles " in
3439382ff0afSmrg	*" $lib "*) ;;
3440382ff0afSmrg	*) dlfiles="$dlfiles $lib" ;;
3441382ff0afSmrg	esac
3442382ff0afSmrg      done
3443382ff0afSmrg
3444382ff0afSmrg      # Make sure dlprefiles contains only unique files
3445382ff0afSmrg      old_dlprefiles="$dlprefiles"
3446382ff0afSmrg      dlprefiles=
3447382ff0afSmrg      for lib in $old_dlprefiles; do
3448382ff0afSmrg	case "$dlprefiles " in
3449382ff0afSmrg	*" $lib "*) ;;
3450382ff0afSmrg	*) dlprefiles="$dlprefiles $lib" ;;
3451382ff0afSmrg	esac
3452382ff0afSmrg      done
3453382ff0afSmrg
3454382ff0afSmrg      if test "$build_libtool_libs" = yes; then
3455382ff0afSmrg	if test -n "$rpath"; then
3456382ff0afSmrg	  case $host in
3457382ff0afSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
3458382ff0afSmrg	    # these systems don't actually have a c library (as such)!
3459382ff0afSmrg	    ;;
3460382ff0afSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
3461382ff0afSmrg	    # Rhapsody C library is in the System framework
3462382ff0afSmrg	    deplibs="$deplibs -framework System"
3463382ff0afSmrg	    ;;
3464382ff0afSmrg	  *-*-netbsd*)
3465382ff0afSmrg	    # Don't link with libc until the a.out ld.so is fixed.
3466382ff0afSmrg	    ;;
3467382ff0afSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
3468382ff0afSmrg	    # Do not include libc due to us having libc/libc_r.
3469382ff0afSmrg	    ;;
3470382ff0afSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
3471382ff0afSmrg	    # Causes problems with __ctype
3472382ff0afSmrg	    ;;
3473382ff0afSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
3474382ff0afSmrg	    # Compiler inserts libc in the correct place for threads to work
3475382ff0afSmrg	    ;;
3476382ff0afSmrg 	  *)
3477382ff0afSmrg	    # Add libc to deplibs on all other systems if necessary.
3478382ff0afSmrg	    if test "$build_libtool_need_lc" = "yes"; then
3479382ff0afSmrg	      deplibs="$deplibs -lc"
3480382ff0afSmrg	    fi
3481382ff0afSmrg	    ;;
3482382ff0afSmrg	  esac
3483382ff0afSmrg	fi
3484382ff0afSmrg
3485382ff0afSmrg	# Transform deplibs into only deplibs that can be linked in shared.
3486382ff0afSmrg	name_save=$name
3487382ff0afSmrg	libname_save=$libname
3488382ff0afSmrg	release_save=$release
3489382ff0afSmrg	versuffix_save=$versuffix
3490382ff0afSmrg	major_save=$major
3491382ff0afSmrg	# I'm not sure if I'm treating the release correctly.  I think
3492382ff0afSmrg	# release should show up in the -l (ie -lgmp5) so we don't want to
3493382ff0afSmrg	# add it in twice.  Is that correct?
3494382ff0afSmrg	release=""
3495382ff0afSmrg	versuffix=""
3496382ff0afSmrg	major=""
3497382ff0afSmrg	newdeplibs=
3498382ff0afSmrg	droppeddeps=no
3499382ff0afSmrg	case $deplibs_check_method in
3500382ff0afSmrg	pass_all)
3501382ff0afSmrg	  # Don't check for shared/static.  Everything works.
3502382ff0afSmrg	  # This might be a little naive.  We might want to check
3503382ff0afSmrg	  # whether the library exists or not.  But this is on
3504382ff0afSmrg	  # osf3 & osf4 and I'm not really sure... Just
3505382ff0afSmrg	  # implementing what was already the behavior.
3506382ff0afSmrg	  newdeplibs=$deplibs
3507382ff0afSmrg	  ;;
3508382ff0afSmrg	test_compile)
3509382ff0afSmrg	  # This code stresses the "libraries are programs" paradigm to its
3510382ff0afSmrg	  # limits. Maybe even breaks it.  We compile a program, linking it
3511382ff0afSmrg	  # against the deplibs as a proxy for the library.  Then we can check
3512382ff0afSmrg	  # whether they linked in statically or dynamically with ldd.
3513382ff0afSmrg	  $rm conftest.c
3514382ff0afSmrg	  cat > conftest.c <<EOF
3515382ff0afSmrg	  int main() { return 0; }
3516382ff0afSmrgEOF
3517382ff0afSmrg	  $rm conftest
3518382ff0afSmrg	  $LTCC $LTCFLAGS -o conftest conftest.c $deplibs
3519382ff0afSmrg	  if test "$?" -eq 0 ; then
3520382ff0afSmrg	    ldd_output=`ldd conftest`
3521382ff0afSmrg	    for i in $deplibs; do
3522382ff0afSmrg	      name=`expr $i : '-l\(.*\)'`
3523382ff0afSmrg	      # If $name is empty we are operating on a -L argument.
3524382ff0afSmrg              if test "$name" != "" && test "$name" -ne "0"; then
3525382ff0afSmrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3526382ff0afSmrg		  case " $predeps $postdeps " in
3527382ff0afSmrg		  *" $i "*)
3528382ff0afSmrg		    newdeplibs="$newdeplibs $i"
3529382ff0afSmrg		    i=""
3530382ff0afSmrg		    ;;
3531382ff0afSmrg		  esac
3532382ff0afSmrg	        fi
3533382ff0afSmrg		if test -n "$i" ; then
3534382ff0afSmrg		  libname=`eval \\$echo \"$libname_spec\"`
3535382ff0afSmrg		  deplib_matches=`eval \\$echo \"$library_names_spec\"`
3536382ff0afSmrg		  set dummy $deplib_matches
3537382ff0afSmrg		  deplib_match=$2
3538382ff0afSmrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
3539382ff0afSmrg		    newdeplibs="$newdeplibs $i"
3540382ff0afSmrg		  else
3541382ff0afSmrg		    droppeddeps=yes
3542382ff0afSmrg		    $echo
3543382ff0afSmrg		    $echo "*** Warning: dynamic linker does not accept needed library $i."
3544382ff0afSmrg		    $echo "*** I have the capability to make that library automatically link in when"
3545382ff0afSmrg		    $echo "*** you link to this library.  But I can only do this if you have a"
3546382ff0afSmrg		    $echo "*** shared version of the library, which I believe you do not have"
3547382ff0afSmrg		    $echo "*** because a test_compile did reveal that the linker did not use it for"
3548382ff0afSmrg		    $echo "*** its dynamic dependency list that programs get resolved with at runtime."
3549382ff0afSmrg		  fi
3550382ff0afSmrg		fi
3551382ff0afSmrg	      else
3552382ff0afSmrg		newdeplibs="$newdeplibs $i"
3553382ff0afSmrg	      fi
3554382ff0afSmrg	    done
3555382ff0afSmrg	  else
3556382ff0afSmrg	    # Error occurred in the first compile.  Let's try to salvage
3557382ff0afSmrg	    # the situation: Compile a separate program for each library.
3558382ff0afSmrg	    for i in $deplibs; do
3559382ff0afSmrg	      name=`expr $i : '-l\(.*\)'`
3560382ff0afSmrg	      # If $name is empty we are operating on a -L argument.
3561382ff0afSmrg              if test "$name" != "" && test "$name" != "0"; then
3562382ff0afSmrg		$rm conftest
3563382ff0afSmrg		$LTCC $LTCFLAGS -o conftest conftest.c $i
3564382ff0afSmrg		# Did it work?
3565382ff0afSmrg		if test "$?" -eq 0 ; then
3566382ff0afSmrg		  ldd_output=`ldd conftest`
3567382ff0afSmrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3568382ff0afSmrg		    case " $predeps $postdeps " in
3569382ff0afSmrg		    *" $i "*)
3570382ff0afSmrg		      newdeplibs="$newdeplibs $i"
3571382ff0afSmrg		      i=""
3572382ff0afSmrg		      ;;
3573382ff0afSmrg		    esac
3574382ff0afSmrg		  fi
3575382ff0afSmrg		  if test -n "$i" ; then
3576382ff0afSmrg		    libname=`eval \\$echo \"$libname_spec\"`
3577382ff0afSmrg		    deplib_matches=`eval \\$echo \"$library_names_spec\"`
3578382ff0afSmrg		    set dummy $deplib_matches
3579382ff0afSmrg		    deplib_match=$2
3580382ff0afSmrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
3581382ff0afSmrg		      newdeplibs="$newdeplibs $i"
3582382ff0afSmrg		    else
3583382ff0afSmrg		      droppeddeps=yes
3584382ff0afSmrg		      $echo
3585382ff0afSmrg		      $echo "*** Warning: dynamic linker does not accept needed library $i."
3586382ff0afSmrg		      $echo "*** I have the capability to make that library automatically link in when"
3587382ff0afSmrg		      $echo "*** you link to this library.  But I can only do this if you have a"
3588382ff0afSmrg		      $echo "*** shared version of the library, which you do not appear to have"
3589382ff0afSmrg		      $echo "*** because a test_compile did reveal that the linker did not use this one"
3590382ff0afSmrg		      $echo "*** as a dynamic dependency that programs can get resolved with at runtime."
3591382ff0afSmrg		    fi
3592382ff0afSmrg		  fi
3593382ff0afSmrg		else
3594382ff0afSmrg		  droppeddeps=yes
3595382ff0afSmrg		  $echo
3596382ff0afSmrg		  $echo "*** Warning!  Library $i is needed by this library but I was not able to"
3597382ff0afSmrg		  $echo "***  make it link in!  You will probably need to install it or some"
3598382ff0afSmrg		  $echo "*** library that it depends on before this library will be fully"
3599382ff0afSmrg		  $echo "*** functional.  Installing it before continuing would be even better."
3600382ff0afSmrg		fi
3601382ff0afSmrg	      else
3602382ff0afSmrg		newdeplibs="$newdeplibs $i"
3603382ff0afSmrg	      fi
3604382ff0afSmrg	    done
3605382ff0afSmrg	  fi
3606382ff0afSmrg	  ;;
3607382ff0afSmrg	file_magic*)
3608382ff0afSmrg	  set dummy $deplibs_check_method
3609382ff0afSmrg	  file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
3610382ff0afSmrg	  for a_deplib in $deplibs; do
3611382ff0afSmrg	    name=`expr $a_deplib : '-l\(.*\)'`
3612382ff0afSmrg	    # If $name is empty we are operating on a -L argument.
3613382ff0afSmrg            if test "$name" != "" && test  "$name" != "0"; then
3614382ff0afSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3615382ff0afSmrg		case " $predeps $postdeps " in
3616382ff0afSmrg		*" $a_deplib "*)
3617382ff0afSmrg		  newdeplibs="$newdeplibs $a_deplib"
3618382ff0afSmrg		  a_deplib=""
3619382ff0afSmrg		  ;;
3620382ff0afSmrg		esac
3621382ff0afSmrg	      fi
3622382ff0afSmrg	      if test -n "$a_deplib" ; then
3623382ff0afSmrg		libname=`eval \\$echo \"$libname_spec\"`
3624382ff0afSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
3625382ff0afSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
3626382ff0afSmrg		  for potent_lib in $potential_libs; do
3627382ff0afSmrg		      # Follow soft links.
3628382ff0afSmrg		      if ls -lLd "$potent_lib" 2>/dev/null \
3629382ff0afSmrg			 | grep " -> " >/dev/null; then
3630382ff0afSmrg			continue
3631382ff0afSmrg		      fi
3632382ff0afSmrg		      # The statement above tries to avoid entering an
3633382ff0afSmrg		      # endless loop below, in case of cyclic links.
3634382ff0afSmrg		      # We might still enter an endless loop, since a link
3635382ff0afSmrg		      # loop can be closed while we follow links,
3636382ff0afSmrg		      # but so what?
3637382ff0afSmrg		      potlib="$potent_lib"
3638382ff0afSmrg		      while test -h "$potlib" 2>/dev/null; do
3639382ff0afSmrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
3640382ff0afSmrg			case $potliblink in
3641382ff0afSmrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
3642382ff0afSmrg			*) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
3643382ff0afSmrg			esac
3644382ff0afSmrg		      done
3645382ff0afSmrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
3646382ff0afSmrg			 | ${SED} 10q \
3647382ff0afSmrg			 | $EGREP "$file_magic_regex" > /dev/null; then
3648382ff0afSmrg			newdeplibs="$newdeplibs $a_deplib"
3649382ff0afSmrg			a_deplib=""
3650382ff0afSmrg			break 2
3651382ff0afSmrg		      fi
3652382ff0afSmrg		  done
3653382ff0afSmrg		done
3654382ff0afSmrg	      fi
3655382ff0afSmrg	      if test -n "$a_deplib" ; then
3656382ff0afSmrg		droppeddeps=yes
3657382ff0afSmrg		$echo
3658382ff0afSmrg		$echo "*** Warning: linker path does not have real file for library $a_deplib."
3659382ff0afSmrg		$echo "*** I have the capability to make that library automatically link in when"
3660382ff0afSmrg		$echo "*** you link to this library.  But I can only do this if you have a"
3661382ff0afSmrg		$echo "*** shared version of the library, which you do not appear to have"
3662382ff0afSmrg		$echo "*** because I did check the linker path looking for a file starting"
3663382ff0afSmrg		if test -z "$potlib" ; then
3664382ff0afSmrg		  $echo "*** with $libname but no candidates were found. (...for file magic test)"
3665382ff0afSmrg		else
3666382ff0afSmrg		  $echo "*** with $libname and none of the candidates passed a file format test"
3667382ff0afSmrg		  $echo "*** using a file magic. Last file checked: $potlib"
3668382ff0afSmrg		fi
3669382ff0afSmrg	      fi
3670382ff0afSmrg	    else
3671382ff0afSmrg	      # Add a -L argument.
3672382ff0afSmrg	      newdeplibs="$newdeplibs $a_deplib"
3673382ff0afSmrg	    fi
3674382ff0afSmrg	  done # Gone through all deplibs.
3675382ff0afSmrg	  ;;
3676382ff0afSmrg	match_pattern*)
3677382ff0afSmrg	  set dummy $deplibs_check_method
3678382ff0afSmrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
3679382ff0afSmrg	  for a_deplib in $deplibs; do
3680382ff0afSmrg	    name=`expr $a_deplib : '-l\(.*\)'`
3681382ff0afSmrg	    # If $name is empty we are operating on a -L argument.
3682382ff0afSmrg	    if test -n "$name" && test "$name" != "0"; then
3683382ff0afSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3684382ff0afSmrg		case " $predeps $postdeps " in
3685382ff0afSmrg		*" $a_deplib "*)
3686382ff0afSmrg		  newdeplibs="$newdeplibs $a_deplib"
3687382ff0afSmrg		  a_deplib=""
3688382ff0afSmrg		  ;;
3689382ff0afSmrg		esac
3690382ff0afSmrg	      fi
3691382ff0afSmrg	      if test -n "$a_deplib" ; then
3692382ff0afSmrg		libname=`eval \\$echo \"$libname_spec\"`
3693382ff0afSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
3694382ff0afSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
3695382ff0afSmrg		  for potent_lib in $potential_libs; do
3696382ff0afSmrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
3697382ff0afSmrg		    if eval $echo \"$potent_lib\" 2>/dev/null \
3698382ff0afSmrg		        | ${SED} 10q \
3699382ff0afSmrg		        | $EGREP "$match_pattern_regex" > /dev/null; then
3700382ff0afSmrg		      newdeplibs="$newdeplibs $a_deplib"
3701382ff0afSmrg		      a_deplib=""
3702382ff0afSmrg		      break 2
3703382ff0afSmrg		    fi
3704382ff0afSmrg		  done
3705382ff0afSmrg		done
3706382ff0afSmrg	      fi
3707382ff0afSmrg	      if test -n "$a_deplib" ; then
3708382ff0afSmrg		droppeddeps=yes
3709382ff0afSmrg		$echo
3710382ff0afSmrg		$echo "*** Warning: linker path does not have real file for library $a_deplib."
3711382ff0afSmrg		$echo "*** I have the capability to make that library automatically link in when"
3712382ff0afSmrg		$echo "*** you link to this library.  But I can only do this if you have a"
3713382ff0afSmrg		$echo "*** shared version of the library, which you do not appear to have"
3714382ff0afSmrg		$echo "*** because I did check the linker path looking for a file starting"
3715382ff0afSmrg		if test -z "$potlib" ; then
3716382ff0afSmrg		  $echo "*** with $libname but no candidates were found. (...for regex pattern test)"
3717382ff0afSmrg		else
3718382ff0afSmrg		  $echo "*** with $libname and none of the candidates passed a file format test"
3719382ff0afSmrg		  $echo "*** using a regex pattern. Last file checked: $potlib"
3720382ff0afSmrg		fi
3721382ff0afSmrg	      fi
3722382ff0afSmrg	    else
3723382ff0afSmrg	      # Add a -L argument.
3724382ff0afSmrg	      newdeplibs="$newdeplibs $a_deplib"
3725382ff0afSmrg	    fi
3726382ff0afSmrg	  done # Gone through all deplibs.
3727382ff0afSmrg	  ;;
3728382ff0afSmrg	none | unknown | *)
3729382ff0afSmrg	  newdeplibs=""
3730382ff0afSmrg	  tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
3731382ff0afSmrg	    -e 's/ -[LR][^ ]*//g'`
3732382ff0afSmrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3733382ff0afSmrg	    for i in $predeps $postdeps ; do
3734382ff0afSmrg	      # can't use Xsed below, because $i might contain '/'
3735382ff0afSmrg	      tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"`
3736382ff0afSmrg	    done
3737382ff0afSmrg	  fi
3738382ff0afSmrg	  if $echo "X $tmp_deplibs" | $Xsed -e 's/[ 	]//g' \
3739382ff0afSmrg	    | grep . >/dev/null; then
3740382ff0afSmrg	    $echo
3741382ff0afSmrg	    if test "X$deplibs_check_method" = "Xnone"; then
3742382ff0afSmrg	      $echo "*** Warning: inter-library dependencies are not supported in this platform."
3743382ff0afSmrg	    else
3744382ff0afSmrg	      $echo "*** Warning: inter-library dependencies are not known to be supported."
3745382ff0afSmrg	    fi
3746382ff0afSmrg	    $echo "*** All declared inter-library dependencies are being dropped."
3747382ff0afSmrg	    droppeddeps=yes
3748382ff0afSmrg	  fi
3749382ff0afSmrg	  ;;
3750382ff0afSmrg	esac
3751382ff0afSmrg	versuffix=$versuffix_save
3752382ff0afSmrg	major=$major_save
3753382ff0afSmrg	release=$release_save
3754382ff0afSmrg	libname=$libname_save
3755382ff0afSmrg	name=$name_save
3756382ff0afSmrg
3757382ff0afSmrg	case $host in
3758382ff0afSmrg	*-*-rhapsody* | *-*-darwin1.[012])
3759382ff0afSmrg	  # On Rhapsody replace the C library is the System framework
3760382ff0afSmrg	  newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'`
3761382ff0afSmrg	  ;;
3762382ff0afSmrg	esac
3763382ff0afSmrg
3764382ff0afSmrg	if test "$droppeddeps" = yes; then
3765382ff0afSmrg	  if test "$module" = yes; then
3766382ff0afSmrg	    $echo
3767382ff0afSmrg	    $echo "*** Warning: libtool could not satisfy all declared inter-library"
3768382ff0afSmrg	    $echo "*** dependencies of module $libname.  Therefore, libtool will create"
3769382ff0afSmrg	    $echo "*** a static module, that should work as long as the dlopening"
3770382ff0afSmrg	    $echo "*** application is linked with the -dlopen flag."
3771382ff0afSmrg	    if test -z "$global_symbol_pipe"; then
3772382ff0afSmrg	      $echo
3773382ff0afSmrg	      $echo "*** However, this would only work if libtool was able to extract symbol"
3774382ff0afSmrg	      $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
3775382ff0afSmrg	      $echo "*** not find such a program.  So, this module is probably useless."
3776382ff0afSmrg	      $echo "*** \`nm' from GNU binutils and a full rebuild may help."
3777382ff0afSmrg	    fi
3778382ff0afSmrg	    if test "$build_old_libs" = no; then
3779382ff0afSmrg	      oldlibs="$output_objdir/$libname.$libext"
3780382ff0afSmrg	      build_libtool_libs=module
3781382ff0afSmrg	      build_old_libs=yes
3782382ff0afSmrg	    else
3783382ff0afSmrg	      build_libtool_libs=no
3784382ff0afSmrg	    fi
3785382ff0afSmrg	  else
3786382ff0afSmrg	    $echo "*** The inter-library dependencies that have been dropped here will be"
3787382ff0afSmrg	    $echo "*** automatically added whenever a program is linked with this library"
3788382ff0afSmrg	    $echo "*** or is declared to -dlopen it."
3789382ff0afSmrg
3790382ff0afSmrg	    if test "$allow_undefined" = no; then
3791382ff0afSmrg	      $echo
3792382ff0afSmrg	      $echo "*** Since this library must not contain undefined symbols,"
3793382ff0afSmrg	      $echo "*** because either the platform does not support them or"
3794382ff0afSmrg	      $echo "*** it was explicitly requested with -no-undefined,"
3795382ff0afSmrg	      $echo "*** libtool will only create a static version of it."
3796382ff0afSmrg	      if test "$build_old_libs" = no; then
3797382ff0afSmrg		oldlibs="$output_objdir/$libname.$libext"
3798382ff0afSmrg		build_libtool_libs=module
3799382ff0afSmrg		build_old_libs=yes
3800382ff0afSmrg	      else
3801382ff0afSmrg		build_libtool_libs=no
3802382ff0afSmrg	      fi
3803382ff0afSmrg	    fi
3804382ff0afSmrg	  fi
3805382ff0afSmrg	fi
3806382ff0afSmrg	# Done checking deplibs!
3807382ff0afSmrg	deplibs=$newdeplibs
3808382ff0afSmrg      fi
3809382ff0afSmrg
3810382ff0afSmrg
3811382ff0afSmrg      # move library search paths that coincide with paths to not yet
3812382ff0afSmrg      # installed libraries to the beginning of the library search list
3813382ff0afSmrg      new_libs=
3814382ff0afSmrg      for path in $notinst_path; do
3815382ff0afSmrg	case " $new_libs " in
3816382ff0afSmrg	*" -L$path/$objdir "*) ;;
3817382ff0afSmrg	*)
3818382ff0afSmrg	  case " $deplibs " in
3819382ff0afSmrg	  *" -L$path/$objdir "*)
3820382ff0afSmrg	    new_libs="$new_libs -L$path/$objdir" ;;
3821382ff0afSmrg	  esac
3822382ff0afSmrg	  ;;
3823382ff0afSmrg	esac
3824382ff0afSmrg      done
3825382ff0afSmrg      for deplib in $deplibs; do
3826382ff0afSmrg	case $deplib in
3827382ff0afSmrg	-L*)
3828382ff0afSmrg	  case " $new_libs " in
3829382ff0afSmrg	  *" $deplib "*) ;;
3830382ff0afSmrg	  *) new_libs="$new_libs $deplib" ;;
3831382ff0afSmrg	  esac
3832382ff0afSmrg	  ;;
3833382ff0afSmrg	*) new_libs="$new_libs $deplib" ;;
3834382ff0afSmrg	esac
3835382ff0afSmrg      done
3836382ff0afSmrg      deplibs="$new_libs"
3837382ff0afSmrg
3838382ff0afSmrg
3839382ff0afSmrg      # All the library-specific variables (install_libdir is set above).
3840382ff0afSmrg      library_names=
3841382ff0afSmrg      old_library=
3842382ff0afSmrg      dlname=
3843382ff0afSmrg
3844382ff0afSmrg      # Test again, we may have decided not to build it any more
3845382ff0afSmrg      if test "$build_libtool_libs" = yes; then
3846382ff0afSmrg	if test "$hardcode_into_libs" = yes; then
3847382ff0afSmrg	  # Hardcode the library paths
3848382ff0afSmrg	  hardcode_libdirs=
3849382ff0afSmrg	  dep_rpath=
3850382ff0afSmrg	  rpath="$finalize_rpath"
3851382ff0afSmrg	  test "$mode" != relink && rpath="$compile_rpath$rpath"
3852382ff0afSmrg	  for libdir in $rpath; do
3853382ff0afSmrg	    if test -n "$hardcode_libdir_flag_spec"; then
3854382ff0afSmrg	      if test -n "$hardcode_libdir_separator"; then
3855382ff0afSmrg		if test -z "$hardcode_libdirs"; then
3856382ff0afSmrg		  hardcode_libdirs="$libdir"
3857382ff0afSmrg		else
3858382ff0afSmrg		  # Just accumulate the unique libdirs.
3859382ff0afSmrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
3860382ff0afSmrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
3861382ff0afSmrg		    ;;
3862382ff0afSmrg		  *)
3863382ff0afSmrg		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
3864382ff0afSmrg		    ;;
3865382ff0afSmrg		  esac
3866382ff0afSmrg		fi
3867382ff0afSmrg	      else
3868382ff0afSmrg		eval flag=\"$hardcode_libdir_flag_spec\"
3869382ff0afSmrg		dep_rpath="$dep_rpath $flag"
3870382ff0afSmrg	      fi
3871382ff0afSmrg	    elif test -n "$runpath_var"; then
3872382ff0afSmrg	      case "$perm_rpath " in
3873382ff0afSmrg	      *" $libdir "*) ;;
3874382ff0afSmrg	      *) perm_rpath="$perm_rpath $libdir" ;;
3875382ff0afSmrg	      esac
3876382ff0afSmrg	    fi
3877382ff0afSmrg	  done
3878382ff0afSmrg	  # Substitute the hardcoded libdirs into the rpath.
3879382ff0afSmrg	  if test -n "$hardcode_libdir_separator" &&
3880382ff0afSmrg	     test -n "$hardcode_libdirs"; then
3881382ff0afSmrg	    libdir="$hardcode_libdirs"
3882382ff0afSmrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
3883382ff0afSmrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
3884382ff0afSmrg	    else
3885382ff0afSmrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
3886382ff0afSmrg	    fi
3887382ff0afSmrg	  fi
3888382ff0afSmrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
3889382ff0afSmrg	    # We should set the runpath_var.
3890382ff0afSmrg	    rpath=
3891382ff0afSmrg	    for dir in $perm_rpath; do
3892382ff0afSmrg	      rpath="$rpath$dir:"
3893382ff0afSmrg	    done
3894382ff0afSmrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
3895382ff0afSmrg	  fi
3896382ff0afSmrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
3897382ff0afSmrg	fi
3898382ff0afSmrg
3899382ff0afSmrg	shlibpath="$finalize_shlibpath"
3900382ff0afSmrg	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
3901382ff0afSmrg	if test -n "$shlibpath"; then
3902382ff0afSmrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
3903382ff0afSmrg	fi
3904382ff0afSmrg
3905382ff0afSmrg	# Get the real and link names of the library.
3906382ff0afSmrg	eval shared_ext=\"$shrext_cmds\"
3907382ff0afSmrg	eval library_names=\"$library_names_spec\"
3908382ff0afSmrg	set dummy $library_names
3909382ff0afSmrg	realname="$2"
3910382ff0afSmrg	shift; shift
3911382ff0afSmrg
3912382ff0afSmrg	if test -n "$soname_spec"; then
3913382ff0afSmrg	  eval soname=\"$soname_spec\"
3914382ff0afSmrg	else
3915382ff0afSmrg	  soname="$realname"
3916382ff0afSmrg	fi
3917382ff0afSmrg	if test -z "$dlname"; then
3918382ff0afSmrg	  dlname=$soname
3919382ff0afSmrg	fi
3920382ff0afSmrg
3921382ff0afSmrg	lib="$output_objdir/$realname"
3922382ff0afSmrg	linknames=
3923382ff0afSmrg	for link
3924382ff0afSmrg	do
3925382ff0afSmrg	  linknames="$linknames $link"
3926382ff0afSmrg	done
3927382ff0afSmrg
3928382ff0afSmrg	# Use standard objects if they are pic
3929382ff0afSmrg	test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
3930382ff0afSmrg
3931382ff0afSmrg	# Prepare the list of exported symbols
3932382ff0afSmrg	if test -z "$export_symbols"; then
3933382ff0afSmrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
3934382ff0afSmrg	    $show "generating symbol list for \`$libname.la'"
3935382ff0afSmrg	    export_symbols="$output_objdir/$libname.exp"
3936382ff0afSmrg	    $run $rm $export_symbols
3937382ff0afSmrg	    cmds=$export_symbols_cmds
3938382ff0afSmrg	    save_ifs="$IFS"; IFS='~'
3939382ff0afSmrg	    for cmd in $cmds; do
3940382ff0afSmrg	      IFS="$save_ifs"
3941382ff0afSmrg	      eval cmd=\"$cmd\"
3942382ff0afSmrg	      if len=`expr "X$cmd" : ".*"` &&
3943382ff0afSmrg	       test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
3944382ff0afSmrg	        $show "$cmd"
3945382ff0afSmrg	        $run eval "$cmd" || exit $?
3946382ff0afSmrg	        skipped_export=false
3947382ff0afSmrg	      else
3948382ff0afSmrg	        # The command line is too long to execute in one step.
3949382ff0afSmrg	        $show "using reloadable object file for export list..."
3950382ff0afSmrg	        skipped_export=:
3951382ff0afSmrg		# Break out early, otherwise skipped_export may be
3952382ff0afSmrg		# set to false by a later but shorter cmd.
3953382ff0afSmrg		break
3954382ff0afSmrg	      fi
3955382ff0afSmrg	    done
3956382ff0afSmrg	    IFS="$save_ifs"
3957382ff0afSmrg	    if test -n "$export_symbols_regex"; then
3958382ff0afSmrg	      $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
3959382ff0afSmrg	      $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
3960382ff0afSmrg	      $show "$mv \"${export_symbols}T\" \"$export_symbols\""
3961382ff0afSmrg	      $run eval '$mv "${export_symbols}T" "$export_symbols"'
3962382ff0afSmrg	    fi
3963382ff0afSmrg	  fi
3964382ff0afSmrg	fi
3965382ff0afSmrg
3966382ff0afSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
3967382ff0afSmrg	  $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
3968382ff0afSmrg	fi
3969382ff0afSmrg
3970382ff0afSmrg	tmp_deplibs=
3971382ff0afSmrg	for test_deplib in $deplibs; do
3972382ff0afSmrg		case " $convenience " in
3973382ff0afSmrg		*" $test_deplib "*) ;;
3974382ff0afSmrg		*)
3975382ff0afSmrg			tmp_deplibs="$tmp_deplibs $test_deplib"
3976382ff0afSmrg			;;
3977382ff0afSmrg		esac
3978382ff0afSmrg	done
3979382ff0afSmrg	deplibs="$tmp_deplibs"
3980382ff0afSmrg
3981382ff0afSmrg	if test -n "$convenience"; then
3982382ff0afSmrg	  if test -n "$whole_archive_flag_spec"; then
3983382ff0afSmrg	    save_libobjs=$libobjs
3984382ff0afSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
3985382ff0afSmrg	  else
3986382ff0afSmrg	    gentop="$output_objdir/${outputname}x"
3987382ff0afSmrg	    generated="$generated $gentop"
3988382ff0afSmrg
3989382ff0afSmrg	    func_extract_archives $gentop $convenience
3990382ff0afSmrg	    libobjs="$libobjs $func_extract_archives_result"
3991382ff0afSmrg	  fi
3992382ff0afSmrg	fi
3993382ff0afSmrg	
3994382ff0afSmrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
3995382ff0afSmrg	  eval flag=\"$thread_safe_flag_spec\"
3996382ff0afSmrg	  linker_flags="$linker_flags $flag"
3997382ff0afSmrg	fi
3998382ff0afSmrg
3999382ff0afSmrg	# Make a backup of the uninstalled library when relinking
4000382ff0afSmrg	if test "$mode" = relink; then
4001382ff0afSmrg	  $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $?
4002382ff0afSmrg	fi
4003382ff0afSmrg
4004382ff0afSmrg	# Do each of the archive commands.
4005382ff0afSmrg	if test "$module" = yes && test -n "$module_cmds" ; then
4006382ff0afSmrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
4007382ff0afSmrg	    eval test_cmds=\"$module_expsym_cmds\"
4008382ff0afSmrg	    cmds=$module_expsym_cmds
4009382ff0afSmrg	  else
4010382ff0afSmrg	    eval test_cmds=\"$module_cmds\"
4011382ff0afSmrg	    cmds=$module_cmds
4012382ff0afSmrg	  fi
4013382ff0afSmrg	else
4014382ff0afSmrg	if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
4015382ff0afSmrg	  eval test_cmds=\"$archive_expsym_cmds\"
4016382ff0afSmrg	  cmds=$archive_expsym_cmds
4017382ff0afSmrg	else
4018382ff0afSmrg	  eval test_cmds=\"$archive_cmds\"
4019382ff0afSmrg	  cmds=$archive_cmds
4020382ff0afSmrg	  fi
4021382ff0afSmrg	fi
4022382ff0afSmrg
4023382ff0afSmrg	if test "X$skipped_export" != "X:" &&
4024382ff0afSmrg	   len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
4025382ff0afSmrg	   test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
4026382ff0afSmrg	  :
4027382ff0afSmrg	else
4028382ff0afSmrg	  # The command line is too long to link in one step, link piecewise.
4029382ff0afSmrg	  $echo "creating reloadable object files..."
4030382ff0afSmrg
4031382ff0afSmrg	  # Save the value of $output and $libobjs because we want to
4032382ff0afSmrg	  # use them later.  If we have whole_archive_flag_spec, we
4033382ff0afSmrg	  # want to use save_libobjs as it was before
4034382ff0afSmrg	  # whole_archive_flag_spec was expanded, because we can't
4035382ff0afSmrg	  # assume the linker understands whole_archive_flag_spec.
4036382ff0afSmrg	  # This may have to be revisited, in case too many
4037382ff0afSmrg	  # convenience libraries get linked in and end up exceeding
4038382ff0afSmrg	  # the spec.
4039382ff0afSmrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
4040382ff0afSmrg	    save_libobjs=$libobjs
4041382ff0afSmrg	  fi
4042382ff0afSmrg	  save_output=$output
4043382ff0afSmrg	  output_la=`$echo "X$output" | $Xsed -e "$basename"`
4044382ff0afSmrg
4045382ff0afSmrg	  # Clear the reloadable object creation command queue and
4046382ff0afSmrg	  # initialize k to one.
4047382ff0afSmrg	  test_cmds=
4048382ff0afSmrg	  concat_cmds=
4049382ff0afSmrg	  objlist=
4050382ff0afSmrg	  delfiles=
4051382ff0afSmrg	  last_robj=
4052382ff0afSmrg	  k=1
4053382ff0afSmrg	  output=$output_objdir/$output_la-${k}.$objext
4054382ff0afSmrg	  # Loop over the list of objects to be linked.
4055382ff0afSmrg	  for obj in $save_libobjs
4056382ff0afSmrg	  do
4057382ff0afSmrg	    eval test_cmds=\"$reload_cmds $objlist $last_robj\"
4058382ff0afSmrg	    if test "X$objlist" = X ||
4059382ff0afSmrg	       { len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
4060382ff0afSmrg		 test "$len" -le "$max_cmd_len"; }; then
4061382ff0afSmrg	      objlist="$objlist $obj"
4062382ff0afSmrg	    else
4063382ff0afSmrg	      # The command $test_cmds is almost too long, add a
4064382ff0afSmrg	      # command to the queue.
4065382ff0afSmrg	      if test "$k" -eq 1 ; then
4066382ff0afSmrg		# The first file doesn't have a previous command to add.
4067382ff0afSmrg		eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
4068382ff0afSmrg	      else
4069382ff0afSmrg		# All subsequent reloadable object files will link in
4070382ff0afSmrg		# the last one created.
4071382ff0afSmrg		eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
4072382ff0afSmrg	      fi
4073382ff0afSmrg	      last_robj=$output_objdir/$output_la-${k}.$objext
4074382ff0afSmrg	      k=`expr $k + 1`
4075382ff0afSmrg	      output=$output_objdir/$output_la-${k}.$objext
4076382ff0afSmrg	      objlist=$obj
4077382ff0afSmrg	      len=1
4078382ff0afSmrg	    fi
4079382ff0afSmrg	  done
4080382ff0afSmrg	  # Handle the remaining objects by creating one last
4081382ff0afSmrg	  # reloadable object file.  All subsequent reloadable object
4082382ff0afSmrg	  # files will link in the last one created.
4083382ff0afSmrg	  test -z "$concat_cmds" || concat_cmds=$concat_cmds~
4084382ff0afSmrg	  eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
4085382ff0afSmrg
4086382ff0afSmrg	  if ${skipped_export-false}; then
4087382ff0afSmrg	    $show "generating symbol list for \`$libname.la'"
4088382ff0afSmrg	    export_symbols="$output_objdir/$libname.exp"
4089382ff0afSmrg	    $run $rm $export_symbols
4090382ff0afSmrg	    libobjs=$output
4091382ff0afSmrg	    # Append the command to create the export file.
4092382ff0afSmrg	    eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
4093382ff0afSmrg          fi
4094382ff0afSmrg
4095382ff0afSmrg	  # Set up a command to remove the reloadable object files
4096382ff0afSmrg	  # after they are used.
4097382ff0afSmrg	  i=0
4098382ff0afSmrg	  while test "$i" -lt "$k"
4099382ff0afSmrg	  do
4100382ff0afSmrg	    i=`expr $i + 1`
4101382ff0afSmrg	    delfiles="$delfiles $output_objdir/$output_la-${i}.$objext"
4102382ff0afSmrg	  done
4103382ff0afSmrg
4104382ff0afSmrg	  $echo "creating a temporary reloadable object file: $output"
4105382ff0afSmrg
4106382ff0afSmrg	  # Loop through the commands generated above and execute them.
4107382ff0afSmrg	  save_ifs="$IFS"; IFS='~'
4108382ff0afSmrg	  for cmd in $concat_cmds; do
4109382ff0afSmrg	    IFS="$save_ifs"
4110382ff0afSmrg	    $show "$cmd"
4111382ff0afSmrg	    $run eval "$cmd" || exit $?
4112382ff0afSmrg	  done
4113382ff0afSmrg	  IFS="$save_ifs"
4114382ff0afSmrg
4115382ff0afSmrg	  libobjs=$output
4116382ff0afSmrg	  # Restore the value of output.
4117382ff0afSmrg	  output=$save_output
4118382ff0afSmrg
4119382ff0afSmrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
4120382ff0afSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
4121382ff0afSmrg	  fi
4122382ff0afSmrg	  # Expand the library linking commands again to reset the
4123382ff0afSmrg	  # value of $libobjs for piecewise linking.
4124382ff0afSmrg
4125382ff0afSmrg	  # Do each of the archive commands.
4126382ff0afSmrg	  if test "$module" = yes && test -n "$module_cmds" ; then
4127382ff0afSmrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
4128382ff0afSmrg	      cmds=$module_expsym_cmds
4129382ff0afSmrg	    else
4130382ff0afSmrg	      cmds=$module_cmds
4131382ff0afSmrg	    fi
4132382ff0afSmrg	  else
4133382ff0afSmrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
4134382ff0afSmrg	    cmds=$archive_expsym_cmds
4135382ff0afSmrg	  else
4136382ff0afSmrg	    cmds=$archive_cmds
4137382ff0afSmrg	    fi
4138382ff0afSmrg	  fi
4139382ff0afSmrg
4140382ff0afSmrg	  # Append the command to remove the reloadable object files
4141382ff0afSmrg	  # to the just-reset $cmds.
4142382ff0afSmrg	  eval cmds=\"\$cmds~\$rm $delfiles\"
4143382ff0afSmrg	fi
4144382ff0afSmrg	save_ifs="$IFS"; IFS='~'
4145382ff0afSmrg	for cmd in $cmds; do
4146382ff0afSmrg	  IFS="$save_ifs"
4147382ff0afSmrg	  eval cmd=\"$cmd\"
4148382ff0afSmrg	  $show "$cmd"
4149382ff0afSmrg	  $run eval "$cmd" || {
4150382ff0afSmrg	    lt_exit=$?
4151382ff0afSmrg
4152382ff0afSmrg	    # Restore the uninstalled library and exit
4153382ff0afSmrg	    if test "$mode" = relink; then
4154382ff0afSmrg	      $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
4155382ff0afSmrg	    fi
4156382ff0afSmrg
4157382ff0afSmrg	    exit $lt_exit
4158382ff0afSmrg	  }
4159382ff0afSmrg	done
4160382ff0afSmrg	IFS="$save_ifs"
4161382ff0afSmrg
4162382ff0afSmrg	# Restore the uninstalled library and exit
4163382ff0afSmrg	if test "$mode" = relink; then
4164382ff0afSmrg	  $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
4165382ff0afSmrg
4166382ff0afSmrg	  if test -n "$convenience"; then
4167382ff0afSmrg	    if test -z "$whole_archive_flag_spec"; then
4168382ff0afSmrg	      $show "${rm}r $gentop"
4169382ff0afSmrg	      $run ${rm}r "$gentop"
4170382ff0afSmrg	    fi
4171382ff0afSmrg	  fi
4172382ff0afSmrg
4173382ff0afSmrg	  exit $EXIT_SUCCESS
4174382ff0afSmrg	fi
4175382ff0afSmrg
4176382ff0afSmrg	# Create links to the real library.
4177382ff0afSmrg	for linkname in $linknames; do
4178382ff0afSmrg	  if test "$realname" != "$linkname"; then
4179382ff0afSmrg	    $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
4180382ff0afSmrg	    $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
4181382ff0afSmrg	  fi
4182382ff0afSmrg	done
4183382ff0afSmrg
4184382ff0afSmrg	# If -module or -export-dynamic was specified, set the dlname.
4185382ff0afSmrg	if test "$module" = yes || test "$export_dynamic" = yes; then
4186382ff0afSmrg	  # On all known operating systems, these are identical.
4187382ff0afSmrg	  dlname="$soname"
4188382ff0afSmrg	fi
4189382ff0afSmrg      fi
4190382ff0afSmrg      ;;
4191382ff0afSmrg
4192382ff0afSmrg    obj)
4193382ff0afSmrg      if test -n "$deplibs"; then
4194382ff0afSmrg	$echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
4195382ff0afSmrg      fi
4196382ff0afSmrg
4197382ff0afSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
4198382ff0afSmrg	$echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
4199382ff0afSmrg      fi
4200382ff0afSmrg
4201382ff0afSmrg      if test -n "$rpath"; then
4202382ff0afSmrg	$echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
4203382ff0afSmrg      fi
4204382ff0afSmrg
4205382ff0afSmrg      if test -n "$xrpath"; then
4206382ff0afSmrg	$echo "$modename: warning: \`-R' is ignored for objects" 1>&2
4207382ff0afSmrg      fi
4208382ff0afSmrg
4209382ff0afSmrg      if test -n "$vinfo"; then
4210382ff0afSmrg	$echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
4211382ff0afSmrg      fi
4212382ff0afSmrg
4213382ff0afSmrg      if test -n "$release"; then
4214382ff0afSmrg	$echo "$modename: warning: \`-release' is ignored for objects" 1>&2
4215382ff0afSmrg      fi
4216382ff0afSmrg
4217382ff0afSmrg      case $output in
4218382ff0afSmrg      *.lo)
4219382ff0afSmrg	if test -n "$objs$old_deplibs"; then
4220382ff0afSmrg	  $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
4221382ff0afSmrg	  exit $EXIT_FAILURE
4222382ff0afSmrg	fi
4223382ff0afSmrg	libobj="$output"
4224382ff0afSmrg	obj=`$echo "X$output" | $Xsed -e "$lo2o"`
4225382ff0afSmrg	;;
4226382ff0afSmrg      *)
4227382ff0afSmrg	libobj=
4228382ff0afSmrg	obj="$output"
4229382ff0afSmrg	;;
4230382ff0afSmrg      esac
4231382ff0afSmrg
4232382ff0afSmrg      # Delete the old objects.
4233382ff0afSmrg      $run $rm $obj $libobj
4234382ff0afSmrg
4235382ff0afSmrg      # Objects from convenience libraries.  This assumes
4236382ff0afSmrg      # single-version convenience libraries.  Whenever we create
4237382ff0afSmrg      # different ones for PIC/non-PIC, this we'll have to duplicate
4238382ff0afSmrg      # the extraction.
4239382ff0afSmrg      reload_conv_objs=
4240382ff0afSmrg      gentop=
4241382ff0afSmrg      # reload_cmds runs $LD directly, so let us get rid of
4242382ff0afSmrg      # -Wl from whole_archive_flag_spec
4243382ff0afSmrg      wl=
4244382ff0afSmrg
4245382ff0afSmrg      if test -n "$convenience"; then
4246382ff0afSmrg	if test -n "$whole_archive_flag_spec"; then
4247382ff0afSmrg	  eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
4248382ff0afSmrg	else
4249382ff0afSmrg	  gentop="$output_objdir/${obj}x"
4250382ff0afSmrg	  generated="$generated $gentop"
4251382ff0afSmrg
4252382ff0afSmrg	  func_extract_archives $gentop $convenience
4253382ff0afSmrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
4254382ff0afSmrg	fi
4255382ff0afSmrg      fi
4256382ff0afSmrg
4257382ff0afSmrg      # Create the old-style object.
4258382ff0afSmrg      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
4259382ff0afSmrg
4260382ff0afSmrg      output="$obj"
4261382ff0afSmrg      cmds=$reload_cmds
4262382ff0afSmrg      save_ifs="$IFS"; IFS='~'
4263382ff0afSmrg      for cmd in $cmds; do
4264382ff0afSmrg	IFS="$save_ifs"
4265382ff0afSmrg	eval cmd=\"$cmd\"
4266382ff0afSmrg	$show "$cmd"
4267382ff0afSmrg	$run eval "$cmd" || exit $?
4268382ff0afSmrg      done
4269382ff0afSmrg      IFS="$save_ifs"
4270382ff0afSmrg
4271382ff0afSmrg      # Exit if we aren't doing a library object file.
4272382ff0afSmrg      if test -z "$libobj"; then
4273382ff0afSmrg	if test -n "$gentop"; then
4274382ff0afSmrg	  $show "${rm}r $gentop"
4275382ff0afSmrg	  $run ${rm}r $gentop
4276382ff0afSmrg	fi
4277382ff0afSmrg
4278382ff0afSmrg	exit $EXIT_SUCCESS
4279382ff0afSmrg      fi
4280382ff0afSmrg
4281382ff0afSmrg      if test "$build_libtool_libs" != yes; then
4282382ff0afSmrg	if test -n "$gentop"; then
4283382ff0afSmrg	  $show "${rm}r $gentop"
4284382ff0afSmrg	  $run ${rm}r $gentop
4285382ff0afSmrg	fi
4286382ff0afSmrg
4287382ff0afSmrg	# Create an invalid libtool object if no PIC, so that we don't
4288382ff0afSmrg	# accidentally link it into a program.
4289382ff0afSmrg	# $show "echo timestamp > $libobj"
4290382ff0afSmrg	# $run eval "echo timestamp > $libobj" || exit $?
4291382ff0afSmrg	exit $EXIT_SUCCESS
4292382ff0afSmrg      fi
4293382ff0afSmrg
4294382ff0afSmrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
4295382ff0afSmrg	# Only do commands if we really have different PIC objects.
4296382ff0afSmrg	reload_objs="$libobjs $reload_conv_objs"
4297382ff0afSmrg	output="$libobj"
4298382ff0afSmrg	cmds=$reload_cmds
4299382ff0afSmrg	save_ifs="$IFS"; IFS='~'
4300382ff0afSmrg	for cmd in $cmds; do
4301382ff0afSmrg	  IFS="$save_ifs"
4302382ff0afSmrg	  eval cmd=\"$cmd\"
4303382ff0afSmrg	  $show "$cmd"
4304382ff0afSmrg	  $run eval "$cmd" || exit $?
4305382ff0afSmrg	done
4306382ff0afSmrg	IFS="$save_ifs"
4307382ff0afSmrg      fi
4308382ff0afSmrg
4309382ff0afSmrg      if test -n "$gentop"; then
4310382ff0afSmrg	$show "${rm}r $gentop"
4311382ff0afSmrg	$run ${rm}r $gentop
4312382ff0afSmrg      fi
4313382ff0afSmrg
4314382ff0afSmrg      exit $EXIT_SUCCESS
4315382ff0afSmrg      ;;
4316382ff0afSmrg
4317382ff0afSmrg    prog)
4318382ff0afSmrg      case $host in
4319382ff0afSmrg	*cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
4320382ff0afSmrg      esac
4321382ff0afSmrg      if test -n "$vinfo"; then
4322382ff0afSmrg	$echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
4323382ff0afSmrg      fi
4324382ff0afSmrg
4325382ff0afSmrg      if test -n "$release"; then
4326382ff0afSmrg	$echo "$modename: warning: \`-release' is ignored for programs" 1>&2
4327382ff0afSmrg      fi
4328382ff0afSmrg
4329382ff0afSmrg      if test "$preload" = yes; then
4330382ff0afSmrg	if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown &&
4331382ff0afSmrg	   test "$dlopen_self_static" = unknown; then
4332382ff0afSmrg	  $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
4333382ff0afSmrg	fi
4334382ff0afSmrg      fi
4335382ff0afSmrg
4336382ff0afSmrg      case $host in
4337382ff0afSmrg      *-*-rhapsody* | *-*-darwin1.[012])
4338382ff0afSmrg	# On Rhapsody replace the C library is the System framework
4339382ff0afSmrg	compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
4340382ff0afSmrg	finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
4341382ff0afSmrg	;;
4342382ff0afSmrg      esac
4343382ff0afSmrg
4344382ff0afSmrg      case $host in
4345382ff0afSmrg      *darwin*)
4346382ff0afSmrg        # Don't allow lazy linking, it breaks C++ global constructors
4347382ff0afSmrg        if test "$tagname" = CXX ; then
4348382ff0afSmrg        compile_command="$compile_command ${wl}-bind_at_load"
4349382ff0afSmrg        finalize_command="$finalize_command ${wl}-bind_at_load"
4350382ff0afSmrg        fi
4351382ff0afSmrg        ;;
4352382ff0afSmrg      esac
4353382ff0afSmrg
4354382ff0afSmrg
4355382ff0afSmrg      # move library search paths that coincide with paths to not yet
4356382ff0afSmrg      # installed libraries to the beginning of the library search list
4357382ff0afSmrg      new_libs=
4358382ff0afSmrg      for path in $notinst_path; do
4359382ff0afSmrg	case " $new_libs " in
4360382ff0afSmrg	*" -L$path/$objdir "*) ;;
4361382ff0afSmrg	*)
4362382ff0afSmrg	  case " $compile_deplibs " in
4363382ff0afSmrg	  *" -L$path/$objdir "*)
4364382ff0afSmrg	    new_libs="$new_libs -L$path/$objdir" ;;
4365382ff0afSmrg	  esac
4366382ff0afSmrg	  ;;
4367382ff0afSmrg	esac
4368382ff0afSmrg      done
4369382ff0afSmrg      for deplib in $compile_deplibs; do
4370382ff0afSmrg	case $deplib in
4371382ff0afSmrg	-L*)
4372382ff0afSmrg	  case " $new_libs " in
4373382ff0afSmrg	  *" $deplib "*) ;;
4374382ff0afSmrg	  *) new_libs="$new_libs $deplib" ;;
4375382ff0afSmrg	  esac
4376382ff0afSmrg	  ;;
4377382ff0afSmrg	*) new_libs="$new_libs $deplib" ;;
4378382ff0afSmrg	esac
4379382ff0afSmrg      done
4380382ff0afSmrg      compile_deplibs="$new_libs"
4381382ff0afSmrg
4382382ff0afSmrg
4383382ff0afSmrg      compile_command="$compile_command $compile_deplibs"
4384382ff0afSmrg      finalize_command="$finalize_command $finalize_deplibs"
4385382ff0afSmrg
4386382ff0afSmrg      if test -n "$rpath$xrpath"; then
4387382ff0afSmrg	# If the user specified any rpath flags, then add them.
4388382ff0afSmrg	for libdir in $rpath $xrpath; do
4389382ff0afSmrg	  # This is the magic to use -rpath.
4390382ff0afSmrg	  case "$finalize_rpath " in
4391382ff0afSmrg	  *" $libdir "*) ;;
4392382ff0afSmrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
4393382ff0afSmrg	  esac
4394382ff0afSmrg	done
4395382ff0afSmrg      fi
4396382ff0afSmrg
4397382ff0afSmrg      # Now hardcode the library paths
4398382ff0afSmrg      rpath=
4399382ff0afSmrg      hardcode_libdirs=
4400382ff0afSmrg      for libdir in $compile_rpath $finalize_rpath; do
4401382ff0afSmrg	if test -n "$hardcode_libdir_flag_spec"; then
4402382ff0afSmrg	  if test -n "$hardcode_libdir_separator"; then
4403382ff0afSmrg	    if test -z "$hardcode_libdirs"; then
4404382ff0afSmrg	      hardcode_libdirs="$libdir"
4405382ff0afSmrg	    else
4406382ff0afSmrg	      # Just accumulate the unique libdirs.
4407382ff0afSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
4408382ff0afSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
4409382ff0afSmrg		;;
4410382ff0afSmrg	      *)
4411382ff0afSmrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
4412382ff0afSmrg		;;
4413382ff0afSmrg	      esac
4414382ff0afSmrg	    fi
4415382ff0afSmrg	  else
4416382ff0afSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
4417382ff0afSmrg	    rpath="$rpath $flag"
4418382ff0afSmrg	  fi
4419382ff0afSmrg	elif test -n "$runpath_var"; then
4420382ff0afSmrg	  case "$perm_rpath " in
4421382ff0afSmrg	  *" $libdir "*) ;;
4422382ff0afSmrg	  *) perm_rpath="$perm_rpath $libdir" ;;
4423382ff0afSmrg	  esac
4424382ff0afSmrg	fi
4425382ff0afSmrg	case $host in
4426382ff0afSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
4427382ff0afSmrg	  testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'`
4428382ff0afSmrg	  case :$dllsearchpath: in
4429382ff0afSmrg	  *":$libdir:"*) ;;
4430382ff0afSmrg	  *) dllsearchpath="$dllsearchpath:$libdir";;
4431382ff0afSmrg	  esac
4432382ff0afSmrg	  case :$dllsearchpath: in
4433382ff0afSmrg	  *":$testbindir:"*) ;;
4434382ff0afSmrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
4435382ff0afSmrg	  esac
4436382ff0afSmrg	  ;;
4437382ff0afSmrg	esac
4438382ff0afSmrg      done
4439382ff0afSmrg      # Substitute the hardcoded libdirs into the rpath.
4440382ff0afSmrg      if test -n "$hardcode_libdir_separator" &&
4441382ff0afSmrg	 test -n "$hardcode_libdirs"; then
4442382ff0afSmrg	libdir="$hardcode_libdirs"
4443382ff0afSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
4444382ff0afSmrg      fi
4445382ff0afSmrg      compile_rpath="$rpath"
4446382ff0afSmrg
4447382ff0afSmrg      rpath=
4448382ff0afSmrg      hardcode_libdirs=
4449382ff0afSmrg      for libdir in $finalize_rpath; do
4450382ff0afSmrg	if test -n "$hardcode_libdir_flag_spec"; then
4451382ff0afSmrg	  if test -n "$hardcode_libdir_separator"; then
4452382ff0afSmrg	    if test -z "$hardcode_libdirs"; then
4453382ff0afSmrg	      hardcode_libdirs="$libdir"
4454382ff0afSmrg	    else
4455382ff0afSmrg	      # Just accumulate the unique libdirs.
4456382ff0afSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
4457382ff0afSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
4458382ff0afSmrg		;;
4459382ff0afSmrg	      *)
4460382ff0afSmrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
4461382ff0afSmrg		;;
4462382ff0afSmrg	      esac
4463382ff0afSmrg	    fi
4464382ff0afSmrg	  else
4465382ff0afSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
4466382ff0afSmrg	    rpath="$rpath $flag"
4467382ff0afSmrg	  fi
4468382ff0afSmrg	elif test -n "$runpath_var"; then
4469382ff0afSmrg	  case "$finalize_perm_rpath " in
4470382ff0afSmrg	  *" $libdir "*) ;;
4471382ff0afSmrg	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
4472382ff0afSmrg	  esac
4473382ff0afSmrg	fi
4474382ff0afSmrg      done
4475382ff0afSmrg      # Substitute the hardcoded libdirs into the rpath.
4476382ff0afSmrg      if test -n "$hardcode_libdir_separator" &&
4477382ff0afSmrg	 test -n "$hardcode_libdirs"; then
4478382ff0afSmrg	libdir="$hardcode_libdirs"
4479382ff0afSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
4480382ff0afSmrg      fi
4481382ff0afSmrg      finalize_rpath="$rpath"
4482382ff0afSmrg
4483382ff0afSmrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
4484382ff0afSmrg	# Transform all the library objects into standard objects.
4485382ff0afSmrg	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
4486382ff0afSmrg	finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
4487382ff0afSmrg      fi
4488382ff0afSmrg
4489382ff0afSmrg      dlsyms=
4490382ff0afSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
4491382ff0afSmrg	if test -n "$NM" && test -n "$global_symbol_pipe"; then
4492382ff0afSmrg	  dlsyms="${outputname}S.c"
4493382ff0afSmrg	else
4494382ff0afSmrg	  $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
4495382ff0afSmrg	fi
4496382ff0afSmrg      fi
4497382ff0afSmrg
4498382ff0afSmrg      if test -n "$dlsyms"; then
4499382ff0afSmrg	case $dlsyms in
4500382ff0afSmrg	"") ;;
4501382ff0afSmrg	*.c)
4502382ff0afSmrg	  # Discover the nlist of each of the dlfiles.
4503382ff0afSmrg	  nlist="$output_objdir/${outputname}.nm"
4504382ff0afSmrg
4505382ff0afSmrg	  $show "$rm $nlist ${nlist}S ${nlist}T"
4506382ff0afSmrg	  $run $rm "$nlist" "${nlist}S" "${nlist}T"
4507382ff0afSmrg
4508382ff0afSmrg	  # Parse the name list into a source file.
4509382ff0afSmrg	  $show "creating $output_objdir/$dlsyms"
4510382ff0afSmrg
4511382ff0afSmrg	  test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
4512382ff0afSmrg/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
4513382ff0afSmrg/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
4514382ff0afSmrg
4515382ff0afSmrg#ifdef __cplusplus
4516382ff0afSmrgextern \"C\" {
4517382ff0afSmrg#endif
4518382ff0afSmrg
4519382ff0afSmrg/* Prevent the only kind of declaration conflicts we can make. */
4520382ff0afSmrg#define lt_preloaded_symbols some_other_symbol
4521382ff0afSmrg
4522382ff0afSmrg/* External symbol declarations for the compiler. */\
4523382ff0afSmrg"
4524382ff0afSmrg
4525382ff0afSmrg	  if test "$dlself" = yes; then
4526382ff0afSmrg	    $show "generating symbol list for \`$output'"
4527382ff0afSmrg
4528382ff0afSmrg	    test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
4529382ff0afSmrg
4530382ff0afSmrg	    # Add our own program objects to the symbol list.
4531382ff0afSmrg	    progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
4532382ff0afSmrg	    for arg in $progfiles; do
4533382ff0afSmrg	      $show "extracting global C symbols from \`$arg'"
4534382ff0afSmrg	      $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
4535382ff0afSmrg	    done
4536382ff0afSmrg
4537382ff0afSmrg	    if test -n "$exclude_expsyms"; then
4538382ff0afSmrg	      $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
4539382ff0afSmrg	      $run eval '$mv "$nlist"T "$nlist"'
4540382ff0afSmrg	    fi
4541382ff0afSmrg
4542382ff0afSmrg	    if test -n "$export_symbols_regex"; then
4543382ff0afSmrg	      $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
4544382ff0afSmrg	      $run eval '$mv "$nlist"T "$nlist"'
4545382ff0afSmrg	    fi
4546382ff0afSmrg
4547382ff0afSmrg	    # Prepare the list of exported symbols
4548382ff0afSmrg	    if test -z "$export_symbols"; then
4549382ff0afSmrg	      export_symbols="$output_objdir/$outputname.exp"
4550382ff0afSmrg	      $run $rm $export_symbols
4551382ff0afSmrg	      $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4552382ff0afSmrg              case $host in
4553382ff0afSmrg              *cygwin* | *mingw* )
4554382ff0afSmrg	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4555382ff0afSmrg		$run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
4556382ff0afSmrg                ;;
4557382ff0afSmrg              esac
4558382ff0afSmrg	    else
4559382ff0afSmrg	      $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4560382ff0afSmrg	      $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
4561382ff0afSmrg	      $run eval 'mv "$nlist"T "$nlist"'
4562382ff0afSmrg              case $host in
4563382ff0afSmrg              *cygwin* | *mingw* )
4564382ff0afSmrg	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4565382ff0afSmrg		$run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
4566382ff0afSmrg                ;;
4567382ff0afSmrg              esac
4568382ff0afSmrg	    fi
4569382ff0afSmrg	  fi
4570382ff0afSmrg
4571382ff0afSmrg	  for arg in $dlprefiles; do
4572382ff0afSmrg	    $show "extracting global C symbols from \`$arg'"
4573382ff0afSmrg	    name=`$echo "$arg" | ${SED} -e 's%^.*/%%'`
4574382ff0afSmrg	    $run eval '$echo ": $name " >> "$nlist"'
4575382ff0afSmrg	    $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
4576382ff0afSmrg	  done
4577382ff0afSmrg
4578382ff0afSmrg	  if test -z "$run"; then
4579382ff0afSmrg	    # Make sure we have at least an empty file.
4580382ff0afSmrg	    test -f "$nlist" || : > "$nlist"
4581382ff0afSmrg
4582382ff0afSmrg	    if test -n "$exclude_expsyms"; then
4583382ff0afSmrg	      $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
4584382ff0afSmrg	      $mv "$nlist"T "$nlist"
4585382ff0afSmrg	    fi
4586382ff0afSmrg
4587382ff0afSmrg	    # Try sorting and uniquifying the output.
4588382ff0afSmrg	    if grep -v "^: " < "$nlist" |
4589382ff0afSmrg		if sort -k 3 </dev/null >/dev/null 2>&1; then
4590382ff0afSmrg		  sort -k 3
4591382ff0afSmrg		else
4592382ff0afSmrg		  sort +2
4593382ff0afSmrg		fi |
4594382ff0afSmrg		uniq > "$nlist"S; then
4595382ff0afSmrg	      :
4596382ff0afSmrg	    else
4597382ff0afSmrg	      grep -v "^: " < "$nlist" > "$nlist"S
4598382ff0afSmrg	    fi
4599382ff0afSmrg
4600382ff0afSmrg	    if test -f "$nlist"S; then
4601382ff0afSmrg	      eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
4602382ff0afSmrg	    else
4603382ff0afSmrg	      $echo '/* NONE */' >> "$output_objdir/$dlsyms"
4604382ff0afSmrg	    fi
4605382ff0afSmrg
4606382ff0afSmrg	    $echo >> "$output_objdir/$dlsyms" "\
4607382ff0afSmrg
4608382ff0afSmrg#undef lt_preloaded_symbols
4609382ff0afSmrg
4610382ff0afSmrg#if defined (__STDC__) && __STDC__
4611382ff0afSmrg# define lt_ptr void *
4612382ff0afSmrg#else
4613382ff0afSmrg# define lt_ptr char *
4614382ff0afSmrg# define const
4615382ff0afSmrg#endif
4616382ff0afSmrg
4617382ff0afSmrg/* The mapping between symbol names and symbols. */
4618382ff0afSmrg"
4619382ff0afSmrg
4620382ff0afSmrg	    case $host in
4621382ff0afSmrg	    *cygwin* | *mingw* )
4622382ff0afSmrg	  $echo >> "$output_objdir/$dlsyms" "\
4623382ff0afSmrg/* DATA imports from DLLs on WIN32 can't be const, because
4624382ff0afSmrg   runtime relocations are performed -- see ld's documentation
4625382ff0afSmrg   on pseudo-relocs */
4626382ff0afSmrgstruct {
4627382ff0afSmrg"
4628382ff0afSmrg	      ;;
4629382ff0afSmrg	    * )
4630382ff0afSmrg	  $echo >> "$output_objdir/$dlsyms" "\
4631382ff0afSmrgconst struct {
4632382ff0afSmrg"
4633382ff0afSmrg	      ;;
4634382ff0afSmrg	    esac
4635382ff0afSmrg
4636382ff0afSmrg
4637382ff0afSmrg	  $echo >> "$output_objdir/$dlsyms" "\
4638382ff0afSmrg  const char *name;
4639382ff0afSmrg  lt_ptr address;
4640382ff0afSmrg}
4641382ff0afSmrglt_preloaded_symbols[] =
4642382ff0afSmrg{\
4643382ff0afSmrg"
4644382ff0afSmrg
4645382ff0afSmrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
4646382ff0afSmrg
4647382ff0afSmrg	    $echo >> "$output_objdir/$dlsyms" "\
4648382ff0afSmrg  {0, (lt_ptr) 0}
4649382ff0afSmrg};
4650382ff0afSmrg
4651382ff0afSmrg/* This works around a problem in FreeBSD linker */
4652382ff0afSmrg#ifdef FREEBSD_WORKAROUND
4653382ff0afSmrgstatic const void *lt_preloaded_setup() {
4654382ff0afSmrg  return lt_preloaded_symbols;
4655382ff0afSmrg}
4656382ff0afSmrg#endif
4657382ff0afSmrg
4658382ff0afSmrg#ifdef __cplusplus
4659382ff0afSmrg}
4660382ff0afSmrg#endif\
4661382ff0afSmrg"
4662382ff0afSmrg	  fi
4663382ff0afSmrg
4664382ff0afSmrg	  pic_flag_for_symtable=
4665382ff0afSmrg	  case $host in
4666382ff0afSmrg	  # compiling the symbol table file with pic_flag works around
4667382ff0afSmrg	  # a FreeBSD bug that causes programs to crash when -lm is
4668382ff0afSmrg	  # linked before any other PIC object.  But we must not use
4669382ff0afSmrg	  # pic_flag when linking with -static.  The problem exists in
4670382ff0afSmrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
4671382ff0afSmrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
4672382ff0afSmrg	    case "$compile_command " in
4673382ff0afSmrg	    *" -static "*) ;;
4674382ff0afSmrg	    *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";;
4675382ff0afSmrg	    esac;;
4676382ff0afSmrg	  *-*-hpux*)
4677382ff0afSmrg	    case "$compile_command " in
4678382ff0afSmrg	    *" -static "*) ;;
4679382ff0afSmrg	    *) pic_flag_for_symtable=" $pic_flag";;
4680382ff0afSmrg	    esac
4681382ff0afSmrg	  esac
4682382ff0afSmrg
4683382ff0afSmrg	  # Now compile the dynamic symbol file.
4684382ff0afSmrg	  $show "(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
4685382ff0afSmrg	  $run eval '(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
4686382ff0afSmrg
4687382ff0afSmrg	  # Clean up the generated files.
4688382ff0afSmrg	  $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
4689382ff0afSmrg	  $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
4690382ff0afSmrg
4691382ff0afSmrg	  # Transform the symbol file into the correct name.
4692382ff0afSmrg          case $host in
4693382ff0afSmrg          *cygwin* | *mingw* )
4694382ff0afSmrg            if test -f "$output_objdir/${outputname}.def" ; then
4695382ff0afSmrg              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
4696382ff0afSmrg              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
4697382ff0afSmrg            else
4698382ff0afSmrg              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4699382ff0afSmrg              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4700382ff0afSmrg             fi
4701382ff0afSmrg            ;;
4702382ff0afSmrg          * )
4703382ff0afSmrg            compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4704382ff0afSmrg            finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4705382ff0afSmrg            ;;
4706382ff0afSmrg          esac
4707382ff0afSmrg	  ;;
4708382ff0afSmrg	*)
4709382ff0afSmrg	  $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
4710382ff0afSmrg	  exit $EXIT_FAILURE
4711382ff0afSmrg	  ;;
4712382ff0afSmrg	esac
4713382ff0afSmrg      else
4714382ff0afSmrg	# We keep going just in case the user didn't refer to
4715382ff0afSmrg	# lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
4716382ff0afSmrg	# really was required.
4717382ff0afSmrg
4718382ff0afSmrg	# Nullify the symbol file.
4719382ff0afSmrg	compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
4720382ff0afSmrg	finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
4721382ff0afSmrg      fi
4722382ff0afSmrg
4723382ff0afSmrg      if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
4724382ff0afSmrg	# Replace the output file specification.
4725382ff0afSmrg	compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
4726382ff0afSmrg	link_command="$compile_command$compile_rpath"
4727382ff0afSmrg
4728382ff0afSmrg	# We have no uninstalled library dependencies, so finalize right now.
4729382ff0afSmrg	$show "$link_command"
4730382ff0afSmrg	$run eval "$link_command"
4731382ff0afSmrg	exit_status=$?
4732382ff0afSmrg
4733382ff0afSmrg	# Delete the generated files.
4734382ff0afSmrg	if test -n "$dlsyms"; then
4735382ff0afSmrg	  $show "$rm $output_objdir/${outputname}S.${objext}"
4736382ff0afSmrg	  $run $rm "$output_objdir/${outputname}S.${objext}"
4737382ff0afSmrg	fi
4738382ff0afSmrg
4739382ff0afSmrg	exit $exit_status
4740382ff0afSmrg      fi
4741382ff0afSmrg
4742382ff0afSmrg      if test -n "$shlibpath_var"; then
4743382ff0afSmrg	# We should set the shlibpath_var
4744382ff0afSmrg	rpath=
4745382ff0afSmrg	for dir in $temp_rpath; do
4746382ff0afSmrg	  case $dir in
4747382ff0afSmrg	  [\\/]* | [A-Za-z]:[\\/]*)
4748382ff0afSmrg	    # Absolute path.
4749382ff0afSmrg	    rpath="$rpath$dir:"
4750382ff0afSmrg	    ;;
4751382ff0afSmrg	  *)
4752382ff0afSmrg	    # Relative path: add a thisdir entry.
4753382ff0afSmrg	    rpath="$rpath\$thisdir/$dir:"
4754382ff0afSmrg	    ;;
4755382ff0afSmrg	  esac
4756382ff0afSmrg	done
4757382ff0afSmrg	temp_rpath="$rpath"
4758382ff0afSmrg      fi
4759382ff0afSmrg
4760382ff0afSmrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
4761382ff0afSmrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
4762382ff0afSmrg      fi
4763382ff0afSmrg      if test -n "$finalize_shlibpath"; then
4764382ff0afSmrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
4765382ff0afSmrg      fi
4766382ff0afSmrg
4767382ff0afSmrg      compile_var=
4768382ff0afSmrg      finalize_var=
4769382ff0afSmrg      if test -n "$runpath_var"; then
4770382ff0afSmrg	if test -n "$perm_rpath"; then
4771382ff0afSmrg	  # We should set the runpath_var.
4772382ff0afSmrg	  rpath=
4773382ff0afSmrg	  for dir in $perm_rpath; do
4774382ff0afSmrg	    rpath="$rpath$dir:"
4775382ff0afSmrg	  done
4776382ff0afSmrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
4777382ff0afSmrg	fi
4778382ff0afSmrg	if test -n "$finalize_perm_rpath"; then
4779382ff0afSmrg	  # We should set the runpath_var.
4780382ff0afSmrg	  rpath=
4781382ff0afSmrg	  for dir in $finalize_perm_rpath; do
4782382ff0afSmrg	    rpath="$rpath$dir:"
4783382ff0afSmrg	  done
4784382ff0afSmrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
4785382ff0afSmrg	fi
4786382ff0afSmrg      fi
4787382ff0afSmrg
4788382ff0afSmrg      if test "$no_install" = yes; then
4789382ff0afSmrg	# We don't need to create a wrapper script.
4790382ff0afSmrg	link_command="$compile_var$compile_command$compile_rpath"
4791382ff0afSmrg	# Replace the output file specification.
4792382ff0afSmrg	link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
4793382ff0afSmrg	# Delete the old output file.
4794382ff0afSmrg	$run $rm $output
4795382ff0afSmrg	# Link the executable and exit
4796382ff0afSmrg	$show "$link_command"
4797382ff0afSmrg	$run eval "$link_command" || exit $?
4798382ff0afSmrg	exit $EXIT_SUCCESS
4799382ff0afSmrg      fi
4800382ff0afSmrg
4801382ff0afSmrg      if test "$hardcode_action" = relink; then
4802382ff0afSmrg	# Fast installation is not supported
4803382ff0afSmrg	link_command="$compile_var$compile_command$compile_rpath"
4804382ff0afSmrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
4805382ff0afSmrg
4806382ff0afSmrg	$echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
4807382ff0afSmrg	$echo "$modename: \`$output' will be relinked during installation" 1>&2
4808382ff0afSmrg      else
4809382ff0afSmrg	if test "$fast_install" != no; then
4810382ff0afSmrg	  link_command="$finalize_var$compile_command$finalize_rpath"
4811382ff0afSmrg	  if test "$fast_install" = yes; then
4812382ff0afSmrg	    relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
4813382ff0afSmrg	  else
4814382ff0afSmrg	    # fast_install is set to needless
4815382ff0afSmrg	    relink_command=
4816382ff0afSmrg	  fi
4817382ff0afSmrg	else
4818382ff0afSmrg	  link_command="$compile_var$compile_command$compile_rpath"
4819382ff0afSmrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
4820382ff0afSmrg	fi
4821382ff0afSmrg      fi
4822382ff0afSmrg
4823382ff0afSmrg      # Replace the output file specification.
4824382ff0afSmrg      link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
4825382ff0afSmrg
4826382ff0afSmrg      # Delete the old output files.
4827382ff0afSmrg      $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
4828382ff0afSmrg
4829382ff0afSmrg      $show "$link_command"
4830382ff0afSmrg      $run eval "$link_command" || exit $?
4831382ff0afSmrg
4832382ff0afSmrg      # Now create the wrapper script.
4833382ff0afSmrg      $show "creating $output"
4834382ff0afSmrg
4835382ff0afSmrg      # Quote the relink command for shipping.
4836382ff0afSmrg      if test -n "$relink_command"; then
4837382ff0afSmrg	# Preserve any variables that may affect compiler behavior
4838382ff0afSmrg	for var in $variables_saved_for_relink; do
4839382ff0afSmrg	  if eval test -z \"\${$var+set}\"; then
4840382ff0afSmrg	    relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
4841382ff0afSmrg	  elif eval var_value=\$$var; test -z "$var_value"; then
4842382ff0afSmrg	    relink_command="$var=; export $var; $relink_command"
4843382ff0afSmrg	  else
4844382ff0afSmrg	    var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
4845382ff0afSmrg	    relink_command="$var=\"$var_value\"; export $var; $relink_command"
4846382ff0afSmrg	  fi
4847382ff0afSmrg	done
4848382ff0afSmrg	relink_command="(cd `pwd`; $relink_command)"
4849382ff0afSmrg	relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
4850382ff0afSmrg      fi
4851382ff0afSmrg
4852382ff0afSmrg      # Quote $echo for shipping.
4853382ff0afSmrg      if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then
4854382ff0afSmrg	case $progpath in
4855382ff0afSmrg	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
4856382ff0afSmrg	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
4857382ff0afSmrg	esac
4858382ff0afSmrg	qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
4859382ff0afSmrg      else
4860382ff0afSmrg	qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
4861382ff0afSmrg      fi
4862382ff0afSmrg
4863382ff0afSmrg      # Only actually do things if our run command is non-null.
4864382ff0afSmrg      if test -z "$run"; then
4865382ff0afSmrg	# win32 will think the script is a binary if it has
4866382ff0afSmrg	# a .exe suffix, so we strip it off here.
4867382ff0afSmrg	case $output in
4868382ff0afSmrg	  *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;;
4869382ff0afSmrg	esac
4870382ff0afSmrg	# test for cygwin because mv fails w/o .exe extensions
4871382ff0afSmrg	case $host in
4872382ff0afSmrg	  *cygwin*)
4873382ff0afSmrg	    exeext=.exe
4874382ff0afSmrg	    outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;;
4875382ff0afSmrg	  *) exeext= ;;
4876382ff0afSmrg	esac
4877382ff0afSmrg	case $host in
4878382ff0afSmrg	  *cygwin* | *mingw* )
4879382ff0afSmrg            output_name=`basename $output`
4880382ff0afSmrg            output_path=`dirname $output`
4881382ff0afSmrg            cwrappersource="$output_path/$objdir/lt-$output_name.c"
4882382ff0afSmrg            cwrapper="$output_path/$output_name.exe"
4883382ff0afSmrg            $rm $cwrappersource $cwrapper
4884382ff0afSmrg            trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
4885382ff0afSmrg
4886382ff0afSmrg	    cat > $cwrappersource <<EOF
4887382ff0afSmrg
4888382ff0afSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
4889382ff0afSmrg   Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
4890382ff0afSmrg
4891382ff0afSmrg   The $output program cannot be directly executed until all the libtool
4892382ff0afSmrg   libraries that it depends on are installed.
4893382ff0afSmrg
4894382ff0afSmrg   This wrapper executable should never be moved out of the build directory.
4895382ff0afSmrg   If it is, it will not operate correctly.
4896382ff0afSmrg
4897382ff0afSmrg   Currently, it simply execs the wrapper *script* "/bin/sh $output",
4898382ff0afSmrg   but could eventually absorb all of the scripts functionality and
4899382ff0afSmrg   exec $objdir/$outputname directly.
4900382ff0afSmrg*/
4901382ff0afSmrgEOF
4902382ff0afSmrg	    cat >> $cwrappersource<<"EOF"
4903382ff0afSmrg#include <stdio.h>
4904382ff0afSmrg#include <stdlib.h>
4905382ff0afSmrg#include <unistd.h>
4906382ff0afSmrg#include <malloc.h>
4907382ff0afSmrg#include <stdarg.h>
4908382ff0afSmrg#include <assert.h>
4909382ff0afSmrg#include <string.h>
4910382ff0afSmrg#include <ctype.h>
4911382ff0afSmrg#include <sys/stat.h>
4912382ff0afSmrg
4913382ff0afSmrg#if defined(PATH_MAX)
4914382ff0afSmrg# define LT_PATHMAX PATH_MAX
4915382ff0afSmrg#elif defined(MAXPATHLEN)
4916382ff0afSmrg# define LT_PATHMAX MAXPATHLEN
4917382ff0afSmrg#else
4918382ff0afSmrg# define LT_PATHMAX 1024
4919382ff0afSmrg#endif
4920382ff0afSmrg
4921382ff0afSmrg#ifndef DIR_SEPARATOR
4922382ff0afSmrg# define DIR_SEPARATOR '/'
4923382ff0afSmrg# define PATH_SEPARATOR ':'
4924382ff0afSmrg#endif
4925382ff0afSmrg
4926382ff0afSmrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
4927382ff0afSmrg  defined (__OS2__)
4928382ff0afSmrg# define HAVE_DOS_BASED_FILE_SYSTEM
4929382ff0afSmrg# ifndef DIR_SEPARATOR_2
4930382ff0afSmrg#  define DIR_SEPARATOR_2 '\\'
4931382ff0afSmrg# endif
4932382ff0afSmrg# ifndef PATH_SEPARATOR_2
4933382ff0afSmrg#  define PATH_SEPARATOR_2 ';'
4934382ff0afSmrg# endif
4935382ff0afSmrg#endif
4936382ff0afSmrg
4937382ff0afSmrg#ifndef DIR_SEPARATOR_2
4938382ff0afSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
4939382ff0afSmrg#else /* DIR_SEPARATOR_2 */
4940382ff0afSmrg# define IS_DIR_SEPARATOR(ch) \
4941382ff0afSmrg        (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4942382ff0afSmrg#endif /* DIR_SEPARATOR_2 */
4943382ff0afSmrg
4944382ff0afSmrg#ifndef PATH_SEPARATOR_2
4945382ff0afSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
4946382ff0afSmrg#else /* PATH_SEPARATOR_2 */
4947382ff0afSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
4948382ff0afSmrg#endif /* PATH_SEPARATOR_2 */
4949382ff0afSmrg
4950382ff0afSmrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
4951382ff0afSmrg#define XFREE(stale) do { \
4952382ff0afSmrg  if (stale) { free ((void *) stale); stale = 0; } \
4953382ff0afSmrg} while (0)
4954382ff0afSmrg
4955382ff0afSmrg/* -DDEBUG is fairly common in CFLAGS.  */
4956382ff0afSmrg#undef DEBUG
4957382ff0afSmrg#if defined DEBUGWRAPPER
4958382ff0afSmrg# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
4959382ff0afSmrg#else
4960382ff0afSmrg# define DEBUG(format, ...)
4961382ff0afSmrg#endif
4962382ff0afSmrg
4963382ff0afSmrgconst char *program_name = NULL;
4964382ff0afSmrg
4965382ff0afSmrgvoid * xmalloc (size_t num);
4966382ff0afSmrgchar * xstrdup (const char *string);
4967382ff0afSmrgconst char * base_name (const char *name);
4968382ff0afSmrgchar * find_executable(const char *wrapper);
4969382ff0afSmrgint    check_executable(const char *path);
4970382ff0afSmrgchar * strendzap(char *str, const char *pat);
4971382ff0afSmrgvoid lt_fatal (const char *message, ...);
4972382ff0afSmrg
4973382ff0afSmrgint
4974382ff0afSmrgmain (int argc, char *argv[])
4975382ff0afSmrg{
4976382ff0afSmrg  char **newargz;
4977382ff0afSmrg  int i;
4978382ff0afSmrg
4979382ff0afSmrg  program_name = (char *) xstrdup (base_name (argv[0]));
4980382ff0afSmrg  DEBUG("(main) argv[0]      : %s\n",argv[0]);
4981382ff0afSmrg  DEBUG("(main) program_name : %s\n",program_name);
4982382ff0afSmrg  newargz = XMALLOC(char *, argc+2);
4983382ff0afSmrgEOF
4984382ff0afSmrg
4985382ff0afSmrg            cat >> $cwrappersource <<EOF
4986382ff0afSmrg  newargz[0] = (char *) xstrdup("$SHELL");
4987382ff0afSmrgEOF
4988382ff0afSmrg
4989382ff0afSmrg            cat >> $cwrappersource <<"EOF"
4990382ff0afSmrg  newargz[1] = find_executable(argv[0]);
4991382ff0afSmrg  if (newargz[1] == NULL)
4992382ff0afSmrg    lt_fatal("Couldn't find %s", argv[0]);
4993382ff0afSmrg  DEBUG("(main) found exe at : %s\n",newargz[1]);
4994382ff0afSmrg  /* we know the script has the same name, without the .exe */
4995382ff0afSmrg  /* so make sure newargz[1] doesn't end in .exe */
4996382ff0afSmrg  strendzap(newargz[1],".exe");
4997382ff0afSmrg  for (i = 1; i < argc; i++)
4998382ff0afSmrg    newargz[i+1] = xstrdup(argv[i]);
4999382ff0afSmrg  newargz[argc+1] = NULL;
5000382ff0afSmrg
5001382ff0afSmrg  for (i=0; i<argc+1; i++)
5002382ff0afSmrg  {
5003382ff0afSmrg    DEBUG("(main) newargz[%d]   : %s\n",i,newargz[i]);
5004382ff0afSmrg    ;
5005382ff0afSmrg  }
5006382ff0afSmrg
5007382ff0afSmrgEOF
5008382ff0afSmrg
5009382ff0afSmrg            case $host_os in
5010382ff0afSmrg              mingw*)
5011382ff0afSmrg                cat >> $cwrappersource <<EOF
5012382ff0afSmrg  execv("$SHELL",(char const **)newargz);
5013382ff0afSmrgEOF
5014382ff0afSmrg              ;;
5015382ff0afSmrg              *)
5016382ff0afSmrg                cat >> $cwrappersource <<EOF
5017382ff0afSmrg  execv("$SHELL",newargz);
5018382ff0afSmrgEOF
5019382ff0afSmrg              ;;
5020382ff0afSmrg            esac
5021382ff0afSmrg
5022382ff0afSmrg            cat >> $cwrappersource <<"EOF"
5023382ff0afSmrg  return 127;
5024382ff0afSmrg}
5025382ff0afSmrg
5026382ff0afSmrgvoid *
5027382ff0afSmrgxmalloc (size_t num)
5028382ff0afSmrg{
5029382ff0afSmrg  void * p = (void *) malloc (num);
5030382ff0afSmrg  if (!p)
5031382ff0afSmrg    lt_fatal ("Memory exhausted");
5032382ff0afSmrg
5033382ff0afSmrg  return p;
5034382ff0afSmrg}
5035382ff0afSmrg
5036382ff0afSmrgchar *
5037382ff0afSmrgxstrdup (const char *string)
5038382ff0afSmrg{
5039382ff0afSmrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL
5040382ff0afSmrg;
5041382ff0afSmrg}
5042382ff0afSmrg
5043382ff0afSmrgconst char *
5044382ff0afSmrgbase_name (const char *name)
5045382ff0afSmrg{
5046382ff0afSmrg  const char *base;
5047382ff0afSmrg
5048382ff0afSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5049382ff0afSmrg  /* Skip over the disk name in MSDOS pathnames. */
5050382ff0afSmrg  if (isalpha ((unsigned char)name[0]) && name[1] == ':')
5051382ff0afSmrg    name += 2;
5052382ff0afSmrg#endif
5053382ff0afSmrg
5054382ff0afSmrg  for (base = name; *name; name++)
5055382ff0afSmrg    if (IS_DIR_SEPARATOR (*name))
5056382ff0afSmrg      base = name + 1;
5057382ff0afSmrg  return base;
5058382ff0afSmrg}
5059382ff0afSmrg
5060382ff0afSmrgint
5061382ff0afSmrgcheck_executable(const char * path)
5062382ff0afSmrg{
5063382ff0afSmrg  struct stat st;
5064382ff0afSmrg
5065382ff0afSmrg  DEBUG("(check_executable)  : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
5066382ff0afSmrg  if ((!path) || (!*path))
5067382ff0afSmrg    return 0;
5068382ff0afSmrg
5069382ff0afSmrg  if ((stat (path, &st) >= 0) &&
5070382ff0afSmrg      (
5071382ff0afSmrg        /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
5072382ff0afSmrg#if defined (S_IXOTH)
5073382ff0afSmrg       ((st.st_mode & S_IXOTH) == S_IXOTH) ||
5074382ff0afSmrg#endif
5075382ff0afSmrg#if defined (S_IXGRP)
5076382ff0afSmrg       ((st.st_mode & S_IXGRP) == S_IXGRP) ||
5077382ff0afSmrg#endif
5078382ff0afSmrg       ((st.st_mode & S_IXUSR) == S_IXUSR))
5079382ff0afSmrg      )
5080382ff0afSmrg    return 1;
5081382ff0afSmrg  else
5082382ff0afSmrg    return 0;
5083382ff0afSmrg}
5084382ff0afSmrg
5085382ff0afSmrg/* Searches for the full path of the wrapper.  Returns
5086382ff0afSmrg   newly allocated full path name if found, NULL otherwise */
5087382ff0afSmrgchar *
5088382ff0afSmrgfind_executable (const char* wrapper)
5089382ff0afSmrg{
5090382ff0afSmrg  int has_slash = 0;
5091382ff0afSmrg  const char* p;
5092382ff0afSmrg  const char* p_next;
5093382ff0afSmrg  /* static buffer for getcwd */
5094382ff0afSmrg  char tmp[LT_PATHMAX + 1];
5095382ff0afSmrg  int tmp_len;
5096382ff0afSmrg  char* concat_name;
5097382ff0afSmrg
5098382ff0afSmrg  DEBUG("(find_executable)  : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
5099382ff0afSmrg
5100382ff0afSmrg  if ((wrapper == NULL) || (*wrapper == '\0'))
5101382ff0afSmrg    return NULL;
5102382ff0afSmrg
5103382ff0afSmrg  /* Absolute path? */
5104382ff0afSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5105382ff0afSmrg  if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
5106382ff0afSmrg  {
5107382ff0afSmrg    concat_name = xstrdup (wrapper);
5108382ff0afSmrg    if (check_executable(concat_name))
5109382ff0afSmrg      return concat_name;
5110382ff0afSmrg    XFREE(concat_name);
5111382ff0afSmrg  }
5112382ff0afSmrg  else
5113382ff0afSmrg  {
5114382ff0afSmrg#endif
5115382ff0afSmrg    if (IS_DIR_SEPARATOR (wrapper[0]))
5116382ff0afSmrg    {
5117382ff0afSmrg      concat_name = xstrdup (wrapper);
5118382ff0afSmrg      if (check_executable(concat_name))
5119382ff0afSmrg        return concat_name;
5120382ff0afSmrg      XFREE(concat_name);
5121382ff0afSmrg    }
5122382ff0afSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5123382ff0afSmrg  }
5124382ff0afSmrg#endif
5125382ff0afSmrg
5126382ff0afSmrg  for (p = wrapper; *p; p++)
5127382ff0afSmrg    if (*p == '/')
5128382ff0afSmrg    {
5129382ff0afSmrg      has_slash = 1;
5130382ff0afSmrg      break;
5131382ff0afSmrg    }
5132382ff0afSmrg  if (!has_slash)
5133382ff0afSmrg  {
5134382ff0afSmrg    /* no slashes; search PATH */
5135382ff0afSmrg    const char* path = getenv ("PATH");
5136382ff0afSmrg    if (path != NULL)
5137382ff0afSmrg    {
5138382ff0afSmrg      for (p = path; *p; p = p_next)
5139382ff0afSmrg      {
5140382ff0afSmrg        const char* q;
5141382ff0afSmrg        size_t p_len;
5142382ff0afSmrg        for (q = p; *q; q++)
5143382ff0afSmrg          if (IS_PATH_SEPARATOR(*q))
5144382ff0afSmrg            break;
5145382ff0afSmrg        p_len = q - p;
5146382ff0afSmrg        p_next = (*q == '\0' ? q : q + 1);
5147382ff0afSmrg        if (p_len == 0)
5148382ff0afSmrg        {
5149382ff0afSmrg          /* empty path: current directory */
5150382ff0afSmrg          if (getcwd (tmp, LT_PATHMAX) == NULL)
5151382ff0afSmrg            lt_fatal ("getcwd failed");
5152382ff0afSmrg          tmp_len = strlen(tmp);
5153382ff0afSmrg          concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
5154382ff0afSmrg          memcpy (concat_name, tmp, tmp_len);
5155382ff0afSmrg          concat_name[tmp_len] = '/';
5156382ff0afSmrg          strcpy (concat_name + tmp_len + 1, wrapper);
5157382ff0afSmrg        }
5158382ff0afSmrg        else
5159382ff0afSmrg        {
5160382ff0afSmrg          concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
5161382ff0afSmrg          memcpy (concat_name, p, p_len);
5162382ff0afSmrg          concat_name[p_len] = '/';
5163382ff0afSmrg          strcpy (concat_name + p_len + 1, wrapper);
5164382ff0afSmrg        }
5165382ff0afSmrg        if (check_executable(concat_name))
5166382ff0afSmrg          return concat_name;
5167382ff0afSmrg        XFREE(concat_name);
5168382ff0afSmrg      }
5169382ff0afSmrg    }
5170382ff0afSmrg    /* not found in PATH; assume curdir */
5171382ff0afSmrg  }
5172382ff0afSmrg  /* Relative path | not found in path: prepend cwd */
5173382ff0afSmrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
5174382ff0afSmrg    lt_fatal ("getcwd failed");
5175382ff0afSmrg  tmp_len = strlen(tmp);
5176382ff0afSmrg  concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
5177382ff0afSmrg  memcpy (concat_name, tmp, tmp_len);
5178382ff0afSmrg  concat_name[tmp_len] = '/';
5179382ff0afSmrg  strcpy (concat_name + tmp_len + 1, wrapper);
5180382ff0afSmrg
5181382ff0afSmrg  if (check_executable(concat_name))
5182382ff0afSmrg    return concat_name;
5183382ff0afSmrg  XFREE(concat_name);
5184382ff0afSmrg  return NULL;
5185382ff0afSmrg}
5186382ff0afSmrg
5187382ff0afSmrgchar *
5188382ff0afSmrgstrendzap(char *str, const char *pat)
5189382ff0afSmrg{
5190382ff0afSmrg  size_t len, patlen;
5191382ff0afSmrg
5192382ff0afSmrg  assert(str != NULL);
5193382ff0afSmrg  assert(pat != NULL);
5194382ff0afSmrg
5195382ff0afSmrg  len = strlen(str);
5196382ff0afSmrg  patlen = strlen(pat);
5197382ff0afSmrg
5198382ff0afSmrg  if (patlen <= len)
5199382ff0afSmrg  {
5200382ff0afSmrg    str += len - patlen;
5201382ff0afSmrg    if (strcmp(str, pat) == 0)
5202382ff0afSmrg      *str = '\0';
5203382ff0afSmrg  }
5204382ff0afSmrg  return str;
5205382ff0afSmrg}
5206382ff0afSmrg
5207382ff0afSmrgstatic void
5208382ff0afSmrglt_error_core (int exit_status, const char * mode,
5209382ff0afSmrg          const char * message, va_list ap)
5210382ff0afSmrg{
5211382ff0afSmrg  fprintf (stderr, "%s: %s: ", program_name, mode);
5212382ff0afSmrg  vfprintf (stderr, message, ap);
5213382ff0afSmrg  fprintf (stderr, ".\n");
5214382ff0afSmrg
5215382ff0afSmrg  if (exit_status >= 0)
5216382ff0afSmrg    exit (exit_status);
5217382ff0afSmrg}
5218382ff0afSmrg
5219382ff0afSmrgvoid
5220382ff0afSmrglt_fatal (const char *message, ...)
5221382ff0afSmrg{
5222382ff0afSmrg  va_list ap;
5223382ff0afSmrg  va_start (ap, message);
5224382ff0afSmrg  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
5225382ff0afSmrg  va_end (ap);
5226382ff0afSmrg}
5227382ff0afSmrgEOF
5228382ff0afSmrg          # we should really use a build-platform specific compiler
5229382ff0afSmrg          # here, but OTOH, the wrappers (shell script and this C one)
5230382ff0afSmrg          # are only useful if you want to execute the "real" binary.
5231382ff0afSmrg          # Since the "real" binary is built for $host, then this
5232382ff0afSmrg          # wrapper might as well be built for $host, too.
5233382ff0afSmrg          $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
5234382ff0afSmrg          ;;
5235382ff0afSmrg        esac
5236382ff0afSmrg        $rm $output
5237382ff0afSmrg        trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
5238382ff0afSmrg
5239382ff0afSmrg	$echo > $output "\
5240382ff0afSmrg#! $SHELL
5241382ff0afSmrg
5242382ff0afSmrg# $output - temporary wrapper script for $objdir/$outputname
5243382ff0afSmrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
5244382ff0afSmrg#
5245382ff0afSmrg# The $output program cannot be directly executed until all the libtool
5246382ff0afSmrg# libraries that it depends on are installed.
5247382ff0afSmrg#
5248382ff0afSmrg# This wrapper script should never be moved out of the build directory.
5249382ff0afSmrg# If it is, it will not operate correctly.
5250382ff0afSmrg
5251382ff0afSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
5252382ff0afSmrg# metacharacters that are still active within double-quoted strings.
5253382ff0afSmrgXsed='${SED} -e 1s/^X//'
5254382ff0afSmrgsed_quote_subst='$sed_quote_subst'
5255382ff0afSmrg
5256382ff0afSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout
5257382ff0afSmrg# if CDPATH is set.
5258382ff0afSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
5259382ff0afSmrg
5260382ff0afSmrgrelink_command=\"$relink_command\"
5261382ff0afSmrg
5262382ff0afSmrg# This environment variable determines our operation mode.
5263382ff0afSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then
5264382ff0afSmrg  # install mode needs the following variable:
5265382ff0afSmrg  notinst_deplibs='$notinst_deplibs'
5266382ff0afSmrgelse
5267382ff0afSmrg  # When we are sourced in execute mode, \$file and \$echo are already set.
5268382ff0afSmrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
5269382ff0afSmrg    echo=\"$qecho\"
5270382ff0afSmrg    file=\"\$0\"
5271382ff0afSmrg    # Make sure echo works.
5272382ff0afSmrg    if test \"X\$1\" = X--no-reexec; then
5273382ff0afSmrg      # Discard the --no-reexec flag, and continue.
5274382ff0afSmrg      shift
5275382ff0afSmrg    elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
5276382ff0afSmrg      # Yippee, \$echo works!
5277382ff0afSmrg      :
5278382ff0afSmrg    else
5279382ff0afSmrg      # Restart under the correct shell, and then maybe \$echo will work.
5280382ff0afSmrg      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
5281382ff0afSmrg    fi
5282382ff0afSmrg  fi\
5283382ff0afSmrg"
5284382ff0afSmrg	$echo >> $output "\
5285382ff0afSmrg
5286382ff0afSmrg  # Find the directory that this script lives in.
5287382ff0afSmrg  thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
5288382ff0afSmrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
5289382ff0afSmrg
5290382ff0afSmrg  # Follow symbolic links until we get to the real thisdir.
5291382ff0afSmrg  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
5292382ff0afSmrg  while test -n \"\$file\"; do
5293382ff0afSmrg    destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
5294382ff0afSmrg
5295382ff0afSmrg    # If there was a directory component, then change thisdir.
5296382ff0afSmrg    if test \"x\$destdir\" != \"x\$file\"; then
5297382ff0afSmrg      case \"\$destdir\" in
5298382ff0afSmrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
5299382ff0afSmrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
5300382ff0afSmrg      esac
5301382ff0afSmrg    fi
5302382ff0afSmrg
5303382ff0afSmrg    file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
5304382ff0afSmrg    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
5305382ff0afSmrg  done
5306382ff0afSmrg
5307382ff0afSmrg  # Try to get the absolute directory name.
5308382ff0afSmrg  absdir=\`cd \"\$thisdir\" && pwd\`
5309382ff0afSmrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
5310382ff0afSmrg"
5311382ff0afSmrg
5312382ff0afSmrg	if test "$fast_install" = yes; then
5313382ff0afSmrg	  $echo >> $output "\
5314382ff0afSmrg  program=lt-'$outputname'$exeext
5315382ff0afSmrg  progdir=\"\$thisdir/$objdir\"
5316382ff0afSmrg
5317382ff0afSmrg  if test ! -f \"\$progdir/\$program\" || \\
5318382ff0afSmrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
5319382ff0afSmrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
5320382ff0afSmrg
5321382ff0afSmrg    file=\"\$\$-\$program\"
5322382ff0afSmrg
5323382ff0afSmrg    if test ! -d \"\$progdir\"; then
5324382ff0afSmrg      $mkdir \"\$progdir\"
5325382ff0afSmrg    else
5326382ff0afSmrg      $rm \"\$progdir/\$file\"
5327382ff0afSmrg    fi"
5328382ff0afSmrg
5329382ff0afSmrg	  $echo >> $output "\
5330382ff0afSmrg
5331382ff0afSmrg    # relink executable if necessary
5332382ff0afSmrg    if test -n \"\$relink_command\"; then
5333382ff0afSmrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
5334382ff0afSmrg      else
5335382ff0afSmrg	$echo \"\$relink_command_output\" >&2
5336382ff0afSmrg	$rm \"\$progdir/\$file\"
5337382ff0afSmrg	exit $EXIT_FAILURE
5338382ff0afSmrg      fi
5339382ff0afSmrg    fi
5340382ff0afSmrg
5341382ff0afSmrg    $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
5342382ff0afSmrg    { $rm \"\$progdir/\$program\";
5343382ff0afSmrg      $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
5344382ff0afSmrg    $rm \"\$progdir/\$file\"
5345382ff0afSmrg  fi"
5346382ff0afSmrg	else
5347382ff0afSmrg	  $echo >> $output "\
5348382ff0afSmrg  program='$outputname'
5349382ff0afSmrg  progdir=\"\$thisdir/$objdir\"
5350382ff0afSmrg"
5351382ff0afSmrg	fi
5352382ff0afSmrg
5353382ff0afSmrg	$echo >> $output "\
5354382ff0afSmrg
5355382ff0afSmrg  if test -f \"\$progdir/\$program\"; then"
5356382ff0afSmrg
5357382ff0afSmrg	# Export our shlibpath_var if we have one.
5358382ff0afSmrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5359382ff0afSmrg	  $echo >> $output "\
5360382ff0afSmrg    # Add our own library path to $shlibpath_var
5361382ff0afSmrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
5362382ff0afSmrg
5363382ff0afSmrg    # Some systems cannot cope with colon-terminated $shlibpath_var
5364382ff0afSmrg    # The second colon is a workaround for a bug in BeOS R4 sed
5365382ff0afSmrg    $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
5366382ff0afSmrg
5367382ff0afSmrg    export $shlibpath_var
5368382ff0afSmrg"
5369382ff0afSmrg	fi
5370382ff0afSmrg
5371382ff0afSmrg	# fixup the dll searchpath if we need to.
5372382ff0afSmrg	if test -n "$dllsearchpath"; then
5373382ff0afSmrg	  $echo >> $output "\
5374382ff0afSmrg    # Add the dll search path components to the executable PATH
5375382ff0afSmrg    PATH=$dllsearchpath:\$PATH
5376382ff0afSmrg"
5377382ff0afSmrg	fi
5378382ff0afSmrg
5379382ff0afSmrg	$echo >> $output "\
5380382ff0afSmrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
5381382ff0afSmrg      # Run the actual program with our arguments.
5382382ff0afSmrg"
5383382ff0afSmrg	case $host in
5384382ff0afSmrg	# Backslashes separate directories on plain windows
5385382ff0afSmrg	*-*-mingw | *-*-os2*)
5386382ff0afSmrg	  $echo >> $output "\
5387382ff0afSmrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
5388382ff0afSmrg"
5389382ff0afSmrg	  ;;
5390382ff0afSmrg
5391382ff0afSmrg	*)
5392382ff0afSmrg	  $echo >> $output "\
5393382ff0afSmrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
5394382ff0afSmrg"
5395382ff0afSmrg	  ;;
5396382ff0afSmrg	esac
5397382ff0afSmrg	$echo >> $output "\
5398382ff0afSmrg      \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
5399382ff0afSmrg      exit $EXIT_FAILURE
5400382ff0afSmrg    fi
5401382ff0afSmrg  else
5402382ff0afSmrg    # The program doesn't exist.
5403382ff0afSmrg    \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
5404382ff0afSmrg    \$echo \"This script is just a wrapper for \$program.\" 1>&2
5405382ff0afSmrg    $echo \"See the $PACKAGE documentation for more information.\" 1>&2
5406382ff0afSmrg    exit $EXIT_FAILURE
5407382ff0afSmrg  fi
5408382ff0afSmrgfi\
5409382ff0afSmrg"
5410382ff0afSmrg	chmod +x $output
5411382ff0afSmrg      fi
5412382ff0afSmrg      exit $EXIT_SUCCESS
5413382ff0afSmrg      ;;
5414382ff0afSmrg    esac
5415382ff0afSmrg
5416382ff0afSmrg    # See if we need to build an old-fashioned archive.
5417382ff0afSmrg    for oldlib in $oldlibs; do
5418382ff0afSmrg
5419382ff0afSmrg      if test "$build_libtool_libs" = convenience; then
5420382ff0afSmrg	oldobjs="$libobjs_save"
5421382ff0afSmrg	addlibs="$convenience"
5422382ff0afSmrg	build_libtool_libs=no
5423382ff0afSmrg      else
5424382ff0afSmrg	if test "$build_libtool_libs" = module; then
5425382ff0afSmrg	  oldobjs="$libobjs_save"
5426382ff0afSmrg	  build_libtool_libs=no
5427382ff0afSmrg	else
5428382ff0afSmrg	  oldobjs="$old_deplibs $non_pic_objects"
5429382ff0afSmrg	fi
5430382ff0afSmrg	addlibs="$old_convenience"
5431382ff0afSmrg      fi
5432382ff0afSmrg
5433382ff0afSmrg      if test -n "$addlibs"; then
5434382ff0afSmrg	gentop="$output_objdir/${outputname}x"
5435382ff0afSmrg	generated="$generated $gentop"
5436382ff0afSmrg
5437382ff0afSmrg	func_extract_archives $gentop $addlibs
5438382ff0afSmrg	oldobjs="$oldobjs $func_extract_archives_result"
5439382ff0afSmrg      fi
5440382ff0afSmrg
5441382ff0afSmrg      # Do each command in the archive commands.
5442382ff0afSmrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
5443382ff0afSmrg       cmds=$old_archive_from_new_cmds
5444382ff0afSmrg      else
5445382ff0afSmrg	# POSIX demands no paths to be encoded in archives.  We have
5446382ff0afSmrg	# to avoid creating archives with duplicate basenames if we
5447382ff0afSmrg	# might have to extract them afterwards, e.g., when creating a
5448382ff0afSmrg	# static archive out of a convenience library, or when linking
5449382ff0afSmrg	# the entirety of a libtool archive into another (currently
5450382ff0afSmrg	# not supported by libtool).
5451382ff0afSmrg	if (for obj in $oldobjs
5452382ff0afSmrg	    do
5453382ff0afSmrg	      $echo "X$obj" | $Xsed -e 's%^.*/%%'
5454382ff0afSmrg	    done | sort | sort -uc >/dev/null 2>&1); then
5455382ff0afSmrg	  :
5456382ff0afSmrg	else
5457382ff0afSmrg	  $echo "copying selected object files to avoid basename conflicts..."
5458382ff0afSmrg
5459382ff0afSmrg	  if test -z "$gentop"; then
5460382ff0afSmrg	    gentop="$output_objdir/${outputname}x"
5461382ff0afSmrg	    generated="$generated $gentop"
5462382ff0afSmrg
5463382ff0afSmrg	    $show "${rm}r $gentop"
5464382ff0afSmrg	    $run ${rm}r "$gentop"
5465382ff0afSmrg	    $show "$mkdir $gentop"
5466382ff0afSmrg	    $run $mkdir "$gentop"
5467382ff0afSmrg	    exit_status=$?
5468382ff0afSmrg	    if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
5469382ff0afSmrg	      exit $exit_status
5470382ff0afSmrg	    fi
5471382ff0afSmrg	  fi
5472382ff0afSmrg
5473382ff0afSmrg	  save_oldobjs=$oldobjs
5474382ff0afSmrg	  oldobjs=
5475382ff0afSmrg	  counter=1
5476382ff0afSmrg	  for obj in $save_oldobjs
5477382ff0afSmrg	  do
5478382ff0afSmrg	    objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
5479382ff0afSmrg	    case " $oldobjs " in
5480382ff0afSmrg	    " ") oldobjs=$obj ;;
5481382ff0afSmrg	    *[\ /]"$objbase "*)
5482382ff0afSmrg	      while :; do
5483382ff0afSmrg		# Make sure we don't pick an alternate name that also
5484382ff0afSmrg		# overlaps.
5485382ff0afSmrg		newobj=lt$counter-$objbase
5486382ff0afSmrg		counter=`expr $counter + 1`
5487382ff0afSmrg		case " $oldobjs " in
5488382ff0afSmrg		*[\ /]"$newobj "*) ;;
5489382ff0afSmrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
5490382ff0afSmrg		esac
5491382ff0afSmrg	      done
5492382ff0afSmrg	      $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
5493382ff0afSmrg	      $run ln "$obj" "$gentop/$newobj" ||
5494382ff0afSmrg	      $run cp "$obj" "$gentop/$newobj"
5495382ff0afSmrg	      oldobjs="$oldobjs $gentop/$newobj"
5496382ff0afSmrg	      ;;
5497382ff0afSmrg	    *) oldobjs="$oldobjs $obj" ;;
5498382ff0afSmrg	    esac
5499382ff0afSmrg	  done
5500382ff0afSmrg	fi
5501382ff0afSmrg
5502382ff0afSmrg	eval cmds=\"$old_archive_cmds\"
5503382ff0afSmrg
5504382ff0afSmrg	if len=`expr "X$cmds" : ".*"` &&
5505382ff0afSmrg	     test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
5506382ff0afSmrg	  cmds=$old_archive_cmds
5507382ff0afSmrg	else
5508382ff0afSmrg	  # the command line is too long to link in one step, link in parts
5509382ff0afSmrg	  $echo "using piecewise archive linking..."
5510382ff0afSmrg	  save_RANLIB=$RANLIB
5511382ff0afSmrg	  RANLIB=:
5512382ff0afSmrg	  objlist=
5513382ff0afSmrg	  concat_cmds=
5514382ff0afSmrg	  save_oldobjs=$oldobjs
5515382ff0afSmrg
5516382ff0afSmrg	  # Is there a better way of finding the last object in the list?
5517382ff0afSmrg	  for obj in $save_oldobjs
5518382ff0afSmrg	  do
5519382ff0afSmrg	    last_oldobj=$obj
5520382ff0afSmrg	  done
5521382ff0afSmrg	  for obj in $save_oldobjs
5522382ff0afSmrg	  do
5523382ff0afSmrg	    oldobjs="$objlist $obj"
5524382ff0afSmrg	    objlist="$objlist $obj"
5525382ff0afSmrg	    eval test_cmds=\"$old_archive_cmds\"
5526382ff0afSmrg	    if len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
5527382ff0afSmrg	       test "$len" -le "$max_cmd_len"; then
5528382ff0afSmrg	      :
5529382ff0afSmrg	    else
5530382ff0afSmrg	      # the above command should be used before it gets too long
5531382ff0afSmrg	      oldobjs=$objlist
5532382ff0afSmrg	      if test "$obj" = "$last_oldobj" ; then
5533382ff0afSmrg	        RANLIB=$save_RANLIB
5534382ff0afSmrg	      fi
5535382ff0afSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
5536382ff0afSmrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
5537382ff0afSmrg	      objlist=
5538382ff0afSmrg	    fi
5539382ff0afSmrg	  done
5540382ff0afSmrg	  RANLIB=$save_RANLIB
5541382ff0afSmrg	  oldobjs=$objlist
5542382ff0afSmrg	  if test "X$oldobjs" = "X" ; then
5543382ff0afSmrg	    eval cmds=\"\$concat_cmds\"
5544382ff0afSmrg	  else
5545382ff0afSmrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
5546382ff0afSmrg	  fi
5547382ff0afSmrg	fi
5548382ff0afSmrg      fi
5549382ff0afSmrg      save_ifs="$IFS"; IFS='~'
5550382ff0afSmrg      for cmd in $cmds; do
5551382ff0afSmrg        eval cmd=\"$cmd\"
5552382ff0afSmrg	IFS="$save_ifs"
5553382ff0afSmrg	$show "$cmd"
5554382ff0afSmrg	$run eval "$cmd" || exit $?
5555382ff0afSmrg      done
5556382ff0afSmrg      IFS="$save_ifs"
5557382ff0afSmrg    done
5558382ff0afSmrg
5559382ff0afSmrg    if test -n "$generated"; then
5560382ff0afSmrg      $show "${rm}r$generated"
5561382ff0afSmrg      $run ${rm}r$generated
5562382ff0afSmrg    fi
5563382ff0afSmrg
5564382ff0afSmrg    # Now create the libtool archive.
5565382ff0afSmrg    case $output in
5566382ff0afSmrg    *.la)
5567382ff0afSmrg      old_library=
5568382ff0afSmrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
5569382ff0afSmrg      $show "creating $output"
5570382ff0afSmrg
5571382ff0afSmrg      # Preserve any variables that may affect compiler behavior
5572382ff0afSmrg      for var in $variables_saved_for_relink; do
5573382ff0afSmrg	if eval test -z \"\${$var+set}\"; then
5574382ff0afSmrg	  relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
5575382ff0afSmrg	elif eval var_value=\$$var; test -z "$var_value"; then
5576382ff0afSmrg	  relink_command="$var=; export $var; $relink_command"
5577382ff0afSmrg	else
5578382ff0afSmrg	  var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
5579382ff0afSmrg	  relink_command="$var=\"$var_value\"; export $var; $relink_command"
5580382ff0afSmrg	fi
5581382ff0afSmrg      done
5582382ff0afSmrg      # Quote the link command for shipping.
5583382ff0afSmrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
5584382ff0afSmrg      relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
5585382ff0afSmrg      if test "$hardcode_automatic" = yes ; then
5586382ff0afSmrg	relink_command=
5587382ff0afSmrg      fi
5588382ff0afSmrg
5589382ff0afSmrg
5590382ff0afSmrg      # Only create the output if not a dry run.
5591382ff0afSmrg      if test -z "$run"; then
5592382ff0afSmrg	for installed in no yes; do
5593382ff0afSmrg	  if test "$installed" = yes; then
5594382ff0afSmrg	    if test -z "$install_libdir"; then
5595382ff0afSmrg	      break
5596382ff0afSmrg	    fi
5597382ff0afSmrg	    output="$output_objdir/$outputname"i
5598382ff0afSmrg	    # Replace all uninstalled libtool libraries with the installed ones
5599382ff0afSmrg	    newdependency_libs=
5600382ff0afSmrg	    for deplib in $dependency_libs; do
5601382ff0afSmrg	      case $deplib in
5602382ff0afSmrg	      *.la)
5603382ff0afSmrg		name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
5604382ff0afSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
5605382ff0afSmrg		if test -z "$libdir"; then
5606382ff0afSmrg		  $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
5607382ff0afSmrg		  exit $EXIT_FAILURE
5608382ff0afSmrg		fi
5609382ff0afSmrg		newdependency_libs="$newdependency_libs $libdir/$name"
5610382ff0afSmrg		;;
5611382ff0afSmrg	      *) newdependency_libs="$newdependency_libs $deplib" ;;
5612382ff0afSmrg	      esac
5613382ff0afSmrg	    done
5614382ff0afSmrg	    dependency_libs="$newdependency_libs"
5615382ff0afSmrg	    newdlfiles=
5616382ff0afSmrg	    for lib in $dlfiles; do
5617382ff0afSmrg	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
5618382ff0afSmrg	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
5619382ff0afSmrg	      if test -z "$libdir"; then
5620382ff0afSmrg		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
5621382ff0afSmrg		exit $EXIT_FAILURE
5622382ff0afSmrg	      fi
5623382ff0afSmrg	      newdlfiles="$newdlfiles $libdir/$name"
5624382ff0afSmrg	    done
5625382ff0afSmrg	    dlfiles="$newdlfiles"
5626382ff0afSmrg	    newdlprefiles=
5627382ff0afSmrg	    for lib in $dlprefiles; do
5628382ff0afSmrg	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
5629382ff0afSmrg	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
5630382ff0afSmrg	      if test -z "$libdir"; then
5631382ff0afSmrg		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
5632382ff0afSmrg		exit $EXIT_FAILURE
5633382ff0afSmrg	      fi
5634382ff0afSmrg	      newdlprefiles="$newdlprefiles $libdir/$name"
5635382ff0afSmrg	    done
5636382ff0afSmrg	    dlprefiles="$newdlprefiles"
5637382ff0afSmrg	  else
5638382ff0afSmrg	    newdlfiles=
5639382ff0afSmrg	    for lib in $dlfiles; do
5640382ff0afSmrg	      case $lib in
5641382ff0afSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
5642382ff0afSmrg		*) abs=`pwd`"/$lib" ;;
5643382ff0afSmrg	      esac
5644382ff0afSmrg	      newdlfiles="$newdlfiles $abs"
5645382ff0afSmrg	    done
5646382ff0afSmrg	    dlfiles="$newdlfiles"
5647382ff0afSmrg	    newdlprefiles=
5648382ff0afSmrg	    for lib in $dlprefiles; do
5649382ff0afSmrg	      case $lib in
5650382ff0afSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
5651382ff0afSmrg		*) abs=`pwd`"/$lib" ;;
5652382ff0afSmrg	      esac
5653382ff0afSmrg	      newdlprefiles="$newdlprefiles $abs"
5654382ff0afSmrg	    done
5655382ff0afSmrg	    dlprefiles="$newdlprefiles"
5656382ff0afSmrg	  fi
5657382ff0afSmrg	  $rm $output
5658382ff0afSmrg	  # place dlname in correct position for cygwin
5659382ff0afSmrg	  tdlname=$dlname
5660382ff0afSmrg	  case $host,$output,$installed,$module,$dlname in
5661382ff0afSmrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
5662382ff0afSmrg	  esac
5663382ff0afSmrg	  $echo > $output "\
5664382ff0afSmrg# $outputname - a libtool library file
5665382ff0afSmrg# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
5666382ff0afSmrg#
5667382ff0afSmrg# Please DO NOT delete this file!
5668382ff0afSmrg# It is necessary for linking the library.
5669382ff0afSmrg
5670382ff0afSmrg# The name that we can dlopen(3).
5671382ff0afSmrgdlname='$tdlname'
5672382ff0afSmrg
5673382ff0afSmrg# Names of this library.
5674382ff0afSmrglibrary_names='$library_names'
5675382ff0afSmrg
5676382ff0afSmrg# The name of the static archive.
5677382ff0afSmrgold_library='$old_library'
5678382ff0afSmrg
5679382ff0afSmrg# Libraries that this one depends upon.
5680382ff0afSmrgdependency_libs='$dependency_libs'
5681382ff0afSmrg
5682382ff0afSmrg# Version information for $libname.
5683382ff0afSmrgcurrent=$current
5684382ff0afSmrgage=$age
5685382ff0afSmrgrevision=$revision
5686382ff0afSmrg
5687382ff0afSmrg# Is this an already installed library?
5688382ff0afSmrginstalled=$installed
5689382ff0afSmrg
5690382ff0afSmrg# Should we warn about portability when linking against -modules?
5691382ff0afSmrgshouldnotlink=$module
5692382ff0afSmrg
5693382ff0afSmrg# Files to dlopen/dlpreopen
5694382ff0afSmrgdlopen='$dlfiles'
5695382ff0afSmrgdlpreopen='$dlprefiles'
5696382ff0afSmrg
5697382ff0afSmrg# Directory that this library needs to be installed in:
5698382ff0afSmrglibdir='$install_libdir'"
5699382ff0afSmrg	  if test "$installed" = no && test "$need_relink" = yes; then
5700382ff0afSmrg	    $echo >> $output "\
5701382ff0afSmrgrelink_command=\"$relink_command\""
5702382ff0afSmrg	  fi
5703382ff0afSmrg	done
5704382ff0afSmrg      fi
5705382ff0afSmrg
5706382ff0afSmrg      # Do a symbolic link so that the libtool archive can be found in
5707382ff0afSmrg      # LD_LIBRARY_PATH before the program is installed.
5708382ff0afSmrg      $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
5709382ff0afSmrg      $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $?
5710382ff0afSmrg      ;;
5711382ff0afSmrg    esac
5712382ff0afSmrg    exit $EXIT_SUCCESS
5713382ff0afSmrg    ;;
5714382ff0afSmrg
5715382ff0afSmrg  # libtool install mode
5716382ff0afSmrg  install)
5717382ff0afSmrg    modename="$modename: install"
5718382ff0afSmrg
5719382ff0afSmrg    # There may be an optional sh(1) argument at the beginning of
5720382ff0afSmrg    # install_prog (especially on Windows NT).
5721382ff0afSmrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
5722382ff0afSmrg       # Allow the use of GNU shtool's install command.
5723382ff0afSmrg       $echo "X$nonopt" | grep shtool > /dev/null; then
5724382ff0afSmrg      # Aesthetically quote it.
5725382ff0afSmrg      arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
5726382ff0afSmrg      case $arg in
5727382ff0afSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
5728382ff0afSmrg	arg="\"$arg\""
5729382ff0afSmrg	;;
5730382ff0afSmrg      esac
5731382ff0afSmrg      install_prog="$arg "
5732382ff0afSmrg      arg="$1"
5733382ff0afSmrg      shift
5734382ff0afSmrg    else
5735382ff0afSmrg      install_prog=
5736382ff0afSmrg      arg=$nonopt
5737382ff0afSmrg    fi
5738382ff0afSmrg
5739382ff0afSmrg    # The real first argument should be the name of the installation program.
5740382ff0afSmrg    # Aesthetically quote it.
5741382ff0afSmrg    arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
5742382ff0afSmrg    case $arg in
5743382ff0afSmrg    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
5744382ff0afSmrg      arg="\"$arg\""
5745382ff0afSmrg      ;;
5746382ff0afSmrg    esac
5747382ff0afSmrg    install_prog="$install_prog$arg"
5748382ff0afSmrg
5749382ff0afSmrg    # We need to accept at least all the BSD install flags.
5750382ff0afSmrg    dest=
5751382ff0afSmrg    files=
5752382ff0afSmrg    opts=
5753382ff0afSmrg    prev=
5754382ff0afSmrg    install_type=
5755382ff0afSmrg    isdir=no
5756382ff0afSmrg    stripme=
5757382ff0afSmrg    for arg
5758382ff0afSmrg    do
5759382ff0afSmrg      if test -n "$dest"; then
5760382ff0afSmrg	files="$files $dest"
5761382ff0afSmrg	dest=$arg
5762382ff0afSmrg	continue
5763382ff0afSmrg      fi
5764382ff0afSmrg
5765382ff0afSmrg      case $arg in
5766382ff0afSmrg      -d) isdir=yes ;;
5767382ff0afSmrg      -f) 
5768382ff0afSmrg      	case " $install_prog " in
5769382ff0afSmrg	*[\\\ /]cp\ *) ;;
5770382ff0afSmrg	*) prev=$arg ;;
5771382ff0afSmrg	esac
5772382ff0afSmrg	;;
5773382ff0afSmrg      -g | -m | -o) prev=$arg ;;
5774382ff0afSmrg      -s)
5775382ff0afSmrg	stripme=" -s"
5776382ff0afSmrg	continue
5777382ff0afSmrg	;;
5778382ff0afSmrg      -*)
5779382ff0afSmrg	;;
5780382ff0afSmrg      *)
5781382ff0afSmrg	# If the previous option needed an argument, then skip it.
5782382ff0afSmrg	if test -n "$prev"; then
5783382ff0afSmrg	  prev=
5784382ff0afSmrg	else
5785382ff0afSmrg	  dest=$arg
5786382ff0afSmrg	  continue
5787382ff0afSmrg	fi
5788382ff0afSmrg	;;
5789382ff0afSmrg      esac
5790382ff0afSmrg
5791382ff0afSmrg      # Aesthetically quote the argument.
5792382ff0afSmrg      arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
5793382ff0afSmrg      case $arg in
5794382ff0afSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
5795382ff0afSmrg	arg="\"$arg\""
5796382ff0afSmrg	;;
5797382ff0afSmrg      esac
5798382ff0afSmrg      install_prog="$install_prog $arg"
5799382ff0afSmrg    done
5800382ff0afSmrg
5801382ff0afSmrg    if test -z "$install_prog"; then
5802382ff0afSmrg      $echo "$modename: you must specify an install program" 1>&2
5803382ff0afSmrg      $echo "$help" 1>&2
5804382ff0afSmrg      exit $EXIT_FAILURE
5805382ff0afSmrg    fi
5806382ff0afSmrg
5807382ff0afSmrg    if test -n "$prev"; then
5808382ff0afSmrg      $echo "$modename: the \`$prev' option requires an argument" 1>&2
5809382ff0afSmrg      $echo "$help" 1>&2
5810382ff0afSmrg      exit $EXIT_FAILURE
5811382ff0afSmrg    fi
5812382ff0afSmrg
5813382ff0afSmrg    if test -z "$files"; then
5814382ff0afSmrg      if test -z "$dest"; then
5815382ff0afSmrg	$echo "$modename: no file or destination specified" 1>&2
5816382ff0afSmrg      else
5817382ff0afSmrg	$echo "$modename: you must specify a destination" 1>&2
5818382ff0afSmrg      fi
5819382ff0afSmrg      $echo "$help" 1>&2
5820382ff0afSmrg      exit $EXIT_FAILURE
5821382ff0afSmrg    fi
5822382ff0afSmrg
5823382ff0afSmrg    # Strip any trailing slash from the destination.
5824382ff0afSmrg    dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
5825382ff0afSmrg
5826382ff0afSmrg    # Check to see that the destination is a directory.
5827382ff0afSmrg    test -d "$dest" && isdir=yes
5828382ff0afSmrg    if test "$isdir" = yes; then
5829382ff0afSmrg      destdir="$dest"
5830382ff0afSmrg      destname=
5831382ff0afSmrg    else
5832382ff0afSmrg      destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
5833382ff0afSmrg      test "X$destdir" = "X$dest" && destdir=.
5834382ff0afSmrg      destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
5835382ff0afSmrg
5836382ff0afSmrg      # Not a directory, so check to see that there is only one file specified.
5837382ff0afSmrg      set dummy $files
5838382ff0afSmrg      if test "$#" -gt 2; then
5839382ff0afSmrg	$echo "$modename: \`$dest' is not a directory" 1>&2
5840382ff0afSmrg	$echo "$help" 1>&2
5841382ff0afSmrg	exit $EXIT_FAILURE
5842382ff0afSmrg      fi
5843382ff0afSmrg    fi
5844382ff0afSmrg    case $destdir in
5845382ff0afSmrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
5846382ff0afSmrg    *)
5847382ff0afSmrg      for file in $files; do
5848382ff0afSmrg	case $file in
5849382ff0afSmrg	*.lo) ;;
5850382ff0afSmrg	*)
5851382ff0afSmrg	  $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
5852382ff0afSmrg	  $echo "$help" 1>&2
5853382ff0afSmrg	  exit $EXIT_FAILURE
5854382ff0afSmrg	  ;;
5855382ff0afSmrg	esac
5856382ff0afSmrg      done
5857382ff0afSmrg      ;;
5858382ff0afSmrg    esac
5859382ff0afSmrg
5860382ff0afSmrg    # This variable tells wrapper scripts just to set variables rather
5861382ff0afSmrg    # than running their programs.
5862382ff0afSmrg    libtool_install_magic="$magic"
5863382ff0afSmrg
5864382ff0afSmrg    staticlibs=
5865382ff0afSmrg    future_libdirs=
5866382ff0afSmrg    current_libdirs=
5867382ff0afSmrg    for file in $files; do
5868382ff0afSmrg
5869382ff0afSmrg      # Do each installation.
5870382ff0afSmrg      case $file in
5871382ff0afSmrg      *.$libext)
5872382ff0afSmrg	# Do the static libraries later.
5873382ff0afSmrg	staticlibs="$staticlibs $file"
5874382ff0afSmrg	;;
5875382ff0afSmrg
5876382ff0afSmrg      *.la)
5877382ff0afSmrg	# Check to see that this really is a libtool archive.
5878382ff0afSmrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
5879382ff0afSmrg	else
5880382ff0afSmrg	  $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
5881382ff0afSmrg	  $echo "$help" 1>&2
5882382ff0afSmrg	  exit $EXIT_FAILURE
5883382ff0afSmrg	fi
5884382ff0afSmrg
5885382ff0afSmrg	library_names=
5886382ff0afSmrg	old_library=
5887382ff0afSmrg	relink_command=
5888382ff0afSmrg	# If there is no directory component, then add one.
5889382ff0afSmrg	case $file in
5890382ff0afSmrg	*/* | *\\*) . $file ;;
5891382ff0afSmrg	*) . ./$file ;;
5892382ff0afSmrg	esac
5893382ff0afSmrg
5894382ff0afSmrg	# Add the libdir to current_libdirs if it is the destination.
5895382ff0afSmrg	if test "X$destdir" = "X$libdir"; then
5896382ff0afSmrg	  case "$current_libdirs " in
5897382ff0afSmrg	  *" $libdir "*) ;;
5898382ff0afSmrg	  *) current_libdirs="$current_libdirs $libdir" ;;
5899382ff0afSmrg	  esac
5900382ff0afSmrg	else
5901382ff0afSmrg	  # Note the libdir as a future libdir.
5902382ff0afSmrg	  case "$future_libdirs " in
5903382ff0afSmrg	  *" $libdir "*) ;;
5904382ff0afSmrg	  *) future_libdirs="$future_libdirs $libdir" ;;
5905382ff0afSmrg	  esac
5906382ff0afSmrg	fi
5907382ff0afSmrg
5908382ff0afSmrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/
5909382ff0afSmrg	test "X$dir" = "X$file/" && dir=
5910382ff0afSmrg	dir="$dir$objdir"
5911382ff0afSmrg
5912382ff0afSmrg	if test -n "$relink_command"; then
5913382ff0afSmrg	  # Determine the prefix the user has applied to our future dir.
5914382ff0afSmrg	  inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"`
5915382ff0afSmrg
5916382ff0afSmrg	  # Don't allow the user to place us outside of our expected
5917382ff0afSmrg	  # location b/c this prevents finding dependent libraries that
5918382ff0afSmrg	  # are installed to the same prefix.
5919382ff0afSmrg	  # At present, this check doesn't affect windows .dll's that
5920382ff0afSmrg	  # are installed into $libdir/../bin (currently, that works fine)
5921382ff0afSmrg	  # but it's something to keep an eye on.
5922382ff0afSmrg	  if test "$inst_prefix_dir" = "$destdir"; then
5923382ff0afSmrg	    $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
5924382ff0afSmrg	    exit $EXIT_FAILURE
5925382ff0afSmrg	  fi
5926382ff0afSmrg
5927382ff0afSmrg	  if test -n "$inst_prefix_dir"; then
5928382ff0afSmrg	    # Stick the inst_prefix_dir data into the link command.
5929382ff0afSmrg	    relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
5930382ff0afSmrg	  else
5931382ff0afSmrg	    relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
5932382ff0afSmrg	  fi
5933382ff0afSmrg
5934382ff0afSmrg	  $echo "$modename: warning: relinking \`$file'" 1>&2
5935382ff0afSmrg	  $show "$relink_command"
5936382ff0afSmrg	  if $run eval "$relink_command"; then :
5937382ff0afSmrg	  else
5938382ff0afSmrg	    $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
5939382ff0afSmrg	    exit $EXIT_FAILURE
5940382ff0afSmrg	  fi
5941382ff0afSmrg	fi
5942382ff0afSmrg
5943382ff0afSmrg	# See the names of the shared library.
5944382ff0afSmrg	set dummy $library_names
5945382ff0afSmrg	if test -n "$2"; then
5946382ff0afSmrg	  realname="$2"
5947382ff0afSmrg	  shift
5948382ff0afSmrg	  shift
5949382ff0afSmrg
5950382ff0afSmrg	  srcname="$realname"
5951382ff0afSmrg	  test -n "$relink_command" && srcname="$realname"T
5952382ff0afSmrg
5953382ff0afSmrg	  # Install the shared library and build the symlinks.
5954382ff0afSmrg	  $show "$install_prog $dir/$srcname $destdir/$realname"
5955382ff0afSmrg	  $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $?
5956382ff0afSmrg	  if test -n "$stripme" && test -n "$striplib"; then
5957382ff0afSmrg	    $show "$striplib $destdir/$realname"
5958382ff0afSmrg	    $run eval "$striplib $destdir/$realname" || exit $?
5959382ff0afSmrg	  fi
5960382ff0afSmrg
5961382ff0afSmrg	  if test "$#" -gt 0; then
5962382ff0afSmrg	    # Delete the old symlinks, and create new ones.
5963382ff0afSmrg	    # Try `ln -sf' first, because the `ln' binary might depend on
5964382ff0afSmrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
5965382ff0afSmrg	    # so we also need to try rm && ln -s.
5966382ff0afSmrg	    for linkname
5967382ff0afSmrg	    do
5968382ff0afSmrg	      if test "$linkname" != "$realname"; then
5969382ff0afSmrg                $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
5970382ff0afSmrg                $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
5971382ff0afSmrg	      fi
5972382ff0afSmrg	    done
5973382ff0afSmrg	  fi
5974382ff0afSmrg
5975382ff0afSmrg	  # Do each command in the postinstall commands.
5976382ff0afSmrg	  lib="$destdir/$realname"
5977382ff0afSmrg	  cmds=$postinstall_cmds
5978382ff0afSmrg	  save_ifs="$IFS"; IFS='~'
5979382ff0afSmrg	  for cmd in $cmds; do
5980382ff0afSmrg	    IFS="$save_ifs"
5981382ff0afSmrg	    eval cmd=\"$cmd\"
5982382ff0afSmrg	    $show "$cmd"
5983382ff0afSmrg	    $run eval "$cmd" || {
5984382ff0afSmrg	      lt_exit=$?
5985382ff0afSmrg
5986382ff0afSmrg	      # Restore the uninstalled library and exit
5987382ff0afSmrg	      if test "$mode" = relink; then
5988382ff0afSmrg		$run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
5989382ff0afSmrg	      fi
5990382ff0afSmrg
5991382ff0afSmrg	      exit $lt_exit
5992382ff0afSmrg	    }
5993382ff0afSmrg	  done
5994382ff0afSmrg	  IFS="$save_ifs"
5995382ff0afSmrg	fi
5996382ff0afSmrg
5997382ff0afSmrg	# Install the pseudo-library for information purposes.
5998382ff0afSmrg	name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
5999382ff0afSmrg	instname="$dir/$name"i
6000382ff0afSmrg	$show "$install_prog $instname $destdir/$name"
6001382ff0afSmrg	$run eval "$install_prog $instname $destdir/$name" || exit $?
6002382ff0afSmrg
6003382ff0afSmrg	# Maybe install the static library, too.
6004382ff0afSmrg	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
6005382ff0afSmrg	;;
6006382ff0afSmrg
6007382ff0afSmrg      *.lo)
6008382ff0afSmrg	# Install (i.e. copy) a libtool object.
6009382ff0afSmrg
6010382ff0afSmrg	# Figure out destination file name, if it wasn't already specified.
6011382ff0afSmrg	if test -n "$destname"; then
6012382ff0afSmrg	  destfile="$destdir/$destname"
6013382ff0afSmrg	else
6014382ff0afSmrg	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
6015382ff0afSmrg	  destfile="$destdir/$destfile"
6016382ff0afSmrg	fi
6017382ff0afSmrg
6018382ff0afSmrg	# Deduce the name of the destination old-style object file.
6019382ff0afSmrg	case $destfile in
6020382ff0afSmrg	*.lo)
6021382ff0afSmrg	  staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
6022382ff0afSmrg	  ;;
6023382ff0afSmrg	*.$objext)
6024382ff0afSmrg	  staticdest="$destfile"
6025382ff0afSmrg	  destfile=
6026382ff0afSmrg	  ;;
6027382ff0afSmrg	*)
6028382ff0afSmrg	  $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
6029382ff0afSmrg	  $echo "$help" 1>&2
6030382ff0afSmrg	  exit $EXIT_FAILURE
6031382ff0afSmrg	  ;;
6032382ff0afSmrg	esac
6033382ff0afSmrg
6034382ff0afSmrg	# Install the libtool object if requested.
6035382ff0afSmrg	if test -n "$destfile"; then
6036382ff0afSmrg	  $show "$install_prog $file $destfile"
6037382ff0afSmrg	  $run eval "$install_prog $file $destfile" || exit $?
6038382ff0afSmrg	fi
6039382ff0afSmrg
6040382ff0afSmrg	# Install the old object if enabled.
6041382ff0afSmrg	if test "$build_old_libs" = yes; then
6042382ff0afSmrg	  # Deduce the name of the old-style object file.
6043382ff0afSmrg	  staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
6044382ff0afSmrg
6045382ff0afSmrg	  $show "$install_prog $staticobj $staticdest"
6046382ff0afSmrg	  $run eval "$install_prog \$staticobj \$staticdest" || exit $?
6047382ff0afSmrg	fi
6048382ff0afSmrg	exit $EXIT_SUCCESS
6049382ff0afSmrg	;;
6050382ff0afSmrg
6051382ff0afSmrg      *)
6052382ff0afSmrg	# Figure out destination file name, if it wasn't already specified.
6053382ff0afSmrg	if test -n "$destname"; then
6054382ff0afSmrg	  destfile="$destdir/$destname"
6055382ff0afSmrg	else
6056382ff0afSmrg	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
6057382ff0afSmrg	  destfile="$destdir/$destfile"
6058382ff0afSmrg	fi
6059382ff0afSmrg
6060382ff0afSmrg	# If the file is missing, and there is a .exe on the end, strip it
6061382ff0afSmrg	# because it is most likely a libtool script we actually want to
6062382ff0afSmrg	# install
6063382ff0afSmrg	stripped_ext=""
6064382ff0afSmrg	case $file in
6065382ff0afSmrg	  *.exe)
6066382ff0afSmrg	    if test ! -f "$file"; then
6067382ff0afSmrg	      file=`$echo $file|${SED} 's,.exe$,,'`
6068382ff0afSmrg	      stripped_ext=".exe"
6069382ff0afSmrg	    fi
6070382ff0afSmrg	    ;;
6071382ff0afSmrg	esac
6072382ff0afSmrg
6073382ff0afSmrg	# Do a test to see if this is really a libtool program.
6074382ff0afSmrg	case $host in
6075382ff0afSmrg	*cygwin*|*mingw*)
6076382ff0afSmrg	    wrapper=`$echo $file | ${SED} -e 's,.exe$,,'`
6077382ff0afSmrg	    ;;
6078382ff0afSmrg	*)
6079382ff0afSmrg	    wrapper=$file
6080382ff0afSmrg	    ;;
6081382ff0afSmrg	esac
6082382ff0afSmrg	if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then
6083382ff0afSmrg	  notinst_deplibs=
6084382ff0afSmrg	  relink_command=
6085382ff0afSmrg
6086382ff0afSmrg	  # Note that it is not necessary on cygwin/mingw to append a dot to
6087382ff0afSmrg	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
6088382ff0afSmrg	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
6089382ff0afSmrg	  # `FILE.' does not work on cygwin managed mounts.
6090382ff0afSmrg	  #
6091382ff0afSmrg	  # If there is no directory component, then add one.
6092382ff0afSmrg	  case $wrapper in
6093382ff0afSmrg	  */* | *\\*) . ${wrapper} ;;
6094382ff0afSmrg	  *) . ./${wrapper} ;;
6095382ff0afSmrg	  esac
6096382ff0afSmrg
6097382ff0afSmrg	  # Check the variables that should have been set.
6098382ff0afSmrg	  if test -z "$notinst_deplibs"; then
6099382ff0afSmrg	    $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2
6100382ff0afSmrg	    exit $EXIT_FAILURE
6101382ff0afSmrg	  fi
6102382ff0afSmrg
6103382ff0afSmrg	  finalize=yes
6104382ff0afSmrg	  for lib in $notinst_deplibs; do
6105382ff0afSmrg	    # Check to see that each library is installed.
6106382ff0afSmrg	    libdir=
6107382ff0afSmrg	    if test -f "$lib"; then
6108382ff0afSmrg	      # If there is no directory component, then add one.
6109382ff0afSmrg	      case $lib in
6110382ff0afSmrg	      */* | *\\*) . $lib ;;
6111382ff0afSmrg	      *) . ./$lib ;;
6112382ff0afSmrg	      esac
6113382ff0afSmrg	    fi
6114382ff0afSmrg	    libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
6115382ff0afSmrg	    if test -n "$libdir" && test ! -f "$libfile"; then
6116382ff0afSmrg	      $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
6117382ff0afSmrg	      finalize=no
6118382ff0afSmrg	    fi
6119382ff0afSmrg	  done
6120382ff0afSmrg
6121382ff0afSmrg	  relink_command=
6122382ff0afSmrg	  # Note that it is not necessary on cygwin/mingw to append a dot to
6123382ff0afSmrg	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
6124382ff0afSmrg	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
6125382ff0afSmrg	  # `FILE.' does not work on cygwin managed mounts.
6126382ff0afSmrg	  #
6127382ff0afSmrg	  # If there is no directory component, then add one.
6128382ff0afSmrg	  case $wrapper in
6129382ff0afSmrg	  */* | *\\*) . ${wrapper} ;;
6130382ff0afSmrg	  *) . ./${wrapper} ;;
6131382ff0afSmrg	  esac
6132382ff0afSmrg
6133382ff0afSmrg	  outputname=
6134382ff0afSmrg	  if test "$fast_install" = no && test -n "$relink_command"; then
6135382ff0afSmrg	    if test "$finalize" = yes && test -z "$run"; then
6136382ff0afSmrg	      tmpdir=`func_mktempdir`
6137382ff0afSmrg	      file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
6138382ff0afSmrg	      outputname="$tmpdir/$file"
6139382ff0afSmrg	      # Replace the output file specification.
6140382ff0afSmrg	      relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
6141382ff0afSmrg
6142382ff0afSmrg	      $show "$relink_command"
6143382ff0afSmrg	      if $run eval "$relink_command"; then :
6144382ff0afSmrg	      else
6145382ff0afSmrg		$echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
6146382ff0afSmrg		${rm}r "$tmpdir"
6147382ff0afSmrg		continue
6148382ff0afSmrg	      fi
6149382ff0afSmrg	      file="$outputname"
6150382ff0afSmrg	    else
6151382ff0afSmrg	      $echo "$modename: warning: cannot relink \`$file'" 1>&2
6152382ff0afSmrg	    fi
6153382ff0afSmrg	  else
6154382ff0afSmrg	    # Install the binary that we compiled earlier.
6155382ff0afSmrg	    file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
6156382ff0afSmrg	  fi
6157382ff0afSmrg	fi
6158382ff0afSmrg
6159382ff0afSmrg	# remove .exe since cygwin /usr/bin/install will append another
6160382ff0afSmrg	# one anyway 
6161382ff0afSmrg	case $install_prog,$host in
6162382ff0afSmrg	*/usr/bin/install*,*cygwin*)
6163382ff0afSmrg	  case $file:$destfile in
6164382ff0afSmrg	  *.exe:*.exe)
6165382ff0afSmrg	    # this is ok
6166382ff0afSmrg	    ;;
6167382ff0afSmrg	  *.exe:*)
6168382ff0afSmrg	    destfile=$destfile.exe
6169382ff0afSmrg	    ;;
6170382ff0afSmrg	  *:*.exe)
6171382ff0afSmrg	    destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'`
6172382ff0afSmrg	    ;;
6173382ff0afSmrg	  esac
6174382ff0afSmrg	  ;;
6175382ff0afSmrg	esac
6176382ff0afSmrg	$show "$install_prog$stripme $file $destfile"
6177382ff0afSmrg	$run eval "$install_prog\$stripme \$file \$destfile" || exit $?
6178382ff0afSmrg	test -n "$outputname" && ${rm}r "$tmpdir"
6179382ff0afSmrg	;;
6180382ff0afSmrg      esac
6181382ff0afSmrg    done
6182382ff0afSmrg
6183382ff0afSmrg    for file in $staticlibs; do
6184382ff0afSmrg      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
6185382ff0afSmrg
6186382ff0afSmrg      # Set up the ranlib parameters.
6187382ff0afSmrg      oldlib="$destdir/$name"
6188382ff0afSmrg
6189382ff0afSmrg      $show "$install_prog $file $oldlib"
6190382ff0afSmrg      $run eval "$install_prog \$file \$oldlib" || exit $?
6191382ff0afSmrg
6192382ff0afSmrg      if test -n "$stripme" && test -n "$old_striplib"; then
6193382ff0afSmrg	$show "$old_striplib $oldlib"
6194382ff0afSmrg	$run eval "$old_striplib $oldlib" || exit $?
6195382ff0afSmrg      fi
6196382ff0afSmrg
6197382ff0afSmrg      # Do each command in the postinstall commands.
6198382ff0afSmrg      cmds=$old_postinstall_cmds
6199382ff0afSmrg      save_ifs="$IFS"; IFS='~'
6200382ff0afSmrg      for cmd in $cmds; do
6201382ff0afSmrg	IFS="$save_ifs"
6202382ff0afSmrg	eval cmd=\"$cmd\"
6203382ff0afSmrg	$show "$cmd"
6204382ff0afSmrg	$run eval "$cmd" || exit $?
6205382ff0afSmrg      done
6206382ff0afSmrg      IFS="$save_ifs"
6207382ff0afSmrg    done
6208382ff0afSmrg
6209382ff0afSmrg    if test -n "$future_libdirs"; then
6210382ff0afSmrg      $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
6211382ff0afSmrg    fi
6212382ff0afSmrg
6213382ff0afSmrg    if test -n "$current_libdirs"; then
6214382ff0afSmrg      # Maybe just do a dry run.
6215382ff0afSmrg      test -n "$run" && current_libdirs=" -n$current_libdirs"
6216382ff0afSmrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
6217382ff0afSmrg    else
6218382ff0afSmrg      exit $EXIT_SUCCESS
6219382ff0afSmrg    fi
6220382ff0afSmrg    ;;
6221382ff0afSmrg
6222382ff0afSmrg  # libtool finish mode
6223382ff0afSmrg  finish)
6224382ff0afSmrg    modename="$modename: finish"
6225382ff0afSmrg    libdirs="$nonopt"
6226382ff0afSmrg    admincmds=
6227382ff0afSmrg
6228382ff0afSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
6229382ff0afSmrg      for dir
6230382ff0afSmrg      do
6231382ff0afSmrg	libdirs="$libdirs $dir"
6232382ff0afSmrg      done
6233382ff0afSmrg
6234382ff0afSmrg      for libdir in $libdirs; do
6235382ff0afSmrg	if test -n "$finish_cmds"; then
6236382ff0afSmrg	  # Do each command in the finish commands.
6237382ff0afSmrg	  cmds=$finish_cmds
6238382ff0afSmrg	  save_ifs="$IFS"; IFS='~'
6239382ff0afSmrg	  for cmd in $cmds; do
6240382ff0afSmrg	    IFS="$save_ifs"
6241382ff0afSmrg	    eval cmd=\"$cmd\"
6242382ff0afSmrg	    $show "$cmd"
6243382ff0afSmrg	    $run eval "$cmd" || admincmds="$admincmds
6244382ff0afSmrg       $cmd"
6245382ff0afSmrg	  done
6246382ff0afSmrg	  IFS="$save_ifs"
6247382ff0afSmrg	fi
6248382ff0afSmrg	if test -n "$finish_eval"; then
6249382ff0afSmrg	  # Do the single finish_eval.
6250382ff0afSmrg	  eval cmds=\"$finish_eval\"
6251382ff0afSmrg	  $run eval "$cmds" || admincmds="$admincmds
6252382ff0afSmrg       $cmds"
6253382ff0afSmrg	fi
6254382ff0afSmrg      done
6255382ff0afSmrg    fi
6256382ff0afSmrg
6257382ff0afSmrg    # Exit here if they wanted silent mode.
6258382ff0afSmrg    test "$show" = : && exit $EXIT_SUCCESS
6259382ff0afSmrg
6260382ff0afSmrg    $echo "X----------------------------------------------------------------------" | $Xsed
6261382ff0afSmrg    $echo "Libraries have been installed in:"
6262382ff0afSmrg    for libdir in $libdirs; do
6263382ff0afSmrg      $echo "   $libdir"
6264382ff0afSmrg    done
6265382ff0afSmrg    $echo
6266382ff0afSmrg    $echo "If you ever happen to want to link against installed libraries"
6267382ff0afSmrg    $echo "in a given directory, LIBDIR, you must either use libtool, and"
6268382ff0afSmrg    $echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
6269382ff0afSmrg    $echo "flag during linking and do at least one of the following:"
6270382ff0afSmrg    if test -n "$shlibpath_var"; then
6271382ff0afSmrg      $echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
6272382ff0afSmrg      $echo "     during execution"
6273382ff0afSmrg    fi
6274382ff0afSmrg    if test -n "$runpath_var"; then
6275382ff0afSmrg      $echo "   - add LIBDIR to the \`$runpath_var' environment variable"
6276382ff0afSmrg      $echo "     during linking"
6277382ff0afSmrg    fi
6278382ff0afSmrg    if test -n "$hardcode_libdir_flag_spec"; then
6279382ff0afSmrg      libdir=LIBDIR
6280382ff0afSmrg      eval flag=\"$hardcode_libdir_flag_spec\"
6281382ff0afSmrg
6282382ff0afSmrg      $echo "   - use the \`$flag' linker flag"
6283382ff0afSmrg    fi
6284382ff0afSmrg    if test -n "$admincmds"; then
6285382ff0afSmrg      $echo "   - have your system administrator run these commands:$admincmds"
6286382ff0afSmrg    fi
6287382ff0afSmrg    if test -f /etc/ld.so.conf; then
6288382ff0afSmrg      $echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
6289382ff0afSmrg    fi
6290382ff0afSmrg    $echo
6291382ff0afSmrg    $echo "See any operating system documentation about shared libraries for"
6292382ff0afSmrg    $echo "more information, such as the ld(1) and ld.so(8) manual pages."
6293382ff0afSmrg    $echo "X----------------------------------------------------------------------" | $Xsed
6294382ff0afSmrg    exit $EXIT_SUCCESS
6295382ff0afSmrg    ;;
6296382ff0afSmrg
6297382ff0afSmrg  # libtool execute mode
6298382ff0afSmrg  execute)
6299382ff0afSmrg    modename="$modename: execute"
6300382ff0afSmrg
6301382ff0afSmrg    # The first argument is the command name.
6302382ff0afSmrg    cmd="$nonopt"
6303382ff0afSmrg    if test -z "$cmd"; then
6304382ff0afSmrg      $echo "$modename: you must specify a COMMAND" 1>&2
6305382ff0afSmrg      $echo "$help"
6306382ff0afSmrg      exit $EXIT_FAILURE
6307382ff0afSmrg    fi
6308382ff0afSmrg
6309382ff0afSmrg    # Handle -dlopen flags immediately.
6310382ff0afSmrg    for file in $execute_dlfiles; do
6311382ff0afSmrg      if test ! -f "$file"; then
6312382ff0afSmrg	$echo "$modename: \`$file' is not a file" 1>&2
6313382ff0afSmrg	$echo "$help" 1>&2
6314382ff0afSmrg	exit $EXIT_FAILURE
6315382ff0afSmrg      fi
6316382ff0afSmrg
6317382ff0afSmrg      dir=
6318382ff0afSmrg      case $file in
6319382ff0afSmrg      *.la)
6320382ff0afSmrg	# Check to see that this really is a libtool archive.
6321382ff0afSmrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
6322382ff0afSmrg	else
6323382ff0afSmrg	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
6324382ff0afSmrg	  $echo "$help" 1>&2
6325382ff0afSmrg	  exit $EXIT_FAILURE
6326382ff0afSmrg	fi
6327382ff0afSmrg
6328382ff0afSmrg	# Read the libtool library.
6329382ff0afSmrg	dlname=
6330382ff0afSmrg	library_names=
6331382ff0afSmrg
6332382ff0afSmrg	# If there is no directory component, then add one.
6333382ff0afSmrg	case $file in
6334382ff0afSmrg	*/* | *\\*) . $file ;;
6335382ff0afSmrg	*) . ./$file ;;
6336382ff0afSmrg	esac
6337382ff0afSmrg
6338382ff0afSmrg	# Skip this library if it cannot be dlopened.
6339382ff0afSmrg	if test -z "$dlname"; then
6340382ff0afSmrg	  # Warn if it was a shared library.
6341382ff0afSmrg	  test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
6342382ff0afSmrg	  continue
6343382ff0afSmrg	fi
6344382ff0afSmrg
6345382ff0afSmrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
6346382ff0afSmrg	test "X$dir" = "X$file" && dir=.
6347382ff0afSmrg
6348382ff0afSmrg	if test -f "$dir/$objdir/$dlname"; then
6349382ff0afSmrg	  dir="$dir/$objdir"
6350382ff0afSmrg	else
6351382ff0afSmrg	  $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
6352382ff0afSmrg	  exit $EXIT_FAILURE
6353382ff0afSmrg	fi
6354382ff0afSmrg	;;
6355382ff0afSmrg
6356382ff0afSmrg      *.lo)
6357382ff0afSmrg	# Just add the directory containing the .lo file.
6358382ff0afSmrg	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
6359382ff0afSmrg	test "X$dir" = "X$file" && dir=.
6360382ff0afSmrg	;;
6361382ff0afSmrg
6362382ff0afSmrg      *)
6363382ff0afSmrg	$echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
6364382ff0afSmrg	continue
6365382ff0afSmrg	;;
6366382ff0afSmrg      esac
6367382ff0afSmrg
6368382ff0afSmrg      # Get the absolute pathname.
6369382ff0afSmrg      absdir=`cd "$dir" && pwd`
6370382ff0afSmrg      test -n "$absdir" && dir="$absdir"
6371382ff0afSmrg
6372382ff0afSmrg      # Now add the directory to shlibpath_var.
6373382ff0afSmrg      if eval "test -z \"\$$shlibpath_var\""; then
6374382ff0afSmrg	eval "$shlibpath_var=\"\$dir\""
6375382ff0afSmrg      else
6376382ff0afSmrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
6377382ff0afSmrg      fi
6378382ff0afSmrg    done
6379382ff0afSmrg
6380382ff0afSmrg    # This variable tells wrapper scripts just to set shlibpath_var
6381382ff0afSmrg    # rather than running their programs.
6382382ff0afSmrg    libtool_execute_magic="$magic"
6383382ff0afSmrg
6384382ff0afSmrg    # Check if any of the arguments is a wrapper script.
6385382ff0afSmrg    args=
6386382ff0afSmrg    for file
6387382ff0afSmrg    do
6388382ff0afSmrg      case $file in
6389382ff0afSmrg      -*) ;;
6390382ff0afSmrg      *)
6391382ff0afSmrg	# Do a test to see if this is really a libtool program.
6392382ff0afSmrg	if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
6393382ff0afSmrg	  # If there is no directory component, then add one.
6394382ff0afSmrg	  case $file in
6395382ff0afSmrg	  */* | *\\*) . $file ;;
6396382ff0afSmrg	  *) . ./$file ;;
6397382ff0afSmrg	  esac
6398382ff0afSmrg
6399382ff0afSmrg	  # Transform arg to wrapped name.
6400382ff0afSmrg	  file="$progdir/$program"
6401382ff0afSmrg	fi
6402382ff0afSmrg	;;
6403382ff0afSmrg      esac
6404382ff0afSmrg      # Quote arguments (to preserve shell metacharacters).
6405382ff0afSmrg      file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
6406382ff0afSmrg      args="$args \"$file\""
6407382ff0afSmrg    done
6408382ff0afSmrg
6409382ff0afSmrg    if test -z "$run"; then
6410382ff0afSmrg      if test -n "$shlibpath_var"; then
6411382ff0afSmrg	# Export the shlibpath_var.
6412382ff0afSmrg	eval "export $shlibpath_var"
6413382ff0afSmrg      fi
6414382ff0afSmrg
6415382ff0afSmrg      # Restore saved environment variables
6416382ff0afSmrg      if test "${save_LC_ALL+set}" = set; then
6417382ff0afSmrg	LC_ALL="$save_LC_ALL"; export LC_ALL
6418382ff0afSmrg      fi
6419382ff0afSmrg      if test "${save_LANG+set}" = set; then
6420382ff0afSmrg	LANG="$save_LANG"; export LANG
6421382ff0afSmrg      fi
6422382ff0afSmrg
6423382ff0afSmrg      # Now prepare to actually exec the command.
6424382ff0afSmrg      exec_cmd="\$cmd$args"
6425382ff0afSmrg    else
6426382ff0afSmrg      # Display what would be done.
6427382ff0afSmrg      if test -n "$shlibpath_var"; then
6428382ff0afSmrg	eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
6429382ff0afSmrg	$echo "export $shlibpath_var"
6430382ff0afSmrg      fi
6431382ff0afSmrg      $echo "$cmd$args"
6432382ff0afSmrg      exit $EXIT_SUCCESS
6433382ff0afSmrg    fi
6434382ff0afSmrg    ;;
6435382ff0afSmrg
6436382ff0afSmrg  # libtool clean and uninstall mode
6437382ff0afSmrg  clean | uninstall)
6438382ff0afSmrg    modename="$modename: $mode"
6439382ff0afSmrg    rm="$nonopt"
6440382ff0afSmrg    files=
6441382ff0afSmrg    rmforce=
6442382ff0afSmrg    exit_status=0
6443382ff0afSmrg
6444382ff0afSmrg    # This variable tells wrapper scripts just to set variables rather
6445382ff0afSmrg    # than running their programs.
6446382ff0afSmrg    libtool_install_magic="$magic"
6447382ff0afSmrg
6448382ff0afSmrg    for arg
6449382ff0afSmrg    do
6450382ff0afSmrg      case $arg in
6451382ff0afSmrg      -f) rm="$rm $arg"; rmforce=yes ;;
6452382ff0afSmrg      -*) rm="$rm $arg" ;;
6453382ff0afSmrg      *) files="$files $arg" ;;
6454382ff0afSmrg      esac
6455382ff0afSmrg    done
6456382ff0afSmrg
6457382ff0afSmrg    if test -z "$rm"; then
6458382ff0afSmrg      $echo "$modename: you must specify an RM program" 1>&2
6459382ff0afSmrg      $echo "$help" 1>&2
6460382ff0afSmrg      exit $EXIT_FAILURE
6461382ff0afSmrg    fi
6462382ff0afSmrg
6463382ff0afSmrg    rmdirs=
6464382ff0afSmrg
6465382ff0afSmrg    origobjdir="$objdir"
6466382ff0afSmrg    for file in $files; do
6467382ff0afSmrg      dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
6468382ff0afSmrg      if test "X$dir" = "X$file"; then
6469382ff0afSmrg	dir=.
6470382ff0afSmrg	objdir="$origobjdir"
6471382ff0afSmrg      else
6472382ff0afSmrg	objdir="$dir/$origobjdir"
6473382ff0afSmrg      fi
6474382ff0afSmrg      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
6475382ff0afSmrg      test "$mode" = uninstall && objdir="$dir"
6476382ff0afSmrg
6477382ff0afSmrg      # Remember objdir for removal later, being careful to avoid duplicates
6478382ff0afSmrg      if test "$mode" = clean; then
6479382ff0afSmrg	case " $rmdirs " in
6480382ff0afSmrg	  *" $objdir "*) ;;
6481382ff0afSmrg	  *) rmdirs="$rmdirs $objdir" ;;
6482382ff0afSmrg	esac
6483382ff0afSmrg      fi
6484382ff0afSmrg
6485382ff0afSmrg      # Don't error if the file doesn't exist and rm -f was used.
6486382ff0afSmrg      if (test -L "$file") >/dev/null 2>&1 \
6487382ff0afSmrg	|| (test -h "$file") >/dev/null 2>&1 \
6488382ff0afSmrg	|| test -f "$file"; then
6489382ff0afSmrg	:
6490382ff0afSmrg      elif test -d "$file"; then
6491382ff0afSmrg	exit_status=1
6492382ff0afSmrg	continue
6493382ff0afSmrg      elif test "$rmforce" = yes; then
6494382ff0afSmrg	continue
6495382ff0afSmrg      fi
6496382ff0afSmrg
6497382ff0afSmrg      rmfiles="$file"
6498382ff0afSmrg
6499382ff0afSmrg      case $name in
6500382ff0afSmrg      *.la)
6501382ff0afSmrg	# Possibly a libtool archive, so verify it.
6502382ff0afSmrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
6503382ff0afSmrg	  . $dir/$name
6504382ff0afSmrg
6505382ff0afSmrg	  # Delete the libtool libraries and symlinks.
6506382ff0afSmrg	  for n in $library_names; do
6507382ff0afSmrg	    rmfiles="$rmfiles $objdir/$n"
6508382ff0afSmrg	  done
6509382ff0afSmrg	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
6510382ff0afSmrg
6511382ff0afSmrg	  case "$mode" in
6512382ff0afSmrg	  clean)
6513382ff0afSmrg	    case "  $library_names " in
6514382ff0afSmrg	    # "  " in the beginning catches empty $dlname
6515382ff0afSmrg	    *" $dlname "*) ;;
6516382ff0afSmrg	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
6517382ff0afSmrg	    esac
6518382ff0afSmrg	     test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
6519382ff0afSmrg	    ;;
6520382ff0afSmrg	  uninstall)
6521382ff0afSmrg	    if test -n "$library_names"; then
6522382ff0afSmrg	      # Do each command in the postuninstall commands.
6523382ff0afSmrg	      cmds=$postuninstall_cmds
6524382ff0afSmrg	      save_ifs="$IFS"; IFS='~'
6525382ff0afSmrg	      for cmd in $cmds; do
6526382ff0afSmrg		IFS="$save_ifs"
6527382ff0afSmrg		eval cmd=\"$cmd\"
6528382ff0afSmrg		$show "$cmd"
6529382ff0afSmrg		$run eval "$cmd"
6530382ff0afSmrg		if test "$?" -ne 0 && test "$rmforce" != yes; then
6531382ff0afSmrg		  exit_status=1
6532382ff0afSmrg		fi
6533382ff0afSmrg	      done
6534382ff0afSmrg	      IFS="$save_ifs"
6535382ff0afSmrg	    fi
6536382ff0afSmrg
6537382ff0afSmrg	    if test -n "$old_library"; then
6538382ff0afSmrg	      # Do each command in the old_postuninstall commands.
6539382ff0afSmrg	      cmds=$old_postuninstall_cmds
6540382ff0afSmrg	      save_ifs="$IFS"; IFS='~'
6541382ff0afSmrg	      for cmd in $cmds; do
6542382ff0afSmrg		IFS="$save_ifs"
6543382ff0afSmrg		eval cmd=\"$cmd\"
6544382ff0afSmrg		$show "$cmd"
6545382ff0afSmrg		$run eval "$cmd"
6546382ff0afSmrg		if test "$?" -ne 0 && test "$rmforce" != yes; then
6547382ff0afSmrg		  exit_status=1
6548382ff0afSmrg		fi
6549382ff0afSmrg	      done
6550382ff0afSmrg	      IFS="$save_ifs"
6551382ff0afSmrg	    fi
6552382ff0afSmrg	    # FIXME: should reinstall the best remaining shared library.
6553382ff0afSmrg	    ;;
6554382ff0afSmrg	  esac
6555382ff0afSmrg	fi
6556382ff0afSmrg	;;
6557382ff0afSmrg
6558382ff0afSmrg      *.lo)
6559382ff0afSmrg	# Possibly a libtool object, so verify it.
6560382ff0afSmrg	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
6561382ff0afSmrg
6562382ff0afSmrg	  # Read the .lo file
6563382ff0afSmrg	  . $dir/$name
6564382ff0afSmrg
6565382ff0afSmrg	  # Add PIC object to the list of files to remove.
6566382ff0afSmrg	  if test -n "$pic_object" \
6567382ff0afSmrg	     && test "$pic_object" != none; then
6568382ff0afSmrg	    rmfiles="$rmfiles $dir/$pic_object"
6569382ff0afSmrg	  fi
6570382ff0afSmrg
6571382ff0afSmrg	  # Add non-PIC object to the list of files to remove.
6572382ff0afSmrg	  if test -n "$non_pic_object" \
6573382ff0afSmrg	     && test "$non_pic_object" != none; then
6574382ff0afSmrg	    rmfiles="$rmfiles $dir/$non_pic_object"
6575382ff0afSmrg	  fi
6576382ff0afSmrg	fi
6577382ff0afSmrg	;;
6578382ff0afSmrg
6579382ff0afSmrg      *)
6580382ff0afSmrg	if test "$mode" = clean ; then
6581382ff0afSmrg	  noexename=$name
6582382ff0afSmrg	  case $file in
6583382ff0afSmrg	  *.exe)
6584382ff0afSmrg	    file=`$echo $file|${SED} 's,.exe$,,'`
6585382ff0afSmrg	    noexename=`$echo $name|${SED} 's,.exe$,,'`
6586382ff0afSmrg	    # $file with .exe has already been added to rmfiles,
6587382ff0afSmrg	    # add $file without .exe
6588382ff0afSmrg	    rmfiles="$rmfiles $file"
6589382ff0afSmrg	    ;;
6590382ff0afSmrg	  esac
6591382ff0afSmrg	  # Do a test to see if this is a libtool program.
6592382ff0afSmrg	  if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
6593382ff0afSmrg	    relink_command=
6594382ff0afSmrg	    . $dir/$noexename
6595382ff0afSmrg
6596382ff0afSmrg	    # note $name still contains .exe if it was in $file originally
6597382ff0afSmrg	    # as does the version of $file that was added into $rmfiles
6598382ff0afSmrg	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
6599382ff0afSmrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
6600382ff0afSmrg	      rmfiles="$rmfiles $objdir/lt-$name"
6601382ff0afSmrg	    fi
6602382ff0afSmrg	    if test "X$noexename" != "X$name" ; then
6603382ff0afSmrg	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
6604382ff0afSmrg	    fi
6605382ff0afSmrg	  fi
6606382ff0afSmrg	fi
6607382ff0afSmrg	;;
6608382ff0afSmrg      esac
6609382ff0afSmrg      $show "$rm $rmfiles"
6610382ff0afSmrg      $run $rm $rmfiles || exit_status=1
6611382ff0afSmrg    done
6612382ff0afSmrg    objdir="$origobjdir"
6613382ff0afSmrg
6614382ff0afSmrg    # Try to remove the ${objdir}s in the directories where we deleted files
6615382ff0afSmrg    for dir in $rmdirs; do
6616382ff0afSmrg      if test -d "$dir"; then
6617382ff0afSmrg	$show "rmdir $dir"
6618382ff0afSmrg	$run rmdir $dir >/dev/null 2>&1
6619382ff0afSmrg      fi
6620382ff0afSmrg    done
6621382ff0afSmrg
6622382ff0afSmrg    exit $exit_status
6623382ff0afSmrg    ;;
6624382ff0afSmrg
6625382ff0afSmrg  "")
6626382ff0afSmrg    $echo "$modename: you must specify a MODE" 1>&2
6627382ff0afSmrg    $echo "$generic_help" 1>&2
6628382ff0afSmrg    exit $EXIT_FAILURE
6629382ff0afSmrg    ;;
6630382ff0afSmrg  esac
6631382ff0afSmrg
6632382ff0afSmrg  if test -z "$exec_cmd"; then
6633382ff0afSmrg    $echo "$modename: invalid operation mode \`$mode'" 1>&2
6634382ff0afSmrg    $echo "$generic_help" 1>&2
6635382ff0afSmrg    exit $EXIT_FAILURE
6636382ff0afSmrg  fi
6637382ff0afSmrgfi # test -z "$show_help"
6638382ff0afSmrg
6639382ff0afSmrgif test -n "$exec_cmd"; then
6640382ff0afSmrg  eval exec $exec_cmd
6641382ff0afSmrg  exit $EXIT_FAILURE
6642382ff0afSmrgfi
6643382ff0afSmrg
6644382ff0afSmrg# We need to display help for each of the modes.
6645382ff0afSmrgcase $mode in
6646382ff0afSmrg"") $echo \
6647382ff0afSmrg"Usage: $modename [OPTION]... [MODE-ARG]...
6648382ff0afSmrg
6649382ff0afSmrgProvide generalized library-building support services.
6650382ff0afSmrg
6651382ff0afSmrg    --config          show all configuration variables
6652382ff0afSmrg    --debug           enable verbose shell tracing
6653382ff0afSmrg-n, --dry-run         display commands without modifying any files
6654382ff0afSmrg    --features        display basic configuration information and exit
6655382ff0afSmrg    --finish          same as \`--mode=finish'
6656382ff0afSmrg    --help            display this help message and exit
6657382ff0afSmrg    --mode=MODE       use operation mode MODE [default=inferred from MODE-ARGS]
6658382ff0afSmrg    --quiet           same as \`--silent'
6659382ff0afSmrg    --silent          don't print informational messages
6660382ff0afSmrg    --tag=TAG         use configuration variables from tag TAG
6661382ff0afSmrg    --version         print version information
6662382ff0afSmrg
6663382ff0afSmrgMODE must be one of the following:
6664382ff0afSmrg
6665382ff0afSmrg      clean           remove files from the build directory
6666382ff0afSmrg      compile         compile a source file into a libtool object
6667382ff0afSmrg      execute         automatically set library path, then run a program
6668382ff0afSmrg      finish          complete the installation of libtool libraries
6669382ff0afSmrg      install         install libraries or executables
6670382ff0afSmrg      link            create a library or an executable
6671382ff0afSmrg      uninstall       remove libraries from an installed directory
6672382ff0afSmrg
6673382ff0afSmrgMODE-ARGS vary depending on the MODE.  Try \`$modename --help --mode=MODE' for
6674382ff0afSmrga more detailed description of MODE.
6675382ff0afSmrg
6676382ff0afSmrgReport bugs to <bug-libtool@gnu.org>."
6677382ff0afSmrg  exit $EXIT_SUCCESS
6678382ff0afSmrg  ;;
6679382ff0afSmrg
6680382ff0afSmrgclean)
6681382ff0afSmrg  $echo \
6682382ff0afSmrg"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
6683382ff0afSmrg
6684382ff0afSmrgRemove files from the build directory.
6685382ff0afSmrg
6686382ff0afSmrgRM is the name of the program to use to delete files associated with each FILE
6687382ff0afSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
6688382ff0afSmrgto RM.
6689382ff0afSmrg
6690382ff0afSmrgIf FILE is a libtool library, object or program, all the files associated
6691382ff0afSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
6692382ff0afSmrg  ;;
6693382ff0afSmrg
6694382ff0afSmrgcompile)
6695382ff0afSmrg  $echo \
6696382ff0afSmrg"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
6697382ff0afSmrg
6698382ff0afSmrgCompile a source file into a libtool library object.
6699382ff0afSmrg
6700382ff0afSmrgThis mode accepts the following additional options:
6701382ff0afSmrg
6702382ff0afSmrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
6703382ff0afSmrg  -prefer-pic       try to building PIC objects only
6704382ff0afSmrg  -prefer-non-pic   try to building non-PIC objects only
6705382ff0afSmrg  -static           always build a \`.o' file suitable for static linking
6706382ff0afSmrg
6707382ff0afSmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
6708382ff0afSmrgfrom the given SOURCEFILE.
6709382ff0afSmrg
6710382ff0afSmrgThe output file name is determined by removing the directory component from
6711382ff0afSmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
6712382ff0afSmrglibrary object suffix, \`.lo'."
6713382ff0afSmrg  ;;
6714382ff0afSmrg
6715382ff0afSmrgexecute)
6716382ff0afSmrg  $echo \
6717382ff0afSmrg"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
6718382ff0afSmrg
6719382ff0afSmrgAutomatically set library path, then run a program.
6720382ff0afSmrg
6721382ff0afSmrgThis mode accepts the following additional options:
6722382ff0afSmrg
6723382ff0afSmrg  -dlopen FILE      add the directory containing FILE to the library path
6724382ff0afSmrg
6725382ff0afSmrgThis mode sets the library path environment variable according to \`-dlopen'
6726382ff0afSmrgflags.
6727382ff0afSmrg
6728382ff0afSmrgIf any of the ARGS are libtool executable wrappers, then they are translated
6729382ff0afSmrginto their corresponding uninstalled binary, and any of their required library
6730382ff0afSmrgdirectories are added to the library path.
6731382ff0afSmrg
6732382ff0afSmrgThen, COMMAND is executed, with ARGS as arguments."
6733382ff0afSmrg  ;;
6734382ff0afSmrg
6735382ff0afSmrgfinish)
6736382ff0afSmrg  $echo \
6737382ff0afSmrg"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
6738382ff0afSmrg
6739382ff0afSmrgComplete the installation of libtool libraries.
6740382ff0afSmrg
6741382ff0afSmrgEach LIBDIR is a directory that contains libtool libraries.
6742382ff0afSmrg
6743382ff0afSmrgThe commands that this mode executes may require superuser privileges.  Use
6744382ff0afSmrgthe \`--dry-run' option if you just want to see what would be executed."
6745382ff0afSmrg  ;;
6746382ff0afSmrg
6747382ff0afSmrginstall)
6748382ff0afSmrg  $echo \
6749382ff0afSmrg"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
6750382ff0afSmrg
6751382ff0afSmrgInstall executables or libraries.
6752382ff0afSmrg
6753382ff0afSmrgINSTALL-COMMAND is the installation command.  The first component should be
6754382ff0afSmrgeither the \`install' or \`cp' program.
6755382ff0afSmrg
6756382ff0afSmrgThe rest of the components are interpreted as arguments to that command (only
6757382ff0afSmrgBSD-compatible install options are recognized)."
6758382ff0afSmrg  ;;
6759382ff0afSmrg
6760382ff0afSmrglink)
6761382ff0afSmrg  $echo \
6762382ff0afSmrg"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
6763382ff0afSmrg
6764382ff0afSmrgLink object files or libraries together to form another library, or to
6765382ff0afSmrgcreate an executable program.
6766382ff0afSmrg
6767382ff0afSmrgLINK-COMMAND is a command using the C compiler that you would use to create
6768382ff0afSmrga program from several object files.
6769382ff0afSmrg
6770382ff0afSmrgThe following components of LINK-COMMAND are treated specially:
6771382ff0afSmrg
6772382ff0afSmrg  -all-static       do not do any dynamic linking at all
6773382ff0afSmrg  -avoid-version    do not add a version suffix if possible
6774382ff0afSmrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
6775382ff0afSmrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
6776382ff0afSmrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
6777382ff0afSmrg  -export-symbols SYMFILE
6778382ff0afSmrg		    try to export only the symbols listed in SYMFILE
6779382ff0afSmrg  -export-symbols-regex REGEX
6780382ff0afSmrg		    try to export only the symbols matching REGEX
6781382ff0afSmrg  -LLIBDIR          search LIBDIR for required installed libraries
6782382ff0afSmrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
6783382ff0afSmrg  -module           build a library that can dlopened
6784382ff0afSmrg  -no-fast-install  disable the fast-install mode
6785382ff0afSmrg  -no-install       link a not-installable executable
6786382ff0afSmrg  -no-undefined     declare that a library does not refer to external symbols
6787382ff0afSmrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
6788382ff0afSmrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
6789382ff0afSmrg  -precious-files-regex REGEX
6790382ff0afSmrg                    don't remove output files matching REGEX
6791382ff0afSmrg  -release RELEASE  specify package release information
6792382ff0afSmrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
6793382ff0afSmrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
6794382ff0afSmrg  -static           do not do any dynamic linking of libtool libraries
6795382ff0afSmrg  -version-info CURRENT[:REVISION[:AGE]]
6796382ff0afSmrg		    specify library version info [each variable defaults to 0]
6797382ff0afSmrg
6798382ff0afSmrgAll other options (arguments beginning with \`-') are ignored.
6799382ff0afSmrg
6800382ff0afSmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
6801382ff0afSmrgtreated as uninstalled libtool libraries, other files are standard or library
6802382ff0afSmrgobject files.
6803382ff0afSmrg
6804382ff0afSmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
6805382ff0afSmrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
6806382ff0afSmrgrequired, except when creating a convenience library.
6807382ff0afSmrg
6808382ff0afSmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
6809382ff0afSmrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
6810382ff0afSmrg
6811382ff0afSmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
6812382ff0afSmrgis created, otherwise an executable program is created."
6813382ff0afSmrg  ;;
6814382ff0afSmrg
6815382ff0afSmrguninstall)
6816382ff0afSmrg  $echo \
6817382ff0afSmrg"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
6818382ff0afSmrg
6819382ff0afSmrgRemove libraries from an installation directory.
6820382ff0afSmrg
6821382ff0afSmrgRM is the name of the program to use to delete files associated with each FILE
6822382ff0afSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
6823382ff0afSmrgto RM.
6824382ff0afSmrg
6825382ff0afSmrgIf FILE is a libtool library, all the files associated with it are deleted.
6826382ff0afSmrgOtherwise, only FILE itself is deleted using RM."
6827382ff0afSmrg  ;;
6828382ff0afSmrg
6829382ff0afSmrg*)
6830382ff0afSmrg  $echo "$modename: invalid operation mode \`$mode'" 1>&2
6831382ff0afSmrg  $echo "$help" 1>&2
6832382ff0afSmrg  exit $EXIT_FAILURE
6833382ff0afSmrg  ;;
6834382ff0afSmrgesac
6835382ff0afSmrg
6836382ff0afSmrg$echo
6837382ff0afSmrg$echo "Try \`$modename --help' for more information about other modes."
6838382ff0afSmrg
6839382ff0afSmrgexit $?
6840382ff0afSmrg
6841382ff0afSmrg# The TAGs below are defined such that we never get into a situation
6842382ff0afSmrg# in which we disable both kinds of libraries.  Given conflicting
6843382ff0afSmrg# choices, we go for a static library, that is the most portable,
6844382ff0afSmrg# since we can't tell whether shared libraries were disabled because
6845382ff0afSmrg# the user asked for that or because the platform doesn't support
6846382ff0afSmrg# them.  This is particularly important on AIX, because we don't
6847382ff0afSmrg# support having both static and shared libraries enabled at the same
6848382ff0afSmrg# time on that platform, so we default to a shared-only configuration.
6849382ff0afSmrg# If a disable-shared tag is given, we'll fallback to a static-only
6850382ff0afSmrg# configuration.  But we'll never go from static-only to shared-only.
6851382ff0afSmrg
6852382ff0afSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
6853382ff0afSmrgdisable_libs=shared
6854382ff0afSmrg# ### END LIBTOOL TAG CONFIG: disable-shared
6855382ff0afSmrg
6856382ff0afSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
6857382ff0afSmrgdisable_libs=static
6858382ff0afSmrg# ### END LIBTOOL TAG CONFIG: disable-static
6859382ff0afSmrg
6860382ff0afSmrg# Local Variables:
6861382ff0afSmrg# mode:shell-script
6862382ff0afSmrg# sh-indentation:2
6863382ff0afSmrg# End:
6864