xref: /freebsd/contrib/file/ltmain.sh (revision fe267a559009cbf34f9341666fe4d88a92c02d5e)
1
2# libtool (GNU libtool) 2.4.2
3# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
4
5# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
6# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
7# This is free software; see the source for copying conditions.  There is NO
8# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9
10# GNU Libtool is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation; either version 2 of the License, or
13# (at your option) any later version.
14#
15# As a special exception to the GNU General Public License,
16# if you distribute this file as part of a program or library that
17# is built using GNU Libtool, you may include this file under the
18# same distribution terms that you use for the rest of that program.
19#
20# GNU Libtool is distributed in the hope that it will be useful, but
21# WITHOUT ANY WARRANTY; without even the implied warranty of
22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23# General Public License for more details.
24#
25# You should have received a copy of the GNU General Public License
26# along with GNU Libtool; see the file COPYING.  If not, a copy
27# can be downloaded from http://www.gnu.org/licenses/gpl.html,
28# or obtained by writing to the Free Software Foundation, Inc.,
29# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30
31# Usage: $progname [OPTION]... [MODE-ARG]...
32#
33# Provide generalized library-building support services.
34#
35#       --config             show all configuration variables
36#       --debug              enable verbose shell tracing
37#   -n, --dry-run            display commands without modifying any files
38#       --features           display basic configuration information and exit
39#       --mode=MODE          use operation mode MODE
40#       --preserve-dup-deps  don't remove duplicate dependency libraries
41#       --quiet, --silent    don't print informational messages
42#       --no-quiet, --no-silent
43#                            print informational messages (default)
44#       --no-warn            don't display warning messages
45#       --tag=TAG            use configuration variables from tag TAG
46#   -v, --verbose            print more informational messages than default
47#       --no-verbose         don't print the extra informational messages
48#       --version            print version information
49#   -h, --help, --help-all   print short, long, or detailed help message
50#
51# MODE must be one of the following:
52#
53#         clean              remove files from the build directory
54#         compile            compile a source file into a libtool object
55#         execute            automatically set library path, then run a program
56#         finish             complete the installation of libtool libraries
57#         install            install libraries or executables
58#         link               create a library or an executable
59#         uninstall          remove libraries from an installed directory
60#
61# MODE-ARGS vary depending on the MODE.  When passed as first option,
62# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
63# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
64#
65# When reporting a bug, please describe a test case to reproduce it and
66# include the following information:
67#
68#         host-triplet:	$host
69#         shell:		$SHELL
70#         compiler:		$LTCC
71#         compiler flags:		$LTCFLAGS
72#         linker:		$LD (gnu? $with_gnu_ld)
73#         $progname:	(GNU libtool) 2.4.2
74#         automake:	$automake_version
75#         autoconf:	$autoconf_version
76#
77# Report bugs to <bug-libtool@gnu.org>.
78# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
79# General help using GNU software: <http://www.gnu.org/gethelp/>.
80
81PROGRAM=libtool
82PACKAGE=libtool
83VERSION=2.4.2
84TIMESTAMP=""
85package_revision=1.3337
86
87# Be Bourne compatible
88if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
89  emulate sh
90  NULLCMD=:
91  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
92  # is contrary to our usage.  Disable this feature.
93  alias -g '${1+"$@"}'='"$@"'
94  setopt NO_GLOB_SUBST
95else
96  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
97fi
98BIN_SH=xpg4; export BIN_SH # for Tru64
99DUALCASE=1; export DUALCASE # for MKS sh
100
101# A function that is used when there is no print builtin or printf.
102func_fallback_echo ()
103{
104  eval 'cat <<_LTECHO_EOF
105$1
106_LTECHO_EOF'
107}
108
109# NLS nuisances: We save the old values to restore during execute mode.
110lt_user_locale=
111lt_safe_locale=
112for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
113do
114  eval "if test \"\${$lt_var+set}\" = set; then
115          save_$lt_var=\$$lt_var
116          $lt_var=C
117	  export $lt_var
118	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
119	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
120	fi"
121done
122LC_ALL=C
123LANGUAGE=C
124export LANGUAGE LC_ALL
125
126$lt_unset CDPATH
127
128
129# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
130# is ksh but when the shell is invoked as "sh" and the current value of
131# the _XPG environment variable is not equal to 1 (one), the special
132# positional parameter $0, within a function call, is the name of the
133# function.
134progpath="$0"
135
136unset CP
137unset MV
138unset RM
139: ${CP="cp -f"}
140test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
141: ${MAKE="make"}
142: ${MKDIR="mkdir"}
143: ${MV="mv -f"}
144: ${RM="rm -f"}
145: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
146: ${Xsed="$SED -e 1s/^X//"}
147
148# Global variables:
149EXIT_SUCCESS=0
150EXIT_FAILURE=1
151EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
152EXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
153
154exit_status=$EXIT_SUCCESS
155
156# Make sure IFS has a sensible default
157lt_nl='
158'
159IFS=" 	$lt_nl"
160
161dirname="s,/[^/]*$,,"
162basename="s,^.*/,,"
163
164# func_dirname file append nondir_replacement
165# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
166# otherwise set result to NONDIR_REPLACEMENT.
167func_dirname ()
168{
169    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
170    if test "X$func_dirname_result" = "X${1}"; then
171      func_dirname_result="${3}"
172    else
173      func_dirname_result="$func_dirname_result${2}"
174    fi
175} # func_dirname may be replaced by extended shell implementation
176
177
178# func_basename file
179func_basename ()
180{
181    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
182} # func_basename may be replaced by extended shell implementation
183
184
185# func_dirname_and_basename file append nondir_replacement
186# perform func_basename and func_dirname in a single function
187# call:
188#   dirname:  Compute the dirname of FILE.  If nonempty,
189#             add APPEND to the result, otherwise set result
190#             to NONDIR_REPLACEMENT.
191#             value returned in "$func_dirname_result"
192#   basename: Compute filename of FILE.
193#             value retuned in "$func_basename_result"
194# Implementation must be kept synchronized with func_dirname
195# and func_basename. For efficiency, we do not delegate to
196# those functions but instead duplicate the functionality here.
197func_dirname_and_basename ()
198{
199    # Extract subdirectory from the argument.
200    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
201    if test "X$func_dirname_result" = "X${1}"; then
202      func_dirname_result="${3}"
203    else
204      func_dirname_result="$func_dirname_result${2}"
205    fi
206    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
207} # func_dirname_and_basename may be replaced by extended shell implementation
208
209
210# func_stripname prefix suffix name
211# strip PREFIX and SUFFIX off of NAME.
212# PREFIX and SUFFIX must not contain globbing or regex special
213# characters, hashes, percent signs, but SUFFIX may contain a leading
214# dot (in which case that matches only a dot).
215# func_strip_suffix prefix name
216func_stripname ()
217{
218    case ${2} in
219      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
220      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
221    esac
222} # func_stripname may be replaced by extended shell implementation
223
224
225# These SED scripts presuppose an absolute path with a trailing slash.
226pathcar='s,^/\([^/]*\).*$,\1,'
227pathcdr='s,^/[^/]*,,'
228removedotparts=':dotsl
229		s@/\./@/@g
230		t dotsl
231		s,/\.$,/,'
232collapseslashes='s@/\{1,\}@/@g'
233finalslash='s,/*$,/,'
234
235# func_normal_abspath PATH
236# Remove doubled-up and trailing slashes, "." path components,
237# and cancel out any ".." path components in PATH after making
238# it an absolute path.
239#             value returned in "$func_normal_abspath_result"
240func_normal_abspath ()
241{
242  # Start from root dir and reassemble the path.
243  func_normal_abspath_result=
244  func_normal_abspath_tpath=$1
245  func_normal_abspath_altnamespace=
246  case $func_normal_abspath_tpath in
247    "")
248      # Empty path, that just means $cwd.
249      func_stripname '' '/' "`pwd`"
250      func_normal_abspath_result=$func_stripname_result
251      return
252    ;;
253    # The next three entries are used to spot a run of precisely
254    # two leading slashes without using negated character classes;
255    # we take advantage of case's first-match behaviour.
256    ///*)
257      # Unusual form of absolute path, do nothing.
258    ;;
259    //*)
260      # Not necessarily an ordinary path; POSIX reserves leading '//'
261      # and for example Cygwin uses it to access remote file shares
262      # over CIFS/SMB, so we conserve a leading double slash if found.
263      func_normal_abspath_altnamespace=/
264    ;;
265    /*)
266      # Absolute path, do nothing.
267    ;;
268    *)
269      # Relative path, prepend $cwd.
270      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
271    ;;
272  esac
273  # Cancel out all the simple stuff to save iterations.  We also want
274  # the path to end with a slash for ease of parsing, so make sure
275  # there is one (and only one) here.
276  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
277        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
278  while :; do
279    # Processed it all yet?
280    if test "$func_normal_abspath_tpath" = / ; then
281      # If we ascended to the root using ".." the result may be empty now.
282      if test -z "$func_normal_abspath_result" ; then
283        func_normal_abspath_result=/
284      fi
285      break
286    fi
287    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
288        -e "$pathcar"`
289    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
290        -e "$pathcdr"`
291    # Figure out what to do with it
292    case $func_normal_abspath_tcomponent in
293      "")
294        # Trailing empty path component, ignore it.
295      ;;
296      ..)
297        # Parent dir; strip last assembled component from result.
298        func_dirname "$func_normal_abspath_result"
299        func_normal_abspath_result=$func_dirname_result
300      ;;
301      *)
302        # Actual path component, append it.
303        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
304      ;;
305    esac
306  done
307  # Restore leading double-slash if one was found on entry.
308  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
309}
310
311# func_relative_path SRCDIR DSTDIR
312# generates a relative path from SRCDIR to DSTDIR, with a trailing
313# slash if non-empty, suitable for immediately appending a filename
314# without needing to append a separator.
315#             value returned in "$func_relative_path_result"
316func_relative_path ()
317{
318  func_relative_path_result=
319  func_normal_abspath "$1"
320  func_relative_path_tlibdir=$func_normal_abspath_result
321  func_normal_abspath "$2"
322  func_relative_path_tbindir=$func_normal_abspath_result
323
324  # Ascend the tree starting from libdir
325  while :; do
326    # check if we have found a prefix of bindir
327    case $func_relative_path_tbindir in
328      $func_relative_path_tlibdir)
329        # found an exact match
330        func_relative_path_tcancelled=
331        break
332        ;;
333      $func_relative_path_tlibdir*)
334        # found a matching prefix
335        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
336        func_relative_path_tcancelled=$func_stripname_result
337        if test -z "$func_relative_path_result"; then
338          func_relative_path_result=.
339        fi
340        break
341        ;;
342      *)
343        func_dirname $func_relative_path_tlibdir
344        func_relative_path_tlibdir=${func_dirname_result}
345        if test "x$func_relative_path_tlibdir" = x ; then
346          # Have to descend all the way to the root!
347          func_relative_path_result=../$func_relative_path_result
348          func_relative_path_tcancelled=$func_relative_path_tbindir
349          break
350        fi
351        func_relative_path_result=../$func_relative_path_result
352        ;;
353    esac
354  done
355
356  # Now calculate path; take care to avoid doubling-up slashes.
357  func_stripname '' '/' "$func_relative_path_result"
358  func_relative_path_result=$func_stripname_result
359  func_stripname '/' '/' "$func_relative_path_tcancelled"
360  if test "x$func_stripname_result" != x ; then
361    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
362  fi
363
364  # Normalisation. If bindir is libdir, return empty string,
365  # else relative path ending with a slash; either way, target
366  # file name can be directly appended.
367  if test ! -z "$func_relative_path_result"; then
368    func_stripname './' '' "$func_relative_path_result/"
369    func_relative_path_result=$func_stripname_result
370  fi
371}
372
373# The name of this program:
374func_dirname_and_basename "$progpath"
375progname=$func_basename_result
376
377# Make sure we have an absolute path for reexecution:
378case $progpath in
379  [\\/]*|[A-Za-z]:\\*) ;;
380  *[\\/]*)
381     progdir=$func_dirname_result
382     progdir=`cd "$progdir" && pwd`
383     progpath="$progdir/$progname"
384     ;;
385  *)
386     save_IFS="$IFS"
387     IFS=${PATH_SEPARATOR-:}
388     for progdir in $PATH; do
389       IFS="$save_IFS"
390       test -x "$progdir/$progname" && break
391     done
392     IFS="$save_IFS"
393     test -n "$progdir" || progdir=`pwd`
394     progpath="$progdir/$progname"
395     ;;
396esac
397
398# Sed substitution that helps us do robust quoting.  It backslashifies
399# metacharacters that are still active within double-quoted strings.
400Xsed="${SED}"' -e 1s/^X//'
401sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
402
403# Same as above, but do not quote variable references.
404double_quote_subst='s/\(["`\\]\)/\\\1/g'
405
406# Sed substitution that turns a string into a regex matching for the
407# string literally.
408sed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
409
410# Sed substitution that converts a w32 file name or path
411# which contains forward slashes, into one that contains
412# (escaped) backslashes.  A very naive implementation.
413lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
414
415# Re-`\' parameter expansions in output of double_quote_subst that were
416# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
417# in input to double_quote_subst, that '$' was protected from expansion.
418# Since each input `\' is now two `\'s, look for any number of runs of
419# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
420bs='\\'
421bs2='\\\\'
422bs4='\\\\\\\\'
423dollar='\$'
424sed_double_backslash="\
425  s/$bs4/&\\
426/g
427  s/^$bs2$dollar/$bs&/
428  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
429  s/\n//g"
430
431# Standard options:
432opt_dry_run=false
433opt_help=false
434opt_quiet=false
435opt_verbose=false
436opt_warning=:
437
438# func_echo arg...
439# Echo program name prefixed message, along with the current mode
440# name if it has been set yet.
441func_echo ()
442{
443    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
444}
445
446# func_verbose arg...
447# Echo program name prefixed message in verbose mode only.
448func_verbose ()
449{
450    $opt_verbose && func_echo ${1+"$@"}
451
452    # A bug in bash halts the script if the last line of a function
453    # fails when set -e is in force, so we need another command to
454    # work around that:
455    :
456}
457
458# func_echo_all arg...
459# Invoke $ECHO with all args, space-separated.
460func_echo_all ()
461{
462    $ECHO "$*"
463}
464
465# func_error arg...
466# Echo program name prefixed message to standard error.
467func_error ()
468{
469    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
470}
471
472# func_warning arg...
473# Echo program name prefixed warning message to standard error.
474func_warning ()
475{
476    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
477
478    # bash bug again:
479    :
480}
481
482# func_fatal_error arg...
483# Echo program name prefixed message to standard error, and exit.
484func_fatal_error ()
485{
486    func_error ${1+"$@"}
487    exit $EXIT_FAILURE
488}
489
490# func_fatal_help arg...
491# Echo program name prefixed message to standard error, followed by
492# a help hint, and exit.
493func_fatal_help ()
494{
495    func_error ${1+"$@"}
496    func_fatal_error "$help"
497}
498help="Try \`$progname --help' for more information."  ## default
499
500
501# func_grep expression filename
502# Check whether EXPRESSION matches any line of FILENAME, without output.
503func_grep ()
504{
505    $GREP "$1" "$2" >/dev/null 2>&1
506}
507
508
509# func_mkdir_p directory-path
510# Make sure the entire path to DIRECTORY-PATH is available.
511func_mkdir_p ()
512{
513    my_directory_path="$1"
514    my_dir_list=
515
516    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
517
518      # Protect directory names starting with `-'
519      case $my_directory_path in
520        -*) my_directory_path="./$my_directory_path" ;;
521      esac
522
523      # While some portion of DIR does not yet exist...
524      while test ! -d "$my_directory_path"; do
525        # ...make a list in topmost first order.  Use a colon delimited
526	# list incase some portion of path contains whitespace.
527        my_dir_list="$my_directory_path:$my_dir_list"
528
529        # If the last portion added has no slash in it, the list is done
530        case $my_directory_path in */*) ;; *) break ;; esac
531
532        # ...otherwise throw away the child directory and loop
533        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
534      done
535      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
536
537      save_mkdir_p_IFS="$IFS"; IFS=':'
538      for my_dir in $my_dir_list; do
539	IFS="$save_mkdir_p_IFS"
540        # mkdir can fail with a `File exist' error if two processes
541        # try to create one of the directories concurrently.  Don't
542        # stop in that case!
543        $MKDIR "$my_dir" 2>/dev/null || :
544      done
545      IFS="$save_mkdir_p_IFS"
546
547      # Bail out if we (or some other process) failed to create a directory.
548      test -d "$my_directory_path" || \
549        func_fatal_error "Failed to create \`$1'"
550    fi
551}
552
553
554# func_mktempdir [string]
555# Make a temporary directory that won't clash with other running
556# libtool processes, and avoids race conditions if possible.  If
557# given, STRING is the basename for that directory.
558func_mktempdir ()
559{
560    my_template="${TMPDIR-/tmp}/${1-$progname}"
561
562    if test "$opt_dry_run" = ":"; then
563      # Return a directory name, but don't create it in dry-run mode
564      my_tmpdir="${my_template}-$$"
565    else
566
567      # If mktemp works, use that first and foremost
568      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
569
570      if test ! -d "$my_tmpdir"; then
571        # Failing that, at least try and use $RANDOM to avoid a race
572        my_tmpdir="${my_template}-${RANDOM-0}$$"
573
574        save_mktempdir_umask=`umask`
575        umask 0077
576        $MKDIR "$my_tmpdir"
577        umask $save_mktempdir_umask
578      fi
579
580      # If we're not in dry-run mode, bomb out on failure
581      test -d "$my_tmpdir" || \
582        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
583    fi
584
585    $ECHO "$my_tmpdir"
586}
587
588
589# func_quote_for_eval arg
590# Aesthetically quote ARG to be evaled later.
591# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
592# is double-quoted, suitable for a subsequent eval, whereas
593# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
594# which are still active within double quotes backslashified.
595func_quote_for_eval ()
596{
597    case $1 in
598      *[\\\`\"\$]*)
599	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
600      *)
601        func_quote_for_eval_unquoted_result="$1" ;;
602    esac
603
604    case $func_quote_for_eval_unquoted_result in
605      # Double-quote args containing shell metacharacters to delay
606      # word splitting, command substitution and and variable
607      # expansion for a subsequent eval.
608      # Many Bourne shells cannot handle close brackets correctly
609      # in scan sets, so we specify it separately.
610      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
611        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
612        ;;
613      *)
614        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
615    esac
616}
617
618
619# func_quote_for_expand arg
620# Aesthetically quote ARG to be evaled later; same as above,
621# but do not quote variable references.
622func_quote_for_expand ()
623{
624    case $1 in
625      *[\\\`\"]*)
626	my_arg=`$ECHO "$1" | $SED \
627	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
628      *)
629        my_arg="$1" ;;
630    esac
631
632    case $my_arg in
633      # Double-quote args containing shell metacharacters to delay
634      # word splitting and command substitution for a subsequent eval.
635      # Many Bourne shells cannot handle close brackets correctly
636      # in scan sets, so we specify it separately.
637      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
638        my_arg="\"$my_arg\""
639        ;;
640    esac
641
642    func_quote_for_expand_result="$my_arg"
643}
644
645
646# func_show_eval cmd [fail_exp]
647# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
648# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
649# is given, then evaluate it.
650func_show_eval ()
651{
652    my_cmd="$1"
653    my_fail_exp="${2-:}"
654
655    ${opt_silent-false} || {
656      func_quote_for_expand "$my_cmd"
657      eval "func_echo $func_quote_for_expand_result"
658    }
659
660    if ${opt_dry_run-false}; then :; else
661      eval "$my_cmd"
662      my_status=$?
663      if test "$my_status" -eq 0; then :; else
664	eval "(exit $my_status); $my_fail_exp"
665      fi
666    fi
667}
668
669
670# func_show_eval_locale cmd [fail_exp]
671# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
672# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
673# is given, then evaluate it.  Use the saved locale for evaluation.
674func_show_eval_locale ()
675{
676    my_cmd="$1"
677    my_fail_exp="${2-:}"
678
679    ${opt_silent-false} || {
680      func_quote_for_expand "$my_cmd"
681      eval "func_echo $func_quote_for_expand_result"
682    }
683
684    if ${opt_dry_run-false}; then :; else
685      eval "$lt_user_locale
686	    $my_cmd"
687      my_status=$?
688      eval "$lt_safe_locale"
689      if test "$my_status" -eq 0; then :; else
690	eval "(exit $my_status); $my_fail_exp"
691      fi
692    fi
693}
694
695# func_tr_sh
696# Turn $1 into a string suitable for a shell variable name.
697# Result is stored in $func_tr_sh_result.  All characters
698# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
699# if $1 begins with a digit, a '_' is prepended as well.
700func_tr_sh ()
701{
702  case $1 in
703  [0-9]* | *[!a-zA-Z0-9_]*)
704    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
705    ;;
706  * )
707    func_tr_sh_result=$1
708    ;;
709  esac
710}
711
712
713# func_version
714# Echo version message to standard output and exit.
715func_version ()
716{
717    $opt_debug
718
719    $SED -n '/(C)/!b go
720	:more
721	/\./!{
722	  N
723	  s/\n# / /
724	  b more
725	}
726	:go
727	/^# '$PROGRAM' (GNU /,/# warranty; / {
728        s/^# //
729	s/^# *$//
730        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
731        p
732     }' < "$progpath"
733     exit $?
734}
735
736# func_usage
737# Echo short help message to standard output and exit.
738func_usage ()
739{
740    $opt_debug
741
742    $SED -n '/^# Usage:/,/^#  *.*--help/ {
743        s/^# //
744	s/^# *$//
745	s/\$progname/'$progname'/
746	p
747    }' < "$progpath"
748    echo
749    $ECHO "run \`$progname --help | more' for full usage"
750    exit $?
751}
752
753# func_help [NOEXIT]
754# Echo long help message to standard output and exit,
755# unless 'noexit' is passed as argument.
756func_help ()
757{
758    $opt_debug
759
760    $SED -n '/^# Usage:/,/# Report bugs to/ {
761	:print
762        s/^# //
763	s/^# *$//
764	s*\$progname*'$progname'*
765	s*\$host*'"$host"'*
766	s*\$SHELL*'"$SHELL"'*
767	s*\$LTCC*'"$LTCC"'*
768	s*\$LTCFLAGS*'"$LTCFLAGS"'*
769	s*\$LD*'"$LD"'*
770	s/\$with_gnu_ld/'"$with_gnu_ld"'/
771	s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
772	s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
773	p
774	d
775     }
776     /^# .* home page:/b print
777     /^# General help using/b print
778     ' < "$progpath"
779    ret=$?
780    if test -z "$1"; then
781      exit $ret
782    fi
783}
784
785# func_missing_arg argname
786# Echo program name prefixed message to standard error and set global
787# exit_cmd.
788func_missing_arg ()
789{
790    $opt_debug
791
792    func_error "missing argument for $1."
793    exit_cmd=exit
794}
795
796
797# func_split_short_opt shortopt
798# Set func_split_short_opt_name and func_split_short_opt_arg shell
799# variables after splitting SHORTOPT after the 2nd character.
800func_split_short_opt ()
801{
802    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
803    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
804
805    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
806    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
807} # func_split_short_opt may be replaced by extended shell implementation
808
809
810# func_split_long_opt longopt
811# Set func_split_long_opt_name and func_split_long_opt_arg shell
812# variables after splitting LONGOPT at the `=' sign.
813func_split_long_opt ()
814{
815    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
816    my_sed_long_arg='1s/^--[^=]*=//'
817
818    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
819    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
820} # func_split_long_opt may be replaced by extended shell implementation
821
822exit_cmd=:
823
824
825
826
827
828magic="%%%MAGIC variable%%%"
829magic_exe="%%%MAGIC EXE variable%%%"
830
831# Global variables.
832nonopt=
833preserve_args=
834lo2o="s/\\.lo\$/.${objext}/"
835o2lo="s/\\.${objext}\$/.lo/"
836extracted_archives=
837extracted_serial=0
838
839# If this variable is set in any of the actions, the command in it
840# will be execed at the end.  This prevents here-documents from being
841# left over by shells.
842exec_cmd=
843
844# func_append var value
845# Append VALUE to the end of shell variable VAR.
846func_append ()
847{
848    eval "${1}=\$${1}\${2}"
849} # func_append may be replaced by extended shell implementation
850
851# func_append_quoted var value
852# Quote VALUE and append to the end of shell variable VAR, separated
853# by a space.
854func_append_quoted ()
855{
856    func_quote_for_eval "${2}"
857    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
858} # func_append_quoted may be replaced by extended shell implementation
859
860
861# func_arith arithmetic-term...
862func_arith ()
863{
864    func_arith_result=`expr "${@}"`
865} # func_arith may be replaced by extended shell implementation
866
867
868# func_len string
869# STRING may not start with a hyphen.
870func_len ()
871{
872    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
873} # func_len may be replaced by extended shell implementation
874
875
876# func_lo2o object
877func_lo2o ()
878{
879    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
880} # func_lo2o may be replaced by extended shell implementation
881
882
883# func_xform libobj-or-source
884func_xform ()
885{
886    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
887} # func_xform may be replaced by extended shell implementation
888
889
890# func_fatal_configuration arg...
891# Echo program name prefixed message to standard error, followed by
892# a configuration failure hint, and exit.
893func_fatal_configuration ()
894{
895    func_error ${1+"$@"}
896    func_error "See the $PACKAGE documentation for more information."
897    func_fatal_error "Fatal configuration error."
898}
899
900
901# func_config
902# Display the configuration for all the tags in this script.
903func_config ()
904{
905    re_begincf='^# ### BEGIN LIBTOOL'
906    re_endcf='^# ### END LIBTOOL'
907
908    # Default configuration.
909    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
910
911    # Now print the configurations for the tags.
912    for tagname in $taglist; do
913      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
914    done
915
916    exit $?
917}
918
919# func_features
920# Display the features supported by this script.
921func_features ()
922{
923    echo "host: $host"
924    if test "$build_libtool_libs" = yes; then
925      echo "enable shared libraries"
926    else
927      echo "disable shared libraries"
928    fi
929    if test "$build_old_libs" = yes; then
930      echo "enable static libraries"
931    else
932      echo "disable static libraries"
933    fi
934
935    exit $?
936}
937
938# func_enable_tag tagname
939# Verify that TAGNAME is valid, and either flag an error and exit, or
940# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
941# variable here.
942func_enable_tag ()
943{
944  # Global variable:
945  tagname="$1"
946
947  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
948  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
949  sed_extractcf="/$re_begincf/,/$re_endcf/p"
950
951  # Validate tagname.
952  case $tagname in
953    *[!-_A-Za-z0-9,/]*)
954      func_fatal_error "invalid tag name: $tagname"
955      ;;
956  esac
957
958  # Don't test for the "default" C tag, as we know it's
959  # there but not specially marked.
960  case $tagname in
961    CC) ;;
962    *)
963      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
964	taglist="$taglist $tagname"
965
966	# Evaluate the configuration.  Be careful to quote the path
967	# and the sed script, to avoid splitting on whitespace, but
968	# also don't use non-portable quotes within backquotes within
969	# quotes we have to do it in 2 steps:
970	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
971	eval "$extractedcf"
972      else
973	func_error "ignoring unknown tag $tagname"
974      fi
975      ;;
976  esac
977}
978
979# func_check_version_match
980# Ensure that we are using m4 macros, and libtool script from the same
981# release of libtool.
982func_check_version_match ()
983{
984  if test "$package_revision" != "$macro_revision"; then
985    if test "$VERSION" != "$macro_version"; then
986      if test -z "$macro_version"; then
987        cat >&2 <<_LT_EOF
988$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
989$progname: definition of this LT_INIT comes from an older release.
990$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
991$progname: and run autoconf again.
992_LT_EOF
993      else
994        cat >&2 <<_LT_EOF
995$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
996$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
997$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
998$progname: and run autoconf again.
999_LT_EOF
1000      fi
1001    else
1002      cat >&2 <<_LT_EOF
1003$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
1004$progname: but the definition of this LT_INIT comes from revision $macro_revision.
1005$progname: You should recreate aclocal.m4 with macros from revision $package_revision
1006$progname: of $PACKAGE $VERSION and run autoconf again.
1007_LT_EOF
1008    fi
1009
1010    exit $EXIT_MISMATCH
1011  fi
1012}
1013
1014
1015# Shorthand for --mode=foo, only valid as the first argument
1016case $1 in
1017clean|clea|cle|cl)
1018  shift; set dummy --mode clean ${1+"$@"}; shift
1019  ;;
1020compile|compil|compi|comp|com|co|c)
1021  shift; set dummy --mode compile ${1+"$@"}; shift
1022  ;;
1023execute|execut|execu|exec|exe|ex|e)
1024  shift; set dummy --mode execute ${1+"$@"}; shift
1025  ;;
1026finish|finis|fini|fin|fi|f)
1027  shift; set dummy --mode finish ${1+"$@"}; shift
1028  ;;
1029install|instal|insta|inst|ins|in|i)
1030  shift; set dummy --mode install ${1+"$@"}; shift
1031  ;;
1032link|lin|li|l)
1033  shift; set dummy --mode link ${1+"$@"}; shift
1034  ;;
1035uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
1036  shift; set dummy --mode uninstall ${1+"$@"}; shift
1037  ;;
1038esac
1039
1040
1041
1042# Option defaults:
1043opt_debug=:
1044opt_dry_run=false
1045opt_config=false
1046opt_preserve_dup_deps=false
1047opt_features=false
1048opt_finish=false
1049opt_help=false
1050opt_help_all=false
1051opt_silent=:
1052opt_warning=:
1053opt_verbose=:
1054opt_silent=false
1055opt_verbose=false
1056
1057
1058# Parse options once, thoroughly.  This comes as soon as possible in the
1059# script to make things like `--version' happen as quickly as we can.
1060{
1061  # this just eases exit handling
1062  while test $# -gt 0; do
1063    opt="$1"
1064    shift
1065    case $opt in
1066      --debug|-x)	opt_debug='set -x'
1067			func_echo "enabling shell trace mode"
1068			$opt_debug
1069			;;
1070      --dry-run|--dryrun|-n)
1071			opt_dry_run=:
1072			;;
1073      --config)
1074			opt_config=:
1075func_config
1076			;;
1077      --dlopen|-dlopen)
1078			optarg="$1"
1079			opt_dlopen="${opt_dlopen+$opt_dlopen
1080}$optarg"
1081			shift
1082			;;
1083      --preserve-dup-deps)
1084			opt_preserve_dup_deps=:
1085			;;
1086      --features)
1087			opt_features=:
1088func_features
1089			;;
1090      --finish)
1091			opt_finish=:
1092set dummy --mode finish ${1+"$@"}; shift
1093			;;
1094      --help)
1095			opt_help=:
1096			;;
1097      --help-all)
1098			opt_help_all=:
1099opt_help=': help-all'
1100			;;
1101      --mode)
1102			test $# = 0 && func_missing_arg $opt && break
1103			optarg="$1"
1104			opt_mode="$optarg"
1105case $optarg in
1106  # Valid mode arguments:
1107  clean|compile|execute|finish|install|link|relink|uninstall) ;;
1108
1109  # Catch anything else as an error
1110  *) func_error "invalid argument for $opt"
1111     exit_cmd=exit
1112     break
1113     ;;
1114esac
1115			shift
1116			;;
1117      --no-silent|--no-quiet)
1118			opt_silent=false
1119func_append preserve_args " $opt"
1120			;;
1121      --no-warning|--no-warn)
1122			opt_warning=false
1123func_append preserve_args " $opt"
1124			;;
1125      --no-verbose)
1126			opt_verbose=false
1127func_append preserve_args " $opt"
1128			;;
1129      --silent|--quiet)
1130			opt_silent=:
1131func_append preserve_args " $opt"
1132        opt_verbose=false
1133			;;
1134      --verbose|-v)
1135			opt_verbose=:
1136func_append preserve_args " $opt"
1137opt_silent=false
1138			;;
1139      --tag)
1140			test $# = 0 && func_missing_arg $opt && break
1141			optarg="$1"
1142			opt_tag="$optarg"
1143func_append preserve_args " $opt $optarg"
1144func_enable_tag "$optarg"
1145			shift
1146			;;
1147
1148      -\?|-h)		func_usage				;;
1149      --help)		func_help				;;
1150      --version)	func_version				;;
1151
1152      # Separate optargs to long options:
1153      --*=*)
1154			func_split_long_opt "$opt"
1155			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
1156			shift
1157			;;
1158
1159      # Separate non-argument short options:
1160      -\?*|-h*|-n*|-v*)
1161			func_split_short_opt "$opt"
1162			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
1163			shift
1164			;;
1165
1166      --)		break					;;
1167      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
1168      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
1169    esac
1170  done
1171
1172  # Validate options:
1173
1174  # save first non-option argument
1175  if test "$#" -gt 0; then
1176    nonopt="$opt"
1177    shift
1178  fi
1179
1180  # preserve --debug
1181  test "$opt_debug" = : || func_append preserve_args " --debug"
1182
1183  case $host in
1184    *cygwin* | *mingw* | *pw32* | *cegcc*)
1185      # don't eliminate duplications in $postdeps and $predeps
1186      opt_duplicate_compiler_generated_deps=:
1187      ;;
1188    *)
1189      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
1190      ;;
1191  esac
1192
1193  $opt_help || {
1194    # Sanity checks first:
1195    func_check_version_match
1196
1197    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
1198      func_fatal_configuration "not configured to build any kind of library"
1199    fi
1200
1201    # Darwin sucks
1202    eval std_shrext=\"$shrext_cmds\"
1203
1204    # Only execute mode is allowed to have -dlopen flags.
1205    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
1206      func_error "unrecognized option \`-dlopen'"
1207      $ECHO "$help" 1>&2
1208      exit $EXIT_FAILURE
1209    fi
1210
1211    # Change the help message to a mode-specific one.
1212    generic_help="$help"
1213    help="Try \`$progname --help --mode=$opt_mode' for more information."
1214  }
1215
1216
1217  # Bail if the options were screwed
1218  $exit_cmd $EXIT_FAILURE
1219}
1220
1221
1222
1223
1224## ----------- ##
1225##    Main.    ##
1226## ----------- ##
1227
1228# func_lalib_p file
1229# True iff FILE is a libtool `.la' library or `.lo' object file.
1230# This function is only a basic sanity check; it will hardly flush out
1231# determined imposters.
1232func_lalib_p ()
1233{
1234    test -f "$1" &&
1235      $SED -e 4q "$1" 2>/dev/null \
1236        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
1237}
1238
1239# func_lalib_unsafe_p file
1240# True iff FILE is a libtool `.la' library or `.lo' object file.
1241# This function implements the same check as func_lalib_p without
1242# resorting to external programs.  To this end, it redirects stdin and
1243# closes it afterwards, without saving the original file descriptor.
1244# As a safety measure, use it only where a negative result would be
1245# fatal anyway.  Works if `file' does not exist.
1246func_lalib_unsafe_p ()
1247{
1248    lalib_p=no
1249    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
1250	for lalib_p_l in 1 2 3 4
1251	do
1252	    read lalib_p_line
1253	    case "$lalib_p_line" in
1254		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
1255	    esac
1256	done
1257	exec 0<&5 5<&-
1258    fi
1259    test "$lalib_p" = yes
1260}
1261
1262# func_ltwrapper_script_p file
1263# True iff FILE is a libtool wrapper script
1264# This function is only a basic sanity check; it will hardly flush out
1265# determined imposters.
1266func_ltwrapper_script_p ()
1267{
1268    func_lalib_p "$1"
1269}
1270
1271# func_ltwrapper_executable_p file
1272# True iff FILE is a libtool wrapper executable
1273# This function is only a basic sanity check; it will hardly flush out
1274# determined imposters.
1275func_ltwrapper_executable_p ()
1276{
1277    func_ltwrapper_exec_suffix=
1278    case $1 in
1279    *.exe) ;;
1280    *) func_ltwrapper_exec_suffix=.exe ;;
1281    esac
1282    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
1283}
1284
1285# func_ltwrapper_scriptname file
1286# Assumes file is an ltwrapper_executable
1287# uses $file to determine the appropriate filename for a
1288# temporary ltwrapper_script.
1289func_ltwrapper_scriptname ()
1290{
1291    func_dirname_and_basename "$1" "" "."
1292    func_stripname '' '.exe' "$func_basename_result"
1293    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
1294}
1295
1296# func_ltwrapper_p file
1297# True iff FILE is a libtool wrapper script or wrapper executable
1298# This function is only a basic sanity check; it will hardly flush out
1299# determined imposters.
1300func_ltwrapper_p ()
1301{
1302    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
1303}
1304
1305
1306# func_execute_cmds commands fail_cmd
1307# Execute tilde-delimited COMMANDS.
1308# If FAIL_CMD is given, eval that upon failure.
1309# FAIL_CMD may read-access the current command in variable CMD!
1310func_execute_cmds ()
1311{
1312    $opt_debug
1313    save_ifs=$IFS; IFS='~'
1314    for cmd in $1; do
1315      IFS=$save_ifs
1316      eval cmd=\"$cmd\"
1317      func_show_eval "$cmd" "${2-:}"
1318    done
1319    IFS=$save_ifs
1320}
1321
1322
1323# func_source file
1324# Source FILE, adding directory component if necessary.
1325# Note that it is not necessary on cygwin/mingw to append a dot to
1326# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
1327# behavior happens only for exec(3), not for open(2)!  Also, sourcing
1328# `FILE.' does not work on cygwin managed mounts.
1329func_source ()
1330{
1331    $opt_debug
1332    case $1 in
1333    */* | *\\*)	. "$1" ;;
1334    *)		. "./$1" ;;
1335    esac
1336}
1337
1338
1339# func_resolve_sysroot PATH
1340# Replace a leading = in PATH with a sysroot.  Store the result into
1341# func_resolve_sysroot_result
1342func_resolve_sysroot ()
1343{
1344  func_resolve_sysroot_result=$1
1345  case $func_resolve_sysroot_result in
1346  =*)
1347    func_stripname '=' '' "$func_resolve_sysroot_result"
1348    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
1349    ;;
1350  esac
1351}
1352
1353# func_replace_sysroot PATH
1354# If PATH begins with the sysroot, replace it with = and
1355# store the result into func_replace_sysroot_result.
1356func_replace_sysroot ()
1357{
1358  case "$lt_sysroot:$1" in
1359  ?*:"$lt_sysroot"*)
1360    func_stripname "$lt_sysroot" '' "$1"
1361    func_replace_sysroot_result="=$func_stripname_result"
1362    ;;
1363  *)
1364    # Including no sysroot.
1365    func_replace_sysroot_result=$1
1366    ;;
1367  esac
1368}
1369
1370# func_infer_tag arg
1371# Infer tagged configuration to use if any are available and
1372# if one wasn't chosen via the "--tag" command line option.
1373# Only attempt this if the compiler in the base compile
1374# command doesn't match the default compiler.
1375# arg is usually of the form 'gcc ...'
1376func_infer_tag ()
1377{
1378    $opt_debug
1379    if test -n "$available_tags" && test -z "$tagname"; then
1380      CC_quoted=
1381      for arg in $CC; do
1382	func_append_quoted CC_quoted "$arg"
1383      done
1384      CC_expanded=`func_echo_all $CC`
1385      CC_quoted_expanded=`func_echo_all $CC_quoted`
1386      case $@ in
1387      # Blanks in the command may have been stripped by the calling shell,
1388      # but not from the CC environment variable when configure was run.
1389      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1390      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
1391      # Blanks at the start of $base_compile will cause this to fail
1392      # if we don't check for them as well.
1393      *)
1394	for z in $available_tags; do
1395	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1396	    # Evaluate the configuration.
1397	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1398	    CC_quoted=
1399	    for arg in $CC; do
1400	      # Double-quote args containing other shell metacharacters.
1401	      func_append_quoted CC_quoted "$arg"
1402	    done
1403	    CC_expanded=`func_echo_all $CC`
1404	    CC_quoted_expanded=`func_echo_all $CC_quoted`
1405	    case "$@ " in
1406	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1407	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
1408	      # The compiler in the base compile command matches
1409	      # the one in the tagged configuration.
1410	      # Assume this is the tagged configuration we want.
1411	      tagname=$z
1412	      break
1413	      ;;
1414	    esac
1415	  fi
1416	done
1417	# If $tagname still isn't set, then no tagged configuration
1418	# was found and let the user know that the "--tag" command
1419	# line option must be used.
1420	if test -z "$tagname"; then
1421	  func_echo "unable to infer tagged configuration"
1422	  func_fatal_error "specify a tag with \`--tag'"
1423#	else
1424#	  func_verbose "using $tagname tagged configuration"
1425	fi
1426	;;
1427      esac
1428    fi
1429}
1430
1431
1432
1433# func_write_libtool_object output_name pic_name nonpic_name
1434# Create a libtool object file (analogous to a ".la" file),
1435# but don't create it if we're doing a dry run.
1436func_write_libtool_object ()
1437{
1438    write_libobj=${1}
1439    if test "$build_libtool_libs" = yes; then
1440      write_lobj=\'${2}\'
1441    else
1442      write_lobj=none
1443    fi
1444
1445    if test "$build_old_libs" = yes; then
1446      write_oldobj=\'${3}\'
1447    else
1448      write_oldobj=none
1449    fi
1450
1451    $opt_dry_run || {
1452      cat >${write_libobj}T <<EOF
1453# $write_libobj - a libtool object file
1454# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1455#
1456# Please DO NOT delete this file!
1457# It is necessary for linking the library.
1458
1459# Name of the PIC object.
1460pic_object=$write_lobj
1461
1462# Name of the non-PIC object
1463non_pic_object=$write_oldobj
1464
1465EOF
1466      $MV "${write_libobj}T" "${write_libobj}"
1467    }
1468}
1469
1470
1471##################################################
1472# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
1473##################################################
1474
1475# func_convert_core_file_wine_to_w32 ARG
1476# Helper function used by file name conversion functions when $build is *nix,
1477# and $host is mingw, cygwin, or some other w32 environment. Relies on a
1478# correctly configured wine environment available, with the winepath program
1479# in $build's $PATH.
1480#
1481# ARG is the $build file name to be converted to w32 format.
1482# Result is available in $func_convert_core_file_wine_to_w32_result, and will
1483# be empty on error (or when ARG is empty)
1484func_convert_core_file_wine_to_w32 ()
1485{
1486  $opt_debug
1487  func_convert_core_file_wine_to_w32_result="$1"
1488  if test -n "$1"; then
1489    # Unfortunately, winepath does not exit with a non-zero error code, so we
1490    # are forced to check the contents of stdout. On the other hand, if the
1491    # command is not found, the shell will set an exit code of 127 and print
1492    # *an error message* to stdout. So we must check for both error code of
1493    # zero AND non-empty stdout, which explains the odd construction:
1494    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
1495    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
1496      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
1497        $SED -e "$lt_sed_naive_backslashify"`
1498    else
1499      func_convert_core_file_wine_to_w32_result=
1500    fi
1501  fi
1502}
1503# end: func_convert_core_file_wine_to_w32
1504
1505
1506# func_convert_core_path_wine_to_w32 ARG
1507# Helper function used by path conversion functions when $build is *nix, and
1508# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
1509# configured wine environment available, with the winepath program in $build's
1510# $PATH. Assumes ARG has no leading or trailing path separator characters.
1511#
1512# ARG is path to be converted from $build format to win32.
1513# Result is available in $func_convert_core_path_wine_to_w32_result.
1514# Unconvertible file (directory) names in ARG are skipped; if no directory names
1515# are convertible, then the result may be empty.
1516func_convert_core_path_wine_to_w32 ()
1517{
1518  $opt_debug
1519  # unfortunately, winepath doesn't convert paths, only file names
1520  func_convert_core_path_wine_to_w32_result=""
1521  if test -n "$1"; then
1522    oldIFS=$IFS
1523    IFS=:
1524    for func_convert_core_path_wine_to_w32_f in $1; do
1525      IFS=$oldIFS
1526      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
1527      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
1528        if test -z "$func_convert_core_path_wine_to_w32_result"; then
1529          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
1530        else
1531          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
1532        fi
1533      fi
1534    done
1535    IFS=$oldIFS
1536  fi
1537}
1538# end: func_convert_core_path_wine_to_w32
1539
1540
1541# func_cygpath ARGS...
1542# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
1543# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
1544# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
1545# (2), returns the Cygwin file name or path in func_cygpath_result (input
1546# file name or path is assumed to be in w32 format, as previously converted
1547# from $build's *nix or MSYS format). In case (3), returns the w32 file name
1548# or path in func_cygpath_result (input file name or path is assumed to be in
1549# Cygwin format). Returns an empty string on error.
1550#
1551# ARGS are passed to cygpath, with the last one being the file name or path to
1552# be converted.
1553#
1554# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
1555# environment variable; do not put it in $PATH.
1556func_cygpath ()
1557{
1558  $opt_debug
1559  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
1560    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
1561    if test "$?" -ne 0; then
1562      # on failure, ensure result is empty
1563      func_cygpath_result=
1564    fi
1565  else
1566    func_cygpath_result=
1567    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
1568  fi
1569}
1570#end: func_cygpath
1571
1572
1573# func_convert_core_msys_to_w32 ARG
1574# Convert file name or path ARG from MSYS format to w32 format.  Return
1575# result in func_convert_core_msys_to_w32_result.
1576func_convert_core_msys_to_w32 ()
1577{
1578  $opt_debug
1579  # awkward: cmd appends spaces to result
1580  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
1581    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
1582}
1583#end: func_convert_core_msys_to_w32
1584
1585
1586# func_convert_file_check ARG1 ARG2
1587# Verify that ARG1 (a file name in $build format) was converted to $host
1588# format in ARG2. Otherwise, emit an error message, but continue (resetting
1589# func_to_host_file_result to ARG1).
1590func_convert_file_check ()
1591{
1592  $opt_debug
1593  if test -z "$2" && test -n "$1" ; then
1594    func_error "Could not determine host file name corresponding to"
1595    func_error "  \`$1'"
1596    func_error "Continuing, but uninstalled executables may not work."
1597    # Fallback:
1598    func_to_host_file_result="$1"
1599  fi
1600}
1601# end func_convert_file_check
1602
1603
1604# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
1605# Verify that FROM_PATH (a path in $build format) was converted to $host
1606# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
1607# func_to_host_file_result to a simplistic fallback value (see below).
1608func_convert_path_check ()
1609{
1610  $opt_debug
1611  if test -z "$4" && test -n "$3"; then
1612    func_error "Could not determine the host path corresponding to"
1613    func_error "  \`$3'"
1614    func_error "Continuing, but uninstalled executables may not work."
1615    # Fallback.  This is a deliberately simplistic "conversion" and
1616    # should not be "improved".  See libtool.info.
1617    if test "x$1" != "x$2"; then
1618      lt_replace_pathsep_chars="s|$1|$2|g"
1619      func_to_host_path_result=`echo "$3" |
1620        $SED -e "$lt_replace_pathsep_chars"`
1621    else
1622      func_to_host_path_result="$3"
1623    fi
1624  fi
1625}
1626# end func_convert_path_check
1627
1628
1629# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
1630# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
1631# and appending REPL if ORIG matches BACKPAT.
1632func_convert_path_front_back_pathsep ()
1633{
1634  $opt_debug
1635  case $4 in
1636  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
1637    ;;
1638  esac
1639  case $4 in
1640  $2 ) func_append func_to_host_path_result "$3"
1641    ;;
1642  esac
1643}
1644# end func_convert_path_front_back_pathsep
1645
1646
1647##################################################
1648# $build to $host FILE NAME CONVERSION FUNCTIONS #
1649##################################################
1650# invoked via `$to_host_file_cmd ARG'
1651#
1652# In each case, ARG is the path to be converted from $build to $host format.
1653# Result will be available in $func_to_host_file_result.
1654
1655
1656# func_to_host_file ARG
1657# Converts the file name ARG from $build format to $host format. Return result
1658# in func_to_host_file_result.
1659func_to_host_file ()
1660{
1661  $opt_debug
1662  $to_host_file_cmd "$1"
1663}
1664# end func_to_host_file
1665
1666
1667# func_to_tool_file ARG LAZY
1668# converts the file name ARG from $build format to toolchain format. Return
1669# result in func_to_tool_file_result.  If the conversion in use is listed
1670# in (the comma separated) LAZY, no conversion takes place.
1671func_to_tool_file ()
1672{
1673  $opt_debug
1674  case ,$2, in
1675    *,"$to_tool_file_cmd",*)
1676      func_to_tool_file_result=$1
1677      ;;
1678    *)
1679      $to_tool_file_cmd "$1"
1680      func_to_tool_file_result=$func_to_host_file_result
1681      ;;
1682  esac
1683}
1684# end func_to_tool_file
1685
1686
1687# func_convert_file_noop ARG
1688# Copy ARG to func_to_host_file_result.
1689func_convert_file_noop ()
1690{
1691  func_to_host_file_result="$1"
1692}
1693# end func_convert_file_noop
1694
1695
1696# func_convert_file_msys_to_w32 ARG
1697# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
1698# conversion to w32 is not available inside the cwrapper.  Returns result in
1699# func_to_host_file_result.
1700func_convert_file_msys_to_w32 ()
1701{
1702  $opt_debug
1703  func_to_host_file_result="$1"
1704  if test -n "$1"; then
1705    func_convert_core_msys_to_w32 "$1"
1706    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
1707  fi
1708  func_convert_file_check "$1" "$func_to_host_file_result"
1709}
1710# end func_convert_file_msys_to_w32
1711
1712
1713# func_convert_file_cygwin_to_w32 ARG
1714# Convert file name ARG from Cygwin to w32 format.  Returns result in
1715# func_to_host_file_result.
1716func_convert_file_cygwin_to_w32 ()
1717{
1718  $opt_debug
1719  func_to_host_file_result="$1"
1720  if test -n "$1"; then
1721    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
1722    # LT_CYGPATH in this case.
1723    func_to_host_file_result=`cygpath -m "$1"`
1724  fi
1725  func_convert_file_check "$1" "$func_to_host_file_result"
1726}
1727# end func_convert_file_cygwin_to_w32
1728
1729
1730# func_convert_file_nix_to_w32 ARG
1731# Convert file name ARG from *nix to w32 format.  Requires a wine environment
1732# and a working winepath. Returns result in func_to_host_file_result.
1733func_convert_file_nix_to_w32 ()
1734{
1735  $opt_debug
1736  func_to_host_file_result="$1"
1737  if test -n "$1"; then
1738    func_convert_core_file_wine_to_w32 "$1"
1739    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
1740  fi
1741  func_convert_file_check "$1" "$func_to_host_file_result"
1742}
1743# end func_convert_file_nix_to_w32
1744
1745
1746# func_convert_file_msys_to_cygwin ARG
1747# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1748# Returns result in func_to_host_file_result.
1749func_convert_file_msys_to_cygwin ()
1750{
1751  $opt_debug
1752  func_to_host_file_result="$1"
1753  if test -n "$1"; then
1754    func_convert_core_msys_to_w32 "$1"
1755    func_cygpath -u "$func_convert_core_msys_to_w32_result"
1756    func_to_host_file_result="$func_cygpath_result"
1757  fi
1758  func_convert_file_check "$1" "$func_to_host_file_result"
1759}
1760# end func_convert_file_msys_to_cygwin
1761
1762
1763# func_convert_file_nix_to_cygwin ARG
1764# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
1765# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
1766# in func_to_host_file_result.
1767func_convert_file_nix_to_cygwin ()
1768{
1769  $opt_debug
1770  func_to_host_file_result="$1"
1771  if test -n "$1"; then
1772    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
1773    func_convert_core_file_wine_to_w32 "$1"
1774    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
1775    func_to_host_file_result="$func_cygpath_result"
1776  fi
1777  func_convert_file_check "$1" "$func_to_host_file_result"
1778}
1779# end func_convert_file_nix_to_cygwin
1780
1781
1782#############################################
1783# $build to $host PATH CONVERSION FUNCTIONS #
1784#############################################
1785# invoked via `$to_host_path_cmd ARG'
1786#
1787# In each case, ARG is the path to be converted from $build to $host format.
1788# The result will be available in $func_to_host_path_result.
1789#
1790# Path separators are also converted from $build format to $host format.  If
1791# ARG begins or ends with a path separator character, it is preserved (but
1792# converted to $host format) on output.
1793#
1794# All path conversion functions are named using the following convention:
1795#   file name conversion function    : func_convert_file_X_to_Y ()
1796#   path conversion function         : func_convert_path_X_to_Y ()
1797# where, for any given $build/$host combination the 'X_to_Y' value is the
1798# same.  If conversion functions are added for new $build/$host combinations,
1799# the two new functions must follow this pattern, or func_init_to_host_path_cmd
1800# will break.
1801
1802
1803# func_init_to_host_path_cmd
1804# Ensures that function "pointer" variable $to_host_path_cmd is set to the
1805# appropriate value, based on the value of $to_host_file_cmd.
1806to_host_path_cmd=
1807func_init_to_host_path_cmd ()
1808{
1809  $opt_debug
1810  if test -z "$to_host_path_cmd"; then
1811    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
1812    to_host_path_cmd="func_convert_path_${func_stripname_result}"
1813  fi
1814}
1815
1816
1817# func_to_host_path ARG
1818# Converts the path ARG from $build format to $host format. Return result
1819# in func_to_host_path_result.
1820func_to_host_path ()
1821{
1822  $opt_debug
1823  func_init_to_host_path_cmd
1824  $to_host_path_cmd "$1"
1825}
1826# end func_to_host_path
1827
1828
1829# func_convert_path_noop ARG
1830# Copy ARG to func_to_host_path_result.
1831func_convert_path_noop ()
1832{
1833  func_to_host_path_result="$1"
1834}
1835# end func_convert_path_noop
1836
1837
1838# func_convert_path_msys_to_w32 ARG
1839# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
1840# conversion to w32 is not available inside the cwrapper.  Returns result in
1841# func_to_host_path_result.
1842func_convert_path_msys_to_w32 ()
1843{
1844  $opt_debug
1845  func_to_host_path_result="$1"
1846  if test -n "$1"; then
1847    # Remove leading and trailing path separator characters from ARG.  MSYS
1848    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
1849    # and winepath ignores them completely.
1850    func_stripname : : "$1"
1851    func_to_host_path_tmp1=$func_stripname_result
1852    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1853    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
1854    func_convert_path_check : ";" \
1855      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1856    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1857  fi
1858}
1859# end func_convert_path_msys_to_w32
1860
1861
1862# func_convert_path_cygwin_to_w32 ARG
1863# Convert path ARG from Cygwin to w32 format.  Returns result in
1864# func_to_host_file_result.
1865func_convert_path_cygwin_to_w32 ()
1866{
1867  $opt_debug
1868  func_to_host_path_result="$1"
1869  if test -n "$1"; then
1870    # See func_convert_path_msys_to_w32:
1871    func_stripname : : "$1"
1872    func_to_host_path_tmp1=$func_stripname_result
1873    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
1874    func_convert_path_check : ";" \
1875      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1876    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1877  fi
1878}
1879# end func_convert_path_cygwin_to_w32
1880
1881
1882# func_convert_path_nix_to_w32 ARG
1883# Convert path ARG from *nix to w32 format.  Requires a wine environment and
1884# a working winepath.  Returns result in func_to_host_file_result.
1885func_convert_path_nix_to_w32 ()
1886{
1887  $opt_debug
1888  func_to_host_path_result="$1"
1889  if test -n "$1"; then
1890    # See func_convert_path_msys_to_w32:
1891    func_stripname : : "$1"
1892    func_to_host_path_tmp1=$func_stripname_result
1893    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1894    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
1895    func_convert_path_check : ";" \
1896      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1897    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1898  fi
1899}
1900# end func_convert_path_nix_to_w32
1901
1902
1903# func_convert_path_msys_to_cygwin ARG
1904# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1905# Returns result in func_to_host_file_result.
1906func_convert_path_msys_to_cygwin ()
1907{
1908  $opt_debug
1909  func_to_host_path_result="$1"
1910  if test -n "$1"; then
1911    # See func_convert_path_msys_to_w32:
1912    func_stripname : : "$1"
1913    func_to_host_path_tmp1=$func_stripname_result
1914    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1915    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
1916    func_to_host_path_result="$func_cygpath_result"
1917    func_convert_path_check : : \
1918      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1919    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1920  fi
1921}
1922# end func_convert_path_msys_to_cygwin
1923
1924
1925# func_convert_path_nix_to_cygwin ARG
1926# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
1927# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
1928# func_to_host_file_result.
1929func_convert_path_nix_to_cygwin ()
1930{
1931  $opt_debug
1932  func_to_host_path_result="$1"
1933  if test -n "$1"; then
1934    # Remove leading and trailing path separator characters from
1935    # ARG. msys behavior is inconsistent here, cygpath turns them
1936    # into '.;' and ';.', and winepath ignores them completely.
1937    func_stripname : : "$1"
1938    func_to_host_path_tmp1=$func_stripname_result
1939    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1940    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
1941    func_to_host_path_result="$func_cygpath_result"
1942    func_convert_path_check : : \
1943      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1944    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1945  fi
1946}
1947# end func_convert_path_nix_to_cygwin
1948
1949
1950# func_mode_compile arg...
1951func_mode_compile ()
1952{
1953    $opt_debug
1954    # Get the compilation command and the source file.
1955    base_compile=
1956    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
1957    suppress_opt=yes
1958    suppress_output=
1959    arg_mode=normal
1960    libobj=
1961    later=
1962    pie_flag=
1963
1964    for arg
1965    do
1966      case $arg_mode in
1967      arg  )
1968	# do not "continue".  Instead, add this to base_compile
1969	lastarg="$arg"
1970	arg_mode=normal
1971	;;
1972
1973      target )
1974	libobj="$arg"
1975	arg_mode=normal
1976	continue
1977	;;
1978
1979      normal )
1980	# Accept any command-line options.
1981	case $arg in
1982	-o)
1983	  test -n "$libobj" && \
1984	    func_fatal_error "you cannot specify \`-o' more than once"
1985	  arg_mode=target
1986	  continue
1987	  ;;
1988
1989	-pie | -fpie | -fPIE)
1990          func_append pie_flag " $arg"
1991	  continue
1992	  ;;
1993
1994	-shared | -static | -prefer-pic | -prefer-non-pic)
1995	  func_append later " $arg"
1996	  continue
1997	  ;;
1998
1999	-no-suppress)
2000	  suppress_opt=no
2001	  continue
2002	  ;;
2003
2004	-Xcompiler)
2005	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
2006	  continue      #  The current "srcfile" will either be retained or
2007	  ;;            #  replaced later.  I would guess that would be a bug.
2008
2009	-Wc,*)
2010	  func_stripname '-Wc,' '' "$arg"
2011	  args=$func_stripname_result
2012	  lastarg=
2013	  save_ifs="$IFS"; IFS=','
2014	  for arg in $args; do
2015	    IFS="$save_ifs"
2016	    func_append_quoted lastarg "$arg"
2017	  done
2018	  IFS="$save_ifs"
2019	  func_stripname ' ' '' "$lastarg"
2020	  lastarg=$func_stripname_result
2021
2022	  # Add the arguments to base_compile.
2023	  func_append base_compile " $lastarg"
2024	  continue
2025	  ;;
2026
2027	*)
2028	  # Accept the current argument as the source file.
2029	  # The previous "srcfile" becomes the current argument.
2030	  #
2031	  lastarg="$srcfile"
2032	  srcfile="$arg"
2033	  ;;
2034	esac  #  case $arg
2035	;;
2036      esac    #  case $arg_mode
2037
2038      # Aesthetically quote the previous argument.
2039      func_append_quoted base_compile "$lastarg"
2040    done # for arg
2041
2042    case $arg_mode in
2043    arg)
2044      func_fatal_error "you must specify an argument for -Xcompile"
2045      ;;
2046    target)
2047      func_fatal_error "you must specify a target with \`-o'"
2048      ;;
2049    *)
2050      # Get the name of the library object.
2051      test -z "$libobj" && {
2052	func_basename "$srcfile"
2053	libobj="$func_basename_result"
2054      }
2055      ;;
2056    esac
2057
2058    # Recognize several different file suffixes.
2059    # If the user specifies -o file.o, it is replaced with file.lo
2060    case $libobj in
2061    *.[cCFSifmso] | \
2062    *.ada | *.adb | *.ads | *.asm | \
2063    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
2064    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
2065      func_xform "$libobj"
2066      libobj=$func_xform_result
2067      ;;
2068    esac
2069
2070    case $libobj in
2071    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
2072    *)
2073      func_fatal_error "cannot determine name of library object from \`$libobj'"
2074      ;;
2075    esac
2076
2077    func_infer_tag $base_compile
2078
2079    for arg in $later; do
2080      case $arg in
2081      -shared)
2082	test "$build_libtool_libs" != yes && \
2083	  func_fatal_configuration "can not build a shared library"
2084	build_old_libs=no
2085	continue
2086	;;
2087
2088      -static)
2089	build_libtool_libs=no
2090	build_old_libs=yes
2091	continue
2092	;;
2093
2094      -prefer-pic)
2095	pic_mode=yes
2096	continue
2097	;;
2098
2099      -prefer-non-pic)
2100	pic_mode=no
2101	continue
2102	;;
2103      esac
2104    done
2105
2106    func_quote_for_eval "$libobj"
2107    test "X$libobj" != "X$func_quote_for_eval_result" \
2108      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
2109      && func_warning "libobj name \`$libobj' may not contain shell special characters."
2110    func_dirname_and_basename "$obj" "/" ""
2111    objname="$func_basename_result"
2112    xdir="$func_dirname_result"
2113    lobj=${xdir}$objdir/$objname
2114
2115    test -z "$base_compile" && \
2116      func_fatal_help "you must specify a compilation command"
2117
2118    # Delete any leftover library objects.
2119    if test "$build_old_libs" = yes; then
2120      removelist="$obj $lobj $libobj ${libobj}T"
2121    else
2122      removelist="$lobj $libobj ${libobj}T"
2123    fi
2124
2125    # On Cygwin there's no "real" PIC flag so we must build both object types
2126    case $host_os in
2127    cygwin* | mingw* | pw32* | os2* | cegcc*)
2128      pic_mode=default
2129      ;;
2130    esac
2131    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
2132      # non-PIC code in shared libraries is not supported
2133      pic_mode=default
2134    fi
2135
2136    # Calculate the filename of the output object if compiler does
2137    # not support -o with -c
2138    if test "$compiler_c_o" = no; then
2139      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
2140      lockfile="$output_obj.lock"
2141    else
2142      output_obj=
2143      need_locks=no
2144      lockfile=
2145    fi
2146
2147    # Lock this critical section if it is needed
2148    # We use this script file to make the link, it avoids creating a new file
2149    if test "$need_locks" = yes; then
2150      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
2151	func_echo "Waiting for $lockfile to be removed"
2152	sleep 2
2153      done
2154    elif test "$need_locks" = warn; then
2155      if test -f "$lockfile"; then
2156	$ECHO "\
2157*** ERROR, $lockfile exists and contains:
2158`cat $lockfile 2>/dev/null`
2159
2160This indicates that another process is trying to use the same
2161temporary object file, and libtool could not work around it because
2162your compiler does not support \`-c' and \`-o' together.  If you
2163repeat this compilation, it may succeed, by chance, but you had better
2164avoid parallel builds (make -j) in this platform, or get a better
2165compiler."
2166
2167	$opt_dry_run || $RM $removelist
2168	exit $EXIT_FAILURE
2169      fi
2170      func_append removelist " $output_obj"
2171      $ECHO "$srcfile" > "$lockfile"
2172    fi
2173
2174    $opt_dry_run || $RM $removelist
2175    func_append removelist " $lockfile"
2176    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
2177
2178    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
2179    srcfile=$func_to_tool_file_result
2180    func_quote_for_eval "$srcfile"
2181    qsrcfile=$func_quote_for_eval_result
2182
2183    # Only build a PIC object if we are building libtool libraries.
2184    if test "$build_libtool_libs" = yes; then
2185      # Without this assignment, base_compile gets emptied.
2186      fbsd_hideous_sh_bug=$base_compile
2187
2188      if test "$pic_mode" != no; then
2189	command="$base_compile $qsrcfile $pic_flag"
2190      else
2191	# Don't build PIC code
2192	command="$base_compile $qsrcfile"
2193      fi
2194
2195      func_mkdir_p "$xdir$objdir"
2196
2197      if test -z "$output_obj"; then
2198	# Place PIC objects in $objdir
2199	func_append command " -o $lobj"
2200      fi
2201
2202      func_show_eval_locale "$command"	\
2203          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
2204
2205      if test "$need_locks" = warn &&
2206	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2207	$ECHO "\
2208*** ERROR, $lockfile contains:
2209`cat $lockfile 2>/dev/null`
2210
2211but it should contain:
2212$srcfile
2213
2214This indicates that another process is trying to use the same
2215temporary object file, and libtool could not work around it because
2216your compiler does not support \`-c' and \`-o' together.  If you
2217repeat this compilation, it may succeed, by chance, but you had better
2218avoid parallel builds (make -j) in this platform, or get a better
2219compiler."
2220
2221	$opt_dry_run || $RM $removelist
2222	exit $EXIT_FAILURE
2223      fi
2224
2225      # Just move the object if needed, then go on to compile the next one
2226      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
2227	func_show_eval '$MV "$output_obj" "$lobj"' \
2228	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2229      fi
2230
2231      # Allow error messages only from the first compilation.
2232      if test "$suppress_opt" = yes; then
2233	suppress_output=' >/dev/null 2>&1'
2234      fi
2235    fi
2236
2237    # Only build a position-dependent object if we build old libraries.
2238    if test "$build_old_libs" = yes; then
2239      if test "$pic_mode" != yes; then
2240	# Don't build PIC code
2241	command="$base_compile $qsrcfile$pie_flag"
2242      else
2243	command="$base_compile $qsrcfile $pic_flag"
2244      fi
2245      if test "$compiler_c_o" = yes; then
2246	func_append command " -o $obj"
2247      fi
2248
2249      # Suppress compiler output if we already did a PIC compilation.
2250      func_append command "$suppress_output"
2251      func_show_eval_locale "$command" \
2252        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
2253
2254      if test "$need_locks" = warn &&
2255	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2256	$ECHO "\
2257*** ERROR, $lockfile contains:
2258`cat $lockfile 2>/dev/null`
2259
2260but it should contain:
2261$srcfile
2262
2263This indicates that another process is trying to use the same
2264temporary object file, and libtool could not work around it because
2265your compiler does not support \`-c' and \`-o' together.  If you
2266repeat this compilation, it may succeed, by chance, but you had better
2267avoid parallel builds (make -j) in this platform, or get a better
2268compiler."
2269
2270	$opt_dry_run || $RM $removelist
2271	exit $EXIT_FAILURE
2272      fi
2273
2274      # Just move the object if needed
2275      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
2276	func_show_eval '$MV "$output_obj" "$obj"' \
2277	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2278      fi
2279    fi
2280
2281    $opt_dry_run || {
2282      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
2283
2284      # Unlock the critical section if it was locked
2285      if test "$need_locks" != no; then
2286	removelist=$lockfile
2287        $RM "$lockfile"
2288      fi
2289    }
2290
2291    exit $EXIT_SUCCESS
2292}
2293
2294$opt_help || {
2295  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
2296}
2297
2298func_mode_help ()
2299{
2300    # We need to display help for each of the modes.
2301    case $opt_mode in
2302      "")
2303        # Generic help is extracted from the usage comments
2304        # at the start of this file.
2305        func_help
2306        ;;
2307
2308      clean)
2309        $ECHO \
2310"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
2311
2312Remove files from the build directory.
2313
2314RM is the name of the program to use to delete files associated with each FILE
2315(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2316to RM.
2317
2318If FILE is a libtool library, object or program, all the files associated
2319with it are deleted. Otherwise, only FILE itself is deleted using RM."
2320        ;;
2321
2322      compile)
2323      $ECHO \
2324"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
2325
2326Compile a source file into a libtool library object.
2327
2328This mode accepts the following additional options:
2329
2330  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
2331  -no-suppress      do not suppress compiler output for multiple passes
2332  -prefer-pic       try to build PIC objects only
2333  -prefer-non-pic   try to build non-PIC objects only
2334  -shared           do not build a \`.o' file suitable for static linking
2335  -static           only build a \`.o' file suitable for static linking
2336  -Wc,FLAG          pass FLAG directly to the compiler
2337
2338COMPILE-COMMAND is a command to be used in creating a \`standard' object file
2339from the given SOURCEFILE.
2340
2341The output file name is determined by removing the directory component from
2342SOURCEFILE, then substituting the C source code suffix \`.c' with the
2343library object suffix, \`.lo'."
2344        ;;
2345
2346      execute)
2347        $ECHO \
2348"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
2349
2350Automatically set library path, then run a program.
2351
2352This mode accepts the following additional options:
2353
2354  -dlopen FILE      add the directory containing FILE to the library path
2355
2356This mode sets the library path environment variable according to \`-dlopen'
2357flags.
2358
2359If any of the ARGS are libtool executable wrappers, then they are translated
2360into their corresponding uninstalled binary, and any of their required library
2361directories are added to the library path.
2362
2363Then, COMMAND is executed, with ARGS as arguments."
2364        ;;
2365
2366      finish)
2367        $ECHO \
2368"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
2369
2370Complete the installation of libtool libraries.
2371
2372Each LIBDIR is a directory that contains libtool libraries.
2373
2374The commands that this mode executes may require superuser privileges.  Use
2375the \`--dry-run' option if you just want to see what would be executed."
2376        ;;
2377
2378      install)
2379        $ECHO \
2380"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
2381
2382Install executables or libraries.
2383
2384INSTALL-COMMAND is the installation command.  The first component should be
2385either the \`install' or \`cp' program.
2386
2387The following components of INSTALL-COMMAND are treated specially:
2388
2389  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
2390
2391The rest of the components are interpreted as arguments to that command (only
2392BSD-compatible install options are recognized)."
2393        ;;
2394
2395      link)
2396        $ECHO \
2397"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
2398
2399Link object files or libraries together to form another library, or to
2400create an executable program.
2401
2402LINK-COMMAND is a command using the C compiler that you would use to create
2403a program from several object files.
2404
2405The following components of LINK-COMMAND are treated specially:
2406
2407  -all-static       do not do any dynamic linking at all
2408  -avoid-version    do not add a version suffix if possible
2409  -bindir BINDIR    specify path to binaries directory (for systems where
2410                    libraries must be found in the PATH setting at runtime)
2411  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
2412  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
2413  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
2414  -export-symbols SYMFILE
2415                    try to export only the symbols listed in SYMFILE
2416  -export-symbols-regex REGEX
2417                    try to export only the symbols matching REGEX
2418  -LLIBDIR          search LIBDIR for required installed libraries
2419  -lNAME            OUTPUT-FILE requires the installed library libNAME
2420  -module           build a library that can dlopened
2421  -no-fast-install  disable the fast-install mode
2422  -no-install       link a not-installable executable
2423  -no-undefined     declare that a library does not refer to external symbols
2424  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
2425  -objectlist FILE  Use a list of object files found in FILE to specify objects
2426  -precious-files-regex REGEX
2427                    don't remove output files matching REGEX
2428  -release RELEASE  specify package release information
2429  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
2430  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
2431  -shared           only do dynamic linking of libtool libraries
2432  -shrext SUFFIX    override the standard shared library file extension
2433  -static           do not do any dynamic linking of uninstalled libtool libraries
2434  -static-libtool-libs
2435                    do not do any dynamic linking of libtool libraries
2436  -version-info CURRENT[:REVISION[:AGE]]
2437                    specify library version info [each variable defaults to 0]
2438  -weak LIBNAME     declare that the target provides the LIBNAME interface
2439  -Wc,FLAG
2440  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
2441  -Wl,FLAG
2442  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
2443  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
2444
2445All other options (arguments beginning with \`-') are ignored.
2446
2447Every other argument is treated as a filename.  Files ending in \`.la' are
2448treated as uninstalled libtool libraries, other files are standard or library
2449object files.
2450
2451If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
2452only library objects (\`.lo' files) may be specified, and \`-rpath' is
2453required, except when creating a convenience library.
2454
2455If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
2456using \`ar' and \`ranlib', or on Windows using \`lib'.
2457
2458If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
2459is created, otherwise an executable program is created."
2460        ;;
2461
2462      uninstall)
2463        $ECHO \
2464"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
2465
2466Remove libraries from an installation directory.
2467
2468RM is the name of the program to use to delete files associated with each FILE
2469(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2470to RM.
2471
2472If FILE is a libtool library, all the files associated with it are deleted.
2473Otherwise, only FILE itself is deleted using RM."
2474        ;;
2475
2476      *)
2477        func_fatal_help "invalid operation mode \`$opt_mode'"
2478        ;;
2479    esac
2480
2481    echo
2482    $ECHO "Try \`$progname --help' for more information about other modes."
2483}
2484
2485# Now that we've collected a possible --mode arg, show help if necessary
2486if $opt_help; then
2487  if test "$opt_help" = :; then
2488    func_mode_help
2489  else
2490    {
2491      func_help noexit
2492      for opt_mode in compile link execute install finish uninstall clean; do
2493	func_mode_help
2494      done
2495    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
2496    {
2497      func_help noexit
2498      for opt_mode in compile link execute install finish uninstall clean; do
2499	echo
2500	func_mode_help
2501      done
2502    } |
2503    sed '1d
2504      /^When reporting/,/^Report/{
2505	H
2506	d
2507      }
2508      $x
2509      /information about other modes/d
2510      /more detailed .*MODE/d
2511      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
2512  fi
2513  exit $?
2514fi
2515
2516
2517# func_mode_execute arg...
2518func_mode_execute ()
2519{
2520    $opt_debug
2521    # The first argument is the command name.
2522    cmd="$nonopt"
2523    test -z "$cmd" && \
2524      func_fatal_help "you must specify a COMMAND"
2525
2526    # Handle -dlopen flags immediately.
2527    for file in $opt_dlopen; do
2528      test -f "$file" \
2529	|| func_fatal_help "\`$file' is not a file"
2530
2531      dir=
2532      case $file in
2533      *.la)
2534	func_resolve_sysroot "$file"
2535	file=$func_resolve_sysroot_result
2536
2537	# Check to see that this really is a libtool archive.
2538	func_lalib_unsafe_p "$file" \
2539	  || func_fatal_help "\`$lib' is not a valid libtool archive"
2540
2541	# Read the libtool library.
2542	dlname=
2543	library_names=
2544	func_source "$file"
2545
2546	# Skip this library if it cannot be dlopened.
2547	if test -z "$dlname"; then
2548	  # Warn if it was a shared library.
2549	  test -n "$library_names" && \
2550	    func_warning "\`$file' was not linked with \`-export-dynamic'"
2551	  continue
2552	fi
2553
2554	func_dirname "$file" "" "."
2555	dir="$func_dirname_result"
2556
2557	if test -f "$dir/$objdir/$dlname"; then
2558	  func_append dir "/$objdir"
2559	else
2560	  if test ! -f "$dir/$dlname"; then
2561	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
2562	  fi
2563	fi
2564	;;
2565
2566      *.lo)
2567	# Just add the directory containing the .lo file.
2568	func_dirname "$file" "" "."
2569	dir="$func_dirname_result"
2570	;;
2571
2572      *)
2573	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
2574	continue
2575	;;
2576      esac
2577
2578      # Get the absolute pathname.
2579      absdir=`cd "$dir" && pwd`
2580      test -n "$absdir" && dir="$absdir"
2581
2582      # Now add the directory to shlibpath_var.
2583      if eval "test -z \"\$$shlibpath_var\""; then
2584	eval "$shlibpath_var=\"\$dir\""
2585      else
2586	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
2587      fi
2588    done
2589
2590    # This variable tells wrapper scripts just to set shlibpath_var
2591    # rather than running their programs.
2592    libtool_execute_magic="$magic"
2593
2594    # Check if any of the arguments is a wrapper script.
2595    args=
2596    for file
2597    do
2598      case $file in
2599      -* | *.la | *.lo ) ;;
2600      *)
2601	# Do a test to see if this is really a libtool program.
2602	if func_ltwrapper_script_p "$file"; then
2603	  func_source "$file"
2604	  # Transform arg to wrapped name.
2605	  file="$progdir/$program"
2606	elif func_ltwrapper_executable_p "$file"; then
2607	  func_ltwrapper_scriptname "$file"
2608	  func_source "$func_ltwrapper_scriptname_result"
2609	  # Transform arg to wrapped name.
2610	  file="$progdir/$program"
2611	fi
2612	;;
2613      esac
2614      # Quote arguments (to preserve shell metacharacters).
2615      func_append_quoted args "$file"
2616    done
2617
2618    if test "X$opt_dry_run" = Xfalse; then
2619      if test -n "$shlibpath_var"; then
2620	# Export the shlibpath_var.
2621	eval "export $shlibpath_var"
2622      fi
2623
2624      # Restore saved environment variables
2625      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
2626      do
2627	eval "if test \"\${save_$lt_var+set}\" = set; then
2628                $lt_var=\$save_$lt_var; export $lt_var
2629	      else
2630		$lt_unset $lt_var
2631	      fi"
2632      done
2633
2634      # Now prepare to actually exec the command.
2635      exec_cmd="\$cmd$args"
2636    else
2637      # Display what would be done.
2638      if test -n "$shlibpath_var"; then
2639	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
2640	echo "export $shlibpath_var"
2641      fi
2642      $ECHO "$cmd$args"
2643      exit $EXIT_SUCCESS
2644    fi
2645}
2646
2647test "$opt_mode" = execute && func_mode_execute ${1+"$@"}
2648
2649
2650# func_mode_finish arg...
2651func_mode_finish ()
2652{
2653    $opt_debug
2654    libs=
2655    libdirs=
2656    admincmds=
2657
2658    for opt in "$nonopt" ${1+"$@"}
2659    do
2660      if test -d "$opt"; then
2661	func_append libdirs " $opt"
2662
2663      elif test -f "$opt"; then
2664	if func_lalib_unsafe_p "$opt"; then
2665	  func_append libs " $opt"
2666	else
2667	  func_warning "\`$opt' is not a valid libtool archive"
2668	fi
2669
2670      else
2671	func_fatal_error "invalid argument \`$opt'"
2672      fi
2673    done
2674
2675    if test -n "$libs"; then
2676      if test -n "$lt_sysroot"; then
2677        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
2678        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
2679      else
2680        sysroot_cmd=
2681      fi
2682
2683      # Remove sysroot references
2684      if $opt_dry_run; then
2685        for lib in $libs; do
2686          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
2687        done
2688      else
2689        tmpdir=`func_mktempdir`
2690        for lib in $libs; do
2691	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
2692	    > $tmpdir/tmp-la
2693	  mv -f $tmpdir/tmp-la $lib
2694	done
2695        ${RM}r "$tmpdir"
2696      fi
2697    fi
2698
2699    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2700      for libdir in $libdirs; do
2701	if test -n "$finish_cmds"; then
2702	  # Do each command in the finish commands.
2703	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
2704'"$cmd"'"'
2705	fi
2706	if test -n "$finish_eval"; then
2707	  # Do the single finish_eval.
2708	  eval cmds=\"$finish_eval\"
2709	  $opt_dry_run || eval "$cmds" || func_append admincmds "
2710       $cmds"
2711	fi
2712      done
2713    fi
2714
2715    # Exit here if they wanted silent mode.
2716    $opt_silent && exit $EXIT_SUCCESS
2717
2718    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2719      echo "----------------------------------------------------------------------"
2720      echo "Libraries have been installed in:"
2721      for libdir in $libdirs; do
2722	$ECHO "   $libdir"
2723      done
2724      echo
2725      echo "If you ever happen to want to link against installed libraries"
2726      echo "in a given directory, LIBDIR, you must either use libtool, and"
2727      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
2728      echo "flag during linking and do at least one of the following:"
2729      if test -n "$shlibpath_var"; then
2730	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
2731	echo "     during execution"
2732      fi
2733      if test -n "$runpath_var"; then
2734	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
2735	echo "     during linking"
2736      fi
2737      if test -n "$hardcode_libdir_flag_spec"; then
2738	libdir=LIBDIR
2739	eval flag=\"$hardcode_libdir_flag_spec\"
2740
2741	$ECHO "   - use the \`$flag' linker flag"
2742      fi
2743      if test -n "$admincmds"; then
2744	$ECHO "   - have your system administrator run these commands:$admincmds"
2745      fi
2746      if test -f /etc/ld.so.conf; then
2747	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
2748      fi
2749      echo
2750
2751      echo "See any operating system documentation about shared libraries for"
2752      case $host in
2753	solaris2.[6789]|solaris2.1[0-9])
2754	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
2755	  echo "pages."
2756	  ;;
2757	*)
2758	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
2759	  ;;
2760      esac
2761      echo "----------------------------------------------------------------------"
2762    fi
2763    exit $EXIT_SUCCESS
2764}
2765
2766test "$opt_mode" = finish && func_mode_finish ${1+"$@"}
2767
2768
2769# func_mode_install arg...
2770func_mode_install ()
2771{
2772    $opt_debug
2773    # There may be an optional sh(1) argument at the beginning of
2774    # install_prog (especially on Windows NT).
2775    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
2776       # Allow the use of GNU shtool's install command.
2777       case $nonopt in *shtool*) :;; *) false;; esac; then
2778      # Aesthetically quote it.
2779      func_quote_for_eval "$nonopt"
2780      install_prog="$func_quote_for_eval_result "
2781      arg=$1
2782      shift
2783    else
2784      install_prog=
2785      arg=$nonopt
2786    fi
2787
2788    # The real first argument should be the name of the installation program.
2789    # Aesthetically quote it.
2790    func_quote_for_eval "$arg"
2791    func_append install_prog "$func_quote_for_eval_result"
2792    install_shared_prog=$install_prog
2793    case " $install_prog " in
2794      *[\\\ /]cp\ *) install_cp=: ;;
2795      *) install_cp=false ;;
2796    esac
2797
2798    # We need to accept at least all the BSD install flags.
2799    dest=
2800    files=
2801    opts=
2802    prev=
2803    install_type=
2804    isdir=no
2805    stripme=
2806    no_mode=:
2807    for arg
2808    do
2809      arg2=
2810      if test -n "$dest"; then
2811	func_append files " $dest"
2812	dest=$arg
2813	continue
2814      fi
2815
2816      case $arg in
2817      -d) isdir=yes ;;
2818      -f)
2819	if $install_cp; then :; else
2820	  prev=$arg
2821	fi
2822	;;
2823      -g | -m | -o)
2824	prev=$arg
2825	;;
2826      -s)
2827	stripme=" -s"
2828	continue
2829	;;
2830      -*)
2831	;;
2832      *)
2833	# If the previous option needed an argument, then skip it.
2834	if test -n "$prev"; then
2835	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
2836	    arg2=$install_override_mode
2837	    no_mode=false
2838	  fi
2839	  prev=
2840	else
2841	  dest=$arg
2842	  continue
2843	fi
2844	;;
2845      esac
2846
2847      # Aesthetically quote the argument.
2848      func_quote_for_eval "$arg"
2849      func_append install_prog " $func_quote_for_eval_result"
2850      if test -n "$arg2"; then
2851	func_quote_for_eval "$arg2"
2852      fi
2853      func_append install_shared_prog " $func_quote_for_eval_result"
2854    done
2855
2856    test -z "$install_prog" && \
2857      func_fatal_help "you must specify an install program"
2858
2859    test -n "$prev" && \
2860      func_fatal_help "the \`$prev' option requires an argument"
2861
2862    if test -n "$install_override_mode" && $no_mode; then
2863      if $install_cp; then :; else
2864	func_quote_for_eval "$install_override_mode"
2865	func_append install_shared_prog " -m $func_quote_for_eval_result"
2866      fi
2867    fi
2868
2869    if test -z "$files"; then
2870      if test -z "$dest"; then
2871	func_fatal_help "no file or destination specified"
2872      else
2873	func_fatal_help "you must specify a destination"
2874      fi
2875    fi
2876
2877    # Strip any trailing slash from the destination.
2878    func_stripname '' '/' "$dest"
2879    dest=$func_stripname_result
2880
2881    # Check to see that the destination is a directory.
2882    test -d "$dest" && isdir=yes
2883    if test "$isdir" = yes; then
2884      destdir="$dest"
2885      destname=
2886    else
2887      func_dirname_and_basename "$dest" "" "."
2888      destdir="$func_dirname_result"
2889      destname="$func_basename_result"
2890
2891      # Not a directory, so check to see that there is only one file specified.
2892      set dummy $files; shift
2893      test "$#" -gt 1 && \
2894	func_fatal_help "\`$dest' is not a directory"
2895    fi
2896    case $destdir in
2897    [\\/]* | [A-Za-z]:[\\/]*) ;;
2898    *)
2899      for file in $files; do
2900	case $file in
2901	*.lo) ;;
2902	*)
2903	  func_fatal_help "\`$destdir' must be an absolute directory name"
2904	  ;;
2905	esac
2906      done
2907      ;;
2908    esac
2909
2910    # This variable tells wrapper scripts just to set variables rather
2911    # than running their programs.
2912    libtool_install_magic="$magic"
2913
2914    staticlibs=
2915    future_libdirs=
2916    current_libdirs=
2917    for file in $files; do
2918
2919      # Do each installation.
2920      case $file in
2921      *.$libext)
2922	# Do the static libraries later.
2923	func_append staticlibs " $file"
2924	;;
2925
2926      *.la)
2927	func_resolve_sysroot "$file"
2928	file=$func_resolve_sysroot_result
2929
2930	# Check to see that this really is a libtool archive.
2931	func_lalib_unsafe_p "$file" \
2932	  || func_fatal_help "\`$file' is not a valid libtool archive"
2933
2934	library_names=
2935	old_library=
2936	relink_command=
2937	func_source "$file"
2938
2939	# Add the libdir to current_libdirs if it is the destination.
2940	if test "X$destdir" = "X$libdir"; then
2941	  case "$current_libdirs " in
2942	  *" $libdir "*) ;;
2943	  *) func_append current_libdirs " $libdir" ;;
2944	  esac
2945	else
2946	  # Note the libdir as a future libdir.
2947	  case "$future_libdirs " in
2948	  *" $libdir "*) ;;
2949	  *) func_append future_libdirs " $libdir" ;;
2950	  esac
2951	fi
2952
2953	func_dirname "$file" "/" ""
2954	dir="$func_dirname_result"
2955	func_append dir "$objdir"
2956
2957	if test -n "$relink_command"; then
2958	  # Determine the prefix the user has applied to our future dir.
2959	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
2960
2961	  # Don't allow the user to place us outside of our expected
2962	  # location b/c this prevents finding dependent libraries that
2963	  # are installed to the same prefix.
2964	  # At present, this check doesn't affect windows .dll's that
2965	  # are installed into $libdir/../bin (currently, that works fine)
2966	  # but it's something to keep an eye on.
2967	  test "$inst_prefix_dir" = "$destdir" && \
2968	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2969
2970	  if test -n "$inst_prefix_dir"; then
2971	    # Stick the inst_prefix_dir data into the link command.
2972	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2973	  else
2974	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
2975	  fi
2976
2977	  func_warning "relinking \`$file'"
2978	  func_show_eval "$relink_command" \
2979	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2980	fi
2981
2982	# See the names of the shared library.
2983	set dummy $library_names; shift
2984	if test -n "$1"; then
2985	  realname="$1"
2986	  shift
2987
2988	  srcname="$realname"
2989	  test -n "$relink_command" && srcname="$realname"T
2990
2991	  # Install the shared library and build the symlinks.
2992	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
2993	      'exit $?'
2994	  tstripme="$stripme"
2995	  case $host_os in
2996	  cygwin* | mingw* | pw32* | cegcc*)
2997	    case $realname in
2998	    *.dll.a)
2999	      tstripme=""
3000	      ;;
3001	    esac
3002	    ;;
3003	  esac
3004	  if test -n "$tstripme" && test -n "$striplib"; then
3005	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
3006	  fi
3007
3008	  if test "$#" -gt 0; then
3009	    # Delete the old symlinks, and create new ones.
3010	    # Try `ln -sf' first, because the `ln' binary might depend on
3011	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
3012	    # so we also need to try rm && ln -s.
3013	    for linkname
3014	    do
3015	      test "$linkname" != "$realname" \
3016		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
3017	    done
3018	  fi
3019
3020	  # Do each command in the postinstall commands.
3021	  lib="$destdir/$realname"
3022	  func_execute_cmds "$postinstall_cmds" 'exit $?'
3023	fi
3024
3025	# Install the pseudo-library for information purposes.
3026	func_basename "$file"
3027	name="$func_basename_result"
3028	instname="$dir/$name"i
3029	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
3030
3031	# Maybe install the static library, too.
3032	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
3033	;;
3034
3035      *.lo)
3036	# Install (i.e. copy) a libtool object.
3037
3038	# Figure out destination file name, if it wasn't already specified.
3039	if test -n "$destname"; then
3040	  destfile="$destdir/$destname"
3041	else
3042	  func_basename "$file"
3043	  destfile="$func_basename_result"
3044	  destfile="$destdir/$destfile"
3045	fi
3046
3047	# Deduce the name of the destination old-style object file.
3048	case $destfile in
3049	*.lo)
3050	  func_lo2o "$destfile"
3051	  staticdest=$func_lo2o_result
3052	  ;;
3053	*.$objext)
3054	  staticdest="$destfile"
3055	  destfile=
3056	  ;;
3057	*)
3058	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
3059	  ;;
3060	esac
3061
3062	# Install the libtool object if requested.
3063	test -n "$destfile" && \
3064	  func_show_eval "$install_prog $file $destfile" 'exit $?'
3065
3066	# Install the old object if enabled.
3067	if test "$build_old_libs" = yes; then
3068	  # Deduce the name of the old-style object file.
3069	  func_lo2o "$file"
3070	  staticobj=$func_lo2o_result
3071	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
3072	fi
3073	exit $EXIT_SUCCESS
3074	;;
3075
3076      *)
3077	# Figure out destination file name, if it wasn't already specified.
3078	if test -n "$destname"; then
3079	  destfile="$destdir/$destname"
3080	else
3081	  func_basename "$file"
3082	  destfile="$func_basename_result"
3083	  destfile="$destdir/$destfile"
3084	fi
3085
3086	# If the file is missing, and there is a .exe on the end, strip it
3087	# because it is most likely a libtool script we actually want to
3088	# install
3089	stripped_ext=""
3090	case $file in
3091	  *.exe)
3092	    if test ! -f "$file"; then
3093	      func_stripname '' '.exe' "$file"
3094	      file=$func_stripname_result
3095	      stripped_ext=".exe"
3096	    fi
3097	    ;;
3098	esac
3099
3100	# Do a test to see if this is really a libtool program.
3101	case $host in
3102	*cygwin* | *mingw*)
3103	    if func_ltwrapper_executable_p "$file"; then
3104	      func_ltwrapper_scriptname "$file"
3105	      wrapper=$func_ltwrapper_scriptname_result
3106	    else
3107	      func_stripname '' '.exe' "$file"
3108	      wrapper=$func_stripname_result
3109	    fi
3110	    ;;
3111	*)
3112	    wrapper=$file
3113	    ;;
3114	esac
3115	if func_ltwrapper_script_p "$wrapper"; then
3116	  notinst_deplibs=
3117	  relink_command=
3118
3119	  func_source "$wrapper"
3120
3121	  # Check the variables that should have been set.
3122	  test -z "$generated_by_libtool_version" && \
3123	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
3124
3125	  finalize=yes
3126	  for lib in $notinst_deplibs; do
3127	    # Check to see that each library is installed.
3128	    libdir=
3129	    if test -f "$lib"; then
3130	      func_source "$lib"
3131	    fi
3132	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
3133	    if test -n "$libdir" && test ! -f "$libfile"; then
3134	      func_warning "\`$lib' has not been installed in \`$libdir'"
3135	      finalize=no
3136	    fi
3137	  done
3138
3139	  relink_command=
3140	  func_source "$wrapper"
3141
3142	  outputname=
3143	  if test "$fast_install" = no && test -n "$relink_command"; then
3144	    $opt_dry_run || {
3145	      if test "$finalize" = yes; then
3146	        tmpdir=`func_mktempdir`
3147		func_basename "$file$stripped_ext"
3148		file="$func_basename_result"
3149	        outputname="$tmpdir/$file"
3150	        # Replace the output file specification.
3151	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
3152
3153	        $opt_silent || {
3154	          func_quote_for_expand "$relink_command"
3155		  eval "func_echo $func_quote_for_expand_result"
3156	        }
3157	        if eval "$relink_command"; then :
3158	          else
3159		  func_error "error: relink \`$file' with the above command before installing it"
3160		  $opt_dry_run || ${RM}r "$tmpdir"
3161		  continue
3162	        fi
3163	        file="$outputname"
3164	      else
3165	        func_warning "cannot relink \`$file'"
3166	      fi
3167	    }
3168	  else
3169	    # Install the binary that we compiled earlier.
3170	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
3171	  fi
3172	fi
3173
3174	# remove .exe since cygwin /usr/bin/install will append another
3175	# one anyway
3176	case $install_prog,$host in
3177	*/usr/bin/install*,*cygwin*)
3178	  case $file:$destfile in
3179	  *.exe:*.exe)
3180	    # this is ok
3181	    ;;
3182	  *.exe:*)
3183	    destfile=$destfile.exe
3184	    ;;
3185	  *:*.exe)
3186	    func_stripname '' '.exe' "$destfile"
3187	    destfile=$func_stripname_result
3188	    ;;
3189	  esac
3190	  ;;
3191	esac
3192	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
3193	$opt_dry_run || if test -n "$outputname"; then
3194	  ${RM}r "$tmpdir"
3195	fi
3196	;;
3197      esac
3198    done
3199
3200    for file in $staticlibs; do
3201      func_basename "$file"
3202      name="$func_basename_result"
3203
3204      # Set up the ranlib parameters.
3205      oldlib="$destdir/$name"
3206      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
3207      tool_oldlib=$func_to_tool_file_result
3208
3209      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
3210
3211      if test -n "$stripme" && test -n "$old_striplib"; then
3212	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
3213      fi
3214
3215      # Do each command in the postinstall commands.
3216      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
3217    done
3218
3219    test -n "$future_libdirs" && \
3220      func_warning "remember to run \`$progname --finish$future_libdirs'"
3221
3222    if test -n "$current_libdirs"; then
3223      # Maybe just do a dry run.
3224      $opt_dry_run && current_libdirs=" -n$current_libdirs"
3225      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
3226    else
3227      exit $EXIT_SUCCESS
3228    fi
3229}
3230
3231test "$opt_mode" = install && func_mode_install ${1+"$@"}
3232
3233
3234# func_generate_dlsyms outputname originator pic_p
3235# Extract symbols from dlprefiles and create ${outputname}S.o with
3236# a dlpreopen symbol table.
3237func_generate_dlsyms ()
3238{
3239    $opt_debug
3240    my_outputname="$1"
3241    my_originator="$2"
3242    my_pic_p="${3-no}"
3243    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
3244    my_dlsyms=
3245
3246    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
3247      if test -n "$NM" && test -n "$global_symbol_pipe"; then
3248	my_dlsyms="${my_outputname}S.c"
3249      else
3250	func_error "not configured to extract global symbols from dlpreopened files"
3251      fi
3252    fi
3253
3254    if test -n "$my_dlsyms"; then
3255      case $my_dlsyms in
3256      "") ;;
3257      *.c)
3258	# Discover the nlist of each of the dlfiles.
3259	nlist="$output_objdir/${my_outputname}.nm"
3260
3261	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
3262
3263	# Parse the name list into a source file.
3264	func_verbose "creating $output_objdir/$my_dlsyms"
3265
3266	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
3267/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
3268/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
3269
3270#ifdef __cplusplus
3271extern \"C\" {
3272#endif
3273
3274#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
3275#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
3276#endif
3277
3278/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
3279#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
3280/* DATA imports from DLLs on WIN32 con't be const, because runtime
3281   relocations are performed -- see ld's documentation on pseudo-relocs.  */
3282# define LT_DLSYM_CONST
3283#elif defined(__osf__)
3284/* This system does not cope well with relocations in const data.  */
3285# define LT_DLSYM_CONST
3286#else
3287# define LT_DLSYM_CONST const
3288#endif
3289
3290/* External symbol declarations for the compiler. */\
3291"
3292
3293	if test "$dlself" = yes; then
3294	  func_verbose "generating symbol list for \`$output'"
3295
3296	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
3297
3298	  # Add our own program objects to the symbol list.
3299	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
3300	  for progfile in $progfiles; do
3301	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
3302	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
3303	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
3304	  done
3305
3306	  if test -n "$exclude_expsyms"; then
3307	    $opt_dry_run || {
3308	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
3309	      eval '$MV "$nlist"T "$nlist"'
3310	    }
3311	  fi
3312
3313	  if test -n "$export_symbols_regex"; then
3314	    $opt_dry_run || {
3315	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
3316	      eval '$MV "$nlist"T "$nlist"'
3317	    }
3318	  fi
3319
3320	  # Prepare the list of exported symbols
3321	  if test -z "$export_symbols"; then
3322	    export_symbols="$output_objdir/$outputname.exp"
3323	    $opt_dry_run || {
3324	      $RM $export_symbols
3325	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
3326	      case $host in
3327	      *cygwin* | *mingw* | *cegcc* )
3328                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3329                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
3330	        ;;
3331	      esac
3332	    }
3333	  else
3334	    $opt_dry_run || {
3335	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
3336	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
3337	      eval '$MV "$nlist"T "$nlist"'
3338	      case $host in
3339	        *cygwin* | *mingw* | *cegcc* )
3340	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3341	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
3342	          ;;
3343	      esac
3344	    }
3345	  fi
3346	fi
3347
3348	for dlprefile in $dlprefiles; do
3349	  func_verbose "extracting global C symbols from \`$dlprefile'"
3350	  func_basename "$dlprefile"
3351	  name="$func_basename_result"
3352          case $host in
3353	    *cygwin* | *mingw* | *cegcc* )
3354	      # if an import library, we need to obtain dlname
3355	      if func_win32_import_lib_p "$dlprefile"; then
3356	        func_tr_sh "$dlprefile"
3357	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
3358	        dlprefile_dlbasename=""
3359	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
3360	          # Use subshell, to avoid clobbering current variable values
3361	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
3362	          if test -n "$dlprefile_dlname" ; then
3363	            func_basename "$dlprefile_dlname"
3364	            dlprefile_dlbasename="$func_basename_result"
3365	          else
3366	            # no lafile. user explicitly requested -dlpreopen <import library>.
3367	            $sharedlib_from_linklib_cmd "$dlprefile"
3368	            dlprefile_dlbasename=$sharedlib_from_linklib_result
3369	          fi
3370	        fi
3371	        $opt_dry_run || {
3372	          if test -n "$dlprefile_dlbasename" ; then
3373	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
3374	          else
3375	            func_warning "Could not compute DLL name from $name"
3376	            eval '$ECHO ": $name " >> "$nlist"'
3377	          fi
3378	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3379	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
3380	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
3381	        }
3382	      else # not an import lib
3383	        $opt_dry_run || {
3384	          eval '$ECHO ": $name " >> "$nlist"'
3385	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3386	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3387	        }
3388	      fi
3389	    ;;
3390	    *)
3391	      $opt_dry_run || {
3392	        eval '$ECHO ": $name " >> "$nlist"'
3393	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3394	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3395	      }
3396	    ;;
3397          esac
3398	done
3399
3400	$opt_dry_run || {
3401	  # Make sure we have at least an empty file.
3402	  test -f "$nlist" || : > "$nlist"
3403
3404	  if test -n "$exclude_expsyms"; then
3405	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
3406	    $MV "$nlist"T "$nlist"
3407	  fi
3408
3409	  # Try sorting and uniquifying the output.
3410	  if $GREP -v "^: " < "$nlist" |
3411	      if sort -k 3 </dev/null >/dev/null 2>&1; then
3412		sort -k 3
3413	      else
3414		sort +2
3415	      fi |
3416	      uniq > "$nlist"S; then
3417	    :
3418	  else
3419	    $GREP -v "^: " < "$nlist" > "$nlist"S
3420	  fi
3421
3422	  if test -f "$nlist"S; then
3423	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
3424	  else
3425	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
3426	  fi
3427
3428	  echo >> "$output_objdir/$my_dlsyms" "\
3429
3430/* The mapping between symbol names and symbols.  */
3431typedef struct {
3432  const char *name;
3433  void *address;
3434} lt_dlsymlist;
3435extern LT_DLSYM_CONST lt_dlsymlist
3436lt_${my_prefix}_LTX_preloaded_symbols[];
3437LT_DLSYM_CONST lt_dlsymlist
3438lt_${my_prefix}_LTX_preloaded_symbols[] =
3439{\
3440  { \"$my_originator\", (void *) 0 },"
3441
3442	  case $need_lib_prefix in
3443	  no)
3444	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
3445	    ;;
3446	  *)
3447	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
3448	    ;;
3449	  esac
3450	  echo >> "$output_objdir/$my_dlsyms" "\
3451  {0, (void *) 0}
3452};
3453
3454/* This works around a problem in FreeBSD linker */
3455#ifdef FREEBSD_WORKAROUND
3456static const void *lt_preloaded_setup() {
3457  return lt_${my_prefix}_LTX_preloaded_symbols;
3458}
3459#endif
3460
3461#ifdef __cplusplus
3462}
3463#endif\
3464"
3465	} # !$opt_dry_run
3466
3467	pic_flag_for_symtable=
3468	case "$compile_command " in
3469	*" -static "*) ;;
3470	*)
3471	  case $host in
3472	  # compiling the symbol table file with pic_flag works around
3473	  # a FreeBSD bug that causes programs to crash when -lm is
3474	  # linked before any other PIC object.  But we must not use
3475	  # pic_flag when linking with -static.  The problem exists in
3476	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
3477	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
3478	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
3479	  *-*-hpux*)
3480	    pic_flag_for_symtable=" $pic_flag"  ;;
3481	  *)
3482	    if test "X$my_pic_p" != Xno; then
3483	      pic_flag_for_symtable=" $pic_flag"
3484	    fi
3485	    ;;
3486	  esac
3487	  ;;
3488	esac
3489	symtab_cflags=
3490	for arg in $LTCFLAGS; do
3491	  case $arg in
3492	  -pie | -fpie | -fPIE) ;;
3493	  *) func_append symtab_cflags " $arg" ;;
3494	  esac
3495	done
3496
3497	# Now compile the dynamic symbol file.
3498	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
3499
3500	# Clean up the generated files.
3501	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
3502
3503	# Transform the symbol file into the correct name.
3504	symfileobj="$output_objdir/${my_outputname}S.$objext"
3505	case $host in
3506	*cygwin* | *mingw* | *cegcc* )
3507	  if test -f "$output_objdir/$my_outputname.def"; then
3508	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3509	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3510	  else
3511	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3512	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3513	  fi
3514	  ;;
3515	*)
3516	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3517	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3518	  ;;
3519	esac
3520	;;
3521      *)
3522	func_fatal_error "unknown suffix for \`$my_dlsyms'"
3523	;;
3524      esac
3525    else
3526      # We keep going just in case the user didn't refer to
3527      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
3528      # really was required.
3529
3530      # Nullify the symbol file.
3531      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
3532      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
3533    fi
3534}
3535
3536# func_win32_libid arg
3537# return the library type of file 'arg'
3538#
3539# Need a lot of goo to handle *both* DLLs and import libs
3540# Has to be a shell function in order to 'eat' the argument
3541# that is supplied when $file_magic_command is called.
3542# Despite the name, also deal with 64 bit binaries.
3543func_win32_libid ()
3544{
3545  $opt_debug
3546  win32_libid_type="unknown"
3547  win32_fileres=`file -L $1 2>/dev/null`
3548  case $win32_fileres in
3549  *ar\ archive\ import\ library*) # definitely import
3550    win32_libid_type="x86 archive import"
3551    ;;
3552  *ar\ archive*) # could be an import, or static
3553    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
3554    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
3555       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
3556      func_to_tool_file "$1" func_convert_file_msys_to_w32
3557      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
3558	$SED -n -e '
3559	    1,100{
3560		/ I /{
3561		    s,.*,import,
3562		    p
3563		    q
3564		}
3565	    }'`
3566      case $win32_nmres in
3567      import*)  win32_libid_type="x86 archive import";;
3568      *)        win32_libid_type="x86 archive static";;
3569      esac
3570    fi
3571    ;;
3572  *DLL*)
3573    win32_libid_type="x86 DLL"
3574    ;;
3575  *executable*) # but shell scripts are "executable" too...
3576    case $win32_fileres in
3577    *MS\ Windows\ PE\ Intel*)
3578      win32_libid_type="x86 DLL"
3579      ;;
3580    esac
3581    ;;
3582  esac
3583  $ECHO "$win32_libid_type"
3584}
3585
3586# func_cygming_dll_for_implib ARG
3587#
3588# Platform-specific function to extract the
3589# name of the DLL associated with the specified
3590# import library ARG.
3591# Invoked by eval'ing the libtool variable
3592#    $sharedlib_from_linklib_cmd
3593# Result is available in the variable
3594#    $sharedlib_from_linklib_result
3595func_cygming_dll_for_implib ()
3596{
3597  $opt_debug
3598  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
3599}
3600
3601# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
3602#
3603# The is the core of a fallback implementation of a
3604# platform-specific function to extract the name of the
3605# DLL associated with the specified import library LIBNAME.
3606#
3607# SECTION_NAME is either .idata$6 or .idata$7, depending
3608# on the platform and compiler that created the implib.
3609#
3610# Echos the name of the DLL associated with the
3611# specified import library.
3612func_cygming_dll_for_implib_fallback_core ()
3613{
3614  $opt_debug
3615  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
3616  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
3617    $SED '/^Contents of section '"$match_literal"':/{
3618      # Place marker at beginning of archive member dllname section
3619      s/.*/====MARK====/
3620      p
3621      d
3622    }
3623    # These lines can sometimes be longer than 43 characters, but
3624    # are always uninteresting
3625    /:[	 ]*file format pe[i]\{,1\}-/d
3626    /^In archive [^:]*:/d
3627    # Ensure marker is printed
3628    /^====MARK====/p
3629    # Remove all lines with less than 43 characters
3630    /^.\{43\}/!d
3631    # From remaining lines, remove first 43 characters
3632    s/^.\{43\}//' |
3633    $SED -n '
3634      # Join marker and all lines until next marker into a single line
3635      /^====MARK====/ b para
3636      H
3637      $ b para
3638      b
3639      :para
3640      x
3641      s/\n//g
3642      # Remove the marker
3643      s/^====MARK====//
3644      # Remove trailing dots and whitespace
3645      s/[\. \t]*$//
3646      # Print
3647      /./p' |
3648    # we now have a list, one entry per line, of the stringified
3649    # contents of the appropriate section of all members of the
3650    # archive which possess that section. Heuristic: eliminate
3651    # all those which have a first or second character that is
3652    # a '.' (that is, objdump's representation of an unprintable
3653    # character.) This should work for all archives with less than
3654    # 0x302f exports -- but will fail for DLLs whose name actually
3655    # begins with a literal '.' or a single character followed by
3656    # a '.'.
3657    #
3658    # Of those that remain, print the first one.
3659    $SED -e '/^\./d;/^.\./d;q'
3660}
3661
3662# func_cygming_gnu_implib_p ARG
3663# This predicate returns with zero status (TRUE) if
3664# ARG is a GNU/binutils-style import library. Returns
3665# with nonzero status (FALSE) otherwise.
3666func_cygming_gnu_implib_p ()
3667{
3668  $opt_debug
3669  func_to_tool_file "$1" func_convert_file_msys_to_w32
3670  func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`
3671  test -n "$func_cygming_gnu_implib_tmp"
3672}
3673
3674# func_cygming_ms_implib_p ARG
3675# This predicate returns with zero status (TRUE) if
3676# ARG is an MS-style import library. Returns
3677# with nonzero status (FALSE) otherwise.
3678func_cygming_ms_implib_p ()
3679{
3680  $opt_debug
3681  func_to_tool_file "$1" func_convert_file_msys_to_w32
3682  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
3683  test -n "$func_cygming_ms_implib_tmp"
3684}
3685
3686# func_cygming_dll_for_implib_fallback ARG
3687# Platform-specific function to extract the
3688# name of the DLL associated with the specified
3689# import library ARG.
3690#
3691# This fallback implementation is for use when $DLLTOOL
3692# does not support the --identify-strict option.
3693# Invoked by eval'ing the libtool variable
3694#    $sharedlib_from_linklib_cmd
3695# Result is available in the variable
3696#    $sharedlib_from_linklib_result
3697func_cygming_dll_for_implib_fallback ()
3698{
3699  $opt_debug
3700  if func_cygming_gnu_implib_p "$1" ; then
3701    # binutils import library
3702    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
3703  elif func_cygming_ms_implib_p "$1" ; then
3704    # ms-generated import library
3705    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
3706  else
3707    # unknown
3708    sharedlib_from_linklib_result=""
3709  fi
3710}
3711
3712
3713# func_extract_an_archive dir oldlib
3714func_extract_an_archive ()
3715{
3716    $opt_debug
3717    f_ex_an_ar_dir="$1"; shift
3718    f_ex_an_ar_oldlib="$1"
3719    if test "$lock_old_archive_extraction" = yes; then
3720      lockfile=$f_ex_an_ar_oldlib.lock
3721      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
3722	func_echo "Waiting for $lockfile to be removed"
3723	sleep 2
3724      done
3725    fi
3726    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
3727		   'stat=$?; rm -f "$lockfile"; exit $stat'
3728    if test "$lock_old_archive_extraction" = yes; then
3729      $opt_dry_run || rm -f "$lockfile"
3730    fi
3731    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
3732     :
3733    else
3734      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
3735    fi
3736}
3737
3738
3739# func_extract_archives gentop oldlib ...
3740func_extract_archives ()
3741{
3742    $opt_debug
3743    my_gentop="$1"; shift
3744    my_oldlibs=${1+"$@"}
3745    my_oldobjs=""
3746    my_xlib=""
3747    my_xabs=""
3748    my_xdir=""
3749
3750    for my_xlib in $my_oldlibs; do
3751      # Extract the objects.
3752      case $my_xlib in
3753	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
3754	*) my_xabs=`pwd`"/$my_xlib" ;;
3755      esac
3756      func_basename "$my_xlib"
3757      my_xlib="$func_basename_result"
3758      my_xlib_u=$my_xlib
3759      while :; do
3760        case " $extracted_archives " in
3761	*" $my_xlib_u "*)
3762	  func_arith $extracted_serial + 1
3763	  extracted_serial=$func_arith_result
3764	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
3765	*) break ;;
3766	esac
3767      done
3768      extracted_archives="$extracted_archives $my_xlib_u"
3769      my_xdir="$my_gentop/$my_xlib_u"
3770
3771      func_mkdir_p "$my_xdir"
3772
3773      case $host in
3774      *-darwin*)
3775	func_verbose "Extracting $my_xabs"
3776	# Do not bother doing anything if just a dry run
3777	$opt_dry_run || {
3778	  darwin_orig_dir=`pwd`
3779	  cd $my_xdir || exit $?
3780	  darwin_archive=$my_xabs
3781	  darwin_curdir=`pwd`
3782	  darwin_base_archive=`basename "$darwin_archive"`
3783	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
3784	  if test -n "$darwin_arches"; then
3785	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
3786	    darwin_arch=
3787	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
3788	    for darwin_arch in  $darwin_arches ; do
3789	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3790	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
3791	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3792	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
3793	      cd "$darwin_curdir"
3794	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
3795	    done # $darwin_arches
3796            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
3797	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
3798	    darwin_file=
3799	    darwin_files=
3800	    for darwin_file in $darwin_filelist; do
3801	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
3802	      $LIPO -create -output "$darwin_file" $darwin_files
3803	    done # $darwin_filelist
3804	    $RM -rf unfat-$$
3805	    cd "$darwin_orig_dir"
3806	  else
3807	    cd $darwin_orig_dir
3808	    func_extract_an_archive "$my_xdir" "$my_xabs"
3809	  fi # $darwin_arches
3810	} # !$opt_dry_run
3811	;;
3812      *)
3813        func_extract_an_archive "$my_xdir" "$my_xabs"
3814	;;
3815      esac
3816      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
3817    done
3818
3819    func_extract_archives_result="$my_oldobjs"
3820}
3821
3822
3823# func_emit_wrapper [arg=no]
3824#
3825# Emit a libtool wrapper script on stdout.
3826# Don't directly open a file because we may want to
3827# incorporate the script contents within a cygwin/mingw
3828# wrapper executable.  Must ONLY be called from within
3829# func_mode_link because it depends on a number of variables
3830# set therein.
3831#
3832# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
3833# variable will take.  If 'yes', then the emitted script
3834# will assume that the directory in which it is stored is
3835# the $objdir directory.  This is a cygwin/mingw-specific
3836# behavior.
3837func_emit_wrapper ()
3838{
3839	func_emit_wrapper_arg1=${1-no}
3840
3841	$ECHO "\
3842#! $SHELL
3843
3844# $output - temporary wrapper script for $objdir/$outputname
3845# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
3846#
3847# The $output program cannot be directly executed until all the libtool
3848# libraries that it depends on are installed.
3849#
3850# This wrapper script should never be moved out of the build directory.
3851# If it is, it will not operate correctly.
3852
3853# Sed substitution that helps us do robust quoting.  It backslashifies
3854# metacharacters that are still active within double-quoted strings.
3855sed_quote_subst='$sed_quote_subst'
3856
3857# Be Bourne compatible
3858if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
3859  emulate sh
3860  NULLCMD=:
3861  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
3862  # is contrary to our usage.  Disable this feature.
3863  alias -g '\${1+\"\$@\"}'='\"\$@\"'
3864  setopt NO_GLOB_SUBST
3865else
3866  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
3867fi
3868BIN_SH=xpg4; export BIN_SH # for Tru64
3869DUALCASE=1; export DUALCASE # for MKS sh
3870
3871# The HP-UX ksh and POSIX shell print the target directory to stdout
3872# if CDPATH is set.
3873(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
3874
3875relink_command=\"$relink_command\"
3876
3877# This environment variable determines our operation mode.
3878if test \"\$libtool_install_magic\" = \"$magic\"; then
3879  # install mode needs the following variables:
3880  generated_by_libtool_version='$macro_version'
3881  notinst_deplibs='$notinst_deplibs'
3882else
3883  # When we are sourced in execute mode, \$file and \$ECHO are already set.
3884  if test \"\$libtool_execute_magic\" != \"$magic\"; then
3885    file=\"\$0\""
3886
3887    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
3888    $ECHO "\
3889
3890# A function that is used when there is no print builtin or printf.
3891func_fallback_echo ()
3892{
3893  eval 'cat <<_LTECHO_EOF
3894\$1
3895_LTECHO_EOF'
3896}
3897    ECHO=\"$qECHO\"
3898  fi
3899
3900# Very basic option parsing. These options are (a) specific to
3901# the libtool wrapper, (b) are identical between the wrapper
3902# /script/ and the wrapper /executable/ which is used only on
3903# windows platforms, and (c) all begin with the string "--lt-"
3904# (application programs are unlikely to have options which match
3905# this pattern).
3906#
3907# There are only two supported options: --lt-debug and
3908# --lt-dump-script. There is, deliberately, no --lt-help.
3909#
3910# The first argument to this parsing function should be the
3911# script's $0 value, followed by "$@".
3912lt_option_debug=
3913func_parse_lt_options ()
3914{
3915  lt_script_arg0=\$0
3916  shift
3917  for lt_opt
3918  do
3919    case \"\$lt_opt\" in
3920    --lt-debug) lt_option_debug=1 ;;
3921    --lt-dump-script)
3922        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
3923        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
3924        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
3925        cat \"\$lt_dump_D/\$lt_dump_F\"
3926        exit 0
3927      ;;
3928    --lt-*)
3929        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
3930        exit 1
3931      ;;
3932    esac
3933  done
3934
3935  # Print the debug banner immediately:
3936  if test -n \"\$lt_option_debug\"; then
3937    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
3938  fi
3939}
3940
3941# Used when --lt-debug. Prints its arguments to stdout
3942# (redirection is the responsibility of the caller)
3943func_lt_dump_args ()
3944{
3945  lt_dump_args_N=1;
3946  for lt_arg
3947  do
3948    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
3949    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
3950  done
3951}
3952
3953# Core function for launching the target application
3954func_exec_program_core ()
3955{
3956"
3957  case $host in
3958  # Backslashes separate directories on plain windows
3959  *-*-mingw | *-*-os2* | *-cegcc*)
3960    $ECHO "\
3961      if test -n \"\$lt_option_debug\"; then
3962        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
3963        func_lt_dump_args \${1+\"\$@\"} 1>&2
3964      fi
3965      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
3966"
3967    ;;
3968
3969  *)
3970    $ECHO "\
3971      if test -n \"\$lt_option_debug\"; then
3972        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
3973        func_lt_dump_args \${1+\"\$@\"} 1>&2
3974      fi
3975      exec \"\$progdir/\$program\" \${1+\"\$@\"}
3976"
3977    ;;
3978  esac
3979  $ECHO "\
3980      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
3981      exit 1
3982}
3983
3984# A function to encapsulate launching the target application
3985# Strips options in the --lt-* namespace from \$@ and
3986# launches target application with the remaining arguments.
3987func_exec_program ()
3988{
3989  case \" \$* \" in
3990  *\\ --lt-*)
3991    for lt_wr_arg
3992    do
3993      case \$lt_wr_arg in
3994      --lt-*) ;;
3995      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
3996      esac
3997      shift
3998    done ;;
3999  esac
4000  func_exec_program_core \${1+\"\$@\"}
4001}
4002
4003  # Parse options
4004  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
4005
4006  # Find the directory that this script lives in.
4007  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
4008  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
4009
4010  # Follow symbolic links until we get to the real thisdir.
4011  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
4012  while test -n \"\$file\"; do
4013    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
4014
4015    # If there was a directory component, then change thisdir.
4016    if test \"x\$destdir\" != \"x\$file\"; then
4017      case \"\$destdir\" in
4018      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
4019      *) thisdir=\"\$thisdir/\$destdir\" ;;
4020      esac
4021    fi
4022
4023    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
4024    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
4025  done
4026
4027  # Usually 'no', except on cygwin/mingw when embedded into
4028  # the cwrapper.
4029  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
4030  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
4031    # special case for '.'
4032    if test \"\$thisdir\" = \".\"; then
4033      thisdir=\`pwd\`
4034    fi
4035    # remove .libs from thisdir
4036    case \"\$thisdir\" in
4037    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
4038    $objdir )   thisdir=. ;;
4039    esac
4040  fi
4041
4042  # Try to get the absolute directory name.
4043  absdir=\`cd \"\$thisdir\" && pwd\`
4044  test -n \"\$absdir\" && thisdir=\"\$absdir\"
4045"
4046
4047	if test "$fast_install" = yes; then
4048	  $ECHO "\
4049  program=lt-'$outputname'$exeext
4050  progdir=\"\$thisdir/$objdir\"
4051
4052  if test ! -f \"\$progdir/\$program\" ||
4053     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
4054       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
4055
4056    file=\"\$\$-\$program\"
4057
4058    if test ! -d \"\$progdir\"; then
4059      $MKDIR \"\$progdir\"
4060    else
4061      $RM \"\$progdir/\$file\"
4062    fi"
4063
4064	  $ECHO "\
4065
4066    # relink executable if necessary
4067    if test -n \"\$relink_command\"; then
4068      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
4069      else
4070	$ECHO \"\$relink_command_output\" >&2
4071	$RM \"\$progdir/\$file\"
4072	exit 1
4073      fi
4074    fi
4075
4076    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
4077    { $RM \"\$progdir/\$program\";
4078      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
4079    $RM \"\$progdir/\$file\"
4080  fi"
4081	else
4082	  $ECHO "\
4083  program='$outputname'
4084  progdir=\"\$thisdir/$objdir\"
4085"
4086	fi
4087
4088	$ECHO "\
4089
4090  if test -f \"\$progdir/\$program\"; then"
4091
4092	# fixup the dll searchpath if we need to.
4093	#
4094	# Fix the DLL searchpath if we need to.  Do this before prepending
4095	# to shlibpath, because on Windows, both are PATH and uninstalled
4096	# libraries must come first.
4097	if test -n "$dllsearchpath"; then
4098	  $ECHO "\
4099    # Add the dll search path components to the executable PATH
4100    PATH=$dllsearchpath:\$PATH
4101"
4102	fi
4103
4104	# Export our shlibpath_var if we have one.
4105	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4106	  $ECHO "\
4107    # Add our own library path to $shlibpath_var
4108    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
4109
4110    # Some systems cannot cope with colon-terminated $shlibpath_var
4111    # The second colon is a workaround for a bug in BeOS R4 sed
4112    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
4113
4114    export $shlibpath_var
4115"
4116	fi
4117
4118	$ECHO "\
4119    if test \"\$libtool_execute_magic\" != \"$magic\"; then
4120      # Run the actual program with our arguments.
4121      func_exec_program \${1+\"\$@\"}
4122    fi
4123  else
4124    # The program doesn't exist.
4125    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
4126    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
4127    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
4128    exit 1
4129  fi
4130fi\
4131"
4132}
4133
4134
4135# func_emit_cwrapperexe_src
4136# emit the source code for a wrapper executable on stdout
4137# Must ONLY be called from within func_mode_link because
4138# it depends on a number of variable set therein.
4139func_emit_cwrapperexe_src ()
4140{
4141	cat <<EOF
4142
4143/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
4144   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
4145
4146   The $output program cannot be directly executed until all the libtool
4147   libraries that it depends on are installed.
4148
4149   This wrapper executable should never be moved out of the build directory.
4150   If it is, it will not operate correctly.
4151*/
4152EOF
4153	    cat <<"EOF"
4154#ifdef _MSC_VER
4155# define _CRT_SECURE_NO_DEPRECATE 1
4156#endif
4157#include <stdio.h>
4158#include <stdlib.h>
4159#ifdef _MSC_VER
4160# include <direct.h>
4161# include <process.h>
4162# include <io.h>
4163#else
4164# include <unistd.h>
4165# include <stdint.h>
4166# ifdef __CYGWIN__
4167#  include <io.h>
4168# endif
4169#endif
4170#include <malloc.h>
4171#include <stdarg.h>
4172#include <assert.h>
4173#include <string.h>
4174#include <ctype.h>
4175#include <errno.h>
4176#include <fcntl.h>
4177#include <sys/stat.h>
4178
4179/* declarations of non-ANSI functions */
4180#if defined(__MINGW32__)
4181# ifdef __STRICT_ANSI__
4182int _putenv (const char *);
4183# endif
4184#elif defined(__CYGWIN__)
4185# ifdef __STRICT_ANSI__
4186char *realpath (const char *, char *);
4187int putenv (char *);
4188int setenv (const char *, const char *, int);
4189# endif
4190/* #elif defined (other platforms) ... */
4191#endif
4192
4193/* portability defines, excluding path handling macros */
4194#if defined(_MSC_VER)
4195# define setmode _setmode
4196# define stat    _stat
4197# define chmod   _chmod
4198# define getcwd  _getcwd
4199# define putenv  _putenv
4200# define S_IXUSR _S_IEXEC
4201# ifndef _INTPTR_T_DEFINED
4202#  define _INTPTR_T_DEFINED
4203#  define intptr_t int
4204# endif
4205#elif defined(__MINGW32__)
4206# define setmode _setmode
4207# define stat    _stat
4208# define chmod   _chmod
4209# define getcwd  _getcwd
4210# define putenv  _putenv
4211#elif defined(__CYGWIN__)
4212# define HAVE_SETENV
4213# define FOPEN_WB "wb"
4214/* #elif defined (other platforms) ... */
4215#endif
4216
4217#if defined(PATH_MAX)
4218# define LT_PATHMAX PATH_MAX
4219#elif defined(MAXPATHLEN)
4220# define LT_PATHMAX MAXPATHLEN
4221#else
4222# define LT_PATHMAX 1024
4223#endif
4224
4225#ifndef S_IXOTH
4226# define S_IXOTH 0
4227#endif
4228#ifndef S_IXGRP
4229# define S_IXGRP 0
4230#endif
4231
4232/* path handling portability macros */
4233#ifndef DIR_SEPARATOR
4234# define DIR_SEPARATOR '/'
4235# define PATH_SEPARATOR ':'
4236#endif
4237
4238#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
4239  defined (__OS2__)
4240# define HAVE_DOS_BASED_FILE_SYSTEM
4241# define FOPEN_WB "wb"
4242# ifndef DIR_SEPARATOR_2
4243#  define DIR_SEPARATOR_2 '\\'
4244# endif
4245# ifndef PATH_SEPARATOR_2
4246#  define PATH_SEPARATOR_2 ';'
4247# endif
4248#endif
4249
4250#ifndef DIR_SEPARATOR_2
4251# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
4252#else /* DIR_SEPARATOR_2 */
4253# define IS_DIR_SEPARATOR(ch) \
4254	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4255#endif /* DIR_SEPARATOR_2 */
4256
4257#ifndef PATH_SEPARATOR_2
4258# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
4259#else /* PATH_SEPARATOR_2 */
4260# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
4261#endif /* PATH_SEPARATOR_2 */
4262
4263#ifndef FOPEN_WB
4264# define FOPEN_WB "w"
4265#endif
4266#ifndef _O_BINARY
4267# define _O_BINARY 0
4268#endif
4269
4270#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
4271#define XFREE(stale) do { \
4272  if (stale) { free ((void *) stale); stale = 0; } \
4273} while (0)
4274
4275#if defined(LT_DEBUGWRAPPER)
4276static int lt_debug = 1;
4277#else
4278static int lt_debug = 0;
4279#endif
4280
4281const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
4282
4283void *xmalloc (size_t num);
4284char *xstrdup (const char *string);
4285const char *base_name (const char *name);
4286char *find_executable (const char *wrapper);
4287char *chase_symlinks (const char *pathspec);
4288int make_executable (const char *path);
4289int check_executable (const char *path);
4290char *strendzap (char *str, const char *pat);
4291void lt_debugprintf (const char *file, int line, const char *fmt, ...);
4292void lt_fatal (const char *file, int line, const char *message, ...);
4293static const char *nonnull (const char *s);
4294static const char *nonempty (const char *s);
4295void lt_setenv (const char *name, const char *value);
4296char *lt_extend_str (const char *orig_value, const char *add, int to_end);
4297void lt_update_exe_path (const char *name, const char *value);
4298void lt_update_lib_path (const char *name, const char *value);
4299char **prepare_spawn (char **argv);
4300void lt_dump_script (FILE *f);
4301EOF
4302
4303	    cat <<EOF
4304volatile const char * MAGIC_EXE = "$magic_exe";
4305const char * LIB_PATH_VARNAME = "$shlibpath_var";
4306EOF
4307
4308	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4309              func_to_host_path "$temp_rpath"
4310	      cat <<EOF
4311const char * LIB_PATH_VALUE   = "$func_to_host_path_result";
4312EOF
4313	    else
4314	      cat <<"EOF"
4315const char * LIB_PATH_VALUE   = "";
4316EOF
4317	    fi
4318
4319	    if test -n "$dllsearchpath"; then
4320              func_to_host_path "$dllsearchpath:"
4321	      cat <<EOF
4322const char * EXE_PATH_VARNAME = "PATH";
4323const char * EXE_PATH_VALUE   = "$func_to_host_path_result";
4324EOF
4325	    else
4326	      cat <<"EOF"
4327const char * EXE_PATH_VARNAME = "";
4328const char * EXE_PATH_VALUE   = "";
4329EOF
4330	    fi
4331
4332	    if test "$fast_install" = yes; then
4333	      cat <<EOF
4334const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
4335EOF
4336	    else
4337	      cat <<EOF
4338const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
4339EOF
4340	    fi
4341
4342
4343	    cat <<"EOF"
4344
4345#define LTWRAPPER_OPTION_PREFIX         "--lt-"
4346
4347static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
4348static const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
4349static const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
4350
4351int
4352main (int argc, char *argv[])
4353{
4354  char **newargz;
4355  int  newargc;
4356  char *tmp_pathspec;
4357  char *actual_cwrapper_path;
4358  char *actual_cwrapper_name;
4359  char *target_name;
4360  char *lt_argv_zero;
4361  intptr_t rval = 127;
4362
4363  int i;
4364
4365  program_name = (char *) xstrdup (base_name (argv[0]));
4366  newargz = XMALLOC (char *, argc + 1);
4367
4368  /* very simple arg parsing; don't want to rely on getopt
4369   * also, copy all non cwrapper options to newargz, except
4370   * argz[0], which is handled differently
4371   */
4372  newargc=0;
4373  for (i = 1; i < argc; i++)
4374    {
4375      if (strcmp (argv[i], dumpscript_opt) == 0)
4376	{
4377EOF
4378	    case "$host" in
4379	      *mingw* | *cygwin* )
4380		# make stdout use "unix" line endings
4381		echo "          setmode(1,_O_BINARY);"
4382		;;
4383	      esac
4384
4385	    cat <<"EOF"
4386	  lt_dump_script (stdout);
4387	  return 0;
4388	}
4389      if (strcmp (argv[i], debug_opt) == 0)
4390	{
4391          lt_debug = 1;
4392          continue;
4393	}
4394      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
4395        {
4396          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
4397             namespace, but it is not one of the ones we know about and
4398             have already dealt with, above (inluding dump-script), then
4399             report an error. Otherwise, targets might begin to believe
4400             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
4401             namespace. The first time any user complains about this, we'll
4402             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
4403             or a configure.ac-settable value.
4404           */
4405          lt_fatal (__FILE__, __LINE__,
4406		    "unrecognized %s option: '%s'",
4407                    ltwrapper_option_prefix, argv[i]);
4408        }
4409      /* otherwise ... */
4410      newargz[++newargc] = xstrdup (argv[i]);
4411    }
4412  newargz[++newargc] = NULL;
4413
4414EOF
4415	    cat <<EOF
4416  /* The GNU banner must be the first non-error debug message */
4417  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
4418EOF
4419	    cat <<"EOF"
4420  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
4421  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
4422
4423  tmp_pathspec = find_executable (argv[0]);
4424  if (tmp_pathspec == NULL)
4425    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
4426  lt_debugprintf (__FILE__, __LINE__,
4427                  "(main) found exe (before symlink chase) at: %s\n",
4428		  tmp_pathspec);
4429
4430  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
4431  lt_debugprintf (__FILE__, __LINE__,
4432                  "(main) found exe (after symlink chase) at: %s\n",
4433		  actual_cwrapper_path);
4434  XFREE (tmp_pathspec);
4435
4436  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
4437  strendzap (actual_cwrapper_path, actual_cwrapper_name);
4438
4439  /* wrapper name transforms */
4440  strendzap (actual_cwrapper_name, ".exe");
4441  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
4442  XFREE (actual_cwrapper_name);
4443  actual_cwrapper_name = tmp_pathspec;
4444  tmp_pathspec = 0;
4445
4446  /* target_name transforms -- use actual target program name; might have lt- prefix */
4447  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
4448  strendzap (target_name, ".exe");
4449  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
4450  XFREE (target_name);
4451  target_name = tmp_pathspec;
4452  tmp_pathspec = 0;
4453
4454  lt_debugprintf (__FILE__, __LINE__,
4455		  "(main) libtool target name: %s\n",
4456		  target_name);
4457EOF
4458
4459	    cat <<EOF
4460  newargz[0] =
4461    XMALLOC (char, (strlen (actual_cwrapper_path) +
4462		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
4463  strcpy (newargz[0], actual_cwrapper_path);
4464  strcat (newargz[0], "$objdir");
4465  strcat (newargz[0], "/");
4466EOF
4467
4468	    cat <<"EOF"
4469  /* stop here, and copy so we don't have to do this twice */
4470  tmp_pathspec = xstrdup (newargz[0]);
4471
4472  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
4473  strcat (newargz[0], actual_cwrapper_name);
4474
4475  /* DO want the lt- prefix here if it exists, so use target_name */
4476  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
4477  XFREE (tmp_pathspec);
4478  tmp_pathspec = NULL;
4479EOF
4480
4481	    case $host_os in
4482	      mingw*)
4483	    cat <<"EOF"
4484  {
4485    char* p;
4486    while ((p = strchr (newargz[0], '\\')) != NULL)
4487      {
4488	*p = '/';
4489      }
4490    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
4491      {
4492	*p = '/';
4493      }
4494  }
4495EOF
4496	    ;;
4497	    esac
4498
4499	    cat <<"EOF"
4500  XFREE (target_name);
4501  XFREE (actual_cwrapper_path);
4502  XFREE (actual_cwrapper_name);
4503
4504  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
4505  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
4506  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
4507     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
4508     because on Windows, both *_VARNAMEs are PATH but uninstalled
4509     libraries must come first. */
4510  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
4511  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
4512
4513  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
4514		  nonnull (lt_argv_zero));
4515  for (i = 0; i < newargc; i++)
4516    {
4517      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
4518		      i, nonnull (newargz[i]));
4519    }
4520
4521EOF
4522
4523	    case $host_os in
4524	      mingw*)
4525		cat <<"EOF"
4526  /* execv doesn't actually work on mingw as expected on unix */
4527  newargz = prepare_spawn (newargz);
4528  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
4529  if (rval == -1)
4530    {
4531      /* failed to start process */
4532      lt_debugprintf (__FILE__, __LINE__,
4533		      "(main) failed to launch target \"%s\": %s\n",
4534		      lt_argv_zero, nonnull (strerror (errno)));
4535      return 127;
4536    }
4537  return rval;
4538EOF
4539		;;
4540	      *)
4541		cat <<"EOF"
4542  execv (lt_argv_zero, newargz);
4543  return rval; /* =127, but avoids unused variable warning */
4544EOF
4545		;;
4546	    esac
4547
4548	    cat <<"EOF"
4549}
4550
4551void *
4552xmalloc (size_t num)
4553{
4554  void *p = (void *) malloc (num);
4555  if (!p)
4556    lt_fatal (__FILE__, __LINE__, "memory exhausted");
4557
4558  return p;
4559}
4560
4561char *
4562xstrdup (const char *string)
4563{
4564  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
4565			  string) : NULL;
4566}
4567
4568const char *
4569base_name (const char *name)
4570{
4571  const char *base;
4572
4573#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4574  /* Skip over the disk name in MSDOS pathnames. */
4575  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
4576    name += 2;
4577#endif
4578
4579  for (base = name; *name; name++)
4580    if (IS_DIR_SEPARATOR (*name))
4581      base = name + 1;
4582  return base;
4583}
4584
4585int
4586check_executable (const char *path)
4587{
4588  struct stat st;
4589
4590  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
4591                  nonempty (path));
4592  if ((!path) || (!*path))
4593    return 0;
4594
4595  if ((stat (path, &st) >= 0)
4596      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
4597    return 1;
4598  else
4599    return 0;
4600}
4601
4602int
4603make_executable (const char *path)
4604{
4605  int rval = 0;
4606  struct stat st;
4607
4608  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
4609                  nonempty (path));
4610  if ((!path) || (!*path))
4611    return 0;
4612
4613  if (stat (path, &st) >= 0)
4614    {
4615      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
4616    }
4617  return rval;
4618}
4619
4620/* Searches for the full path of the wrapper.  Returns
4621   newly allocated full path name if found, NULL otherwise
4622   Does not chase symlinks, even on platforms that support them.
4623*/
4624char *
4625find_executable (const char *wrapper)
4626{
4627  int has_slash = 0;
4628  const char *p;
4629  const char *p_next;
4630  /* static buffer for getcwd */
4631  char tmp[LT_PATHMAX + 1];
4632  int tmp_len;
4633  char *concat_name;
4634
4635  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
4636                  nonempty (wrapper));
4637
4638  if ((wrapper == NULL) || (*wrapper == '\0'))
4639    return NULL;
4640
4641  /* Absolute path? */
4642#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4643  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
4644    {
4645      concat_name = xstrdup (wrapper);
4646      if (check_executable (concat_name))
4647	return concat_name;
4648      XFREE (concat_name);
4649    }
4650  else
4651    {
4652#endif
4653      if (IS_DIR_SEPARATOR (wrapper[0]))
4654	{
4655	  concat_name = xstrdup (wrapper);
4656	  if (check_executable (concat_name))
4657	    return concat_name;
4658	  XFREE (concat_name);
4659	}
4660#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4661    }
4662#endif
4663
4664  for (p = wrapper; *p; p++)
4665    if (*p == '/')
4666      {
4667	has_slash = 1;
4668	break;
4669      }
4670  if (!has_slash)
4671    {
4672      /* no slashes; search PATH */
4673      const char *path = getenv ("PATH");
4674      if (path != NULL)
4675	{
4676	  for (p = path; *p; p = p_next)
4677	    {
4678	      const char *q;
4679	      size_t p_len;
4680	      for (q = p; *q; q++)
4681		if (IS_PATH_SEPARATOR (*q))
4682		  break;
4683	      p_len = q - p;
4684	      p_next = (*q == '\0' ? q : q + 1);
4685	      if (p_len == 0)
4686		{
4687		  /* empty path: current directory */
4688		  if (getcwd (tmp, LT_PATHMAX) == NULL)
4689		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4690                              nonnull (strerror (errno)));
4691		  tmp_len = strlen (tmp);
4692		  concat_name =
4693		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4694		  memcpy (concat_name, tmp, tmp_len);
4695		  concat_name[tmp_len] = '/';
4696		  strcpy (concat_name + tmp_len + 1, wrapper);
4697		}
4698	      else
4699		{
4700		  concat_name =
4701		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
4702		  memcpy (concat_name, p, p_len);
4703		  concat_name[p_len] = '/';
4704		  strcpy (concat_name + p_len + 1, wrapper);
4705		}
4706	      if (check_executable (concat_name))
4707		return concat_name;
4708	      XFREE (concat_name);
4709	    }
4710	}
4711      /* not found in PATH; assume curdir */
4712    }
4713  /* Relative path | not found in path: prepend cwd */
4714  if (getcwd (tmp, LT_PATHMAX) == NULL)
4715    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4716              nonnull (strerror (errno)));
4717  tmp_len = strlen (tmp);
4718  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4719  memcpy (concat_name, tmp, tmp_len);
4720  concat_name[tmp_len] = '/';
4721  strcpy (concat_name + tmp_len + 1, wrapper);
4722
4723  if (check_executable (concat_name))
4724    return concat_name;
4725  XFREE (concat_name);
4726  return NULL;
4727}
4728
4729char *
4730chase_symlinks (const char *pathspec)
4731{
4732#ifndef S_ISLNK
4733  return xstrdup (pathspec);
4734#else
4735  char buf[LT_PATHMAX];
4736  struct stat s;
4737  char *tmp_pathspec = xstrdup (pathspec);
4738  char *p;
4739  int has_symlinks = 0;
4740  while (strlen (tmp_pathspec) && !has_symlinks)
4741    {
4742      lt_debugprintf (__FILE__, __LINE__,
4743		      "checking path component for symlinks: %s\n",
4744		      tmp_pathspec);
4745      if (lstat (tmp_pathspec, &s) == 0)
4746	{
4747	  if (S_ISLNK (s.st_mode) != 0)
4748	    {
4749	      has_symlinks = 1;
4750	      break;
4751	    }
4752
4753	  /* search backwards for last DIR_SEPARATOR */
4754	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
4755	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4756	    p--;
4757	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4758	    {
4759	      /* no more DIR_SEPARATORS left */
4760	      break;
4761	    }
4762	  *p = '\0';
4763	}
4764      else
4765	{
4766	  lt_fatal (__FILE__, __LINE__,
4767		    "error accessing file \"%s\": %s",
4768		    tmp_pathspec, nonnull (strerror (errno)));
4769	}
4770    }
4771  XFREE (tmp_pathspec);
4772
4773  if (!has_symlinks)
4774    {
4775      return xstrdup (pathspec);
4776    }
4777
4778  tmp_pathspec = realpath (pathspec, buf);
4779  if (tmp_pathspec == 0)
4780    {
4781      lt_fatal (__FILE__, __LINE__,
4782		"could not follow symlinks for %s", pathspec);
4783    }
4784  return xstrdup (tmp_pathspec);
4785#endif
4786}
4787
4788char *
4789strendzap (char *str, const char *pat)
4790{
4791  size_t len, patlen;
4792
4793  assert (str != NULL);
4794  assert (pat != NULL);
4795
4796  len = strlen (str);
4797  patlen = strlen (pat);
4798
4799  if (patlen <= len)
4800    {
4801      str += len - patlen;
4802      if (strcmp (str, pat) == 0)
4803	*str = '\0';
4804    }
4805  return str;
4806}
4807
4808void
4809lt_debugprintf (const char *file, int line, const char *fmt, ...)
4810{
4811  va_list args;
4812  if (lt_debug)
4813    {
4814      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
4815      va_start (args, fmt);
4816      (void) vfprintf (stderr, fmt, args);
4817      va_end (args);
4818    }
4819}
4820
4821static void
4822lt_error_core (int exit_status, const char *file,
4823	       int line, const char *mode,
4824	       const char *message, va_list ap)
4825{
4826  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
4827  vfprintf (stderr, message, ap);
4828  fprintf (stderr, ".\n");
4829
4830  if (exit_status >= 0)
4831    exit (exit_status);
4832}
4833
4834void
4835lt_fatal (const char *file, int line, const char *message, ...)
4836{
4837  va_list ap;
4838  va_start (ap, message);
4839  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
4840  va_end (ap);
4841}
4842
4843static const char *
4844nonnull (const char *s)
4845{
4846  return s ? s : "(null)";
4847}
4848
4849static const char *
4850nonempty (const char *s)
4851{
4852  return (s && !*s) ? "(empty)" : nonnull (s);
4853}
4854
4855void
4856lt_setenv (const char *name, const char *value)
4857{
4858  lt_debugprintf (__FILE__, __LINE__,
4859		  "(lt_setenv) setting '%s' to '%s'\n",
4860                  nonnull (name), nonnull (value));
4861  {
4862#ifdef HAVE_SETENV
4863    /* always make a copy, for consistency with !HAVE_SETENV */
4864    char *str = xstrdup (value);
4865    setenv (name, str, 1);
4866#else
4867    int len = strlen (name) + 1 + strlen (value) + 1;
4868    char *str = XMALLOC (char, len);
4869    sprintf (str, "%s=%s", name, value);
4870    if (putenv (str) != EXIT_SUCCESS)
4871      {
4872        XFREE (str);
4873      }
4874#endif
4875  }
4876}
4877
4878char *
4879lt_extend_str (const char *orig_value, const char *add, int to_end)
4880{
4881  char *new_value;
4882  if (orig_value && *orig_value)
4883    {
4884      int orig_value_len = strlen (orig_value);
4885      int add_len = strlen (add);
4886      new_value = XMALLOC (char, add_len + orig_value_len + 1);
4887      if (to_end)
4888        {
4889          strcpy (new_value, orig_value);
4890          strcpy (new_value + orig_value_len, add);
4891        }
4892      else
4893        {
4894          strcpy (new_value, add);
4895          strcpy (new_value + add_len, orig_value);
4896        }
4897    }
4898  else
4899    {
4900      new_value = xstrdup (add);
4901    }
4902  return new_value;
4903}
4904
4905void
4906lt_update_exe_path (const char *name, const char *value)
4907{
4908  lt_debugprintf (__FILE__, __LINE__,
4909		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
4910                  nonnull (name), nonnull (value));
4911
4912  if (name && *name && value && *value)
4913    {
4914      char *new_value = lt_extend_str (getenv (name), value, 0);
4915      /* some systems can't cope with a ':'-terminated path #' */
4916      int len = strlen (new_value);
4917      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
4918        {
4919          new_value[len-1] = '\0';
4920        }
4921      lt_setenv (name, new_value);
4922      XFREE (new_value);
4923    }
4924}
4925
4926void
4927lt_update_lib_path (const char *name, const char *value)
4928{
4929  lt_debugprintf (__FILE__, __LINE__,
4930		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
4931                  nonnull (name), nonnull (value));
4932
4933  if (name && *name && value && *value)
4934    {
4935      char *new_value = lt_extend_str (getenv (name), value, 0);
4936      lt_setenv (name, new_value);
4937      XFREE (new_value);
4938    }
4939}
4940
4941EOF
4942	    case $host_os in
4943	      mingw*)
4944		cat <<"EOF"
4945
4946/* Prepares an argument vector before calling spawn().
4947   Note that spawn() does not by itself call the command interpreter
4948     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
4949      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
4950         GetVersionEx(&v);
4951         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
4952      }) ? "cmd.exe" : "command.com").
4953   Instead it simply concatenates the arguments, separated by ' ', and calls
4954   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
4955   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
4956   special way:
4957   - Space and tab are interpreted as delimiters. They are not treated as
4958     delimiters if they are surrounded by double quotes: "...".
4959   - Unescaped double quotes are removed from the input. Their only effect is
4960     that within double quotes, space and tab are treated like normal
4961     characters.
4962   - Backslashes not followed by double quotes are not special.
4963   - But 2*n+1 backslashes followed by a double quote become
4964     n backslashes followed by a double quote (n >= 0):
4965       \" -> "
4966       \\\" -> \"
4967       \\\\\" -> \\"
4968 */
4969#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
4970#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
4971char **
4972prepare_spawn (char **argv)
4973{
4974  size_t argc;
4975  char **new_argv;
4976  size_t i;
4977
4978  /* Count number of arguments.  */
4979  for (argc = 0; argv[argc] != NULL; argc++)
4980    ;
4981
4982  /* Allocate new argument vector.  */
4983  new_argv = XMALLOC (char *, argc + 1);
4984
4985  /* Put quoted arguments into the new argument vector.  */
4986  for (i = 0; i < argc; i++)
4987    {
4988      const char *string = argv[i];
4989
4990      if (string[0] == '\0')
4991	new_argv[i] = xstrdup ("\"\"");
4992      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
4993	{
4994	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
4995	  size_t length;
4996	  unsigned int backslashes;
4997	  const char *s;
4998	  char *quoted_string;
4999	  char *p;
5000
5001	  length = 0;
5002	  backslashes = 0;
5003	  if (quote_around)
5004	    length++;
5005	  for (s = string; *s != '\0'; s++)
5006	    {
5007	      char c = *s;
5008	      if (c == '"')
5009		length += backslashes + 1;
5010	      length++;
5011	      if (c == '\\')
5012		backslashes++;
5013	      else
5014		backslashes = 0;
5015	    }
5016	  if (quote_around)
5017	    length += backslashes + 1;
5018
5019	  quoted_string = XMALLOC (char, length + 1);
5020
5021	  p = quoted_string;
5022	  backslashes = 0;
5023	  if (quote_around)
5024	    *p++ = '"';
5025	  for (s = string; *s != '\0'; s++)
5026	    {
5027	      char c = *s;
5028	      if (c == '"')
5029		{
5030		  unsigned int j;
5031		  for (j = backslashes + 1; j > 0; j--)
5032		    *p++ = '\\';
5033		}
5034	      *p++ = c;
5035	      if (c == '\\')
5036		backslashes++;
5037	      else
5038		backslashes = 0;
5039	    }
5040	  if (quote_around)
5041	    {
5042	      unsigned int j;
5043	      for (j = backslashes; j > 0; j--)
5044		*p++ = '\\';
5045	      *p++ = '"';
5046	    }
5047	  *p = '\0';
5048
5049	  new_argv[i] = quoted_string;
5050	}
5051      else
5052	new_argv[i] = (char *) string;
5053    }
5054  new_argv[argc] = NULL;
5055
5056  return new_argv;
5057}
5058EOF
5059		;;
5060	    esac
5061
5062            cat <<"EOF"
5063void lt_dump_script (FILE* f)
5064{
5065EOF
5066	    func_emit_wrapper yes |
5067	      $SED -n -e '
5068s/^\(.\{79\}\)\(..*\)/\1\
5069\2/
5070h
5071s/\([\\"]\)/\\\1/g
5072s/$/\\n/
5073s/\([^\n]*\).*/  fputs ("\1", f);/p
5074g
5075D'
5076            cat <<"EOF"
5077}
5078EOF
5079}
5080# end: func_emit_cwrapperexe_src
5081
5082# func_win32_import_lib_p ARG
5083# True if ARG is an import lib, as indicated by $file_magic_cmd
5084func_win32_import_lib_p ()
5085{
5086    $opt_debug
5087    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
5088    *import*) : ;;
5089    *) false ;;
5090    esac
5091}
5092
5093# func_mode_link arg...
5094func_mode_link ()
5095{
5096    $opt_debug
5097    case $host in
5098    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5099      # It is impossible to link a dll without this setting, and
5100      # we shouldn't force the makefile maintainer to figure out
5101      # which system we are compiling for in order to pass an extra
5102      # flag for every libtool invocation.
5103      # allow_undefined=no
5104
5105      # FIXME: Unfortunately, there are problems with the above when trying
5106      # to make a dll which has undefined symbols, in which case not
5107      # even a static library is built.  For now, we need to specify
5108      # -no-undefined on the libtool link line when we can be certain
5109      # that all symbols are satisfied, otherwise we get a static library.
5110      allow_undefined=yes
5111      ;;
5112    *)
5113      allow_undefined=yes
5114      ;;
5115    esac
5116    libtool_args=$nonopt
5117    base_compile="$nonopt $@"
5118    compile_command=$nonopt
5119    finalize_command=$nonopt
5120
5121    compile_rpath=
5122    finalize_rpath=
5123    compile_shlibpath=
5124    finalize_shlibpath=
5125    convenience=
5126    old_convenience=
5127    deplibs=
5128    old_deplibs=
5129    compiler_flags=
5130    linker_flags=
5131    dllsearchpath=
5132    lib_search_path=`pwd`
5133    inst_prefix_dir=
5134    new_inherited_linker_flags=
5135
5136    avoid_version=no
5137    bindir=
5138    dlfiles=
5139    dlprefiles=
5140    dlself=no
5141    export_dynamic=no
5142    export_symbols=
5143    export_symbols_regex=
5144    generated=
5145    libobjs=
5146    ltlibs=
5147    module=no
5148    no_install=no
5149    objs=
5150    non_pic_objects=
5151    precious_files_regex=
5152    prefer_static_libs=no
5153    preload=no
5154    prev=
5155    prevarg=
5156    release=
5157    rpath=
5158    xrpath=
5159    perm_rpath=
5160    temp_rpath=
5161    thread_safe=no
5162    vinfo=
5163    vinfo_number=no
5164    weak_libs=
5165    single_module="${wl}-single_module"
5166    func_infer_tag $base_compile
5167
5168    # We need to know -static, to get the right output filenames.
5169    for arg
5170    do
5171      case $arg in
5172      -shared)
5173	test "$build_libtool_libs" != yes && \
5174	  func_fatal_configuration "can not build a shared library"
5175	build_old_libs=no
5176	break
5177	;;
5178      -all-static | -static | -static-libtool-libs)
5179	case $arg in
5180	-all-static)
5181	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
5182	    func_warning "complete static linking is impossible in this configuration"
5183	  fi
5184	  if test -n "$link_static_flag"; then
5185	    dlopen_self=$dlopen_self_static
5186	  fi
5187	  prefer_static_libs=yes
5188	  ;;
5189	-static)
5190	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5191	    dlopen_self=$dlopen_self_static
5192	  fi
5193	  prefer_static_libs=built
5194	  ;;
5195	-static-libtool-libs)
5196	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5197	    dlopen_self=$dlopen_self_static
5198	  fi
5199	  prefer_static_libs=yes
5200	  ;;
5201	esac
5202	build_libtool_libs=no
5203	build_old_libs=yes
5204	break
5205	;;
5206      esac
5207    done
5208
5209    # See if our shared archives depend on static archives.
5210    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
5211
5212    # Go through the arguments, transforming them on the way.
5213    while test "$#" -gt 0; do
5214      arg="$1"
5215      shift
5216      func_quote_for_eval "$arg"
5217      qarg=$func_quote_for_eval_unquoted_result
5218      func_append libtool_args " $func_quote_for_eval_result"
5219
5220      # If the previous option needs an argument, assign it.
5221      if test -n "$prev"; then
5222	case $prev in
5223	output)
5224	  func_append compile_command " @OUTPUT@"
5225	  func_append finalize_command " @OUTPUT@"
5226	  ;;
5227	esac
5228
5229	case $prev in
5230	bindir)
5231	  bindir="$arg"
5232	  prev=
5233	  continue
5234	  ;;
5235	dlfiles|dlprefiles)
5236	  if test "$preload" = no; then
5237	    # Add the symbol object into the linking commands.
5238	    func_append compile_command " @SYMFILE@"
5239	    func_append finalize_command " @SYMFILE@"
5240	    preload=yes
5241	  fi
5242	  case $arg in
5243	  *.la | *.lo) ;;  # We handle these cases below.
5244	  force)
5245	    if test "$dlself" = no; then
5246	      dlself=needless
5247	      export_dynamic=yes
5248	    fi
5249	    prev=
5250	    continue
5251	    ;;
5252	  self)
5253	    if test "$prev" = dlprefiles; then
5254	      dlself=yes
5255	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
5256	      dlself=yes
5257	    else
5258	      dlself=needless
5259	      export_dynamic=yes
5260	    fi
5261	    prev=
5262	    continue
5263	    ;;
5264	  *)
5265	    if test "$prev" = dlfiles; then
5266	      func_append dlfiles " $arg"
5267	    else
5268	      func_append dlprefiles " $arg"
5269	    fi
5270	    prev=
5271	    continue
5272	    ;;
5273	  esac
5274	  ;;
5275	expsyms)
5276	  export_symbols="$arg"
5277	  test -f "$arg" \
5278	    || func_fatal_error "symbol file \`$arg' does not exist"
5279	  prev=
5280	  continue
5281	  ;;
5282	expsyms_regex)
5283	  export_symbols_regex="$arg"
5284	  prev=
5285	  continue
5286	  ;;
5287	framework)
5288	  case $host in
5289	    *-*-darwin*)
5290	      case "$deplibs " in
5291		*" $qarg.ltframework "*) ;;
5292		*) func_append deplibs " $qarg.ltframework" # this is fixed later
5293		   ;;
5294	      esac
5295	      ;;
5296	  esac
5297	  prev=
5298	  continue
5299	  ;;
5300	inst_prefix)
5301	  inst_prefix_dir="$arg"
5302	  prev=
5303	  continue
5304	  ;;
5305	objectlist)
5306	  if test -f "$arg"; then
5307	    save_arg=$arg
5308	    moreargs=
5309	    for fil in `cat "$save_arg"`
5310	    do
5311#	      func_append moreargs " $fil"
5312	      arg=$fil
5313	      # A libtool-controlled object.
5314
5315	      # Check to see that this really is a libtool object.
5316	      if func_lalib_unsafe_p "$arg"; then
5317		pic_object=
5318		non_pic_object=
5319
5320		# Read the .lo file
5321		func_source "$arg"
5322
5323		if test -z "$pic_object" ||
5324		   test -z "$non_pic_object" ||
5325		   test "$pic_object" = none &&
5326		   test "$non_pic_object" = none; then
5327		  func_fatal_error "cannot find name of object for \`$arg'"
5328		fi
5329
5330		# Extract subdirectory from the argument.
5331		func_dirname "$arg" "/" ""
5332		xdir="$func_dirname_result"
5333
5334		if test "$pic_object" != none; then
5335		  # Prepend the subdirectory the object is found in.
5336		  pic_object="$xdir$pic_object"
5337
5338		  if test "$prev" = dlfiles; then
5339		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5340		      func_append dlfiles " $pic_object"
5341		      prev=
5342		      continue
5343		    else
5344		      # If libtool objects are unsupported, then we need to preload.
5345		      prev=dlprefiles
5346		    fi
5347		  fi
5348
5349		  # CHECK ME:  I think I busted this.  -Ossama
5350		  if test "$prev" = dlprefiles; then
5351		    # Preload the old-style object.
5352		    func_append dlprefiles " $pic_object"
5353		    prev=
5354		  fi
5355
5356		  # A PIC object.
5357		  func_append libobjs " $pic_object"
5358		  arg="$pic_object"
5359		fi
5360
5361		# Non-PIC object.
5362		if test "$non_pic_object" != none; then
5363		  # Prepend the subdirectory the object is found in.
5364		  non_pic_object="$xdir$non_pic_object"
5365
5366		  # A standard non-PIC object
5367		  func_append non_pic_objects " $non_pic_object"
5368		  if test -z "$pic_object" || test "$pic_object" = none ; then
5369		    arg="$non_pic_object"
5370		  fi
5371		else
5372		  # If the PIC object exists, use it instead.
5373		  # $xdir was prepended to $pic_object above.
5374		  non_pic_object="$pic_object"
5375		  func_append non_pic_objects " $non_pic_object"
5376		fi
5377	      else
5378		# Only an error if not doing a dry-run.
5379		if $opt_dry_run; then
5380		  # Extract subdirectory from the argument.
5381		  func_dirname "$arg" "/" ""
5382		  xdir="$func_dirname_result"
5383
5384		  func_lo2o "$arg"
5385		  pic_object=$xdir$objdir/$func_lo2o_result
5386		  non_pic_object=$xdir$func_lo2o_result
5387		  func_append libobjs " $pic_object"
5388		  func_append non_pic_objects " $non_pic_object"
5389	        else
5390		  func_fatal_error "\`$arg' is not a valid libtool object"
5391		fi
5392	      fi
5393	    done
5394	  else
5395	    func_fatal_error "link input file \`$arg' does not exist"
5396	  fi
5397	  arg=$save_arg
5398	  prev=
5399	  continue
5400	  ;;
5401	precious_regex)
5402	  precious_files_regex="$arg"
5403	  prev=
5404	  continue
5405	  ;;
5406	release)
5407	  release="-$arg"
5408	  prev=
5409	  continue
5410	  ;;
5411	rpath | xrpath)
5412	  # We need an absolute path.
5413	  case $arg in
5414	  [\\/]* | [A-Za-z]:[\\/]*) ;;
5415	  *)
5416	    func_fatal_error "only absolute run-paths are allowed"
5417	    ;;
5418	  esac
5419	  if test "$prev" = rpath; then
5420	    case "$rpath " in
5421	    *" $arg "*) ;;
5422	    *) func_append rpath " $arg" ;;
5423	    esac
5424	  else
5425	    case "$xrpath " in
5426	    *" $arg "*) ;;
5427	    *) func_append xrpath " $arg" ;;
5428	    esac
5429	  fi
5430	  prev=
5431	  continue
5432	  ;;
5433	shrext)
5434	  shrext_cmds="$arg"
5435	  prev=
5436	  continue
5437	  ;;
5438	weak)
5439	  func_append weak_libs " $arg"
5440	  prev=
5441	  continue
5442	  ;;
5443	xcclinker)
5444	  func_append linker_flags " $qarg"
5445	  func_append compiler_flags " $qarg"
5446	  prev=
5447	  func_append compile_command " $qarg"
5448	  func_append finalize_command " $qarg"
5449	  continue
5450	  ;;
5451	xcompiler)
5452	  func_append compiler_flags " $qarg"
5453	  prev=
5454	  func_append compile_command " $qarg"
5455	  func_append finalize_command " $qarg"
5456	  continue
5457	  ;;
5458	xlinker)
5459	  func_append linker_flags " $qarg"
5460	  func_append compiler_flags " $wl$qarg"
5461	  prev=
5462	  func_append compile_command " $wl$qarg"
5463	  func_append finalize_command " $wl$qarg"
5464	  continue
5465	  ;;
5466	*)
5467	  eval "$prev=\"\$arg\""
5468	  prev=
5469	  continue
5470	  ;;
5471	esac
5472      fi # test -n "$prev"
5473
5474      prevarg="$arg"
5475
5476      case $arg in
5477      -all-static)
5478	if test -n "$link_static_flag"; then
5479	  # See comment for -static flag below, for more details.
5480	  func_append compile_command " $link_static_flag"
5481	  func_append finalize_command " $link_static_flag"
5482	fi
5483	continue
5484	;;
5485
5486      -allow-undefined)
5487	# FIXME: remove this flag sometime in the future.
5488	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
5489	;;
5490
5491      -avoid-version)
5492	avoid_version=yes
5493	continue
5494	;;
5495
5496      -bindir)
5497	prev=bindir
5498	continue
5499	;;
5500
5501      -dlopen)
5502	prev=dlfiles
5503	continue
5504	;;
5505
5506      -dlpreopen)
5507	prev=dlprefiles
5508	continue
5509	;;
5510
5511      -export-dynamic)
5512	export_dynamic=yes
5513	continue
5514	;;
5515
5516      -export-symbols | -export-symbols-regex)
5517	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
5518	  func_fatal_error "more than one -exported-symbols argument is not allowed"
5519	fi
5520	if test "X$arg" = "X-export-symbols"; then
5521	  prev=expsyms
5522	else
5523	  prev=expsyms_regex
5524	fi
5525	continue
5526	;;
5527
5528      -framework)
5529	prev=framework
5530	continue
5531	;;
5532
5533      -inst-prefix-dir)
5534	prev=inst_prefix
5535	continue
5536	;;
5537
5538      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
5539      # so, if we see these flags be careful not to treat them like -L
5540      -L[A-Z][A-Z]*:*)
5541	case $with_gcc/$host in
5542	no/*-*-irix* | /*-*-irix*)
5543	  func_append compile_command " $arg"
5544	  func_append finalize_command " $arg"
5545	  ;;
5546	esac
5547	continue
5548	;;
5549
5550      -L*)
5551	func_stripname "-L" '' "$arg"
5552	if test -z "$func_stripname_result"; then
5553	  if test "$#" -gt 0; then
5554	    func_fatal_error "require no space between \`-L' and \`$1'"
5555	  else
5556	    func_fatal_error "need path for \`-L' option"
5557	  fi
5558	fi
5559	func_resolve_sysroot "$func_stripname_result"
5560	dir=$func_resolve_sysroot_result
5561	# We need an absolute path.
5562	case $dir in
5563	[\\/]* | [A-Za-z]:[\\/]*) ;;
5564	*)
5565	  absdir=`cd "$dir" && pwd`
5566	  test -z "$absdir" && \
5567	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
5568	  dir="$absdir"
5569	  ;;
5570	esac
5571	case "$deplibs " in
5572	*" -L$dir "* | *" $arg "*)
5573	  # Will only happen for absolute or sysroot arguments
5574	  ;;
5575	*)
5576	  # Preserve sysroot, but never include relative directories
5577	  case $dir in
5578	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
5579	    *) func_append deplibs " -L$dir" ;;
5580	  esac
5581	  func_append lib_search_path " $dir"
5582	  ;;
5583	esac
5584	case $host in
5585	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5586	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
5587	  case :$dllsearchpath: in
5588	  *":$dir:"*) ;;
5589	  ::) dllsearchpath=$dir;;
5590	  *) func_append dllsearchpath ":$dir";;
5591	  esac
5592	  case :$dllsearchpath: in
5593	  *":$testbindir:"*) ;;
5594	  ::) dllsearchpath=$testbindir;;
5595	  *) func_append dllsearchpath ":$testbindir";;
5596	  esac
5597	  ;;
5598	esac
5599	continue
5600	;;
5601
5602      -l*)
5603	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
5604	  case $host in
5605	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
5606	    # These systems don't actually have a C or math library (as such)
5607	    continue
5608	    ;;
5609	  *-*-os2*)
5610	    # These systems don't actually have a C library (as such)
5611	    test "X$arg" = "X-lc" && continue
5612	    ;;
5613	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5614	    # Do not include libc due to us having libc/libc_r.
5615	    test "X$arg" = "X-lc" && continue
5616	    ;;
5617	  *-*-rhapsody* | *-*-darwin1.[012])
5618	    # Rhapsody C and math libraries are in the System framework
5619	    func_append deplibs " System.ltframework"
5620	    continue
5621	    ;;
5622	  *-*-sco3.2v5* | *-*-sco5v6*)
5623	    # Causes problems with __ctype
5624	    test "X$arg" = "X-lc" && continue
5625	    ;;
5626	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
5627	    # Compiler inserts libc in the correct place for threads to work
5628	    test "X$arg" = "X-lc" && continue
5629	    ;;
5630	  esac
5631	elif test "X$arg" = "X-lc_r"; then
5632	 case $host in
5633	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5634	   # Do not include libc_r directly, use -pthread flag.
5635	   continue
5636	   ;;
5637	 esac
5638	fi
5639	func_append deplibs " $arg"
5640	continue
5641	;;
5642
5643      -module)
5644	module=yes
5645	continue
5646	;;
5647
5648      # Tru64 UNIX uses -model [arg] to determine the layout of C++
5649      # classes, name mangling, and exception handling.
5650      # Darwin uses the -arch flag to determine output architecture.
5651      -model|-arch|-isysroot|--sysroot)
5652	func_append compiler_flags " $arg"
5653	func_append compile_command " $arg"
5654	func_append finalize_command " $arg"
5655	prev=xcompiler
5656	continue
5657	;;
5658
5659      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
5660      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
5661	func_append compiler_flags " $arg"
5662	func_append compile_command " $arg"
5663	func_append finalize_command " $arg"
5664	case "$new_inherited_linker_flags " in
5665	    *" $arg "*) ;;
5666	    * ) func_append new_inherited_linker_flags " $arg" ;;
5667	esac
5668	continue
5669	;;
5670
5671      -multi_module)
5672	single_module="${wl}-multi_module"
5673	continue
5674	;;
5675
5676      -no-fast-install)
5677	fast_install=no
5678	continue
5679	;;
5680
5681      -no-install)
5682	case $host in
5683	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
5684	  # The PATH hackery in wrapper scripts is required on Windows
5685	  # and Darwin in order for the loader to find any dlls it needs.
5686	  func_warning "\`-no-install' is ignored for $host"
5687	  func_warning "assuming \`-no-fast-install' instead"
5688	  fast_install=no
5689	  ;;
5690	*) no_install=yes ;;
5691	esac
5692	continue
5693	;;
5694
5695      -no-undefined)
5696	allow_undefined=no
5697	continue
5698	;;
5699
5700      -objectlist)
5701	prev=objectlist
5702	continue
5703	;;
5704
5705      -o) prev=output ;;
5706
5707      -precious-files-regex)
5708	prev=precious_regex
5709	continue
5710	;;
5711
5712      -release)
5713	prev=release
5714	continue
5715	;;
5716
5717      -rpath)
5718	prev=rpath
5719	continue
5720	;;
5721
5722      -R)
5723	prev=xrpath
5724	continue
5725	;;
5726
5727      -R*)
5728	func_stripname '-R' '' "$arg"
5729	dir=$func_stripname_result
5730	# We need an absolute path.
5731	case $dir in
5732	[\\/]* | [A-Za-z]:[\\/]*) ;;
5733	=*)
5734	  func_stripname '=' '' "$dir"
5735	  dir=$lt_sysroot$func_stripname_result
5736	  ;;
5737	*)
5738	  func_fatal_error "only absolute run-paths are allowed"
5739	  ;;
5740	esac
5741	case "$xrpath " in
5742	*" $dir "*) ;;
5743	*) func_append xrpath " $dir" ;;
5744	esac
5745	continue
5746	;;
5747
5748      -shared)
5749	# The effects of -shared are defined in a previous loop.
5750	continue
5751	;;
5752
5753      -shrext)
5754	prev=shrext
5755	continue
5756	;;
5757
5758      -static | -static-libtool-libs)
5759	# The effects of -static are defined in a previous loop.
5760	# We used to do the same as -all-static on platforms that
5761	# didn't have a PIC flag, but the assumption that the effects
5762	# would be equivalent was wrong.  It would break on at least
5763	# Digital Unix and AIX.
5764	continue
5765	;;
5766
5767      -thread-safe)
5768	thread_safe=yes
5769	continue
5770	;;
5771
5772      -version-info)
5773	prev=vinfo
5774	continue
5775	;;
5776
5777      -version-number)
5778	prev=vinfo
5779	vinfo_number=yes
5780	continue
5781	;;
5782
5783      -weak)
5784        prev=weak
5785	continue
5786	;;
5787
5788      -Wc,*)
5789	func_stripname '-Wc,' '' "$arg"
5790	args=$func_stripname_result
5791	arg=
5792	save_ifs="$IFS"; IFS=','
5793	for flag in $args; do
5794	  IFS="$save_ifs"
5795          func_quote_for_eval "$flag"
5796	  func_append arg " $func_quote_for_eval_result"
5797	  func_append compiler_flags " $func_quote_for_eval_result"
5798	done
5799	IFS="$save_ifs"
5800	func_stripname ' ' '' "$arg"
5801	arg=$func_stripname_result
5802	;;
5803
5804      -Wl,*)
5805	func_stripname '-Wl,' '' "$arg"
5806	args=$func_stripname_result
5807	arg=
5808	save_ifs="$IFS"; IFS=','
5809	for flag in $args; do
5810	  IFS="$save_ifs"
5811          func_quote_for_eval "$flag"
5812	  func_append arg " $wl$func_quote_for_eval_result"
5813	  func_append compiler_flags " $wl$func_quote_for_eval_result"
5814	  func_append linker_flags " $func_quote_for_eval_result"
5815	done
5816	IFS="$save_ifs"
5817	func_stripname ' ' '' "$arg"
5818	arg=$func_stripname_result
5819	;;
5820
5821      -Xcompiler)
5822	prev=xcompiler
5823	continue
5824	;;
5825
5826      -Xlinker)
5827	prev=xlinker
5828	continue
5829	;;
5830
5831      -XCClinker)
5832	prev=xcclinker
5833	continue
5834	;;
5835
5836      # -msg_* for osf cc
5837      -msg_*)
5838	func_quote_for_eval "$arg"
5839	arg="$func_quote_for_eval_result"
5840	;;
5841
5842      # Flags to be passed through unchanged, with rationale:
5843      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
5844      # -r[0-9][0-9]*        specify processor for the SGI compiler
5845      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
5846      # +DA*, +DD*           enable 64-bit mode for the HP compiler
5847      # -q*                  compiler args for the IBM compiler
5848      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
5849      # -F/path              path to uninstalled frameworks, gcc on darwin
5850      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
5851      # @file                GCC response files
5852      # -tp=*                Portland pgcc target processor selection
5853      # --sysroot=*          for sysroot support
5854      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
5855      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
5856      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
5857      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
5858        func_quote_for_eval "$arg"
5859	arg="$func_quote_for_eval_result"
5860        func_append compile_command " $arg"
5861        func_append finalize_command " $arg"
5862        func_append compiler_flags " $arg"
5863        continue
5864        ;;
5865
5866      # Some other compiler flag.
5867      -* | +*)
5868        func_quote_for_eval "$arg"
5869	arg="$func_quote_for_eval_result"
5870	;;
5871
5872      *.$objext)
5873	# A standard object.
5874	func_append objs " $arg"
5875	;;
5876
5877      *.lo)
5878	# A libtool-controlled object.
5879
5880	# Check to see that this really is a libtool object.
5881	if func_lalib_unsafe_p "$arg"; then
5882	  pic_object=
5883	  non_pic_object=
5884
5885	  # Read the .lo file
5886	  func_source "$arg"
5887
5888	  if test -z "$pic_object" ||
5889	     test -z "$non_pic_object" ||
5890	     test "$pic_object" = none &&
5891	     test "$non_pic_object" = none; then
5892	    func_fatal_error "cannot find name of object for \`$arg'"
5893	  fi
5894
5895	  # Extract subdirectory from the argument.
5896	  func_dirname "$arg" "/" ""
5897	  xdir="$func_dirname_result"
5898
5899	  if test "$pic_object" != none; then
5900	    # Prepend the subdirectory the object is found in.
5901	    pic_object="$xdir$pic_object"
5902
5903	    if test "$prev" = dlfiles; then
5904	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5905		func_append dlfiles " $pic_object"
5906		prev=
5907		continue
5908	      else
5909		# If libtool objects are unsupported, then we need to preload.
5910		prev=dlprefiles
5911	      fi
5912	    fi
5913
5914	    # CHECK ME:  I think I busted this.  -Ossama
5915	    if test "$prev" = dlprefiles; then
5916	      # Preload the old-style object.
5917	      func_append dlprefiles " $pic_object"
5918	      prev=
5919	    fi
5920
5921	    # A PIC object.
5922	    func_append libobjs " $pic_object"
5923	    arg="$pic_object"
5924	  fi
5925
5926	  # Non-PIC object.
5927	  if test "$non_pic_object" != none; then
5928	    # Prepend the subdirectory the object is found in.
5929	    non_pic_object="$xdir$non_pic_object"
5930
5931	    # A standard non-PIC object
5932	    func_append non_pic_objects " $non_pic_object"
5933	    if test -z "$pic_object" || test "$pic_object" = none ; then
5934	      arg="$non_pic_object"
5935	    fi
5936	  else
5937	    # If the PIC object exists, use it instead.
5938	    # $xdir was prepended to $pic_object above.
5939	    non_pic_object="$pic_object"
5940	    func_append non_pic_objects " $non_pic_object"
5941	  fi
5942	else
5943	  # Only an error if not doing a dry-run.
5944	  if $opt_dry_run; then
5945	    # Extract subdirectory from the argument.
5946	    func_dirname "$arg" "/" ""
5947	    xdir="$func_dirname_result"
5948
5949	    func_lo2o "$arg"
5950	    pic_object=$xdir$objdir/$func_lo2o_result
5951	    non_pic_object=$xdir$func_lo2o_result
5952	    func_append libobjs " $pic_object"
5953	    func_append non_pic_objects " $non_pic_object"
5954	  else
5955	    func_fatal_error "\`$arg' is not a valid libtool object"
5956	  fi
5957	fi
5958	;;
5959
5960      *.$libext)
5961	# An archive.
5962	func_append deplibs " $arg"
5963	func_append old_deplibs " $arg"
5964	continue
5965	;;
5966
5967      *.la)
5968	# A libtool-controlled library.
5969
5970	func_resolve_sysroot "$arg"
5971	if test "$prev" = dlfiles; then
5972	  # This library was specified with -dlopen.
5973	  func_append dlfiles " $func_resolve_sysroot_result"
5974	  prev=
5975	elif test "$prev" = dlprefiles; then
5976	  # The library was specified with -dlpreopen.
5977	  func_append dlprefiles " $func_resolve_sysroot_result"
5978	  prev=
5979	else
5980	  func_append deplibs " $func_resolve_sysroot_result"
5981	fi
5982	continue
5983	;;
5984
5985      # Some other compiler argument.
5986      *)
5987	# Unknown arguments in both finalize_command and compile_command need
5988	# to be aesthetically quoted because they are evaled later.
5989	func_quote_for_eval "$arg"
5990	arg="$func_quote_for_eval_result"
5991	;;
5992      esac # arg
5993
5994      # Now actually substitute the argument into the commands.
5995      if test -n "$arg"; then
5996	func_append compile_command " $arg"
5997	func_append finalize_command " $arg"
5998      fi
5999    done # argument parsing loop
6000
6001    test -n "$prev" && \
6002      func_fatal_help "the \`$prevarg' option requires an argument"
6003
6004    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
6005      eval arg=\"$export_dynamic_flag_spec\"
6006      func_append compile_command " $arg"
6007      func_append finalize_command " $arg"
6008    fi
6009
6010    oldlibs=
6011    # calculate the name of the file, without its directory
6012    func_basename "$output"
6013    outputname="$func_basename_result"
6014    libobjs_save="$libobjs"
6015
6016    if test -n "$shlibpath_var"; then
6017      # get the directories listed in $shlibpath_var
6018      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
6019    else
6020      shlib_search_path=
6021    fi
6022    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
6023    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
6024
6025    func_dirname "$output" "/" ""
6026    output_objdir="$func_dirname_result$objdir"
6027    func_to_tool_file "$output_objdir/"
6028    tool_output_objdir=$func_to_tool_file_result
6029    # Create the object directory.
6030    func_mkdir_p "$output_objdir"
6031
6032    # Determine the type of output
6033    case $output in
6034    "")
6035      func_fatal_help "you must specify an output file"
6036      ;;
6037    *.$libext) linkmode=oldlib ;;
6038    *.lo | *.$objext) linkmode=obj ;;
6039    *.la) linkmode=lib ;;
6040    *) linkmode=prog ;; # Anything else should be a program.
6041    esac
6042
6043    specialdeplibs=
6044
6045    libs=
6046    # Find all interdependent deplibs by searching for libraries
6047    # that are linked more than once (e.g. -la -lb -la)
6048    for deplib in $deplibs; do
6049      if $opt_preserve_dup_deps ; then
6050	case "$libs " in
6051	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
6052	esac
6053      fi
6054      func_append libs " $deplib"
6055    done
6056
6057    if test "$linkmode" = lib; then
6058      libs="$predeps $libs $compiler_lib_search_path $postdeps"
6059
6060      # Compute libraries that are listed more than once in $predeps
6061      # $postdeps and mark them as special (i.e., whose duplicates are
6062      # not to be eliminated).
6063      pre_post_deps=
6064      if $opt_duplicate_compiler_generated_deps; then
6065	for pre_post_dep in $predeps $postdeps; do
6066	  case "$pre_post_deps " in
6067	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
6068	  esac
6069	  func_append pre_post_deps " $pre_post_dep"
6070	done
6071      fi
6072      pre_post_deps=
6073    fi
6074
6075    deplibs=
6076    newdependency_libs=
6077    newlib_search_path=
6078    need_relink=no # whether we're linking any uninstalled libtool libraries
6079    notinst_deplibs= # not-installed libtool libraries
6080    notinst_path= # paths that contain not-installed libtool libraries
6081
6082    case $linkmode in
6083    lib)
6084	passes="conv dlpreopen link"
6085	for file in $dlfiles $dlprefiles; do
6086	  case $file in
6087	  *.la) ;;
6088	  *)
6089	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
6090	    ;;
6091	  esac
6092	done
6093	;;
6094    prog)
6095	compile_deplibs=
6096	finalize_deplibs=
6097	alldeplibs=no
6098	newdlfiles=
6099	newdlprefiles=
6100	passes="conv scan dlopen dlpreopen link"
6101	;;
6102    *)  passes="conv"
6103	;;
6104    esac
6105
6106    for pass in $passes; do
6107      # The preopen pass in lib mode reverses $deplibs; put it back here
6108      # so that -L comes before libs that need it for instance...
6109      if test "$linkmode,$pass" = "lib,link"; then
6110	## FIXME: Find the place where the list is rebuilt in the wrong
6111	##        order, and fix it there properly
6112        tmp_deplibs=
6113	for deplib in $deplibs; do
6114	  tmp_deplibs="$deplib $tmp_deplibs"
6115	done
6116	deplibs="$tmp_deplibs"
6117      fi
6118
6119      if test "$linkmode,$pass" = "lib,link" ||
6120	 test "$linkmode,$pass" = "prog,scan"; then
6121	libs="$deplibs"
6122	deplibs=
6123      fi
6124      if test "$linkmode" = prog; then
6125	case $pass in
6126	dlopen) libs="$dlfiles" ;;
6127	dlpreopen) libs="$dlprefiles" ;;
6128	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
6129	esac
6130      fi
6131      if test "$linkmode,$pass" = "lib,dlpreopen"; then
6132	# Collect and forward deplibs of preopened libtool libs
6133	for lib in $dlprefiles; do
6134	  # Ignore non-libtool-libs
6135	  dependency_libs=
6136	  func_resolve_sysroot "$lib"
6137	  case $lib in
6138	  *.la)	func_source "$func_resolve_sysroot_result" ;;
6139	  esac
6140
6141	  # Collect preopened libtool deplibs, except any this library
6142	  # has declared as weak libs
6143	  for deplib in $dependency_libs; do
6144	    func_basename "$deplib"
6145            deplib_base=$func_basename_result
6146	    case " $weak_libs " in
6147	    *" $deplib_base "*) ;;
6148	    *) func_append deplibs " $deplib" ;;
6149	    esac
6150	  done
6151	done
6152	libs="$dlprefiles"
6153      fi
6154      if test "$pass" = dlopen; then
6155	# Collect dlpreopened libraries
6156	save_deplibs="$deplibs"
6157	deplibs=
6158      fi
6159
6160      for deplib in $libs; do
6161	lib=
6162	found=no
6163	case $deplib in
6164	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
6165        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
6166	  if test "$linkmode,$pass" = "prog,link"; then
6167	    compile_deplibs="$deplib $compile_deplibs"
6168	    finalize_deplibs="$deplib $finalize_deplibs"
6169	  else
6170	    func_append compiler_flags " $deplib"
6171	    if test "$linkmode" = lib ; then
6172		case "$new_inherited_linker_flags " in
6173		    *" $deplib "*) ;;
6174		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6175		esac
6176	    fi
6177	  fi
6178	  continue
6179	  ;;
6180	-l*)
6181	  if test "$linkmode" != lib && test "$linkmode" != prog; then
6182	    func_warning "\`-l' is ignored for archives/objects"
6183	    continue
6184	  fi
6185	  func_stripname '-l' '' "$deplib"
6186	  name=$func_stripname_result
6187	  if test "$linkmode" = lib; then
6188	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
6189	  else
6190	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
6191	  fi
6192	  for searchdir in $searchdirs; do
6193	    for search_ext in .la $std_shrext .so .a; do
6194	      # Search the libtool library
6195	      lib="$searchdir/lib${name}${search_ext}"
6196	      if test -f "$lib"; then
6197		if test "$search_ext" = ".la"; then
6198		  found=yes
6199		else
6200		  found=no
6201		fi
6202		break 2
6203	      fi
6204	    done
6205	  done
6206	  if test "$found" != yes; then
6207	    # deplib doesn't seem to be a libtool library
6208	    if test "$linkmode,$pass" = "prog,link"; then
6209	      compile_deplibs="$deplib $compile_deplibs"
6210	      finalize_deplibs="$deplib $finalize_deplibs"
6211	    else
6212	      deplibs="$deplib $deplibs"
6213	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6214	    fi
6215	    continue
6216	  else # deplib is a libtool library
6217	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
6218	    # We need to do some special things here, and not later.
6219	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6220	      case " $predeps $postdeps " in
6221	      *" $deplib "*)
6222		if func_lalib_p "$lib"; then
6223		  library_names=
6224		  old_library=
6225		  func_source "$lib"
6226		  for l in $old_library $library_names; do
6227		    ll="$l"
6228		  done
6229		  if test "X$ll" = "X$old_library" ; then # only static version available
6230		    found=no
6231		    func_dirname "$lib" "" "."
6232		    ladir="$func_dirname_result"
6233		    lib=$ladir/$old_library
6234		    if test "$linkmode,$pass" = "prog,link"; then
6235		      compile_deplibs="$deplib $compile_deplibs"
6236		      finalize_deplibs="$deplib $finalize_deplibs"
6237		    else
6238		      deplibs="$deplib $deplibs"
6239		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6240		    fi
6241		    continue
6242		  fi
6243		fi
6244		;;
6245	      *) ;;
6246	      esac
6247	    fi
6248	  fi
6249	  ;; # -l
6250	*.ltframework)
6251	  if test "$linkmode,$pass" = "prog,link"; then
6252	    compile_deplibs="$deplib $compile_deplibs"
6253	    finalize_deplibs="$deplib $finalize_deplibs"
6254	  else
6255	    deplibs="$deplib $deplibs"
6256	    if test "$linkmode" = lib ; then
6257		case "$new_inherited_linker_flags " in
6258		    *" $deplib "*) ;;
6259		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6260		esac
6261	    fi
6262	  fi
6263	  continue
6264	  ;;
6265	-L*)
6266	  case $linkmode in
6267	  lib)
6268	    deplibs="$deplib $deplibs"
6269	    test "$pass" = conv && continue
6270	    newdependency_libs="$deplib $newdependency_libs"
6271	    func_stripname '-L' '' "$deplib"
6272	    func_resolve_sysroot "$func_stripname_result"
6273	    func_append newlib_search_path " $func_resolve_sysroot_result"
6274	    ;;
6275	  prog)
6276	    if test "$pass" = conv; then
6277	      deplibs="$deplib $deplibs"
6278	      continue
6279	    fi
6280	    if test "$pass" = scan; then
6281	      deplibs="$deplib $deplibs"
6282	    else
6283	      compile_deplibs="$deplib $compile_deplibs"
6284	      finalize_deplibs="$deplib $finalize_deplibs"
6285	    fi
6286	    func_stripname '-L' '' "$deplib"
6287	    func_resolve_sysroot "$func_stripname_result"
6288	    func_append newlib_search_path " $func_resolve_sysroot_result"
6289	    ;;
6290	  *)
6291	    func_warning "\`-L' is ignored for archives/objects"
6292	    ;;
6293	  esac # linkmode
6294	  continue
6295	  ;; # -L
6296	-R*)
6297	  if test "$pass" = link; then
6298	    func_stripname '-R' '' "$deplib"
6299	    func_resolve_sysroot "$func_stripname_result"
6300	    dir=$func_resolve_sysroot_result
6301	    # Make sure the xrpath contains only unique directories.
6302	    case "$xrpath " in
6303	    *" $dir "*) ;;
6304	    *) func_append xrpath " $dir" ;;
6305	    esac
6306	  fi
6307	  deplibs="$deplib $deplibs"
6308	  continue
6309	  ;;
6310	*.la)
6311	  func_resolve_sysroot "$deplib"
6312	  lib=$func_resolve_sysroot_result
6313	  ;;
6314	*.$libext)
6315	  if test "$pass" = conv; then
6316	    deplibs="$deplib $deplibs"
6317	    continue
6318	  fi
6319	  case $linkmode in
6320	  lib)
6321	    # Linking convenience modules into shared libraries is allowed,
6322	    # but linking other static libraries is non-portable.
6323	    case " $dlpreconveniencelibs " in
6324	    *" $deplib "*) ;;
6325	    *)
6326	      valid_a_lib=no
6327	      case $deplibs_check_method in
6328		match_pattern*)
6329		  set dummy $deplibs_check_method; shift
6330		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6331		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
6332		    | $EGREP "$match_pattern_regex" > /dev/null; then
6333		    valid_a_lib=yes
6334		  fi
6335		;;
6336		pass_all)
6337		  valid_a_lib=yes
6338		;;
6339	      esac
6340	      if test "$valid_a_lib" != yes; then
6341		echo
6342		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
6343		echo "*** I have the capability to make that library automatically link in when"
6344		echo "*** you link to this library.  But I can only do this if you have a"
6345		echo "*** shared version of the library, which you do not appear to have"
6346		echo "*** because the file extensions .$libext of this argument makes me believe"
6347		echo "*** that it is just a static archive that I should not use here."
6348	      else
6349		echo
6350		$ECHO "*** Warning: Linking the shared library $output against the"
6351		$ECHO "*** static library $deplib is not portable!"
6352		deplibs="$deplib $deplibs"
6353	      fi
6354	      ;;
6355	    esac
6356	    continue
6357	    ;;
6358	  prog)
6359	    if test "$pass" != link; then
6360	      deplibs="$deplib $deplibs"
6361	    else
6362	      compile_deplibs="$deplib $compile_deplibs"
6363	      finalize_deplibs="$deplib $finalize_deplibs"
6364	    fi
6365	    continue
6366	    ;;
6367	  esac # linkmode
6368	  ;; # *.$libext
6369	*.lo | *.$objext)
6370	  if test "$pass" = conv; then
6371	    deplibs="$deplib $deplibs"
6372	  elif test "$linkmode" = prog; then
6373	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
6374	      # If there is no dlopen support or we're linking statically,
6375	      # we need to preload.
6376	      func_append newdlprefiles " $deplib"
6377	      compile_deplibs="$deplib $compile_deplibs"
6378	      finalize_deplibs="$deplib $finalize_deplibs"
6379	    else
6380	      func_append newdlfiles " $deplib"
6381	    fi
6382	  fi
6383	  continue
6384	  ;;
6385	%DEPLIBS%)
6386	  alldeplibs=yes
6387	  continue
6388	  ;;
6389	esac # case $deplib
6390
6391	if test "$found" = yes || test -f "$lib"; then :
6392	else
6393	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
6394	fi
6395
6396	# Check to see that this really is a libtool archive.
6397	func_lalib_unsafe_p "$lib" \
6398	  || func_fatal_error "\`$lib' is not a valid libtool archive"
6399
6400	func_dirname "$lib" "" "."
6401	ladir="$func_dirname_result"
6402
6403	dlname=
6404	dlopen=
6405	dlpreopen=
6406	libdir=
6407	library_names=
6408	old_library=
6409	inherited_linker_flags=
6410	# If the library was installed with an old release of libtool,
6411	# it will not redefine variables installed, or shouldnotlink
6412	installed=yes
6413	shouldnotlink=no
6414	avoidtemprpath=
6415
6416
6417	# Read the .la file
6418	func_source "$lib"
6419
6420	# Convert "-framework foo" to "foo.ltframework"
6421	if test -n "$inherited_linker_flags"; then
6422	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
6423	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
6424	    case " $new_inherited_linker_flags " in
6425	      *" $tmp_inherited_linker_flag "*) ;;
6426	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
6427	    esac
6428	  done
6429	fi
6430	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
6431	if test "$linkmode,$pass" = "lib,link" ||
6432	   test "$linkmode,$pass" = "prog,scan" ||
6433	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
6434	  test -n "$dlopen" && func_append dlfiles " $dlopen"
6435	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
6436	fi
6437
6438	if test "$pass" = conv; then
6439	  # Only check for convenience libraries
6440	  deplibs="$lib $deplibs"
6441	  if test -z "$libdir"; then
6442	    if test -z "$old_library"; then
6443	      func_fatal_error "cannot find name of link library for \`$lib'"
6444	    fi
6445	    # It is a libtool convenience library, so add in its objects.
6446	    func_append convenience " $ladir/$objdir/$old_library"
6447	    func_append old_convenience " $ladir/$objdir/$old_library"
6448	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
6449	    func_fatal_error "\`$lib' is not a convenience library"
6450	  fi
6451	  tmp_libs=
6452	  for deplib in $dependency_libs; do
6453	    deplibs="$deplib $deplibs"
6454	    if $opt_preserve_dup_deps ; then
6455	      case "$tmp_libs " in
6456	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6457	      esac
6458	    fi
6459	    func_append tmp_libs " $deplib"
6460	  done
6461	  continue
6462	fi # $pass = conv
6463
6464
6465	# Get the name of the library we link against.
6466	linklib=
6467	if test -n "$old_library" &&
6468	   { test "$prefer_static_libs" = yes ||
6469	     test "$prefer_static_libs,$installed" = "built,no"; }; then
6470	  linklib=$old_library
6471	else
6472	  for l in $old_library $library_names; do
6473	    linklib="$l"
6474	  done
6475	fi
6476	if test -z "$linklib"; then
6477	  func_fatal_error "cannot find name of link library for \`$lib'"
6478	fi
6479
6480	# This library was specified with -dlopen.
6481	if test "$pass" = dlopen; then
6482	  if test -z "$libdir"; then
6483	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
6484	  fi
6485	  if test -z "$dlname" ||
6486	     test "$dlopen_support" != yes ||
6487	     test "$build_libtool_libs" = no; then
6488	    # If there is no dlname, no dlopen support or we're linking
6489	    # statically, we need to preload.  We also need to preload any
6490	    # dependent libraries so libltdl's deplib preloader doesn't
6491	    # bomb out in the load deplibs phase.
6492	    func_append dlprefiles " $lib $dependency_libs"
6493	  else
6494	    func_append newdlfiles " $lib"
6495	  fi
6496	  continue
6497	fi # $pass = dlopen
6498
6499	# We need an absolute path.
6500	case $ladir in
6501	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
6502	*)
6503	  abs_ladir=`cd "$ladir" && pwd`
6504	  if test -z "$abs_ladir"; then
6505	    func_warning "cannot determine absolute directory name of \`$ladir'"
6506	    func_warning "passing it literally to the linker, although it might fail"
6507	    abs_ladir="$ladir"
6508	  fi
6509	  ;;
6510	esac
6511	func_basename "$lib"
6512	laname="$func_basename_result"
6513
6514	# Find the relevant object directory and library name.
6515	if test "X$installed" = Xyes; then
6516	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6517	    func_warning "library \`$lib' was moved."
6518	    dir="$ladir"
6519	    absdir="$abs_ladir"
6520	    libdir="$abs_ladir"
6521	  else
6522	    dir="$lt_sysroot$libdir"
6523	    absdir="$lt_sysroot$libdir"
6524	  fi
6525	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
6526	else
6527	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6528	    dir="$ladir"
6529	    absdir="$abs_ladir"
6530	    # Remove this search path later
6531	    func_append notinst_path " $abs_ladir"
6532	  else
6533	    dir="$ladir/$objdir"
6534	    absdir="$abs_ladir/$objdir"
6535	    # Remove this search path later
6536	    func_append notinst_path " $abs_ladir"
6537	  fi
6538	fi # $installed = yes
6539	func_stripname 'lib' '.la' "$laname"
6540	name=$func_stripname_result
6541
6542	# This library was specified with -dlpreopen.
6543	if test "$pass" = dlpreopen; then
6544	  if test -z "$libdir" && test "$linkmode" = prog; then
6545	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
6546	  fi
6547	  case "$host" in
6548	    # special handling for platforms with PE-DLLs.
6549	    *cygwin* | *mingw* | *cegcc* )
6550	      # Linker will automatically link against shared library if both
6551	      # static and shared are present.  Therefore, ensure we extract
6552	      # symbols from the import library if a shared library is present
6553	      # (otherwise, the dlopen module name will be incorrect).  We do
6554	      # this by putting the import library name into $newdlprefiles.
6555	      # We recover the dlopen module name by 'saving' the la file
6556	      # name in a special purpose variable, and (later) extracting the
6557	      # dlname from the la file.
6558	      if test -n "$dlname"; then
6559	        func_tr_sh "$dir/$linklib"
6560	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
6561	        func_append newdlprefiles " $dir/$linklib"
6562	      else
6563	        func_append newdlprefiles " $dir/$old_library"
6564	        # Keep a list of preopened convenience libraries to check
6565	        # that they are being used correctly in the link pass.
6566	        test -z "$libdir" && \
6567	          func_append dlpreconveniencelibs " $dir/$old_library"
6568	      fi
6569	    ;;
6570	    * )
6571	      # Prefer using a static library (so that no silly _DYNAMIC symbols
6572	      # are required to link).
6573	      if test -n "$old_library"; then
6574	        func_append newdlprefiles " $dir/$old_library"
6575	        # Keep a list of preopened convenience libraries to check
6576	        # that they are being used correctly in the link pass.
6577	        test -z "$libdir" && \
6578	          func_append dlpreconveniencelibs " $dir/$old_library"
6579	      # Otherwise, use the dlname, so that lt_dlopen finds it.
6580	      elif test -n "$dlname"; then
6581	        func_append newdlprefiles " $dir/$dlname"
6582	      else
6583	        func_append newdlprefiles " $dir/$linklib"
6584	      fi
6585	    ;;
6586	  esac
6587	fi # $pass = dlpreopen
6588
6589	if test -z "$libdir"; then
6590	  # Link the convenience library
6591	  if test "$linkmode" = lib; then
6592	    deplibs="$dir/$old_library $deplibs"
6593	  elif test "$linkmode,$pass" = "prog,link"; then
6594	    compile_deplibs="$dir/$old_library $compile_deplibs"
6595	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
6596	  else
6597	    deplibs="$lib $deplibs" # used for prog,scan pass
6598	  fi
6599	  continue
6600	fi
6601
6602
6603	if test "$linkmode" = prog && test "$pass" != link; then
6604	  func_append newlib_search_path " $ladir"
6605	  deplibs="$lib $deplibs"
6606
6607	  linkalldeplibs=no
6608	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
6609	     test "$build_libtool_libs" = no; then
6610	    linkalldeplibs=yes
6611	  fi
6612
6613	  tmp_libs=
6614	  for deplib in $dependency_libs; do
6615	    case $deplib in
6616	    -L*) func_stripname '-L' '' "$deplib"
6617	         func_resolve_sysroot "$func_stripname_result"
6618	         func_append newlib_search_path " $func_resolve_sysroot_result"
6619		 ;;
6620	    esac
6621	    # Need to link against all dependency_libs?
6622	    if test "$linkalldeplibs" = yes; then
6623	      deplibs="$deplib $deplibs"
6624	    else
6625	      # Need to hardcode shared library paths
6626	      # or/and link against static libraries
6627	      newdependency_libs="$deplib $newdependency_libs"
6628	    fi
6629	    if $opt_preserve_dup_deps ; then
6630	      case "$tmp_libs " in
6631	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6632	      esac
6633	    fi
6634	    func_append tmp_libs " $deplib"
6635	  done # for deplib
6636	  continue
6637	fi # $linkmode = prog...
6638
6639	if test "$linkmode,$pass" = "prog,link"; then
6640	  if test -n "$library_names" &&
6641	     { { test "$prefer_static_libs" = no ||
6642	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
6643	       test -z "$old_library"; }; then
6644	    # We need to hardcode the library path
6645	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
6646	      # Make sure the rpath contains only unique directories.
6647	      case "$temp_rpath:" in
6648	      *"$absdir:"*) ;;
6649	      *) func_append temp_rpath "$absdir:" ;;
6650	      esac
6651	    fi
6652
6653	    # Hardcode the library path.
6654	    # Skip directories that are in the system default run-time
6655	    # search path.
6656	    case " $sys_lib_dlsearch_path " in
6657	    *" $absdir "*) ;;
6658	    *)
6659	      case "$compile_rpath " in
6660	      *" $absdir "*) ;;
6661	      *) func_append compile_rpath " $absdir" ;;
6662	      esac
6663	      ;;
6664	    esac
6665	    case " $sys_lib_dlsearch_path " in
6666	    *" $libdir "*) ;;
6667	    *)
6668	      case "$finalize_rpath " in
6669	      *" $libdir "*) ;;
6670	      *) func_append finalize_rpath " $libdir" ;;
6671	      esac
6672	      ;;
6673	    esac
6674	  fi # $linkmode,$pass = prog,link...
6675
6676	  if test "$alldeplibs" = yes &&
6677	     { test "$deplibs_check_method" = pass_all ||
6678	       { test "$build_libtool_libs" = yes &&
6679		 test -n "$library_names"; }; }; then
6680	    # We only need to search for static libraries
6681	    continue
6682	  fi
6683	fi
6684
6685	link_static=no # Whether the deplib will be linked statically
6686	use_static_libs=$prefer_static_libs
6687	if test "$use_static_libs" = built && test "$installed" = yes; then
6688	  use_static_libs=no
6689	fi
6690	if test -n "$library_names" &&
6691	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
6692	  case $host in
6693	  *cygwin* | *mingw* | *cegcc*)
6694	      # No point in relinking DLLs because paths are not encoded
6695	      func_append notinst_deplibs " $lib"
6696	      need_relink=no
6697	    ;;
6698	  *)
6699	    if test "$installed" = no; then
6700	      func_append notinst_deplibs " $lib"
6701	      need_relink=yes
6702	    fi
6703	    ;;
6704	  esac
6705	  # This is a shared library
6706
6707	  # Warn about portability, can't link against -module's on some
6708	  # systems (darwin).  Don't bleat about dlopened modules though!
6709	  dlopenmodule=""
6710	  for dlpremoduletest in $dlprefiles; do
6711	    if test "X$dlpremoduletest" = "X$lib"; then
6712	      dlopenmodule="$dlpremoduletest"
6713	      break
6714	    fi
6715	  done
6716	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
6717	    echo
6718	    if test "$linkmode" = prog; then
6719	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
6720	    else
6721	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
6722	    fi
6723	    $ECHO "*** $linklib is not portable!"
6724	  fi
6725	  if test "$linkmode" = lib &&
6726	     test "$hardcode_into_libs" = yes; then
6727	    # Hardcode the library path.
6728	    # Skip directories that are in the system default run-time
6729	    # search path.
6730	    case " $sys_lib_dlsearch_path " in
6731	    *" $absdir "*) ;;
6732	    *)
6733	      case "$compile_rpath " in
6734	      *" $absdir "*) ;;
6735	      *) func_append compile_rpath " $absdir" ;;
6736	      esac
6737	      ;;
6738	    esac
6739	    case " $sys_lib_dlsearch_path " in
6740	    *" $libdir "*) ;;
6741	    *)
6742	      case "$finalize_rpath " in
6743	      *" $libdir "*) ;;
6744	      *) func_append finalize_rpath " $libdir" ;;
6745	      esac
6746	      ;;
6747	    esac
6748	  fi
6749
6750	  if test -n "$old_archive_from_expsyms_cmds"; then
6751	    # figure out the soname
6752	    set dummy $library_names
6753	    shift
6754	    realname="$1"
6755	    shift
6756	    libname=`eval "\\$ECHO \"$libname_spec\""`
6757	    # use dlname if we got it. it's perfectly good, no?
6758	    if test -n "$dlname"; then
6759	      soname="$dlname"
6760	    elif test -n "$soname_spec"; then
6761	      # bleh windows
6762	      case $host in
6763	      *cygwin* | mingw* | *cegcc*)
6764	        func_arith $current - $age
6765		major=$func_arith_result
6766		versuffix="-$major"
6767		;;
6768	      esac
6769	      eval soname=\"$soname_spec\"
6770	    else
6771	      soname="$realname"
6772	    fi
6773
6774	    # Make a new name for the extract_expsyms_cmds to use
6775	    soroot="$soname"
6776	    func_basename "$soroot"
6777	    soname="$func_basename_result"
6778	    func_stripname 'lib' '.dll' "$soname"
6779	    newlib=libimp-$func_stripname_result.a
6780
6781	    # If the library has no export list, then create one now
6782	    if test -f "$output_objdir/$soname-def"; then :
6783	    else
6784	      func_verbose "extracting exported symbol list from \`$soname'"
6785	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
6786	    fi
6787
6788	    # Create $newlib
6789	    if test -f "$output_objdir/$newlib"; then :; else
6790	      func_verbose "generating import library for \`$soname'"
6791	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
6792	    fi
6793	    # make sure the library variables are pointing to the new library
6794	    dir=$output_objdir
6795	    linklib=$newlib
6796	  fi # test -n "$old_archive_from_expsyms_cmds"
6797
6798	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
6799	    add_shlibpath=
6800	    add_dir=
6801	    add=
6802	    lib_linked=yes
6803	    case $hardcode_action in
6804	    immediate | unsupported)
6805	      if test "$hardcode_direct" = no; then
6806		add="$dir/$linklib"
6807		case $host in
6808		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
6809		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
6810		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
6811		    *-*-unixware7*) add_dir="-L$dir" ;;
6812		  *-*-darwin* )
6813		    # if the lib is a (non-dlopened) module then we can not
6814		    # link against it, someone is ignoring the earlier warnings
6815		    if /usr/bin/file -L $add 2> /dev/null |
6816			 $GREP ": [^:]* bundle" >/dev/null ; then
6817		      if test "X$dlopenmodule" != "X$lib"; then
6818			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
6819			if test -z "$old_library" ; then
6820			  echo
6821			  echo "*** And there doesn't seem to be a static archive available"
6822			  echo "*** The link will probably fail, sorry"
6823			else
6824			  add="$dir/$old_library"
6825			fi
6826		      elif test -n "$old_library"; then
6827			add="$dir/$old_library"
6828		      fi
6829		    fi
6830		esac
6831	      elif test "$hardcode_minus_L" = no; then
6832		case $host in
6833		*-*-sunos*) add_shlibpath="$dir" ;;
6834		esac
6835		add_dir="-L$dir"
6836		add="-l$name"
6837	      elif test "$hardcode_shlibpath_var" = no; then
6838		add_shlibpath="$dir"
6839		add="-l$name"
6840	      else
6841		lib_linked=no
6842	      fi
6843	      ;;
6844	    relink)
6845	      if test "$hardcode_direct" = yes &&
6846	         test "$hardcode_direct_absolute" = no; then
6847		add="$dir/$linklib"
6848	      elif test "$hardcode_minus_L" = yes; then
6849		add_dir="-L$absdir"
6850		# Try looking first in the location we're being installed to.
6851		if test -n "$inst_prefix_dir"; then
6852		  case $libdir in
6853		    [\\/]*)
6854		      func_append add_dir " -L$inst_prefix_dir$libdir"
6855		      ;;
6856		  esac
6857		fi
6858		add="-l$name"
6859	      elif test "$hardcode_shlibpath_var" = yes; then
6860		add_shlibpath="$dir"
6861		add="-l$name"
6862	      else
6863		lib_linked=no
6864	      fi
6865	      ;;
6866	    *) lib_linked=no ;;
6867	    esac
6868
6869	    if test "$lib_linked" != yes; then
6870	      func_fatal_configuration "unsupported hardcode properties"
6871	    fi
6872
6873	    if test -n "$add_shlibpath"; then
6874	      case :$compile_shlibpath: in
6875	      *":$add_shlibpath:"*) ;;
6876	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
6877	      esac
6878	    fi
6879	    if test "$linkmode" = prog; then
6880	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
6881	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
6882	    else
6883	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6884	      test -n "$add" && deplibs="$add $deplibs"
6885	      if test "$hardcode_direct" != yes &&
6886		 test "$hardcode_minus_L" != yes &&
6887		 test "$hardcode_shlibpath_var" = yes; then
6888		case :$finalize_shlibpath: in
6889		*":$libdir:"*) ;;
6890		*) func_append finalize_shlibpath "$libdir:" ;;
6891		esac
6892	      fi
6893	    fi
6894	  fi
6895
6896	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
6897	    add_shlibpath=
6898	    add_dir=
6899	    add=
6900	    # Finalize command for both is simple: just hardcode it.
6901	    if test "$hardcode_direct" = yes &&
6902	       test "$hardcode_direct_absolute" = no; then
6903	      if test -f "$inst_prefix_dir$libdir/$linklib"; then
6904	        add="$inst_prefix_dir$libdir/$linklib"
6905	      else
6906	        add="$libdir/$linklib"
6907	      fi
6908	    elif test "$hardcode_minus_L" = yes; then
6909	      add_dir="-L$libdir"
6910	      add="-l$name"
6911	    elif test "$hardcode_shlibpath_var" = yes; then
6912	      case :$finalize_shlibpath: in
6913	      *":$libdir:"*) ;;
6914	      *) func_append finalize_shlibpath "$libdir:" ;;
6915	      esac
6916	      add="-l$name"
6917	    elif test "$hardcode_automatic" = yes; then
6918	      if test -n "$inst_prefix_dir" &&
6919		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
6920		add="$inst_prefix_dir$libdir/$linklib"
6921	      else
6922		add="$libdir/$linklib"
6923	      fi
6924	    else
6925	      # We cannot seem to hardcode it, guess we'll fake it.
6926	      add_dir="-L$libdir"
6927	      # Try looking first in the location we're being installed to.
6928	      if test -n "$inst_prefix_dir"; then
6929		case $libdir in
6930		  [\\/]*)
6931		    func_append add_dir " -L$inst_prefix_dir$libdir"
6932		    ;;
6933		esac
6934	      fi
6935	      add="-l$name"
6936	    fi
6937
6938	    if test "$linkmode" = prog; then
6939	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
6940	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
6941	    else
6942	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6943	      test -n "$add" && deplibs="$add $deplibs"
6944	    fi
6945	  fi
6946	elif test "$linkmode" = prog; then
6947	  # Here we assume that one of hardcode_direct or hardcode_minus_L
6948	  # is not unsupported.  This is valid on all known static and
6949	  # shared platforms.
6950	  if test "$hardcode_direct" != unsupported; then
6951	    test -n "$old_library" && linklib="$old_library"
6952	    compile_deplibs="$dir/$linklib $compile_deplibs"
6953	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
6954	  else
6955	    compile_deplibs="-l$name -L$dir $compile_deplibs"
6956	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
6957	  fi
6958	elif test "$build_libtool_libs" = yes; then
6959	  # Not a shared library
6960	  if test "$deplibs_check_method" != pass_all; then
6961	    # We're trying link a shared library against a static one
6962	    # but the system doesn't support it.
6963
6964	    # Just print a warning and add the library to dependency_libs so
6965	    # that the program can be linked against the static library.
6966	    echo
6967	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
6968	    echo "*** I have the capability to make that library automatically link in when"
6969	    echo "*** you link to this library.  But I can only do this if you have a"
6970	    echo "*** shared version of the library, which you do not appear to have."
6971	    if test "$module" = yes; then
6972	      echo "*** But as you try to build a module library, libtool will still create "
6973	      echo "*** a static module, that should work as long as the dlopening application"
6974	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
6975	      if test -z "$global_symbol_pipe"; then
6976		echo
6977		echo "*** However, this would only work if libtool was able to extract symbol"
6978		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
6979		echo "*** not find such a program.  So, this module is probably useless."
6980		echo "*** \`nm' from GNU binutils and a full rebuild may help."
6981	      fi
6982	      if test "$build_old_libs" = no; then
6983		build_libtool_libs=module
6984		build_old_libs=yes
6985	      else
6986		build_libtool_libs=no
6987	      fi
6988	    fi
6989	  else
6990	    deplibs="$dir/$old_library $deplibs"
6991	    link_static=yes
6992	  fi
6993	fi # link shared/static library?
6994
6995	if test "$linkmode" = lib; then
6996	  if test -n "$dependency_libs" &&
6997	     { test "$hardcode_into_libs" != yes ||
6998	       test "$build_old_libs" = yes ||
6999	       test "$link_static" = yes; }; then
7000	    # Extract -R from dependency_libs
7001	    temp_deplibs=
7002	    for libdir in $dependency_libs; do
7003	      case $libdir in
7004	      -R*) func_stripname '-R' '' "$libdir"
7005	           temp_xrpath=$func_stripname_result
7006		   case " $xrpath " in
7007		   *" $temp_xrpath "*) ;;
7008		   *) func_append xrpath " $temp_xrpath";;
7009		   esac;;
7010	      *) func_append temp_deplibs " $libdir";;
7011	      esac
7012	    done
7013	    dependency_libs="$temp_deplibs"
7014	  fi
7015
7016	  func_append newlib_search_path " $absdir"
7017	  # Link against this library
7018	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
7019	  # ... and its dependency_libs
7020	  tmp_libs=
7021	  for deplib in $dependency_libs; do
7022	    newdependency_libs="$deplib $newdependency_libs"
7023	    case $deplib in
7024              -L*) func_stripname '-L' '' "$deplib"
7025                   func_resolve_sysroot "$func_stripname_result";;
7026              *) func_resolve_sysroot "$deplib" ;;
7027            esac
7028	    if $opt_preserve_dup_deps ; then
7029	      case "$tmp_libs " in
7030	      *" $func_resolve_sysroot_result "*)
7031                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
7032	      esac
7033	    fi
7034	    func_append tmp_libs " $func_resolve_sysroot_result"
7035	  done
7036
7037	  if test "$link_all_deplibs" != no; then
7038	    # Add the search paths of all dependency libraries
7039	    for deplib in $dependency_libs; do
7040	      path=
7041	      case $deplib in
7042	      -L*) path="$deplib" ;;
7043	      *.la)
7044	        func_resolve_sysroot "$deplib"
7045	        deplib=$func_resolve_sysroot_result
7046	        func_dirname "$deplib" "" "."
7047		dir=$func_dirname_result
7048		# We need an absolute path.
7049		case $dir in
7050		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
7051		*)
7052		  absdir=`cd "$dir" && pwd`
7053		  if test -z "$absdir"; then
7054		    func_warning "cannot determine absolute directory name of \`$dir'"
7055		    absdir="$dir"
7056		  fi
7057		  ;;
7058		esac
7059		if $GREP "^installed=no" $deplib > /dev/null; then
7060		case $host in
7061		*-*-darwin*)
7062		  depdepl=
7063		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
7064		  if test -n "$deplibrary_names" ; then
7065		    for tmp in $deplibrary_names ; do
7066		      depdepl=$tmp
7067		    done
7068		    if test -f "$absdir/$objdir/$depdepl" ; then
7069		      depdepl="$absdir/$objdir/$depdepl"
7070		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
7071                      if test -z "$darwin_install_name"; then
7072                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
7073                      fi
7074		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
7075		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
7076		      path=
7077		    fi
7078		  fi
7079		  ;;
7080		*)
7081		  path="-L$absdir/$objdir"
7082		  ;;
7083		esac
7084		else
7085		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
7086		  test -z "$libdir" && \
7087		    func_fatal_error "\`$deplib' is not a valid libtool archive"
7088		  test "$absdir" != "$libdir" && \
7089		    func_warning "\`$deplib' seems to be moved"
7090
7091		  path="-L$absdir"
7092		fi
7093		;;
7094	      esac
7095	      case " $deplibs " in
7096	      *" $path "*) ;;
7097	      *) deplibs="$path $deplibs" ;;
7098	      esac
7099	    done
7100	  fi # link_all_deplibs != no
7101	fi # linkmode = lib
7102      done # for deplib in $libs
7103      if test "$pass" = link; then
7104	if test "$linkmode" = "prog"; then
7105	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
7106	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
7107	else
7108	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7109	fi
7110      fi
7111      dependency_libs="$newdependency_libs"
7112      if test "$pass" = dlpreopen; then
7113	# Link the dlpreopened libraries before other libraries
7114	for deplib in $save_deplibs; do
7115	  deplibs="$deplib $deplibs"
7116	done
7117      fi
7118      if test "$pass" != dlopen; then
7119	if test "$pass" != conv; then
7120	  # Make sure lib_search_path contains only unique directories.
7121	  lib_search_path=
7122	  for dir in $newlib_search_path; do
7123	    case "$lib_search_path " in
7124	    *" $dir "*) ;;
7125	    *) func_append lib_search_path " $dir" ;;
7126	    esac
7127	  done
7128	  newlib_search_path=
7129	fi
7130
7131	if test "$linkmode,$pass" != "prog,link"; then
7132	  vars="deplibs"
7133	else
7134	  vars="compile_deplibs finalize_deplibs"
7135	fi
7136	for var in $vars dependency_libs; do
7137	  # Add libraries to $var in reverse order
7138	  eval tmp_libs=\"\$$var\"
7139	  new_libs=
7140	  for deplib in $tmp_libs; do
7141	    # FIXME: Pedantically, this is the right thing to do, so
7142	    #        that some nasty dependency loop isn't accidentally
7143	    #        broken:
7144	    #new_libs="$deplib $new_libs"
7145	    # Pragmatically, this seems to cause very few problems in
7146	    # practice:
7147	    case $deplib in
7148	    -L*) new_libs="$deplib $new_libs" ;;
7149	    -R*) ;;
7150	    *)
7151	      # And here is the reason: when a library appears more
7152	      # than once as an explicit dependence of a library, or
7153	      # is implicitly linked in more than once by the
7154	      # compiler, it is considered special, and multiple
7155	      # occurrences thereof are not removed.  Compare this
7156	      # with having the same library being listed as a
7157	      # dependency of multiple other libraries: in this case,
7158	      # we know (pedantically, we assume) the library does not
7159	      # need to be listed more than once, so we keep only the
7160	      # last copy.  This is not always right, but it is rare
7161	      # enough that we require users that really mean to play
7162	      # such unportable linking tricks to link the library
7163	      # using -Wl,-lname, so that libtool does not consider it
7164	      # for duplicate removal.
7165	      case " $specialdeplibs " in
7166	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
7167	      *)
7168		case " $new_libs " in
7169		*" $deplib "*) ;;
7170		*) new_libs="$deplib $new_libs" ;;
7171		esac
7172		;;
7173	      esac
7174	      ;;
7175	    esac
7176	  done
7177	  tmp_libs=
7178	  for deplib in $new_libs; do
7179	    case $deplib in
7180	    -L*)
7181	      case " $tmp_libs " in
7182	      *" $deplib "*) ;;
7183	      *) func_append tmp_libs " $deplib" ;;
7184	      esac
7185	      ;;
7186	    *) func_append tmp_libs " $deplib" ;;
7187	    esac
7188	  done
7189	  eval $var=\"$tmp_libs\"
7190	done # for var
7191      fi
7192      # Last step: remove runtime libs from dependency_libs
7193      # (they stay in deplibs)
7194      tmp_libs=
7195      for i in $dependency_libs ; do
7196	case " $predeps $postdeps $compiler_lib_search_path " in
7197	*" $i "*)
7198	  i=""
7199	  ;;
7200	esac
7201	if test -n "$i" ; then
7202	  func_append tmp_libs " $i"
7203	fi
7204      done
7205      dependency_libs=$tmp_libs
7206    done # for pass
7207    if test "$linkmode" = prog; then
7208      dlfiles="$newdlfiles"
7209    fi
7210    if test "$linkmode" = prog || test "$linkmode" = lib; then
7211      dlprefiles="$newdlprefiles"
7212    fi
7213
7214    case $linkmode in
7215    oldlib)
7216      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
7217	func_warning "\`-dlopen' is ignored for archives"
7218      fi
7219
7220      case " $deplibs" in
7221      *\ -l* | *\ -L*)
7222	func_warning "\`-l' and \`-L' are ignored for archives" ;;
7223      esac
7224
7225      test -n "$rpath" && \
7226	func_warning "\`-rpath' is ignored for archives"
7227
7228      test -n "$xrpath" && \
7229	func_warning "\`-R' is ignored for archives"
7230
7231      test -n "$vinfo" && \
7232	func_warning "\`-version-info/-version-number' is ignored for archives"
7233
7234      test -n "$release" && \
7235	func_warning "\`-release' is ignored for archives"
7236
7237      test -n "$export_symbols$export_symbols_regex" && \
7238	func_warning "\`-export-symbols' is ignored for archives"
7239
7240      # Now set the variables for building old libraries.
7241      build_libtool_libs=no
7242      oldlibs="$output"
7243      func_append objs "$old_deplibs"
7244      ;;
7245
7246    lib)
7247      # Make sure we only generate libraries of the form `libNAME.la'.
7248      case $outputname in
7249      lib*)
7250	func_stripname 'lib' '.la' "$outputname"
7251	name=$func_stripname_result
7252	eval shared_ext=\"$shrext_cmds\"
7253	eval libname=\"$libname_spec\"
7254	;;
7255      *)
7256	test "$module" = no && \
7257	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
7258
7259	if test "$need_lib_prefix" != no; then
7260	  # Add the "lib" prefix for modules if required
7261	  func_stripname '' '.la' "$outputname"
7262	  name=$func_stripname_result
7263	  eval shared_ext=\"$shrext_cmds\"
7264	  eval libname=\"$libname_spec\"
7265	else
7266	  func_stripname '' '.la' "$outputname"
7267	  libname=$func_stripname_result
7268	fi
7269	;;
7270      esac
7271
7272      if test -n "$objs"; then
7273	if test "$deplibs_check_method" != pass_all; then
7274	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
7275	else
7276	  echo
7277	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
7278	  $ECHO "*** objects $objs is not portable!"
7279	  func_append libobjs " $objs"
7280	fi
7281      fi
7282
7283      test "$dlself" != no && \
7284	func_warning "\`-dlopen self' is ignored for libtool libraries"
7285
7286      set dummy $rpath
7287      shift
7288      test "$#" -gt 1 && \
7289	func_warning "ignoring multiple \`-rpath's for a libtool library"
7290
7291      install_libdir="$1"
7292
7293      oldlibs=
7294      if test -z "$rpath"; then
7295	if test "$build_libtool_libs" = yes; then
7296	  # Building a libtool convenience library.
7297	  # Some compilers have problems with a `.al' extension so
7298	  # convenience libraries should have the same extension an
7299	  # archive normally would.
7300	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
7301	  build_libtool_libs=convenience
7302	  build_old_libs=yes
7303	fi
7304
7305	test -n "$vinfo" && \
7306	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
7307
7308	test -n "$release" && \
7309	  func_warning "\`-release' is ignored for convenience libraries"
7310      else
7311
7312	# Parse the version information argument.
7313	save_ifs="$IFS"; IFS=':'
7314	set dummy $vinfo 0 0 0
7315	shift
7316	IFS="$save_ifs"
7317
7318	test -n "$7" && \
7319	  func_fatal_help "too many parameters to \`-version-info'"
7320
7321	# convert absolute version numbers to libtool ages
7322	# this retains compatibility with .la files and attempts
7323	# to make the code below a bit more comprehensible
7324
7325	case $vinfo_number in
7326	yes)
7327	  number_major="$1"
7328	  number_minor="$2"
7329	  number_revision="$3"
7330	  #
7331	  # There are really only two kinds -- those that
7332	  # use the current revision as the major version
7333	  # and those that subtract age and use age as
7334	  # a minor version.  But, then there is irix
7335	  # which has an extra 1 added just for fun
7336	  #
7337	  case $version_type in
7338	  # correct linux to gnu/linux during the next big refactor
7339	  darwin|linux|osf|windows|none)
7340	    func_arith $number_major + $number_minor
7341	    current=$func_arith_result
7342	    age="$number_minor"
7343	    revision="$number_revision"
7344	    ;;
7345	  freebsd-aout|freebsd-elf|qnx|sunos)
7346	    current="$number_major"
7347	    revision="$number_minor"
7348	    age="0"
7349	    ;;
7350	  irix|nonstopux)
7351	    func_arith $number_major + $number_minor
7352	    current=$func_arith_result
7353	    age="$number_minor"
7354	    revision="$number_minor"
7355	    lt_irix_increment=no
7356	    ;;
7357	  esac
7358	  ;;
7359	no)
7360	  current="$1"
7361	  revision="$2"
7362	  age="$3"
7363	  ;;
7364	esac
7365
7366	# Check that each of the things are valid numbers.
7367	case $current in
7368	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]) ;;
7369	*)
7370	  func_error "CURRENT \`$current' must be a nonnegative integer"
7371	  func_fatal_error "\`$vinfo' is not valid version information"
7372	  ;;
7373	esac
7374
7375	case $revision in
7376	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]) ;;
7377	*)
7378	  func_error "REVISION \`$revision' must be a nonnegative integer"
7379	  func_fatal_error "\`$vinfo' is not valid version information"
7380	  ;;
7381	esac
7382
7383	case $age in
7384	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]) ;;
7385	*)
7386	  func_error "AGE \`$age' must be a nonnegative integer"
7387	  func_fatal_error "\`$vinfo' is not valid version information"
7388	  ;;
7389	esac
7390
7391	if test "$age" -gt "$current"; then
7392	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
7393	  func_fatal_error "\`$vinfo' is not valid version information"
7394	fi
7395
7396	# Calculate the version variables.
7397	major=
7398	versuffix=
7399	versuffix2=
7400	verstring=
7401	case $version_type in
7402	none) ;;
7403
7404	darwin)
7405	  # Like Linux, but with the current version available in
7406	  # verstring for coding it into the library header
7407	  func_arith $current - $age
7408	  major=.$func_arith_result
7409	  versuffix="$major.$age.$revision"
7410	  # Darwin ld doesn't like 0 for these options...
7411	  func_arith $current + 1
7412	  minor_current=$func_arith_result
7413	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
7414	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
7415	  ;;
7416
7417	freebsd-aout)
7418	  major=".$current"
7419	  versuffix=".$current.$revision";
7420	  ;;
7421
7422	freebsd-elf)
7423	  major=".$current"
7424	  versuffix=".$current"
7425	  ;;
7426
7427	irix | nonstopux)
7428	  if test "X$lt_irix_increment" = "Xno"; then
7429	    func_arith $current - $age
7430	  else
7431	    func_arith $current - $age + 1
7432	  fi
7433	  major=$func_arith_result
7434
7435	  case $version_type in
7436	    nonstopux) verstring_prefix=nonstopux ;;
7437	    *)         verstring_prefix=sgi ;;
7438	  esac
7439	  verstring="$verstring_prefix$major.$revision"
7440
7441	  # Add in all the interfaces that we are compatible with.
7442	  loop=$revision
7443	  while test "$loop" -ne 0; do
7444	    func_arith $revision - $loop
7445	    iface=$func_arith_result
7446	    func_arith $loop - 1
7447	    loop=$func_arith_result
7448	    verstring="$verstring_prefix$major.$iface:$verstring"
7449	  done
7450
7451	  # Before this point, $major must not contain `.'.
7452	  major=.$major
7453	  versuffix="$major.$revision"
7454	  ;;
7455
7456	linux) # correct to gnu/linux during the next big refactor
7457	  func_arith $current - $age
7458	  major=.$func_arith_result
7459	  versuffix="$major.$age.$revision"
7460	  versuffix2="$major.$age"
7461	  ;;
7462
7463	osf)
7464	  func_arith $current - $age
7465	  major=.$func_arith_result
7466	  versuffix=".$current.$age.$revision"
7467	  verstring="$current.$age.$revision"
7468
7469	  # Add in all the interfaces that we are compatible with.
7470	  loop=$age
7471	  while test "$loop" -ne 0; do
7472	    func_arith $current - $loop
7473	    iface=$func_arith_result
7474	    func_arith $loop - 1
7475	    loop=$func_arith_result
7476	    verstring="$verstring:${iface}.0"
7477	  done
7478
7479	  # Make executables depend on our current version.
7480	  func_append verstring ":${current}.0"
7481	  ;;
7482
7483	qnx)
7484	  major=".$current"
7485	  versuffix=".$current"
7486	  ;;
7487
7488	sunos)
7489	  major=".$current"
7490	  versuffix=".$current.$revision"
7491	  ;;
7492
7493	windows)
7494	  # Use '-' rather than '.', since we only want one
7495	  # extension on DOS 8.3 filesystems.
7496	  func_arith $current - $age
7497	  major=$func_arith_result
7498	  versuffix="-$major"
7499	  ;;
7500
7501	*)
7502	  func_fatal_configuration "unknown library version type \`$version_type'"
7503	  ;;
7504	esac
7505
7506	# Clear the version info if we defaulted, and they specified a release.
7507	if test -z "$vinfo" && test -n "$release"; then
7508	  major=
7509	  case $version_type in
7510	  darwin)
7511	    # we can't check for "0.0" in archive_cmds due to quoting
7512	    # problems, so we reset it completely
7513	    verstring=
7514	    ;;
7515	  *)
7516	    verstring="0.0"
7517	    ;;
7518	  esac
7519	  if test "$need_version" = no; then
7520	    versuffix=
7521	    versuffix2=
7522	  else
7523	    versuffix=".0.0"
7524	    versuffix2=".0.0"
7525	  fi
7526	fi
7527
7528	# Remove version info from name if versioning should be avoided
7529	if test "$avoid_version" = yes && test "$need_version" = no; then
7530	  major=
7531	  versuffix=
7532	  versuffix2=
7533	  verstring=""
7534	fi
7535
7536	# Check to see if the archive will have undefined symbols.
7537	if test "$allow_undefined" = yes; then
7538	  if test "$allow_undefined_flag" = unsupported; then
7539	    func_warning "undefined symbols not allowed in $host shared libraries"
7540	    build_libtool_libs=no
7541	    build_old_libs=yes
7542	  fi
7543	else
7544	  # Don't allow undefined symbols.
7545	  allow_undefined_flag="$no_undefined_flag"
7546	fi
7547
7548      fi
7549
7550      func_generate_dlsyms "$libname" "$libname" "yes"
7551      func_append libobjs " $symfileobj"
7552      test "X$libobjs" = "X " && libobjs=
7553
7554      if test "$opt_mode" != relink; then
7555	# Remove our outputs, but don't remove object files since they
7556	# may have been created when compiling PIC objects.
7557	removelist=
7558	tempremovelist=`$ECHO "$output_objdir/*"`
7559	for p in $tempremovelist; do
7560	  case $p in
7561	    *.$objext | *.gcno)
7562	       ;;
7563	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
7564	       if test "X$precious_files_regex" != "X"; then
7565		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
7566		 then
7567		   continue
7568		 fi
7569	       fi
7570	       func_append removelist " $p"
7571	       ;;
7572	    *) ;;
7573	  esac
7574	done
7575	test -n "$removelist" && \
7576	  func_show_eval "${RM}r \$removelist"
7577      fi
7578
7579      # Now set the variables for building old libraries.
7580      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
7581	func_append oldlibs " $output_objdir/$libname.$libext"
7582
7583	# Transform .lo files to .o files.
7584	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
7585      fi
7586
7587      # Eliminate all temporary directories.
7588      #for path in $notinst_path; do
7589      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
7590      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
7591      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
7592      #done
7593
7594      if test -n "$xrpath"; then
7595	# If the user specified any rpath flags, then add them.
7596	temp_xrpath=
7597	for libdir in $xrpath; do
7598	  func_replace_sysroot "$libdir"
7599	  func_append temp_xrpath " -R$func_replace_sysroot_result"
7600	  case "$finalize_rpath " in
7601	  *" $libdir "*) ;;
7602	  *) func_append finalize_rpath " $libdir" ;;
7603	  esac
7604	done
7605	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
7606	  dependency_libs="$temp_xrpath $dependency_libs"
7607	fi
7608      fi
7609
7610      # Make sure dlfiles contains only unique files that won't be dlpreopened
7611      old_dlfiles="$dlfiles"
7612      dlfiles=
7613      for lib in $old_dlfiles; do
7614	case " $dlprefiles $dlfiles " in
7615	*" $lib "*) ;;
7616	*) func_append dlfiles " $lib" ;;
7617	esac
7618      done
7619
7620      # Make sure dlprefiles contains only unique files
7621      old_dlprefiles="$dlprefiles"
7622      dlprefiles=
7623      for lib in $old_dlprefiles; do
7624	case "$dlprefiles " in
7625	*" $lib "*) ;;
7626	*) func_append dlprefiles " $lib" ;;
7627	esac
7628      done
7629
7630      if test "$build_libtool_libs" = yes; then
7631	if test -n "$rpath"; then
7632	  case $host in
7633	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
7634	    # these systems don't actually have a c library (as such)!
7635	    ;;
7636	  *-*-rhapsody* | *-*-darwin1.[012])
7637	    # Rhapsody C library is in the System framework
7638	    func_append deplibs " System.ltframework"
7639	    ;;
7640	  *-*-netbsd*)
7641	    # Don't link with libc until the a.out ld.so is fixed.
7642	    ;;
7643	  *-*-openbsd* | *-*-mirbsd* | *-*-freebsd* | *-*-dragonfly*)
7644	    # Do not include libc due to us having libc/libc_r.
7645	    ;;
7646	  *-*-sco3.2v5* | *-*-sco5v6*)
7647	    # Causes problems with __ctype
7648	    ;;
7649	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
7650	    # Compiler inserts libc in the correct place for threads to work
7651	    ;;
7652	  *)
7653	    # Add libc to deplibs on all other systems if necessary.
7654	    if test "$build_libtool_need_lc" = "yes"; then
7655	      func_append deplibs " -lc"
7656	    fi
7657	    ;;
7658	  esac
7659	fi
7660
7661	# Transform deplibs into only deplibs that can be linked in shared.
7662	name_save=$name
7663	libname_save=$libname
7664	release_save=$release
7665	versuffix_save=$versuffix
7666	versuffix2_save=$versuffix2
7667	major_save=$major
7668	# I'm not sure if I'm treating the release correctly.  I think
7669	# release should show up in the -l (ie -lgmp5) so we don't want to
7670	# add it in twice.  Is that correct?
7671	release=""
7672	versuffix=""
7673	versuffix2=""
7674	major=""
7675	newdeplibs=
7676	droppeddeps=no
7677	case $deplibs_check_method in
7678	pass_all)
7679	  # Don't check for shared/static.  Everything works.
7680	  # This might be a little naive.  We might want to check
7681	  # whether the library exists or not.  But this is on
7682	  # osf3 & osf4 and I'm not really sure... Just
7683	  # implementing what was already the behavior.
7684	  newdeplibs=$deplibs
7685	  ;;
7686	test_compile)
7687	  # This code stresses the "libraries are programs" paradigm to its
7688	  # limits. Maybe even breaks it.  We compile a program, linking it
7689	  # against the deplibs as a proxy for the library.  Then we can check
7690	  # whether they linked in statically or dynamically with ldd.
7691	  $opt_dry_run || $RM conftest.c
7692	  cat > conftest.c <<EOF
7693	  int main() { return 0; }
7694EOF
7695	  $opt_dry_run || $RM conftest
7696	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
7697	    ldd_output=`ldd conftest`
7698	    for i in $deplibs; do
7699	      case $i in
7700	      -l*)
7701		func_stripname -l '' "$i"
7702		name=$func_stripname_result
7703		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7704		  case " $predeps $postdeps " in
7705		  *" $i "*)
7706		    func_append newdeplibs " $i"
7707		    i=""
7708		    ;;
7709		  esac
7710		fi
7711		if test -n "$i" ; then
7712		  libname=`eval "\\$ECHO \"$libname_spec\""`
7713		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7714		  set dummy $deplib_matches; shift
7715		  deplib_match=$1
7716		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7717		    func_append newdeplibs " $i"
7718		  else
7719		    droppeddeps=yes
7720		    echo
7721		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7722		    echo "*** I have the capability to make that library automatically link in when"
7723		    echo "*** you link to this library.  But I can only do this if you have a"
7724		    echo "*** shared version of the library, which I believe you do not have"
7725		    echo "*** because a test_compile did reveal that the linker did not use it for"
7726		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
7727		  fi
7728		fi
7729		;;
7730	      *)
7731		func_append newdeplibs " $i"
7732		;;
7733	      esac
7734	    done
7735	  else
7736	    # Error occurred in the first compile.  Let's try to salvage
7737	    # the situation: Compile a separate program for each library.
7738	    for i in $deplibs; do
7739	      case $i in
7740	      -l*)
7741		func_stripname -l '' "$i"
7742		name=$func_stripname_result
7743		$opt_dry_run || $RM conftest
7744		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
7745		  ldd_output=`ldd conftest`
7746		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7747		    case " $predeps $postdeps " in
7748		    *" $i "*)
7749		      func_append newdeplibs " $i"
7750		      i=""
7751		      ;;
7752		    esac
7753		  fi
7754		  if test -n "$i" ; then
7755		    libname=`eval "\\$ECHO \"$libname_spec\""`
7756		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7757		    set dummy $deplib_matches; shift
7758		    deplib_match=$1
7759		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7760		      func_append newdeplibs " $i"
7761		    else
7762		      droppeddeps=yes
7763		      echo
7764		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7765		      echo "*** I have the capability to make that library automatically link in when"
7766		      echo "*** you link to this library.  But I can only do this if you have a"
7767		      echo "*** shared version of the library, which you do not appear to have"
7768		      echo "*** because a test_compile did reveal that the linker did not use this one"
7769		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
7770		    fi
7771		  fi
7772		else
7773		  droppeddeps=yes
7774		  echo
7775		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
7776		  echo "*** make it link in!  You will probably need to install it or some"
7777		  echo "*** library that it depends on before this library will be fully"
7778		  echo "*** functional.  Installing it before continuing would be even better."
7779		fi
7780		;;
7781	      *)
7782		func_append newdeplibs " $i"
7783		;;
7784	      esac
7785	    done
7786	  fi
7787	  ;;
7788	file_magic*)
7789	  set dummy $deplibs_check_method; shift
7790	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7791	  for a_deplib in $deplibs; do
7792	    case $a_deplib in
7793	    -l*)
7794	      func_stripname -l '' "$a_deplib"
7795	      name=$func_stripname_result
7796	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7797		case " $predeps $postdeps " in
7798		*" $a_deplib "*)
7799		  func_append newdeplibs " $a_deplib"
7800		  a_deplib=""
7801		  ;;
7802		esac
7803	      fi
7804	      if test -n "$a_deplib" ; then
7805		libname=`eval "\\$ECHO \"$libname_spec\""`
7806		if test -n "$file_magic_glob"; then
7807		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
7808		else
7809		  libnameglob=$libname
7810		fi
7811		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
7812		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7813		  if test "$want_nocaseglob" = yes; then
7814		    shopt -s nocaseglob
7815		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7816		    $nocaseglob
7817		  else
7818		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7819		  fi
7820		  for potent_lib in $potential_libs; do
7821		      # Follow soft links.
7822		      if ls -lLd "$potent_lib" 2>/dev/null |
7823			 $GREP " -> " >/dev/null; then
7824			continue
7825		      fi
7826		      # The statement above tries to avoid entering an
7827		      # endless loop below, in case of cyclic links.
7828		      # We might still enter an endless loop, since a link
7829		      # loop can be closed while we follow links,
7830		      # but so what?
7831		      potlib="$potent_lib"
7832		      while test -h "$potlib" 2>/dev/null; do
7833			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
7834			case $potliblink in
7835			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
7836			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
7837			esac
7838		      done
7839		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
7840			 $SED -e 10q |
7841			 $EGREP "$file_magic_regex" > /dev/null; then
7842			func_append newdeplibs " $a_deplib"
7843			a_deplib=""
7844			break 2
7845		      fi
7846		  done
7847		done
7848	      fi
7849	      if test -n "$a_deplib" ; then
7850		droppeddeps=yes
7851		echo
7852		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7853		echo "*** I have the capability to make that library automatically link in when"
7854		echo "*** you link to this library.  But I can only do this if you have a"
7855		echo "*** shared version of the library, which you do not appear to have"
7856		echo "*** because I did check the linker path looking for a file starting"
7857		if test -z "$potlib" ; then
7858		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
7859		else
7860		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7861		  $ECHO "*** using a file magic. Last file checked: $potlib"
7862		fi
7863	      fi
7864	      ;;
7865	    *)
7866	      # Add a -L argument.
7867	      func_append newdeplibs " $a_deplib"
7868	      ;;
7869	    esac
7870	  done # Gone through all deplibs.
7871	  ;;
7872	match_pattern*)
7873	  set dummy $deplibs_check_method; shift
7874	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7875	  for a_deplib in $deplibs; do
7876	    case $a_deplib in
7877	    -l*)
7878	      func_stripname -l '' "$a_deplib"
7879	      name=$func_stripname_result
7880	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7881		case " $predeps $postdeps " in
7882		*" $a_deplib "*)
7883		  func_append newdeplibs " $a_deplib"
7884		  a_deplib=""
7885		  ;;
7886		esac
7887	      fi
7888	      if test -n "$a_deplib" ; then
7889		libname=`eval "\\$ECHO \"$libname_spec\""`
7890		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7891		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
7892		  for potent_lib in $potential_libs; do
7893		    potlib="$potent_lib" # see symlink-check above in file_magic test
7894		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
7895		       $EGREP "$match_pattern_regex" > /dev/null; then
7896		      func_append newdeplibs " $a_deplib"
7897		      a_deplib=""
7898		      break 2
7899		    fi
7900		  done
7901		done
7902	      fi
7903	      if test -n "$a_deplib" ; then
7904		droppeddeps=yes
7905		echo
7906		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7907		echo "*** I have the capability to make that library automatically link in when"
7908		echo "*** you link to this library.  But I can only do this if you have a"
7909		echo "*** shared version of the library, which you do not appear to have"
7910		echo "*** because I did check the linker path looking for a file starting"
7911		if test -z "$potlib" ; then
7912		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
7913		else
7914		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7915		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
7916		fi
7917	      fi
7918	      ;;
7919	    *)
7920	      # Add a -L argument.
7921	      func_append newdeplibs " $a_deplib"
7922	      ;;
7923	    esac
7924	  done # Gone through all deplibs.
7925	  ;;
7926	none | unknown | *)
7927	  newdeplibs=""
7928	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
7929	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7930	    for i in $predeps $postdeps ; do
7931	      # can't use Xsed below, because $i might contain '/'
7932	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
7933	    done
7934	  fi
7935	  case $tmp_deplibs in
7936	  *[!\	\ ]*)
7937	    echo
7938	    if test "X$deplibs_check_method" = "Xnone"; then
7939	      echo "*** Warning: inter-library dependencies are not supported in this platform."
7940	    else
7941	      echo "*** Warning: inter-library dependencies are not known to be supported."
7942	    fi
7943	    echo "*** All declared inter-library dependencies are being dropped."
7944	    droppeddeps=yes
7945	    ;;
7946	  esac
7947	  ;;
7948	esac
7949	versuffix=$versuffix_save
7950	versuffix2=$versuffix2_save
7951	major=$major_save
7952	release=$release_save
7953	libname=$libname_save
7954	name=$name_save
7955
7956	case $host in
7957	*-*-rhapsody* | *-*-darwin1.[012])
7958	  # On Rhapsody replace the C library with the System framework
7959	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
7960	  ;;
7961	esac
7962
7963	if test "$droppeddeps" = yes; then
7964	  if test "$module" = yes; then
7965	    echo
7966	    echo "*** Warning: libtool could not satisfy all declared inter-library"
7967	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
7968	    echo "*** a static module, that should work as long as the dlopening"
7969	    echo "*** application is linked with the -dlopen flag."
7970	    if test -z "$global_symbol_pipe"; then
7971	      echo
7972	      echo "*** However, this would only work if libtool was able to extract symbol"
7973	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
7974	      echo "*** not find such a program.  So, this module is probably useless."
7975	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
7976	    fi
7977	    if test "$build_old_libs" = no; then
7978	      oldlibs="$output_objdir/$libname.$libext"
7979	      build_libtool_libs=module
7980	      build_old_libs=yes
7981	    else
7982	      build_libtool_libs=no
7983	    fi
7984	  else
7985	    echo "*** The inter-library dependencies that have been dropped here will be"
7986	    echo "*** automatically added whenever a program is linked with this library"
7987	    echo "*** or is declared to -dlopen it."
7988
7989	    if test "$allow_undefined" = no; then
7990	      echo
7991	      echo "*** Since this library must not contain undefined symbols,"
7992	      echo "*** because either the platform does not support them or"
7993	      echo "*** it was explicitly requested with -no-undefined,"
7994	      echo "*** libtool will only create a static version of it."
7995	      if test "$build_old_libs" = no; then
7996		oldlibs="$output_objdir/$libname.$libext"
7997		build_libtool_libs=module
7998		build_old_libs=yes
7999	      else
8000		build_libtool_libs=no
8001	      fi
8002	    fi
8003	  fi
8004	fi
8005	# Done checking deplibs!
8006	deplibs=$newdeplibs
8007      fi
8008      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
8009      case $host in
8010	*-*-darwin*)
8011	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8012	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8013	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8014	  ;;
8015      esac
8016
8017      # move library search paths that coincide with paths to not yet
8018      # installed libraries to the beginning of the library search list
8019      new_libs=
8020      for path in $notinst_path; do
8021	case " $new_libs " in
8022	*" -L$path/$objdir "*) ;;
8023	*)
8024	  case " $deplibs " in
8025	  *" -L$path/$objdir "*)
8026	    func_append new_libs " -L$path/$objdir" ;;
8027	  esac
8028	  ;;
8029	esac
8030      done
8031      for deplib in $deplibs; do
8032	case $deplib in
8033	-L*)
8034	  case " $new_libs " in
8035	  *" $deplib "*) ;;
8036	  *) func_append new_libs " $deplib" ;;
8037	  esac
8038	  ;;
8039	*) func_append new_libs " $deplib" ;;
8040	esac
8041      done
8042      deplibs="$new_libs"
8043
8044      # All the library-specific variables (install_libdir is set above).
8045      library_names=
8046      old_library=
8047      dlname=
8048
8049      # Test again, we may have decided not to build it any more
8050      if test "$build_libtool_libs" = yes; then
8051	# Remove ${wl} instances when linking with ld.
8052	# FIXME: should test the right _cmds variable.
8053	case $archive_cmds in
8054	  *\$LD\ *) wl= ;;
8055        esac
8056	if test "$hardcode_into_libs" = yes; then
8057	  # Hardcode the library paths
8058	  hardcode_libdirs=
8059	  dep_rpath=
8060	  rpath="$finalize_rpath"
8061	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
8062	  for libdir in $rpath; do
8063	    if test -n "$hardcode_libdir_flag_spec"; then
8064	      if test -n "$hardcode_libdir_separator"; then
8065		func_replace_sysroot "$libdir"
8066		libdir=$func_replace_sysroot_result
8067		if test -z "$hardcode_libdirs"; then
8068		  hardcode_libdirs="$libdir"
8069		else
8070		  # Just accumulate the unique libdirs.
8071		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8072		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8073		    ;;
8074		  *)
8075		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8076		    ;;
8077		  esac
8078		fi
8079	      else
8080		eval flag=\"$hardcode_libdir_flag_spec\"
8081		func_append dep_rpath " $flag"
8082	      fi
8083	    elif test -n "$runpath_var"; then
8084	      case "$perm_rpath " in
8085	      *" $libdir "*) ;;
8086	      *) func_append perm_rpath " $libdir" ;;
8087	      esac
8088	    fi
8089	  done
8090	  # Substitute the hardcoded libdirs into the rpath.
8091	  if test -n "$hardcode_libdir_separator" &&
8092	     test -n "$hardcode_libdirs"; then
8093	    libdir="$hardcode_libdirs"
8094	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
8095	  fi
8096	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
8097	    # We should set the runpath_var.
8098	    rpath=
8099	    for dir in $perm_rpath; do
8100	      func_append rpath "$dir:"
8101	    done
8102	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
8103	  fi
8104	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
8105	fi
8106
8107	shlibpath="$finalize_shlibpath"
8108	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
8109	if test -n "$shlibpath"; then
8110	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
8111	fi
8112
8113	# Get the real and link names of the library.
8114	eval shared_ext=\"$shrext_cmds\"
8115	eval library_names=\"$library_names_spec\"
8116	set dummy $library_names
8117	shift
8118	realname="$1"
8119	shift
8120
8121	if test -n "$soname_spec"; then
8122	  eval soname=\"$soname_spec\"
8123	else
8124	  soname="$realname"
8125	fi
8126	if test -z "$dlname"; then
8127	  dlname=$soname
8128	fi
8129
8130	lib="$output_objdir/$realname"
8131	linknames=
8132	for link
8133	do
8134	  func_append linknames " $link"
8135	done
8136
8137	# Use standard objects if they are pic
8138	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
8139	test "X$libobjs" = "X " && libobjs=
8140
8141	delfiles=
8142	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8143	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
8144	  export_symbols="$output_objdir/$libname.uexp"
8145	  func_append delfiles " $export_symbols"
8146	fi
8147
8148	orig_export_symbols=
8149	case $host_os in
8150	cygwin* | mingw* | cegcc*)
8151	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
8152	    # exporting using user supplied symfile
8153	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
8154	      # and it's NOT already a .def file. Must figure out
8155	      # which of the given symbols are data symbols and tag
8156	      # them as such. So, trigger use of export_symbols_cmds.
8157	      # export_symbols gets reassigned inside the "prepare
8158	      # the list of exported symbols" if statement, so the
8159	      # include_expsyms logic still works.
8160	      orig_export_symbols="$export_symbols"
8161	      export_symbols=
8162	      always_export_symbols=yes
8163	    fi
8164	  fi
8165	  ;;
8166	esac
8167
8168	# Prepare the list of exported symbols
8169	if test -z "$export_symbols"; then
8170	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
8171	    func_verbose "generating symbol list for \`$libname.la'"
8172	    export_symbols="$output_objdir/$libname.exp"
8173	    $opt_dry_run || $RM $export_symbols
8174	    cmds=$export_symbols_cmds
8175	    save_ifs="$IFS"; IFS='~'
8176	    for cmd1 in $cmds; do
8177	      IFS="$save_ifs"
8178	      # Take the normal branch if the nm_file_list_spec branch
8179	      # doesn't work or if tool conversion is not needed.
8180	      case $nm_file_list_spec~$to_tool_file_cmd in
8181		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
8182		  try_normal_branch=yes
8183		  eval cmd=\"$cmd1\"
8184		  func_len " $cmd"
8185		  len=$func_len_result
8186		  ;;
8187		*)
8188		  try_normal_branch=no
8189		  ;;
8190	      esac
8191	      if test "$try_normal_branch" = yes \
8192		 && { test "$len" -lt "$max_cmd_len" \
8193		      || test "$max_cmd_len" -le -1; }
8194	      then
8195		func_show_eval "$cmd" 'exit $?'
8196		skipped_export=false
8197	      elif test -n "$nm_file_list_spec"; then
8198		func_basename "$output"
8199		output_la=$func_basename_result
8200		save_libobjs=$libobjs
8201		save_output=$output
8202		output=${output_objdir}/${output_la}.nm
8203		func_to_tool_file "$output"
8204		libobjs=$nm_file_list_spec$func_to_tool_file_result
8205		func_append delfiles " $output"
8206		func_verbose "creating $NM input file list: $output"
8207		for obj in $save_libobjs; do
8208		  func_to_tool_file "$obj"
8209		  $ECHO "$func_to_tool_file_result"
8210		done > "$output"
8211		eval cmd=\"$cmd1\"
8212		func_show_eval "$cmd" 'exit $?'
8213		output=$save_output
8214		libobjs=$save_libobjs
8215		skipped_export=false
8216	      else
8217		# The command line is too long to execute in one step.
8218		func_verbose "using reloadable object file for export list..."
8219		skipped_export=:
8220		# Break out early, otherwise skipped_export may be
8221		# set to false by a later but shorter cmd.
8222		break
8223	      fi
8224	    done
8225	    IFS="$save_ifs"
8226	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
8227	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8228	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8229	    fi
8230	  fi
8231	fi
8232
8233	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8234	  tmp_export_symbols="$export_symbols"
8235	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8236	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8237	fi
8238
8239	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
8240	  # The given exports_symbols file has to be filtered, so filter it.
8241	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8242	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
8243	  # 's' commands which not all seds can handle. GNU sed should be fine
8244	  # though. Also, the filter scales superlinearly with the number of
8245	  # global variables. join(1) would be nice here, but unfortunately
8246	  # isn't a blessed tool.
8247	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8248	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8249	  export_symbols=$output_objdir/$libname.def
8250	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8251	fi
8252
8253	tmp_deplibs=
8254	for test_deplib in $deplibs; do
8255	  case " $convenience " in
8256	  *" $test_deplib "*) ;;
8257	  *)
8258	    func_append tmp_deplibs " $test_deplib"
8259	    ;;
8260	  esac
8261	done
8262	deplibs="$tmp_deplibs"
8263
8264	if test -n "$convenience"; then
8265	  if test -n "$whole_archive_flag_spec" &&
8266	    test "$compiler_needs_object" = yes &&
8267	    test -z "$libobjs"; then
8268	    # extract the archives, so we have objects to list.
8269	    # TODO: could optimize this to just extract one archive.
8270	    whole_archive_flag_spec=
8271	  fi
8272	  if test -n "$whole_archive_flag_spec"; then
8273	    save_libobjs=$libobjs
8274	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8275	    test "X$libobjs" = "X " && libobjs=
8276	  else
8277	    gentop="$output_objdir/${outputname}x"
8278	    func_append generated " $gentop"
8279
8280	    func_extract_archives $gentop $convenience
8281	    func_append libobjs " $func_extract_archives_result"
8282	    test "X$libobjs" = "X " && libobjs=
8283	  fi
8284	fi
8285
8286	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
8287	  eval flag=\"$thread_safe_flag_spec\"
8288	  func_append linker_flags " $flag"
8289	fi
8290
8291	# Make a backup of the uninstalled library when relinking
8292	if test "$opt_mode" = relink; then
8293	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
8294	fi
8295
8296	# Do each of the archive commands.
8297	if test "$module" = yes && test -n "$module_cmds" ; then
8298	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8299	    eval test_cmds=\"$module_expsym_cmds\"
8300	    cmds=$module_expsym_cmds
8301	  else
8302	    eval test_cmds=\"$module_cmds\"
8303	    cmds=$module_cmds
8304	  fi
8305	else
8306	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8307	    eval test_cmds=\"$archive_expsym_cmds\"
8308	    cmds=$archive_expsym_cmds
8309	  else
8310	    eval test_cmds=\"$archive_cmds\"
8311	    cmds=$archive_cmds
8312	  fi
8313	fi
8314
8315	if test "X$skipped_export" != "X:" &&
8316	   func_len " $test_cmds" &&
8317	   len=$func_len_result &&
8318	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
8319	  :
8320	else
8321	  # The command line is too long to link in one step, link piecewise
8322	  # or, if using GNU ld and skipped_export is not :, use a linker
8323	  # script.
8324
8325	  # Save the value of $output and $libobjs because we want to
8326	  # use them later.  If we have whole_archive_flag_spec, we
8327	  # want to use save_libobjs as it was before
8328	  # whole_archive_flag_spec was expanded, because we can't
8329	  # assume the linker understands whole_archive_flag_spec.
8330	  # This may have to be revisited, in case too many
8331	  # convenience libraries get linked in and end up exceeding
8332	  # the spec.
8333	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
8334	    save_libobjs=$libobjs
8335	  fi
8336	  save_output=$output
8337	  func_basename "$output"
8338	  output_la=$func_basename_result
8339
8340	  # Clear the reloadable object creation command queue and
8341	  # initialize k to one.
8342	  test_cmds=
8343	  concat_cmds=
8344	  objlist=
8345	  last_robj=
8346	  k=1
8347
8348	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
8349	    output=${output_objdir}/${output_la}.lnkscript
8350	    func_verbose "creating GNU ld script: $output"
8351	    echo 'INPUT (' > $output
8352	    for obj in $save_libobjs
8353	    do
8354	      func_to_tool_file "$obj"
8355	      $ECHO "$func_to_tool_file_result" >> $output
8356	    done
8357	    echo ')' >> $output
8358	    func_append delfiles " $output"
8359	    func_to_tool_file "$output"
8360	    output=$func_to_tool_file_result
8361	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
8362	    output=${output_objdir}/${output_la}.lnk
8363	    func_verbose "creating linker input file list: $output"
8364	    : > $output
8365	    set x $save_libobjs
8366	    shift
8367	    firstobj=
8368	    if test "$compiler_needs_object" = yes; then
8369	      firstobj="$1 "
8370	      shift
8371	    fi
8372	    for obj
8373	    do
8374	      func_to_tool_file "$obj"
8375	      $ECHO "$func_to_tool_file_result" >> $output
8376	    done
8377	    func_append delfiles " $output"
8378	    func_to_tool_file "$output"
8379	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
8380	  else
8381	    if test -n "$save_libobjs"; then
8382	      func_verbose "creating reloadable object files..."
8383	      output=$output_objdir/$output_la-${k}.$objext
8384	      eval test_cmds=\"$reload_cmds\"
8385	      func_len " $test_cmds"
8386	      len0=$func_len_result
8387	      len=$len0
8388
8389	      # Loop over the list of objects to be linked.
8390	      for obj in $save_libobjs
8391	      do
8392		func_len " $obj"
8393		func_arith $len + $func_len_result
8394		len=$func_arith_result
8395		if test "X$objlist" = X ||
8396		   test "$len" -lt "$max_cmd_len"; then
8397		  func_append objlist " $obj"
8398		else
8399		  # The command $test_cmds is almost too long, add a
8400		  # command to the queue.
8401		  if test "$k" -eq 1 ; then
8402		    # The first file doesn't have a previous command to add.
8403		    reload_objs=$objlist
8404		    eval concat_cmds=\"$reload_cmds\"
8405		  else
8406		    # All subsequent reloadable object files will link in
8407		    # the last one created.
8408		    reload_objs="$objlist $last_robj"
8409		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
8410		  fi
8411		  last_robj=$output_objdir/$output_la-${k}.$objext
8412		  func_arith $k + 1
8413		  k=$func_arith_result
8414		  output=$output_objdir/$output_la-${k}.$objext
8415		  objlist=" $obj"
8416		  func_len " $last_robj"
8417		  func_arith $len0 + $func_len_result
8418		  len=$func_arith_result
8419		fi
8420	      done
8421	      # Handle the remaining objects by creating one last
8422	      # reloadable object file.  All subsequent reloadable object
8423	      # files will link in the last one created.
8424	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8425	      reload_objs="$objlist $last_robj"
8426	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
8427	      if test -n "$last_robj"; then
8428	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
8429	      fi
8430	      func_append delfiles " $output"
8431
8432	    else
8433	      output=
8434	    fi
8435
8436	    if ${skipped_export-false}; then
8437	      func_verbose "generating symbol list for \`$libname.la'"
8438	      export_symbols="$output_objdir/$libname.exp"
8439	      $opt_dry_run || $RM $export_symbols
8440	      libobjs=$output
8441	      # Append the command to create the export file.
8442	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8443	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
8444	      if test -n "$last_robj"; then
8445		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
8446	      fi
8447	    fi
8448
8449	    test -n "$save_libobjs" &&
8450	      func_verbose "creating a temporary reloadable object file: $output"
8451
8452	    # Loop through the commands generated above and execute them.
8453	    save_ifs="$IFS"; IFS='~'
8454	    for cmd in $concat_cmds; do
8455	      IFS="$save_ifs"
8456	      $opt_silent || {
8457		  func_quote_for_expand "$cmd"
8458		  eval "func_echo $func_quote_for_expand_result"
8459	      }
8460	      $opt_dry_run || eval "$cmd" || {
8461		lt_exit=$?
8462
8463		# Restore the uninstalled library and exit
8464		if test "$opt_mode" = relink; then
8465		  ( cd "$output_objdir" && \
8466		    $RM "${realname}T" && \
8467		    $MV "${realname}U" "$realname" )
8468		fi
8469
8470		exit $lt_exit
8471	      }
8472	    done
8473	    IFS="$save_ifs"
8474
8475	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
8476	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8477	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8478	    fi
8479	  fi
8480
8481          if ${skipped_export-false}; then
8482	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
8483	      tmp_export_symbols="$export_symbols"
8484	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8485	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8486	    fi
8487
8488	    if test -n "$orig_export_symbols"; then
8489	      # The given exports_symbols file has to be filtered, so filter it.
8490	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8491	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
8492	      # 's' commands which not all seds can handle. GNU sed should be fine
8493	      # though. Also, the filter scales superlinearly with the number of
8494	      # global variables. join(1) would be nice here, but unfortunately
8495	      # isn't a blessed tool.
8496	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8497	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8498	      export_symbols=$output_objdir/$libname.def
8499	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8500	    fi
8501	  fi
8502
8503	  libobjs=$output
8504	  # Restore the value of output.
8505	  output=$save_output
8506
8507	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
8508	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8509	    test "X$libobjs" = "X " && libobjs=
8510	  fi
8511	  # Expand the library linking commands again to reset the
8512	  # value of $libobjs for piecewise linking.
8513
8514	  # Do each of the archive commands.
8515	  if test "$module" = yes && test -n "$module_cmds" ; then
8516	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8517	      cmds=$module_expsym_cmds
8518	    else
8519	      cmds=$module_cmds
8520	    fi
8521	  else
8522	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8523	      cmds=$archive_expsym_cmds
8524	    else
8525	      cmds=$archive_cmds
8526	    fi
8527	  fi
8528	fi
8529
8530	if test -n "$delfiles"; then
8531	  # Append the command to remove temporary files to $cmds.
8532	  eval cmds=\"\$cmds~\$RM $delfiles\"
8533	fi
8534
8535	# Add any objects from preloaded convenience libraries
8536	if test -n "$dlprefiles"; then
8537	  gentop="$output_objdir/${outputname}x"
8538	  func_append generated " $gentop"
8539
8540	  func_extract_archives $gentop $dlprefiles
8541	  func_append libobjs " $func_extract_archives_result"
8542	  test "X$libobjs" = "X " && libobjs=
8543	fi
8544
8545	save_ifs="$IFS"; IFS='~'
8546	for cmd in $cmds; do
8547	  IFS="$save_ifs"
8548	  eval cmd=\"$cmd\"
8549	  $opt_silent || {
8550	    func_quote_for_expand "$cmd"
8551	    eval "func_echo $func_quote_for_expand_result"
8552	  }
8553	  $opt_dry_run || eval "$cmd" || {
8554	    lt_exit=$?
8555
8556	    # Restore the uninstalled library and exit
8557	    if test "$opt_mode" = relink; then
8558	      ( cd "$output_objdir" && \
8559	        $RM "${realname}T" && \
8560		$MV "${realname}U" "$realname" )
8561	    fi
8562
8563	    exit $lt_exit
8564	  }
8565	done
8566	IFS="$save_ifs"
8567
8568	# Restore the uninstalled library and exit
8569	if test "$opt_mode" = relink; then
8570	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
8571
8572	  if test -n "$convenience"; then
8573	    if test -z "$whole_archive_flag_spec"; then
8574	      func_show_eval '${RM}r "$gentop"'
8575	    fi
8576	  fi
8577
8578	  exit $EXIT_SUCCESS
8579	fi
8580
8581	# Create links to the real library.
8582	for linkname in $linknames; do
8583	  if test "$realname" != "$linkname"; then
8584	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
8585	  fi
8586	done
8587
8588	# If -module or -export-dynamic was specified, set the dlname.
8589	if test "$module" = yes || test "$export_dynamic" = yes; then
8590	  # On all known operating systems, these are identical.
8591	  dlname="$soname"
8592	fi
8593      fi
8594      ;;
8595
8596    obj)
8597      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
8598	func_warning "\`-dlopen' is ignored for objects"
8599      fi
8600
8601      case " $deplibs" in
8602      *\ -l* | *\ -L*)
8603	func_warning "\`-l' and \`-L' are ignored for objects" ;;
8604      esac
8605
8606      test -n "$rpath" && \
8607	func_warning "\`-rpath' is ignored for objects"
8608
8609      test -n "$xrpath" && \
8610	func_warning "\`-R' is ignored for objects"
8611
8612      test -n "$vinfo" && \
8613	func_warning "\`-version-info' is ignored for objects"
8614
8615      test -n "$release" && \
8616	func_warning "\`-release' is ignored for objects"
8617
8618      case $output in
8619      *.lo)
8620	test -n "$objs$old_deplibs" && \
8621	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
8622
8623	libobj=$output
8624	func_lo2o "$libobj"
8625	obj=$func_lo2o_result
8626	;;
8627      *)
8628	libobj=
8629	obj="$output"
8630	;;
8631      esac
8632
8633      # Delete the old objects.
8634      $opt_dry_run || $RM $obj $libobj
8635
8636      # Objects from convenience libraries.  This assumes
8637      # single-version convenience libraries.  Whenever we create
8638      # different ones for PIC/non-PIC, this we'll have to duplicate
8639      # the extraction.
8640      reload_conv_objs=
8641      gentop=
8642      # reload_cmds runs $LD directly, so let us get rid of
8643      # -Wl from whole_archive_flag_spec and hope we can get by with
8644      # turning comma into space..
8645      wl=
8646
8647      if test -n "$convenience"; then
8648	if test -n "$whole_archive_flag_spec"; then
8649	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
8650	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
8651	else
8652	  gentop="$output_objdir/${obj}x"
8653	  func_append generated " $gentop"
8654
8655	  func_extract_archives $gentop $convenience
8656	  reload_conv_objs="$reload_objs $func_extract_archives_result"
8657	fi
8658      fi
8659
8660      # If we're not building shared, we need to use non_pic_objs
8661      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
8662
8663      # Create the old-style object.
8664      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
8665
8666      output="$obj"
8667      func_execute_cmds "$reload_cmds" 'exit $?'
8668
8669      # Exit if we aren't doing a library object file.
8670      if test -z "$libobj"; then
8671	if test -n "$gentop"; then
8672	  func_show_eval '${RM}r "$gentop"'
8673	fi
8674
8675	exit $EXIT_SUCCESS
8676      fi
8677
8678      if test "$build_libtool_libs" != yes; then
8679	if test -n "$gentop"; then
8680	  func_show_eval '${RM}r "$gentop"'
8681	fi
8682
8683	# Create an invalid libtool object if no PIC, so that we don't
8684	# accidentally link it into a program.
8685	# $show "echo timestamp > $libobj"
8686	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
8687	exit $EXIT_SUCCESS
8688      fi
8689
8690      if test -n "$pic_flag" || test "$pic_mode" != default; then
8691	# Only do commands if we really have different PIC objects.
8692	reload_objs="$libobjs $reload_conv_objs"
8693	output="$libobj"
8694	func_execute_cmds "$reload_cmds" 'exit $?'
8695      fi
8696
8697      if test -n "$gentop"; then
8698	func_show_eval '${RM}r "$gentop"'
8699      fi
8700
8701      exit $EXIT_SUCCESS
8702      ;;
8703
8704    prog)
8705      case $host in
8706	*cygwin*) func_stripname '' '.exe' "$output"
8707	          output=$func_stripname_result.exe;;
8708      esac
8709      test -n "$vinfo" && \
8710	func_warning "\`-version-info' is ignored for programs"
8711
8712      test -n "$release" && \
8713	func_warning "\`-release' is ignored for programs"
8714
8715      test "$preload" = yes \
8716        && test "$dlopen_support" = unknown \
8717	&& test "$dlopen_self" = unknown \
8718	&& test "$dlopen_self_static" = unknown && \
8719	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
8720
8721      case $host in
8722      *-*-rhapsody* | *-*-darwin1.[012])
8723	# On Rhapsody replace the C library is the System framework
8724	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
8725	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
8726	;;
8727      esac
8728
8729      case $host in
8730      *-*-darwin*)
8731	# Don't allow lazy linking, it breaks C++ global constructors
8732	# But is supposedly fixed on 10.4 or later (yay!).
8733	if test "$tagname" = CXX ; then
8734	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
8735	    10.[0123])
8736	      func_append compile_command " ${wl}-bind_at_load"
8737	      func_append finalize_command " ${wl}-bind_at_load"
8738	    ;;
8739	  esac
8740	fi
8741	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
8742	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8743	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8744	;;
8745      esac
8746
8747
8748      # move library search paths that coincide with paths to not yet
8749      # installed libraries to the beginning of the library search list
8750      new_libs=
8751      for path in $notinst_path; do
8752	case " $new_libs " in
8753	*" -L$path/$objdir "*) ;;
8754	*)
8755	  case " $compile_deplibs " in
8756	  *" -L$path/$objdir "*)
8757	    func_append new_libs " -L$path/$objdir" ;;
8758	  esac
8759	  ;;
8760	esac
8761      done
8762      for deplib in $compile_deplibs; do
8763	case $deplib in
8764	-L*)
8765	  case " $new_libs " in
8766	  *" $deplib "*) ;;
8767	  *) func_append new_libs " $deplib" ;;
8768	  esac
8769	  ;;
8770	*) func_append new_libs " $deplib" ;;
8771	esac
8772      done
8773      compile_deplibs="$new_libs"
8774
8775
8776      func_append compile_command " $compile_deplibs"
8777      func_append finalize_command " $finalize_deplibs"
8778
8779      if test -n "$rpath$xrpath"; then
8780	# If the user specified any rpath flags, then add them.
8781	for libdir in $rpath $xrpath; do
8782	  # This is the magic to use -rpath.
8783	  case "$finalize_rpath " in
8784	  *" $libdir "*) ;;
8785	  *) func_append finalize_rpath " $libdir" ;;
8786	  esac
8787	done
8788      fi
8789
8790      # Now hardcode the library paths
8791      rpath=
8792      hardcode_libdirs=
8793      for libdir in $compile_rpath $finalize_rpath; do
8794	if test -n "$hardcode_libdir_flag_spec"; then
8795	  if test -n "$hardcode_libdir_separator"; then
8796	    if test -z "$hardcode_libdirs"; then
8797	      hardcode_libdirs="$libdir"
8798	    else
8799	      # Just accumulate the unique libdirs.
8800	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8801	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8802		;;
8803	      *)
8804		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8805		;;
8806	      esac
8807	    fi
8808	  else
8809	    eval flag=\"$hardcode_libdir_flag_spec\"
8810	    func_append rpath " $flag"
8811	  fi
8812	elif test -n "$runpath_var"; then
8813	  case "$perm_rpath " in
8814	  *" $libdir "*) ;;
8815	  *) func_append perm_rpath " $libdir" ;;
8816	  esac
8817	fi
8818	case $host in
8819	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
8820	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
8821	  case :$dllsearchpath: in
8822	  *":$libdir:"*) ;;
8823	  ::) dllsearchpath=$libdir;;
8824	  *) func_append dllsearchpath ":$libdir";;
8825	  esac
8826	  case :$dllsearchpath: in
8827	  *":$testbindir:"*) ;;
8828	  ::) dllsearchpath=$testbindir;;
8829	  *) func_append dllsearchpath ":$testbindir";;
8830	  esac
8831	  ;;
8832	esac
8833      done
8834      # Substitute the hardcoded libdirs into the rpath.
8835      if test -n "$hardcode_libdir_separator" &&
8836	 test -n "$hardcode_libdirs"; then
8837	libdir="$hardcode_libdirs"
8838	eval rpath=\" $hardcode_libdir_flag_spec\"
8839      fi
8840      compile_rpath="$rpath"
8841
8842      rpath=
8843      hardcode_libdirs=
8844      for libdir in $finalize_rpath; do
8845	if test -n "$hardcode_libdir_flag_spec"; then
8846	  if test -n "$hardcode_libdir_separator"; then
8847	    if test -z "$hardcode_libdirs"; then
8848	      hardcode_libdirs="$libdir"
8849	    else
8850	      # Just accumulate the unique libdirs.
8851	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8852	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8853		;;
8854	      *)
8855		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8856		;;
8857	      esac
8858	    fi
8859	  else
8860	    eval flag=\"$hardcode_libdir_flag_spec\"
8861	    func_append rpath " $flag"
8862	  fi
8863	elif test -n "$runpath_var"; then
8864	  case "$finalize_perm_rpath " in
8865	  *" $libdir "*) ;;
8866	  *) func_append finalize_perm_rpath " $libdir" ;;
8867	  esac
8868	fi
8869      done
8870      # Substitute the hardcoded libdirs into the rpath.
8871      if test -n "$hardcode_libdir_separator" &&
8872	 test -n "$hardcode_libdirs"; then
8873	libdir="$hardcode_libdirs"
8874	eval rpath=\" $hardcode_libdir_flag_spec\"
8875      fi
8876      finalize_rpath="$rpath"
8877
8878      if test -n "$libobjs" && test "$build_old_libs" = yes; then
8879	# Transform all the library objects into standard objects.
8880	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8881	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8882      fi
8883
8884      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
8885
8886      # template prelinking step
8887      if test -n "$prelink_cmds"; then
8888	func_execute_cmds "$prelink_cmds" 'exit $?'
8889      fi
8890
8891      wrappers_required=yes
8892      case $host in
8893      *cegcc* | *mingw32ce*)
8894        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
8895        wrappers_required=no
8896        ;;
8897      *cygwin* | *mingw* )
8898        if test "$build_libtool_libs" != yes; then
8899          wrappers_required=no
8900        fi
8901        ;;
8902      *)
8903        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
8904          wrappers_required=no
8905        fi
8906        ;;
8907      esac
8908      if test "$wrappers_required" = no; then
8909	# Replace the output file specification.
8910	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8911	link_command="$compile_command$compile_rpath"
8912
8913	# We have no uninstalled library dependencies, so finalize right now.
8914	exit_status=0
8915	func_show_eval "$link_command" 'exit_status=$?'
8916
8917	if test -n "$postlink_cmds"; then
8918	  func_to_tool_file "$output"
8919	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8920	  func_execute_cmds "$postlink_cmds" 'exit $?'
8921	fi
8922
8923	# Delete the generated files.
8924	if test -f "$output_objdir/${outputname}S.${objext}"; then
8925	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
8926	fi
8927
8928	exit $exit_status
8929      fi
8930
8931      if test -n "$compile_shlibpath$finalize_shlibpath"; then
8932	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
8933      fi
8934      if test -n "$finalize_shlibpath"; then
8935	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
8936      fi
8937
8938      compile_var=
8939      finalize_var=
8940      if test -n "$runpath_var"; then
8941	if test -n "$perm_rpath"; then
8942	  # We should set the runpath_var.
8943	  rpath=
8944	  for dir in $perm_rpath; do
8945	    func_append rpath "$dir:"
8946	  done
8947	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
8948	fi
8949	if test -n "$finalize_perm_rpath"; then
8950	  # We should set the runpath_var.
8951	  rpath=
8952	  for dir in $finalize_perm_rpath; do
8953	    func_append rpath "$dir:"
8954	  done
8955	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
8956	fi
8957      fi
8958
8959      if test "$no_install" = yes; then
8960	# We don't need to create a wrapper script.
8961	link_command="$compile_var$compile_command$compile_rpath"
8962	# Replace the output file specification.
8963	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8964	# Delete the old output file.
8965	$opt_dry_run || $RM $output
8966	# Link the executable and exit
8967	func_show_eval "$link_command" 'exit $?'
8968
8969	if test -n "$postlink_cmds"; then
8970	  func_to_tool_file "$output"
8971	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8972	  func_execute_cmds "$postlink_cmds" 'exit $?'
8973	fi
8974
8975	exit $EXIT_SUCCESS
8976      fi
8977
8978      if test "$hardcode_action" = relink; then
8979	# Fast installation is not supported
8980	link_command="$compile_var$compile_command$compile_rpath"
8981	relink_command="$finalize_var$finalize_command$finalize_rpath"
8982
8983	func_warning "this platform does not like uninstalled shared libraries"
8984	func_warning "\`$output' will be relinked during installation"
8985      else
8986	if test "$fast_install" != no; then
8987	  link_command="$finalize_var$compile_command$finalize_rpath"
8988	  if test "$fast_install" = yes; then
8989	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
8990	  else
8991	    # fast_install is set to needless
8992	    relink_command=
8993	  fi
8994	else
8995	  link_command="$compile_var$compile_command$compile_rpath"
8996	  relink_command="$finalize_var$finalize_command$finalize_rpath"
8997	fi
8998      fi
8999
9000      # Replace the output file specification.
9001      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
9002
9003      # Delete the old output files.
9004      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
9005
9006      func_show_eval "$link_command" 'exit $?'
9007
9008      if test -n "$postlink_cmds"; then
9009	func_to_tool_file "$output_objdir/$outputname"
9010	postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
9011	func_execute_cmds "$postlink_cmds" 'exit $?'
9012      fi
9013
9014      # Now create the wrapper script.
9015      func_verbose "creating $output"
9016
9017      # Quote the relink command for shipping.
9018      if test -n "$relink_command"; then
9019	# Preserve any variables that may affect compiler behavior
9020	for var in $variables_saved_for_relink; do
9021	  if eval test -z \"\${$var+set}\"; then
9022	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9023	  elif eval var_value=\$$var; test -z "$var_value"; then
9024	    relink_command="$var=; export $var; $relink_command"
9025	  else
9026	    func_quote_for_eval "$var_value"
9027	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9028	  fi
9029	done
9030	relink_command="(cd `pwd`; $relink_command)"
9031	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9032      fi
9033
9034      # Only actually do things if not in dry run mode.
9035      $opt_dry_run || {
9036	# win32 will think the script is a binary if it has
9037	# a .exe suffix, so we strip it off here.
9038	case $output in
9039	  *.exe) func_stripname '' '.exe' "$output"
9040	         output=$func_stripname_result ;;
9041	esac
9042	# test for cygwin because mv fails w/o .exe extensions
9043	case $host in
9044	  *cygwin*)
9045	    exeext=.exe
9046	    func_stripname '' '.exe' "$outputname"
9047	    outputname=$func_stripname_result ;;
9048	  *) exeext= ;;
9049	esac
9050	case $host in
9051	  *cygwin* | *mingw* )
9052	    func_dirname_and_basename "$output" "" "."
9053	    output_name=$func_basename_result
9054	    output_path=$func_dirname_result
9055	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
9056	    cwrapper="$output_path/$output_name.exe"
9057	    $RM $cwrappersource $cwrapper
9058	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
9059
9060	    func_emit_cwrapperexe_src > $cwrappersource
9061
9062	    # The wrapper executable is built using the $host compiler,
9063	    # because it contains $host paths and files. If cross-
9064	    # compiling, it, like the target executable, must be
9065	    # executed on the $host or under an emulation environment.
9066	    $opt_dry_run || {
9067	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
9068	      $STRIP $cwrapper
9069	    }
9070
9071	    # Now, create the wrapper script for func_source use:
9072	    func_ltwrapper_scriptname $cwrapper
9073	    $RM $func_ltwrapper_scriptname_result
9074	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
9075	    $opt_dry_run || {
9076	      # note: this script will not be executed, so do not chmod.
9077	      if test "x$build" = "x$host" ; then
9078		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
9079	      else
9080		func_emit_wrapper no > $func_ltwrapper_scriptname_result
9081	      fi
9082	    }
9083	  ;;
9084	  * )
9085	    $RM $output
9086	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
9087
9088	    func_emit_wrapper no > $output
9089	    chmod +x $output
9090	  ;;
9091	esac
9092      }
9093      exit $EXIT_SUCCESS
9094      ;;
9095    esac
9096
9097    # See if we need to build an old-fashioned archive.
9098    for oldlib in $oldlibs; do
9099
9100      if test "$build_libtool_libs" = convenience; then
9101	oldobjs="$libobjs_save $symfileobj"
9102	addlibs="$convenience"
9103	build_libtool_libs=no
9104      else
9105	if test "$build_libtool_libs" = module; then
9106	  oldobjs="$libobjs_save"
9107	  build_libtool_libs=no
9108	else
9109	  oldobjs="$old_deplibs $non_pic_objects"
9110	  if test "$preload" = yes && test -f "$symfileobj"; then
9111	    func_append oldobjs " $symfileobj"
9112	  fi
9113	fi
9114	addlibs="$old_convenience"
9115      fi
9116
9117      if test -n "$addlibs"; then
9118	gentop="$output_objdir/${outputname}x"
9119	func_append generated " $gentop"
9120
9121	func_extract_archives $gentop $addlibs
9122	func_append oldobjs " $func_extract_archives_result"
9123      fi
9124
9125      # Do each command in the archive commands.
9126      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
9127	cmds=$old_archive_from_new_cmds
9128      else
9129
9130	# Add any objects from preloaded convenience libraries
9131	if test -n "$dlprefiles"; then
9132	  gentop="$output_objdir/${outputname}x"
9133	  func_append generated " $gentop"
9134
9135	  func_extract_archives $gentop $dlprefiles
9136	  func_append oldobjs " $func_extract_archives_result"
9137	fi
9138
9139	# POSIX demands no paths to be encoded in archives.  We have
9140	# to avoid creating archives with duplicate basenames if we
9141	# might have to extract them afterwards, e.g., when creating a
9142	# static archive out of a convenience library, or when linking
9143	# the entirety of a libtool archive into another (currently
9144	# not supported by libtool).
9145	if (for obj in $oldobjs
9146	    do
9147	      func_basename "$obj"
9148	      $ECHO "$func_basename_result"
9149	    done | sort | sort -uc >/dev/null 2>&1); then
9150	  :
9151	else
9152	  echo "copying selected object files to avoid basename conflicts..."
9153	  gentop="$output_objdir/${outputname}x"
9154	  func_append generated " $gentop"
9155	  func_mkdir_p "$gentop"
9156	  save_oldobjs=$oldobjs
9157	  oldobjs=
9158	  counter=1
9159	  for obj in $save_oldobjs
9160	  do
9161	    func_basename "$obj"
9162	    objbase="$func_basename_result"
9163	    case " $oldobjs " in
9164	    " ") oldobjs=$obj ;;
9165	    *[\ /]"$objbase "*)
9166	      while :; do
9167		# Make sure we don't pick an alternate name that also
9168		# overlaps.
9169		newobj=lt$counter-$objbase
9170		func_arith $counter + 1
9171		counter=$func_arith_result
9172		case " $oldobjs " in
9173		*[\ /]"$newobj "*) ;;
9174		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
9175		esac
9176	      done
9177	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
9178	      func_append oldobjs " $gentop/$newobj"
9179	      ;;
9180	    *) func_append oldobjs " $obj" ;;
9181	    esac
9182	  done
9183	fi
9184	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
9185	tool_oldlib=$func_to_tool_file_result
9186	eval cmds=\"$old_archive_cmds\"
9187
9188	func_len " $cmds"
9189	len=$func_len_result
9190	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
9191	  cmds=$old_archive_cmds
9192	elif test -n "$archiver_list_spec"; then
9193	  func_verbose "using command file archive linking..."
9194	  for obj in $oldobjs
9195	  do
9196	    func_to_tool_file "$obj"
9197	    $ECHO "$func_to_tool_file_result"
9198	  done > $output_objdir/$libname.libcmd
9199	  func_to_tool_file "$output_objdir/$libname.libcmd"
9200	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
9201	  cmds=$old_archive_cmds
9202	else
9203	  # the command line is too long to link in one step, link in parts
9204	  func_verbose "using piecewise archive linking..."
9205	  save_RANLIB=$RANLIB
9206	  RANLIB=:
9207	  objlist=
9208	  concat_cmds=
9209	  save_oldobjs=$oldobjs
9210	  oldobjs=
9211	  # Is there a better way of finding the last object in the list?
9212	  for obj in $save_oldobjs
9213	  do
9214	    last_oldobj=$obj
9215	  done
9216	  eval test_cmds=\"$old_archive_cmds\"
9217	  func_len " $test_cmds"
9218	  len0=$func_len_result
9219	  len=$len0
9220	  for obj in $save_oldobjs
9221	  do
9222	    func_len " $obj"
9223	    func_arith $len + $func_len_result
9224	    len=$func_arith_result
9225	    func_append objlist " $obj"
9226	    if test "$len" -lt "$max_cmd_len"; then
9227	      :
9228	    else
9229	      # the above command should be used before it gets too long
9230	      oldobjs=$objlist
9231	      if test "$obj" = "$last_oldobj" ; then
9232		RANLIB=$save_RANLIB
9233	      fi
9234	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9235	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
9236	      objlist=
9237	      len=$len0
9238	    fi
9239	  done
9240	  RANLIB=$save_RANLIB
9241	  oldobjs=$objlist
9242	  if test "X$oldobjs" = "X" ; then
9243	    eval cmds=\"\$concat_cmds\"
9244	  else
9245	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
9246	  fi
9247	fi
9248      fi
9249      func_execute_cmds "$cmds" 'exit $?'
9250    done
9251
9252    test -n "$generated" && \
9253      func_show_eval "${RM}r$generated"
9254
9255    # Now create the libtool archive.
9256    case $output in
9257    *.la)
9258      old_library=
9259      test "$build_old_libs" = yes && old_library="$libname.$libext"
9260      func_verbose "creating $output"
9261
9262      # Preserve any variables that may affect compiler behavior
9263      for var in $variables_saved_for_relink; do
9264	if eval test -z \"\${$var+set}\"; then
9265	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9266	elif eval var_value=\$$var; test -z "$var_value"; then
9267	  relink_command="$var=; export $var; $relink_command"
9268	else
9269	  func_quote_for_eval "$var_value"
9270	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9271	fi
9272      done
9273      # Quote the link command for shipping.
9274      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
9275      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9276      if test "$hardcode_automatic" = yes ; then
9277	relink_command=
9278      fi
9279
9280      # Only create the output if not a dry run.
9281      $opt_dry_run || {
9282	for installed in no yes; do
9283	  if test "$installed" = yes; then
9284	    if test -z "$install_libdir"; then
9285	      break
9286	    fi
9287	    output="$output_objdir/$outputname"i
9288	    # Replace all uninstalled libtool libraries with the installed ones
9289	    newdependency_libs=
9290	    for deplib in $dependency_libs; do
9291	      case $deplib in
9292	      *.la)
9293		func_basename "$deplib"
9294		name="$func_basename_result"
9295		func_resolve_sysroot "$deplib"
9296		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
9297		test -z "$libdir" && \
9298		  func_fatal_error "\`$deplib' is not a valid libtool archive"
9299		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
9300		;;
9301	      -L*)
9302		func_stripname -L '' "$deplib"
9303		func_replace_sysroot "$func_stripname_result"
9304		func_append newdependency_libs " -L$func_replace_sysroot_result"
9305		;;
9306	      -R*)
9307		func_stripname -R '' "$deplib"
9308		func_replace_sysroot "$func_stripname_result"
9309		func_append newdependency_libs " -R$func_replace_sysroot_result"
9310		;;
9311	      *) func_append newdependency_libs " $deplib" ;;
9312	      esac
9313	    done
9314	    dependency_libs="$newdependency_libs"
9315	    newdlfiles=
9316
9317	    for lib in $dlfiles; do
9318	      case $lib in
9319	      *.la)
9320	        func_basename "$lib"
9321		name="$func_basename_result"
9322		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9323		test -z "$libdir" && \
9324		  func_fatal_error "\`$lib' is not a valid libtool archive"
9325		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
9326		;;
9327	      *) func_append newdlfiles " $lib" ;;
9328	      esac
9329	    done
9330	    dlfiles="$newdlfiles"
9331	    newdlprefiles=
9332	    for lib in $dlprefiles; do
9333	      case $lib in
9334	      *.la)
9335		# Only pass preopened files to the pseudo-archive (for
9336		# eventual linking with the app. that links it) if we
9337		# didn't already link the preopened objects directly into
9338		# the library:
9339		func_basename "$lib"
9340		name="$func_basename_result"
9341		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9342		test -z "$libdir" && \
9343		  func_fatal_error "\`$lib' is not a valid libtool archive"
9344		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
9345		;;
9346	      esac
9347	    done
9348	    dlprefiles="$newdlprefiles"
9349	  else
9350	    newdlfiles=
9351	    for lib in $dlfiles; do
9352	      case $lib in
9353		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9354		*) abs=`pwd`"/$lib" ;;
9355	      esac
9356	      func_append newdlfiles " $abs"
9357	    done
9358	    dlfiles="$newdlfiles"
9359	    newdlprefiles=
9360	    for lib in $dlprefiles; do
9361	      case $lib in
9362		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9363		*) abs=`pwd`"/$lib" ;;
9364	      esac
9365	      func_append newdlprefiles " $abs"
9366	    done
9367	    dlprefiles="$newdlprefiles"
9368	  fi
9369	  $RM $output
9370	  # place dlname in correct position for cygwin
9371	  # In fact, it would be nice if we could use this code for all target
9372	  # systems that can't hard-code library paths into their executables
9373	  # and that have no shared library path variable independent of PATH,
9374	  # but it turns out we can't easily determine that from inspecting
9375	  # libtool variables, so we have to hard-code the OSs to which it
9376	  # applies here; at the moment, that means platforms that use the PE
9377	  # object format with DLL files.  See the long comment at the top of
9378	  # tests/bindir.at for full details.
9379	  tdlname=$dlname
9380	  case $host,$output,$installed,$module,$dlname in
9381	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
9382	      # If a -bindir argument was supplied, place the dll there.
9383	      if test "x$bindir" != x ;
9384	      then
9385		func_relative_path "$install_libdir" "$bindir"
9386		tdlname=$func_relative_path_result$dlname
9387	      else
9388		# Otherwise fall back on heuristic.
9389		tdlname=../bin/$dlname
9390	      fi
9391	      ;;
9392	  esac
9393	  $ECHO > $output "\
9394# $outputname - a libtool library file
9395# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
9396#
9397# Please DO NOT delete this file!
9398# It is necessary for linking the library.
9399
9400# The name that we can dlopen(3).
9401dlname='$tdlname'
9402
9403# Names of this library.
9404library_names='$library_names'
9405
9406# The name of the static archive.
9407old_library='$old_library'
9408
9409# Linker flags that can not go in dependency_libs.
9410inherited_linker_flags='$new_inherited_linker_flags'
9411
9412# Libraries that this one depends upon.
9413dependency_libs='$dependency_libs'
9414
9415# Names of additional weak libraries provided by this library
9416weak_library_names='$weak_libs'
9417
9418# Version information for $libname.
9419current=$current
9420age=$age
9421revision=$revision
9422
9423# Is this an already installed library?
9424installed=$installed
9425
9426# Should we warn about portability when linking against -modules?
9427shouldnotlink=$module
9428
9429# Files to dlopen/dlpreopen
9430dlopen='$dlfiles'
9431dlpreopen='$dlprefiles'
9432
9433# Directory that this library needs to be installed in:
9434libdir='$install_libdir'"
9435	  if test "$installed" = no && test "$need_relink" = yes && \
9436	     test -n "$relink_command"; then
9437	    $ECHO >> $output "\
9438relink_command=\"$relink_command\""
9439	  fi
9440	done
9441      }
9442
9443      # Do a symbolic link so that the libtool archive can be found in
9444      # LD_LIBRARY_PATH before the program is installed.
9445      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
9446      ;;
9447    esac
9448    exit $EXIT_SUCCESS
9449}
9450
9451{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
9452    func_mode_link ${1+"$@"}
9453
9454
9455# func_mode_uninstall arg...
9456func_mode_uninstall ()
9457{
9458    $opt_debug
9459    RM="$nonopt"
9460    files=
9461    rmforce=
9462    exit_status=0
9463
9464    # This variable tells wrapper scripts just to set variables rather
9465    # than running their programs.
9466    libtool_install_magic="$magic"
9467
9468    for arg
9469    do
9470      case $arg in
9471      -f) func_append RM " $arg"; rmforce=yes ;;
9472      -*) func_append RM " $arg" ;;
9473      *) func_append files " $arg" ;;
9474      esac
9475    done
9476
9477    test -z "$RM" && \
9478      func_fatal_help "you must specify an RM program"
9479
9480    rmdirs=
9481
9482    for file in $files; do
9483      func_dirname "$file" "" "."
9484      dir="$func_dirname_result"
9485      if test "X$dir" = X.; then
9486	odir="$objdir"
9487      else
9488	odir="$dir/$objdir"
9489      fi
9490      func_basename "$file"
9491      name="$func_basename_result"
9492      test "$opt_mode" = uninstall && odir="$dir"
9493
9494      # Remember odir for removal later, being careful to avoid duplicates
9495      if test "$opt_mode" = clean; then
9496	case " $rmdirs " in
9497	  *" $odir "*) ;;
9498	  *) func_append rmdirs " $odir" ;;
9499	esac
9500      fi
9501
9502      # Don't error if the file doesn't exist and rm -f was used.
9503      if { test -L "$file"; } >/dev/null 2>&1 ||
9504	 { test -h "$file"; } >/dev/null 2>&1 ||
9505	 test -f "$file"; then
9506	:
9507      elif test -d "$file"; then
9508	exit_status=1
9509	continue
9510      elif test "$rmforce" = yes; then
9511	continue
9512      fi
9513
9514      rmfiles="$file"
9515
9516      case $name in
9517      *.la)
9518	# Possibly a libtool archive, so verify it.
9519	if func_lalib_p "$file"; then
9520	  func_source $dir/$name
9521
9522	  # Delete the libtool libraries and symlinks.
9523	  for n in $library_names; do
9524	    func_append rmfiles " $odir/$n"
9525	  done
9526	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
9527
9528	  case "$opt_mode" in
9529	  clean)
9530	    case " $library_names " in
9531	    *" $dlname "*) ;;
9532	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
9533	    esac
9534	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
9535	    ;;
9536	  uninstall)
9537	    if test -n "$library_names"; then
9538	      # Do each command in the postuninstall commands.
9539	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9540	    fi
9541
9542	    if test -n "$old_library"; then
9543	      # Do each command in the old_postuninstall commands.
9544	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9545	    fi
9546	    # FIXME: should reinstall the best remaining shared library.
9547	    ;;
9548	  esac
9549	fi
9550	;;
9551
9552      *.lo)
9553	# Possibly a libtool object, so verify it.
9554	if func_lalib_p "$file"; then
9555
9556	  # Read the .lo file
9557	  func_source $dir/$name
9558
9559	  # Add PIC object to the list of files to remove.
9560	  if test -n "$pic_object" &&
9561	     test "$pic_object" != none; then
9562	    func_append rmfiles " $dir/$pic_object"
9563	  fi
9564
9565	  # Add non-PIC object to the list of files to remove.
9566	  if test -n "$non_pic_object" &&
9567	     test "$non_pic_object" != none; then
9568	    func_append rmfiles " $dir/$non_pic_object"
9569	  fi
9570	fi
9571	;;
9572
9573      *)
9574	if test "$opt_mode" = clean ; then
9575	  noexename=$name
9576	  case $file in
9577	  *.exe)
9578	    func_stripname '' '.exe' "$file"
9579	    file=$func_stripname_result
9580	    func_stripname '' '.exe' "$name"
9581	    noexename=$func_stripname_result
9582	    # $file with .exe has already been added to rmfiles,
9583	    # add $file without .exe
9584	    func_append rmfiles " $file"
9585	    ;;
9586	  esac
9587	  # Do a test to see if this is a libtool program.
9588	  if func_ltwrapper_p "$file"; then
9589	    if func_ltwrapper_executable_p "$file"; then
9590	      func_ltwrapper_scriptname "$file"
9591	      relink_command=
9592	      func_source $func_ltwrapper_scriptname_result
9593	      func_append rmfiles " $func_ltwrapper_scriptname_result"
9594	    else
9595	      relink_command=
9596	      func_source $dir/$noexename
9597	    fi
9598
9599	    # note $name still contains .exe if it was in $file originally
9600	    # as does the version of $file that was added into $rmfiles
9601	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
9602	    if test "$fast_install" = yes && test -n "$relink_command"; then
9603	      func_append rmfiles " $odir/lt-$name"
9604	    fi
9605	    if test "X$noexename" != "X$name" ; then
9606	      func_append rmfiles " $odir/lt-${noexename}.c"
9607	    fi
9608	  fi
9609	fi
9610	;;
9611      esac
9612      func_show_eval "$RM $rmfiles" 'exit_status=1'
9613    done
9614
9615    # Try to remove the ${objdir}s in the directories where we deleted files
9616    for dir in $rmdirs; do
9617      if test -d "$dir"; then
9618	func_show_eval "rmdir $dir >/dev/null 2>&1"
9619      fi
9620    done
9621
9622    exit $exit_status
9623}
9624
9625{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
9626    func_mode_uninstall ${1+"$@"}
9627
9628test -z "$opt_mode" && {
9629  help="$generic_help"
9630  func_fatal_help "you must specify a MODE"
9631}
9632
9633test -z "$exec_cmd" && \
9634  func_fatal_help "invalid operation mode \`$opt_mode'"
9635
9636if test -n "$exec_cmd"; then
9637  eval exec "$exec_cmd"
9638  exit $EXIT_FAILURE
9639fi
9640
9641exit $exit_status
9642
9643
9644# The TAGs below are defined such that we never get into a situation
9645# in which we disable both kinds of libraries.  Given conflicting
9646# choices, we go for a static library, that is the most portable,
9647# since we can't tell whether shared libraries were disabled because
9648# the user asked for that or because the platform doesn't support
9649# them.  This is particularly important on AIX, because we don't
9650# support having both static and shared libraries enabled at the same
9651# time on that platform, so we default to a shared-only configuration.
9652# If a disable-shared tag is given, we'll fallback to a static-only
9653# configuration.  But we'll never go from static-only to shared-only.
9654
9655# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
9656build_libtool_libs=no
9657build_old_libs=yes
9658# ### END LIBTOOL TAG CONFIG: disable-shared
9659
9660# ### BEGIN LIBTOOL TAG CONFIG: disable-static
9661build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
9662# ### END LIBTOOL TAG CONFIG: disable-static
9663
9664# Local Variables:
9665# mode:shell-script
9666# sh-indentation:2
9667# End:
9668# vi:sw=2
9669
9670