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