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