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