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