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