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