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