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