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