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