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