3 # libtool (GNU libtool) 2.4.2.418
4 # Provide generalized library-building support services.
5 # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
7 # Copyright (C) 1996-2013 Free Software Foundation, Inc.
8 # This is free software; see the source for copying conditions. There is NO
9 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 # GNU Libtool is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # As a special exception to the GNU General Public License,
17 # if you distribute this file as part of a program or library that
18 # is built using GNU Libtool, you may include this file under the
19 # same distribution terms that you use for the rest of that program.
21 # GNU Libtool is distributed in the hope that it will be useful, but
22 # WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 # General Public License for more details.
26 # You should have received a copy of the GNU General Public License
27 # along with this program. If not, see <http://www.gnu.org/licenses/>.
33 package_revision=2.4.2.418
40 # Run './libtool --help' for help with using this script from the
44 ## ------------------------------- ##
45 ## User overridable command paths. ##
46 ## ------------------------------- ##
48 # After configure completes, it has a better idea of some of the
49 # shell tools we need than the defaults used by the functions shared
50 # with bootstrap, so set those here where they can still be over-
51 # ridden by the user, but otherwise take precedence.
53 : ${AUTOCONF="autoconf"}
54 : ${AUTOMAKE="automake"}
57 ## -------------------------- ##
58 ## Source external libraries. ##
59 ## -------------------------- ##
61 # Much of our low-level functionality needs to be sourced from external
62 # libraries, which are installed to $pkgauxdir.
64 # Set a version string for this script.
65 scriptversion=2013-08-23.20; # UTC
67 # General shell script boiler plate, and helper functions.
68 # Written by Gary V. Vaughan, 2004
70 # Copyright (C) 2004-2013 Free Software Foundation, Inc.
71 # This is free software; see the source for copying conditions. There is NO
72 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
74 # This program is free software; you can redistribute it and/or modify
75 # it under the terms of the GNU General Public License as published by
76 # the Free Software Foundation; either version 3 of the License, or
77 # (at your option) any later version.
79 # As a special exception to the GNU General Public License, if you distribute
80 # this file as part of a program or library that is built using GNU Libtool,
81 # you may include this file under the same distribution terms that you use
82 # for the rest of that program.
84 # This program is distributed in the hope that it will be useful,
85 # but WITHOUT ANY WARRANTY; without even the implied warranty of
86 # MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
87 # General Public License for more details.
89 # You should have received a copy of the GNU General Public License
90 # along with this program. If not, see <http://www.gnu.org/licenses/>.
92 # Please report bugs or propose patches to gary@gnu.org.
99 # Evaluate this file near the top of your script to gain access to
100 # the functions and variables defined here:
102 # . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
104 # If you need to override any of the default environment variable
105 # settings, do that before evaluating this file.
108 ## -------------------- ##
109 ## Shell normalisation. ##
110 ## -------------------- ##
112 # Some shells need a little help to be as Bourne compatible as possible.
113 # Before doing anything else, make sure all that help has been provided!
115 DUALCASE=1; export DUALCASE # for MKS sh
116 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
119 # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
120 # is contrary to our usage. Disable this feature.
121 alias -g '${1+"$@"}'='"$@"'
124 case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
127 # NLS nuisances: We save the old values in case they are required later.
130 for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
132 eval "if test set = \"\${$_G_var+set}\"; then
133 save_$_G_var=\$$_G_var
136 _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
137 _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
142 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
144 # Make sure IFS has a sensible default
150 # There are still modern systems that have problems with 'echo' mis-
151 # handling backslashes, among others, so make sure $bs_echo is set to a
152 # command that correctly interprets backslashes.
153 # (this code from Autoconf 2.68)
155 # Printing a long string crashes Solaris 7 /usr/bin/printf.
156 bs_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
157 bs_echo=$bs_echo$bs_echo$bs_echo$bs_echo$bs_echo
158 bs_echo=$bs_echo$bs_echo$bs_echo$bs_echo$bs_echo$bs_echo
159 # Prefer a ksh shell builtin over an external printf program on Solaris,
160 # but without wasting forks for bash or zsh.
161 if test -z "$BASH_VERSION$ZSH_VERSION" \
162 && (test "X`print -r -- $bs_echo`" = "X$bs_echo") 2>/dev/null; then
163 bs_echo='print -r --'
164 bs_echo_n='print -rn --'
165 elif (test "X`printf %s $bs_echo`" = "X$bs_echo") 2>/dev/null; then
166 bs_echo='printf %s\n'
167 bs_echo_n='printf %s'
169 if test "X`(/usr/ucb/echo -n -n $bs_echo) 2>/dev/null`" = "X-n $bs_echo"; then
170 bs_echo_body='eval /usr/ucb/echo -n "$1$nl"'
171 bs_echo_n='/usr/ucb/echo -n'
173 bs_echo_body='eval expr "X$1" : "X\\(.*\\)"'
178 expr "X$arg" : "X\\(.*\\)$nl";
179 arg=`expr "X$arg" : ".*$nl\\(.*\\)"`;;
181 expr "X$arg" : "X\\(.*\\)" | tr -d "$nl"
183 export bs_echo_n_body
184 bs_echo_n='sh -c $bs_echo_n_body bs_echo'
187 bs_echo='sh -c $bs_echo_body bs_echo'
191 ## ------------------------------- ##
192 ## User overridable command paths. ##
193 ## ------------------------------- ##
195 # All uppercase variable names are used for environment variables. These
196 # variables can be overridden by the user before calling a script that
197 # uses them if a suitable command of that name is not already available
198 # in the command search PATH.
211 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
214 ## -------------------- ##
215 ## Useful sed snippets. ##
216 ## -------------------- ##
218 sed_dirname='s|/[^/]*$||'
219 sed_basename='s|^.*/||'
221 # Sed substitution that helps us do robust quoting. It backslashifies
222 # metacharacters that are still active within double-quoted strings.
223 sed_quote_subst='s|\([`"$\\]\)|\\\1|g'
225 # Same as above, but do not quote variable references.
226 sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
228 # Sed substitution that turns a string into a regex matching for the
230 sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
232 # Sed substitution that converts a w32 file name or path
233 # that contains forward slashes, into one that contains
234 # (escaped) backslashes. A very naive implementation.
235 sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
237 # Re-'\' parameter expansions in output of sed_double_quote_subst that
238 # were '\'-ed in input to the same. If an odd number of '\' preceded a
239 # '$' in input to sed_double_quote_subst, that '$' was protected from
240 # expansion. Since each input '\' is now two '\'s, look for any number
241 # of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'.
246 sed_double_backslash="\
249 s/^$_G_bs2$_G_dollar/$_G_bs&/
250 s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
254 ## ----------------- ##
255 ## Global variables. ##
256 ## ----------------- ##
258 # Except for the global variables explicitly listed below, the following
259 # functions in the '^func_' namespace, and the '^require_' namespace
260 # variables initialised in the 'Resource management' section, sourcing
261 # this file will not pollute your global namespace with anything
262 # else. There's no portable way to scope variables in Bourne shell
263 # though, so actually running these functions will sometimes place
264 # results into a variable named after the function, and often use
265 # temporary variables in the '^_G_' namespace. If you are careful to
266 # avoid using those namespaces casually in your sourcing script, things
267 # should continue to work as you expect. And, of course, you can freely
268 # overwrite any of the functions or variables defined here before
269 # calling anything to customize them.
273 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
274 EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
276 # Allow overriding, eg assuming that you follow the convention of
277 # putting '$debug_cmd' at the start of all your functions, you can get
278 # bash to show function call trace with:
280 # debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
281 debug_cmd=${debug_cmd-":"}
284 # By convention, finish your script with:
288 # so that you can set exit_status to non-zero if you want to indicate
289 # something went wrong during execution without actually bailing out at
290 # the point of failure.
291 exit_status=$EXIT_SUCCESS
293 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
294 # is ksh but when the shell is invoked as "sh" and the current value of
295 # the _XPG environment variable is not equal to 1 (one), the special
296 # positional parameter $0, within a function call, is the name of the
300 # The name of this program.
301 progname=`$bs_echo "$progpath" |$SED "$sed_basename"`
303 # Make sure we have an absolute progpath for reexecution:
305 [\\/]*|[A-Za-z]:\\*) ;;
307 progdir=`$bs_echo "$progpath" |$SED "$sed_dirname"`
308 progdir=`cd "$progdir" && pwd`
309 progpath=$progdir/$progname
313 IFS=${PATH_SEPARATOR-:}
314 for progdir in $PATH; do
316 test -x "$progdir/$progname" && break
319 test -n "$progdir" || progdir=`pwd`
320 progpath=$progdir/$progname
325 ## ----------------- ##
326 ## Standard options. ##
327 ## ----------------- ##
329 # The following options affect the operation of the functions defined
330 # below, and should be set appropriately depending on run-time para-
331 # meters passed on the command line.
337 # Categories 'all' and 'none' are always available. Append any others
338 # you will pass as the first argument to func_warning from your own
342 # By default, display warnings according to 'opt_warning_types'. Set
343 # 'warning_func' to ':' to elide all warnings, or func_fatal_error to
344 # treat the next displayed warning as a fatal error.
345 warning_func=func_warn_and_continue
347 # Set to 'all' to display all warnings, 'none' to suppress all
348 # warnings, or a space delimited list of some subset of
349 # 'warning_categories' to display only the listed warnings.
350 opt_warning_types=all
353 ## -------------------- ##
354 ## Resource management. ##
355 ## -------------------- ##
357 # This section contains definitions for functions that each ensure a
358 # particular resource (a file, or a non-empty configuration variable for
359 # example) is available, and if appropriate to extract default values
360 # from pertinent package files. Call them using their associated
361 # 'require_*' variable to ensure that they are executed, at most, once.
363 # It's entirely deliberate that calling these functions can set
364 # variables that don't obey the namespace limitations obeyed by the rest
365 # of this file, in order that that they be as useful as possible to
369 # require_term_colors
370 # -------------------
371 # Allow display of bold text on terminals that support it.
372 require_term_colors=func_require_term_colors
373 func_require_term_colors ()
378 # COLORTERM and USE_ANSI_COLORS environment variables take
379 # precedence, because most terminfo databases neglect to describe
380 # whether color sequences are supported.
381 test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
383 if test 1 = "$USE_ANSI_COLORS"; then
384 # Standard ANSI escape sequences
386 tc_bold='
\e[1m'; tc_standout='
\e[7m'
387 tc_red='
\e[31m'; tc_green='
\e[32m'
388 tc_blue='
\e[34m'; tc_cyan='
\e[36m'
390 # Otherwise trust the terminfo database after all.
391 test -n "`tput sgr0 2>/dev/null`" && {
393 test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
395 test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
396 test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
397 test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
398 test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
399 test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
404 require_term_colors=:
408 ## ----------------- ##
409 ## Function library. ##
410 ## ----------------- ##
412 # This section contains a variety of useful functions to call in your
413 # scripts. Take note of the portable wrappers for features provided by
414 # some modern shells, which will fall back to slower equivalents on
415 # less featureful shells.
418 # func_append VAR VALUE
419 # ---------------------
420 # Append VALUE onto the existing contents of VAR.
422 # We should try to minimise forks, especially on Windows where they are
423 # unreasonably slow, so skip the feature probes when bash or zsh are
425 if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
426 : ${_G_HAVE_ARITH_OP="yes"}
427 : ${_G_HAVE_XSI_OPS="yes"}
428 # The += operator was introduced in bash 3.1
429 case $BASH_VERSION in
430 [12].* | 3.0 | 3.0*) ;;
432 : ${_G_HAVE_PLUSEQ_OP="yes"}
438 # Can be empty, in which case the shell is probed, "yes" if += is
439 # useable or anything else if it does not work.
440 test -z "$_G_HAVE_PLUSEQ_OP" \
441 && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
442 && _G_HAVE_PLUSEQ_OP=yes
444 if test yes = "$_G_HAVE_PLUSEQ_OP"
446 # This is an XSI compatible shell, allowing a faster implementation...
454 # ...otherwise fall back to using expr, which is often a shell builtin.
464 # func_append_quoted VAR VALUE
465 # ----------------------------
466 # Quote VALUE and append to the end of shell variable VAR, separated
468 if test yes = "$_G_HAVE_PLUSEQ_OP"; then
469 eval 'func_append_quoted ()
473 func_quote_for_eval "$2"
474 eval "$1+=\\ \$func_quote_for_eval_result"
477 func_append_quoted ()
481 func_quote_for_eval "$2"
482 eval "$1=\$$1\\ \$func_quote_for_eval_result"
487 # func_append_uniq VAR VALUE
488 # --------------------------
489 # Append unique VALUE onto the existing contents of VAR, assuming
490 # entries are delimited by the first character of VALUE. For example:
492 # func_append_uniq options " --another-option option-argument"
494 # will only append to $options if " --another-option option-argument "
495 # is not already present somewhere in $options already (note spaces at
496 # each end implied by leading space in second argument).
501 eval _G_current_value='`$bs_echo $'$1'`'
502 _G_delim=`expr "$2" : '\(.\)'`
504 case $_G_delim$_G_current_value$_G_delim in
506 *) func_append "$@" ;;
513 # Set func_arith_result to the result of evaluating TERMs.
514 test -z "$_G_HAVE_ARITH_OP" \
515 && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
516 && _G_HAVE_ARITH_OP=yes
518 if test yes = "$_G_HAVE_ARITH_OP"; then
523 func_arith_result=$(( $* ))
530 func_arith_result=`expr "$@"`
537 # Set func_basename_result to FILE with everything up to and including
538 # the last / stripped.
539 if test yes = "$_G_HAVE_XSI_OPS"; then
540 # If this shell supports suffix pattern removal, then use it to avoid
541 # forking. Hide the definitions single quotes in case the shell chokes
542 # on unsupported syntax...
543 _b='func_basename_result=${1##*/}'
545 */*) func_dirname_result=${1%/*}$2 ;;
546 * ) func_dirname_result=$3 ;;
550 # ...otherwise fall back to using sed.
551 _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
552 _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"`
553 if test "X$func_dirname_result" = "X$1"; then
554 func_dirname_result=$3
556 func_append func_dirname_result "$2"
560 eval 'func_basename ()
568 # func_dirname FILE APPEND NONDIR_REPLACEMENT
569 # -------------------------------------------
570 # Compute the dirname of FILE. If nonempty, add APPEND to the result,
571 # otherwise set result to NONDIR_REPLACEMENT.
572 eval 'func_dirname ()
580 # func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
581 # --------------------------------------------------------
582 # Perform func_basename and func_dirname in a single function
584 # dirname: Compute the dirname of FILE. If nonempty,
585 # add APPEND to the result, otherwise set result
586 # to NONDIR_REPLACEMENT.
587 # value returned in "$func_dirname_result"
588 # basename: Compute filename of FILE.
589 # value retuned in "$func_basename_result"
590 # For efficiency, we do not delegate to the functions above but instead
591 # duplicate the functionality here.
592 eval 'func_dirname_and_basename ()
603 # Echo program name prefixed message.
612 for _G_line in $_G_message; do
614 $bs_echo "$progname: $_G_line"
620 # func_echo_all ARG...
621 # --------------------
622 # Invoke $ECHO with all args, space-separated.
629 # func_echo_infix_1 INFIX ARG...
630 # ------------------------------
631 # Echo program name, followed by INFIX on the first line, with any
632 # additional lines not showing INFIX.
641 _G_prefix="$progname: $_G_infix: "
644 # Strip color escape sequences before counting printable length
645 for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
647 test -n "$_G_tc" && {
648 _G_esc_tc=`$bs_echo "$_G_tc" | sed "$sed_make_literal_regex"`
649 _G_indent=`$bs_echo "$_G_indent" | sed "s|$_G_esc_tc||g"`
652 _G_indent="$progname: "`echo "$_G_indent" | sed 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes
654 func_echo_infix_1_IFS=$IFS
656 for _G_line in $_G_message; do
657 IFS=$func_echo_infix_1_IFS
658 $bs_echo "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
661 IFS=$func_echo_infix_1_IFS
667 # Echo program name prefixed message to standard error.
674 func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2
678 # func_fatal_error ARG...
679 # -----------------------
680 # Echo program name prefixed message to standard error, and exit.
690 # func_grep EXPRESSION FILENAME
691 # -----------------------------
692 # Check whether EXPRESSION matches any line of FILENAME, without output.
697 $GREP "$1" "$2" >/dev/null 2>&1
703 # Set func_len_result to the length of STRING. STRING may not
704 # start with a hyphen.
705 test -z "$_G_HAVE_XSI_OPS" \
707 test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
708 && _G_HAVE_XSI_OPS=yes
710 if test yes = "$_G_HAVE_XSI_OPS"; then
715 func_len_result=${#1}
722 func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
727 # func_mkdir_p DIRECTORY-PATH
728 # ---------------------------
729 # Make sure the entire path to DIRECTORY-PATH is available.
737 if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
739 # Protect directory names starting with '-'
740 case $_G_directory_path in
741 -*) _G_directory_path=./$_G_directory_path ;;
744 # While some portion of DIR does not yet exist...
745 while test ! -d "$_G_directory_path"; do
746 # ...make a list in topmost first order. Use a colon delimited
747 # list incase some portion of path contains whitespace.
748 _G_dir_list=$_G_directory_path:$_G_dir_list
750 # If the last portion added has no slash in it, the list is done
751 case $_G_directory_path in */*) ;; *) break ;; esac
753 # ...otherwise throw away the child directory and loop
754 _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
756 _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
758 func_mkdir_p_IFS=$IFS; IFS=:
759 for _G_dir in $_G_dir_list; do
760 IFS=$func_mkdir_p_IFS
761 # mkdir can fail with a 'File exist' error if two processes
762 # try to create one of the directories concurrently. Don't
764 $MKDIR "$_G_dir" 2>/dev/null || :
766 IFS=$func_mkdir_p_IFS
768 # Bail out if we (or some other process) failed to create a directory.
769 test -d "$_G_directory_path" || \
770 func_fatal_error "Failed to create '$1'"
775 # func_mktempdir [BASENAME]
776 # -------------------------
777 # Make a temporary directory that won't clash with other running
778 # libtool processes, and avoids race conditions if possible. If
779 # given, BASENAME is the basename for that directory.
784 _G_template=${TMPDIR-/tmp}/${1-$progname}
786 if test : = "$opt_dry_run"; then
787 # Return a directory name, but don't create it in dry-run mode
788 _G_tmpdir=$_G_template-$$
791 # If mktemp works, use that first and foremost
792 _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
794 if test ! -d "$_G_tmpdir"; then
795 # Failing that, at least try and use $RANDOM to avoid a race
796 _G_tmpdir=$_G_template-${RANDOM-0}$$
798 func_mktempdir_umask=`umask`
801 umask $func_mktempdir_umask
804 # If we're not in dry-run mode, bomb out on failure
805 test -d "$_G_tmpdir" || \
806 func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
813 # func_normal_abspath PATH
814 # ------------------------
815 # Remove doubled-up and trailing slashes, "." path components,
816 # and cancel out any ".." path components in PATH after making
817 # it an absolute path.
818 func_normal_abspath ()
822 # These SED scripts presuppose an absolute path with a trailing slash.
823 _G_pathcar='s|^/\([^/]*\).*$|\1|'
824 _G_pathcdr='s|^/[^/]*||'
825 _G_removedotparts=':dotsl
829 _G_collapseslashes='s|/\{1,\}|/|g'
830 _G_finalslash='s|/*$|/|'
832 # Start from root dir and reassemble the path.
833 func_normal_abspath_result=
834 func_normal_abspath_tpath=$1
835 func_normal_abspath_altnamespace=
836 case $func_normal_abspath_tpath in
838 # Empty path, that just means $cwd.
839 func_stripname '' '/' "`pwd`"
840 func_normal_abspath_result=$func_stripname_result
843 # The next three entries are used to spot a run of precisely
844 # two leading slashes without using negated character classes;
845 # we take advantage of case's first-match behaviour.
847 # Unusual form of absolute path, do nothing.
850 # Not necessarily an ordinary path; POSIX reserves leading '//'
851 # and for example Cygwin uses it to access remote file shares
852 # over CIFS/SMB, so we conserve a leading double slash if found.
853 func_normal_abspath_altnamespace=/
856 # Absolute path, do nothing.
859 # Relative path, prepend $cwd.
860 func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
864 # Cancel out all the simple stuff to save iterations. We also want
865 # the path to end with a slash for ease of parsing, so make sure
866 # there is one (and only one) here.
867 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
868 -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
870 # Processed it all yet?
871 if test / = "$func_normal_abspath_tpath"; then
872 # If we ascended to the root using ".." the result may be empty now.
873 if test -z "$func_normal_abspath_result"; then
874 func_normal_abspath_result=/
878 func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
880 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
882 # Figure out what to do with it
883 case $func_normal_abspath_tcomponent in
885 # Trailing empty path component, ignore it.
888 # Parent dir; strip last assembled component from result.
889 func_dirname "$func_normal_abspath_result"
890 func_normal_abspath_result=$func_dirname_result
893 # Actual path component, append it.
894 func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
898 # Restore leading double-slash if one was found on entry.
899 func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
903 # func_notquiet ARG...
904 # --------------------
905 # Echo program name prefixed message only when not in quiet mode.
910 $opt_quiet || func_echo ${1+"$@"}
912 # A bug in bash halts the script if the last line of a function
913 # fails when set -e is in force, so we need another command to
919 # func_relative_path SRCDIR DSTDIR
920 # --------------------------------
921 # Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
922 func_relative_path ()
926 func_relative_path_result=
927 func_normal_abspath "$1"
928 func_relative_path_tlibdir=$func_normal_abspath_result
929 func_normal_abspath "$2"
930 func_relative_path_tbindir=$func_normal_abspath_result
932 # Ascend the tree starting from libdir
934 # check if we have found a prefix of bindir
935 case $func_relative_path_tbindir in
936 $func_relative_path_tlibdir)
937 # found an exact match
938 func_relative_path_tcancelled=
941 $func_relative_path_tlibdir*)
942 # found a matching prefix
943 func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
944 func_relative_path_tcancelled=$func_stripname_result
945 if test -z "$func_relative_path_result"; then
946 func_relative_path_result=.
951 func_dirname $func_relative_path_tlibdir
952 func_relative_path_tlibdir=$func_dirname_result
953 if test -z "$func_relative_path_tlibdir"; then
954 # Have to descend all the way to the root!
955 func_relative_path_result=../$func_relative_path_result
956 func_relative_path_tcancelled=$func_relative_path_tbindir
959 func_relative_path_result=../$func_relative_path_result
964 # Now calculate path; take care to avoid doubling-up slashes.
965 func_stripname '' '/' "$func_relative_path_result"
966 func_relative_path_result=$func_stripname_result
967 func_stripname '/' '/' "$func_relative_path_tcancelled"
968 if test -n "$func_stripname_result"; then
969 func_append func_relative_path_result "/$func_stripname_result"
972 # Normalisation. If bindir is libdir, return '.' else relative path.
973 if test -n "$func_relative_path_result"; then
974 func_stripname './' '' "$func_relative_path_result"
975 func_relative_path_result=$func_stripname_result
978 test -n "$func_relative_path_result" || func_relative_path_result=.
984 # func_quote_for_eval ARG...
985 # --------------------------
986 # Aesthetically quote ARGs to be evaled later.
987 # This function returns two values:
988 # i) func_quote_for_eval_result
989 # double-quoted, suitable for a subsequent eval
990 # ii) func_quote_for_eval_unquoted_result
991 # has all characters that are still active within double
992 # quotes backslashified.
993 func_quote_for_eval ()
997 func_quote_for_eval_unquoted_result=
998 func_quote_for_eval_result=
999 while test 0 -lt $#; do
1002 _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
1004 _G_unquoted_arg=$1 ;;
1006 if test -n "$func_quote_for_eval_unquoted_result"; then
1007 func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
1009 func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
1012 case $_G_unquoted_arg in
1013 # Double-quote args containing shell metacharacters to delay
1014 # word splitting, command substitution and variable expansion
1015 # for a subsequent eval.
1016 # Many Bourne shells cannot handle close brackets correctly
1017 # in scan sets, so we specify it separately.
1018 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
1019 _G_quoted_arg=\"$_G_unquoted_arg\"
1022 _G_quoted_arg=$_G_unquoted_arg
1026 if test -n "$func_quote_for_eval_result"; then
1027 func_append func_quote_for_eval_result " $_G_quoted_arg"
1029 func_append func_quote_for_eval_result "$_G_quoted_arg"
1036 # func_quote_for_expand ARG
1037 # -------------------------
1038 # Aesthetically quote ARG to be evaled later; same as above,
1039 # but do not quote variable references.
1040 func_quote_for_expand ()
1046 _G_arg=`$ECHO "$1" | $SED \
1047 -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
1053 # Double-quote args containing shell metacharacters to delay
1054 # word splitting and command substitution for a subsequent eval.
1055 # Many Bourne shells cannot handle close brackets correctly
1056 # in scan sets, so we specify it separately.
1057 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
1062 func_quote_for_expand_result=$_G_arg
1066 # func_stripname PREFIX SUFFIX NAME
1067 # ---------------------------------
1068 # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
1069 # PREFIX and SUFFIX must not contain globbing or regex special
1070 # characters, hashes, percent signs, but SUFFIX may contain a leading
1071 # dot (in which case that matches only a dot).
1072 if test yes = "$_G_HAVE_XSI_OPS"; then
1073 eval 'func_stripname ()
1077 # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
1078 # positional parameters, so assign one to ordinary variable first.
1079 func_stripname_result=$3
1080 func_stripname_result=${func_stripname_result#"$1"}
1081 func_stripname_result=${func_stripname_result%"$2"}
1089 .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
1090 *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
1096 # func_show_eval CMD [FAIL_EXP]
1097 # -----------------------------
1098 # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
1099 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
1100 # is given, then evaluate it.
1106 _G_fail_exp=${2-':'}
1108 func_quote_for_expand "$_G_cmd"
1109 eval "func_notquiet $func_quote_for_expand_result"
1114 if test 0 -ne "$_G_status"; then
1115 eval "(exit $_G_status); $_G_fail_exp"
1121 # func_show_eval_locale CMD [FAIL_EXP]
1122 # ------------------------------------
1123 # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
1124 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
1125 # is given, then evaluate it. Use the saved locale for evaluation.
1126 func_show_eval_locale ()
1131 _G_fail_exp=${2-':'}
1134 func_quote_for_expand "$_G_cmd"
1135 eval "func_echo $func_quote_for_expand_result"
1139 eval "$_G_user_locale
1142 eval "$_G_safe_locale"
1143 if test 0 -ne "$_G_status"; then
1144 eval "(exit $_G_status); $_G_fail_exp"
1152 # Turn $1 into a string suitable for a shell variable name.
1153 # Result is stored in $func_tr_sh_result. All characters
1154 # not in the set a-zA-Z0-9_ are replaced with '_'. Further,
1155 # if $1 begins with a digit, a '_' is prepended as well.
1161 [0-9]* | *[!a-zA-Z0-9_]*)
1162 func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
1165 func_tr_sh_result=$1
1171 # func_verbose ARG...
1172 # -------------------
1173 # Echo program name prefixed message in verbose mode only.
1178 $opt_verbose && func_echo "$*"
1184 # func_warn_and_continue ARG...
1185 # -----------------------------
1186 # Echo program name prefixed warning message to standard error.
1187 func_warn_and_continue ()
1191 $require_term_colors
1193 func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
1197 # func_warning CATEGORY ARG...
1198 # ----------------------------
1199 # Echo program name prefixed warning message to standard error. Warning
1200 # messages can be filtered according to CATEGORY, where this function
1201 # elides messages where CATEGORY is not listed in the global variable
1202 # 'opt_warning_types'.
1207 # CATEGORY must be in the warning_categories list!
1208 case " $warning_categories " in
1210 *) func_internal_error "invalid warning category '$1'" ;;
1216 case " $opt_warning_types " in
1217 *" $_G_category "*) $warning_func ${1+"$@"} ;;
1222 # func_sort_ver VER1 VER2
1223 # -----------------------
1224 # 'sort -V' is not generally available.
1225 # Note this deviates from the version comparison in automake
1226 # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
1227 # but this should suffice as we won't be specifying old
1228 # version formats or redundant trailing .0 in bootstrap.conf.
1229 # If we did want full compatibility then we should probably
1230 # use m4_version_compare from autoconf.
1238 # Split on '.' and compare each component.
1241 p1=`echo "$ver1" |cut -d. -f$i`
1242 p2=`echo "$ver2" |cut -d. -f$i`
1243 if test ! "$p1"; then
1246 elif test ! "$p2"; then
1249 elif test ! "$p1" = "$p2"; then
1250 if test "$p1" -gt "$p2" 2>/dev/null; then # numeric comparison
1252 elif test "$p2" -gt "$p1" 2>/dev/null; then # numeric comparison
1254 else # numeric, then lexicographic comparison
1255 lp=`printf "$p1\n$p2\n" |sort -n |tail -n1`
1256 if test "$lp" = "$p2"; then
1270 # mode: shell-script
1272 # eval: (add-hook 'write-file-hooks 'time-stamp)
1273 # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
1274 # time-stamp-time-zone: "UTC"
1278 # Set a version string for this script.
1279 scriptversion=2012-10-21.11; # UTC
1281 # A portable, pluggable option parser for Bourne shell.
1282 # Written by Gary V. Vaughan, 2010
1284 # Copyright (C) 2010-2013 Free Software Foundation, Inc.
1285 # This is free software; see the source for copying conditions. There is NO
1286 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1288 # This program is free software: you can redistribute it and/or modify
1289 # it under the terms of the GNU General Public License as published by
1290 # the Free Software Foundation, either version 3 of the License, or
1291 # (at your option) any later version.
1293 # This program is distributed in the hope that it will be useful,
1294 # but WITHOUT ANY WARRANTY; without even the implied warranty of
1295 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1296 # GNU General Public License for more details.
1298 # You should have received a copy of the GNU General Public License
1299 # along with this program. If not, see <http://www.gnu.org/licenses/>.
1301 # Please report bugs or propose patches to gary@gnu.org.
1308 # This file is a library for parsing options in your shell scripts along
1309 # with assorted other useful supporting features that you can make use
1312 # For the simplest scripts you might need only:
1315 # . relative/path/to/funclib.sh
1316 # . relative/path/to/options-parser
1318 # func_options ${1+"$@"}
1319 # eval set dummy "$func_options_result"; shift
1320 # ...rest of your script...
1322 # In order for the '--version' option to work, you will need to have a
1323 # suitably formatted comment like the one at the top of this file
1324 # starting with '# Written by ' and ending with '# warranty; '.
1326 # For '-h' and '--help' to work, you will also need a one line
1327 # description of your script's purpose in a comment directly above the
1328 # '# Written by ' line, like the one at the top of this file.
1330 # The default options also support '--debug', which will turn on shell
1331 # execution tracing (see the comment above debug_cmd below for another
1332 # use), and '--verbose' and the func_verbose function to allow your script
1333 # to display verbose messages only when your user has specified
1336 # After sourcing this file, you can plug processing for additional
1337 # options by amending the variables from the 'Configuration' section
1338 # below, and following the instructions in the 'Option parsing'
1339 # section further down.
1341 ## -------------- ##
1342 ## Configuration. ##
1343 ## -------------- ##
1345 # You should override these variables in your script after sourcing this
1346 # file so that they reflect the customisations you have added to the
1349 # The usage line for option parsing errors and the start of '-h' and
1350 # '--help' output messages. You can embed shell variables for delayed
1351 # expansion at the time the message is displayed, but you will need to
1352 # quote other shell meta-characters carefully to prevent them being
1353 # expanded when the contents are evaled.
1354 usage='$progpath [OPTION]...'
1356 # Short help message in response to '-h' and '--help'. Add to this or
1357 # override it after sourcing this library to reflect the full set of
1358 # options your script accepts.
1360 --debug enable verbose shell tracing
1361 -W, --warnings=CATEGORY
1362 report the warnings falling in CATEGORY [all]
1363 -v, --verbose verbosely report processing
1364 --version print version information and exit
1365 -h, --help print short or long help message and exit
1368 # Additional text appended to 'usage_message' in response to '--help'.
1370 Warning categories include:
1371 'all' show all warnings
1372 'none' turn off all the warnings
1373 'error' warnings are treated as fatal errors"
1375 # Help message printed before fatal option parsing errors.
1376 fatal_help="Try '\$progname --help' for more information."
1380 ## ------------------------- ##
1381 ## Hook function management. ##
1382 ## ------------------------- ##
1384 # This section contains functions for adding, removing, and running hooks
1385 # to the main code. A hook is just a named list of of function, that can
1386 # be run in order later on.
1388 # func_hookable FUNC_NAME
1389 # -----------------------
1390 # Declare that FUNC_NAME will run hooks added with
1391 # 'func_add_hook FUNC_NAME ...'.
1396 func_append hookable_fns " $1"
1400 # func_add_hook FUNC_NAME HOOK_FUNC
1401 # ---------------------------------
1402 # Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must
1403 # first have been declared "hookable" by a call to 'func_hookable'.
1408 case " $hookable_fns " in
1410 *) func_fatal_error "'$1' does not accept hook functions." ;;
1413 eval func_append ${1}_hooks '" $2"'
1417 # func_remove_hook FUNC_NAME HOOK_FUNC
1418 # ------------------------------------
1419 # Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
1424 eval ${1}_hooks='`$bs_echo "\$'$1'_hooks" |$SED "s| '$2'||"`'
1428 # func_run_hooks FUNC_NAME [ARG]...
1429 # ---------------------------------
1430 # Run all hook functions registered to FUNC_NAME.
1431 # It is assumed that the list of hook functions contains nothing more
1432 # than a whitespace-delimited list of legal shell function names, and
1433 # no effort is wasted trying to catch shell meta-characters or preserve
1439 case " $hookable_fns " in
1441 *) func_fatal_error "'$1' does not support hook funcions.n" ;;
1444 eval _G_hook_fns=\$$1_hooks; shift
1446 for _G_hook in $_G_hook_fns; do
1447 eval $_G_hook '"$@"'
1449 # store returned options list back into positional
1450 # parameters for next 'cmd' execution.
1451 eval _G_hook_result=\$${_G_hook}_result
1452 eval set dummy "$_G_hook_result"; shift
1455 func_quote_for_eval ${1+"$@"}
1456 func_run_hooks_result=$func_quote_for_eval_result
1461 ## --------------- ##
1462 ## Option parsing. ##
1463 ## --------------- ##
1465 # In order to add your own option parsing hooks, you must accept the
1466 # full positional parameter list in your hook function, remove any
1467 # options that you action, and then pass back the remaining unprocessed
1468 # options in '<hooked_function_name>_result', escaped suitably for
1469 # 'eval'. Like this:
1471 # my_options_prep ()
1475 # # Extend the existing usage message.
1476 # usage_message=$usage_message'
1477 # -s, --silent don'\''t print informational messages
1480 # func_quote_for_eval ${1+"$@"}
1481 # my_options_prep_result=$func_quote_for_eval_result
1483 # func_add_hook func_options_prep my_options_prep
1486 # my_silent_option ()
1490 # # Note that for efficiency, we parse as many options as we can
1491 # # recognise in a loop before passing the remainder back to the
1492 # # caller on the first unrecognised argument we encounter.
1493 # while test $# -gt 0; do
1496 # --silent|-s) opt_silent=: ;;
1497 # # Separate non-argument short options:
1498 # -s*) func_split_short_opt "$_G_opt"
1499 # set dummy "$func_split_short_opt_name" \
1500 # "-$func_split_short_opt_arg" ${1+"$@"}
1503 # *) set dummy "$_G_opt" "$*"; shift; break ;;
1507 # func_quote_for_eval ${1+"$@"}
1508 # my_silent_option_result=$func_quote_for_eval_result
1510 # func_add_hook func_parse_options my_silent_option
1513 # my_option_validation ()
1517 # $opt_silent && $opt_verbose && func_fatal_help "\
1518 # '--silent' and '--verbose' options are mutually exclusive."
1520 # func_quote_for_eval ${1+"$@"}
1521 # my_option_validation_result=$func_quote_for_eval_result
1523 # func_add_hook func_validate_options my_option_validation
1525 # You'll alse need to manually amend $usage_message to reflect the extra
1526 # options you parse. It's preferable to append if you can, so that
1527 # multiple option parsing hooks can be added safely.
1530 # func_options [ARG]...
1531 # ---------------------
1532 # All the functions called inside func_options are hookable. See the
1533 # individual implementations for details.
1534 func_hookable func_options
1539 func_options_prep ${1+"$@"}
1540 eval func_parse_options \
1541 ${func_options_prep_result+"$func_options_prep_result"}
1542 eval func_validate_options \
1543 ${func_parse_options_result+"$func_parse_options_result"}
1545 eval func_run_hooks func_options \
1546 ${func_validate_options_result+"$func_validate_options_result"}
1548 # save modified positional parameters for caller
1549 func_options_result=$func_run_hooks_result
1553 # func_options_prep [ARG]...
1554 # --------------------------
1555 # All initialisations required before starting the option parse loop.
1556 # Note that when calling hook functions, we pass through the list of
1557 # positional parameters. If a hook function modifies that list, and
1558 # needs to propogate that back to rest of this script, then the complete
1559 # modified list must be put in 'func_run_hooks_result' before
1561 func_hookable func_options_prep
1562 func_options_prep ()
1570 func_run_hooks func_options_prep ${1+"$@"}
1572 # save modified positional parameters for caller
1573 func_options_prep_result=$func_run_hooks_result
1577 # func_parse_options [ARG]...
1578 # ---------------------------
1579 # The main option parsing loop.
1580 func_hookable func_parse_options
1581 func_parse_options ()
1585 func_parse_options_result=
1587 # this just eases exit handling
1588 while test $# -gt 0; do
1589 # Defer to hook functions for initial option parsing, so they
1590 # get priority in the event of reusing an option name.
1591 func_run_hooks func_parse_options ${1+"$@"}
1593 # Adjust func_parse_options positional parameters to match
1594 eval set dummy "$func_run_hooks_result"; shift
1596 # Break out of the loop if we already parsed every option.
1597 test $# -gt 0 || break
1602 --debug|-x) debug_cmd='set -x'
1603 func_echo "enabling shell trace mode"
1607 --no-warnings|--no-warning|--no-warn)
1608 set dummy --warnings none ${1+"$@"}
1612 --warnings|--warning|-W)
1613 test $# = 0 && func_missing_arg $_G_opt && break
1614 case " $warning_categories $1" in
1616 # trailing space prevents matching last $1 above
1617 func_append_uniq opt_warning_types " $1"
1620 opt_warning_types=$warning_categories
1623 opt_warning_types=none
1627 opt_warning_types=$warning_categories
1628 warning_func=func_fatal_error
1632 "unsupported warning category: '$1'"
1638 --verbose|-v) opt_verbose=: ;;
1639 --version) func_version ;;
1640 -\?|-h) func_usage ;;
1641 --help) func_help ;;
1643 # Separate optargs to long options (plugins may need this):
1644 --*=*) func_split_equals "$_G_opt"
1645 set dummy "$func_split_equals_lhs" \
1646 "$func_split_equals_rhs" ${1+"$@"}
1650 # Separate optargs to short options:
1652 func_split_short_opt "$_G_opt"
1653 set dummy "$func_split_short_opt_name" \
1654 "$func_split_short_opt_arg" ${1+"$@"}
1658 # Separate non-argument short options:
1660 func_split_short_opt "$_G_opt"
1661 set dummy "$func_split_short_opt_name" \
1662 "-$func_split_short_opt_arg" ${1+"$@"}
1667 -*) func_fatal_help "unrecognised option: '$_G_opt'" ;;
1668 *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
1672 # save modified positional parameters for caller
1673 func_quote_for_eval ${1+"$@"}
1674 func_parse_options_result=$func_quote_for_eval_result
1678 # func_validate_options [ARG]...
1679 # ------------------------------
1680 # Perform any sanity checks on option settings and/or unconsumed
1682 func_hookable func_validate_options
1683 func_validate_options ()
1687 # Display all warnings if -W was not given.
1688 test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
1690 func_run_hooks func_validate_options ${1+"$@"}
1692 # Bail if the options were screwed!
1693 $exit_cmd $EXIT_FAILURE
1695 # save modified positional parameters for caller
1696 func_validate_options_result=$func_run_hooks_result
1701 ## ------------------##
1702 ## Helper functions. ##
1703 ## ------------------##
1705 # This section contains the helper functions used by the rest of the
1706 # hookable option parser framework in ascii-betical order.
1709 # func_fatal_help ARG...
1710 # ----------------------
1711 # Echo program name prefixed message to standard error, followed by
1712 # a help hint, and exit.
1717 eval \$bs_echo \""Usage: $usage"\"
1718 eval \$bs_echo \""$fatal_help"\"
1719 func_error ${1+"$@"}
1726 # Echo long help message to standard output and exit.
1732 $bs_echo "$long_help_message"
1737 # func_missing_arg ARGNAME
1738 # ------------------------
1739 # Echo program name prefixed message to standard error and set global
1745 func_error "Missing argument for '$1'."
1750 # func_split_equals STRING
1751 # ------------------------
1752 # Set func_split_equals_lhs and func_split_equals_rhs shell variables after
1753 # splitting STRING at the '=' sign.
1754 test -z "$_G_HAVE_XSI_OPS" \
1756 test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
1757 && _G_HAVE_XSI_OPS=yes
1759 if test yes = "$_G_HAVE_XSI_OPS"
1761 # This is an XSI compatible shell, allowing a faster implementation...
1762 eval 'func_split_equals ()
1766 func_split_equals_lhs=${1%%=*}
1767 func_split_equals_rhs=${1#*=}
1768 test "x$func_split_equals_lhs" = "x$1" \
1769 && func_split_equals_rhs=
1772 # ...otherwise fall back to using expr, which is often a shell builtin.
1773 func_split_equals ()
1777 func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
1778 func_split_equals_rhs=
1779 test "x$func_split_equals_lhs" = "x$1" \
1780 || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
1782 fi #func_split_equals
1785 # func_split_short_opt SHORTOPT
1786 # -----------------------------
1787 # Set func_split_short_opt_name and func_split_short_opt_arg shell
1788 # variables after splitting SHORTOPT after the 2nd character.
1789 if test yes = "$_G_HAVE_XSI_OPS"
1791 # This is an XSI compatible shell, allowing a faster implementation...
1792 eval 'func_split_short_opt ()
1796 func_split_short_opt_arg=${1#??}
1797 func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
1800 # ...otherwise fall back to using expr, which is often a shell builtin.
1801 func_split_short_opt ()
1805 func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
1806 func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
1808 fi #func_split_short_opt
1813 # Echo short help message to standard output and exit.
1819 $bs_echo "Run '$progname --help |${PAGER-more}' for full usage"
1824 # func_usage_message
1825 # ------------------
1826 # Echo short help message to standard output.
1827 func_usage_message ()
1831 eval \$bs_echo \""Usage: $usage"\"
1838 /^Written by/q' < "$progpath"
1840 eval \$bs_echo \""$usage_message"\"
1846 # Echo version message to standard output and exit.
1851 printf '%s\n' "$progname $scriptversion"
1861 /^# Written by /,/# warranty; / {
1864 s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
1871 /^warranty; /q' < "$progpath"
1878 # mode: shell-script
1880 # eval: (add-hook 'write-file-hooks 'time-stamp)
1881 # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
1882 # time-stamp-time-zone: "UTC"
1885 # Set a version string.
1886 scriptversion='(GNU libtool) 2.4.2.418'
1891 # Libtool also displays the current mode in messages, so override
1892 # funclib.sh func_echo with this custom definition.
1901 for _G_line in $_G_message; do
1903 $bs_echo "$progname${opt_mode+: $opt_mode}: $_G_line"
1909 # func_warning ARG...
1910 # -------------------
1911 # Libtool warnings are not categorized, so override funclib.sh
1912 # func_warning with this simpler definition.
1917 $warning_func ${1+"$@"}
1921 ## ---------------- ##
1922 ## Options parsing. ##
1923 ## ---------------- ##
1925 # Hook in the functions to make sure our own options are parsed during
1926 # the option parsing loop.
1928 usage='$progpath [OPTION]... [MODE-ARG]...'
1930 # Short help message in response to '-h'.
1931 usage_message="Options:
1932 --config show all configuration variables
1933 --debug enable verbose shell tracing
1934 -n, --dry-run display commands without modifying any files
1935 --features display basic configuration information and exit
1936 --mode=MODE use operation mode MODE
1937 --no-warnings equivalent to '-Wnone'
1938 --preserve-dup-deps don't remove duplicate dependency libraries
1939 --quiet, --silent don't print informational messages
1940 --tag=TAG use configuration variables from tag TAG
1941 -v, --verbose print more informational messages than default
1942 --version print version information
1943 -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all]
1944 -h, --help, --help-all print short, long, or detailed help message
1947 # Additional text appended to 'usage_message' in response to '--help'.
1948 long_help_message=$long_help_message"
1950 MODE must be one of the following:
1952 clean remove files from the build directory
1953 compile compile a source file into a libtool object
1954 execute automatically set library path, then run a program
1955 finish complete the installation of libtool libraries
1956 install install libraries or executables
1957 link create a library or an executable
1958 uninstall remove libraries from an installed directory
1960 MODE-ARGS vary depending on the MODE. When passed as first option,
1961 '--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
1962 Try '$progname --help --mode=MODE' for a more detailed description of MODE.
1964 When reporting a bug, please describe a test case to reproduce it and
1965 include the following information:
1970 compiler flags: $LTCFLAGS
1971 linker: $LD (gnu? $with_gnu_ld)
1972 version: $progname (GNU libtool) 2.4.2.418
1973 automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
1974 autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q`
1976 Report bugs to <bug-libtool@gnu.org>.
1977 GNU libtool home page: <http://www.gnu.org/software/libtool/>.
1978 General help using GNU software: <http://www.gnu.org/gethelp/>."
1981 # func_lo2o OBJECT-NAME
1982 # ---------------------
1983 # Transform OBJECT-NAME from a '.lo' suffix to the platform specific
1986 lo2o=s/\\.lo\$/.$objext/
1987 o2lo=s/\\.$objext\$/.lo/
1989 if test yes = "$_G_HAVE_XSI_OPS"; then
1993 *.lo) func_lo2o_result=${1%.lo}.$objext ;;
1994 * ) func_lo2o_result=$1 ;;
1998 # func_xform LIBOBJ-OR-SOURCE
1999 # ---------------------------
2000 # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
2001 # suffix to a '.lo' libtool-object suffix.
2004 func_xform_result=${1%.*}.lo
2007 # ...otherwise fall back to using sed.
2010 func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
2015 func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
2020 # func_fatal_configuration ARG...
2021 # -------------------------------
2022 # Echo program name prefixed message to standard error, followed by
2023 # a configuration failure hint, and exit.
2024 func_fatal_configuration ()
2026 func__fatal_error ${1+"$@"} \
2027 "See the $PACKAGE documentation for more information." \
2028 "Fatal configuration error."
2034 # Display the configuration for all the tags in this script.
2037 re_begincf='^# ### BEGIN LIBTOOL'
2038 re_endcf='^# ### END LIBTOOL'
2040 # Default configuration.
2041 $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
2043 # Now print the configurations for the tags.
2044 for tagname in $taglist; do
2045 $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
2054 # Display the features supported by this script.
2058 if test yes = "$build_libtool_libs"; then
2059 echo "enable shared libraries"
2061 echo "disable shared libraries"
2063 if test yes = "$build_old_libs"; then
2064 echo "enable static libraries"
2066 echo "disable static libraries"
2073 # func_enable_tag TAGNAME
2074 # -----------------------
2075 # Verify that TAGNAME is valid, and either flag an error and exit, or
2076 # enable the TAGNAME tag. We also add TAGNAME to the global $taglist
2083 re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
2084 re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
2085 sed_extractcf=/$re_begincf/,/$re_endcf/p
2090 func_fatal_error "invalid tag name: $tagname"
2094 # Don't test for the "default" C tag, as we know it's
2095 # there but not specially marked.
2099 if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
2100 taglist="$taglist $tagname"
2102 # Evaluate the configuration. Be careful to quote the path
2103 # and the sed script, to avoid splitting on whitespace, but
2104 # also don't use non-portable quotes within backquotes within
2105 # quotes we have to do it in 2 steps:
2106 extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
2109 func_error "ignoring unknown tag $tagname"
2116 # func_check_version_match
2117 # ------------------------
2118 # Ensure that we are using m4 macros, and libtool script from the same
2119 # release of libtool.
2120 func_check_version_match ()
2122 if test "$package_revision" != "$macro_revision"; then
2123 if test "$VERSION" != "$macro_version"; then
2124 if test -z "$macro_version"; then
2126 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
2127 $progname: definition of this LT_INIT comes from an older release.
2128 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2129 $progname: and run autoconf again.
2133 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
2134 $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
2135 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
2136 $progname: and run autoconf again.
2141 $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
2142 $progname: but the definition of this LT_INIT comes from revision $macro_revision.
2143 $progname: You should recreate aclocal.m4 with macros from revision $package_revision
2144 $progname: of $PACKAGE $VERSION and run autoconf again.
2153 # libtool_options_prep [ARG]...
2154 # -----------------------------
2155 # Preparation for options parsed by libtool.
2156 libtool_options_prep ()
2166 opt_preserve_dup_deps=false
2172 # Shorthand for --mode=foo, only valid as the first argument
2175 shift; set dummy --mode clean ${1+"$@"}; shift
2177 compile|compil|compi|comp|com|co|c)
2178 shift; set dummy --mode compile ${1+"$@"}; shift
2180 execute|execut|execu|exec|exe|ex|e)
2181 shift; set dummy --mode execute ${1+"$@"}; shift
2183 finish|finis|fini|fin|fi|f)
2184 shift; set dummy --mode finish ${1+"$@"}; shift
2186 install|instal|insta|inst|ins|in|i)
2187 shift; set dummy --mode install ${1+"$@"}; shift
2190 shift; set dummy --mode link ${1+"$@"}; shift
2192 uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
2193 shift; set dummy --mode uninstall ${1+"$@"}; shift
2197 # Pass back the list of options.
2198 func_quote_for_eval ${1+"$@"}
2199 libtool_options_prep_result=$func_quote_for_eval_result
2201 func_add_hook func_options_prep libtool_options_prep
2204 # libtool_parse_options [ARG]...
2205 # ---------------------------------
2206 # Provide handling for libtool specific options.
2207 libtool_parse_options ()
2211 # Perform our own loop to consume as many options as possible in
2213 while test $# -gt 0; do
2217 --dry-run|--dryrun|-n)
2221 --config) func_config ;;
2224 opt_dlopen="${opt_dlopen+$opt_dlopen
2229 --preserve-dup-deps)
2230 opt_preserve_dup_deps=: ;;
2232 --features) func_features ;;
2234 --finish) set dummy --mode finish ${1+"$@"}; shift ;;
2236 --help) opt_help=: ;;
2238 --help-all) opt_help=': help-all' ;;
2240 --mode) test $# = 0 && func_missing_arg $_G_opt && break
2243 # Valid mode arguments:
2244 clean|compile|execute|finish|install|link|relink|uninstall) ;;
2246 # Catch anything else as an error
2247 *) func_error "invalid argument for $_G_opt"
2255 --no-silent|--no-quiet)
2257 func_append preserve_args " $_G_opt"
2260 --no-warnings|--no-warning|--no-warn)
2262 func_append preserve_args " $_G_opt"
2267 func_append preserve_args " $_G_opt"
2273 func_append preserve_args " $_G_opt"
2276 --tag) test $# = 0 && func_missing_arg $_G_opt && break
2278 func_append preserve_args " $_G_opt $1"
2279 func_enable_tag "$1"
2283 --verbose|-v) opt_quiet=false
2285 func_append preserve_args " $_G_opt"
2288 # An option not handled by this hook function:
2289 *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
2294 # save modified positional parameters for caller
2295 func_quote_for_eval ${1+"$@"}
2296 libtool_parse_options_result=$func_quote_for_eval_result
2298 func_add_hook func_parse_options libtool_parse_options
2302 # libtool_validate_options [ARG]...
2303 # ---------------------------------
2304 # Perform any sanity checks on option settings and/or unconsumed
2306 libtool_validate_options ()
2308 # save first non-option argument
2309 if test 0 -lt $#; then
2315 test : = "$debug_cmd" || func_append preserve_args " --debug"
2318 *cygwin* | *mingw* | *pw32* | *cegcc*)
2319 # don't eliminate duplications in $postdeps and $predeps
2320 opt_duplicate_compiler_generated_deps=:
2323 opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
2328 # Sanity checks first:
2329 func_check_version_match
2331 test yes != "$build_libtool_libs" \
2332 && test yes != "$build_old_libs" \
2333 && func_fatal_configuration "not configured to build any kind of library"
2336 eval std_shrext=\"$shrext_cmds\"
2338 # Only execute mode is allowed to have -dlopen flags.
2339 if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
2340 func_error "unrecognized option '-dlopen'"
2345 # Change the help message to a mode-specific one.
2347 help="Try '$progname --help --mode=$opt_mode' for more information."
2350 # Pass back the unparsed argument list
2351 func_quote_for_eval ${1+"$@"}
2352 libtool_validate_options_result=$func_quote_for_eval_result
2354 func_add_hook func_validate_options libtool_validate_options
2357 # Process options as early as possible so that --help and --version
2358 # can return quickly.
2359 func_options ${1+"$@"}
2360 eval set dummy "$func_options_result"; shift
2368 magic='%%%MAGIC variable%%%'
2369 magic_exe='%%%MAGIC EXE variable%%%'
2375 # If this variable is set in any of the actions, the command in it
2376 # will be execed at the end. This prevents here-documents from being
2377 # left over by shells.
2381 # A function that is used when there is no print builtin or printf.
2382 func_fallback_echo ()
2384 eval 'cat <<_LTECHO_EOF
2390 # True iff FILE is a libtool '.la' library or '.lo' object file.
2391 # This function is only a basic sanity check; it will hardly flush out
2392 # determined imposters.
2396 $SED -e 4q "$1" 2>/dev/null \
2397 | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
2400 # func_lalib_unsafe_p file
2401 # True iff FILE is a libtool '.la' library or '.lo' object file.
2402 # This function implements the same check as func_lalib_p without
2403 # resorting to external programs. To this end, it redirects stdin and
2404 # closes it afterwards, without saving the original file descriptor.
2405 # As a safety measure, use it only where a negative result would be
2406 # fatal anyway. Works if 'file' does not exist.
2407 func_lalib_unsafe_p ()
2410 if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
2411 for lalib_p_l in 1 2 3 4
2414 case $lalib_p_line in
2415 \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
2420 test yes = "$lalib_p"
2423 # func_ltwrapper_script_p file
2424 # True iff FILE is a libtool wrapper script
2425 # This function is only a basic sanity check; it will hardly flush out
2426 # determined imposters.
2427 func_ltwrapper_script_p ()
2432 # func_ltwrapper_executable_p file
2433 # True iff FILE is a libtool wrapper executable
2434 # This function is only a basic sanity check; it will hardly flush out
2435 # determined imposters.
2436 func_ltwrapper_executable_p ()
2438 func_ltwrapper_exec_suffix=
2441 *) func_ltwrapper_exec_suffix=.exe ;;
2443 $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
2446 # func_ltwrapper_scriptname file
2447 # Assumes file is an ltwrapper_executable
2448 # uses $file to determine the appropriate filename for a
2449 # temporary ltwrapper_script.
2450 func_ltwrapper_scriptname ()
2452 func_dirname_and_basename "$1" "" "."
2453 func_stripname '' '.exe' "$func_basename_result"
2454 func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
2457 # func_ltwrapper_p file
2458 # True iff FILE is a libtool wrapper script or wrapper executable
2459 # This function is only a basic sanity check; it will hardly flush out
2460 # determined imposters.
2463 func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
2467 # func_execute_cmds commands fail_cmd
2468 # Execute tilde-delimited COMMANDS.
2469 # If FAIL_CMD is given, eval that upon failure.
2470 # FAIL_CMD may read-access the current command in variable CMD!
2471 func_execute_cmds ()
2475 save_ifs=$IFS; IFS='~'
2480 func_show_eval "$cmd" "${2-:}"
2487 # Source FILE, adding directory component if necessary.
2488 # Note that it is not necessary on cygwin/mingw to append a dot to
2489 # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
2490 # behavior happens only for exec(3), not for open(2)! Also, sourcing
2491 # 'FILE.' does not work on cygwin managed mounts.
2497 */* | *\\*) . "$1" ;;
2503 # func_resolve_sysroot PATH
2504 # Replace a leading = in PATH with a sysroot. Store the result into
2505 # func_resolve_sysroot_result
2506 func_resolve_sysroot ()
2508 func_resolve_sysroot_result=$1
2509 case $func_resolve_sysroot_result in
2511 func_stripname '=' '' "$func_resolve_sysroot_result"
2512 func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
2517 # func_replace_sysroot PATH
2518 # If PATH begins with the sysroot, replace it with = and
2519 # store the result into func_replace_sysroot_result.
2520 func_replace_sysroot ()
2522 case $lt_sysroot:$1 in
2524 func_stripname "$lt_sysroot" '' "$1"
2525 func_replace_sysroot_result='='$func_stripname_result
2528 # Including no sysroot.
2529 func_replace_sysroot_result=$1
2534 # func_infer_tag arg
2535 # Infer tagged configuration to use if any are available and
2536 # if one wasn't chosen via the "--tag" command line option.
2537 # Only attempt this if the compiler in the base compile
2538 # command doesn't match the default compiler.
2539 # arg is usually of the form 'gcc ...'
2544 if test -n "$available_tags" && test -z "$tagname"; then
2547 func_append_quoted CC_quoted "$arg"
2549 CC_expanded=`func_echo_all $CC`
2550 CC_quoted_expanded=`func_echo_all $CC_quoted`
2552 # Blanks in the command may have been stripped by the calling shell,
2553 # but not from the CC environment variable when configure was run.
2554 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2555 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
2556 # Blanks at the start of $base_compile will cause this to fail
2557 # if we don't check for them as well.
2559 for z in $available_tags; do
2560 if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
2561 # Evaluate the configuration.
2562 eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
2565 # Double-quote args containing other shell metacharacters.
2566 func_append_quoted CC_quoted "$arg"
2568 CC_expanded=`func_echo_all $CC`
2569 CC_quoted_expanded=`func_echo_all $CC_quoted`
2571 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
2572 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
2573 # The compiler in the base compile command matches
2574 # the one in the tagged configuration.
2575 # Assume this is the tagged configuration we want.
2582 # If $tagname still isn't set, then no tagged configuration
2583 # was found and let the user know that the "--tag" command
2584 # line option must be used.
2585 if test -z "$tagname"; then
2586 func_echo "unable to infer tagged configuration"
2587 func_fatal_error "specify a tag with '--tag'"
2589 # func_verbose "using $tagname tagged configuration"
2598 # func_write_libtool_object output_name pic_name nonpic_name
2599 # Create a libtool object file (analogous to a ".la" file),
2600 # but don't create it if we're doing a dry run.
2601 func_write_libtool_object ()
2604 if test yes = "$build_libtool_libs"; then
2610 if test yes = "$build_old_libs"; then
2617 cat >${write_libobj}T <<EOF
2618 # $write_libobj - a libtool object file
2619 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
2621 # Please DO NOT delete this file!
2622 # It is necessary for linking the library.
2624 # Name of the PIC object.
2625 pic_object=$write_lobj
2627 # Name of the non-PIC object
2628 non_pic_object=$write_oldobj
2631 $MV "${write_libobj}T" "$write_libobj"
2636 ##################################################
2637 # FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
2638 ##################################################
2640 # func_convert_core_file_wine_to_w32 ARG
2641 # Helper function used by file name conversion functions when $build is *nix,
2642 # and $host is mingw, cygwin, or some other w32 environment. Relies on a
2643 # correctly configured wine environment available, with the winepath program
2644 # in $build's $PATH.
2646 # ARG is the $build file name to be converted to w32 format.
2647 # Result is available in $func_convert_core_file_wine_to_w32_result, and will
2648 # be empty on error (or when ARG is empty)
2649 func_convert_core_file_wine_to_w32 ()
2653 func_convert_core_file_wine_to_w32_result=$1
2654 if test -n "$1"; then
2655 # Unfortunately, winepath does not exit with a non-zero error code, so we
2656 # are forced to check the contents of stdout. On the other hand, if the
2657 # command is not found, the shell will set an exit code of 127 and print
2658 # *an error message* to stdout. So we must check for both error code of
2659 # zero AND non-empty stdout, which explains the odd construction:
2660 func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
2661 if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
2662 func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
2663 $SED -e "$sed_naive_backslashify"`
2665 func_convert_core_file_wine_to_w32_result=
2669 # end: func_convert_core_file_wine_to_w32
2672 # func_convert_core_path_wine_to_w32 ARG
2673 # Helper function used by path conversion functions when $build is *nix, and
2674 # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
2675 # configured wine environment available, with the winepath program in $build's
2676 # $PATH. Assumes ARG has no leading or trailing path separator characters.
2678 # ARG is path to be converted from $build format to win32.
2679 # Result is available in $func_convert_core_path_wine_to_w32_result.
2680 # Unconvertible file (directory) names in ARG are skipped; if no directory names
2681 # are convertible, then the result may be empty.
2682 func_convert_core_path_wine_to_w32 ()
2686 # unfortunately, winepath doesn't convert paths, only file names
2687 func_convert_core_path_wine_to_w32_result=
2688 if test -n "$1"; then
2691 for func_convert_core_path_wine_to_w32_f in $1; do
2693 func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
2694 if test -n "$func_convert_core_file_wine_to_w32_result"; then
2695 if test -z "$func_convert_core_path_wine_to_w32_result"; then
2696 func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
2698 func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
2705 # end: func_convert_core_path_wine_to_w32
2708 # func_cygpath ARGS...
2709 # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
2710 # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
2711 # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
2712 # (2), returns the Cygwin file name or path in func_cygpath_result (input
2713 # file name or path is assumed to be in w32 format, as previously converted
2714 # from $build's *nix or MSYS format). In case (3), returns the w32 file name
2715 # or path in func_cygpath_result (input file name or path is assumed to be in
2716 # Cygwin format). Returns an empty string on error.
2718 # ARGS are passed to cygpath, with the last one being the file name or path to
2721 # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
2722 # environment variable; do not put it in $PATH.
2727 if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
2728 func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
2729 if test "$?" -ne 0; then
2730 # on failure, ensure result is empty
2731 func_cygpath_result=
2734 func_cygpath_result=
2735 func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
2741 # func_convert_core_msys_to_w32 ARG
2742 # Convert file name or path ARG from MSYS format to w32 format. Return
2743 # result in func_convert_core_msys_to_w32_result.
2744 func_convert_core_msys_to_w32 ()
2748 # awkward: cmd appends spaces to result
2749 func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
2750 $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
2752 #end: func_convert_core_msys_to_w32
2755 # func_convert_file_check ARG1 ARG2
2756 # Verify that ARG1 (a file name in $build format) was converted to $host
2757 # format in ARG2. Otherwise, emit an error message, but continue (resetting
2758 # func_to_host_file_result to ARG1).
2759 func_convert_file_check ()
2763 if test -z "$2" && test -n "$1"; then
2764 func_error "Could not determine host file name corresponding to"
2766 func_error "Continuing, but uninstalled executables may not work."
2768 func_to_host_file_result=$1
2771 # end func_convert_file_check
2774 # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
2775 # Verify that FROM_PATH (a path in $build format) was converted to $host
2776 # format in TO_PATH. Otherwise, emit an error message, but continue, resetting
2777 # func_to_host_file_result to a simplistic fallback value (see below).
2778 func_convert_path_check ()
2782 if test -z "$4" && test -n "$3"; then
2783 func_error "Could not determine the host path corresponding to"
2785 func_error "Continuing, but uninstalled executables may not work."
2786 # Fallback. This is a deliberately simplistic "conversion" and
2787 # should not be "improved". See libtool.info.
2788 if test "x$1" != "x$2"; then
2789 lt_replace_pathsep_chars="s|$1|$2|g"
2790 func_to_host_path_result=`echo "$3" |
2791 $SED -e "$lt_replace_pathsep_chars"`
2793 func_to_host_path_result=$3
2797 # end func_convert_path_check
2800 # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
2801 # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
2802 # and appending REPL if ORIG matches BACKPAT.
2803 func_convert_path_front_back_pathsep ()
2808 $1 ) func_to_host_path_result=$3$func_to_host_path_result
2812 $2 ) func_append func_to_host_path_result "$3"
2816 # end func_convert_path_front_back_pathsep
2819 ##################################################
2820 # $build to $host FILE NAME CONVERSION FUNCTIONS #
2821 ##################################################
2822 # invoked via '$to_host_file_cmd ARG'
2824 # In each case, ARG is the path to be converted from $build to $host format.
2825 # Result will be available in $func_to_host_file_result.
2828 # func_to_host_file ARG
2829 # Converts the file name ARG from $build format to $host format. Return result
2830 # in func_to_host_file_result.
2831 func_to_host_file ()
2835 $to_host_file_cmd "$1"
2837 # end func_to_host_file
2840 # func_to_tool_file ARG LAZY
2841 # converts the file name ARG from $build format to toolchain format. Return
2842 # result in func_to_tool_file_result. If the conversion in use is listed
2843 # in (the comma separated) LAZY, no conversion takes place.
2844 func_to_tool_file ()
2849 *,"$to_tool_file_cmd",*)
2850 func_to_tool_file_result=$1
2853 $to_tool_file_cmd "$1"
2854 func_to_tool_file_result=$func_to_host_file_result
2858 # end func_to_tool_file
2861 # func_convert_file_noop ARG
2862 # Copy ARG to func_to_host_file_result.
2863 func_convert_file_noop ()
2865 func_to_host_file_result=$1
2867 # end func_convert_file_noop
2870 # func_convert_file_msys_to_w32 ARG
2871 # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
2872 # conversion to w32 is not available inside the cwrapper. Returns result in
2873 # func_to_host_file_result.
2874 func_convert_file_msys_to_w32 ()
2878 func_to_host_file_result=$1
2879 if test -n "$1"; then
2880 func_convert_core_msys_to_w32 "$1"
2881 func_to_host_file_result=$func_convert_core_msys_to_w32_result
2883 func_convert_file_check "$1" "$func_to_host_file_result"
2885 # end func_convert_file_msys_to_w32
2888 # func_convert_file_cygwin_to_w32 ARG
2889 # Convert file name ARG from Cygwin to w32 format. Returns result in
2890 # func_to_host_file_result.
2891 func_convert_file_cygwin_to_w32 ()
2895 func_to_host_file_result=$1
2896 if test -n "$1"; then
2897 # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
2898 # LT_CYGPATH in this case.
2899 func_to_host_file_result=`cygpath -m "$1"`
2901 func_convert_file_check "$1" "$func_to_host_file_result"
2903 # end func_convert_file_cygwin_to_w32
2906 # func_convert_file_nix_to_w32 ARG
2907 # Convert file name ARG from *nix to w32 format. Requires a wine environment
2908 # and a working winepath. Returns result in func_to_host_file_result.
2909 func_convert_file_nix_to_w32 ()
2913 func_to_host_file_result=$1
2914 if test -n "$1"; then
2915 func_convert_core_file_wine_to_w32 "$1"
2916 func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
2918 func_convert_file_check "$1" "$func_to_host_file_result"
2920 # end func_convert_file_nix_to_w32
2923 # func_convert_file_msys_to_cygwin ARG
2924 # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
2925 # Returns result in func_to_host_file_result.
2926 func_convert_file_msys_to_cygwin ()
2930 func_to_host_file_result=$1
2931 if test -n "$1"; then
2932 func_convert_core_msys_to_w32 "$1"
2933 func_cygpath -u "$func_convert_core_msys_to_w32_result"
2934 func_to_host_file_result=$func_cygpath_result
2936 func_convert_file_check "$1" "$func_to_host_file_result"
2938 # end func_convert_file_msys_to_cygwin
2941 # func_convert_file_nix_to_cygwin ARG
2942 # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed
2943 # in a wine environment, working winepath, and LT_CYGPATH set. Returns result
2944 # in func_to_host_file_result.
2945 func_convert_file_nix_to_cygwin ()
2949 func_to_host_file_result=$1
2950 if test -n "$1"; then
2951 # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
2952 func_convert_core_file_wine_to_w32 "$1"
2953 func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
2954 func_to_host_file_result=$func_cygpath_result
2956 func_convert_file_check "$1" "$func_to_host_file_result"
2958 # end func_convert_file_nix_to_cygwin
2961 #############################################
2962 # $build to $host PATH CONVERSION FUNCTIONS #
2963 #############################################
2964 # invoked via '$to_host_path_cmd ARG'
2966 # In each case, ARG is the path to be converted from $build to $host format.
2967 # The result will be available in $func_to_host_path_result.
2969 # Path separators are also converted from $build format to $host format. If
2970 # ARG begins or ends with a path separator character, it is preserved (but
2971 # converted to $host format) on output.
2973 # All path conversion functions are named using the following convention:
2974 # file name conversion function : func_convert_file_X_to_Y ()
2975 # path conversion function : func_convert_path_X_to_Y ()
2976 # where, for any given $build/$host combination the 'X_to_Y' value is the
2977 # same. If conversion functions are added for new $build/$host combinations,
2978 # the two new functions must follow this pattern, or func_init_to_host_path_cmd
2982 # func_init_to_host_path_cmd
2983 # Ensures that function "pointer" variable $to_host_path_cmd is set to the
2984 # appropriate value, based on the value of $to_host_file_cmd.
2986 func_init_to_host_path_cmd ()
2990 if test -z "$to_host_path_cmd"; then
2991 func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
2992 to_host_path_cmd=func_convert_path_$func_stripname_result
2997 # func_to_host_path ARG
2998 # Converts the path ARG from $build format to $host format. Return result
2999 # in func_to_host_path_result.
3000 func_to_host_path ()
3004 func_init_to_host_path_cmd
3005 $to_host_path_cmd "$1"
3007 # end func_to_host_path
3010 # func_convert_path_noop ARG
3011 # Copy ARG to func_to_host_path_result.
3012 func_convert_path_noop ()
3014 func_to_host_path_result=$1
3016 # end func_convert_path_noop
3019 # func_convert_path_msys_to_w32 ARG
3020 # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
3021 # conversion to w32 is not available inside the cwrapper. Returns result in
3022 # func_to_host_path_result.
3023 func_convert_path_msys_to_w32 ()
3027 func_to_host_path_result=$1
3028 if test -n "$1"; then
3029 # Remove leading and trailing path separator characters from ARG. MSYS
3030 # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
3031 # and winepath ignores them completely.
3032 func_stripname : : "$1"
3033 func_to_host_path_tmp1=$func_stripname_result
3034 func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
3035 func_to_host_path_result=$func_convert_core_msys_to_w32_result
3036 func_convert_path_check : ";" \
3037 "$func_to_host_path_tmp1" "$func_to_host_path_result"
3038 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3041 # end func_convert_path_msys_to_w32
3044 # func_convert_path_cygwin_to_w32 ARG
3045 # Convert path ARG from Cygwin to w32 format. Returns result in
3046 # func_to_host_file_result.
3047 func_convert_path_cygwin_to_w32 ()
3051 func_to_host_path_result=$1
3052 if test -n "$1"; then
3053 # See func_convert_path_msys_to_w32:
3054 func_stripname : : "$1"
3055 func_to_host_path_tmp1=$func_stripname_result
3056 func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
3057 func_convert_path_check : ";" \
3058 "$func_to_host_path_tmp1" "$func_to_host_path_result"
3059 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3062 # end func_convert_path_cygwin_to_w32
3065 # func_convert_path_nix_to_w32 ARG
3066 # Convert path ARG from *nix to w32 format. Requires a wine environment and
3067 # a working winepath. Returns result in func_to_host_file_result.
3068 func_convert_path_nix_to_w32 ()
3072 func_to_host_path_result=$1
3073 if test -n "$1"; then
3074 # See func_convert_path_msys_to_w32:
3075 func_stripname : : "$1"
3076 func_to_host_path_tmp1=$func_stripname_result
3077 func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
3078 func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
3079 func_convert_path_check : ";" \
3080 "$func_to_host_path_tmp1" "$func_to_host_path_result"
3081 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
3084 # end func_convert_path_nix_to_w32
3087 # func_convert_path_msys_to_cygwin ARG
3088 # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
3089 # Returns result in func_to_host_file_result.
3090 func_convert_path_msys_to_cygwin ()
3094 func_to_host_path_result=$1
3095 if test -n "$1"; then
3096 # See func_convert_path_msys_to_w32:
3097 func_stripname : : "$1"
3098 func_to_host_path_tmp1=$func_stripname_result
3099 func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
3100 func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
3101 func_to_host_path_result=$func_cygpath_result
3102 func_convert_path_check : : \
3103 "$func_to_host_path_tmp1" "$func_to_host_path_result"
3104 func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3107 # end func_convert_path_msys_to_cygwin
3110 # func_convert_path_nix_to_cygwin ARG
3111 # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a
3112 # a wine environment, working winepath, and LT_CYGPATH set. Returns result in
3113 # func_to_host_file_result.
3114 func_convert_path_nix_to_cygwin ()
3118 func_to_host_path_result=$1
3119 if test -n "$1"; then
3120 # Remove leading and trailing path separator characters from
3121 # ARG. msys behavior is inconsistent here, cygpath turns them
3122 # into '.;' and ';.', and winepath ignores them completely.
3123 func_stripname : : "$1"
3124 func_to_host_path_tmp1=$func_stripname_result
3125 func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
3126 func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
3127 func_to_host_path_result=$func_cygpath_result
3128 func_convert_path_check : : \
3129 "$func_to_host_path_tmp1" "$func_to_host_path_result"
3130 func_convert_path_front_back_pathsep ":*" "*:" : "$1"
3133 # end func_convert_path_nix_to_cygwin
3136 # func_dll_def_p FILE
3137 # True iff FILE is a Windows DLL '.def' file.
3138 # Keep in sync with _LT_DLL_DEF_P in libtool.m4
3143 func_dll_def_p_tmp=`$SED -n \
3145 -e '/^\(;.*\)*$/d' \
3146 -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \
3149 test DEF = "$func_dll_def_p_tmp"
3153 # func_mode_compile arg...
3154 func_mode_compile ()
3158 # Get the compilation command and the source file.
3160 srcfile=$nonopt # always keep a non-empty value in "srcfile"
3172 # do not "continue". Instead, add this to base_compile
3184 # Accept any command-line options.
3187 test -n "$libobj" && \
3188 func_fatal_error "you cannot specify '-o' more than once"
3193 -pie | -fpie | -fPIE)
3194 func_append pie_flag " $arg"
3198 -shared | -static | -prefer-pic | -prefer-non-pic)
3199 func_append later " $arg"
3209 arg_mode=arg # the next one goes into the "base_compile" arg list
3210 continue # The current "srcfile" will either be retained or
3211 ;; # replaced later. I would guess that would be a bug.
3214 func_stripname '-Wc,' '' "$arg"
3215 args=$func_stripname_result
3217 save_ifs=$IFS; IFS=,
3218 for arg in $args; do
3220 func_append_quoted lastarg "$arg"
3223 func_stripname ' ' '' "$lastarg"
3224 lastarg=$func_stripname_result
3226 # Add the arguments to base_compile.
3227 func_append base_compile " $lastarg"
3232 # Accept the current argument as the source file.
3233 # The previous "srcfile" becomes the current argument.
3240 esac # case $arg_mode
3242 # Aesthetically quote the previous argument.
3243 func_append_quoted base_compile "$lastarg"
3248 func_fatal_error "you must specify an argument for -Xcompile"
3251 func_fatal_error "you must specify a target with '-o'"
3254 # Get the name of the library object.
3255 test -z "$libobj" && {
3256 func_basename "$srcfile"
3257 libobj=$func_basename_result
3262 # Recognize several different file suffixes.
3263 # If the user specifies -o file.o, it is replaced with file.lo
3266 *.ada | *.adb | *.ads | *.asm | \
3267 *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
3268 *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
3269 func_xform "$libobj"
3270 libobj=$func_xform_result
3275 *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
3277 func_fatal_error "cannot determine name of library object from '$libobj'"
3281 func_infer_tag $base_compile
3283 for arg in $later; do
3286 test yes = "$build_libtool_libs" \
3287 || func_fatal_configuration "cannot build a shared library"
3293 build_libtool_libs=no
3310 func_quote_for_eval "$libobj"
3311 test "X$libobj" != "X$func_quote_for_eval_result" \
3312 && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
3313 && func_warning "libobj name '$libobj' may not contain shell special characters."
3314 func_dirname_and_basename "$obj" "/" ""
3315 objname=$func_basename_result
3316 xdir=$func_dirname_result
3317 lobj=$xdir$objdir/$objname
3319 test -z "$base_compile" && \
3320 func_fatal_help "you must specify a compilation command"
3322 # Delete any leftover library objects.
3323 if test yes = "$build_old_libs"; then
3324 removelist="$obj $lobj $libobj ${libobj}T"
3326 removelist="$lobj $libobj ${libobj}T"
3329 # On Cygwin there's no "real" PIC flag so we must build both object types
3331 cygwin* | mingw* | pw32* | os2* | cegcc*)
3335 if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
3336 # non-PIC code in shared libraries is not supported
3340 # Calculate the filename of the output object if compiler does
3341 # not support -o with -c
3342 if test no = "$compiler_c_o"; then
3343 output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
3344 lockfile=$output_obj.lock
3351 # Lock this critical section if it is needed
3352 # We use this script file to make the link, it avoids creating a new file
3353 if test yes = "$need_locks"; then
3354 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
3355 func_echo "Waiting for $lockfile to be removed"
3358 elif test warn = "$need_locks"; then
3359 if test -f "$lockfile"; then
3361 *** ERROR, $lockfile exists and contains:
3362 `cat $lockfile 2>/dev/null`
3364 This indicates that another process is trying to use the same
3365 temporary object file, and libtool could not work around it because
3366 your compiler does not support '-c' and '-o' together. If you
3367 repeat this compilation, it may succeed, by chance, but you had better
3368 avoid parallel builds (make -j) in this platform, or get a better
3371 $opt_dry_run || $RM $removelist
3374 func_append removelist " $output_obj"
3375 $ECHO "$srcfile" > "$lockfile"
3378 $opt_dry_run || $RM $removelist
3379 func_append removelist " $lockfile"
3380 trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
3382 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
3383 srcfile=$func_to_tool_file_result
3384 func_quote_for_eval "$srcfile"
3385 qsrcfile=$func_quote_for_eval_result
3387 # Only build a PIC object if we are building libtool libraries.
3388 if test yes = "$build_libtool_libs"; then
3389 # Without this assignment, base_compile gets emptied.
3390 fbsd_hideous_sh_bug=$base_compile
3392 if test no != "$pic_mode"; then
3393 command="$base_compile $qsrcfile $pic_flag"
3395 # Don't build PIC code
3396 command="$base_compile $qsrcfile"
3399 func_mkdir_p "$xdir$objdir"
3401 if test -z "$output_obj"; then
3402 # Place PIC objects in $objdir
3403 func_append command " -o $lobj"
3406 func_show_eval_locale "$command" \
3407 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
3409 if test warn = "$need_locks" &&
3410 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
3412 *** ERROR, $lockfile contains:
3413 `cat $lockfile 2>/dev/null`
3415 but it should contain:
3418 This indicates that another process is trying to use the same
3419 temporary object file, and libtool could not work around it because
3420 your compiler does not support '-c' and '-o' together. If you
3421 repeat this compilation, it may succeed, by chance, but you had better
3422 avoid parallel builds (make -j) in this platform, or get a better
3425 $opt_dry_run || $RM $removelist
3429 # Just move the object if needed, then go on to compile the next one
3430 if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
3431 func_show_eval '$MV "$output_obj" "$lobj"' \
3432 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
3435 # Allow error messages only from the first compilation.
3436 if test yes = "$suppress_opt"; then
3437 suppress_output=' >/dev/null 2>&1'
3441 # Only build a position-dependent object if we build old libraries.
3442 if test yes = "$build_old_libs"; then
3443 if test yes != "$pic_mode"; then
3444 # Don't build PIC code
3445 command="$base_compile $qsrcfile$pie_flag"
3447 command="$base_compile $qsrcfile $pic_flag"
3449 if test yes = "$compiler_c_o"; then
3450 func_append command " -o $obj"
3453 # Suppress compiler output if we already did a PIC compilation.
3454 func_append command "$suppress_output"
3455 func_show_eval_locale "$command" \
3456 '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
3458 if test warn = "$need_locks" &&
3459 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
3461 *** ERROR, $lockfile contains:
3462 `cat $lockfile 2>/dev/null`
3464 but it should contain:
3467 This indicates that another process is trying to use the same
3468 temporary object file, and libtool could not work around it because
3469 your compiler does not support '-c' and '-o' together. If you
3470 repeat this compilation, it may succeed, by chance, but you had better
3471 avoid parallel builds (make -j) in this platform, or get a better
3474 $opt_dry_run || $RM $removelist
3478 # Just move the object if needed
3479 if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
3480 func_show_eval '$MV "$output_obj" "$obj"' \
3481 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
3486 func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
3488 # Unlock the critical section if it was locked
3489 if test no != "$need_locks"; then
3490 removelist=$lockfile
3499 test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
3504 # We need to display help for each of the modes.
3507 # Generic help is extracted from the usage comments
3508 # at the start of this file.
3514 "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
3516 Remove files from the build directory.
3518 RM is the name of the program to use to delete files associated with each FILE
3519 (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed
3522 If FILE is a libtool library, object or program, all the files associated
3523 with it are deleted. Otherwise, only FILE itself is deleted using RM."
3528 "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
3530 Compile a source file into a libtool library object.
3532 This mode accepts the following additional options:
3534 -o OUTPUT-FILE set the output file name to OUTPUT-FILE
3535 -no-suppress do not suppress compiler output for multiple passes
3536 -prefer-pic try to build PIC objects only
3537 -prefer-non-pic try to build non-PIC objects only
3538 -shared do not build a '.o' file suitable for static linking
3539 -static only build a '.o' file suitable for static linking
3540 -Wc,FLAG pass FLAG directly to the compiler
3542 COMPILE-COMMAND is a command to be used in creating a 'standard' object file
3543 from the given SOURCEFILE.
3545 The output file name is determined by removing the directory component from
3546 SOURCEFILE, then substituting the C source code suffix '.c' with the
3547 library object suffix, '.lo'."
3552 "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
3554 Automatically set library path, then run a program.
3556 This mode accepts the following additional options:
3558 -dlopen FILE add the directory containing FILE to the library path
3560 This mode sets the library path environment variable according to '-dlopen'
3563 If any of the ARGS are libtool executable wrappers, then they are translated
3564 into their corresponding uninstalled binary, and any of their required library
3565 directories are added to the library path.
3567 Then, COMMAND is executed, with ARGS as arguments."
3572 "Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
3574 Complete the installation of libtool libraries.
3576 Each LIBDIR is a directory that contains libtool libraries.
3578 The commands that this mode executes may require superuser privileges. Use
3579 the '--dry-run' option if you just want to see what would be executed."
3584 "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
3586 Install executables or libraries.
3588 INSTALL-COMMAND is the installation command. The first component should be
3589 either the 'install' or 'cp' program.
3591 The following components of INSTALL-COMMAND are treated specially:
3593 -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation
3595 The rest of the components are interpreted as arguments to that command (only
3596 BSD-compatible install options are recognized)."
3601 "Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
3603 Link object files or libraries together to form another library, or to
3604 create an executable program.
3606 LINK-COMMAND is a command using the C compiler that you would use to create
3607 a program from several object files.
3609 The following components of LINK-COMMAND are treated specially:
3611 -all-static do not do any dynamic linking at all
3612 -avoid-version do not add a version suffix if possible
3613 -bindir BINDIR specify path to binaries directory (for systems where
3614 libraries must be found in the PATH setting at runtime)
3615 -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime
3616 -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
3617 -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
3618 -export-symbols SYMFILE
3619 try to export only the symbols listed in SYMFILE
3620 -export-symbols-regex REGEX
3621 try to export only the symbols matching REGEX
3622 -LLIBDIR search LIBDIR for required installed libraries
3623 -lNAME OUTPUT-FILE requires the installed library libNAME
3624 -module build a library that can dlopened
3625 -no-fast-install disable the fast-install mode
3626 -no-install link a not-installable executable
3627 -no-undefined declare that a library does not refer to external symbols
3628 -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
3629 -objectlist FILE Use a list of object files found in FILE to specify objects
3630 -precious-files-regex REGEX
3631 don't remove output files matching REGEX
3632 -release RELEASE specify package release information
3633 -rpath LIBDIR the created library will eventually be installed in LIBDIR
3634 -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
3635 -shared only do dynamic linking of libtool libraries
3636 -shrext SUFFIX override the standard shared library file extension
3637 -static do not do any dynamic linking of uninstalled libtool libraries
3638 -static-libtool-libs
3639 do not do any dynamic linking of libtool libraries
3640 -version-info CURRENT[:REVISION[:AGE]]
3641 specify library version info [each variable defaults to 0]
3642 -weak LIBNAME declare that the target provides the LIBNAME interface
3644 -Xcompiler FLAG pass linker-specific FLAG directly to the compiler
3646 -Xlinker FLAG pass linker-specific FLAG directly to the linker
3647 -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC)
3649 All other options (arguments beginning with '-') are ignored.
3651 Every other argument is treated as a filename. Files ending in '.la' are
3652 treated as uninstalled libtool libraries, other files are standard or library
3655 If the OUTPUT-FILE ends in '.la', then a libtool library is created,
3656 only library objects ('.lo' files) may be specified, and '-rpath' is
3657 required, except when creating a convenience library.
3659 If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
3660 using 'ar' and 'ranlib', or on Windows using 'lib'.
3662 If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
3663 is created, otherwise an executable program is created."
3668 "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
3670 Remove libraries from an installation directory.
3672 RM is the name of the program to use to delete files associated with each FILE
3673 (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed
3676 If FILE is a libtool library, all the files associated with it are deleted.
3677 Otherwise, only FILE itself is deleted using RM."
3681 func_fatal_help "invalid operation mode '$opt_mode'"
3686 $ECHO "Try '$progname --help' for more information about other modes."
3689 # Now that we've collected a possible --mode arg, show help if necessary
3691 if test : = "$opt_help"; then
3696 for opt_mode in compile link execute install finish uninstall clean; do
3699 } | sed -n '1p; 2,$s/^Usage:/ or: /p'
3702 for opt_mode in compile link execute install finish uninstall clean; do
3708 /^When reporting/,/^Report/{
3713 /information about other modes/d
3714 /more detailed .*MODE/d
3715 s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
3721 # func_mode_execute arg...
3722 func_mode_execute ()
3726 # The first argument is the command name.
3729 func_fatal_help "you must specify a COMMAND"
3731 # Handle -dlopen flags immediately.
3732 for file in $opt_dlopen; do
3734 || func_fatal_help "'$file' is not a file"
3739 func_resolve_sysroot "$file"
3740 file=$func_resolve_sysroot_result
3742 # Check to see that this really is a libtool archive.
3743 func_lalib_unsafe_p "$file" \
3744 || func_fatal_help "'$lib' is not a valid libtool archive"
3746 # Read the libtool library.
3751 # Skip this library if it cannot be dlopened.
3752 if test -z "$dlname"; then
3753 # Warn if it was a shared library.
3754 test -n "$library_names" && \
3755 func_warning "'$file' was not linked with '-export-dynamic'"
3759 func_dirname "$file" "" "."
3760 dir=$func_dirname_result
3762 if test -f "$dir/$objdir/$dlname"; then
3763 func_append dir "/$objdir"
3765 if test ! -f "$dir/$dlname"; then
3766 func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
3772 # Just add the directory containing the .lo file.
3773 func_dirname "$file" "" "."
3774 dir=$func_dirname_result
3778 func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
3783 # Get the absolute pathname.
3784 absdir=`cd "$dir" && pwd`
3785 test -n "$absdir" && dir=$absdir
3787 # Now add the directory to shlibpath_var.
3788 if eval "test -z \"\$$shlibpath_var\""; then
3789 eval "$shlibpath_var=\"\$dir\""
3791 eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
3795 # This variable tells wrapper scripts just to set shlibpath_var
3796 # rather than running their programs.
3797 libtool_execute_magic=$magic
3799 # Check if any of the arguments is a wrapper script.
3804 -* | *.la | *.lo ) ;;
3806 # Do a test to see if this is really a libtool program.
3807 if func_ltwrapper_script_p "$file"; then
3809 # Transform arg to wrapped name.
3810 file=$progdir/$program
3811 elif func_ltwrapper_executable_p "$file"; then
3812 func_ltwrapper_scriptname "$file"
3813 func_source "$func_ltwrapper_scriptname_result"
3814 # Transform arg to wrapped name.
3815 file=$progdir/$program
3819 # Quote arguments (to preserve shell metacharacters).
3820 func_append_quoted args "$file"
3823 if $opt_dry_run; then
3824 # Display what would be done.
3825 if test -n "$shlibpath_var"; then
3826 eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
3827 echo "export $shlibpath_var"
3832 if test -n "$shlibpath_var"; then
3833 # Export the shlibpath_var.
3834 eval "export $shlibpath_var"
3837 # Restore saved environment variables
3838 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
3840 eval "if test \"\${save_$lt_var+set}\" = set; then
3841 $lt_var=\$save_$lt_var; export $lt_var
3847 # Now prepare to actually exec the command.
3852 test execute = "$opt_mode" && func_mode_execute ${1+"$@"}
3855 # func_mode_finish arg...
3864 for opt in "$nonopt" ${1+"$@"}
3866 if test -d "$opt"; then
3867 func_append libdirs " $opt"
3869 elif test -f "$opt"; then
3870 if func_lalib_unsafe_p "$opt"; then
3871 func_append libs " $opt"
3873 func_warning "'$opt' is not a valid libtool archive"
3877 func_fatal_error "invalid argument '$opt'"
3881 if test -n "$libs"; then
3882 if test -n "$lt_sysroot"; then
3883 sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
3884 sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
3889 # Remove sysroot references
3890 if $opt_dry_run; then
3891 for lib in $libs; do
3892 echo "removing references to $lt_sysroot and '=' prefixes from $lib"
3895 tmpdir=`func_mktempdir`
3896 for lib in $libs; do
3897 sed -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
3899 mv -f $tmpdir/tmp-la $lib
3905 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
3906 for libdir in $libdirs; do
3907 if test -n "$finish_cmds"; then
3908 # Do each command in the finish commands.
3909 func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
3912 if test -n "$finish_eval"; then
3913 # Do the single finish_eval.
3914 eval cmds=\"$finish_eval\"
3915 $opt_dry_run || eval "$cmds" || func_append admincmds "
3921 # Exit here if they wanted silent mode.
3922 $opt_quiet && exit $EXIT_SUCCESS
3924 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
3925 echo "----------------------------------------------------------------------"
3926 echo "Libraries have been installed in:"
3927 for libdir in $libdirs; do
3931 echo "If you ever happen to want to link against installed libraries"
3932 echo "in a given directory, LIBDIR, you must either use libtool, and"
3933 echo "specify the full pathname of the library, or use the '-LLIBDIR'"
3934 echo "flag during linking and do at least one of the following:"
3935 if test -n "$shlibpath_var"; then
3936 echo " - add LIBDIR to the '$shlibpath_var' environment variable"
3937 echo " during execution"
3939 if test -n "$runpath_var"; then
3940 echo " - add LIBDIR to the '$runpath_var' environment variable"
3941 echo " during linking"
3943 if test -n "$hardcode_libdir_flag_spec"; then
3945 eval flag=\"$hardcode_libdir_flag_spec\"
3947 $ECHO " - use the '$flag' linker flag"
3949 if test -n "$admincmds"; then
3950 $ECHO " - have your system administrator run these commands:$admincmds"
3952 if test -f /etc/ld.so.conf; then
3953 echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
3957 echo "See any operating system documentation about shared libraries for"
3959 solaris2.[6789]|solaris2.1[0-9])
3960 echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
3964 echo "more information, such as the ld(1) and ld.so(8) manual pages."
3967 echo "----------------------------------------------------------------------"
3972 test finish = "$opt_mode" && func_mode_finish ${1+"$@"}
3975 # func_mode_install arg...
3976 func_mode_install ()
3980 # There may be an optional sh(1) argument at the beginning of
3981 # install_prog (especially on Windows NT).
3982 if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
3983 # Allow the use of GNU shtool's install command.
3984 case $nonopt in *shtool*) :;; *) false;; esac
3986 # Aesthetically quote it.
3987 func_quote_for_eval "$nonopt"
3988 install_prog="$func_quote_for_eval_result "
3996 # The real first argument should be the name of the installation program.
3997 # Aesthetically quote it.
3998 func_quote_for_eval "$arg"
3999 func_append install_prog "$func_quote_for_eval_result"
4000 install_shared_prog=$install_prog
4001 case " $install_prog " in
4002 *[\\\ /]cp\ *) install_cp=: ;;
4003 *) install_cp=false ;;
4006 # We need to accept at least all the BSD install flags.
4018 if test -n "$dest"; then
4019 func_append files " $dest"
4027 if $install_cp; then :; else
4041 # If the previous option needed an argument, then skip it.
4042 if test -n "$prev"; then
4043 if test X-m = "X$prev" && test -n "$install_override_mode"; then
4044 arg2=$install_override_mode
4055 # Aesthetically quote the argument.
4056 func_quote_for_eval "$arg"
4057 func_append install_prog " $func_quote_for_eval_result"
4058 if test -n "$arg2"; then
4059 func_quote_for_eval "$arg2"
4061 func_append install_shared_prog " $func_quote_for_eval_result"
4064 test -z "$install_prog" && \
4065 func_fatal_help "you must specify an install program"
4067 test -n "$prev" && \
4068 func_fatal_help "the '$prev' option requires an argument"
4070 if test -n "$install_override_mode" && $no_mode; then
4071 if $install_cp; then :; else
4072 func_quote_for_eval "$install_override_mode"
4073 func_append install_shared_prog " -m $func_quote_for_eval_result"
4077 if test -z "$files"; then
4078 if test -z "$dest"; then
4079 func_fatal_help "no file or destination specified"
4081 func_fatal_help "you must specify a destination"
4085 # Strip any trailing slash from the destination.
4086 func_stripname '' '/' "$dest"
4087 dest=$func_stripname_result
4089 # Check to see that the destination is a directory.
4090 test -d "$dest" && isdir=:
4095 func_dirname_and_basename "$dest" "" "."
4096 destdir=$func_dirname_result
4097 destname=$func_basename_result
4099 # Not a directory, so check to see that there is only one file specified.
4100 set dummy $files; shift
4101 test "$#" -gt 1 && \
4102 func_fatal_help "'$dest' is not a directory"
4105 [\\/]* | [A-Za-z]:[\\/]*) ;;
4107 for file in $files; do
4111 func_fatal_help "'$destdir' must be an absolute directory name"
4118 # This variable tells wrapper scripts just to set variables rather
4119 # than running their programs.
4120 libtool_install_magic=$magic
4125 for file in $files; do
4127 # Do each installation.
4130 # Do the static libraries later.
4131 func_append staticlibs " $file"
4135 func_resolve_sysroot "$file"
4136 file=$func_resolve_sysroot_result
4138 # Check to see that this really is a libtool archive.
4139 func_lalib_unsafe_p "$file" \
4140 || func_fatal_help "'$file' is not a valid libtool archive"
4147 # Add the libdir to current_libdirs if it is the destination.
4148 if test "X$destdir" = "X$libdir"; then
4149 case "$current_libdirs " in
4151 *) func_append current_libdirs " $libdir" ;;
4154 # Note the libdir as a future libdir.
4155 case "$future_libdirs " in
4157 *) func_append future_libdirs " $libdir" ;;
4161 func_dirname "$file" "/" ""
4162 dir=$func_dirname_result
4163 func_append dir "$objdir"
4165 if test -n "$relink_command"; then
4166 # Determine the prefix the user has applied to our future dir.
4167 inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
4169 # Don't allow the user to place us outside of our expected
4170 # location b/c this prevents finding dependent libraries that
4171 # are installed to the same prefix.
4172 # At present, this check doesn't affect windows .dll's that
4173 # are installed into $libdir/../bin (currently, that works fine)
4174 # but it's something to keep an eye on.
4175 test "$inst_prefix_dir" = "$destdir" && \
4176 func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
4178 if test -n "$inst_prefix_dir"; then
4179 # Stick the inst_prefix_dir data into the link command.
4180 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
4182 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
4185 func_warning "relinking '$file'"
4186 func_show_eval "$relink_command" \
4187 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
4190 # See the names of the shared library.
4191 set dummy $library_names; shift
4192 if test -n "$1"; then
4197 test -n "$relink_command" && srcname=${realname}T
4199 # Install the shared library and build the symlinks.
4200 func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
4204 cygwin* | mingw* | pw32* | cegcc*)
4212 if test -n "$tstripme" && test -n "$striplib"; then
4213 func_show_eval "$striplib $destdir/$realname" 'exit $?'
4216 if test "$#" -gt 0; then
4217 # Delete the old symlinks, and create new ones.
4218 # Try 'ln -sf' first, because the 'ln' binary might depend on
4219 # the symlink we replace! Solaris /bin/ln does not understand -f,
4220 # so we also need to try rm && ln -s.
4223 test "$linkname" != "$realname" \
4224 && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
4228 # Do each command in the postinstall commands.
4229 lib=$destdir/$realname
4230 func_execute_cmds "$postinstall_cmds" 'exit $?'
4233 # Install the pseudo-library for information purposes.
4234 func_basename "$file"
4235 name=$func_basename_result
4236 instname=$dir/${name}i
4237 func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
4239 # Maybe install the static library, too.
4240 test -n "$old_library" && func_append staticlibs " $dir/$old_library"
4244 # Install (i.e. copy) a libtool object.
4246 # Figure out destination file name, if it wasn't already specified.
4247 if test -n "$destname"; then
4248 destfile=$destdir/$destname
4250 func_basename "$file"
4251 destfile=$func_basename_result
4252 destfile=$destdir/$destfile
4255 # Deduce the name of the destination old-style object file.
4258 func_lo2o "$destfile"
4259 staticdest=$func_lo2o_result
4262 staticdest=$destfile
4266 func_fatal_help "cannot copy a libtool object to '$destfile'"
4270 # Install the libtool object if requested.
4271 test -n "$destfile" && \
4272 func_show_eval "$install_prog $file $destfile" 'exit $?'
4274 # Install the old object if enabled.
4275 if test yes = "$build_old_libs"; then
4276 # Deduce the name of the old-style object file.
4278 staticobj=$func_lo2o_result
4279 func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
4285 # Figure out destination file name, if it wasn't already specified.
4286 if test -n "$destname"; then
4287 destfile=$destdir/$destname
4289 func_basename "$file"
4290 destfile=$func_basename_result
4291 destfile=$destdir/$destfile
4294 # If the file is missing, and there is a .exe on the end, strip it
4295 # because it is most likely a libtool script we actually want to
4300 if test ! -f "$file"; then
4301 func_stripname '' '.exe' "$file"
4302 file=$func_stripname_result
4308 # Do a test to see if this is really a libtool program.
4311 if func_ltwrapper_executable_p "$file"; then
4312 func_ltwrapper_scriptname "$file"
4313 wrapper=$func_ltwrapper_scriptname_result
4315 func_stripname '' '.exe' "$file"
4316 wrapper=$func_stripname_result
4323 if func_ltwrapper_script_p "$wrapper"; then
4327 func_source "$wrapper"
4329 # Check the variables that should have been set.
4330 test -z "$generated_by_libtool_version" && \
4331 func_fatal_error "invalid libtool wrapper script '$wrapper'"
4334 for lib in $notinst_deplibs; do
4335 # Check to see that each library is installed.
4337 if test -f "$lib"; then
4340 libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
4341 if test -n "$libdir" && test ! -f "$libfile"; then
4342 func_warning "'$lib' has not been installed in '$libdir'"
4348 func_source "$wrapper"
4351 if test no = "$fast_install" && test -n "$relink_command"; then
4354 tmpdir=`func_mktempdir`
4355 func_basename "$file$stripped_ext"
4356 file=$func_basename_result
4357 outputname=$tmpdir/$file
4358 # Replace the output file specification.
4359 relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
4362 func_quote_for_expand "$relink_command"
4363 eval "func_echo $func_quote_for_expand_result"
4365 if eval "$relink_command"; then :
4367 func_error "error: relink '$file' with the above command before installing it"
4368 $opt_dry_run || ${RM}r "$tmpdir"
4373 func_warning "cannot relink '$file'"
4377 # Install the binary that we compiled earlier.
4378 file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
4382 # remove .exe since cygwin /usr/bin/install will append another
4384 case $install_prog,$host in
4385 */usr/bin/install*,*cygwin*)
4386 case $file:$destfile in
4391 destfile=$destfile.exe
4394 func_stripname '' '.exe' "$destfile"
4395 destfile=$func_stripname_result
4400 func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
4401 $opt_dry_run || if test -n "$outputname"; then
4408 for file in $staticlibs; do
4409 func_basename "$file"
4410 name=$func_basename_result
4412 # Set up the ranlib parameters.
4413 oldlib=$destdir/$name
4414 func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
4415 tool_oldlib=$func_to_tool_file_result
4417 func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
4419 if test -n "$stripme" && test -n "$old_striplib"; then
4420 func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
4423 # Do each command in the postinstall commands.
4424 func_execute_cmds "$old_postinstall_cmds" 'exit $?'
4427 test -n "$future_libdirs" && \
4428 func_warning "remember to run '$progname --finish$future_libdirs'"
4430 if test -n "$current_libdirs"; then
4431 # Maybe just do a dry run.
4432 $opt_dry_run && current_libdirs=" -n$current_libdirs"
4433 exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
4439 test install = "$opt_mode" && func_mode_install ${1+"$@"}
4442 # func_generate_dlsyms outputname originator pic_p
4443 # Extract symbols from dlprefiles and create ${outputname}S.o with
4444 # a dlpreopen symbol table.
4445 func_generate_dlsyms ()
4452 my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
4455 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
4456 if test -n "$NM" && test -n "$global_symbol_pipe"; then
4457 my_dlsyms=${my_outputname}S.c
4459 func_error "not configured to extract global symbols from dlpreopened files"
4463 if test -n "$my_dlsyms"; then
4467 # Discover the nlist of each of the dlfiles.
4468 nlist=$output_objdir/$my_outputname.nm
4470 func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
4472 # Parse the name list into a source file.
4473 func_verbose "creating $output_objdir/$my_dlsyms"
4475 $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
4476 /* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
4477 /* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
4483 #if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
4484 #pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
4487 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
4488 #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
4489 /* DATA imports from DLLs on WIN32 can't be const, because runtime
4490 relocations are performed -- see ld's documentation on pseudo-relocs. */
4491 # define LT_DLSYM_CONST
4492 #elif defined __osf__
4493 /* This system does not cope well with relocations in const data. */
4494 # define LT_DLSYM_CONST
4496 # define LT_DLSYM_CONST const
4499 #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
4501 /* External symbol declarations for the compiler. */\
4504 if test yes = "$dlself"; then
4505 func_verbose "generating symbol list for '$output'"
4507 $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
4509 # Add our own program objects to the symbol list.
4510 progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
4511 for progfile in $progfiles; do
4512 func_to_tool_file "$progfile" func_convert_file_msys_to_w32
4513 func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
4514 $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
4517 if test -n "$exclude_expsyms"; then
4519 eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
4520 eval '$MV "$nlist"T "$nlist"'
4524 if test -n "$export_symbols_regex"; then
4526 eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
4527 eval '$MV "$nlist"T "$nlist"'
4531 # Prepare the list of exported symbols
4532 if test -z "$export_symbols"; then
4533 export_symbols=$output_objdir/$outputname.exp
4536 eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4538 *cygwin* | *mingw* | *cegcc* )
4539 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4540 eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
4546 eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4547 eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
4548 eval '$MV "$nlist"T "$nlist"'
4550 *cygwin* | *mingw* | *cegcc* )
4551 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
4552 eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
4559 for dlprefile in $dlprefiles; do
4560 func_verbose "extracting global C symbols from '$dlprefile'"
4561 func_basename "$dlprefile"
4562 name=$func_basename_result
4564 *cygwin* | *mingw* | *cegcc* )
4565 # if an import library, we need to obtain dlname
4566 if func_win32_import_lib_p "$dlprefile"; then
4567 func_tr_sh "$dlprefile"
4568 eval "curr_lafile=\$libfile_$func_tr_sh_result"
4569 dlprefile_dlbasename=
4570 if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
4571 # Use subshell, to avoid clobbering current variable values
4572 dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
4573 if test -n "$dlprefile_dlname"; then
4574 func_basename "$dlprefile_dlname"
4575 dlprefile_dlbasename=$func_basename_result
4577 # no lafile. user explicitly requested -dlpreopen <import library>.
4578 $sharedlib_from_linklib_cmd "$dlprefile"
4579 dlprefile_dlbasename=$sharedlib_from_linklib_result
4583 if test -n "$dlprefile_dlbasename"; then
4584 eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
4586 func_warning "Could not compute DLL name from $name"
4587 eval '$ECHO ": $name " >> "$nlist"'
4589 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4590 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
4591 $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
4593 else # not an import lib
4595 eval '$ECHO ": $name " >> "$nlist"'
4596 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4597 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4603 eval '$ECHO ": $name " >> "$nlist"'
4604 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
4605 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
4612 # Make sure we have at least an empty file.
4613 test -f "$nlist" || : > "$nlist"
4615 if test -n "$exclude_expsyms"; then
4616 $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
4617 $MV "$nlist"T "$nlist"
4620 # Try sorting and uniquifying the output.
4621 if $GREP -v "^: " < "$nlist" |
4622 if sort -k 3 </dev/null >/dev/null 2>&1; then
4627 uniq > "$nlist"S; then
4630 $GREP -v "^: " < "$nlist" > "$nlist"S
4633 if test -f "$nlist"S; then
4634 eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
4636 echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
4639 func_show_eval '$RM "${nlist}I"'
4640 if test -n "$global_symbol_to_import"; then
4641 eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
4644 echo >> "$output_objdir/$my_dlsyms" "\
4646 /* The mapping between symbol names and symbols. */
4651 extern LT_DLSYM_CONST lt_dlsymlist
4652 lt_${my_prefix}_LTX_preloaded_symbols[];\
4655 if test -s "$nlist"I; then
4656 echo >> "$output_objdir/$my_dlsyms" "\
4657 static void lt_syminit(void)
4659 LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
4660 for (; symbol->name; ++symbol)
4662 $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
4663 echo >> "$output_objdir/$my_dlsyms" "\
4667 echo >> "$output_objdir/$my_dlsyms" "\
4668 LT_DLSYM_CONST lt_dlsymlist
4669 lt_${my_prefix}_LTX_preloaded_symbols[] =
4670 { {\"$my_originator\", (void *) 0},"
4672 if test -s "$nlist"I; then
4673 echo >> "$output_objdir/$my_dlsyms" "\
4674 {\"@INIT@\", (void *) <_syminit},"
4677 case $need_lib_prefix in
4679 eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
4682 eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
4685 echo >> "$output_objdir/$my_dlsyms" "\
4689 /* This works around a problem in FreeBSD linker */
4690 #ifdef FREEBSD_WORKAROUND
4691 static const void *lt_preloaded_setup() {
4692 return lt_${my_prefix}_LTX_preloaded_symbols;
4702 pic_flag_for_symtable=
4703 case "$compile_command " in
4707 # compiling the symbol table file with pic_flag works around
4708 # a FreeBSD bug that causes programs to crash when -lm is
4709 # linked before any other PIC object. But we must not use
4710 # pic_flag when linking with -static. The problem exists in
4711 # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
4712 *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
4713 pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
4715 pic_flag_for_symtable=" $pic_flag" ;;
4717 $my_pic_p && pic_flag_for_symtable=" $pic_flag"
4723 for arg in $LTCFLAGS; do
4725 -pie | -fpie | -fPIE) ;;
4726 *) func_append symtab_cflags " $arg" ;;
4730 # Now compile the dynamic symbol file.
4731 func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
4733 # Clean up the generated files.
4734 func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
4736 # Transform the symbol file into the correct name.
4737 symfileobj=$output_objdir/${my_outputname}S.$objext
4739 *cygwin* | *mingw* | *cegcc* )
4740 if test -f "$output_objdir/$my_outputname.def"; then
4741 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
4742 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
4744 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4745 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4749 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4750 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
4755 func_fatal_error "unknown suffix for '$my_dlsyms'"
4759 # We keep going just in case the user didn't refer to
4760 # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
4761 # really was required.
4763 # Nullify the symbol file.
4764 compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
4765 finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
4769 # func_cygming_gnu_implib_p ARG
4770 # This predicate returns with zero status (TRUE) if
4771 # ARG is a GNU/binutils-style import library. Returns
4772 # with nonzero status (FALSE) otherwise.
4773 func_cygming_gnu_implib_p ()
4777 func_to_tool_file "$1" func_convert_file_msys_to_w32
4778 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)$'`
4779 test -n "$func_cygming_gnu_implib_tmp"
4782 # func_cygming_ms_implib_p ARG
4783 # This predicate returns with zero status (TRUE) if
4784 # ARG is an MS-style import library. Returns
4785 # with nonzero status (FALSE) otherwise.
4786 func_cygming_ms_implib_p ()
4790 func_to_tool_file "$1" func_convert_file_msys_to_w32
4791 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
4792 test -n "$func_cygming_ms_implib_tmp"
4795 # func_win32_libid arg
4796 # return the library type of file 'arg'
4798 # Need a lot of goo to handle *both* DLLs and import libs
4799 # Has to be a shell function in order to 'eat' the argument
4800 # that is supplied when $file_magic_command is called.
4801 # Despite the name, also deal with 64 bit binaries.
4806 win32_libid_type=unknown
4807 win32_fileres=`file -L $1 2>/dev/null`
4808 case $win32_fileres in
4809 *ar\ archive\ import\ library*) # definitely import
4810 win32_libid_type="x86 archive import"
4812 *ar\ archive*) # could be an import, or static
4813 # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
4814 if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
4815 $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
4816 case $nm_interface in
4818 if func_cygming_ms_implib_p "$1" ||
4819 func_cygming_gnu_implib_p "$1"
4827 func_to_tool_file "$1" func_convert_file_msys_to_w32
4828 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
4839 case $win32_nmres in
4840 import*) win32_libid_type="x86 archive import";;
4841 *) win32_libid_type="x86 archive static";;
4846 win32_libid_type="x86 DLL"
4848 *executable*) # but shell scripts are "executable" too...
4849 case $win32_fileres in
4850 *MS\ Windows\ PE\ Intel*)
4851 win32_libid_type="x86 DLL"
4856 $ECHO "$win32_libid_type"
4859 # func_cygming_dll_for_implib ARG
4861 # Platform-specific function to extract the
4862 # name of the DLL associated with the specified
4863 # import library ARG.
4864 # Invoked by eval'ing the libtool variable
4865 # $sharedlib_from_linklib_cmd
4866 # Result is available in the variable
4867 # $sharedlib_from_linklib_result
4868 func_cygming_dll_for_implib ()
4872 sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
4875 # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
4877 # The is the core of a fallback implementation of a
4878 # platform-specific function to extract the name of the
4879 # DLL associated with the specified import library LIBNAME.
4881 # SECTION_NAME is either .idata$6 or .idata$7, depending
4882 # on the platform and compiler that created the implib.
4884 # Echos the name of the DLL associated with the
4885 # specified import library.
4886 func_cygming_dll_for_implib_fallback_core ()
4890 match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
4891 $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
4892 $SED '/^Contents of section '"$match_literal"':/{
4893 # Place marker at beginning of archive member dllname section
4898 # These lines can sometimes be longer than 43 characters, but
4899 # are always uninteresting
4900 /:[ ]*file format pe[i]\{,1\}-/d
4901 /^In archive [^:]*:/d
4902 # Ensure marker is printed
4904 # Remove all lines with less than 43 characters
4906 # From remaining lines, remove first 43 characters
4909 # Join marker and all lines until next marker into a single line
4910 /^====MARK====/ b para
4919 # Remove trailing dots and whitespace
4923 # we now have a list, one entry per line, of the stringified
4924 # contents of the appropriate section of all members of the
4925 # archive that possess that section. Heuristic: eliminate
4926 # all those that have a first or second character that is
4927 # a '.' (that is, objdump's representation of an unprintable
4928 # character.) This should work for all archives with less than
4929 # 0x302f exports -- but will fail for DLLs whose name actually
4930 # begins with a literal '.' or a single character followed by
4933 # Of those that remain, print the first one.
4934 $SED -e '/^\./d;/^.\./d;q'
4937 # func_cygming_dll_for_implib_fallback ARG
4938 # Platform-specific function to extract the
4939 # name of the DLL associated with the specified
4940 # import library ARG.
4942 # This fallback implementation is for use when $DLLTOOL
4943 # does not support the --identify-strict option.
4944 # Invoked by eval'ing the libtool variable
4945 # $sharedlib_from_linklib_cmd
4946 # Result is available in the variable
4947 # $sharedlib_from_linklib_result
4948 func_cygming_dll_for_implib_fallback ()
4952 if func_cygming_gnu_implib_p "$1"; then
4953 # binutils import library
4954 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
4955 elif func_cygming_ms_implib_p "$1"; then
4956 # ms-generated import library
4957 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
4960 sharedlib_from_linklib_result=
4965 # func_extract_an_archive dir oldlib
4966 func_extract_an_archive ()
4970 f_ex_an_ar_dir=$1; shift
4971 f_ex_an_ar_oldlib=$1
4972 if test yes = "$lock_old_archive_extraction"; then
4973 lockfile=$f_ex_an_ar_oldlib.lock
4974 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
4975 func_echo "Waiting for $lockfile to be removed"
4979 func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
4980 'stat=$?; rm -f "$lockfile"; exit $stat'
4981 if test yes = "$lock_old_archive_extraction"; then
4982 $opt_dry_run || rm -f "$lockfile"
4984 if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
4987 func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
4992 # func_extract_archives gentop oldlib ...
4993 func_extract_archives ()
4998 my_oldlibs=${1+"$@"}
5004 for my_xlib in $my_oldlibs; do
5005 # Extract the objects.
5007 [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
5008 *) my_xabs=`pwd`"/$my_xlib" ;;
5010 func_basename "$my_xlib"
5011 my_xlib=$func_basename_result
5014 case " $extracted_archives " in
5016 func_arith $extracted_serial + 1
5017 extracted_serial=$func_arith_result
5018 my_xlib_u=lt$extracted_serial-$my_xlib ;;
5022 extracted_archives="$extracted_archives $my_xlib_u"
5023 my_xdir=$my_gentop/$my_xlib_u
5025 func_mkdir_p "$my_xdir"
5029 func_verbose "Extracting $my_xabs"
5030 # Do not bother doing anything if just a dry run
5032 darwin_orig_dir=`pwd`
5033 cd $my_xdir || exit $?
5034 darwin_archive=$my_xabs
5036 func_basename "$darwin_archive"
5037 darwin_base_archive=$func_basename_result
5038 darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
5039 if test -n "$darwin_arches"; then
5040 darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
5042 func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
5043 for darwin_arch in $darwin_arches; do
5044 func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
5045 $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
5046 cd "unfat-$$/$darwin_base_archive-$darwin_arch"
5047 func_extract_an_archive "`pwd`" "$darwin_base_archive"
5049 $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
5050 done # $darwin_arches
5051 ## Okay now we've a bunch of thin objects, gotta fatten them up :)
5052 darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
5055 for darwin_file in $darwin_filelist; do
5056 darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
5057 $LIPO -create -output "$darwin_file" $darwin_files
5058 done # $darwin_filelist
5060 cd "$darwin_orig_dir"
5063 func_extract_an_archive "$my_xdir" "$my_xabs"
5068 func_extract_an_archive "$my_xdir" "$my_xabs"
5071 my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
5074 func_extract_archives_result=$my_oldobjs
5078 # func_emit_wrapper [arg=no]
5080 # Emit a libtool wrapper script on stdout.
5081 # Don't directly open a file because we may want to
5082 # incorporate the script contents within a cygwin/mingw
5083 # wrapper executable. Must ONLY be called from within
5084 # func_mode_link because it depends on a number of variables
5087 # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
5088 # variable will take. If 'yes', then the emitted script
5089 # will assume that the directory where it is stored is
5090 # the $objdir directory. This is a cygwin/mingw-specific
5092 func_emit_wrapper ()
5094 func_emit_wrapper_arg1=${1-no}
5099 # $output - temporary wrapper script for $objdir/$outputname
5100 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
5102 # The $output program cannot be directly executed until all the libtool
5103 # libraries that it depends on are installed.
5105 # This wrapper script should never be moved out of the build directory.
5106 # If it is, it will not operate correctly.
5108 # Sed substitution that helps us do robust quoting. It backslashifies
5109 # metacharacters that are still active within double-quoted strings.
5110 sed_quote_subst='$sed_quote_subst'
5112 # Be Bourne compatible
5113 if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
5116 # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
5117 # is contrary to our usage. Disable this feature.
5118 alias -g '\${1+\"\$@\"}'='\"\$@\"'
5119 setopt NO_GLOB_SUBST
5121 case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
5123 BIN_SH=xpg4; export BIN_SH # for Tru64
5124 DUALCASE=1; export DUALCASE # for MKS sh
5126 # The HP-UX ksh and POSIX shell print the target directory to stdout
5128 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
5130 relink_command=\"$relink_command\"
5132 # This environment variable determines our operation mode.
5133 if test \"\$libtool_install_magic\" = \"$magic\"; then
5134 # install mode needs the following variables:
5135 generated_by_libtool_version='$macro_version'
5136 notinst_deplibs='$notinst_deplibs'
5138 # When we are sourced in execute mode, \$file and \$ECHO are already set.
5139 if test \"\$libtool_execute_magic\" != \"$magic\"; then
5142 qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
5145 # A function that is used when there is no print builtin or printf.
5146 func_fallback_echo ()
5148 eval 'cat <<_LTECHO_EOF
5155 # Very basic option parsing. These options are (a) specific to
5156 # the libtool wrapper, (b) are identical between the wrapper
5157 # /script/ and the wrapper /executable/ that is used only on
5158 # windows platforms, and (c) all begin with the string "--lt-"
5159 # (application programs are unlikely to have options that match
5162 # There are only two supported options: --lt-debug and
5163 # --lt-dump-script. There is, deliberately, no --lt-help.
5165 # The first argument to this parsing function should be the
5166 # script's $0 value, followed by "$@".
5168 func_parse_lt_options ()
5174 case \"\$lt_opt\" in
5175 --lt-debug) lt_option_debug=1 ;;
5177 lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
5178 test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
5179 lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
5180 cat \"\$lt_dump_D/\$lt_dump_F\"
5184 \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
5190 # Print the debug banner immediately:
5191 if test -n \"\$lt_option_debug\"; then
5192 echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
5196 # Used when --lt-debug. Prints its arguments to stdout
5197 # (redirection is the responsibility of the caller)
5198 func_lt_dump_args ()
5203 \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
5204 lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
5208 # Core function for launching the target application
5209 func_exec_program_core ()
5213 # Backslashes separate directories on plain windows
5214 *-*-mingw | *-*-os2* | *-cegcc*)
5216 if test -n \"\$lt_option_debug\"; then
5217 \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
5218 func_lt_dump_args \${1+\"\$@\"} 1>&2
5220 exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
5226 if test -n \"\$lt_option_debug\"; then
5227 \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
5228 func_lt_dump_args \${1+\"\$@\"} 1>&2
5230 exec \"\$progdir/\$program\" \${1+\"\$@\"}
5235 \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
5239 # A function to encapsulate launching the target application
5240 # Strips options in the --lt-* namespace from \$@ and
5241 # launches target application with the remaining arguments.
5242 func_exec_program ()
5250 *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
5255 func_exec_program_core \${1+\"\$@\"}
5259 func_parse_lt_options \"\$0\" \${1+\"\$@\"}
5261 # Find the directory that this script lives in.
5262 thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
5263 test \"x\$thisdir\" = \"x\$file\" && thisdir=.
5265 # Follow symbolic links until we get to the real thisdir.
5266 file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
5267 while test -n \"\$file\"; do
5268 destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
5270 # If there was a directory component, then change thisdir.
5271 if test \"x\$destdir\" != \"x\$file\"; then
5272 case \"\$destdir\" in
5273 [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
5274 *) thisdir=\"\$thisdir/\$destdir\" ;;
5278 file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
5279 file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
5282 # Usually 'no', except on cygwin/mingw when embedded into
5284 WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
5285 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
5286 # special case for '.'
5287 if test \"\$thisdir\" = \".\"; then
5290 # remove .libs from thisdir
5291 case \"\$thisdir\" in
5292 *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
5293 $objdir ) thisdir=. ;;
5297 # Try to get the absolute directory name.
5298 absdir=\`cd \"\$thisdir\" && pwd\`
5299 test -n \"\$absdir\" && thisdir=\"\$absdir\"
5302 if test yes = "$fast_install"; then
5304 program=lt-'$outputname'$exeext
5305 progdir=\"\$thisdir/$objdir\"
5307 if test ! -f \"\$progdir/\$program\" ||
5308 { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
5309 test \"X\$file\" != \"X\$progdir/\$program\"; }; then
5311 file=\"\$\$-\$program\"
5313 if test ! -d \"\$progdir\"; then
5314 $MKDIR \"\$progdir\"
5316 $RM \"\$progdir/\$file\"
5321 # relink executable if necessary
5322 if test -n \"\$relink_command\"; then
5323 if relink_command_output=\`eval \$relink_command 2>&1\`; then :
5325 $ECHO \"\$relink_command_output\" >&2
5326 $RM \"\$progdir/\$file\"
5331 $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
5332 { $RM \"\$progdir/\$program\";
5333 $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
5334 $RM \"\$progdir/\$file\"
5338 program='$outputname'
5339 progdir=\"\$thisdir/$objdir\"
5345 if test -f \"\$progdir/\$program\"; then"
5347 # fixup the dll searchpath if we need to.
5349 # Fix the DLL searchpath if we need to. Do this before prepending
5350 # to shlibpath, because on Windows, both are PATH and uninstalled
5351 # libraries must come first.
5352 if test -n "$dllsearchpath"; then
5354 # Add the dll search path components to the executable PATH
5355 PATH=$dllsearchpath:\$PATH
5359 # Export our shlibpath_var if we have one.
5360 if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5362 # Add our own library path to $shlibpath_var
5363 $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
5365 # Some systems cannot cope with colon-terminated $shlibpath_var
5366 # The second colon is a workaround for a bug in BeOS R4 sed
5367 $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
5369 export $shlibpath_var
5374 if test \"\$libtool_execute_magic\" != \"$magic\"; then
5375 # Run the actual program with our arguments.
5376 func_exec_program \${1+\"\$@\"}
5379 # The program doesn't exist.
5380 \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
5381 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
5382 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
5390 # func_emit_cwrapperexe_src
5391 # emit the source code for a wrapper executable on stdout
5392 # Must ONLY be called from within func_mode_link because
5393 # it depends on a number of variable set therein.
5394 func_emit_cwrapperexe_src ()
5398 /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
5399 Generated by $PROGRAM (GNU $PACKAGE) $VERSION
5401 The $output program cannot be directly executed until all the libtool
5402 libraries that it depends on are installed.
5404 This wrapper executable should never be moved out of the build directory.
5405 If it is, it will not operate correctly.
5410 # define _CRT_SECURE_NO_DEPRECATE 1
5415 # include <direct.h>
5416 # include <process.h>
5419 # include <unistd.h>
5420 # include <stdint.h>
5432 #include <sys/stat.h>
5434 #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
5436 /* declarations of non-ANSI functions */
5437 #if defined __MINGW32__
5438 # ifdef __STRICT_ANSI__
5439 int _putenv (const char *);
5441 #elif defined __CYGWIN__
5442 # ifdef __STRICT_ANSI__
5443 char *realpath (const char *, char *);
5444 int putenv (char *);
5445 int setenv (const char *, const char *, int);
5447 /* #elif defined other_platform || defined ... */
5450 /* portability defines, excluding path handling macros */
5451 #if defined _MSC_VER
5452 # define setmode _setmode
5454 # define chmod _chmod
5455 # define getcwd _getcwd
5456 # define putenv _putenv
5457 # define S_IXUSR _S_IEXEC
5458 #elif defined __MINGW32__
5459 # define setmode _setmode
5461 # define chmod _chmod
5462 # define getcwd _getcwd
5463 # define putenv _putenv
5464 #elif defined __CYGWIN__
5465 # define HAVE_SETENV
5466 # define FOPEN_WB "wb"
5467 /* #elif defined other platforms ... */
5470 #if defined PATH_MAX
5471 # define LT_PATHMAX PATH_MAX
5472 #elif defined MAXPATHLEN
5473 # define LT_PATHMAX MAXPATHLEN
5475 # define LT_PATHMAX 1024
5485 /* path handling portability macros */
5486 #ifndef DIR_SEPARATOR
5487 # define DIR_SEPARATOR '/'
5488 # define PATH_SEPARATOR ':'
5491 #if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
5493 # define HAVE_DOS_BASED_FILE_SYSTEM
5494 # define FOPEN_WB "wb"
5495 # ifndef DIR_SEPARATOR_2
5496 # define DIR_SEPARATOR_2 '\\'
5498 # ifndef PATH_SEPARATOR_2
5499 # define PATH_SEPARATOR_2 ';'
5503 #ifndef DIR_SEPARATOR_2
5504 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
5505 #else /* DIR_SEPARATOR_2 */
5506 # define IS_DIR_SEPARATOR(ch) \
5507 (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
5508 #endif /* DIR_SEPARATOR_2 */
5510 #ifndef PATH_SEPARATOR_2
5511 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
5512 #else /* PATH_SEPARATOR_2 */
5513 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
5514 #endif /* PATH_SEPARATOR_2 */
5517 # define FOPEN_WB "w"
5520 # define _O_BINARY 0
5523 #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
5524 #define XFREE(stale) do { \
5525 if (stale) { free (stale); stale = 0; } \
5528 #if defined LT_DEBUGWRAPPER
5529 static int lt_debug = 1;
5531 static int lt_debug = 0;
5534 const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
5536 void *xmalloc (size_t num);
5537 char *xstrdup (const char *string);
5538 const char *base_name (const char *name);
5539 char *find_executable (const char *wrapper);
5540 char *chase_symlinks (const char *pathspec);
5541 int make_executable (const char *path);
5542 int check_executable (const char *path);
5543 char *strendzap (char *str, const char *pat);
5544 void lt_debugprintf (const char *file, int line, const char *fmt, ...);
5545 void lt_fatal (const char *file, int line, const char *message, ...);
5546 static const char *nonnull (const char *s);
5547 static const char *nonempty (const char *s);
5548 void lt_setenv (const char *name, const char *value);
5549 char *lt_extend_str (const char *orig_value, const char *add, int to_end);
5550 void lt_update_exe_path (const char *name, const char *value);
5551 void lt_update_lib_path (const char *name, const char *value);
5552 char **prepare_spawn (char **argv);
5553 void lt_dump_script (FILE *f);
5557 volatile const char * MAGIC_EXE = "$magic_exe";
5558 const char * LIB_PATH_VARNAME = "$shlibpath_var";
5561 if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
5562 func_to_host_path "$temp_rpath"
5564 const char * LIB_PATH_VALUE = "$func_to_host_path_result";
5568 const char * LIB_PATH_VALUE = "";
5572 if test -n "$dllsearchpath"; then
5573 func_to_host_path "$dllsearchpath:"
5575 const char * EXE_PATH_VARNAME = "PATH";
5576 const char * EXE_PATH_VALUE = "$func_to_host_path_result";
5580 const char * EXE_PATH_VARNAME = "";
5581 const char * EXE_PATH_VALUE = "";
5585 if test yes = "$fast_install"; then
5587 const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
5591 const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
5598 #define LTWRAPPER_OPTION_PREFIX "--lt-"
5600 static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
5601 static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script";
5602 static const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug";
5605 main (int argc, char *argv[])
5610 char *actual_cwrapper_path;
5611 char *actual_cwrapper_name;
5618 program_name = (char *) xstrdup (base_name (argv[0]));
5619 newargz = XMALLOC (char *, (size_t) argc + 1);
5621 /* very simple arg parsing; don't want to rely on getopt
5622 * also, copy all non cwrapper options to newargz, except
5623 * argz[0], which is handled differently
5626 for (i = 1; i < argc; i++)
5628 if (STREQ (argv[i], dumpscript_opt))
5632 *mingw* | *cygwin* )
5633 # make stdout use "unix" line endings
5634 echo " setmode(1,_O_BINARY);"
5639 lt_dump_script (stdout);
5642 if (STREQ (argv[i], debug_opt))
5647 if (STREQ (argv[i], ltwrapper_option_prefix))
5649 /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
5650 namespace, but it is not one of the ones we know about and
5651 have already dealt with, above (inluding dump-script), then
5652 report an error. Otherwise, targets might begin to believe
5653 they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
5654 namespace. The first time any user complains about this, we'll
5655 need to make LTWRAPPER_OPTION_PREFIX a configure-time option
5656 or a configure.ac-settable value.
5658 lt_fatal (__FILE__, __LINE__,
5659 "unrecognized %s option: '%s'",
5660 ltwrapper_option_prefix, argv[i]);
5663 newargz[++newargc] = xstrdup (argv[i]);
5665 newargz[++newargc] = NULL;
5669 /* The GNU banner must be the first non-error debug message */
5670 lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
5673 lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
5674 lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
5676 tmp_pathspec = find_executable (argv[0]);
5677 if (tmp_pathspec == NULL)
5678 lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
5679 lt_debugprintf (__FILE__, __LINE__,
5680 "(main) found exe (before symlink chase) at: %s\n",
5683 actual_cwrapper_path = chase_symlinks (tmp_pathspec);
5684 lt_debugprintf (__FILE__, __LINE__,
5685 "(main) found exe (after symlink chase) at: %s\n",
5686 actual_cwrapper_path);
5687 XFREE (tmp_pathspec);
5689 actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
5690 strendzap (actual_cwrapper_path, actual_cwrapper_name);
5692 /* wrapper name transforms */
5693 strendzap (actual_cwrapper_name, ".exe");
5694 tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
5695 XFREE (actual_cwrapper_name);
5696 actual_cwrapper_name = tmp_pathspec;
5699 /* target_name transforms -- use actual target program name; might have lt- prefix */
5700 target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
5701 strendzap (target_name, ".exe");
5702 tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
5703 XFREE (target_name);
5704 target_name = tmp_pathspec;
5707 lt_debugprintf (__FILE__, __LINE__,
5708 "(main) libtool target name: %s\n",
5714 XMALLOC (char, (strlen (actual_cwrapper_path) +
5715 strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
5716 strcpy (newargz[0], actual_cwrapper_path);
5717 strcat (newargz[0], "$objdir");
5718 strcat (newargz[0], "/");
5722 /* stop here, and copy so we don't have to do this twice */
5723 tmp_pathspec = xstrdup (newargz[0]);
5725 /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
5726 strcat (newargz[0], actual_cwrapper_name);
5728 /* DO want the lt- prefix here if it exists, so use target_name */
5729 lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
5730 XFREE (tmp_pathspec);
5731 tmp_pathspec = NULL;
5739 while ((p = strchr (newargz[0], '\\')) != NULL)
5743 while ((p = strchr (lt_argv_zero, '\\')) != NULL)
5753 XFREE (target_name);
5754 XFREE (actual_cwrapper_path);
5755 XFREE (actual_cwrapper_name);
5757 lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
5758 lt_setenv ("DUALCASE", "1"); /* for MSK sh */
5759 /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must
5760 be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
5761 because on Windows, both *_VARNAMEs are PATH but uninstalled
5762 libraries must come first. */
5763 lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
5764 lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
5766 lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
5767 nonnull (lt_argv_zero));
5768 for (i = 0; i < newargc; i++)
5770 lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
5771 i, nonnull (newargz[i]));
5779 /* execv doesn't actually work on mingw as expected on unix */
5780 newargz = prepare_spawn (newargz);
5781 rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
5784 /* failed to start process */
5785 lt_debugprintf (__FILE__, __LINE__,
5786 "(main) failed to launch target \"%s\": %s\n",
5787 lt_argv_zero, nonnull (strerror (errno)));
5795 execv (lt_argv_zero, newargz);
5796 return rval; /* =127, but avoids unused variable warning */
5805 xmalloc (size_t num)
5807 void *p = (void *) malloc (num);
5809 lt_fatal (__FILE__, __LINE__, "memory exhausted");
5815 xstrdup (const char *string)
5817 return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
5822 base_name (const char *name)
5826 #if defined HAVE_DOS_BASED_FILE_SYSTEM
5827 /* Skip over the disk name in MSDOS pathnames. */
5828 if (isalpha ((unsigned char) name[0]) && name[1] == ':')
5832 for (base = name; *name; name++)
5833 if (IS_DIR_SEPARATOR (*name))
5839 check_executable (const char *path)
5843 lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
5845 if ((!path) || (!*path))
5848 if ((stat (path, &st) >= 0)
5849 && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
5856 make_executable (const char *path)
5861 lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
5863 if ((!path) || (!*path))
5866 if (stat (path, &st) >= 0)
5868 rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
5873 /* Searches for the full path of the wrapper. Returns
5874 newly allocated full path name if found, NULL otherwise
5875 Does not chase symlinks, even on platforms that support them.
5878 find_executable (const char *wrapper)
5883 /* static buffer for getcwd */
5884 char tmp[LT_PATHMAX + 1];
5888 lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
5889 nonempty (wrapper));
5891 if ((wrapper == NULL) || (*wrapper == '\0'))
5894 /* Absolute path? */
5895 #if defined HAVE_DOS_BASED_FILE_SYSTEM
5896 if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
5898 concat_name = xstrdup (wrapper);
5899 if (check_executable (concat_name))
5901 XFREE (concat_name);
5906 if (IS_DIR_SEPARATOR (wrapper[0]))
5908 concat_name = xstrdup (wrapper);
5909 if (check_executable (concat_name))
5911 XFREE (concat_name);
5913 #if defined HAVE_DOS_BASED_FILE_SYSTEM
5917 for (p = wrapper; *p; p++)
5925 /* no slashes; search PATH */
5926 const char *path = getenv ("PATH");
5929 for (p = path; *p; p = p_next)
5933 for (q = p; *q; q++)
5934 if (IS_PATH_SEPARATOR (*q))
5936 p_len = (size_t) (q - p);
5937 p_next = (*q == '\0' ? q : q + 1);
5940 /* empty path: current directory */
5941 if (getcwd (tmp, LT_PATHMAX) == NULL)
5942 lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
5943 nonnull (strerror (errno)));
5944 tmp_len = strlen (tmp);
5946 XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
5947 memcpy (concat_name, tmp, tmp_len);
5948 concat_name[tmp_len] = '/';
5949 strcpy (concat_name + tmp_len + 1, wrapper);
5954 XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
5955 memcpy (concat_name, p, p_len);
5956 concat_name[p_len] = '/';
5957 strcpy (concat_name + p_len + 1, wrapper);
5959 if (check_executable (concat_name))
5961 XFREE (concat_name);
5964 /* not found in PATH; assume curdir */
5966 /* Relative path | not found in path: prepend cwd */
5967 if (getcwd (tmp, LT_PATHMAX) == NULL)
5968 lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
5969 nonnull (strerror (errno)));
5970 tmp_len = strlen (tmp);
5971 concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
5972 memcpy (concat_name, tmp, tmp_len);
5973 concat_name[tmp_len] = '/';
5974 strcpy (concat_name + tmp_len + 1, wrapper);
5976 if (check_executable (concat_name))
5978 XFREE (concat_name);
5983 chase_symlinks (const char *pathspec)
5986 return xstrdup (pathspec);
5988 char buf[LT_PATHMAX];
5990 char *tmp_pathspec = xstrdup (pathspec);
5992 int has_symlinks = 0;
5993 while (strlen (tmp_pathspec) && !has_symlinks)
5995 lt_debugprintf (__FILE__, __LINE__,
5996 "checking path component for symlinks: %s\n",
5998 if (lstat (tmp_pathspec, &s) == 0)
6000 if (S_ISLNK (s.st_mode) != 0)
6006 /* search backwards for last DIR_SEPARATOR */
6007 p = tmp_pathspec + strlen (tmp_pathspec) - 1;
6008 while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
6010 if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
6012 /* no more DIR_SEPARATORS left */
6019 lt_fatal (__FILE__, __LINE__,
6020 "error accessing file \"%s\": %s",
6021 tmp_pathspec, nonnull (strerror (errno)));
6024 XFREE (tmp_pathspec);
6028 return xstrdup (pathspec);
6031 tmp_pathspec = realpath (pathspec, buf);
6032 if (tmp_pathspec == 0)
6034 lt_fatal (__FILE__, __LINE__,
6035 "could not follow symlinks for %s", pathspec);
6037 return xstrdup (tmp_pathspec);
6042 strendzap (char *str, const char *pat)
6046 assert (str != NULL);
6047 assert (pat != NULL);
6050 patlen = strlen (pat);
6054 str += len - patlen;
6055 if (STREQ (str, pat))
6062 lt_debugprintf (const char *file, int line, const char *fmt, ...)
6067 (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
6068 va_start (args, fmt);
6069 (void) vfprintf (stderr, fmt, args);
6075 lt_error_core (int exit_status, const char *file,
6076 int line, const char *mode,
6077 const char *message, va_list ap)
6079 fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
6080 vfprintf (stderr, message, ap);
6081 fprintf (stderr, ".\n");
6083 if (exit_status >= 0)
6088 lt_fatal (const char *file, int line, const char *message, ...)
6091 va_start (ap, message);
6092 lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
6097 nonnull (const char *s)
6099 return s ? s : "(null)";
6103 nonempty (const char *s)
6105 return (s && !*s) ? "(empty)" : nonnull (s);
6109 lt_setenv (const char *name, const char *value)
6111 lt_debugprintf (__FILE__, __LINE__,
6112 "(lt_setenv) setting '%s' to '%s'\n",
6113 nonnull (name), nonnull (value));
6116 /* always make a copy, for consistency with !HAVE_SETENV */
6117 char *str = xstrdup (value);
6118 setenv (name, str, 1);
6120 size_t len = strlen (name) + 1 + strlen (value) + 1;
6121 char *str = XMALLOC (char, len);
6122 sprintf (str, "%s=%s", name, value);
6123 if (putenv (str) != EXIT_SUCCESS)
6132 lt_extend_str (const char *orig_value, const char *add, int to_end)
6135 if (orig_value && *orig_value)
6137 size_t orig_value_len = strlen (orig_value);
6138 size_t add_len = strlen (add);
6139 new_value = XMALLOC (char, add_len + orig_value_len + 1);
6142 strcpy (new_value, orig_value);
6143 strcpy (new_value + orig_value_len, add);
6147 strcpy (new_value, add);
6148 strcpy (new_value + add_len, orig_value);
6153 new_value = xstrdup (add);
6159 lt_update_exe_path (const char *name, const char *value)
6161 lt_debugprintf (__FILE__, __LINE__,
6162 "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
6163 nonnull (name), nonnull (value));
6165 if (name && *name && value && *value)
6167 char *new_value = lt_extend_str (getenv (name), value, 0);
6168 /* some systems can't cope with a ':'-terminated path #' */
6169 size_t len = strlen (new_value);
6170 while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
6172 new_value[--len] = '\0';
6174 lt_setenv (name, new_value);
6180 lt_update_lib_path (const char *name, const char *value)
6182 lt_debugprintf (__FILE__, __LINE__,
6183 "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
6184 nonnull (name), nonnull (value));
6186 if (name && *name && value && *value)
6188 char *new_value = lt_extend_str (getenv (name), value, 0);
6189 lt_setenv (name, new_value);
6199 /* Prepares an argument vector before calling spawn().
6200 Note that spawn() does not by itself call the command interpreter
6201 (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
6202 ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
6204 v.dwPlatformId == VER_PLATFORM_WIN32_NT;
6205 }) ? "cmd.exe" : "command.com").
6206 Instead it simply concatenates the arguments, separated by ' ', and calls
6207 CreateProcess(). We must quote the arguments since Win32 CreateProcess()
6208 interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
6210 - Space and tab are interpreted as delimiters. They are not treated as
6211 delimiters if they are surrounded by double quotes: "...".
6212 - Unescaped double quotes are removed from the input. Their only effect is
6213 that within double quotes, space and tab are treated like normal
6215 - Backslashes not followed by double quotes are not special.
6216 - But 2*n+1 backslashes followed by a double quote become
6217 n backslashes followed by a double quote (n >= 0):
6222 #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"
6223 #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"
6225 prepare_spawn (char **argv)
6231 /* Count number of arguments. */
6232 for (argc = 0; argv[argc] != NULL; argc++)
6235 /* Allocate new argument vector. */
6236 new_argv = XMALLOC (char *, argc + 1);
6238 /* Put quoted arguments into the new argument vector. */
6239 for (i = 0; i < argc; i++)
6241 const char *string = argv[i];
6243 if (string[0] == '\0')
6244 new_argv[i] = xstrdup ("\"\"");
6245 else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
6247 int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
6249 unsigned int backslashes;
6251 char *quoted_string;
6258 for (s = string; *s != '\0'; s++)
6262 length += backslashes + 1;
6270 length += backslashes + 1;
6272 quoted_string = XMALLOC (char, length + 1);
6278 for (s = string; *s != '\0'; s++)
6284 for (j = backslashes + 1; j > 0; j--)
6296 for (j = backslashes; j > 0; j--)
6302 new_argv[i] = quoted_string;
6305 new_argv[i] = (char *) string;
6307 new_argv[argc] = NULL;
6316 void lt_dump_script (FILE* f)
6319 func_emit_wrapper yes |
6321 s/^\(.\{79\}\)\(..*\)/\1\
6326 s/\([^\n]*\).*/ fputs ("\1", f);/p
6333 # end: func_emit_cwrapperexe_src
6335 # func_win32_import_lib_p ARG
6336 # True if ARG is an import lib, as indicated by $file_magic_cmd
6337 func_win32_import_lib_p ()
6341 case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
6347 # func_mode_link arg...
6353 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
6354 # It is impossible to link a dll without this setting, and
6355 # we shouldn't force the makefile maintainer to figure out
6356 # what system we are compiling for in order to pass an extra
6357 # flag for every libtool invocation.
6358 # allow_undefined=no
6360 # FIXME: Unfortunately, there are problems with the above when trying
6361 # to make a dll that has undefined symbols, in which case not
6362 # even a static library is built. For now, we need to specify
6363 # -no-undefined on the libtool link line when we can be certain
6364 # that all symbols are satisfied, otherwise we get a static library.
6371 libtool_args=$nonopt
6372 base_compile="$nonopt $@"
6373 compile_command=$nonopt
6374 finalize_command=$nonopt
6387 lib_search_path=`pwd`
6389 new_inherited_linker_flags=
6398 export_symbols_regex=
6406 precious_files_regex=
6407 prefer_static_libs=no
6420 single_module=$wl-single_module
6421 func_infer_tag $base_compile
6423 # We need to know -static, to get the right output filenames.
6428 test yes != "$build_libtool_libs" \
6429 && func_fatal_configuration "cannot build a shared library"
6433 -all-static | -static | -static-libtool-libs)
6436 if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
6437 func_warning "complete static linking is impossible in this configuration"
6439 if test -n "$link_static_flag"; then
6440 dlopen_self=$dlopen_self_static
6442 prefer_static_libs=yes
6445 if test -z "$pic_flag" && test -n "$link_static_flag"; then
6446 dlopen_self=$dlopen_self_static
6448 prefer_static_libs=built
6450 -static-libtool-libs)
6451 if test -z "$pic_flag" && test -n "$link_static_flag"; then
6452 dlopen_self=$dlopen_self_static
6454 prefer_static_libs=yes
6457 build_libtool_libs=no
6464 # See if our shared archives depend on static archives.
6465 test -n "$old_archive_from_new_cmds" && build_old_libs=yes
6467 # Go through the arguments, transforming them on the way.
6468 while test "$#" -gt 0; do
6471 func_quote_for_eval "$arg"
6472 qarg=$func_quote_for_eval_unquoted_result
6473 func_append libtool_args " $func_quote_for_eval_result"
6475 # If the previous option needs an argument, assign it.
6476 if test -n "$prev"; then
6479 func_append compile_command " @OUTPUT@"
6480 func_append finalize_command " @OUTPUT@"
6492 # Add the symbol object into the linking commands.
6493 func_append compile_command " @SYMFILE@"
6494 func_append finalize_command " @SYMFILE@"
6498 *.la | *.lo) ;; # We handle these cases below.
6500 if test no = "$dlself"; then
6508 if test dlprefiles = "$prev"; then
6510 elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
6520 if test dlfiles = "$prev"; then
6521 func_append dlfiles " $arg"
6523 func_append dlprefiles " $arg"
6533 || func_fatal_error "symbol file '$arg' does not exist"
6538 export_symbols_regex=$arg
6546 *" $qarg.ltframework "*) ;;
6547 *) func_append deplibs " $qarg.ltframework" # this is fixed later
6556 inst_prefix_dir=$arg
6561 # Clang does not use LLVM to link, so we can simply discard any
6562 # '-mllvm $arg' options when doing the link step.
6567 if test -f "$arg"; then
6570 for fil in `cat "$save_arg"`
6572 # func_append moreargs " $fil"
6574 # A libtool-controlled object.
6576 # Check to see that this really is a libtool object.
6577 if func_lalib_unsafe_p "$arg"; then
6584 if test -z "$pic_object" ||
6585 test -z "$non_pic_object" ||
6586 test none = "$pic_object" &&
6587 test none = "$non_pic_object"; then
6588 func_fatal_error "cannot find name of object for '$arg'"
6591 # Extract subdirectory from the argument.
6592 func_dirname "$arg" "/" ""
6593 xdir=$func_dirname_result
6595 if test none != "$pic_object"; then
6596 # Prepend the subdirectory the object is found in.
6597 pic_object=$xdir$pic_object
6599 if test dlfiles = "$prev"; then
6600 if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
6601 func_append dlfiles " $pic_object"
6605 # If libtool objects are unsupported, then we need to preload.
6610 # CHECK ME: I think I busted this. -Ossama
6611 if test dlprefiles = "$prev"; then
6612 # Preload the old-style object.
6613 func_append dlprefiles " $pic_object"
6618 func_append libobjs " $pic_object"
6623 if test none != "$non_pic_object"; then
6624 # Prepend the subdirectory the object is found in.
6625 non_pic_object=$xdir$non_pic_object
6627 # A standard non-PIC object
6628 func_append non_pic_objects " $non_pic_object"
6629 if test -z "$pic_object" || test none = "$pic_object"; then
6633 # If the PIC object exists, use it instead.
6634 # $xdir was prepended to $pic_object above.
6635 non_pic_object=$pic_object
6636 func_append non_pic_objects " $non_pic_object"
6639 # Only an error if not doing a dry-run.
6640 if $opt_dry_run; then
6641 # Extract subdirectory from the argument.
6642 func_dirname "$arg" "/" ""
6643 xdir=$func_dirname_result
6646 pic_object=$xdir$objdir/$func_lo2o_result
6647 non_pic_object=$xdir$func_lo2o_result
6648 func_append libobjs " $pic_object"
6649 func_append non_pic_objects " $non_pic_object"
6651 func_fatal_error "'$arg' is not a valid libtool object"
6656 func_fatal_error "link input file '$arg' does not exist"
6663 precious_files_regex=$arg
6673 # We need an absolute path.
6675 [\\/]* | [A-Za-z]:[\\/]*) ;;
6677 func_fatal_error "only absolute run-paths are allowed"
6680 if test rpath = "$prev"; then
6683 *) func_append rpath " $arg" ;;
6688 *) func_append xrpath " $arg" ;;
6700 func_append weak_libs " $arg"
6705 func_append linker_flags " $qarg"
6706 func_append compiler_flags " $qarg"
6708 func_append compile_command " $qarg"
6709 func_append finalize_command " $qarg"
6713 func_append compiler_flags " $qarg"
6715 func_append compile_command " $qarg"
6716 func_append finalize_command " $qarg"
6720 func_append linker_flags " $qarg"
6721 func_append compiler_flags " $wl$qarg"
6723 func_append compile_command " $wl$qarg"
6724 func_append finalize_command " $wl$qarg"
6728 eval "$prev=\"\$arg\""
6733 fi # test -n "$prev"
6739 if test -n "$link_static_flag"; then
6740 # See comment for -static flag below, for more details.
6741 func_append compile_command " $link_static_flag"
6742 func_append finalize_command " $link_static_flag"
6748 # FIXME: remove this flag sometime in the future.
6749 func_fatal_error "'-allow-undefined' must not be used because it is the default"
6777 -export-symbols | -export-symbols-regex)
6778 if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
6779 func_fatal_error "more than one -exported-symbols argument is not allowed"
6781 if test X-export-symbols = "X$arg"; then
6799 # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
6800 # so, if we see these flags be careful not to treat them like -L
6802 case $with_gcc/$host in
6803 no/*-*-irix* | /*-*-irix*)
6804 func_append compile_command " $arg"
6805 func_append finalize_command " $arg"
6812 func_stripname "-L" '' "$arg"
6813 if test -z "$func_stripname_result"; then
6814 if test "$#" -gt 0; then
6815 func_fatal_error "require no space between '-L' and '$1'"
6817 func_fatal_error "need path for '-L' option"
6820 func_resolve_sysroot "$func_stripname_result"
6821 dir=$func_resolve_sysroot_result
6822 # We need an absolute path.
6824 [\\/]* | [A-Za-z]:[\\/]*) ;;
6826 absdir=`cd "$dir" && pwd`
6827 test -z "$absdir" && \
6828 func_fatal_error "cannot determine absolute directory name of '$dir'"
6833 *" -L$dir "* | *" $arg "*)
6834 # Will only happen for absolute or sysroot arguments
6837 # Preserve sysroot, but never include relative directories
6839 [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
6840 *) func_append deplibs " -L$dir" ;;
6842 func_append lib_search_path " $dir"
6846 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
6847 testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
6848 case :$dllsearchpath: in
6850 ::) dllsearchpath=$dir;;
6851 *) func_append dllsearchpath ":$dir";;
6853 case :$dllsearchpath: in
6854 *":$testbindir:"*) ;;
6855 ::) dllsearchpath=$testbindir;;
6856 *) func_append dllsearchpath ":$testbindir";;
6864 if test X-lc = "X$arg" || test X-lm = "X$arg"; then
6866 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
6867 # These systems don't actually have a C or math library (as such)
6871 # These systems don't actually have a C library (as such)
6872 test X-lc = "X$arg" && continue
6874 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
6875 # Do not include libc due to us having libc/libc_r.
6876 test X-lc = "X$arg" && continue
6878 *-*-rhapsody* | *-*-darwin1.[012])
6879 # Rhapsody C and math libraries are in the System framework
6880 func_append deplibs " System.ltframework"
6883 *-*-sco3.2v5* | *-*-sco5v6*)
6884 # Causes problems with __ctype
6885 test X-lc = "X$arg" && continue
6887 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
6888 # Compiler inserts libc in the correct place for threads to work
6889 test X-lc = "X$arg" && continue
6892 elif test X-lc_r = "X$arg"; then
6894 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
6895 # Do not include libc_r directly, use -pthread flag.
6900 func_append deplibs " $arg"
6914 # Tru64 UNIX uses -model [arg] to determine the layout of C++
6915 # classes, name mangling, and exception handling.
6916 # Darwin uses the -arch flag to determine output architecture.
6917 -model|-arch|-isysroot|--sysroot)
6918 func_append compiler_flags " $arg"
6919 func_append compile_command " $arg"
6920 func_append finalize_command " $arg"
6925 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
6926 |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
6927 func_append compiler_flags " $arg"
6928 func_append compile_command " $arg"
6929 func_append finalize_command " $arg"
6930 case "$new_inherited_linker_flags " in
6932 * ) func_append new_inherited_linker_flags " $arg" ;;
6938 single_module=$wl-multi_module
6949 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
6950 # The PATH hackery in wrapper scripts is required on Windows
6951 # and Darwin in order for the loader to find any dlls it needs.
6952 func_warning "'-no-install' is ignored for $host"
6953 func_warning "assuming '-no-fast-install' instead"
6956 *) no_install=yes ;;
6973 -precious-files-regex)
6994 func_stripname '-R' '' "$arg"
6995 dir=$func_stripname_result
6996 # We need an absolute path.
6998 [\\/]* | [A-Za-z]:[\\/]*) ;;
7000 func_stripname '=' '' "$dir"
7001 dir=$lt_sysroot$func_stripname_result
7004 func_fatal_error "only absolute run-paths are allowed"
7009 *) func_append xrpath " $dir" ;;
7015 # The effects of -shared are defined in a previous loop.
7024 -static | -static-libtool-libs)
7025 # The effects of -static are defined in a previous loop.
7026 # We used to do the same as -all-static on platforms that
7027 # didn't have a PIC flag, but the assumption that the effects
7028 # would be equivalent was wrong. It would break on at least
7029 # Digital Unix and AIX.
7055 func_stripname '-Wc,' '' "$arg"
7056 args=$func_stripname_result
7058 save_ifs=$IFS; IFS=,
7059 for flag in $args; do
7061 func_quote_for_eval "$flag"
7062 func_append arg " $func_quote_for_eval_result"
7063 func_append compiler_flags " $func_quote_for_eval_result"
7066 func_stripname ' ' '' "$arg"
7067 arg=$func_stripname_result
7071 func_stripname '-Wl,' '' "$arg"
7072 args=$func_stripname_result
7074 save_ifs=$IFS; IFS=,
7075 for flag in $args; do
7077 func_quote_for_eval "$flag"
7078 func_append arg " $wl$func_quote_for_eval_result"
7079 func_append compiler_flags " $wl$func_quote_for_eval_result"
7080 func_append linker_flags " $func_quote_for_eval_result"
7083 func_stripname ' ' '' "$arg"
7084 arg=$func_stripname_result
7104 func_quote_for_eval "$arg"
7105 arg=$func_quote_for_eval_result
7108 # Flags to be passed through unchanged, with rationale:
7109 # -64, -mips[0-9] enable 64-bit mode for the SGI compiler
7110 # -r[0-9][0-9]* specify processor for the SGI compiler
7111 # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
7112 # +DA*, +DD* enable 64-bit mode for the HP compiler
7113 # -q* compiler args for the IBM compiler
7114 # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
7115 # -F/path path to uninstalled frameworks, gcc on darwin
7116 # -p, -pg, --coverage, -fprofile-* profiling flags for GCC
7117 # @file GCC response files
7118 # -tp=* Portland pgcc target processor selection
7119 # --sysroot=* for sysroot support
7120 # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
7121 # -stdlib=* select c++ std lib with clang
7122 -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
7123 -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
7124 -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-stdlib=*)
7125 func_quote_for_eval "$arg"
7126 arg=$func_quote_for_eval_result
7127 func_append compile_command " $arg"
7128 func_append finalize_command " $arg"
7129 func_append compiler_flags " $arg"
7133 # Some other compiler flag.
7135 func_quote_for_eval "$arg"
7136 arg=$func_quote_for_eval_result
7140 # A standard object.
7141 func_append objs " $arg"
7145 # A libtool-controlled object.
7147 # Check to see that this really is a libtool object.
7148 if func_lalib_unsafe_p "$arg"; then
7155 if test -z "$pic_object" ||
7156 test -z "$non_pic_object" ||
7157 test none = "$pic_object" &&
7158 test none = "$non_pic_object"; then
7159 func_fatal_error "cannot find name of object for '$arg'"
7162 # Extract subdirectory from the argument.
7163 func_dirname "$arg" "/" ""
7164 xdir=$func_dirname_result
7166 test none = "$pic_object" || {
7167 # Prepend the subdirectory the object is found in.
7168 pic_object=$xdir$pic_object
7170 if test dlfiles = "$prev"; then
7171 if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
7172 func_append dlfiles " $pic_object"
7176 # If libtool objects are unsupported, then we need to preload.
7181 # CHECK ME: I think I busted this. -Ossama
7182 if test dlprefiles = "$prev"; then
7183 # Preload the old-style object.
7184 func_append dlprefiles " $pic_object"
7189 func_append libobjs " $pic_object"
7194 if test none != "$non_pic_object"; then
7195 # Prepend the subdirectory the object is found in.
7196 non_pic_object=$xdir$non_pic_object
7198 # A standard non-PIC object
7199 func_append non_pic_objects " $non_pic_object"
7200 if test -z "$pic_object" || test none = "$pic_object"; then
7204 # If the PIC object exists, use it instead.
7205 # $xdir was prepended to $pic_object above.
7206 non_pic_object=$pic_object
7207 func_append non_pic_objects " $non_pic_object"
7210 # Only an error if not doing a dry-run.
7211 if $opt_dry_run; then
7212 # Extract subdirectory from the argument.
7213 func_dirname "$arg" "/" ""
7214 xdir=$func_dirname_result
7217 pic_object=$xdir$objdir/$func_lo2o_result
7218 non_pic_object=$xdir$func_lo2o_result
7219 func_append libobjs " $pic_object"
7220 func_append non_pic_objects " $non_pic_object"
7222 func_fatal_error "'$arg' is not a valid libtool object"
7229 func_append deplibs " $arg"
7230 func_append old_deplibs " $arg"
7235 # A libtool-controlled library.
7237 func_resolve_sysroot "$arg"
7238 if test dlfiles = "$prev"; then
7239 # This library was specified with -dlopen.
7240 func_append dlfiles " $func_resolve_sysroot_result"
7242 elif test dlprefiles = "$prev"; then
7243 # The library was specified with -dlpreopen.
7244 func_append dlprefiles " $func_resolve_sysroot_result"
7247 func_append deplibs " $func_resolve_sysroot_result"
7252 # Some other compiler argument.
7254 # Unknown arguments in both finalize_command and compile_command need
7255 # to be aesthetically quoted because they are evaled later.
7256 func_quote_for_eval "$arg"
7257 arg=$func_quote_for_eval_result
7261 # Now actually substitute the argument into the commands.
7262 if test -n "$arg"; then
7263 func_append compile_command " $arg"
7264 func_append finalize_command " $arg"
7266 done # argument parsing loop
7268 test -n "$prev" && \
7269 func_fatal_help "the '$prevarg' option requires an argument"
7271 if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
7272 eval arg=\"$export_dynamic_flag_spec\"
7273 func_append compile_command " $arg"
7274 func_append finalize_command " $arg"
7278 # calculate the name of the file, without its directory
7279 func_basename "$output"
7280 outputname=$func_basename_result
7281 libobjs_save=$libobjs
7283 if test -n "$shlibpath_var"; then
7284 # get the directories listed in $shlibpath_var
7285 eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
7289 eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
7290 eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
7292 func_dirname "$output" "/" ""
7293 output_objdir=$func_dirname_result$objdir
7294 func_to_tool_file "$output_objdir/"
7295 tool_output_objdir=$func_to_tool_file_result
7296 # Create the object directory.
7297 func_mkdir_p "$output_objdir"
7299 # Determine the type of output
7302 func_fatal_help "you must specify an output file"
7304 *.$libext) linkmode=oldlib ;;
7305 *.lo | *.$objext) linkmode=obj ;;
7306 *.la) linkmode=lib ;;
7307 *) linkmode=prog ;; # Anything else should be a program.
7313 # Find all interdependent deplibs by searching for libraries
7314 # that are linked more than once (e.g. -la -lb -la)
7315 for deplib in $deplibs; do
7316 if $opt_preserve_dup_deps; then
7318 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
7321 func_append libs " $deplib"
7324 if test lib = "$linkmode"; then
7325 libs="$predeps $libs $compiler_lib_search_path $postdeps"
7327 # Compute libraries that are listed more than once in $predeps
7328 # $postdeps and mark them as special (i.e., whose duplicates are
7329 # not to be eliminated).
7331 if $opt_duplicate_compiler_generated_deps; then
7332 for pre_post_dep in $predeps $postdeps; do
7333 case "$pre_post_deps " in
7334 *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
7336 func_append pre_post_deps " $pre_post_dep"
7345 need_relink=no # whether we're linking any uninstalled libtool libraries
7346 notinst_deplibs= # not-installed libtool libraries
7347 notinst_path= # paths that contain not-installed libtool libraries
7351 passes="conv dlpreopen link"
7352 for file in $dlfiles $dlprefiles; do
7356 func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
7367 passes="conv scan dlopen dlpreopen link"
7373 for pass in $passes; do
7374 # The preopen pass in lib mode reverses $deplibs; put it back here
7375 # so that -L comes before libs that need it for instance...
7376 if test lib,link = "$linkmode,$pass"; then
7377 ## FIXME: Find the place where the list is rebuilt in the wrong
7378 ## order, and fix it there properly
7380 for deplib in $deplibs; do
7381 tmp_deplibs="$deplib $tmp_deplibs"
7383 deplibs=$tmp_deplibs
7386 if test lib,link = "$linkmode,$pass" ||
7387 test prog,scan = "$linkmode,$pass"; then
7391 if test prog = "$linkmode"; then
7393 dlopen) libs=$dlfiles ;;
7394 dlpreopen) libs=$dlprefiles ;;
7395 link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
7398 if test lib,dlpreopen = "$linkmode,$pass"; then
7399 # Collect and forward deplibs of preopened libtool libs
7400 for lib in $dlprefiles; do
7401 # Ignore non-libtool-libs
7403 func_resolve_sysroot "$lib"
7405 *.la) func_source "$func_resolve_sysroot_result" ;;
7408 # Collect preopened libtool deplibs, except any this library
7409 # has declared as weak libs
7410 for deplib in $dependency_libs; do
7411 func_basename "$deplib"
7412 deplib_base=$func_basename_result
7413 case " $weak_libs " in
7414 *" $deplib_base "*) ;;
7415 *) func_append deplibs " $deplib" ;;
7421 if test dlopen = "$pass"; then
7422 # Collect dlpreopened libraries
7423 save_deplibs=$deplibs
7427 for deplib in $libs; do
7431 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
7432 |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
7433 if test prog,link = "$linkmode,$pass"; then
7434 compile_deplibs="$deplib $compile_deplibs"
7435 finalize_deplibs="$deplib $finalize_deplibs"
7437 func_append compiler_flags " $deplib"
7438 if test lib = "$linkmode"; then
7439 case "$new_inherited_linker_flags " in
7441 * ) func_append new_inherited_linker_flags " $deplib" ;;
7448 if test lib != "$linkmode" && test prog != "$linkmode"; then
7449 func_warning "'-l' is ignored for archives/objects"
7452 func_stripname '-l' '' "$deplib"
7453 name=$func_stripname_result
7454 if test lib = "$linkmode"; then
7455 searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
7457 searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
7459 for searchdir in $searchdirs; do
7460 for search_ext in .la $std_shrext .so .a; do
7461 # Search the libtool library
7462 lib=$searchdir/lib$name$search_ext
7463 if test -f "$lib"; then
7464 if test .la = "$search_ext"; then
7474 # deplib is a libtool library
7475 # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
7476 # We need to do some special things here, and not later.
7477 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
7478 case " $predeps $postdeps " in
7480 if func_lalib_p "$lib"; then
7484 for l in $old_library $library_names; do
7487 if test "X$ll" = "X$old_library"; then # only static version available
7489 func_dirname "$lib" "" "."
7490 ladir=$func_dirname_result
7491 lib=$ladir/$old_library
7492 if test prog,link = "$linkmode,$pass"; then
7493 compile_deplibs="$deplib $compile_deplibs"
7494 finalize_deplibs="$deplib $finalize_deplibs"
7496 deplibs="$deplib $deplibs"
7497 test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
7507 # deplib doesn't seem to be a libtool library
7508 if test prog,link = "$linkmode,$pass"; then
7509 compile_deplibs="$deplib $compile_deplibs"
7510 finalize_deplibs="$deplib $finalize_deplibs"
7512 deplibs="$deplib $deplibs"
7513 test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
7519 if test prog,link = "$linkmode,$pass"; then
7520 compile_deplibs="$deplib $compile_deplibs"
7521 finalize_deplibs="$deplib $finalize_deplibs"
7523 deplibs="$deplib $deplibs"
7524 if test lib = "$linkmode"; then
7525 case "$new_inherited_linker_flags " in
7527 * ) func_append new_inherited_linker_flags " $deplib" ;;
7536 deplibs="$deplib $deplibs"
7537 test conv = "$pass" && continue
7538 newdependency_libs="$deplib $newdependency_libs"
7539 func_stripname '-L' '' "$deplib"
7540 func_resolve_sysroot "$func_stripname_result"
7541 func_append newlib_search_path " $func_resolve_sysroot_result"
7544 if test conv = "$pass"; then
7545 deplibs="$deplib $deplibs"
7548 if test scan = "$pass"; then
7549 deplibs="$deplib $deplibs"
7551 compile_deplibs="$deplib $compile_deplibs"
7552 finalize_deplibs="$deplib $finalize_deplibs"
7554 func_stripname '-L' '' "$deplib"
7555 func_resolve_sysroot "$func_stripname_result"
7556 func_append newlib_search_path " $func_resolve_sysroot_result"
7559 func_warning "'-L' is ignored for archives/objects"
7565 if test link = "$pass"; then
7566 func_stripname '-R' '' "$deplib"
7567 func_resolve_sysroot "$func_stripname_result"
7568 dir=$func_resolve_sysroot_result
7569 # Make sure the xrpath contains only unique directories.
7572 *) func_append xrpath " $dir" ;;
7575 deplibs="$deplib $deplibs"
7579 func_resolve_sysroot "$deplib"
7580 lib=$func_resolve_sysroot_result
7583 if test conv = "$pass"; then
7584 deplibs="$deplib $deplibs"
7589 # Linking convenience modules into shared libraries is allowed,
7590 # but linking other static libraries is non-portable.
7591 case " $dlpreconveniencelibs " in
7595 case $deplibs_check_method in
7597 set dummy $deplibs_check_method; shift
7598 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7599 if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
7600 | $EGREP "$match_pattern_regex" > /dev/null; then
7608 if $valid_a_lib; then
7610 $ECHO "*** Warning: Linking the shared library $output against the"
7611 $ECHO "*** static library $deplib is not portable!"
7612 deplibs="$deplib $deplibs"
7615 $ECHO "*** Warning: Trying to link with static lib archive $deplib."
7616 echo "*** I have the capability to make that library automatically link in when"
7617 echo "*** you link to this library. But I can only do this if you have a"
7618 echo "*** shared version of the library, which you do not appear to have"
7619 echo "*** because the file extensions .$libext of this argument makes me believe"
7620 echo "*** that it is just a static archive that I should not use here."
7627 if test link != "$pass"; then
7628 deplibs="$deplib $deplibs"
7630 compile_deplibs="$deplib $compile_deplibs"
7631 finalize_deplibs="$deplib $finalize_deplibs"
7638 if test conv = "$pass"; then
7639 deplibs="$deplib $deplibs"
7640 elif test prog = "$linkmode"; then
7641 if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
7642 # If there is no dlopen support or we're linking statically,
7643 # we need to preload.
7644 func_append newdlprefiles " $deplib"
7645 compile_deplibs="$deplib $compile_deplibs"
7646 finalize_deplibs="$deplib $finalize_deplibs"
7648 func_append newdlfiles " $deplib"
7659 $found || test -f "$lib" \
7660 || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
7662 # Check to see that this really is a libtool archive.
7663 func_lalib_unsafe_p "$lib" \
7664 || func_fatal_error "'$lib' is not a valid libtool archive"
7666 func_dirname "$lib" "" "."
7667 ladir=$func_dirname_result
7675 inherited_linker_flags=
7676 # If the library was installed with an old release of libtool,
7677 # it will not redefine variables installed, or shouldnotlink
7686 # Convert "-framework foo" to "foo.ltframework"
7687 if test -n "$inherited_linker_flags"; then
7688 tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
7689 for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
7690 case " $new_inherited_linker_flags " in
7691 *" $tmp_inherited_linker_flag "*) ;;
7692 *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
7696 dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7697 if test lib,link = "$linkmode,$pass" ||
7698 test prog,scan = "$linkmode,$pass" ||
7699 { test prog != "$linkmode" && test lib != "$linkmode"; }; then
7700 test -n "$dlopen" && func_append dlfiles " $dlopen"
7701 test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
7704 if test conv = "$pass"; then
7705 # Only check for convenience libraries
7706 deplibs="$lib $deplibs"
7707 if test -z "$libdir"; then
7708 if test -z "$old_library"; then
7709 func_fatal_error "cannot find name of link library for '$lib'"
7711 # It is a libtool convenience library, so add in its objects.
7712 func_append convenience " $ladir/$objdir/$old_library"
7713 func_append old_convenience " $ladir/$objdir/$old_library"
7714 elif test prog != "$linkmode" && test lib != "$linkmode"; then
7715 func_fatal_error "'$lib' is not a convenience library"
7718 for deplib in $dependency_libs; do
7719 deplibs="$deplib $deplibs"
7720 if $opt_preserve_dup_deps; then
7721 case "$tmp_libs " in
7722 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
7725 func_append tmp_libs " $deplib"
7731 # Get the name of the library we link against.
7733 if test -n "$old_library" &&
7734 { test yes = "$prefer_static_libs" ||
7735 test built,no = "$prefer_static_libs,$installed"; }; then
7736 linklib=$old_library
7738 for l in $old_library $library_names; do
7742 if test -z "$linklib"; then
7743 func_fatal_error "cannot find name of link library for '$lib'"
7746 # This library was specified with -dlopen.
7747 if test dlopen = "$pass"; then
7749 && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
7750 if test -z "$dlname" ||
7751 test yes != "$dlopen_support" ||
7752 test no = "$build_libtool_libs"
7754 # If there is no dlname, no dlopen support or we're linking
7755 # statically, we need to preload. We also need to preload any
7756 # dependent libraries so libltdl's deplib preloader doesn't
7757 # bomb out in the load deplibs phase.
7758 func_append dlprefiles " $lib $dependency_libs"
7760 func_append newdlfiles " $lib"
7765 # We need an absolute path.
7767 [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
7769 abs_ladir=`cd "$ladir" && pwd`
7770 if test -z "$abs_ladir"; then
7771 func_warning "cannot determine absolute directory name of '$ladir'"
7772 func_warning "passing it literally to the linker, although it might fail"
7777 func_basename "$lib"
7778 laname=$func_basename_result
7780 # Find the relevant object directory and library name.
7781 if test yes = "$installed"; then
7782 if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
7783 func_warning "library '$lib' was moved."
7788 dir=$lt_sysroot$libdir
7789 absdir=$lt_sysroot$libdir
7791 test yes = "$hardcode_automatic" && avoidtemprpath=yes
7793 if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
7796 # Remove this search path later
7797 func_append notinst_path " $abs_ladir"
7800 absdir=$abs_ladir/$objdir
7801 # Remove this search path later
7802 func_append notinst_path " $abs_ladir"
7804 fi # $installed = yes
7805 func_stripname 'lib' '.la' "$laname"
7806 name=$func_stripname_result
7808 # This library was specified with -dlpreopen.
7809 if test dlpreopen = "$pass"; then
7810 if test -z "$libdir" && test prog = "$linkmode"; then
7811 func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
7814 # special handling for platforms with PE-DLLs.
7815 *cygwin* | *mingw* | *cegcc* )
7816 # Linker will automatically link against shared library if both
7817 # static and shared are present. Therefore, ensure we extract
7818 # symbols from the import library if a shared library is present
7819 # (otherwise, the dlopen module name will be incorrect). We do
7820 # this by putting the import library name into $newdlprefiles.
7821 # We recover the dlopen module name by 'saving' the la file
7822 # name in a special purpose variable, and (later) extracting the
7823 # dlname from the la file.
7824 if test -n "$dlname"; then
7825 func_tr_sh "$dir/$linklib"
7826 eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
7827 func_append newdlprefiles " $dir/$linklib"
7829 func_append newdlprefiles " $dir/$old_library"
7830 # Keep a list of preopened convenience libraries to check
7831 # that they are being used correctly in the link pass.
7832 test -z "$libdir" && \
7833 func_append dlpreconveniencelibs " $dir/$old_library"
7837 # Prefer using a static library (so that no silly _DYNAMIC symbols
7838 # are required to link).
7839 if test -n "$old_library"; then
7840 func_append newdlprefiles " $dir/$old_library"
7841 # Keep a list of preopened convenience libraries to check
7842 # that they are being used correctly in the link pass.
7843 test -z "$libdir" && \
7844 func_append dlpreconveniencelibs " $dir/$old_library"
7845 # Otherwise, use the dlname, so that lt_dlopen finds it.
7846 elif test -n "$dlname"; then
7847 func_append newdlprefiles " $dir/$dlname"
7849 func_append newdlprefiles " $dir/$linklib"
7853 fi # $pass = dlpreopen
7855 if test -z "$libdir"; then
7856 # Link the convenience library
7857 if test lib = "$linkmode"; then
7858 deplibs="$dir/$old_library $deplibs"
7859 elif test prog,link = "$linkmode,$pass"; then
7860 compile_deplibs="$dir/$old_library $compile_deplibs"
7861 finalize_deplibs="$dir/$old_library $finalize_deplibs"
7863 deplibs="$lib $deplibs" # used for prog,scan pass
7869 if test prog = "$linkmode" && test link != "$pass"; then
7870 func_append newlib_search_path " $ladir"
7871 deplibs="$lib $deplibs"
7873 linkalldeplibs=false
7874 if test no != "$link_all_deplibs" || test -z "$library_names" ||
7875 test no = "$build_libtool_libs"; then
7880 for deplib in $dependency_libs; do
7882 -L*) func_stripname '-L' '' "$deplib"
7883 func_resolve_sysroot "$func_stripname_result"
7884 func_append newlib_search_path " $func_resolve_sysroot_result"
7887 # Need to link against all dependency_libs?
7888 if $linkalldeplibs; then
7889 deplibs="$deplib $deplibs"
7891 # Need to hardcode shared library paths
7892 # or/and link against static libraries
7893 newdependency_libs="$deplib $newdependency_libs"
7895 if $opt_preserve_dup_deps; then
7896 case "$tmp_libs " in
7897 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
7900 func_append tmp_libs " $deplib"
7903 fi # $linkmode = prog...
7905 if test prog,link = "$linkmode,$pass"; then
7906 if test -n "$library_names" &&
7907 { { test no = "$prefer_static_libs" ||
7908 test built,yes = "$prefer_static_libs,$installed"; } ||
7909 test -z "$old_library"; }; then
7910 # We need to hardcode the library path
7911 if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
7912 # Make sure the rpath contains only unique directories.
7913 case $temp_rpath: in
7915 *) func_append temp_rpath "$absdir:" ;;
7919 # Hardcode the library path.
7920 # Skip directories that are in the system default run-time
7922 case " $sys_lib_dlsearch_path " in
7925 case "$compile_rpath " in
7927 *) func_append compile_rpath " $absdir" ;;
7931 case " $sys_lib_dlsearch_path " in
7934 case "$finalize_rpath " in
7936 *) func_append finalize_rpath " $libdir" ;;
7940 fi # $linkmode,$pass = prog,link...
7943 { test pass_all = "$deplibs_check_method" ||
7944 { test yes = "$build_libtool_libs" &&
7945 test -n "$library_names"; }; }; then
7946 # We only need to search for static libraries
7951 link_static=no # Whether the deplib will be linked statically
7952 use_static_libs=$prefer_static_libs
7953 if test built = "$use_static_libs" && test yes = "$installed"; then
7956 if test -n "$library_names" &&
7957 { test no = "$use_static_libs" || test -z "$old_library"; }; then
7959 *cygwin* | *mingw* | *cegcc*)
7960 # No point in relinking DLLs because paths are not encoded
7961 func_append notinst_deplibs " $lib"
7965 if test no = "$installed"; then
7966 func_append notinst_deplibs " $lib"
7971 # This is a shared library
7973 # Warn about portability, can't link against -module's on some
7974 # systems (darwin). Don't bleat about dlopened modules though!
7976 for dlpremoduletest in $dlprefiles; do
7977 if test "X$dlpremoduletest" = "X$lib"; then
7978 dlopenmodule=$dlpremoduletest
7982 if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
7984 if test prog = "$linkmode"; then
7985 $ECHO "*** Warning: Linking the executable $output against the loadable module"
7987 $ECHO "*** Warning: Linking the shared library $output against the loadable module"
7989 $ECHO "*** $linklib is not portable!"
7991 if test lib = "$linkmode" &&
7992 test yes = "$hardcode_into_libs"; then
7993 # Hardcode the library path.
7994 # Skip directories that are in the system default run-time
7996 case " $sys_lib_dlsearch_path " in
7999 case "$compile_rpath " in
8001 *) func_append compile_rpath " $absdir" ;;
8005 case " $sys_lib_dlsearch_path " in
8008 case "$finalize_rpath " in
8010 *) func_append finalize_rpath " $libdir" ;;
8016 if test -n "$old_archive_from_expsyms_cmds"; then
8017 # figure out the soname
8018 set dummy $library_names
8022 libname=`eval "\\$ECHO \"$libname_spec\""`
8023 # use dlname if we got it. it's perfectly good, no?
8024 if test -n "$dlname"; then
8026 elif test -n "$soname_spec"; then
8029 *cygwin* | mingw* | *cegcc*)
8030 func_arith $current - $age
8031 major=$func_arith_result
8035 eval soname=\"$soname_spec\"
8040 # Make a new name for the extract_expsyms_cmds to use
8042 func_basename "$soroot"
8043 soname=$func_basename_result
8044 func_stripname 'lib' '.dll' "$soname"
8045 newlib=libimp-$func_stripname_result.a
8047 # If the library has no export list, then create one now
8048 if test -f "$output_objdir/$soname-def"; then :
8050 func_verbose "extracting exported symbol list from '$soname'"
8051 func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
8055 if test -f "$output_objdir/$newlib"; then :; else
8056 func_verbose "generating import library for '$soname'"
8057 func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
8059 # make sure the library variables are pointing to the new library
8062 fi # test -n "$old_archive_from_expsyms_cmds"
8064 if test prog = "$linkmode" || test relink != "$opt_mode"; then
8069 case $hardcode_action in
8070 immediate | unsupported)
8071 if test no = "$hardcode_direct"; then
8074 *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
8075 *-*-sysv4*uw2*) add_dir=-L$dir ;;
8076 *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
8077 *-*-unixware7*) add_dir=-L$dir ;;
8079 # if the lib is a (non-dlopened) module then we cannot
8080 # link against it, someone is ignoring the earlier warnings
8081 if /usr/bin/file -L $add 2> /dev/null |
8082 $GREP ": [^:]* bundle" >/dev/null; then
8083 if test "X$dlopenmodule" != "X$lib"; then
8084 $ECHO "*** Warning: lib $linklib is a module, not a shared library"
8085 if test -z "$old_library"; then
8087 echo "*** And there doesn't seem to be a static archive available"
8088 echo "*** The link will probably fail, sorry"
8090 add=$dir/$old_library
8092 elif test -n "$old_library"; then
8093 add=$dir/$old_library
8097 elif test no = "$hardcode_minus_L"; then
8099 *-*-sunos*) add_shlibpath=$dir ;;
8103 elif test no = "$hardcode_shlibpath_var"; then
8111 if test yes = "$hardcode_direct" &&
8112 test no = "$hardcode_direct_absolute"; then
8114 elif test yes = "$hardcode_minus_L"; then
8116 # Try looking first in the location we're being installed to.
8117 if test -n "$inst_prefix_dir"; then
8120 func_append add_dir " -L$inst_prefix_dir$libdir"
8125 elif test yes = "$hardcode_shlibpath_var"; then
8135 if test yes != "$lib_linked"; then
8136 func_fatal_configuration "unsupported hardcode properties"
8139 if test -n "$add_shlibpath"; then
8140 case :$compile_shlibpath: in
8141 *":$add_shlibpath:"*) ;;
8142 *) func_append compile_shlibpath "$add_shlibpath:" ;;
8145 if test prog = "$linkmode"; then
8146 test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
8147 test -n "$add" && compile_deplibs="$add $compile_deplibs"
8149 test -n "$add_dir" && deplibs="$add_dir $deplibs"
8150 test -n "$add" && deplibs="$add $deplibs"
8151 if test yes != "$hardcode_direct" &&
8152 test yes != "$hardcode_minus_L" &&
8153 test yes = "$hardcode_shlibpath_var"; then
8154 case :$finalize_shlibpath: in
8156 *) func_append finalize_shlibpath "$libdir:" ;;
8162 if test prog = "$linkmode" || test relink = "$opt_mode"; then
8166 # Finalize command for both is simple: just hardcode it.
8167 if test yes = "$hardcode_direct" &&
8168 test no = "$hardcode_direct_absolute"; then
8169 add=$libdir/$linklib
8170 elif test yes = "$hardcode_minus_L"; then
8173 elif test yes = "$hardcode_shlibpath_var"; then
8174 case :$finalize_shlibpath: in
8176 *) func_append finalize_shlibpath "$libdir:" ;;
8179 elif test yes = "$hardcode_automatic"; then
8180 if test -n "$inst_prefix_dir" &&
8181 test -f "$inst_prefix_dir$libdir/$linklib"; then
8182 add=$inst_prefix_dir$libdir/$linklib
8184 add=$libdir/$linklib
8187 # We cannot seem to hardcode it, guess we'll fake it.
8189 # Try looking first in the location we're being installed to.
8190 if test -n "$inst_prefix_dir"; then
8193 func_append add_dir " -L$inst_prefix_dir$libdir"
8200 if test prog = "$linkmode"; then
8201 test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
8202 test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
8204 test -n "$add_dir" && deplibs="$add_dir $deplibs"
8205 test -n "$add" && deplibs="$add $deplibs"
8208 elif test prog = "$linkmode"; then
8209 # Here we assume that one of hardcode_direct or hardcode_minus_L
8210 # is not unsupported. This is valid on all known static and
8212 if test unsupported != "$hardcode_direct"; then
8213 test -n "$old_library" && linklib=$old_library
8214 compile_deplibs="$dir/$linklib $compile_deplibs"
8215 finalize_deplibs="$dir/$linklib $finalize_deplibs"
8217 compile_deplibs="-l$name -L$dir $compile_deplibs"
8218 finalize_deplibs="-l$name -L$dir $finalize_deplibs"
8220 elif test yes = "$build_libtool_libs"; then
8221 # Not a shared library
8222 if test pass_all != "$deplibs_check_method"; then
8223 # We're trying link a shared library against a static one
8224 # but the system doesn't support it.
8226 # Just print a warning and add the library to dependency_libs so
8227 # that the program can be linked against the static library.
8229 $ECHO "*** Warning: This system cannot link to static lib archive $lib."
8230 echo "*** I have the capability to make that library automatically link in when"
8231 echo "*** you link to this library. But I can only do this if you have a"
8232 echo "*** shared version of the library, which you do not appear to have."
8233 if test yes = "$module"; then
8234 echo "*** But as you try to build a module library, libtool will still create "
8235 echo "*** a static module, that should work as long as the dlopening application"
8236 echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
8237 if test -z "$global_symbol_pipe"; then
8239 echo "*** However, this would only work if libtool was able to extract symbol"
8240 echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
8241 echo "*** not find such a program. So, this module is probably useless."
8242 echo "*** 'nm' from GNU binutils and a full rebuild may help."
8244 if test no = "$build_old_libs"; then
8245 build_libtool_libs=module
8248 build_libtool_libs=no
8252 deplibs="$dir/$old_library $deplibs"
8255 fi # link shared/static library?
8257 if test lib = "$linkmode"; then
8258 if test -n "$dependency_libs" &&
8259 { test yes != "$hardcode_into_libs" ||
8260 test yes = "$build_old_libs" ||
8261 test yes = "$link_static"; }; then
8262 # Extract -R from dependency_libs
8264 for libdir in $dependency_libs; do
8266 -R*) func_stripname '-R' '' "$libdir"
8267 temp_xrpath=$func_stripname_result
8269 *" $temp_xrpath "*) ;;
8270 *) func_append xrpath " $temp_xrpath";;
8272 *) func_append temp_deplibs " $libdir";;
8275 dependency_libs=$temp_deplibs
8278 func_append newlib_search_path " $absdir"
8279 # Link against this library
8280 test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
8281 # ... and its dependency_libs
8283 for deplib in $dependency_libs; do
8284 newdependency_libs="$deplib $newdependency_libs"
8286 -L*) func_stripname '-L' '' "$deplib"
8287 func_resolve_sysroot "$func_stripname_result";;
8288 *) func_resolve_sysroot "$deplib" ;;
8290 if $opt_preserve_dup_deps; then
8291 case "$tmp_libs " in
8292 *" $func_resolve_sysroot_result "*)
8293 func_append specialdeplibs " $func_resolve_sysroot_result" ;;
8296 func_append tmp_libs " $func_resolve_sysroot_result"
8299 if test no != "$link_all_deplibs"; then
8300 # Add the search paths of all dependency libraries
8301 for deplib in $dependency_libs; do
8304 -L*) path=$deplib ;;
8306 func_resolve_sysroot "$deplib"
8307 deplib=$func_resolve_sysroot_result
8308 func_dirname "$deplib" "" "."
8309 dir=$func_dirname_result
8310 # We need an absolute path.
8312 [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
8314 absdir=`cd "$dir" && pwd`
8315 if test -z "$absdir"; then
8316 func_warning "cannot determine absolute directory name of '$dir'"
8321 if $GREP "^installed=no" $deplib > /dev/null; then
8325 eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
8326 if test -n "$deplibrary_names"; then
8327 for tmp in $deplibrary_names; do
8330 if test -f "$absdir/$objdir/$depdepl"; then
8331 depdepl=$absdir/$objdir/$depdepl
8332 darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
8333 if test -z "$darwin_install_name"; then
8334 darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
8336 func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
8337 func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
8343 path=-L$absdir/$objdir
8347 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
8348 test -z "$libdir" && \
8349 func_fatal_error "'$deplib' is not a valid libtool archive"
8350 test "$absdir" != "$libdir" && \
8351 func_warning "'$deplib' seems to be moved"
8357 case " $deplibs " in
8359 *) deplibs="$path $deplibs" ;;
8362 fi # link_all_deplibs != no
8364 done # for deplib in $libs
8365 if test link = "$pass"; then
8366 if test prog = "$linkmode"; then
8367 compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
8368 finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
8370 compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8373 dependency_libs=$newdependency_libs
8374 if test dlpreopen = "$pass"; then
8375 # Link the dlpreopened libraries before other libraries
8376 for deplib in $save_deplibs; do
8377 deplibs="$deplib $deplibs"
8380 if test dlopen != "$pass"; then
8381 test conv = "$pass" || {
8382 # Make sure lib_search_path contains only unique directories.
8384 for dir in $newlib_search_path; do
8385 case "$lib_search_path " in
8387 *) func_append lib_search_path " $dir" ;;
8393 if test prog,link = "$linkmode,$pass"; then
8394 vars="compile_deplibs finalize_deplibs"
8398 for var in $vars dependency_libs; do
8399 # Add libraries to $var in reverse order
8400 eval tmp_libs=\"\$$var\"
8402 for deplib in $tmp_libs; do
8403 # FIXME: Pedantically, this is the right thing to do, so
8404 # that some nasty dependency loop isn't accidentally
8406 #new_libs="$deplib $new_libs"
8407 # Pragmatically, this seems to cause very few problems in
8410 -L*) new_libs="$deplib $new_libs" ;;
8413 # And here is the reason: when a library appears more
8414 # than once as an explicit dependence of a library, or
8415 # is implicitly linked in more than once by the
8416 # compiler, it is considered special, and multiple
8417 # occurrences thereof are not removed. Compare this
8418 # with having the same library being listed as a
8419 # dependency of multiple other libraries: in this case,
8420 # we know (pedantically, we assume) the library does not
8421 # need to be listed more than once, so we keep only the
8422 # last copy. This is not always right, but it is rare
8423 # enough that we require users that really mean to play
8424 # such unportable linking tricks to link the library
8425 # using -Wl,-lname, so that libtool does not consider it
8426 # for duplicate removal.
8427 case " $specialdeplibs " in
8428 *" $deplib "*) new_libs="$deplib $new_libs" ;;
8430 case " $new_libs " in
8432 *) new_libs="$deplib $new_libs" ;;
8440 for deplib in $new_libs; do
8443 case " $tmp_libs " in
8445 *) func_append tmp_libs " $deplib" ;;
8448 *) func_append tmp_libs " $deplib" ;;
8451 eval $var=\"$tmp_libs\"
8454 # Last step: remove runtime libs from dependency_libs
8455 # (they stay in deplibs)
8457 for i in $dependency_libs; do
8458 case " $predeps $postdeps $compiler_lib_search_path " in
8463 if test -n "$i"; then
8464 func_append tmp_libs " $i"
8467 dependency_libs=$tmp_libs
8469 if test prog = "$linkmode"; then
8472 if test prog = "$linkmode" || test lib = "$linkmode"; then
8473 dlprefiles=$newdlprefiles
8478 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
8479 func_warning "'-dlopen' is ignored for archives"
8484 func_warning "'-l' and '-L' are ignored for archives" ;;
8487 test -n "$rpath" && \
8488 func_warning "'-rpath' is ignored for archives"
8490 test -n "$xrpath" && \
8491 func_warning "'-R' is ignored for archives"
8493 test -n "$vinfo" && \
8494 func_warning "'-version-info/-version-number' is ignored for archives"
8496 test -n "$release" && \
8497 func_warning "'-release' is ignored for archives"
8499 test -n "$export_symbols$export_symbols_regex" && \
8500 func_warning "'-export-symbols' is ignored for archives"
8502 # Now set the variables for building old libraries.
8503 build_libtool_libs=no
8505 func_append objs "$old_deplibs"
8509 # Make sure we only generate libraries of the form 'libNAME.la'.
8512 func_stripname 'lib' '.la' "$outputname"
8513 name=$func_stripname_result
8514 eval shared_ext=\"$shrext_cmds\"
8515 eval libname=\"$libname_spec\"
8518 test no = "$module" \
8519 && func_fatal_help "libtool library '$output' must begin with 'lib'"
8521 if test no != "$need_lib_prefix"; then
8522 # Add the "lib" prefix for modules if required
8523 func_stripname '' '.la' "$outputname"
8524 name=$func_stripname_result
8525 eval shared_ext=\"$shrext_cmds\"
8526 eval libname=\"$libname_spec\"
8528 func_stripname '' '.la' "$outputname"
8529 libname=$func_stripname_result
8534 if test -n "$objs"; then
8535 if test pass_all != "$deplibs_check_method"; then
8536 func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
8539 $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
8540 $ECHO "*** objects $objs is not portable!"
8541 func_append libobjs " $objs"
8545 test no = "$dlself" \
8546 || func_warning "'-dlopen self' is ignored for libtool libraries"
8551 && func_warning "ignoring multiple '-rpath's for a libtool library"
8556 if test -z "$rpath"; then
8557 if test yes = "$build_libtool_libs"; then
8558 # Building a libtool convenience library.
8559 # Some compilers have problems with a '.al' extension so
8560 # convenience libraries should have the same extension an
8561 # archive normally would.
8562 oldlibs="$output_objdir/$libname.$libext $oldlibs"
8563 build_libtool_libs=convenience
8567 test -n "$vinfo" && \
8568 func_warning "'-version-info/-version-number' is ignored for convenience libraries"
8570 test -n "$release" && \
8571 func_warning "'-release' is ignored for convenience libraries"
8574 # Parse the version information argument.
8575 save_ifs=$IFS; IFS=:
8576 set dummy $vinfo 0 0 0
8581 func_fatal_help "too many parameters to '-version-info'"
8583 # convert absolute version numbers to libtool ages
8584 # this retains compatibility with .la files and attempts
8585 # to make the code below a bit more comprehensible
8587 case $vinfo_number in
8593 # There are really only two kinds -- those that
8594 # use the current revision as the major version
8595 # and those that subtract age and use age as
8596 # a minor version. But, then there is irix
8597 # that has an extra 1 added just for fun
8599 case $version_type in
8600 # correct linux to gnu/linux during the next big refactor
8601 darwin|linux|osf|windows|none)
8602 func_arith $number_major + $number_minor
8603 current=$func_arith_result
8605 revision=$number_revision
8607 freebsd-aout|freebsd-elf|qnx|sunos)
8608 current=$number_major
8609 revision=$number_minor
8613 func_arith $number_major + $number_minor
8614 current=$func_arith_result
8616 revision=$number_minor
8617 lt_irix_increment=no
8628 # Check that each of the things are valid numbers.
8630 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]) ;;
8632 func_error "CURRENT '$current' must be a nonnegative integer"
8633 func_fatal_error "'$vinfo' is not valid version information"
8638 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]) ;;
8640 func_error "REVISION '$revision' must be a nonnegative integer"
8641 func_fatal_error "'$vinfo' is not valid version information"
8646 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]) ;;
8648 func_error "AGE '$age' must be a nonnegative integer"
8649 func_fatal_error "'$vinfo' is not valid version information"
8653 if test "$age" -gt "$current"; then
8654 func_error "AGE '$age' is greater than the current interface number '$current'"
8655 func_fatal_error "'$vinfo' is not valid version information"
8658 # Calculate the version variables.
8662 case $version_type in
8666 # Like Linux, but with the current version available in
8667 # verstring for coding it into the library header
8668 func_arith $current - $age
8669 major=.$func_arith_result
8670 versuffix=$major.$age.$revision
8671 # Darwin ld doesn't like 0 for these options...
8672 func_arith $current + 1
8673 minor_current=$func_arith_result
8674 xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
8675 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
8676 # On Darwin other compilers
8679 verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
8682 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
8689 versuffix=.$current.$revision
8698 if test no = "$lt_irix_increment"; then
8699 func_arith $current - $age
8701 func_arith $current - $age + 1
8703 major=$func_arith_result
8705 case $version_type in
8706 nonstopux) verstring_prefix=nonstopux ;;
8707 *) verstring_prefix=sgi ;;
8709 verstring=$verstring_prefix$major.$revision
8711 # Add in all the interfaces that we are compatible with.
8713 while test 0 -ne "$loop"; do
8714 func_arith $revision - $loop
8715 iface=$func_arith_result
8716 func_arith $loop - 1
8717 loop=$func_arith_result
8718 verstring=$verstring_prefix$major.$iface:$verstring
8721 # Before this point, $major must not contain '.'.
8723 versuffix=$major.$revision
8726 linux) # correct to gnu/linux during the next big refactor
8727 func_arith $current - $age
8728 major=.$func_arith_result
8729 versuffix=$major.$age.$revision
8733 func_arith $current - $age
8734 major=.$func_arith_result
8735 versuffix=.$current.$age.$revision
8736 verstring=$current.$age.$revision
8738 # Add in all the interfaces that we are compatible with.
8740 while test 0 -ne "$loop"; do
8741 func_arith $current - $loop
8742 iface=$func_arith_result
8743 func_arith $loop - 1
8744 loop=$func_arith_result
8745 verstring=$verstring:$iface.0
8748 # Make executables depend on our current version.
8749 func_append verstring ":$current.0"
8759 versuffix=.$current.$revision
8763 # Use '-' rather than '.', since we only want one
8764 # extension on DOS 8.3 file systems.
8765 func_arith $current - $age
8766 major=$func_arith_result
8771 func_fatal_configuration "unknown library version type '$version_type'"
8775 # Clear the version info if we defaulted, and they specified a release.
8776 if test -z "$vinfo" && test -n "$release"; then
8778 case $version_type in
8780 # we can't check for "0.0" in archive_cmds due to quoting
8781 # problems, so we reset it completely
8788 if test no = "$need_version"; then
8795 # Remove version info from name if versioning should be avoided
8796 if test yes,no = "$avoid_version,$need_version"; then
8802 # Check to see if the archive will have undefined symbols.
8803 if test yes = "$allow_undefined"; then
8804 if test unsupported = "$allow_undefined_flag"; then
8805 if test yes = "$build_old_libs"; then
8806 func_warning "undefined symbols not allowed in $host shared libraries; building static only"
8807 build_libtool_libs=no
8809 func_fatal_error "can't build $host shared library unless -no-undefined is specified"
8813 # Don't allow undefined symbols.
8814 allow_undefined_flag=$no_undefined_flag
8819 func_generate_dlsyms "$libname" "$libname" :
8820 func_append libobjs " $symfileobj"
8821 test " " = "$libobjs" && libobjs=
8823 if test relink != "$opt_mode"; then
8824 # Remove our outputs, but don't remove object files since they
8825 # may have been created when compiling PIC objects.
8827 tempremovelist=`$ECHO "$output_objdir/*"`
8828 for p in $tempremovelist; do
8832 $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
8833 if test -n "$precious_files_regex"; then
8834 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
8839 func_append removelist " $p"
8844 test -n "$removelist" && \
8845 func_show_eval "${RM}r \$removelist"
8848 # Now set the variables for building old libraries.
8849 if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
8850 func_append oldlibs " $output_objdir/$libname.$libext"
8852 # Transform .lo files to .o files.
8853 oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
8856 # Eliminate all temporary directories.
8857 #for path in $notinst_path; do
8858 # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
8859 # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
8860 # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
8863 if test -n "$xrpath"; then
8864 # If the user specified any rpath flags, then add them.
8866 for libdir in $xrpath; do
8867 func_replace_sysroot "$libdir"
8868 func_append temp_xrpath " -R$func_replace_sysroot_result"
8869 case "$finalize_rpath " in
8871 *) func_append finalize_rpath " $libdir" ;;
8874 if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
8875 dependency_libs="$temp_xrpath $dependency_libs"
8879 # Make sure dlfiles contains only unique files that won't be dlpreopened
8880 old_dlfiles=$dlfiles
8882 for lib in $old_dlfiles; do
8883 case " $dlprefiles $dlfiles " in
8885 *) func_append dlfiles " $lib" ;;
8889 # Make sure dlprefiles contains only unique files
8890 old_dlprefiles=$dlprefiles
8892 for lib in $old_dlprefiles; do
8893 case "$dlprefiles " in
8895 *) func_append dlprefiles " $lib" ;;
8899 if test yes = "$build_libtool_libs"; then
8900 if test -n "$rpath"; then
8902 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
8903 # these systems don't actually have a c library (as such)!
8905 *-*-rhapsody* | *-*-darwin1.[012])
8906 # Rhapsody C library is in the System framework
8907 func_append deplibs " System.ltframework"
8910 # Don't link with libc until the a.out ld.so is fixed.
8912 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
8913 # Do not include libc due to us having libc/libc_r.
8915 *-*-sco3.2v5* | *-*-sco5v6*)
8916 # Causes problems with __ctype
8918 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
8919 # Compiler inserts libc in the correct place for threads to work
8922 # Add libc to deplibs on all other systems if necessary.
8923 if test yes = "$build_libtool_need_lc"; then
8924 func_append deplibs " -lc"
8930 # Transform deplibs into only deplibs that can be linked in shared.
8932 libname_save=$libname
8933 release_save=$release
8934 versuffix_save=$versuffix
8936 # I'm not sure if I'm treating the release correctly. I think
8937 # release should show up in the -l (ie -lgmp5) so we don't want to
8938 # add it in twice. Is that correct?
8944 case $deplibs_check_method in
8946 # Don't check for shared/static. Everything works.
8947 # This might be a little naive. We might want to check
8948 # whether the library exists or not. But this is on
8949 # osf3 & osf4 and I'm not really sure... Just
8950 # implementing what was already the behavior.
8954 # This code stresses the "libraries are programs" paradigm to its
8955 # limits. Maybe even breaks it. We compile a program, linking it
8956 # against the deplibs as a proxy for the library. Then we can check
8957 # whether they linked in statically or dynamically with ldd.
8958 $opt_dry_run || $RM conftest.c
8959 cat > conftest.c <<EOF
8960 int main() { return 0; }
8962 $opt_dry_run || $RM conftest
8963 if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
8964 ldd_output=`ldd conftest`
8965 for i in $deplibs; do
8968 func_stripname -l '' "$i"
8969 name=$func_stripname_result
8970 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
8971 case " $predeps $postdeps " in
8973 func_append newdeplibs " $i"
8978 if test -n "$i"; then
8979 libname=`eval "\\$ECHO \"$libname_spec\""`
8980 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
8981 set dummy $deplib_matches; shift
8983 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
8984 func_append newdeplibs " $i"
8988 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
8989 echo "*** I have the capability to make that library automatically link in when"
8990 echo "*** you link to this library. But I can only do this if you have a"
8991 echo "*** shared version of the library, which I believe you do not have"
8992 echo "*** because a test_compile did reveal that the linker did not use it for"
8993 echo "*** its dynamic dependency list that programs get resolved with at runtime."
8998 func_append newdeplibs " $i"
9003 # Error occurred in the first compile. Let's try to salvage
9004 # the situation: Compile a separate program for each library.
9005 for i in $deplibs; do
9008 func_stripname -l '' "$i"
9009 name=$func_stripname_result
9010 $opt_dry_run || $RM conftest
9011 if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
9012 ldd_output=`ldd conftest`
9013 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9014 case " $predeps $postdeps " in
9016 func_append newdeplibs " $i"
9021 if test -n "$i"; then
9022 libname=`eval "\\$ECHO \"$libname_spec\""`
9023 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
9024 set dummy $deplib_matches; shift
9026 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
9027 func_append newdeplibs " $i"
9031 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
9032 echo "*** I have the capability to make that library automatically link in when"
9033 echo "*** you link to this library. But I can only do this if you have a"
9034 echo "*** shared version of the library, which you do not appear to have"
9035 echo "*** because a test_compile did reveal that the linker did not use this one"
9036 echo "*** as a dynamic dependency that programs can get resolved with at runtime."
9042 $ECHO "*** Warning! Library $i is needed by this library but I was not able to"
9043 echo "*** make it link in! You will probably need to install it or some"
9044 echo "*** library that it depends on before this library will be fully"
9045 echo "*** functional. Installing it before continuing would be even better."
9049 func_append newdeplibs " $i"
9056 set dummy $deplibs_check_method; shift
9057 file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
9058 for a_deplib in $deplibs; do
9061 func_stripname -l '' "$a_deplib"
9062 name=$func_stripname_result
9063 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9064 case " $predeps $postdeps " in
9066 func_append newdeplibs " $a_deplib"
9071 if test -n "$a_deplib"; then
9072 libname=`eval "\\$ECHO \"$libname_spec\""`
9073 if test -n "$file_magic_glob"; then
9074 libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
9076 libnameglob=$libname
9078 test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
9079 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
9080 if test yes = "$want_nocaseglob"; then
9082 potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9085 potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
9087 for potent_lib in $potential_libs; do
9088 # Follow soft links.
9089 if ls -lLd "$potent_lib" 2>/dev/null |
9090 $GREP " -> " >/dev/null; then
9093 # The statement above tries to avoid entering an
9094 # endless loop below, in case of cyclic links.
9095 # We might still enter an endless loop, since a link
9096 # loop can be closed while we follow links,
9099 while test -h "$potlib" 2>/dev/null; do
9100 potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
9102 [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
9103 *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
9106 if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
9108 $EGREP "$file_magic_regex" > /dev/null; then
9109 func_append newdeplibs " $a_deplib"
9116 if test -n "$a_deplib"; then
9119 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9120 echo "*** I have the capability to make that library automatically link in when"
9121 echo "*** you link to this library. But I can only do this if you have a"
9122 echo "*** shared version of the library, which you do not appear to have"
9123 echo "*** because I did check the linker path looking for a file starting"
9124 if test -z "$potlib"; then
9125 $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
9127 $ECHO "*** with $libname and none of the candidates passed a file format test"
9128 $ECHO "*** using a file magic. Last file checked: $potlib"
9133 # Add a -L argument.
9134 func_append newdeplibs " $a_deplib"
9137 done # Gone through all deplibs.
9140 set dummy $deplibs_check_method; shift
9141 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
9142 for a_deplib in $deplibs; do
9145 func_stripname -l '' "$a_deplib"
9146 name=$func_stripname_result
9147 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9148 case " $predeps $postdeps " in
9150 func_append newdeplibs " $a_deplib"
9155 if test -n "$a_deplib"; then
9156 libname=`eval "\\$ECHO \"$libname_spec\""`
9157 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
9158 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
9159 for potent_lib in $potential_libs; do
9160 potlib=$potent_lib # see symlink-check above in file_magic test
9161 if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
9162 $EGREP "$match_pattern_regex" > /dev/null; then
9163 func_append newdeplibs " $a_deplib"
9170 if test -n "$a_deplib"; then
9173 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
9174 echo "*** I have the capability to make that library automatically link in when"
9175 echo "*** you link to this library. But I can only do this if you have a"
9176 echo "*** shared version of the library, which you do not appear to have"
9177 echo "*** because I did check the linker path looking for a file starting"
9178 if test -z "$potlib"; then
9179 $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
9181 $ECHO "*** with $libname and none of the candidates passed a file format test"
9182 $ECHO "*** using a regex pattern. Last file checked: $potlib"
9187 # Add a -L argument.
9188 func_append newdeplibs " $a_deplib"
9191 done # Gone through all deplibs.
9195 tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
9196 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
9197 for i in $predeps $postdeps; do
9198 # can't use Xsed below, because $i might contain '/'
9199 tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
9202 case $tmp_deplibs in
9205 if test none = "$deplibs_check_method"; then
9206 echo "*** Warning: inter-library dependencies are not supported in this platform."
9208 echo "*** Warning: inter-library dependencies are not known to be supported."
9210 echo "*** All declared inter-library dependencies are being dropped."
9216 versuffix=$versuffix_save
9218 release=$release_save
9219 libname=$libname_save
9223 *-*-rhapsody* | *-*-darwin1.[012])
9224 # On Rhapsody replace the C library with the System framework
9225 newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
9229 if test yes = "$droppeddeps"; then
9230 if test yes = "$module"; then
9232 echo "*** Warning: libtool could not satisfy all declared inter-library"
9233 $ECHO "*** dependencies of module $libname. Therefore, libtool will create"
9234 echo "*** a static module, that should work as long as the dlopening"
9235 echo "*** application is linked with the -dlopen flag."
9236 if test -z "$global_symbol_pipe"; then
9238 echo "*** However, this would only work if libtool was able to extract symbol"
9239 echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
9240 echo "*** not find such a program. So, this module is probably useless."
9241 echo "*** 'nm' from GNU binutils and a full rebuild may help."
9243 if test no = "$build_old_libs"; then
9244 oldlibs=$output_objdir/$libname.$libext
9245 build_libtool_libs=module
9248 build_libtool_libs=no
9251 echo "*** The inter-library dependencies that have been dropped here will be"
9252 echo "*** automatically added whenever a program is linked with this library"
9253 echo "*** or is declared to -dlopen it."
9255 if test no = "$allow_undefined"; then
9257 echo "*** Since this library must not contain undefined symbols,"
9258 echo "*** because either the platform does not support them or"
9259 echo "*** it was explicitly requested with -no-undefined,"
9260 echo "*** libtool will only create a static version of it."
9261 if test no = "$build_old_libs"; then
9262 oldlibs=$output_objdir/$libname.$libext
9263 build_libtool_libs=module
9266 build_libtool_libs=no
9271 # Done checking deplibs!
9274 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
9277 newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9278 new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9279 deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9283 # move library search paths that coincide with paths to not yet
9284 # installed libraries to the beginning of the library search list
9286 for path in $notinst_path; do
9287 case " $new_libs " in
9288 *" -L$path/$objdir "*) ;;
9290 case " $deplibs " in
9291 *" -L$path/$objdir "*)
9292 func_append new_libs " -L$path/$objdir" ;;
9297 for deplib in $deplibs; do
9300 case " $new_libs " in
9302 *) func_append new_libs " $deplib" ;;
9305 *) func_append new_libs " $deplib" ;;
9310 # All the library-specific variables (install_libdir is set above).
9315 # Test again, we may have decided not to build it any more
9316 if test yes = "$build_libtool_libs"; then
9317 # Remove $wl instances when linking with ld.
9318 # FIXME: should test the right _cmds variable.
9319 case $archive_cmds in
9322 if test yes = "$hardcode_into_libs"; then
9323 # Hardcode the library paths
9326 rpath=$finalize_rpath
9327 test relink = "$opt_mode" || rpath=$compile_rpath$rpath
9328 for libdir in $rpath; do
9329 if test -n "$hardcode_libdir_flag_spec"; then
9330 if test -n "$hardcode_libdir_separator"; then
9331 func_replace_sysroot "$libdir"
9332 libdir=$func_replace_sysroot_result
9333 if test -z "$hardcode_libdirs"; then
9334 hardcode_libdirs=$libdir
9336 # Just accumulate the unique libdirs.
9337 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
9338 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
9341 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
9346 eval flag=\"$hardcode_libdir_flag_spec\"
9347 func_append dep_rpath " $flag"
9349 elif test -n "$runpath_var"; then
9350 case "$perm_rpath " in
9352 *) func_append perm_rpath " $libdir" ;;
9356 # Substitute the hardcoded libdirs into the rpath.
9357 if test -n "$hardcode_libdir_separator" &&
9358 test -n "$hardcode_libdirs"; then
9359 libdir=$hardcode_libdirs
9360 eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
9362 if test -n "$runpath_var" && test -n "$perm_rpath"; then
9363 # We should set the runpath_var.
9365 for dir in $perm_rpath; do
9366 func_append rpath "$dir:"
9368 eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
9370 test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
9373 shlibpath=$finalize_shlibpath
9374 test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
9375 if test -n "$shlibpath"; then
9376 eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
9379 # Get the real and link names of the library.
9380 eval shared_ext=\"$shrext_cmds\"
9381 eval library_names=\"$library_names_spec\"
9382 set dummy $library_names
9387 if test -n "$soname_spec"; then
9388 eval soname=\"$soname_spec\"
9392 if test -z "$dlname"; then
9396 lib=$output_objdir/$realname
9400 func_append linknames " $link"
9403 # Use standard objects if they are pic
9404 test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
9405 test "X$libobjs" = "X " && libobjs=
9408 if test -n "$export_symbols" && test -n "$include_expsyms"; then
9409 $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
9410 export_symbols=$output_objdir/$libname.uexp
9411 func_append delfiles " $export_symbols"
9414 orig_export_symbols=
9416 cygwin* | mingw* | cegcc*)
9417 if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
9418 # exporting using user supplied symfile
9419 func_dll_def_p "$export_symbols" || {
9420 # and it's NOT already a .def file. Must figure out
9421 # which of the given symbols are data symbols and tag
9422 # them as such. So, trigger use of export_symbols_cmds.
9423 # export_symbols gets reassigned inside the "prepare
9424 # the list of exported symbols" if statement, so the
9425 # include_expsyms logic still works.
9426 orig_export_symbols=$export_symbols
9428 always_export_symbols=yes
9434 # Prepare the list of exported symbols
9435 if test -z "$export_symbols"; then
9436 if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
9437 func_verbose "generating symbol list for '$libname.la'"
9438 export_symbols=$output_objdir/$libname.exp
9439 $opt_dry_run || $RM $export_symbols
9440 cmds=$export_symbols_cmds
9441 save_ifs=$IFS; IFS='~'
9442 for cmd1 in $cmds; do
9444 # Take the normal branch if the nm_file_list_spec branch
9445 # doesn't work or if tool conversion is not needed.
9446 case $nm_file_list_spec~$to_tool_file_cmd in
9447 *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
9448 try_normal_branch=yes
9451 len=$func_len_result
9454 try_normal_branch=no
9457 if test yes = "$try_normal_branch" \
9458 && { test "$len" -lt "$max_cmd_len" \
9459 || test "$max_cmd_len" -le -1; }
9461 func_show_eval "$cmd" 'exit $?'
9462 skipped_export=false
9463 elif test -n "$nm_file_list_spec"; then
9464 func_basename "$output"
9465 output_la=$func_basename_result
9466 save_libobjs=$libobjs
9468 output=$output_objdir/$output_la.nm
9469 func_to_tool_file "$output"
9470 libobjs=$nm_file_list_spec$func_to_tool_file_result
9471 func_append delfiles " $output"
9472 func_verbose "creating $NM input file list: $output"
9473 for obj in $save_libobjs; do
9474 func_to_tool_file "$obj"
9475 $ECHO "$func_to_tool_file_result"
9478 func_show_eval "$cmd" 'exit $?'
9480 libobjs=$save_libobjs
9481 skipped_export=false
9483 # The command line is too long to execute in one step.
9484 func_verbose "using reloadable object file for export list..."
9486 # Break out early, otherwise skipped_export may be
9487 # set to false by a later but shorter cmd.
9492 if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
9493 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
9494 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
9499 if test -n "$export_symbols" && test -n "$include_expsyms"; then
9500 tmp_export_symbols=$export_symbols
9501 test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
9502 $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
9505 if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
9506 # The given exports_symbols file has to be filtered, so filter it.
9507 func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
9508 # FIXME: $output_objdir/$libname.filter potentially contains lots of
9509 # 's' commands, which not all seds can handle. GNU sed should be fine
9510 # though. Also, the filter scales superlinearly with the number of
9511 # global variables. join(1) would be nice here, but unfortunately
9512 # isn't a blessed tool.
9513 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
9514 func_append delfiles " $export_symbols $output_objdir/$libname.filter"
9515 export_symbols=$output_objdir/$libname.def
9516 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
9520 for test_deplib in $deplibs; do
9521 case " $convenience " in
9522 *" $test_deplib "*) ;;
9524 func_append tmp_deplibs " $test_deplib"
9528 deplibs=$tmp_deplibs
9530 if test -n "$convenience"; then
9531 if test -n "$whole_archive_flag_spec" &&
9532 test yes = "$compiler_needs_object" &&
9533 test -z "$libobjs"; then
9534 # extract the archives, so we have objects to list.
9535 # TODO: could optimize this to just extract one archive.
9536 whole_archive_flag_spec=
9538 if test -n "$whole_archive_flag_spec"; then
9539 save_libobjs=$libobjs
9540 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
9541 test "X$libobjs" = "X " && libobjs=
9543 gentop=$output_objdir/${outputname}x
9544 func_append generated " $gentop"
9546 func_extract_archives $gentop $convenience
9547 func_append libobjs " $func_extract_archives_result"
9548 test "X$libobjs" = "X " && libobjs=
9552 if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
9553 eval flag=\"$thread_safe_flag_spec\"
9554 func_append linker_flags " $flag"
9557 # Make a backup of the uninstalled library when relinking
9558 if test relink = "$opt_mode"; then
9559 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
9562 # Do each of the archive commands.
9563 if test yes = "$module" && test -n "$module_cmds"; then
9564 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
9565 eval test_cmds=\"$module_expsym_cmds\"
9566 cmds=$module_expsym_cmds
9568 eval test_cmds=\"$module_cmds\"
9572 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
9573 eval test_cmds=\"$archive_expsym_cmds\"
9574 cmds=$archive_expsym_cmds
9576 eval test_cmds=\"$archive_cmds\"
9581 if test : != "$skipped_export" &&
9582 func_len " $test_cmds" &&
9583 len=$func_len_result &&
9584 test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
9587 # The command line is too long to link in one step, link piecewise
9588 # or, if using GNU ld and skipped_export is not :, use a linker
9591 # Save the value of $output and $libobjs because we want to
9592 # use them later. If we have whole_archive_flag_spec, we
9593 # want to use save_libobjs as it was before
9594 # whole_archive_flag_spec was expanded, because we can't
9595 # assume the linker understands whole_archive_flag_spec.
9596 # This may have to be revisited, in case too many
9597 # convenience libraries get linked in and end up exceeding
9599 if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
9600 save_libobjs=$libobjs
9603 func_basename "$output"
9604 output_la=$func_basename_result
9606 # Clear the reloadable object creation command queue and
9607 # initialize k to one.
9614 if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
9615 output=$output_objdir/$output_la.lnkscript
9616 func_verbose "creating GNU ld script: $output"
9617 echo 'INPUT (' > $output
9618 for obj in $save_libobjs
9620 func_to_tool_file "$obj"
9621 $ECHO "$func_to_tool_file_result" >> $output
9624 func_append delfiles " $output"
9625 func_to_tool_file "$output"
9626 output=$func_to_tool_file_result
9627 elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
9628 output=$output_objdir/$output_la.lnk
9629 func_verbose "creating linker input file list: $output"
9634 if test yes = "$compiler_needs_object"; then
9640 func_to_tool_file "$obj"
9641 $ECHO "$func_to_tool_file_result" >> $output
9643 func_append delfiles " $output"
9644 func_to_tool_file "$output"
9645 output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
9647 if test -n "$save_libobjs"; then
9648 func_verbose "creating reloadable object files..."
9649 output=$output_objdir/$output_la-$k.$objext
9650 eval test_cmds=\"$reload_cmds\"
9651 func_len " $test_cmds"
9652 len0=$func_len_result
9655 # Loop over the list of objects to be linked.
9656 for obj in $save_libobjs
9659 func_arith $len + $func_len_result
9660 len=$func_arith_result
9661 if test -z "$objlist" ||
9662 test "$len" -lt "$max_cmd_len"; then
9663 func_append objlist " $obj"
9665 # The command $test_cmds is almost too long, add a
9666 # command to the queue.
9667 if test 1 -eq "$k"; then
9668 # The first file doesn't have a previous command to add.
9669 reload_objs=$objlist
9670 eval concat_cmds=\"$reload_cmds\"
9672 # All subsequent reloadable object files will link in
9673 # the last one created.
9674 reload_objs="$objlist $last_robj"
9675 eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
9677 last_robj=$output_objdir/$output_la-$k.$objext
9679 k=$func_arith_result
9680 output=$output_objdir/$output_la-$k.$objext
9682 func_len " $last_robj"
9683 func_arith $len0 + $func_len_result
9684 len=$func_arith_result
9687 # Handle the remaining objects by creating one last
9688 # reloadable object file. All subsequent reloadable object
9689 # files will link in the last one created.
9690 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9691 reload_objs="$objlist $last_robj"
9692 eval concat_cmds=\"\$concat_cmds$reload_cmds\"
9693 if test -n "$last_robj"; then
9694 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
9696 func_append delfiles " $output"
9702 ${skipped_export-false} && {
9703 func_verbose "generating symbol list for '$libname.la'"
9704 export_symbols=$output_objdir/$libname.exp
9705 $opt_dry_run || $RM $export_symbols
9707 # Append the command to create the export file.
9708 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9709 eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
9710 if test -n "$last_robj"; then
9711 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
9715 test -n "$save_libobjs" &&
9716 func_verbose "creating a temporary reloadable object file: $output"
9718 # Loop through the commands generated above and execute them.
9719 save_ifs=$IFS; IFS='~'
9720 for cmd in $concat_cmds; do
9723 func_quote_for_expand "$cmd"
9724 eval "func_echo $func_quote_for_expand_result"
9726 $opt_dry_run || eval "$cmd" || {
9729 # Restore the uninstalled library and exit
9730 if test relink = "$opt_mode"; then
9731 ( cd "$output_objdir" && \
9732 $RM "${realname}T" && \
9733 $MV "${realname}U" "$realname" )
9741 if test -n "$export_symbols_regex" && ${skipped_export-false}; then
9742 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
9743 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
9747 ${skipped_export-false} && {
9748 if test -n "$export_symbols" && test -n "$include_expsyms"; then
9749 tmp_export_symbols=$export_symbols
9750 test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
9751 $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
9754 if test -n "$orig_export_symbols"; then
9755 # The given exports_symbols file has to be filtered, so filter it.
9756 func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
9757 # FIXME: $output_objdir/$libname.filter potentially contains lots of
9758 # 's' commands, which not all seds can handle. GNU sed should be fine
9759 # though. Also, the filter scales superlinearly with the number of
9760 # global variables. join(1) would be nice here, but unfortunately
9761 # isn't a blessed tool.
9762 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
9763 func_append delfiles " $export_symbols $output_objdir/$libname.filter"
9764 export_symbols=$output_objdir/$libname.def
9765 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
9770 # Restore the value of output.
9773 if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
9774 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
9775 test "X$libobjs" = "X " && libobjs=
9777 # Expand the library linking commands again to reset the
9778 # value of $libobjs for piecewise linking.
9780 # Do each of the archive commands.
9781 if test yes = "$module" && test -n "$module_cmds"; then
9782 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
9783 cmds=$module_expsym_cmds
9788 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
9789 cmds=$archive_expsym_cmds
9796 if test -n "$delfiles"; then
9797 # Append the command to remove temporary files to $cmds.
9798 eval cmds=\"\$cmds~\$RM $delfiles\"
9801 # Add any objects from preloaded convenience libraries
9802 if test -n "$dlprefiles"; then
9803 gentop=$output_objdir/${outputname}x
9804 func_append generated " $gentop"
9806 func_extract_archives $gentop $dlprefiles
9807 func_append libobjs " $func_extract_archives_result"
9808 test "X$libobjs" = "X " && libobjs=
9811 save_ifs=$IFS; IFS='~'
9812 for cmd in $cmds; do
9817 func_quote_for_expand "$cmd"
9818 eval "func_echo $func_quote_for_expand_result"
9820 $opt_dry_run || eval "$cmd" || {
9823 # Restore the uninstalled library and exit
9824 if test relink = "$opt_mode"; then
9825 ( cd "$output_objdir" && \
9826 $RM "${realname}T" && \
9827 $MV "${realname}U" "$realname" )
9835 # Restore the uninstalled library and exit
9836 if test relink = "$opt_mode"; then
9837 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
9839 if test -n "$convenience"; then
9840 if test -z "$whole_archive_flag_spec"; then
9841 func_show_eval '${RM}r "$gentop"'
9848 # Create links to the real library.
9849 for linkname in $linknames; do
9850 if test "$realname" != "$linkname"; then
9851 func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
9855 # If -module or -export-dynamic was specified, set the dlname.
9856 if test yes = "$module" || test yes = "$export_dynamic"; then
9857 # On all known operating systems, these are identical.
9864 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
9865 func_warning "'-dlopen' is ignored for objects"
9870 func_warning "'-l' and '-L' are ignored for objects" ;;
9873 test -n "$rpath" && \
9874 func_warning "'-rpath' is ignored for objects"
9876 test -n "$xrpath" && \
9877 func_warning "'-R' is ignored for objects"
9879 test -n "$vinfo" && \
9880 func_warning "'-version-info' is ignored for objects"
9882 test -n "$release" && \
9883 func_warning "'-release' is ignored for objects"
9887 test -n "$objs$old_deplibs" && \
9888 func_fatal_error "cannot build library object '$output' from non-libtool objects"
9892 obj=$func_lo2o_result
9900 # Delete the old objects.
9901 $opt_dry_run || $RM $obj $libobj
9903 # Objects from convenience libraries. This assumes
9904 # single-version convenience libraries. Whenever we create
9905 # different ones for PIC/non-PIC, this we'll have to duplicate
9909 # reload_cmds runs $LD directly, so let us get rid of
9910 # -Wl from whole_archive_flag_spec and hope we can get by with
9911 # turning comma into space..
9914 if test -n "$convenience"; then
9915 if test -n "$whole_archive_flag_spec"; then
9916 eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
9917 reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
9919 gentop=$output_objdir/${obj}x
9920 func_append generated " $gentop"
9922 func_extract_archives $gentop $convenience
9923 reload_conv_objs="$reload_objs $func_extract_archives_result"
9927 # If we're not building shared, we need to use non_pic_objs
9928 test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
9930 # Create the old-style object.
9931 reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
9934 func_execute_cmds "$reload_cmds" 'exit $?'
9936 # Exit if we aren't doing a library object file.
9937 if test -z "$libobj"; then
9938 if test -n "$gentop"; then
9939 func_show_eval '${RM}r "$gentop"'
9945 test yes = "$build_libtool_libs" || {
9946 if test -n "$gentop"; then
9947 func_show_eval '${RM}r "$gentop"'
9950 # Create an invalid libtool object if no PIC, so that we don't
9951 # accidentally link it into a program.
9952 # $show "echo timestamp > $libobj"
9953 # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
9957 if test -n "$pic_flag" || test default != "$pic_mode"; then
9958 # Only do commands if we really have different PIC objects.
9959 reload_objs="$libobjs $reload_conv_objs"
9961 func_execute_cmds "$reload_cmds" 'exit $?'
9964 if test -n "$gentop"; then
9965 func_show_eval '${RM}r "$gentop"'
9973 *cygwin*) func_stripname '' '.exe' "$output"
9974 output=$func_stripname_result.exe;;
9976 test -n "$vinfo" && \
9977 func_warning "'-version-info' is ignored for programs"
9979 test -n "$release" && \
9980 func_warning "'-release' is ignored for programs"
9983 && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
9984 && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
9987 *-*-rhapsody* | *-*-darwin1.[012])
9988 # On Rhapsody replace the C library is the System framework
9989 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
9990 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
9996 # Don't allow lazy linking, it breaks C++ global constructors
9997 # But is supposedly fixed on 10.4 or later (yay!).
9998 if test CXX = "$tagname"; then
9999 case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
10001 func_append compile_command " $wl-bind_at_load"
10002 func_append finalize_command " $wl-bind_at_load"
10006 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
10007 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
10008 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
10013 # move library search paths that coincide with paths to not yet
10014 # installed libraries to the beginning of the library search list
10016 for path in $notinst_path; do
10017 case " $new_libs " in
10018 *" -L$path/$objdir "*) ;;
10020 case " $compile_deplibs " in
10021 *" -L$path/$objdir "*)
10022 func_append new_libs " -L$path/$objdir" ;;
10027 for deplib in $compile_deplibs; do
10030 case " $new_libs " in
10032 *) func_append new_libs " $deplib" ;;
10035 *) func_append new_libs " $deplib" ;;
10038 compile_deplibs=$new_libs
10041 func_append compile_command " $compile_deplibs"
10042 func_append finalize_command " $finalize_deplibs"
10044 if test -n "$rpath$xrpath"; then
10045 # If the user specified any rpath flags, then add them.
10046 for libdir in $rpath $xrpath; do
10047 # This is the magic to use -rpath.
10048 case "$finalize_rpath " in
10050 *) func_append finalize_rpath " $libdir" ;;
10055 # Now hardcode the library paths
10058 for libdir in $compile_rpath $finalize_rpath; do
10059 if test -n "$hardcode_libdir_flag_spec"; then
10060 if test -n "$hardcode_libdir_separator"; then
10061 if test -z "$hardcode_libdirs"; then
10062 hardcode_libdirs=$libdir
10064 # Just accumulate the unique libdirs.
10065 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
10066 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
10069 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
10074 eval flag=\"$hardcode_libdir_flag_spec\"
10075 func_append rpath " $flag"
10077 elif test -n "$runpath_var"; then
10078 case "$perm_rpath " in
10080 *) func_append perm_rpath " $libdir" ;;
10084 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
10085 testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
10086 case :$dllsearchpath: in
10088 ::) dllsearchpath=$libdir;;
10089 *) func_append dllsearchpath ":$libdir";;
10091 case :$dllsearchpath: in
10092 *":$testbindir:"*) ;;
10093 ::) dllsearchpath=$testbindir;;
10094 *) func_append dllsearchpath ":$testbindir";;
10099 # Substitute the hardcoded libdirs into the rpath.
10100 if test -n "$hardcode_libdir_separator" &&
10101 test -n "$hardcode_libdirs"; then
10102 libdir=$hardcode_libdirs
10103 eval rpath=\" $hardcode_libdir_flag_spec\"
10105 compile_rpath=$rpath
10109 for libdir in $finalize_rpath; do
10110 if test -n "$hardcode_libdir_flag_spec"; then
10111 if test -n "$hardcode_libdir_separator"; then
10112 if test -z "$hardcode_libdirs"; then
10113 hardcode_libdirs=$libdir
10115 # Just accumulate the unique libdirs.
10116 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
10117 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
10120 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
10125 eval flag=\"$hardcode_libdir_flag_spec\"
10126 func_append rpath " $flag"
10128 elif test -n "$runpath_var"; then
10129 case "$finalize_perm_rpath " in
10131 *) func_append finalize_perm_rpath " $libdir" ;;
10135 # Substitute the hardcoded libdirs into the rpath.
10136 if test -n "$hardcode_libdir_separator" &&
10137 test -n "$hardcode_libdirs"; then
10138 libdir=$hardcode_libdirs
10139 eval rpath=\" $hardcode_libdir_flag_spec\"
10141 finalize_rpath=$rpath
10143 if test -n "$libobjs" && test yes = "$build_old_libs"; then
10144 # Transform all the library objects into standard objects.
10145 compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
10146 finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
10149 func_generate_dlsyms "$outputname" "@PROGRAM@" false
10151 # template prelinking step
10152 if test -n "$prelink_cmds"; then
10153 func_execute_cmds "$prelink_cmds" 'exit $?'
10156 wrappers_required=:
10158 *cegcc* | *mingw32ce*)
10159 # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
10160 wrappers_required=false
10162 *cygwin* | *mingw* )
10163 test yes = "$build_libtool_libs" || wrappers_required=false
10166 if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
10167 wrappers_required=false
10171 $wrappers_required || {
10172 # Replace the output file specification.
10173 compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
10174 link_command=$compile_command$compile_rpath
10176 # We have no uninstalled library dependencies, so finalize right now.
10178 func_show_eval "$link_command" 'exit_status=$?'
10180 if test -n "$postlink_cmds"; then
10181 func_to_tool_file "$output"
10182 postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
10183 func_execute_cmds "$postlink_cmds" 'exit $?'
10186 # Delete the generated files.
10187 if test -f "$output_objdir/${outputname}S.$objext"; then
10188 func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
10194 if test -n "$compile_shlibpath$finalize_shlibpath"; then
10195 compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
10197 if test -n "$finalize_shlibpath"; then
10198 finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
10203 if test -n "$runpath_var"; then
10204 if test -n "$perm_rpath"; then
10205 # We should set the runpath_var.
10207 for dir in $perm_rpath; do
10208 func_append rpath "$dir:"
10210 compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
10212 if test -n "$finalize_perm_rpath"; then
10213 # We should set the runpath_var.
10215 for dir in $finalize_perm_rpath; do
10216 func_append rpath "$dir:"
10218 finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
10222 if test yes = "$no_install"; then
10223 # We don't need to create a wrapper script.
10224 link_command=$compile_var$compile_command$compile_rpath
10225 # Replace the output file specification.
10226 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
10227 # Delete the old output file.
10228 $opt_dry_run || $RM $output
10229 # Link the executable and exit
10230 func_show_eval "$link_command" 'exit $?'
10232 if test -n "$postlink_cmds"; then
10233 func_to_tool_file "$output"
10234 postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
10235 func_execute_cmds "$postlink_cmds" 'exit $?'
10241 case $hardcode_action,$fast_install in
10243 # Fast installation is not supported
10244 link_command=$compile_var$compile_command$compile_rpath
10245 relink_command=$finalize_var$finalize_command$finalize_rpath
10247 func_warning "this platform does not like uninstalled shared libraries"
10248 func_warning "'$output' will be relinked during installation"
10251 link_command=$finalize_var$compile_command$finalize_rpath
10252 relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
10255 link_command=$compile_var$compile_command$compile_rpath
10256 relink_command=$finalize_var$finalize_command$finalize_rpath
10259 link_command=$finalize_var$compile_command$finalize_rpath
10264 # Replace the output file specification.
10265 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
10267 # Delete the old output files.
10268 $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
10270 func_show_eval "$link_command" 'exit $?'
10272 if test -n "$postlink_cmds"; then
10273 func_to_tool_file "$output_objdir/$outputname"
10274 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'`
10275 func_execute_cmds "$postlink_cmds" 'exit $?'
10278 # Now create the wrapper script.
10279 func_verbose "creating $output"
10281 # Quote the relink command for shipping.
10282 if test -n "$relink_command"; then
10283 # Preserve any variables that may affect compiler behavior
10284 for var in $variables_saved_for_relink; do
10285 if eval test -z \"\${$var+set}\"; then
10286 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
10287 elif eval var_value=\$$var; test -z "$var_value"; then
10288 relink_command="$var=; export $var; $relink_command"
10290 func_quote_for_eval "$var_value"
10291 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
10294 relink_command="(cd `pwd`; $relink_command)"
10295 relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
10298 # Only actually do things if not in dry run mode.
10300 # win32 will think the script is a binary if it has
10301 # a .exe suffix, so we strip it off here.
10303 *.exe) func_stripname '' '.exe' "$output"
10304 output=$func_stripname_result ;;
10306 # test for cygwin because mv fails w/o .exe extensions
10310 func_stripname '' '.exe' "$outputname"
10311 outputname=$func_stripname_result ;;
10315 *cygwin* | *mingw* )
10316 func_dirname_and_basename "$output" "" "."
10317 output_name=$func_basename_result
10318 output_path=$func_dirname_result
10319 cwrappersource=$output_path/$objdir/lt-$output_name.c
10320 cwrapper=$output_path/$output_name.exe
10321 $RM $cwrappersource $cwrapper
10322 trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
10324 func_emit_cwrapperexe_src > $cwrappersource
10326 # The wrapper executable is built using the $host compiler,
10327 # because it contains $host paths and files. If cross-
10328 # compiling, it, like the target executable, must be
10329 # executed on the $host or under an emulation environment.
10331 $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
10335 # Now, create the wrapper script for func_source use:
10336 func_ltwrapper_scriptname $cwrapper
10337 $RM $func_ltwrapper_scriptname_result
10338 trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
10340 # note: this script will not be executed, so do not chmod.
10341 if test "x$build" = "x$host"; then
10342 $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
10344 func_emit_wrapper no > $func_ltwrapper_scriptname_result
10350 trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
10352 func_emit_wrapper no > $output
10361 # See if we need to build an old-fashioned archive.
10362 for oldlib in $oldlibs; do
10364 case $build_libtool_libs in
10366 oldobjs="$libobjs_save $symfileobj"
10367 addlibs=$convenience
10368 build_libtool_libs=no
10371 oldobjs=$libobjs_save
10372 addlibs=$old_convenience
10373 build_libtool_libs=no
10376 oldobjs="$old_deplibs $non_pic_objects"
10377 $preload && test -f "$symfileobj" \
10378 && func_append oldobjs " $symfileobj"
10379 addlibs=$old_convenience
10383 if test -n "$addlibs"; then
10384 gentop=$output_objdir/${outputname}x
10385 func_append generated " $gentop"
10387 func_extract_archives $gentop $addlibs
10388 func_append oldobjs " $func_extract_archives_result"
10391 # Do each command in the archive commands.
10392 if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
10393 cmds=$old_archive_from_new_cmds
10396 # Add any objects from preloaded convenience libraries
10397 if test -n "$dlprefiles"; then
10398 gentop=$output_objdir/${outputname}x
10399 func_append generated " $gentop"
10401 func_extract_archives $gentop $dlprefiles
10402 func_append oldobjs " $func_extract_archives_result"
10405 # POSIX demands no paths to be encoded in archives. We have
10406 # to avoid creating archives with duplicate basenames if we
10407 # might have to extract them afterwards, e.g., when creating a
10408 # static archive out of a convenience library, or when linking
10409 # the entirety of a libtool archive into another (currently
10410 # not supported by libtool).
10411 if (for obj in $oldobjs
10413 func_basename "$obj"
10414 $ECHO "$func_basename_result"
10415 done | sort | sort -uc >/dev/null 2>&1); then
10418 echo "copying selected object files to avoid basename conflicts..."
10419 gentop=$output_objdir/${outputname}x
10420 func_append generated " $gentop"
10421 func_mkdir_p "$gentop"
10422 save_oldobjs=$oldobjs
10425 for obj in $save_oldobjs
10427 func_basename "$obj"
10428 objbase=$func_basename_result
10429 case " $oldobjs " in
10430 " ") oldobjs=$obj ;;
10431 *[\ /]"$objbase "*)
10433 # Make sure we don't pick an alternate name that also
10435 newobj=lt$counter-$objbase
10436 func_arith $counter + 1
10437 counter=$func_arith_result
10438 case " $oldobjs " in
10439 *[\ /]"$newobj "*) ;;
10440 *) if test ! -f "$gentop/$newobj"; then break; fi ;;
10443 func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
10444 func_append oldobjs " $gentop/$newobj"
10446 *) func_append oldobjs " $obj" ;;
10450 func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
10451 tool_oldlib=$func_to_tool_file_result
10452 eval cmds=\"$old_archive_cmds\"
10455 len=$func_len_result
10456 if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
10457 cmds=$old_archive_cmds
10458 elif test -n "$archiver_list_spec"; then
10459 func_verbose "using command file archive linking..."
10460 for obj in $oldobjs
10462 func_to_tool_file "$obj"
10463 $ECHO "$func_to_tool_file_result"
10464 done > $output_objdir/$libname.libcmd
10465 func_to_tool_file "$output_objdir/$libname.libcmd"
10466 oldobjs=" $archiver_list_spec$func_to_tool_file_result"
10467 cmds=$old_archive_cmds
10469 # the command line is too long to link in one step, link in parts
10470 func_verbose "using piecewise archive linking..."
10471 save_RANLIB=$RANLIB
10475 save_oldobjs=$oldobjs
10477 # Is there a better way of finding the last object in the list?
10478 for obj in $save_oldobjs
10482 eval test_cmds=\"$old_archive_cmds\"
10483 func_len " $test_cmds"
10484 len0=$func_len_result
10486 for obj in $save_oldobjs
10489 func_arith $len + $func_len_result
10490 len=$func_arith_result
10491 func_append objlist " $obj"
10492 if test "$len" -lt "$max_cmd_len"; then
10495 # the above command should be used before it gets too long
10497 if test "$obj" = "$last_oldobj"; then
10498 RANLIB=$save_RANLIB
10500 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
10501 eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
10506 RANLIB=$save_RANLIB
10508 if test -z "$oldobjs"; then
10509 eval cmds=\"\$concat_cmds\"
10511 eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
10515 func_execute_cmds "$cmds" 'exit $?'
10518 test -n "$generated" && \
10519 func_show_eval "${RM}r$generated"
10521 # Now create the libtool archive.
10525 test yes = "$build_old_libs" && old_library=$libname.$libext
10526 func_verbose "creating $output"
10528 # Preserve any variables that may affect compiler behavior
10529 for var in $variables_saved_for_relink; do
10530 if eval test -z \"\${$var+set}\"; then
10531 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
10532 elif eval var_value=\$$var; test -z "$var_value"; then
10533 relink_command="$var=; export $var; $relink_command"
10535 func_quote_for_eval "$var_value"
10536 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
10539 # Quote the link command for shipping.
10540 relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
10541 relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
10542 if test yes = "$hardcode_automatic"; then
10546 # Only create the output if not a dry run.
10548 for installed in no yes; do
10549 if test yes = "$installed"; then
10550 if test -z "$install_libdir"; then
10553 output=$output_objdir/${outputname}i
10554 # Replace all uninstalled libtool libraries with the installed ones
10555 newdependency_libs=
10556 for deplib in $dependency_libs; do
10559 func_basename "$deplib"
10560 name=$func_basename_result
10561 func_resolve_sysroot "$deplib"
10562 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
10563 test -z "$libdir" && \
10564 func_fatal_error "'$deplib' is not a valid libtool archive"
10565 func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
10568 func_stripname -L '' "$deplib"
10569 func_replace_sysroot "$func_stripname_result"
10570 func_append newdependency_libs " -L$func_replace_sysroot_result"
10573 func_stripname -R '' "$deplib"
10574 func_replace_sysroot "$func_stripname_result"
10575 func_append newdependency_libs " -R$func_replace_sysroot_result"
10577 *) func_append newdependency_libs " $deplib" ;;
10580 dependency_libs=$newdependency_libs
10583 for lib in $dlfiles; do
10586 func_basename "$lib"
10587 name=$func_basename_result
10588 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
10589 test -z "$libdir" && \
10590 func_fatal_error "'$lib' is not a valid libtool archive"
10591 func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
10593 *) func_append newdlfiles " $lib" ;;
10596 dlfiles=$newdlfiles
10598 for lib in $dlprefiles; do
10601 # Only pass preopened files to the pseudo-archive (for
10602 # eventual linking with the app. that links it) if we
10603 # didn't already link the preopened objects directly into
10605 func_basename "$lib"
10606 name=$func_basename_result
10607 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
10608 test -z "$libdir" && \
10609 func_fatal_error "'$lib' is not a valid libtool archive"
10610 func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
10614 dlprefiles=$newdlprefiles
10617 for lib in $dlfiles; do
10619 [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
10620 *) abs=`pwd`"/$lib" ;;
10622 func_append newdlfiles " $abs"
10624 dlfiles=$newdlfiles
10626 for lib in $dlprefiles; do
10628 [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
10629 *) abs=`pwd`"/$lib" ;;
10631 func_append newdlprefiles " $abs"
10633 dlprefiles=$newdlprefiles
10636 # place dlname in correct position for cygwin
10637 # In fact, it would be nice if we could use this code for all target
10638 # systems that can't hard-code library paths into their executables
10639 # and that have no shared library path variable independent of PATH,
10640 # but it turns out we can't easily determine that from inspecting
10641 # libtool variables, so we have to hard-code the OSs to which it
10642 # applies here; at the moment, that means platforms that use the PE
10643 # object format with DLL files. See the long comment at the top of
10644 # tests/bindir.at for full details.
10646 case $host,$output,$installed,$module,$dlname in
10647 *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
10648 # If a -bindir argument was supplied, place the dll there.
10649 if test -n "$bindir"; then
10650 func_relative_path "$install_libdir" "$bindir"
10651 tdlname=$func_relative_path_result/$dlname
10653 # Otherwise fall back on heuristic.
10654 tdlname=../bin/$dlname
10659 # $outputname - a libtool library file
10660 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
10662 # Please DO NOT delete this file!
10663 # It is necessary for linking the library.
10665 # The name that we can dlopen(3).
10668 # Names of this library.
10669 library_names='$library_names'
10671 # The name of the static archive.
10672 old_library='$old_library'
10674 # Linker flags that cannot go in dependency_libs.
10675 inherited_linker_flags='$new_inherited_linker_flags'
10677 # Libraries that this one depends upon.
10678 dependency_libs='$dependency_libs'
10680 # Names of additional weak libraries provided by this library
10681 weak_library_names='$weak_libs'
10683 # Version information for $libname.
10688 # Is this an already installed library?
10689 installed=$installed
10691 # Should we warn about portability when linking against -modules?
10692 shouldnotlink=$module
10694 # Files to dlopen/dlpreopen
10696 dlpreopen='$dlprefiles'
10698 # Directory that this library needs to be installed in:
10699 libdir='$install_libdir'"
10700 if test no,yes = "$installed,$need_relink"; then
10701 $ECHO >> $output "\
10702 relink_command=\"$relink_command\""
10707 # Do a symbolic link so that the libtool archive can be found in
10708 # LD_LIBRARY_PATH before the program is installed.
10709 func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
10715 if test link = "$opt_mode" || test relink = "$opt_mode"; then
10716 func_mode_link ${1+"$@"}
10720 # func_mode_uninstall arg...
10721 func_mode_uninstall ()
10730 # This variable tells wrapper scripts just to set variables rather
10731 # than running their programs.
10732 libtool_install_magic=$magic
10737 -f) func_append RM " $arg"; rmforce=: ;;
10738 -*) func_append RM " $arg" ;;
10739 *) func_append files " $arg" ;;
10744 func_fatal_help "you must specify an RM program"
10748 for file in $files; do
10749 func_dirname "$file" "" "."
10750 dir=$func_dirname_result
10751 if test . = "$dir"; then
10756 func_basename "$file"
10757 name=$func_basename_result
10758 test uninstall = "$opt_mode" && odir=$dir
10760 # Remember odir for removal later, being careful to avoid duplicates
10761 if test clean = "$opt_mode"; then
10762 case " $rmdirs " in
10764 *) func_append rmdirs " $odir" ;;
10768 # Don't error if the file doesn't exist and rm -f was used.
10769 if { test -L "$file"; } >/dev/null 2>&1 ||
10770 { test -h "$file"; } >/dev/null 2>&1 ||
10771 test -f "$file"; then
10773 elif test -d "$file"; then
10776 elif $rmforce; then
10784 # Possibly a libtool archive, so verify it.
10785 if func_lalib_p "$file"; then
10786 func_source $dir/$name
10788 # Delete the libtool libraries and symlinks.
10789 for n in $library_names; do
10790 func_append rmfiles " $odir/$n"
10792 test -n "$old_library" && func_append rmfiles " $odir/$old_library"
10796 case " $library_names " in
10798 *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
10800 test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
10803 if test -n "$library_names"; then
10804 # Do each command in the postuninstall commands.
10805 func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
10808 if test -n "$old_library"; then
10809 # Do each command in the old_postuninstall commands.
10810 func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
10812 # FIXME: should reinstall the best remaining shared library.
10819 # Possibly a libtool object, so verify it.
10820 if func_lalib_p "$file"; then
10822 # Read the .lo file
10823 func_source $dir/$name
10825 # Add PIC object to the list of files to remove.
10826 if test -n "$pic_object" && test none != "$pic_object"; then
10827 func_append rmfiles " $dir/$pic_object"
10830 # Add non-PIC object to the list of files to remove.
10831 if test -n "$non_pic_object" && test none != "$non_pic_object"; then
10832 func_append rmfiles " $dir/$non_pic_object"
10838 if test clean = "$opt_mode"; then
10842 func_stripname '' '.exe' "$file"
10843 file=$func_stripname_result
10844 func_stripname '' '.exe' "$name"
10845 noexename=$func_stripname_result
10846 # $file with .exe has already been added to rmfiles,
10847 # add $file without .exe
10848 func_append rmfiles " $file"
10851 # Do a test to see if this is a libtool program.
10852 if func_ltwrapper_p "$file"; then
10853 if func_ltwrapper_executable_p "$file"; then
10854 func_ltwrapper_scriptname "$file"
10856 func_source $func_ltwrapper_scriptname_result
10857 func_append rmfiles " $func_ltwrapper_scriptname_result"
10860 func_source $dir/$noexename
10863 # note $name still contains .exe if it was in $file originally
10864 # as does the version of $file that was added into $rmfiles
10865 func_append rmfiles " $odir/$name $odir/${name}S.$objext"
10866 if test yes = "$fast_install" && test -n "$relink_command"; then
10867 func_append rmfiles " $odir/lt-$name"
10869 if test "X$noexename" != "X$name"; then
10870 func_append rmfiles " $odir/lt-$noexename.c"
10876 func_show_eval "$RM $rmfiles" 'exit_status=1'
10879 # Try to remove the $objdir's in the directories where we deleted files
10880 for dir in $rmdirs; do
10881 if test -d "$dir"; then
10882 func_show_eval "rmdir $dir >/dev/null 2>&1"
10889 if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
10890 func_mode_uninstall ${1+"$@"}
10893 test -z "$opt_mode" && {
10895 func_fatal_help "you must specify a MODE"
10898 test -z "$exec_cmd" && \
10899 func_fatal_help "invalid operation mode '$opt_mode'"
10901 if test -n "$exec_cmd"; then
10902 eval exec "$exec_cmd"
10909 # The TAGs below are defined such that we never get into a situation
10910 # where we disable both kinds of libraries. Given conflicting
10911 # choices, we go for a static library, that is the most portable,
10912 # since we can't tell whether shared libraries were disabled because
10913 # the user asked for that or because the platform doesn't support
10914 # them. This is particularly important on AIX, because we don't
10915 # support having both static and shared libraries enabled at the same
10916 # time on that platform, so we default to a shared-only configuration.
10917 # If a disable-shared tag is given, we'll fallback to a static-only
10918 # configuration. But we'll never go from static-only to shared-only.
10920 # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
10921 build_libtool_libs=no
10923 # ### END LIBTOOL TAG CONFIG: disable-shared
10925 # ### BEGIN LIBTOOL TAG CONFIG: disable-static
10926 build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
10927 # ### END LIBTOOL TAG CONFIG: disable-static
10930 # mode:shell-script