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