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