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