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