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