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