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