Debian Codegraph @

libtool

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