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