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