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