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