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