Merge from trunk: 215733-215743
[official-gcc.git] / gcc-4_7 / ltmain.sh
blob3aac68fa61e041c9db6667b99555bd31461a5d8d
1 # Generated from ltmain.m4sh.
3 # libtool (GNU libtool 1.3134 2009-11-29) 2.2.7a
4 # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
6 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
7 # 2007, 2008, 2009 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 GNU Libtool; see the file COPYING. If not, a copy
28 # can be downloaded from http://www.gnu.org/licenses/gpl.html,
29 # or obtained by writing to the Free Software Foundation, Inc.,
30 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
32 # Usage: $progname [OPTION]... [MODE-ARG]...
34 # Provide generalized library-building support services.
36 # --config show all configuration variables
37 # --debug enable verbose shell tracing
38 # -n, --dry-run display commands without modifying any files
39 # --features display basic configuration information and exit
40 # --mode=MODE use operation mode MODE
41 # --no-finish let install mode avoid finish commands
42 # --preserve-dup-deps don't remove duplicate dependency libraries
43 # --quiet, --silent don't print informational messages
44 # --no-quiet, --no-silent
45 # print informational messages (default)
46 # --tag=TAG use configuration variables from tag TAG
47 # -v, --verbose print more informational messages than default
48 # --no-verbose don't print the extra informational messages
49 # --version print version information
50 # -h, --help, --help-all print short, long, or detailed help message
52 # MODE must be one of the following:
54 # clean remove files from the build directory
55 # compile compile a source file into a libtool object
56 # execute automatically set library path, then run a program
57 # finish complete the installation of libtool libraries
58 # install install libraries or executables
59 # link create a library or an executable
60 # uninstall remove libraries from an installed directory
62 # MODE-ARGS vary depending on the MODE. When passed as first option,
63 # `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
64 # Try `$progname --help --mode=MODE' for a more detailed description of MODE.
66 # When reporting a bug, please describe a test case to reproduce it and
67 # include the following information:
69 # host-triplet: $host
70 # shell: $SHELL
71 # compiler: $LTCC
72 # compiler flags: $LTCFLAGS
73 # linker: $LD (gnu? $with_gnu_ld)
74 # $progname: (GNU libtool 1.3134 2009-11-29) 2.2.7a
75 # automake: $automake_version
76 # autoconf: $autoconf_version
78 # Report bugs to <bug-libtool@gnu.org>.
80 PROGRAM=libtool
81 PACKAGE=libtool
82 VERSION=2.2.7a
83 TIMESTAMP=" 1.3134 2009-11-29"
84 package_revision=1.3134
86 # Be Bourne compatible
87 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
88 emulate sh
89 NULLCMD=:
90 # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
91 # is contrary to our usage. Disable this feature.
92 alias -g '${1+"$@"}'='"$@"'
93 setopt NO_GLOB_SUBST
94 else
95 case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
97 BIN_SH=xpg4; export BIN_SH # for Tru64
98 DUALCASE=1; export DUALCASE # for MKS sh
100 # A function that is used when there is no print builtin or printf.
101 func_fallback_echo ()
103 eval 'cat <<_LTECHO_EOF
105 _LTECHO_EOF'
108 # NLS nuisances: We save the old values to restore during execute mode.
109 # Only set LANG and LC_ALL to C if already set.
110 # These must not be set unconditionally because not all systems understand
111 # e.g. LANG=C (notably SCO).
112 lt_user_locale=
113 lt_safe_locale=
114 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
116 eval "if test \"\${$lt_var+set}\" = set; then
117 save_$lt_var=\$$lt_var
118 $lt_var=C
119 export $lt_var
120 lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
121 lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
123 done
125 $lt_unset CDPATH
133 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
134 # is ksh but when the shell is invoked as "sh" and the current value of
135 # the _XPG environment variable is not equal to 1 (one), the special
136 # positional parameter $0, within a function call, is the name of the
137 # function.
138 progpath="$0"
142 : ${CP="cp -f"}
143 : ${ECHO=$as_echo}
144 : ${EGREP="/bin/grep -E"}
145 : ${FGREP="/bin/grep -F"}
146 : ${GREP="/bin/grep"}
147 : ${LN_S="ln -s"}
148 : ${MAKE="make"}
149 : ${MKDIR="mkdir"}
150 : ${MV="mv -f"}
151 : ${RM="rm -f"}
152 : ${SED="/mount/endor/wildenhu/local-x86_64/bin/sed"}
153 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
154 : ${Xsed="$SED -e 1s/^X//"}
156 # Global variables:
157 EXIT_SUCCESS=0
158 EXIT_FAILURE=1
159 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
160 EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
162 exit_status=$EXIT_SUCCESS
164 # Make sure IFS has a sensible default
165 lt_nl='
167 IFS=" $lt_nl"
169 dirname="s,/[^/]*$,,"
170 basename="s,^.*/,,"
172 # func_dirname_and_basename file append nondir_replacement
173 # perform func_basename and func_dirname in a single function
174 # call:
175 # dirname: Compute the dirname of FILE. If nonempty,
176 # add APPEND to the result, otherwise set result
177 # to NONDIR_REPLACEMENT.
178 # value returned in "$func_dirname_result"
179 # basename: Compute filename of FILE.
180 # value retuned in "$func_basename_result"
181 # Implementation must be kept synchronized with func_dirname
182 # and func_basename. For efficiency, we do not delegate to
183 # those functions but instead duplicate the functionality here.
184 func_dirname_and_basename ()
186 # Extract subdirectory from the argument.
187 func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
188 if test "X$func_dirname_result" = "X${1}"; then
189 func_dirname_result="${3}"
190 else
191 func_dirname_result="$func_dirname_result${2}"
193 func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
196 # Generated shell functions inserted here.
198 # These SED scripts presuppose an absolute path with a trailing slash.
199 pathcar='s,^/\([^/]*\).*$,\1,'
200 pathcdr='s,^/[^/]*,,'
201 removedotparts=':dotsl
202 s@/\./@/@g
203 t dotsl
204 s,/\.$,/,'
205 collapseslashes='s@/\{1,\}@/@g'
206 finalslash='s,/*$,/,'
208 # func_normal_abspath PATH
209 # Remove doubled-up and trailing slashes, "." path components,
210 # and cancel out any ".." path components in PATH after making
211 # it an absolute path.
212 # value returned in "$func_normal_abspath_result"
213 func_normal_abspath ()
215 # Start from root dir and reassemble the path.
216 func_normal_abspath_result=
217 func_normal_abspath_tpath=$1
218 func_normal_abspath_altnamespace=
219 case $func_normal_abspath_tpath in
221 # Empty path, that just means $cwd.
222 func_stripname '' '/' "`pwd`"
223 func_normal_abspath_result=$func_stripname_result
224 return
226 # The next three entries are used to spot a run of precisely
227 # two leading slashes without using negated character classes;
228 # we take advantage of case's first-match behaviour.
229 ///*)
230 # Unusual form of absolute path, do nothing.
232 //*)
233 # Not necessarily an ordinary path; POSIX reserves leading '//'
234 # and for example Cygwin uses it to access remote file shares
235 # over CIFS/SMB, so we conserve a leading double slash if found.
236 func_normal_abspath_altnamespace=/
239 # Absolute path, do nothing.
242 # Relative path, prepend $cwd.
243 func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
245 esac
246 # Cancel out all the simple stuff to save iterations. We also want
247 # the path to end with a slash for ease of parsing, so make sure
248 # there is one (and only one) here.
249 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
250 -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
251 while :; do
252 # Processed it all yet?
253 if test "$func_normal_abspath_tpath" = / ; then
254 # If we ascended to the root using ".." the result may be empty now.
255 if test -z "$func_normal_abspath_result" ; then
256 func_normal_abspath_result=/
258 break
260 func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
261 -e "$pathcar"`
262 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
263 -e "$pathcdr"`
264 # Figure out what to do with it
265 case $func_normal_abspath_tcomponent in
267 # Trailing empty path component, ignore it.
270 # Parent dir; strip last assembled component from result.
271 func_dirname "$func_normal_abspath_result"
272 func_normal_abspath_result=$func_dirname_result
275 # Actual path component, append it.
276 func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
278 esac
279 done
280 # Restore leading double-slash if one was found on entry.
281 func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
284 # func_relative_path SRCDIR DSTDIR
285 # generates a relative path from SRCDIR to DSTDIR, with a trailing
286 # slash if non-empty, suitable for immediately appending a filename
287 # without needing to append a separator.
288 # value returned in "$func_relative_path_result"
289 func_relative_path ()
291 func_relative_path_result=
292 func_normal_abspath "$1"
293 func_relative_path_tlibdir=$func_normal_abspath_result
294 func_normal_abspath "$2"
295 func_relative_path_tbindir=$func_normal_abspath_result
297 # Ascend the tree starting from libdir
298 while :; do
299 # check if we have found a prefix of bindir
300 case $func_relative_path_tbindir in
301 $func_relative_path_tlibdir)
302 # found an exact match
303 func_relative_path_tcancelled=
304 break
306 $func_relative_path_tlibdir*)
307 # found a matching prefix
308 func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
309 func_relative_path_tcancelled=$func_stripname_result
310 if test -z "$func_relative_path_result"; then
311 func_relative_path_result=.
313 break
316 func_dirname $func_relative_path_tlibdir
317 func_relative_path_tlibdir=${func_dirname_result}
318 if test "x$func_relative_path_tlibdir" = x ; then
319 # Have to descend all the way to the root!
320 func_relative_path_result=../$func_relative_path_result
321 func_relative_path_tcancelled=$func_relative_path_tbindir
322 break
324 func_relative_path_result=../$func_relative_path_result
326 esac
327 done
329 # Now calculate path; take care to avoid doubling-up slashes.
330 func_stripname '' '/' "$func_relative_path_result"
331 func_relative_path_result=$func_stripname_result
332 func_stripname '/' '/' "$func_relative_path_tcancelled"
333 if test "x$func_stripname_result" != x ; then
334 func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
337 # Normalisation. If bindir is libdir, return empty string,
338 # else relative path ending with a slash; either way, target
339 # file name can be directly appended.
340 if test ! -z "$func_relative_path_result"; then
341 func_stripname './' '' "$func_relative_path_result/"
342 func_relative_path_result=$func_stripname_result
346 # The name of this program:
347 func_dirname_and_basename "$progpath"
348 progname=$func_basename_result
350 # Make sure we have an absolute path for reexecution:
351 case $progpath in
352 [\\/]*|[A-Za-z]:\\*) ;;
353 *[\\/]*)
354 progdir=$func_dirname_result
355 progdir=`cd "$progdir" && pwd`
356 progpath="$progdir/$progname"
359 save_IFS="$IFS"
360 IFS=:
361 for progdir in $PATH; do
362 IFS="$save_IFS"
363 test -x "$progdir/$progname" && break
364 done
365 IFS="$save_IFS"
366 test -n "$progdir" || progdir=`pwd`
367 progpath="$progdir/$progname"
369 esac
371 # Sed substitution that helps us do robust quoting. It backslashifies
372 # metacharacters that are still active within double-quoted strings.
373 Xsed="${SED}"' -e 1s/^X//'
374 sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
376 # Same as above, but do not quote variable references.
377 double_quote_subst='s/\(["`\\]\)/\\\1/g'
379 # Re-`\' parameter expansions in output of double_quote_subst that were
380 # `\'-ed in input to the same. If an odd number of `\' preceded a '$'
381 # in input to double_quote_subst, that '$' was protected from expansion.
382 # Since each input `\' is now two `\'s, look for any number of runs of
383 # four `\'s followed by two `\'s and then a '$'. `\' that '$'.
384 bs='\\'
385 bs2='\\\\'
386 bs4='\\\\\\\\'
387 dollar='\$'
388 sed_double_backslash="\
389 s/$bs4/&\\
391 s/^$bs2$dollar/$bs&/
392 s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
393 s/\n//g"
395 # Standard options:
396 opt_dry_run=false
397 opt_help=false
398 opt_quiet=false
399 opt_verbose=false
400 opt_warning=:
402 # func_echo arg...
403 # Echo program name prefixed message, along with the current mode
404 # name if it has been set yet.
405 func_echo ()
407 $ECHO "$progname${mode+: }$mode: $*"
410 # func_verbose arg...
411 # Echo program name prefixed message in verbose mode only.
412 func_verbose ()
414 $opt_verbose && func_echo ${1+"$@"}
416 # A bug in bash halts the script if the last line of a function
417 # fails when set -e is in force, so we need another command to
418 # work around that:
422 # func_echo_all arg...
423 # Invoke $ECHO with all args, space-separated.
424 func_echo_all ()
426 $ECHO "$*"
429 # func_error arg...
430 # Echo program name prefixed message to standard error.
431 func_error ()
433 $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
436 # func_warning arg...
437 # Echo program name prefixed warning message to standard error.
438 func_warning ()
440 $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
442 # bash bug again:
446 # func_fatal_error arg...
447 # Echo program name prefixed message to standard error, and exit.
448 func_fatal_error ()
450 func_error ${1+"$@"}
451 exit $EXIT_FAILURE
454 # func_fatal_help arg...
455 # Echo program name prefixed message to standard error, followed by
456 # a help hint, and exit.
457 func_fatal_help ()
459 func_error ${1+"$@"}
460 func_fatal_error "$help"
462 help="Try \`$progname --help' for more information." ## default
465 # func_grep expression filename
466 # Check whether EXPRESSION matches any line of FILENAME, without output.
467 func_grep ()
469 $GREP "$1" "$2" >/dev/null 2>&1
473 # func_mkdir_p directory-path
474 # Make sure the entire path to DIRECTORY-PATH is available.
475 func_mkdir_p ()
477 my_directory_path="$1"
478 my_dir_list=
480 if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
482 # Protect directory names starting with `-'
483 case $my_directory_path in
484 -*) my_directory_path="./$my_directory_path" ;;
485 esac
487 # While some portion of DIR does not yet exist...
488 while test ! -d "$my_directory_path"; do
489 # ...make a list in topmost first order. Use a colon delimited
490 # list incase some portion of path contains whitespace.
491 my_dir_list="$my_directory_path:$my_dir_list"
493 # If the last portion added has no slash in it, the list is done
494 case $my_directory_path in */*) ;; *) break ;; esac
496 # ...otherwise throw away the child directory and loop
497 my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
498 done
499 my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
501 save_mkdir_p_IFS="$IFS"; IFS=':'
502 for my_dir in $my_dir_list; do
503 IFS="$save_mkdir_p_IFS"
504 # mkdir can fail with a `File exist' error if two processes
505 # try to create one of the directories concurrently. Don't
506 # stop in that case!
507 $MKDIR "$my_dir" 2>/dev/null || :
508 done
509 IFS="$save_mkdir_p_IFS"
511 # Bail out if we (or some other process) failed to create a directory.
512 test -d "$my_directory_path" || \
513 func_fatal_error "Failed to create \`$1'"
518 # func_mktempdir [string]
519 # Make a temporary directory that won't clash with other running
520 # libtool processes, and avoids race conditions if possible. If
521 # given, STRING is the basename for that directory.
522 func_mktempdir ()
524 my_template="${TMPDIR-/tmp}/${1-$progname}"
526 if test "$opt_dry_run" = ":"; then
527 # Return a directory name, but don't create it in dry-run mode
528 my_tmpdir="${my_template}-$$"
529 else
531 # If mktemp works, use that first and foremost
532 my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
534 if test ! -d "$my_tmpdir"; then
535 # Failing that, at least try and use $RANDOM to avoid a race
536 my_tmpdir="${my_template}-${RANDOM-0}$$"
538 save_mktempdir_umask=`umask`
539 umask 0077
540 $MKDIR "$my_tmpdir"
541 umask $save_mktempdir_umask
544 # If we're not in dry-run mode, bomb out on failure
545 test -d "$my_tmpdir" || \
546 func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
549 $ECHO "$my_tmpdir"
553 # func_quote_for_eval arg
554 # Aesthetically quote ARG to be evaled later.
555 # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
556 # is double-quoted, suitable for a subsequent eval, whereas
557 # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
558 # which are still active within double quotes backslashified.
559 func_quote_for_eval ()
561 case $1 in
562 *[\\\`\"\$]*)
563 func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
565 func_quote_for_eval_unquoted_result="$1" ;;
566 esac
568 case $func_quote_for_eval_unquoted_result in
569 # Double-quote args containing shell metacharacters to delay
570 # word splitting, command substitution and and variable
571 # expansion for a subsequent eval.
572 # Many Bourne shells cannot handle close brackets correctly
573 # in scan sets, so we specify it separately.
574 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
575 func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
578 func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
579 esac
583 # func_quote_for_expand arg
584 # Aesthetically quote ARG to be evaled later; same as above,
585 # but do not quote variable references.
586 func_quote_for_expand ()
588 case $1 in
589 *[\\\`\"]*)
590 my_arg=`$ECHO "$1" | $SED \
591 -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
593 my_arg="$1" ;;
594 esac
596 case $my_arg in
597 # Double-quote args containing shell metacharacters to delay
598 # word splitting and command substitution for a subsequent eval.
599 # Many Bourne shells cannot handle close brackets correctly
600 # in scan sets, so we specify it separately.
601 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
602 my_arg="\"$my_arg\""
604 esac
606 func_quote_for_expand_result="$my_arg"
610 # func_show_eval cmd [fail_exp]
611 # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
612 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
613 # is given, then evaluate it.
614 func_show_eval ()
616 my_cmd="$1"
617 my_fail_exp="${2-:}"
619 ${opt_silent-false} || {
620 func_quote_for_expand "$my_cmd"
621 eval "func_echo $func_quote_for_expand_result"
624 if ${opt_dry_run-false}; then :; else
625 eval "$my_cmd"
626 my_status=$?
627 if test "$my_status" -eq 0; then :; else
628 eval "(exit $my_status); $my_fail_exp"
634 # func_show_eval_locale cmd [fail_exp]
635 # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
636 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
637 # is given, then evaluate it. Use the saved locale for evaluation.
638 func_show_eval_locale ()
640 my_cmd="$1"
641 my_fail_exp="${2-:}"
643 ${opt_silent-false} || {
644 func_quote_for_expand "$my_cmd"
645 eval "func_echo $func_quote_for_expand_result"
648 if ${opt_dry_run-false}; then :; else
649 eval "$lt_user_locale
650 $my_cmd"
651 my_status=$?
652 eval "$lt_safe_locale"
653 if test "$my_status" -eq 0; then :; else
654 eval "(exit $my_status); $my_fail_exp"
663 # func_version
664 # Echo version message to standard output and exit.
665 func_version ()
667 $SED -n '/(C)/!b go
668 :more
669 /\./!{
671 s/\n# //
672 b more
675 /^# '$PROGRAM' (GNU /,/# warranty; / {
676 s/^# //
677 s/^# *$//
678 s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
680 }' < "$progpath"
681 exit $?
684 # func_usage
685 # Echo short help message to standard output and exit.
686 func_usage ()
688 $SED -n '/^# Usage:/,/^# *-h/ {
689 s/^# //
690 s/^# *$//
691 s/\$progname/'$progname'/
693 }' < "$progpath"
694 echo
695 $ECHO "run \`$progname --help | more' for full usage"
696 exit $?
699 # func_help [NOEXIT]
700 # Echo long help message to standard output and exit,
701 # unless 'noexit' is passed as argument.
702 func_help ()
704 $SED -n '/^# Usage:/,/# Report bugs to/ {
705 s/^# //
706 s/^# *$//
707 s*\$progname*'$progname'*
708 s*\$host*'"$host"'*
709 s*\$SHELL*'"$SHELL"'*
710 s*\$LTCC*'"$LTCC"'*
711 s*\$LTCFLAGS*'"$LTCFLAGS"'*
712 s*\$LD*'"$LD"'*
713 s/\$with_gnu_ld/'"$with_gnu_ld"'/
714 s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
715 s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
717 }' < "$progpath"
718 ret=$?
719 if test -z "$1"; then
720 exit $ret
724 # func_missing_arg argname
725 # Echo program name prefixed message to standard error and set global
726 # exit_cmd.
727 func_missing_arg ()
729 func_error "missing argument for $1"
730 exit_cmd=exit
733 exit_cmd=:
740 magic="%%%MAGIC variable%%%"
741 magic_exe="%%%MAGIC EXE variable%%%"
743 # Global variables.
744 # $mode is unset
745 nonopt=
746 execute_dlfiles=
747 preserve_args=
748 lo2o="s/\\.lo\$/.${objext}/"
749 o2lo="s/\\.${objext}\$/.lo/"
750 extracted_archives=
751 extracted_serial=0
753 opt_dry_run=false
754 opt_finish=:
755 opt_duplicate_deps=false
756 opt_silent=false
757 opt_debug=:
759 # If this variable is set in any of the actions, the command in it
760 # will be execed at the end. This prevents here-documents from being
761 # left over by shells.
762 exec_cmd=
764 # func_fatal_configuration arg...
765 # Echo program name prefixed message to standard error, followed by
766 # a configuration failure hint, and exit.
767 func_fatal_configuration ()
769 func_error ${1+"$@"}
770 func_error "See the $PACKAGE documentation for more information."
771 func_fatal_error "Fatal configuration error."
775 # func_config
776 # Display the configuration for all the tags in this script.
777 func_config ()
779 re_begincf='^# ### BEGIN LIBTOOL'
780 re_endcf='^# ### END LIBTOOL'
782 # Default configuration.
783 $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
785 # Now print the configurations for the tags.
786 for tagname in $taglist; do
787 $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
788 done
790 exit $?
793 # func_features
794 # Display the features supported by this script.
795 func_features ()
797 echo "host: $host"
798 if test "$build_libtool_libs" = yes; then
799 echo "enable shared libraries"
800 else
801 echo "disable shared libraries"
803 if test "$build_old_libs" = yes; then
804 echo "enable static libraries"
805 else
806 echo "disable static libraries"
809 exit $?
812 # func_enable_tag tagname
813 # Verify that TAGNAME is valid, and either flag an error and exit, or
814 # enable the TAGNAME tag. We also add TAGNAME to the global $taglist
815 # variable here.
816 func_enable_tag ()
818 # Global variable:
819 tagname="$1"
821 re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
822 re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
823 sed_extractcf="/$re_begincf/,/$re_endcf/p"
825 # Validate tagname.
826 case $tagname in
827 *[!-_A-Za-z0-9,/]*)
828 func_fatal_error "invalid tag name: $tagname"
830 esac
832 # Don't test for the "default" C tag, as we know it's
833 # there but not specially marked.
834 case $tagname in
835 CC) ;;
837 if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
838 taglist="$taglist $tagname"
840 # Evaluate the configuration. Be careful to quote the path
841 # and the sed script, to avoid splitting on whitespace, but
842 # also don't use non-portable quotes within backquotes within
843 # quotes we have to do it in 2 steps:
844 extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
845 eval "$extractedcf"
846 else
847 func_error "ignoring unknown tag $tagname"
850 esac
853 # Parse options once, thoroughly. This comes as soon as possible in
854 # the script to make things like `libtool --version' happen quickly.
857 # Shorthand for --mode=foo, only valid as the first argument
858 case $1 in
859 clean|clea|cle|cl)
860 shift; set dummy --mode clean ${1+"$@"}; shift
862 compile|compil|compi|comp|com|co|c)
863 shift; set dummy --mode compile ${1+"$@"}; shift
865 execute|execut|execu|exec|exe|ex|e)
866 shift; set dummy --mode execute ${1+"$@"}; shift
868 finish|finis|fini|fin|fi|f)
869 shift; set dummy --mode finish ${1+"$@"}; shift
871 install|instal|insta|inst|ins|in|i)
872 shift; set dummy --mode install ${1+"$@"}; shift
874 link|lin|li|l)
875 shift; set dummy --mode link ${1+"$@"}; shift
877 uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
878 shift; set dummy --mode uninstall ${1+"$@"}; shift
880 esac
882 # Parse non-mode specific arguments:
883 while test "$#" -gt 0; do
884 opt="$1"
885 shift
887 case $opt in
888 --config) func_config ;;
890 --debug) preserve_args="$preserve_args $opt"
891 func_echo "enabling shell trace mode"
892 opt_debug='set -x'
893 $opt_debug
896 -dlopen) test "$#" -eq 0 && func_missing_arg "$opt" && break
897 execute_dlfiles="$execute_dlfiles $1"
898 shift
901 --dry-run | -n) opt_dry_run=: ;;
902 --features) func_features ;;
903 --finish) mode="finish" ;;
904 --no-finish) opt_finish=false ;;
906 --mode) test "$#" -eq 0 && func_missing_arg "$opt" && break
907 case $1 in
908 # Valid mode arguments:
909 clean) ;;
910 compile) ;;
911 execute) ;;
912 finish) ;;
913 install) ;;
914 link) ;;
915 relink) ;;
916 uninstall) ;;
918 # Catch anything else as an error
919 *) func_error "invalid argument for $opt"
920 exit_cmd=exit
921 break
923 esac
925 mode="$1"
926 shift
929 --preserve-dup-deps)
930 opt_duplicate_deps=: ;;
932 --quiet|--silent) preserve_args="$preserve_args $opt"
933 opt_silent=:
934 opt_verbose=false
937 --no-quiet|--no-silent)
938 preserve_args="$preserve_args $opt"
939 opt_silent=false
942 --verbose| -v) preserve_args="$preserve_args $opt"
943 opt_silent=false
944 opt_verbose=:
947 --no-verbose) preserve_args="$preserve_args $opt"
948 opt_verbose=false
951 --tag) test "$#" -eq 0 && func_missing_arg "$opt" && break
952 preserve_args="$preserve_args $opt $1"
953 func_enable_tag "$1" # tagname is set here
954 shift
957 # Separate optargs to long options:
958 -dlopen=*|--mode=*|--tag=*)
959 func_opt_split "$opt"
960 set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
961 shift
964 -\?|-h) func_usage ;;
965 --help) opt_help=: ;;
966 --help-all) opt_help=': help-all' ;;
967 --version) func_version ;;
969 -*) func_fatal_help "unrecognized option \`$opt'" ;;
971 *) nonopt="$opt"
972 break
974 esac
975 done
978 case $host in
979 *cygwin* | *mingw* | *pw32* | *cegcc*)
980 # don't eliminate duplications in $postdeps and $predeps
981 opt_duplicate_compiler_generated_deps=:
984 opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
986 esac
988 # Having warned about all mis-specified options, bail out if
989 # anything was wrong.
990 $exit_cmd $EXIT_FAILURE
993 # func_check_version_match
994 # Ensure that we are using m4 macros, and libtool script from the same
995 # release of libtool.
996 func_check_version_match ()
998 if test "$package_revision" != "$macro_revision"; then
999 if test "$VERSION" != "$macro_version"; then
1000 if test -z "$macro_version"; then
1001 cat >&2 <<_LT_EOF
1002 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
1003 $progname: definition of this LT_INIT comes from an older release.
1004 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
1005 $progname: and run autoconf again.
1006 _LT_EOF
1007 else
1008 cat >&2 <<_LT_EOF
1009 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
1010 $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
1011 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
1012 $progname: and run autoconf again.
1013 _LT_EOF
1015 else
1016 cat >&2 <<_LT_EOF
1017 $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
1018 $progname: but the definition of this LT_INIT comes from revision $macro_revision.
1019 $progname: You should recreate aclocal.m4 with macros from revision $package_revision
1020 $progname: of $PACKAGE $VERSION and run autoconf again.
1021 _LT_EOF
1024 exit $EXIT_MISMATCH
1029 ## ----------- ##
1030 ## Main. ##
1031 ## ----------- ##
1033 $opt_help || {
1034 # Sanity checks first:
1035 func_check_version_match
1037 if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
1038 func_fatal_configuration "not configured to build any kind of library"
1041 test -z "$mode" && func_fatal_error "error: you must specify a MODE."
1044 # Darwin sucks
1045 eval "std_shrext=\"$shrext_cmds\""
1048 # Only execute mode is allowed to have -dlopen flags.
1049 if test -n "$execute_dlfiles" && test "$mode" != execute; then
1050 func_error "unrecognized option \`-dlopen'"
1051 $ECHO "$help" 1>&2
1052 exit $EXIT_FAILURE
1055 # Change the help message to a mode-specific one.
1056 generic_help="$help"
1057 help="Try \`$progname --help --mode=$mode' for more information."
1061 # func_lalib_p file
1062 # True iff FILE is a libtool `.la' library or `.lo' object file.
1063 # This function is only a basic sanity check; it will hardly flush out
1064 # determined imposters.
1065 func_lalib_p ()
1067 test -f "$1" &&
1068 $SED -e 4q "$1" 2>/dev/null \
1069 | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
1072 # func_lalib_unsafe_p file
1073 # True iff FILE is a libtool `.la' library or `.lo' object file.
1074 # This function implements the same check as func_lalib_p without
1075 # resorting to external programs. To this end, it redirects stdin and
1076 # closes it afterwards, without saving the original file descriptor.
1077 # As a safety measure, use it only where a negative result would be
1078 # fatal anyway. Works if `file' does not exist.
1079 func_lalib_unsafe_p ()
1081 lalib_p=no
1082 if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
1083 for lalib_p_l in 1 2 3 4
1085 read lalib_p_line
1086 case "$lalib_p_line" in
1087 \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
1088 esac
1089 done
1090 exec 0<&5 5<&-
1092 test "$lalib_p" = yes
1095 # func_ltwrapper_script_p file
1096 # True iff FILE is a libtool wrapper script
1097 # This function is only a basic sanity check; it will hardly flush out
1098 # determined imposters.
1099 func_ltwrapper_script_p ()
1101 func_lalib_p "$1"
1104 # func_ltwrapper_executable_p file
1105 # True iff FILE is a libtool wrapper executable
1106 # This function is only a basic sanity check; it will hardly flush out
1107 # determined imposters.
1108 func_ltwrapper_executable_p ()
1110 func_ltwrapper_exec_suffix=
1111 case $1 in
1112 *.exe) ;;
1113 *) func_ltwrapper_exec_suffix=.exe ;;
1114 esac
1115 $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
1118 # func_ltwrapper_scriptname file
1119 # Assumes file is an ltwrapper_executable
1120 # uses $file to determine the appropriate filename for a
1121 # temporary ltwrapper_script.
1122 func_ltwrapper_scriptname ()
1124 func_ltwrapper_scriptname_result=""
1125 if func_ltwrapper_executable_p "$1"; then
1126 func_dirname_and_basename "$1" "" "."
1127 func_stripname '' '.exe' "$func_basename_result"
1128 func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
1132 # func_ltwrapper_p file
1133 # True iff FILE is a libtool wrapper script or wrapper executable
1134 # This function is only a basic sanity check; it will hardly flush out
1135 # determined imposters.
1136 func_ltwrapper_p ()
1138 func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
1142 # func_execute_cmds commands fail_cmd
1143 # Execute tilde-delimited COMMANDS.
1144 # If FAIL_CMD is given, eval that upon failure.
1145 # FAIL_CMD may read-access the current command in variable CMD!
1146 func_execute_cmds ()
1148 $opt_debug
1149 save_ifs=$IFS; IFS='~'
1150 for cmd in $1; do
1151 IFS=$save_ifs
1152 eval "cmd=\"$cmd\""
1153 func_show_eval "$cmd" "${2-:}"
1154 done
1155 IFS=$save_ifs
1159 # func_source file
1160 # Source FILE, adding directory component if necessary.
1161 # Note that it is not necessary on cygwin/mingw to append a dot to
1162 # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
1163 # behavior happens only for exec(3), not for open(2)! Also, sourcing
1164 # `FILE.' does not work on cygwin managed mounts.
1165 func_source ()
1167 $opt_debug
1168 case $1 in
1169 */* | *\\*) . "$1" ;;
1170 *) . "./$1" ;;
1171 esac
1175 # func_infer_tag arg
1176 # Infer tagged configuration to use if any are available and
1177 # if one wasn't chosen via the "--tag" command line option.
1178 # Only attempt this if the compiler in the base compile
1179 # command doesn't match the default compiler.
1180 # arg is usually of the form 'gcc ...'
1181 func_infer_tag ()
1183 $opt_debug
1184 if test -n "$available_tags" && test -z "$tagname"; then
1185 CC_quoted=
1186 for arg in $CC; do
1187 func_quote_for_eval "$arg"
1188 CC_quoted="$CC_quoted $func_quote_for_eval_result"
1189 done
1190 CC_expanded=`func_echo_all $CC`
1191 CC_quoted_expanded=`func_echo_all $CC_quoted`
1192 case $@ in
1193 # Blanks in the command may have been stripped by the calling shell,
1194 # but not from the CC environment variable when configure was run.
1195 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1196 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
1197 # Blanks at the start of $base_compile will cause this to fail
1198 # if we don't check for them as well.
1200 for z in $available_tags; do
1201 if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1202 # Evaluate the configuration.
1203 eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1204 CC_quoted=
1205 for arg in $CC; do
1206 # Double-quote args containing other shell metacharacters.
1207 func_quote_for_eval "$arg"
1208 CC_quoted="$CC_quoted $func_quote_for_eval_result"
1209 done
1210 CC_expanded=`func_echo_all $CC`
1211 CC_quoted_expanded=`func_echo_all $CC_quoted`
1212 case "$@ " in
1213 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1214 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
1215 # The compiler in the base compile command matches
1216 # the one in the tagged configuration.
1217 # Assume this is the tagged configuration we want.
1218 tagname=$z
1219 break
1221 esac
1223 done
1224 # If $tagname still isn't set, then no tagged configuration
1225 # was found and let the user know that the "--tag" command
1226 # line option must be used.
1227 if test -z "$tagname"; then
1228 func_echo "unable to infer tagged configuration"
1229 func_fatal_error "specify a tag with \`--tag'"
1230 # else
1231 # func_verbose "using $tagname tagged configuration"
1234 esac
1240 # func_write_libtool_object output_name pic_name nonpic_name
1241 # Create a libtool object file (analogous to a ".la" file),
1242 # but don't create it if we're doing a dry run.
1243 func_write_libtool_object ()
1245 write_libobj=${1}
1246 if test "$build_libtool_libs" = yes; then
1247 write_lobj=\'${2}\'
1248 else
1249 write_lobj=none
1252 if test "$build_old_libs" = yes; then
1253 write_oldobj=\'${3}\'
1254 else
1255 write_oldobj=none
1258 $opt_dry_run || {
1259 cat >${write_libobj}T <<EOF
1260 # $write_libobj - a libtool object file
1261 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1263 # Please DO NOT delete this file!
1264 # It is necessary for linking the library.
1266 # Name of the PIC object.
1267 pic_object=$write_lobj
1269 # Name of the non-PIC object
1270 non_pic_object=$write_oldobj
1273 $MV "${write_libobj}T" "${write_libobj}"
1277 # func_mode_compile arg...
1278 func_mode_compile ()
1280 $opt_debug
1281 # Get the compilation command and the source file.
1282 base_compile=
1283 shared_compile=
1284 static_compile=
1285 srcfile="$nonopt" # always keep a non-empty value in "srcfile"
1286 suppress_opt=yes
1287 suppress_output=
1288 arg_mode=normal
1289 libobj=
1290 later=
1291 pie_flag=
1293 for arg
1295 case $arg_mode in
1296 arg )
1297 # do not "continue". Instead, add this to base_compile
1298 lastarg="$arg"
1299 arg_mode=normal
1302 target )
1303 libobj="$arg"
1304 arg_mode=normal
1305 continue
1308 xcompiler-shared )
1309 arg_mode=normal
1310 func_quote_for_eval "$arg"
1311 shared_compile="$shared_compile $func_quote_for_eval_result"
1312 continue
1315 xcompiler-static )
1316 arg_mode=normal
1317 func_quote_for_eval "$arg"
1318 static_compile="$static_compile $func_quote_for_eval_result"
1319 continue
1322 normal )
1323 # Accept any command-line options.
1324 case $arg in
1326 test -n "$libobj" && \
1327 func_fatal_error "you cannot specify \`-o' more than once"
1328 arg_mode=target
1329 continue
1332 -pie | -fpie | -fPIE)
1333 pie_flag="$pie_flag $arg"
1334 continue
1337 -shared | -static | -prefer-pic | -prefer-non-pic)
1338 later="$later $arg"
1339 continue
1342 -no-suppress)
1343 suppress_opt=no
1344 continue
1347 -Xcompiler)
1348 arg_mode=arg # the next one goes into the "base_compile" arg list
1349 continue # The current "srcfile" will either be retained or
1350 ;; # replaced later. I would guess that would be a bug.
1352 -Xcompiler-shared)
1353 arg_mode=xcompiler-shared # the next one goes into the
1354 # "shared_compile" arg list
1355 continue
1358 -Xcompiler-static)
1359 arg_mode=xcompiler-static # the next one goes into the
1360 # "static_compile" arg list
1361 continue
1364 -Wc,*)
1365 func_stripname '-Wc,' '' "$arg"
1366 args=$func_stripname_result
1367 lastarg=
1368 save_ifs="$IFS"; IFS=','
1369 for arg in $args; do
1370 IFS="$save_ifs"
1371 func_quote_for_eval "$arg"
1372 lastarg="$lastarg $func_quote_for_eval_result"
1373 done
1374 IFS="$save_ifs"
1375 func_stripname ' ' '' "$lastarg"
1376 lastarg=$func_stripname_result
1378 # Add the arguments to base_compile.
1379 base_compile="$base_compile $lastarg"
1380 continue
1384 # Accept the current argument as the source file.
1385 # The previous "srcfile" becomes the current argument.
1387 lastarg="$srcfile"
1388 srcfile="$arg"
1390 esac # case $arg
1392 esac # case $arg_mode
1394 # Aesthetically quote the previous argument.
1395 func_quote_for_eval "$lastarg"
1396 base_compile="$base_compile $func_quote_for_eval_result"
1397 done # for arg
1399 case $arg_mode in
1400 arg)
1401 func_fatal_error "you must specify an argument for -Xcompile"
1403 target)
1404 func_fatal_error "you must specify a target with \`-o'"
1407 # Get the name of the library object.
1408 test -z "$libobj" && {
1409 func_basename "$srcfile"
1410 libobj="$func_basename_result"
1413 esac
1415 # Recognize several different file suffixes.
1416 # If the user specifies -o file.o, it is replaced with file.lo
1417 case $libobj in
1418 *.[cCFSifmso] | \
1419 *.ada | *.adb | *.ads | *.asm | \
1420 *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
1421 *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup)
1422 func_xform "$libobj"
1423 libobj=$func_xform_result
1425 esac
1427 case $libobj in
1428 *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
1430 func_fatal_error "cannot determine name of library object from \`$libobj'"
1432 esac
1434 func_infer_tag $base_compile
1436 for arg in $later; do
1437 case $arg in
1438 -shared)
1439 test "$build_libtool_libs" != yes && \
1440 func_fatal_configuration "can not build a shared library"
1441 build_old_libs=no
1442 continue
1445 -static)
1446 build_libtool_libs=no
1447 build_old_libs=yes
1448 continue
1451 -prefer-pic)
1452 pic_mode=yes
1453 continue
1456 -prefer-non-pic)
1457 pic_mode=no
1458 continue
1460 esac
1461 done
1463 func_quote_for_eval "$libobj"
1464 test "X$libobj" != "X$func_quote_for_eval_result" \
1465 && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
1466 && func_warning "libobj name \`$libobj' may not contain shell special characters."
1467 func_dirname_and_basename "$obj" "/" ""
1468 objname="$func_basename_result"
1469 xdir="$func_dirname_result"
1470 lobj=${xdir}$objdir/$objname
1472 test -z "$base_compile" && \
1473 func_fatal_help "you must specify a compilation command"
1475 # Delete any leftover library objects.
1476 if test "$build_old_libs" = yes; then
1477 removelist="$obj $lobj $libobj ${libobj}T"
1478 else
1479 removelist="$lobj $libobj ${libobj}T"
1482 # On Cygwin there's no "real" PIC flag so we must build both object types
1483 case $host_os in
1484 cygwin* | mingw* | pw32* | os2* | cegcc*)
1485 pic_mode=default
1487 esac
1488 if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
1489 # non-PIC code in shared libraries is not supported
1490 pic_mode=default
1493 # Calculate the filename of the output object if compiler does
1494 # not support -o with -c
1495 if test "$compiler_c_o" = no; then
1496 output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
1497 lockfile="$output_obj.lock"
1498 else
1499 output_obj=
1500 need_locks=no
1501 lockfile=
1504 # Lock this critical section if it is needed
1505 # We use this script file to make the link, it avoids creating a new file
1506 if test "$need_locks" = yes; then
1507 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
1508 func_echo "Waiting for $lockfile to be removed"
1509 sleep 2
1510 done
1511 elif test "$need_locks" = warn; then
1512 if test -f "$lockfile"; then
1513 $ECHO "\
1514 *** ERROR, $lockfile exists and contains:
1515 `cat $lockfile 2>/dev/null`
1517 This indicates that another process is trying to use the same
1518 temporary object file, and libtool could not work around it because
1519 your compiler does not support \`-c' and \`-o' together. If you
1520 repeat this compilation, it may succeed, by chance, but you had better
1521 avoid parallel builds (make -j) in this platform, or get a better
1522 compiler."
1524 $opt_dry_run || $RM $removelist
1525 exit $EXIT_FAILURE
1527 removelist="$removelist $output_obj"
1528 $ECHO "$srcfile" > "$lockfile"
1531 $opt_dry_run || $RM $removelist
1532 removelist="$removelist $lockfile"
1533 trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
1535 if test -n "$fix_srcfile_path"; then
1536 eval "srcfile=\"$fix_srcfile_path\""
1538 func_quote_for_eval "$srcfile"
1539 qsrcfile=$func_quote_for_eval_result
1541 # Only build a PIC object if we are building libtool libraries.
1542 if test "$build_libtool_libs" = yes; then
1543 # Without this assignment, base_compile gets emptied.
1544 fbsd_hideous_sh_bug=$base_compile
1546 if test "$pic_mode" != no; then
1547 command="$base_compile $qsrcfile $pic_flag $shared_compile"
1548 else
1549 # Don't build PIC code
1550 command="$base_compile $qsrcfile $shared_compile"
1553 func_mkdir_p "$xdir$objdir"
1555 if test -z "$output_obj"; then
1556 # Place PIC objects in $objdir
1557 command="$command -o $lobj"
1560 func_show_eval_locale "$command" \
1561 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
1563 if test "$need_locks" = warn &&
1564 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1565 $ECHO "\
1566 *** ERROR, $lockfile contains:
1567 `cat $lockfile 2>/dev/null`
1569 but it should contain:
1570 $srcfile
1572 This indicates that another process is trying to use the same
1573 temporary object file, and libtool could not work around it because
1574 your compiler does not support \`-c' and \`-o' together. If you
1575 repeat this compilation, it may succeed, by chance, but you had better
1576 avoid parallel builds (make -j) in this platform, or get a better
1577 compiler."
1579 $opt_dry_run || $RM $removelist
1580 exit $EXIT_FAILURE
1583 # Just move the object if needed, then go on to compile the next one
1584 if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
1585 func_show_eval '$MV "$output_obj" "$lobj"' \
1586 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
1589 # Allow error messages only from the first compilation.
1590 if test "$suppress_opt" = yes; then
1591 suppress_output=' >/dev/null 2>&1'
1595 # Only build a position-dependent object if we build old libraries.
1596 if test "$build_old_libs" = yes; then
1597 if test "$pic_mode" != yes; then
1598 # Don't build PIC code
1599 command="$base_compile $qsrcfile$pie_flag $static_compile"
1600 else
1601 command="$base_compile $qsrcfile $pic_flag $static_compile"
1603 if test "$compiler_c_o" = yes; then
1604 command="$command -o $obj"
1607 # Suppress compiler output if we already did a PIC compilation.
1608 command="$command$suppress_output"
1609 func_show_eval_locale "$command" \
1610 '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
1612 if test "$need_locks" = warn &&
1613 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1614 $ECHO "\
1615 *** ERROR, $lockfile contains:
1616 `cat $lockfile 2>/dev/null`
1618 but it should contain:
1619 $srcfile
1621 This indicates that another process is trying to use the same
1622 temporary object file, and libtool could not work around it because
1623 your compiler does not support \`-c' and \`-o' together. If you
1624 repeat this compilation, it may succeed, by chance, but you had better
1625 avoid parallel builds (make -j) in this platform, or get a better
1626 compiler."
1628 $opt_dry_run || $RM $removelist
1629 exit $EXIT_FAILURE
1632 # Just move the object if needed
1633 if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
1634 func_show_eval '$MV "$output_obj" "$obj"' \
1635 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
1639 $opt_dry_run || {
1640 func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
1642 # Unlock the critical section if it was locked
1643 if test "$need_locks" != no; then
1644 removelist=$lockfile
1645 $RM "$lockfile"
1649 exit $EXIT_SUCCESS
1652 $opt_help || {
1653 test "$mode" = compile && func_mode_compile ${1+"$@"}
1656 func_mode_help ()
1658 # We need to display help for each of the modes.
1659 case $mode in
1661 # Generic help is extracted from the usage comments
1662 # at the start of this file.
1663 func_help
1666 clean)
1667 $ECHO \
1668 "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
1670 Remove files from the build directory.
1672 RM is the name of the program to use to delete files associated with each FILE
1673 (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
1674 to RM.
1676 If FILE is a libtool library, object or program, all the files associated
1677 with it are deleted. Otherwise, only FILE itself is deleted using RM."
1680 compile)
1681 $ECHO \
1682 "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
1684 Compile a source file into a libtool library object.
1686 This mode accepts the following additional options:
1688 -o OUTPUT-FILE set the output file name to OUTPUT-FILE
1689 -no-suppress do not suppress compiler output for multiple passes
1690 -prefer-pic try to building PIC objects only
1691 -prefer-non-pic try to building non-PIC objects only
1692 -shared do not build a \`.o' file suitable for static linking
1693 -static only build a \`.o' file suitable for static linking
1694 -Wc,FLAG pass FLAG directly to the compiler
1695 -Xcompiler-shared FLAG
1696 pass FLAG directly to the compiler when compiling shared
1697 libraries
1698 -Xcompiler-static FLAG
1699 pass FLAG directly to the compiler when compiling static
1700 libraries
1702 COMPILE-COMMAND is a command to be used in creating a \`standard' object file
1703 from the given SOURCEFILE.
1705 The output file name is determined by removing the directory component from
1706 SOURCEFILE, then substituting the C source code suffix \`.c' with the
1707 library object suffix, \`.lo'."
1710 execute)
1711 $ECHO \
1712 "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
1714 Automatically set library path, then run a program.
1716 This mode accepts the following additional options:
1718 -dlopen FILE add the directory containing FILE to the library path
1720 This mode sets the library path environment variable according to \`-dlopen'
1721 flags.
1723 If any of the ARGS are libtool executable wrappers, then they are translated
1724 into their corresponding uninstalled binary, and any of their required library
1725 directories are added to the library path.
1727 Then, COMMAND is executed, with ARGS as arguments."
1730 finish)
1731 $ECHO \
1732 "Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
1734 Complete the installation of libtool libraries.
1736 Each LIBDIR is a directory that contains libtool libraries.
1738 The commands that this mode executes may require superuser privileges. Use
1739 the \`--dry-run' option if you just want to see what would be executed."
1742 install)
1743 $ECHO \
1744 "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
1746 Install executables or libraries.
1748 INSTALL-COMMAND is the installation command. The first component should be
1749 either the \`install' or \`cp' program.
1751 The following components of INSTALL-COMMAND are treated specially:
1753 -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation
1755 The rest of the components are interpreted as arguments to that command (only
1756 BSD-compatible install options are recognized)."
1759 link)
1760 $ECHO \
1761 "Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
1763 Link object files or libraries together to form another library, or to
1764 create an executable program.
1766 LINK-COMMAND is a command using the C compiler that you would use to create
1767 a program from several object files.
1769 The following components of LINK-COMMAND are treated specially:
1771 -all-static do not do any dynamic linking at all
1772 -avoid-version do not add a version suffix if possible
1773 -bindir BINDIR specify path to binaries directory (for systems where
1774 libraries must be found in the PATH setting at runtime)
1775 -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime
1776 -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
1777 -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
1778 -export-symbols SYMFILE
1779 try to export only the symbols listed in SYMFILE
1780 -export-symbols-regex REGEX
1781 try to export only the symbols matching REGEX
1782 -LLIBDIR search LIBDIR for required installed libraries
1783 -lNAME OUTPUT-FILE requires the installed library libNAME
1784 -module build a library that can dlopened
1785 -no-fast-install disable the fast-install mode
1786 -no-install link a not-installable executable
1787 -no-undefined declare that a library does not refer to external symbols
1788 -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
1789 -objectlist FILE Use a list of object files found in FILE to specify objects
1790 -precious-files-regex REGEX
1791 don't remove output files matching REGEX
1792 -release RELEASE specify package release information
1793 -rpath LIBDIR the created library will eventually be installed in LIBDIR
1794 -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
1795 -shared only do dynamic linking of libtool libraries
1796 -shrext SUFFIX override the standard shared library file extension
1797 -static do not do any dynamic linking of uninstalled libtool libraries
1798 -static-libtool-libs
1799 do not do any dynamic linking of libtool libraries
1800 -version-info CURRENT[:REVISION[:AGE]]
1801 specify library version info [each variable defaults to 0]
1802 -weak LIBNAME declare that the target provides the LIBNAME interface
1803 -Wc,FLAG
1804 -Xcompiler FLAG pass linker-specific FLAG directly to the compiler
1805 -Wl,FLAG
1806 -Xlinker FLAG pass linker-specific FLAG directly to the linker
1807 -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC)
1809 All other options (arguments beginning with \`-') are ignored.
1811 Every other argument is treated as a filename. Files ending in \`.la' are
1812 treated as uninstalled libtool libraries, other files are standard or library
1813 object files.
1815 If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
1816 only library objects (\`.lo' files) may be specified, and \`-rpath' is
1817 required, except when creating a convenience library.
1819 If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
1820 using \`ar' and \`ranlib', or on Windows using \`lib'.
1822 If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
1823 is created, otherwise an executable program is created."
1826 uninstall)
1827 $ECHO \
1828 "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
1830 Remove libraries from an installation directory.
1832 RM is the name of the program to use to delete files associated with each FILE
1833 (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
1834 to RM.
1836 If FILE is a libtool library, all the files associated with it are deleted.
1837 Otherwise, only FILE itself is deleted using RM."
1841 func_fatal_help "invalid operation mode \`$mode'"
1843 esac
1845 echo
1846 $ECHO "Try \`$progname --help' for more information about other modes."
1849 # Now that we've collected a possible --mode arg, show help if necessary
1850 if $opt_help; then
1851 if test "$opt_help" = :; then
1852 func_mode_help
1853 else
1855 func_help noexit
1856 for mode in compile link execute install finish uninstall clean; do
1857 func_mode_help
1858 done
1859 } | sed -n '1p; 2,$s/^Usage:/ or: /p'
1861 func_help noexit
1862 for mode in compile link execute install finish uninstall clean; do
1863 echo
1864 func_mode_help
1865 done
1867 sed '1d
1868 /^When reporting/,/^Report/{
1873 /information about other modes/d
1874 /more detailed .*MODE/d
1875 s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
1877 exit $?
1881 # func_mode_execute arg...
1882 func_mode_execute ()
1884 $opt_debug
1885 # The first argument is the command name.
1886 cmd="$nonopt"
1887 test -z "$cmd" && \
1888 func_fatal_help "you must specify a COMMAND"
1890 # Handle -dlopen flags immediately.
1891 for file in $execute_dlfiles; do
1892 test -f "$file" \
1893 || func_fatal_help "\`$file' is not a file"
1895 dir=
1896 case $file in
1897 *.la)
1898 # Check to see that this really is a libtool archive.
1899 func_lalib_unsafe_p "$file" \
1900 || func_fatal_help "\`$lib' is not a valid libtool archive"
1902 # Read the libtool library.
1903 dlname=
1904 library_names=
1905 func_source "$file"
1907 # Skip this library if it cannot be dlopened.
1908 if test -z "$dlname"; then
1909 # Warn if it was a shared library.
1910 test -n "$library_names" && \
1911 func_warning "\`$file' was not linked with \`-export-dynamic'"
1912 continue
1915 func_dirname "$file" "" "."
1916 dir="$func_dirname_result"
1918 if test -f "$dir/$objdir/$dlname"; then
1919 dir="$dir/$objdir"
1920 else
1921 if test ! -f "$dir/$dlname"; then
1922 func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
1927 *.lo)
1928 # Just add the directory containing the .lo file.
1929 func_dirname "$file" "" "."
1930 dir="$func_dirname_result"
1934 func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
1935 continue
1937 esac
1939 # Get the absolute pathname.
1940 absdir=`cd "$dir" && pwd`
1941 test -n "$absdir" && dir="$absdir"
1943 # Now add the directory to shlibpath_var.
1944 if eval test -z \"\$$shlibpath_var\"; then
1945 eval $shlibpath_var=\$dir
1946 else
1947 eval $shlibpath_var=\$dir:\$$shlibpath_var
1949 done
1951 # This variable tells wrapper scripts just to set shlibpath_var
1952 # rather than running their programs.
1953 libtool_execute_magic="$magic"
1955 # Check if any of the arguments is a wrapper script.
1956 args=
1957 for file
1959 case $file in
1960 -* | *.la | *.lo ) ;;
1962 # Do a test to see if this is really a libtool program.
1963 if func_ltwrapper_script_p "$file"; then
1964 func_source "$file"
1965 # Transform arg to wrapped name.
1966 file="$progdir/$program"
1967 elif func_ltwrapper_executable_p "$file"; then
1968 func_ltwrapper_scriptname "$file"
1969 func_source "$func_ltwrapper_scriptname_result"
1970 # Transform arg to wrapped name.
1971 file="$progdir/$program"
1974 esac
1975 # Quote arguments (to preserve shell metacharacters).
1976 func_quote_for_eval "$file"
1977 args="$args $func_quote_for_eval_result"
1978 done
1980 if test "X$opt_dry_run" = Xfalse; then
1981 if test -n "$shlibpath_var"; then
1982 # Export the shlibpath_var.
1983 eval "export $shlibpath_var"
1986 # Restore saved environment variables
1987 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
1989 eval "if test \"\${save_$lt_var+set}\" = set; then
1990 $lt_var=\$save_$lt_var; export $lt_var
1991 else
1992 $lt_unset $lt_var
1994 done
1996 # Now prepare to actually exec the command.
1997 exec_cmd="\$cmd$args"
1998 else
1999 # Display what would be done.
2000 if test -n "$shlibpath_var"; then
2001 eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
2002 echo "export $shlibpath_var"
2004 $ECHO "$cmd$args"
2005 exit $EXIT_SUCCESS
2009 test "$mode" = execute && func_mode_execute ${1+"$@"}
2012 # func_mode_finish arg...
2013 func_mode_finish ()
2015 $opt_debug
2016 libdirs="$nonopt"
2017 admincmds=
2019 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2020 for dir
2022 libdirs="$libdirs $dir"
2023 done
2025 for libdir in $libdirs; do
2026 if test -n "$finish_cmds"; then
2027 # Do each command in the finish commands.
2028 func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
2029 '"$cmd"'"'
2031 if test -n "$finish_eval"; then
2032 # Do the single finish_eval.
2033 eval cmds=\"$finish_eval\"
2034 $opt_dry_run || eval "$cmds" || admincmds="$admincmds
2035 $cmds"
2037 done
2040 # Exit here if they wanted silent mode.
2041 $opt_silent && exit $EXIT_SUCCESS
2043 echo "----------------------------------------------------------------------"
2044 echo "Libraries have been installed in:"
2045 for libdir in $libdirs; do
2046 $ECHO " $libdir"
2047 done
2048 echo
2049 echo "If you ever happen to want to link against installed libraries"
2050 echo "in a given directory, LIBDIR, you must either use libtool, and"
2051 echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
2052 echo "flag during linking and do at least one of the following:"
2053 if test -n "$shlibpath_var"; then
2054 echo " - add LIBDIR to the \`$shlibpath_var' environment variable"
2055 echo " during execution"
2057 if test -n "$runpath_var"; then
2058 echo " - add LIBDIR to the \`$runpath_var' environment variable"
2059 echo " during linking"
2061 if test -n "$hardcode_libdir_flag_spec"; then
2062 libdir=LIBDIR
2063 eval "flag=\"$hardcode_libdir_flag_spec\""
2065 $ECHO " - use the \`$flag' linker flag"
2067 if test -n "$admincmds"; then
2068 $ECHO " - have your system administrator run these commands:$admincmds"
2070 if test -f /etc/ld.so.conf; then
2071 echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
2073 echo
2075 echo "See any operating system documentation about shared libraries for"
2076 case $host in
2077 solaris2.[6789]|solaris2.1[0-9])
2078 echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
2079 echo "pages."
2082 echo "more information, such as the ld(1) and ld.so(8) manual pages."
2084 esac
2085 echo "----------------------------------------------------------------------"
2086 exit $EXIT_SUCCESS
2089 test "$mode" = finish && func_mode_finish ${1+"$@"}
2092 # func_mode_install arg...
2093 func_mode_install ()
2095 $opt_debug
2096 # There may be an optional sh(1) argument at the beginning of
2097 # install_prog (especially on Windows NT).
2098 if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
2099 # Allow the use of GNU shtool's install command.
2100 case $nonopt in *shtool*) :;; *) false;; esac; then
2101 # Aesthetically quote it.
2102 func_quote_for_eval "$nonopt"
2103 install_prog="$func_quote_for_eval_result "
2104 arg=$1
2105 shift
2106 else
2107 install_prog=
2108 arg=$nonopt
2111 # The real first argument should be the name of the installation program.
2112 # Aesthetically quote it.
2113 func_quote_for_eval "$arg"
2114 install_prog="$install_prog$func_quote_for_eval_result"
2115 install_shared_prog=$install_prog
2116 case " $install_prog " in
2117 *[\\\ /]cp\ *) install_cp=: ;;
2118 *) install_cp=false ;;
2119 esac
2121 # We need to accept at least all the BSD install flags.
2122 dest=
2123 files=
2124 opts=
2125 prev=
2126 install_type=
2127 isdir=no
2128 stripme=
2129 no_mode=:
2130 for arg
2132 arg2=
2133 if test -n "$dest"; then
2134 files="$files $dest"
2135 dest=$arg
2136 continue
2139 case $arg in
2140 -d) isdir=yes ;;
2142 if $install_cp; then :; else
2143 prev=$arg
2146 -g | -m | -o)
2147 prev=$arg
2150 stripme=" -s"
2151 continue
2156 # If the previous option needed an argument, then skip it.
2157 if test -n "$prev"; then
2158 if test "x$prev" = x-m && test -n "$install_override_mode"; then
2159 arg2=$install_override_mode
2160 no_mode=false
2162 prev=
2163 else
2164 dest=$arg
2165 continue
2168 esac
2170 # Aesthetically quote the argument.
2171 func_quote_for_eval "$arg"
2172 install_prog="$install_prog $func_quote_for_eval_result"
2173 if test -n "$arg2"; then
2174 func_quote_for_eval "$arg2"
2176 install_shared_prog="$install_shared_prog $func_quote_for_eval_result"
2177 done
2179 test -z "$install_prog" && \
2180 func_fatal_help "you must specify an install program"
2182 test -n "$prev" && \
2183 func_fatal_help "the \`$prev' option requires an argument"
2185 if test -n "$install_override_mode" && $no_mode; then
2186 if $install_cp; then :; else
2187 func_quote_for_eval "$install_override_mode"
2188 install_shared_prog="$install_shared_prog -m $func_quote_for_eval_result"
2192 if test -z "$files"; then
2193 if test -z "$dest"; then
2194 func_fatal_help "no file or destination specified"
2195 else
2196 func_fatal_help "you must specify a destination"
2200 # Strip any trailing slash from the destination.
2201 func_stripname '' '/' "$dest"
2202 dest=$func_stripname_result
2204 # Check to see that the destination is a directory.
2205 test -d "$dest" && isdir=yes
2206 if test "$isdir" = yes; then
2207 destdir="$dest"
2208 destname=
2209 else
2210 func_dirname_and_basename "$dest" "" "."
2211 destdir="$func_dirname_result"
2212 destname="$func_basename_result"
2214 # Not a directory, so check to see that there is only one file specified.
2215 set dummy $files; shift
2216 test "$#" -gt 1 && \
2217 func_fatal_help "\`$dest' is not a directory"
2219 case $destdir in
2220 [\\/]* | [A-Za-z]:[\\/]*) ;;
2222 for file in $files; do
2223 case $file in
2224 *.lo) ;;
2226 func_fatal_help "\`$destdir' must be an absolute directory name"
2228 esac
2229 done
2231 esac
2233 # This variable tells wrapper scripts just to set variables rather
2234 # than running their programs.
2235 libtool_install_magic="$magic"
2237 staticlibs=
2238 future_libdirs=
2239 current_libdirs=
2240 for file in $files; do
2242 # Do each installation.
2243 case $file in
2244 *.$libext)
2245 # Do the static libraries later.
2246 staticlibs="$staticlibs $file"
2249 *.la)
2250 # Check to see that this really is a libtool archive.
2251 func_lalib_unsafe_p "$file" \
2252 || func_fatal_help "\`$file' is not a valid libtool archive"
2254 library_names=
2255 old_library=
2256 relink_command=
2257 func_source "$file"
2259 # Add the libdir to current_libdirs if it is the destination.
2260 if test "X$destdir" = "X$libdir"; then
2261 case "$current_libdirs " in
2262 *" $libdir "*) ;;
2263 *) current_libdirs="$current_libdirs $libdir" ;;
2264 esac
2265 else
2266 # Note the libdir as a future libdir.
2267 case "$future_libdirs " in
2268 *" $libdir "*) ;;
2269 *) future_libdirs="$future_libdirs $libdir" ;;
2270 esac
2273 func_dirname "$file" "/" ""
2274 dir="$func_dirname_result"
2275 dir="$dir$objdir"
2277 if test -n "$relink_command"; then
2278 # Determine the prefix the user has applied to our future dir.
2279 inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
2281 # Don't allow the user to place us outside of our expected
2282 # location b/c this prevents finding dependent libraries that
2283 # are installed to the same prefix.
2284 # At present, this check doesn't affect windows .dll's that
2285 # are installed into $libdir/../bin (currently, that works fine)
2286 # but it's something to keep an eye on.
2287 test "$inst_prefix_dir" = "$destdir" && \
2288 func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2290 if test -n "$inst_prefix_dir"; then
2291 # Stick the inst_prefix_dir data into the link command.
2292 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2293 else
2294 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
2297 func_warning "relinking \`$file'"
2298 func_show_eval "$relink_command" \
2299 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2302 # See the names of the shared library.
2303 set dummy $library_names; shift
2304 if test -n "$1"; then
2305 realname="$1"
2306 shift
2308 srcname="$realname"
2309 test -n "$relink_command" && srcname="$realname"T
2311 # Install the shared library and build the symlinks.
2312 func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
2313 'exit $?'
2314 tstripme="$stripme"
2315 case $host_os in
2316 cygwin* | mingw* | pw32* | cegcc*)
2317 case $realname in
2318 *.dll.a)
2319 tstripme=""
2321 esac
2323 esac
2324 if test -n "$tstripme" && test -n "$striplib"; then
2325 func_show_eval "$striplib $destdir/$realname" 'exit $?'
2328 if test "$#" -gt 0; then
2329 # Delete the old symlinks, and create new ones.
2330 # Try `ln -sf' first, because the `ln' binary might depend on
2331 # the symlink we replace! Solaris /bin/ln does not understand -f,
2332 # so we also need to try rm && ln -s.
2333 for linkname
2335 test "$linkname" != "$realname" \
2336 && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
2337 done
2340 # Do each command in the postinstall commands.
2341 lib="$destdir/$realname"
2342 func_execute_cmds "$postinstall_cmds" 'exit $?'
2345 # Install the pseudo-library for information purposes.
2346 func_basename "$file"
2347 name="$func_basename_result"
2348 instname="$dir/$name"i
2349 func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
2351 # Maybe install the static library, too.
2352 test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
2355 *.lo)
2356 # Install (i.e. copy) a libtool object.
2358 # Figure out destination file name, if it wasn't already specified.
2359 if test -n "$destname"; then
2360 destfile="$destdir/$destname"
2361 else
2362 func_basename "$file"
2363 destfile="$func_basename_result"
2364 destfile="$destdir/$destfile"
2367 # Deduce the name of the destination old-style object file.
2368 case $destfile in
2369 *.lo)
2370 func_lo2o "$destfile"
2371 staticdest=$func_lo2o_result
2373 *.$objext)
2374 staticdest="$destfile"
2375 destfile=
2378 func_fatal_help "cannot copy a libtool object to \`$destfile'"
2380 esac
2382 # Install the libtool object if requested.
2383 test -n "$destfile" && \
2384 func_show_eval "$install_prog $file $destfile" 'exit $?'
2386 # Install the old object if enabled.
2387 if test "$build_old_libs" = yes; then
2388 # Deduce the name of the old-style object file.
2389 func_lo2o "$file"
2390 staticobj=$func_lo2o_result
2391 func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
2393 exit $EXIT_SUCCESS
2397 # Figure out destination file name, if it wasn't already specified.
2398 if test -n "$destname"; then
2399 destfile="$destdir/$destname"
2400 else
2401 func_basename "$file"
2402 destfile="$func_basename_result"
2403 destfile="$destdir/$destfile"
2406 # If the file is missing, and there is a .exe on the end, strip it
2407 # because it is most likely a libtool script we actually want to
2408 # install
2409 stripped_ext=""
2410 case $file in
2411 *.exe)
2412 if test ! -f "$file"; then
2413 func_stripname '' '.exe' "$file"
2414 file=$func_stripname_result
2415 stripped_ext=".exe"
2418 esac
2420 # Do a test to see if this is really a libtool program.
2421 case $host in
2422 *cygwin* | *mingw*)
2423 if func_ltwrapper_executable_p "$file"; then
2424 func_ltwrapper_scriptname "$file"
2425 wrapper=$func_ltwrapper_scriptname_result
2426 else
2427 func_stripname '' '.exe' "$file"
2428 wrapper=$func_stripname_result
2432 wrapper=$file
2434 esac
2435 if func_ltwrapper_script_p "$wrapper"; then
2436 notinst_deplibs=
2437 relink_command=
2439 func_source "$wrapper"
2441 # Check the variables that should have been set.
2442 test -z "$generated_by_libtool_version" && \
2443 func_fatal_error "invalid libtool wrapper script \`$wrapper'"
2445 finalize=yes
2446 for lib in $notinst_deplibs; do
2447 # Check to see that each library is installed.
2448 libdir=
2449 if test -f "$lib"; then
2450 func_source "$lib"
2452 libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
2453 if test -n "$libdir" && test ! -f "$libfile"; then
2454 func_warning "\`$lib' has not been installed in \`$libdir'"
2455 finalize=no
2457 done
2459 relink_command=
2460 func_source "$wrapper"
2462 outputname=
2463 if test "$fast_install" = no && test -n "$relink_command"; then
2464 $opt_dry_run || {
2465 if test "$finalize" = yes; then
2466 tmpdir=`func_mktempdir`
2467 func_basename "$file$stripped_ext"
2468 file="$func_basename_result"
2469 outputname="$tmpdir/$file"
2470 # Replace the output file specification.
2471 relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
2473 $opt_silent || {
2474 func_quote_for_expand "$relink_command"
2475 eval "func_echo $func_quote_for_expand_result"
2477 if eval "$relink_command"; then :
2478 else
2479 func_error "error: relink \`$file' with the above command before installing it"
2480 $opt_dry_run || ${RM}r "$tmpdir"
2481 continue
2483 file="$outputname"
2484 else
2485 func_warning "cannot relink \`$file'"
2488 else
2489 # Install the binary that we compiled earlier.
2490 file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
2494 # remove .exe since cygwin /usr/bin/install will append another
2495 # one anyway
2496 case $install_prog,$host in
2497 */usr/bin/install*,*cygwin*)
2498 case $file:$destfile in
2499 *.exe:*.exe)
2500 # this is ok
2502 *.exe:*)
2503 destfile=$destfile.exe
2505 *:*.exe)
2506 func_stripname '' '.exe' "$destfile"
2507 destfile=$func_stripname_result
2509 esac
2511 esac
2512 func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
2513 $opt_dry_run || if test -n "$outputname"; then
2514 ${RM}r "$tmpdir"
2517 esac
2518 done
2520 for file in $staticlibs; do
2521 func_basename "$file"
2522 name="$func_basename_result"
2524 # Set up the ranlib parameters.
2525 oldlib="$destdir/$name"
2527 func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
2529 if test -n "$stripme" && test -n "$old_striplib"; then
2530 func_show_eval "$old_striplib $oldlib" 'exit $?'
2533 # Do each command in the postinstall commands.
2534 func_execute_cmds "$old_postinstall_cmds" 'exit $?'
2535 done
2537 test -n "$future_libdirs" && \
2538 func_warning "remember to run \`$progname --finish$future_libdirs'"
2540 if test -n "$current_libdirs" && $opt_finish; then
2541 # Maybe just do a dry run.
2542 $opt_dry_run && current_libdirs=" -n$current_libdirs"
2543 exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
2544 else
2545 exit $EXIT_SUCCESS
2549 test "$mode" = install && func_mode_install ${1+"$@"}
2552 # func_generate_dlsyms outputname originator pic_p
2553 # Extract symbols from dlprefiles and create ${outputname}S.o with
2554 # a dlpreopen symbol table.
2555 func_generate_dlsyms ()
2557 $opt_debug
2558 my_outputname="$1"
2559 my_originator="$2"
2560 my_pic_p="${3-no}"
2561 my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
2562 my_dlsyms=
2564 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
2565 if test -n "$NM" && test -n "$global_symbol_pipe"; then
2566 my_dlsyms="${my_outputname}S.c"
2567 else
2568 func_error "not configured to extract global symbols from dlpreopened files"
2572 if test -n "$my_dlsyms"; then
2573 case $my_dlsyms in
2574 "") ;;
2575 *.c)
2576 # Discover the nlist of each of the dlfiles.
2577 nlist="$output_objdir/${my_outputname}.nm"
2579 func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
2581 # Parse the name list into a source file.
2582 func_verbose "creating $output_objdir/$my_dlsyms"
2584 $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
2585 /* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
2586 /* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
2588 #ifdef __cplusplus
2589 extern \"C\" {
2590 #endif
2592 #if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
2593 #pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
2594 #endif
2596 /* External symbol declarations for the compiler. */\
2599 if test "$dlself" = yes; then
2600 func_verbose "generating symbol list for \`$output'"
2602 $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
2604 # Add our own program objects to the symbol list.
2605 progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
2606 for progfile in $progfiles; do
2607 func_verbose "extracting global C symbols from \`$progfile'"
2608 $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
2609 done
2611 if test -n "$exclude_expsyms"; then
2612 $opt_dry_run || {
2613 $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
2614 $MV "$nlist"T "$nlist"
2618 if test -n "$export_symbols_regex"; then
2619 $opt_dry_run || {
2620 $EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T
2621 $MV "$nlist"T "$nlist"
2625 # Prepare the list of exported symbols
2626 if test -z "$export_symbols"; then
2627 export_symbols="$output_objdir/$outputname.exp"
2628 $opt_dry_run || {
2629 $RM $export_symbols
2630 ${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' < "$nlist" > "$export_symbols"
2631 case $host in
2632 *cygwin* | *mingw* | *cegcc* )
2633 echo EXPORTS > "$output_objdir/$outputname.def"
2634 cat "$export_symbols" >> "$output_objdir/$outputname.def"
2636 esac
2638 else
2639 $opt_dry_run || {
2640 ${SED} -e 's/\([].[*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/' < "$export_symbols" > "$output_objdir/$outputname.exp"
2641 $GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T
2642 $MV "$nlist"T "$nlist"
2643 case $host in
2644 *cygwin* | *mingw* | *cegcc* )
2645 echo EXPORTS > "$output_objdir/$outputname.def"
2646 cat "$nlist" >> "$output_objdir/$outputname.def"
2648 esac
2653 for dlprefile in $dlprefiles; do
2654 func_verbose "extracting global C symbols from \`$dlprefile'"
2655 func_basename "$dlprefile"
2656 name="$func_basename_result"
2657 $opt_dry_run || {
2658 $ECHO ": $name " >> "$nlist"
2659 eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
2661 done
2663 $opt_dry_run || {
2664 # Make sure we have at least an empty file.
2665 test -f "$nlist" || : > "$nlist"
2667 if test -n "$exclude_expsyms"; then
2668 $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
2669 $MV "$nlist"T "$nlist"
2672 # Try sorting and uniquifying the output.
2673 if $GREP -v "^: " < "$nlist" |
2674 if sort -k 3 </dev/null >/dev/null 2>&1; then
2675 sort -k 3
2676 else
2677 sort +2
2678 fi |
2679 uniq > "$nlist"S; then
2681 else
2682 $GREP -v "^: " < "$nlist" > "$nlist"S
2685 if test -f "$nlist"S; then
2686 eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
2687 else
2688 echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
2691 echo >> "$output_objdir/$my_dlsyms" "\
2693 /* The mapping between symbol names and symbols. */
2694 typedef struct {
2695 const char *name;
2696 void *address;
2697 } lt_dlsymlist;
2699 case $host in
2700 *cygwin* | *mingw* | *cegcc* )
2701 echo >> "$output_objdir/$my_dlsyms" "\
2702 /* DATA imports from DLLs on WIN32 con't be const, because
2703 runtime relocations are performed -- see ld's documentation
2704 on pseudo-relocs. */"
2705 lt_dlsym_const= ;;
2706 *osf5*)
2707 echo >> "$output_objdir/$my_dlsyms" "\
2708 /* This system does not cope well with relocations in const data */"
2709 lt_dlsym_const= ;;
2711 lt_dlsym_const=const ;;
2712 esac
2714 echo >> "$output_objdir/$my_dlsyms" "\
2715 extern $lt_dlsym_const lt_dlsymlist
2716 lt_${my_prefix}_LTX_preloaded_symbols[];
2717 $lt_dlsym_const lt_dlsymlist
2718 lt_${my_prefix}_LTX_preloaded_symbols[] =
2720 { \"$my_originator\", (void *) 0 },"
2722 case $need_lib_prefix in
2724 eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
2727 eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
2729 esac
2730 echo >> "$output_objdir/$my_dlsyms" "\
2731 {0, (void *) 0}
2734 /* This works around a problem in FreeBSD linker */
2735 #ifdef FREEBSD_WORKAROUND
2736 static const void *lt_preloaded_setup() {
2737 return lt_${my_prefix}_LTX_preloaded_symbols;
2739 #endif
2741 #ifdef __cplusplus
2743 #endif\
2745 } # !$opt_dry_run
2747 pic_flag_for_symtable=
2748 case "$compile_command " in
2749 *" -static "*) ;;
2751 case $host in
2752 # compiling the symbol table file with pic_flag works around
2753 # a FreeBSD bug that causes programs to crash when -lm is
2754 # linked before any other PIC object. But we must not use
2755 # pic_flag when linking with -static. The problem exists in
2756 # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
2757 *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
2758 pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
2759 *-*-hpux*)
2760 pic_flag_for_symtable=" $pic_flag" ;;
2762 if test "X$my_pic_p" != Xno; then
2763 pic_flag_for_symtable=" $pic_flag"
2766 esac
2768 esac
2769 symtab_cflags=
2770 for arg in $LTCFLAGS; do
2771 case $arg in
2772 -pie | -fpie | -fPIE) ;;
2773 *) symtab_cflags="$symtab_cflags $arg" ;;
2774 esac
2775 done
2777 # Now compile the dynamic symbol file.
2778 func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
2780 # Clean up the generated files.
2781 func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
2783 # Transform the symbol file into the correct name.
2784 symfileobj="$output_objdir/${my_outputname}S.$objext"
2785 case $host in
2786 *cygwin* | *mingw* | *cegcc* )
2787 if test -f "$output_objdir/$my_outputname.def"; then
2788 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
2789 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
2790 else
2791 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
2792 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
2796 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
2797 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
2799 esac
2802 func_fatal_error "unknown suffix for \`$my_dlsyms'"
2804 esac
2805 else
2806 # We keep going just in case the user didn't refer to
2807 # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
2808 # really was required.
2810 # Nullify the symbol file.
2811 compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
2812 finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
2816 # func_win32_libid arg
2817 # return the library type of file 'arg'
2819 # Need a lot of goo to handle *both* DLLs and import libs
2820 # Has to be a shell function in order to 'eat' the argument
2821 # that is supplied when $file_magic_command is called.
2822 # Despite the name, also deal with 64 bit binaries.
2823 func_win32_libid ()
2825 $opt_debug
2826 win32_libid_type="unknown"
2827 win32_fileres=`file -L $1 2>/dev/null`
2828 case $win32_fileres in
2829 *ar\ archive\ import\ library*) # definitely import
2830 win32_libid_type="x86 archive import"
2832 *ar\ archive*) # could be an import, or static
2833 if $OBJDUMP -f "$1" | $SED -e '10q' 2>/dev/null |
2834 $EGREP 'file format (pe-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
2835 win32_nmres=`$NM -f posix -A "$1" |
2836 $SED -n -e '
2837 1,100{
2838 / I /{
2839 s,.*,import,
2844 case $win32_nmres in
2845 import*) win32_libid_type="x86 archive import";;
2846 *) win32_libid_type="x86 archive static";;
2847 esac
2850 *DLL*)
2851 win32_libid_type="x86 DLL"
2853 *executable*) # but shell scripts are "executable" too...
2854 case $win32_fileres in
2855 *MS\ Windows\ PE\ Intel*)
2856 win32_libid_type="x86 DLL"
2858 esac
2860 esac
2861 $ECHO "$win32_libid_type"
2866 # func_extract_an_archive dir oldlib
2867 func_extract_an_archive ()
2869 $opt_debug
2870 f_ex_an_ar_dir="$1"; shift
2871 f_ex_an_ar_oldlib="$1"
2872 if test "$lock_old_archive_extraction" = yes; then
2873 lockfile=$f_ex_an_ar_oldlib.lock
2874 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
2875 func_echo "Waiting for $lockfile to be removed"
2876 sleep 2
2877 done
2879 func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
2880 'stat=$?; rm -f "$lockfile"; exit $stat'
2881 if test "$lock_old_archive_extraction" = yes; then
2882 $opt_dry_run || rm -f "$lockfile"
2884 if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
2886 else
2887 func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
2892 # func_extract_archives gentop oldlib ...
2893 func_extract_archives ()
2895 $opt_debug
2896 my_gentop="$1"; shift
2897 my_oldlibs=${1+"$@"}
2898 my_oldobjs=""
2899 my_xlib=""
2900 my_xabs=""
2901 my_xdir=""
2903 for my_xlib in $my_oldlibs; do
2904 # Extract the objects.
2905 case $my_xlib in
2906 [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
2907 *) my_xabs=`pwd`"/$my_xlib" ;;
2908 esac
2909 func_basename "$my_xlib"
2910 my_xlib="$func_basename_result"
2911 my_xlib_u=$my_xlib
2912 while :; do
2913 case " $extracted_archives " in
2914 *" $my_xlib_u "*)
2915 func_arith $extracted_serial + 1
2916 extracted_serial=$func_arith_result
2917 my_xlib_u=lt$extracted_serial-$my_xlib ;;
2918 *) break ;;
2919 esac
2920 done
2921 extracted_archives="$extracted_archives $my_xlib_u"
2922 my_xdir="$my_gentop/$my_xlib_u"
2924 func_mkdir_p "$my_xdir"
2926 case $host in
2927 *-darwin*)
2928 func_verbose "Extracting $my_xabs"
2929 # Do not bother doing anything if just a dry run
2930 $opt_dry_run || {
2931 darwin_orig_dir=`pwd`
2932 cd $my_xdir || exit $?
2933 darwin_archive=$my_xabs
2934 darwin_curdir=`pwd`
2935 darwin_base_archive=`basename "$darwin_archive"`
2936 darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
2937 if test -n "$darwin_arches"; then
2938 darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
2939 darwin_arch=
2940 func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
2941 for darwin_arch in $darwin_arches ; do
2942 func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
2943 $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
2944 cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
2945 func_extract_an_archive "`pwd`" "${darwin_base_archive}"
2946 cd "$darwin_curdir"
2947 $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
2948 done # $darwin_arches
2949 ## Okay now we've a bunch of thin objects, gotta fatten them up :)
2950 darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
2951 darwin_file=
2952 darwin_files=
2953 for darwin_file in $darwin_filelist; do
2954 darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
2955 $LIPO -create -output "$darwin_file" $darwin_files
2956 done # $darwin_filelist
2957 $RM -rf unfat-$$
2958 cd "$darwin_orig_dir"
2959 else
2960 cd $darwin_orig_dir
2961 func_extract_an_archive "$my_xdir" "$my_xabs"
2962 fi # $darwin_arches
2963 } # !$opt_dry_run
2966 func_extract_an_archive "$my_xdir" "$my_xabs"
2968 esac
2969 my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
2970 done
2972 func_extract_archives_result="$my_oldobjs"
2976 # func_emit_wrapper [arg=no]
2978 # Emit a libtool wrapper script on stdout.
2979 # Don't directly open a file because we may want to
2980 # incorporate the script contents within a cygwin/mingw
2981 # wrapper executable. Must ONLY be called from within
2982 # func_mode_link because it depends on a number of variables
2983 # set therein.
2985 # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
2986 # variable will take. If 'yes', then the emitted script
2987 # will assume that the directory in which it is stored is
2988 # the $objdir directory. This is a cygwin/mingw-specific
2989 # behavior.
2990 func_emit_wrapper ()
2992 func_emit_wrapper_arg1=${1-no}
2994 $ECHO "\
2995 #! $SHELL
2997 # $output - temporary wrapper script for $objdir/$outputname
2998 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
3000 # The $output program cannot be directly executed until all the libtool
3001 # libraries that it depends on are installed.
3003 # This wrapper script should never be moved out of the build directory.
3004 # If it is, it will not operate correctly.
3006 # Sed substitution that helps us do robust quoting. It backslashifies
3007 # metacharacters that are still active within double-quoted strings.
3008 sed_quote_subst='$sed_quote_subst'
3010 # Be Bourne compatible
3011 if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
3012 emulate sh
3013 NULLCMD=:
3014 # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
3015 # is contrary to our usage. Disable this feature.
3016 alias -g '\${1+\"\$@\"}'='\"\$@\"'
3017 setopt NO_GLOB_SUBST
3018 else
3019 case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
3021 BIN_SH=xpg4; export BIN_SH # for Tru64
3022 DUALCASE=1; export DUALCASE # for MKS sh
3024 # The HP-UX ksh and POSIX shell print the target directory to stdout
3025 # if CDPATH is set.
3026 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
3028 relink_command=\"$relink_command\"
3030 # This environment variable determines our operation mode.
3031 if test \"\$libtool_install_magic\" = \"$magic\"; then
3032 # install mode needs the following variables:
3033 generated_by_libtool_version='$macro_version'
3034 notinst_deplibs='$notinst_deplibs'
3035 else
3036 # When we are sourced in execute mode, \$file and \$ECHO are already set.
3037 if test \"\$libtool_execute_magic\" != \"$magic\"; then
3038 file=\"\$0\""
3040 qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
3041 $ECHO "\
3043 # A function that is used when there is no print builtin or printf.
3044 func_fallback_echo ()
3046 eval 'cat <<_LTECHO_EOF
3048 _LTECHO_EOF'
3050 ECHO=\"$qECHO\"
3053 # Find the directory that this script lives in.
3054 thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
3055 test \"x\$thisdir\" = \"x\$file\" && thisdir=.
3057 # Follow symbolic links until we get to the real thisdir.
3058 file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
3059 while test -n \"\$file\"; do
3060 destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
3062 # If there was a directory component, then change thisdir.
3063 if test \"x\$destdir\" != \"x\$file\"; then
3064 case \"\$destdir\" in
3065 [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
3066 *) thisdir=\"\$thisdir/\$destdir\" ;;
3067 esac
3070 file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
3071 file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
3072 done
3074 # Usually 'no', except on cygwin/mingw when embedded into
3075 # the cwrapper.
3076 WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
3077 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
3078 # special case for '.'
3079 if test \"\$thisdir\" = \".\"; then
3080 thisdir=\`pwd\`
3082 # remove .libs from thisdir
3083 case \"\$thisdir\" in
3084 *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
3085 $objdir ) thisdir=. ;;
3086 esac
3089 # Try to get the absolute directory name.
3090 absdir=\`cd \"\$thisdir\" && pwd\`
3091 test -n \"\$absdir\" && thisdir=\"\$absdir\"
3094 if test "$fast_install" = yes; then
3095 $ECHO "\
3096 program=lt-'$outputname'$exeext
3097 progdir=\"\$thisdir/$objdir\"
3099 if test ! -f \"\$progdir/\$program\" ||
3100 { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
3101 test \"X\$file\" != \"X\$progdir/\$program\"; }; then
3103 file=\"\$\$-\$program\"
3105 if test ! -d \"\$progdir\"; then
3106 $MKDIR \"\$progdir\"
3107 else
3108 $RM \"\$progdir/\$file\"
3111 $ECHO "\
3113 # relink executable if necessary
3114 if test -n \"\$relink_command\"; then
3115 if relink_command_output=\`eval \"\$relink_command\" 2>&1\`; then :
3116 else
3117 $ECHO \"\$relink_command_output\" >&2
3118 $RM \"\$progdir/\$file\"
3119 exit 1
3123 $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
3124 { $RM \"\$progdir/\$program\";
3125 $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
3126 $RM \"\$progdir/\$file\"
3128 else
3129 $ECHO "\
3130 program='$outputname'
3131 progdir=\"\$thisdir/$objdir\"
3135 $ECHO "\
3137 if test -f \"\$progdir/\$program\"; then"
3139 # Export our shlibpath_var if we have one.
3140 if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
3141 $ECHO "\
3142 # Add our own library path to $shlibpath_var
3143 $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
3145 # Some systems cannot cope with colon-terminated $shlibpath_var
3146 # The second colon is a workaround for a bug in BeOS R4 sed
3147 $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
3149 export $shlibpath_var
3153 # fixup the dll searchpath if we need to.
3154 if test -n "$dllsearchpath"; then
3155 $ECHO "\
3156 # Add the dll search path components to the executable PATH
3157 PATH=$dllsearchpath:\$PATH
3161 $ECHO "\
3162 if test \"\$libtool_execute_magic\" != \"$magic\"; then
3163 # Run the actual program with our arguments.
3165 case $host in
3166 # Backslashes separate directories on plain windows
3167 *-*-mingw | *-*-os2* | *-cegcc*)
3168 $ECHO "\
3169 exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
3174 $ECHO "\
3175 exec \"\$progdir/\$program\" \${1+\"\$@\"}
3178 esac
3179 $ECHO "\
3180 \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
3181 exit 1
3183 else
3184 # The program doesn't exist.
3185 \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
3186 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
3187 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
3188 exit 1
3195 # func_to_host_path arg
3197 # Convert paths to host format when used with build tools.
3198 # Intended for use with "native" mingw (where libtool itself
3199 # is running under the msys shell), or in the following cross-
3200 # build environments:
3201 # $build $host
3202 # mingw (msys) mingw [e.g. native]
3203 # cygwin mingw
3204 # *nix + wine mingw
3205 # where wine is equipped with the `winepath' executable.
3206 # In the native mingw case, the (msys) shell automatically
3207 # converts paths for any non-msys applications it launches,
3208 # but that facility isn't available from inside the cwrapper.
3209 # Similar accommodations are necessary for $host mingw and
3210 # $build cygwin. Calling this function does no harm for other
3211 # $host/$build combinations not listed above.
3213 # ARG is the path (on $build) that should be converted to
3214 # the proper representation for $host. The result is stored
3215 # in $func_to_host_path_result.
3216 func_to_host_path ()
3218 func_to_host_path_result="$1"
3219 if test -n "$1"; then
3220 case $host in
3221 *mingw* )
3222 lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
3223 case $build in
3224 *mingw* ) # actually, msys
3225 # awkward: cmd appends spaces to result
3226 func_to_host_path_result=`( cmd //c echo "$1" ) 2>/dev/null |
3227 $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
3229 *cygwin* )
3230 func_to_host_path_result=`cygpath -w "$1" |
3231 $SED -e "$lt_sed_naive_backslashify"`
3234 # Unfortunately, winepath does not exit with a non-zero
3235 # error code, so we are forced to check the contents of
3236 # stdout. On the other hand, if the command is not
3237 # found, the shell will set an exit code of 127 and print
3238 # *an error message* to stdout. So we must check for both
3239 # error code of zero AND non-empty stdout, which explains
3240 # the odd construction:
3241 func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null`
3242 if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then
3243 func_to_host_path_result=`$ECHO "$func_to_host_path_tmp1" |
3244 $SED -e "$lt_sed_naive_backslashify"`
3245 else
3246 # Allow warning below.
3247 func_to_host_path_result=
3250 esac
3251 if test -z "$func_to_host_path_result" ; then
3252 func_error "Could not determine host path corresponding to"
3253 func_error " \`$1'"
3254 func_error "Continuing, but uninstalled executables may not work."
3255 # Fallback:
3256 func_to_host_path_result="$1"
3259 esac
3262 # end: func_to_host_path
3264 # func_to_host_pathlist arg
3266 # Convert pathlists to host format when used with build tools.
3267 # See func_to_host_path(), above. This function supports the
3268 # following $build/$host combinations (but does no harm for
3269 # combinations not listed here):
3270 # $build $host
3271 # mingw (msys) mingw [e.g. native]
3272 # cygwin mingw
3273 # *nix + wine mingw
3275 # Path separators are also converted from $build format to
3276 # $host format. If ARG begins or ends with a path separator
3277 # character, it is preserved (but converted to $host format)
3278 # on output.
3280 # ARG is a pathlist (on $build) that should be converted to
3281 # the proper representation on $host. The result is stored
3282 # in $func_to_host_pathlist_result.
3283 func_to_host_pathlist ()
3285 func_to_host_pathlist_result="$1"
3286 if test -n "$1"; then
3287 case $host in
3288 *mingw* )
3289 lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
3290 # Remove leading and trailing path separator characters from
3291 # ARG. msys behavior is inconsistent here, cygpath turns them
3292 # into '.;' and ';.', and winepath ignores them completely.
3293 func_stripname : : "$1"
3294 func_to_host_pathlist_tmp1=$func_stripname_result
3295 case $build in
3296 *mingw* ) # Actually, msys.
3297 # Awkward: cmd appends spaces to result.
3298 func_to_host_pathlist_result=`
3299 ( cmd //c echo "$func_to_host_pathlist_tmp1" ) 2>/dev/null |
3300 $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
3302 *cygwin* )
3303 func_to_host_pathlist_result=`cygpath -w -p "$func_to_host_pathlist_tmp1" |
3304 $SED -e "$lt_sed_naive_backslashify"`
3307 # unfortunately, winepath doesn't convert pathlists
3308 func_to_host_pathlist_result=""
3309 func_to_host_pathlist_oldIFS=$IFS
3310 IFS=:
3311 for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do
3312 IFS=$func_to_host_pathlist_oldIFS
3313 if test -n "$func_to_host_pathlist_f" ; then
3314 func_to_host_path "$func_to_host_pathlist_f"
3315 if test -n "$func_to_host_path_result" ; then
3316 if test -z "$func_to_host_pathlist_result" ; then
3317 func_to_host_pathlist_result="$func_to_host_path_result"
3318 else
3319 func_append func_to_host_pathlist_result ";$func_to_host_path_result"
3323 done
3324 IFS=$func_to_host_pathlist_oldIFS
3326 esac
3327 if test -z "$func_to_host_pathlist_result"; then
3328 func_error "Could not determine the host path(s) corresponding to"
3329 func_error " \`$1'"
3330 func_error "Continuing, but uninstalled executables may not work."
3331 # Fallback. This may break if $1 contains DOS-style drive
3332 # specifications. The fix is not to complicate the expression
3333 # below, but for the user to provide a working wine installation
3334 # with winepath so that path translation in the cross-to-mingw
3335 # case works properly.
3336 lt_replace_pathsep_nix_to_dos="s|:|;|g"
3337 func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\
3338 $SED -e "$lt_replace_pathsep_nix_to_dos"`
3340 # Now, add the leading and trailing path separators back
3341 case "$1" in
3342 :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result"
3344 esac
3345 case "$1" in
3346 *: ) func_append func_to_host_pathlist_result ";"
3348 esac
3350 esac
3353 # end: func_to_host_pathlist
3355 # func_emit_cwrapperexe_src
3356 # emit the source code for a wrapper executable on stdout
3357 # Must ONLY be called from within func_mode_link because
3358 # it depends on a number of variable set therein.
3359 func_emit_cwrapperexe_src ()
3361 cat <<EOF
3363 /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
3364 Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
3366 The $output program cannot be directly executed until all the libtool
3367 libraries that it depends on are installed.
3369 This wrapper executable should never be moved out of the build directory.
3370 If it is, it will not operate correctly.
3372 Currently, it simply execs the wrapper *script* "$SHELL $output",
3373 but could eventually absorb all of the scripts functionality and
3374 exec $objdir/$outputname directly.
3377 cat <<"EOF"
3378 #ifdef _MSC_VER
3379 # define _CRT_SECURE_NO_DEPRECATE 1
3380 #endif
3381 #include <stdio.h>
3382 #include <stdlib.h>
3383 #ifdef _MSC_VER
3384 # include <direct.h>
3385 # include <process.h>
3386 # include <io.h>
3387 #else
3388 # include <unistd.h>
3389 # include <stdint.h>
3390 # ifdef __CYGWIN__
3391 # include <io.h>
3392 # endif
3393 #endif
3394 #include <malloc.h>
3395 #include <stdarg.h>
3396 #include <assert.h>
3397 #include <string.h>
3398 #include <ctype.h>
3399 #include <errno.h>
3400 #include <fcntl.h>
3401 #include <sys/stat.h>
3403 /* declarations of non-ANSI functions */
3404 #if defined(__MINGW32__)
3405 # ifdef __STRICT_ANSI__
3406 int _putenv (const char *);
3407 # endif
3408 #elif defined(__CYGWIN__)
3409 # ifdef __STRICT_ANSI__
3410 char *realpath (const char *, char *);
3411 int putenv (char *);
3412 int setenv (const char *, const char *, int);
3413 # endif
3414 /* #elif defined (other platforms) ... */
3415 #endif
3417 /* portability defines, excluding path handling macros */
3418 #if defined(_MSC_VER)
3419 # define setmode _setmode
3420 # define stat _stat
3421 # define chmod _chmod
3422 # define getcwd _getcwd
3423 # define putenv _putenv
3424 # define S_IXUSR _S_IEXEC
3425 # ifndef _INTPTR_T_DEFINED
3426 # define _INTPTR_T_DEFINED
3427 # define intptr_t int
3428 # endif
3429 #elif defined(__MINGW32__)
3430 # define setmode _setmode
3431 # define stat _stat
3432 # define chmod _chmod
3433 # define getcwd _getcwd
3434 # define putenv _putenv
3435 #elif defined(__CYGWIN__)
3436 # define HAVE_SETENV
3437 # define FOPEN_WB "wb"
3438 /* #elif defined (other platforms) ... */
3439 #endif
3441 #if defined(PATH_MAX)
3442 # define LT_PATHMAX PATH_MAX
3443 #elif defined(MAXPATHLEN)
3444 # define LT_PATHMAX MAXPATHLEN
3445 #else
3446 # define LT_PATHMAX 1024
3447 #endif
3449 #ifndef S_IXOTH
3450 # define S_IXOTH 0
3451 #endif
3452 #ifndef S_IXGRP
3453 # define S_IXGRP 0
3454 #endif
3456 /* path handling portability macros */
3457 #ifndef DIR_SEPARATOR
3458 # define DIR_SEPARATOR '/'
3459 # define PATH_SEPARATOR ':'
3460 #endif
3462 #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
3463 defined (__OS2__)
3464 # define HAVE_DOS_BASED_FILE_SYSTEM
3465 # define FOPEN_WB "wb"
3466 # ifndef DIR_SEPARATOR_2
3467 # define DIR_SEPARATOR_2 '\\'
3468 # endif
3469 # ifndef PATH_SEPARATOR_2
3470 # define PATH_SEPARATOR_2 ';'
3471 # endif
3472 #endif
3474 #ifndef DIR_SEPARATOR_2
3475 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
3476 #else /* DIR_SEPARATOR_2 */
3477 # define IS_DIR_SEPARATOR(ch) \
3478 (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
3479 #endif /* DIR_SEPARATOR_2 */
3481 #ifndef PATH_SEPARATOR_2
3482 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
3483 #else /* PATH_SEPARATOR_2 */
3484 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
3485 #endif /* PATH_SEPARATOR_2 */
3487 #ifndef FOPEN_WB
3488 # define FOPEN_WB "w"
3489 #endif
3490 #ifndef _O_BINARY
3491 # define _O_BINARY 0
3492 #endif
3494 #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
3495 #define XFREE(stale) do { \
3496 if (stale) { free ((void *) stale); stale = 0; } \
3497 } while (0)
3499 #undef LTWRAPPER_DEBUGPRINTF
3500 #if defined LT_DEBUGWRAPPER
3501 # define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args
3502 static void
3503 ltwrapper_debugprintf (const char *fmt, ...)
3505 va_list args;
3506 va_start (args, fmt);
3507 (void) vfprintf (stderr, fmt, args);
3508 va_end (args);
3510 #else
3511 # define LTWRAPPER_DEBUGPRINTF(args)
3512 #endif
3514 const char *program_name = NULL;
3516 void *xmalloc (size_t num);
3517 char *xstrdup (const char *string);
3518 const char *base_name (const char *name);
3519 char *find_executable (const char *wrapper);
3520 char *chase_symlinks (const char *pathspec);
3521 int make_executable (const char *path);
3522 int check_executable (const char *path);
3523 char *strendzap (char *str, const char *pat);
3524 void lt_fatal (const char *message, ...);
3525 void lt_setenv (const char *name, const char *value);
3526 char *lt_extend_str (const char *orig_value, const char *add, int to_end);
3527 void lt_update_exe_path (const char *name, const char *value);
3528 void lt_update_lib_path (const char *name, const char *value);
3529 char **prepare_spawn (char **argv);
3530 void lt_dump_script (FILE *f);
3533 cat <<EOF
3534 const char * MAGIC_EXE = "$magic_exe";
3535 const char * LIB_PATH_VARNAME = "$shlibpath_var";
3538 if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
3539 func_to_host_pathlist "$temp_rpath"
3540 cat <<EOF
3541 const char * LIB_PATH_VALUE = "$func_to_host_pathlist_result";
3543 else
3544 cat <<"EOF"
3545 const char * LIB_PATH_VALUE = "";
3549 if test -n "$dllsearchpath"; then
3550 func_to_host_pathlist "$dllsearchpath:"
3551 cat <<EOF
3552 const char * EXE_PATH_VARNAME = "PATH";
3553 const char * EXE_PATH_VALUE = "$func_to_host_pathlist_result";
3555 else
3556 cat <<"EOF"
3557 const char * EXE_PATH_VARNAME = "";
3558 const char * EXE_PATH_VALUE = "";
3562 if test "$fast_install" = yes; then
3563 cat <<EOF
3564 const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
3566 else
3567 cat <<EOF
3568 const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
3573 cat <<"EOF"
3575 #define LTWRAPPER_OPTION_PREFIX "--lt-"
3576 #define LTWRAPPER_OPTION_PREFIX_LENGTH 5
3578 static const size_t opt_prefix_len = LTWRAPPER_OPTION_PREFIX_LENGTH;
3579 static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
3581 static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script";
3584 main (int argc, char *argv[])
3586 char **newargz;
3587 int newargc;
3588 char *tmp_pathspec;
3589 char *actual_cwrapper_path;
3590 char *actual_cwrapper_name;
3591 char *target_name;
3592 char *lt_argv_zero;
3593 intptr_t rval = 127;
3595 int i;
3597 program_name = (char *) xstrdup (base_name (argv[0]));
3598 LTWRAPPER_DEBUGPRINTF (("(main) argv[0] : %s\n", argv[0]));
3599 LTWRAPPER_DEBUGPRINTF (("(main) program_name : %s\n", program_name));
3601 /* very simple arg parsing; don't want to rely on getopt */
3602 for (i = 1; i < argc; i++)
3604 if (strcmp (argv[i], dumpscript_opt) == 0)
3607 case "$host" in
3608 *mingw* | *cygwin* )
3609 # make stdout use "unix" line endings
3610 echo " setmode(1,_O_BINARY);"
3612 esac
3614 cat <<"EOF"
3615 lt_dump_script (stdout);
3616 return 0;
3620 newargz = XMALLOC (char *, argc + 1);
3621 tmp_pathspec = find_executable (argv[0]);
3622 if (tmp_pathspec == NULL)
3623 lt_fatal ("Couldn't find %s", argv[0]);
3624 LTWRAPPER_DEBUGPRINTF (("(main) found exe (before symlink chase) at : %s\n",
3625 tmp_pathspec));
3627 actual_cwrapper_path = chase_symlinks (tmp_pathspec);
3628 LTWRAPPER_DEBUGPRINTF (("(main) found exe (after symlink chase) at : %s\n",
3629 actual_cwrapper_path));
3630 XFREE (tmp_pathspec);
3632 actual_cwrapper_name = xstrdup( base_name (actual_cwrapper_path));
3633 strendzap (actual_cwrapper_path, actual_cwrapper_name);
3635 /* wrapper name transforms */
3636 strendzap (actual_cwrapper_name, ".exe");
3637 tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
3638 XFREE (actual_cwrapper_name);
3639 actual_cwrapper_name = tmp_pathspec;
3640 tmp_pathspec = 0;
3642 /* target_name transforms -- use actual target program name; might have lt- prefix */
3643 target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
3644 strendzap (target_name, ".exe");
3645 tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
3646 XFREE (target_name);
3647 target_name = tmp_pathspec;
3648 tmp_pathspec = 0;
3650 LTWRAPPER_DEBUGPRINTF (("(main) libtool target name: %s\n",
3651 target_name));
3654 cat <<EOF
3655 newargz[0] =
3656 XMALLOC (char, (strlen (actual_cwrapper_path) +
3657 strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
3658 strcpy (newargz[0], actual_cwrapper_path);
3659 strcat (newargz[0], "$objdir");
3660 strcat (newargz[0], "/");
3663 cat <<"EOF"
3664 /* stop here, and copy so we don't have to do this twice */
3665 tmp_pathspec = xstrdup (newargz[0]);
3667 /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
3668 strcat (newargz[0], actual_cwrapper_name);
3670 /* DO want the lt- prefix here if it exists, so use target_name */
3671 lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
3672 XFREE (tmp_pathspec);
3673 tmp_pathspec = NULL;
3676 case $host_os in
3677 mingw*)
3678 cat <<"EOF"
3680 char* p;
3681 while ((p = strchr (newargz[0], '\\')) != NULL)
3683 *p = '/';
3685 while ((p = strchr (lt_argv_zero, '\\')) != NULL)
3687 *p = '/';
3692 esac
3694 cat <<"EOF"
3695 XFREE (target_name);
3696 XFREE (actual_cwrapper_path);
3697 XFREE (actual_cwrapper_name);
3699 lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
3700 lt_setenv ("DUALCASE", "1"); /* for MSK sh */
3701 lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
3702 lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
3704 newargc=0;
3705 for (i = 1; i < argc; i++)
3707 if (strncmp (argv[i], ltwrapper_option_prefix, opt_prefix_len) == 0)
3709 /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
3710 namespace, but it is not one of the ones we know about and
3711 have already dealt with, above (inluding dump-script), then
3712 report an error. Otherwise, targets might begin to believe
3713 they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
3714 namespace. The first time any user complains about this, we'll
3715 need to make LTWRAPPER_OPTION_PREFIX a configure-time option
3716 or a configure.ac-settable value.
3718 lt_fatal ("Unrecognized option in %s namespace: '%s'",
3719 ltwrapper_option_prefix, argv[i]);
3721 /* otherwise ... */
3722 newargz[++newargc] = xstrdup (argv[i]);
3724 newargz[++newargc] = NULL;
3726 LTWRAPPER_DEBUGPRINTF (("(main) lt_argv_zero : %s\n", (lt_argv_zero ? lt_argv_zero : "<NULL>")));
3727 for (i = 0; i < newargc; i++)
3729 LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d] : %s\n", i, (newargz[i] ? newargz[i] : "<NULL>")));
3734 case $host_os in
3735 mingw*)
3736 cat <<"EOF"
3737 /* execv doesn't actually work on mingw as expected on unix */
3738 newargz = prepare_spawn (newargz);
3739 rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
3740 if (rval == -1)
3742 /* failed to start process */
3743 LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno));
3744 return 127;
3746 return rval;
3750 cat <<"EOF"
3751 execv (lt_argv_zero, newargz);
3752 return rval; /* =127, but avoids unused variable warning */
3755 esac
3757 cat <<"EOF"
3760 void *
3761 xmalloc (size_t num)
3763 void *p = (void *) malloc (num);
3764 if (!p)
3765 lt_fatal ("Memory exhausted");
3767 return p;
3770 char *
3771 xstrdup (const char *string)
3773 return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
3774 string) : NULL;
3777 const char *
3778 base_name (const char *name)
3780 const char *base;
3782 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3783 /* Skip over the disk name in MSDOS pathnames. */
3784 if (isalpha ((unsigned char) name[0]) && name[1] == ':')
3785 name += 2;
3786 #endif
3788 for (base = name; *name; name++)
3789 if (IS_DIR_SEPARATOR (*name))
3790 base = name + 1;
3791 return base;
3795 check_executable (const char *path)
3797 struct stat st;
3799 LTWRAPPER_DEBUGPRINTF (("(check_executable) : %s\n",
3800 path ? (*path ? path : "EMPTY!") : "NULL!"));
3801 if ((!path) || (!*path))
3802 return 0;
3804 if ((stat (path, &st) >= 0)
3805 && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
3806 return 1;
3807 else
3808 return 0;
3812 make_executable (const char *path)
3814 int rval = 0;
3815 struct stat st;
3817 LTWRAPPER_DEBUGPRINTF (("(make_executable) : %s\n",
3818 path ? (*path ? path : "EMPTY!") : "NULL!"));
3819 if ((!path) || (!*path))
3820 return 0;
3822 if (stat (path, &st) >= 0)
3824 rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
3826 return rval;
3829 /* Searches for the full path of the wrapper. Returns
3830 newly allocated full path name if found, NULL otherwise
3831 Does not chase symlinks, even on platforms that support them.
3833 char *
3834 find_executable (const char *wrapper)
3836 int has_slash = 0;
3837 const char *p;
3838 const char *p_next;
3839 /* static buffer for getcwd */
3840 char tmp[LT_PATHMAX + 1];
3841 int tmp_len;
3842 char *concat_name;
3844 LTWRAPPER_DEBUGPRINTF (("(find_executable) : %s\n",
3845 wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"));
3847 if ((wrapper == NULL) || (*wrapper == '\0'))
3848 return NULL;
3850 /* Absolute path? */
3851 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3852 if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
3854 concat_name = xstrdup (wrapper);
3855 if (check_executable (concat_name))
3856 return concat_name;
3857 XFREE (concat_name);
3859 else
3861 #endif
3862 if (IS_DIR_SEPARATOR (wrapper[0]))
3864 concat_name = xstrdup (wrapper);
3865 if (check_executable (concat_name))
3866 return concat_name;
3867 XFREE (concat_name);
3869 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3871 #endif
3873 for (p = wrapper; *p; p++)
3874 if (*p == '/')
3876 has_slash = 1;
3877 break;
3879 if (!has_slash)
3881 /* no slashes; search PATH */
3882 const char *path = getenv ("PATH");
3883 if (path != NULL)
3885 for (p = path; *p; p = p_next)
3887 const char *q;
3888 size_t p_len;
3889 for (q = p; *q; q++)
3890 if (IS_PATH_SEPARATOR (*q))
3891 break;
3892 p_len = q - p;
3893 p_next = (*q == '\0' ? q : q + 1);
3894 if (p_len == 0)
3896 /* empty path: current directory */
3897 if (getcwd (tmp, LT_PATHMAX) == NULL)
3898 lt_fatal ("getcwd failed");
3899 tmp_len = strlen (tmp);
3900 concat_name =
3901 XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
3902 memcpy (concat_name, tmp, tmp_len);
3903 concat_name[tmp_len] = '/';
3904 strcpy (concat_name + tmp_len + 1, wrapper);
3906 else
3908 concat_name =
3909 XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
3910 memcpy (concat_name, p, p_len);
3911 concat_name[p_len] = '/';
3912 strcpy (concat_name + p_len + 1, wrapper);
3914 if (check_executable (concat_name))
3915 return concat_name;
3916 XFREE (concat_name);
3919 /* not found in PATH; assume curdir */
3921 /* Relative path | not found in path: prepend cwd */
3922 if (getcwd (tmp, LT_PATHMAX) == NULL)
3923 lt_fatal ("getcwd failed");
3924 tmp_len = strlen (tmp);
3925 concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
3926 memcpy (concat_name, tmp, tmp_len);
3927 concat_name[tmp_len] = '/';
3928 strcpy (concat_name + tmp_len + 1, wrapper);
3930 if (check_executable (concat_name))
3931 return concat_name;
3932 XFREE (concat_name);
3933 return NULL;
3936 char *
3937 chase_symlinks (const char *pathspec)
3939 #ifndef S_ISLNK
3940 return xstrdup (pathspec);
3941 #else
3942 char buf[LT_PATHMAX];
3943 struct stat s;
3944 char *tmp_pathspec = xstrdup (pathspec);
3945 char *p;
3946 int has_symlinks = 0;
3947 while (strlen (tmp_pathspec) && !has_symlinks)
3949 LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n",
3950 tmp_pathspec));
3951 if (lstat (tmp_pathspec, &s) == 0)
3953 if (S_ISLNK (s.st_mode) != 0)
3955 has_symlinks = 1;
3956 break;
3959 /* search backwards for last DIR_SEPARATOR */
3960 p = tmp_pathspec + strlen (tmp_pathspec) - 1;
3961 while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
3962 p--;
3963 if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
3965 /* no more DIR_SEPARATORS left */
3966 break;
3968 *p = '\0';
3970 else
3972 char *errstr = strerror (errno);
3973 lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr);
3976 XFREE (tmp_pathspec);
3978 if (!has_symlinks)
3980 return xstrdup (pathspec);
3983 tmp_pathspec = realpath (pathspec, buf);
3984 if (tmp_pathspec == 0)
3986 lt_fatal ("Could not follow symlinks for %s", pathspec);
3988 return xstrdup (tmp_pathspec);
3989 #endif
3992 char *
3993 strendzap (char *str, const char *pat)
3995 size_t len, patlen;
3997 assert (str != NULL);
3998 assert (pat != NULL);
4000 len = strlen (str);
4001 patlen = strlen (pat);
4003 if (patlen <= len)
4005 str += len - patlen;
4006 if (strcmp (str, pat) == 0)
4007 *str = '\0';
4009 return str;
4012 static void
4013 lt_error_core (int exit_status, const char *mode,
4014 const char *message, va_list ap)
4016 fprintf (stderr, "%s: %s: ", program_name, mode);
4017 vfprintf (stderr, message, ap);
4018 fprintf (stderr, ".\n");
4020 if (exit_status >= 0)
4021 exit (exit_status);
4024 void
4025 lt_fatal (const char *message, ...)
4027 va_list ap;
4028 va_start (ap, message);
4029 lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
4030 va_end (ap);
4033 void
4034 lt_setenv (const char *name, const char *value)
4036 LTWRAPPER_DEBUGPRINTF (("(lt_setenv) setting '%s' to '%s'\n",
4037 (name ? name : "<NULL>"),
4038 (value ? value : "<NULL>")));
4040 #ifdef HAVE_SETENV
4041 /* always make a copy, for consistency with !HAVE_SETENV */
4042 char *str = xstrdup (value);
4043 setenv (name, str, 1);
4044 #else
4045 int len = strlen (name) + 1 + strlen (value) + 1;
4046 char *str = XMALLOC (char, len);
4047 sprintf (str, "%s=%s", name, value);
4048 if (putenv (str) != EXIT_SUCCESS)
4050 XFREE (str);
4052 #endif
4056 char *
4057 lt_extend_str (const char *orig_value, const char *add, int to_end)
4059 char *new_value;
4060 if (orig_value && *orig_value)
4062 int orig_value_len = strlen (orig_value);
4063 int add_len = strlen (add);
4064 new_value = XMALLOC (char, add_len + orig_value_len + 1);
4065 if (to_end)
4067 strcpy (new_value, orig_value);
4068 strcpy (new_value + orig_value_len, add);
4070 else
4072 strcpy (new_value, add);
4073 strcpy (new_value + add_len, orig_value);
4076 else
4078 new_value = xstrdup (add);
4080 return new_value;
4083 void
4084 lt_update_exe_path (const char *name, const char *value)
4086 LTWRAPPER_DEBUGPRINTF (("(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
4087 (name ? name : "<NULL>"),
4088 (value ? value : "<NULL>")));
4090 if (name && *name && value && *value)
4092 char *new_value = lt_extend_str (getenv (name), value, 0);
4093 /* some systems can't cope with a ':'-terminated path #' */
4094 int len = strlen (new_value);
4095 while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
4097 new_value[len-1] = '\0';
4099 lt_setenv (name, new_value);
4100 XFREE (new_value);
4104 void
4105 lt_update_lib_path (const char *name, const char *value)
4107 LTWRAPPER_DEBUGPRINTF (("(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
4108 (name ? name : "<NULL>"),
4109 (value ? value : "<NULL>")));
4111 if (name && *name && value && *value)
4113 char *new_value = lt_extend_str (getenv (name), value, 0);
4114 lt_setenv (name, new_value);
4115 XFREE (new_value);
4120 case $host_os in
4121 mingw*)
4122 cat <<"EOF"
4124 /* Prepares an argument vector before calling spawn().
4125 Note that spawn() does not by itself call the command interpreter
4126 (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
4127 ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
4128 GetVersionEx(&v);
4129 v.dwPlatformId == VER_PLATFORM_WIN32_NT;
4130 }) ? "cmd.exe" : "command.com").
4131 Instead it simply concatenates the arguments, separated by ' ', and calls
4132 CreateProcess(). We must quote the arguments since Win32 CreateProcess()
4133 interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
4134 special way:
4135 - Space and tab are interpreted as delimiters. They are not treated as
4136 delimiters if they are surrounded by double quotes: "...".
4137 - Unescaped double quotes are removed from the input. Their only effect is
4138 that within double quotes, space and tab are treated like normal
4139 characters.
4140 - Backslashes not followed by double quotes are not special.
4141 - But 2*n+1 backslashes followed by a double quote become
4142 n backslashes followed by a double quote (n >= 0):
4143 \" -> "
4144 \\\" -> \"
4145 \\\\\" -> \\"
4147 #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"
4148 #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"
4149 char **
4150 prepare_spawn (char **argv)
4152 size_t argc;
4153 char **new_argv;
4154 size_t i;
4156 /* Count number of arguments. */
4157 for (argc = 0; argv[argc] != NULL; argc++)
4160 /* Allocate new argument vector. */
4161 new_argv = XMALLOC (char *, argc + 1);
4163 /* Put quoted arguments into the new argument vector. */
4164 for (i = 0; i < argc; i++)
4166 const char *string = argv[i];
4168 if (string[0] == '\0')
4169 new_argv[i] = xstrdup ("\"\"");
4170 else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
4172 int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
4173 size_t length;
4174 unsigned int backslashes;
4175 const char *s;
4176 char *quoted_string;
4177 char *p;
4179 length = 0;
4180 backslashes = 0;
4181 if (quote_around)
4182 length++;
4183 for (s = string; *s != '\0'; s++)
4185 char c = *s;
4186 if (c == '"')
4187 length += backslashes + 1;
4188 length++;
4189 if (c == '\\')
4190 backslashes++;
4191 else
4192 backslashes = 0;
4194 if (quote_around)
4195 length += backslashes + 1;
4197 quoted_string = XMALLOC (char, length + 1);
4199 p = quoted_string;
4200 backslashes = 0;
4201 if (quote_around)
4202 *p++ = '"';
4203 for (s = string; *s != '\0'; s++)
4205 char c = *s;
4206 if (c == '"')
4208 unsigned int j;
4209 for (j = backslashes + 1; j > 0; j--)
4210 *p++ = '\\';
4212 *p++ = c;
4213 if (c == '\\')
4214 backslashes++;
4215 else
4216 backslashes = 0;
4218 if (quote_around)
4220 unsigned int j;
4221 for (j = backslashes; j > 0; j--)
4222 *p++ = '\\';
4223 *p++ = '"';
4225 *p = '\0';
4227 new_argv[i] = quoted_string;
4229 else
4230 new_argv[i] = (char *) string;
4232 new_argv[argc] = NULL;
4234 return new_argv;
4238 esac
4240 cat <<"EOF"
4241 void lt_dump_script (FILE* f)
4244 func_emit_wrapper yes |
4245 $SED -e 's/\([\\"]\)/\\\1/g' \
4246 -e 's/^/ fputs ("/' -e 's/$/\\n", f);/'
4248 cat <<"EOF"
4252 # end: func_emit_cwrapperexe_src
4254 # func_win32_import_lib_p ARG
4255 # True if ARG is an import lib, as indicated by $file_magic_cmd
4256 func_win32_import_lib_p ()
4258 $opt_debug
4259 case `eval "$file_magic_cmd \"\$1\" 2>/dev/null" | $SED -e 10q` in
4260 *import*) : ;;
4261 *) false ;;
4262 esac
4265 # func_mode_link arg...
4266 func_mode_link ()
4268 $opt_debug
4269 case $host in
4270 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
4271 # It is impossible to link a dll without this setting, and
4272 # we shouldn't force the makefile maintainer to figure out
4273 # which system we are compiling for in order to pass an extra
4274 # flag for every libtool invocation.
4275 # allow_undefined=no
4277 # FIXME: Unfortunately, there are problems with the above when trying
4278 # to make a dll which has undefined symbols, in which case not
4279 # even a static library is built. For now, we need to specify
4280 # -no-undefined on the libtool link line when we can be certain
4281 # that all symbols are satisfied, otherwise we get a static library.
4282 allow_undefined=yes
4285 allow_undefined=yes
4287 esac
4288 libtool_args=$nonopt
4289 base_compile="$nonopt $@"
4290 compile_command=$nonopt
4291 finalize_command=$nonopt
4293 compile_rpath=
4294 finalize_rpath=
4295 compile_shlibpath=
4296 finalize_shlibpath=
4297 convenience=
4298 old_convenience=
4299 deplibs=
4300 old_deplibs=
4301 compiler_flags=
4302 linker_flags=
4303 dllsearchpath=
4304 lib_search_path=`pwd`
4305 inst_prefix_dir=
4306 new_inherited_linker_flags=
4308 avoid_version=no
4309 bindir=
4310 dlfiles=
4311 dlprefiles=
4312 dlself=no
4313 export_dynamic=no
4314 export_symbols=
4315 export_symbols_regex=
4316 generated=
4317 libobjs=
4318 ltlibs=
4319 module=no
4320 no_install=no
4321 objs=
4322 non_pic_objects=
4323 precious_files_regex=
4324 prefer_static_libs=no
4325 preload=no
4326 prev=
4327 prevarg=
4328 release=
4329 rpath=
4330 xrpath=
4331 perm_rpath=
4332 temp_rpath=
4333 thread_safe=no
4334 vinfo=
4335 vinfo_number=no
4336 weak_libs=
4337 single_module="${wl}-single_module"
4338 func_infer_tag $base_compile
4340 # We need to know -static, to get the right output filenames.
4341 for arg
4343 case $arg in
4344 -shared)
4345 test "$build_libtool_libs" != yes && \
4346 func_fatal_configuration "can not build a shared library"
4347 build_old_libs=no
4348 break
4350 -all-static | -static | -static-libtool-libs)
4351 case $arg in
4352 -all-static)
4353 if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
4354 func_warning "complete static linking is impossible in this configuration"
4356 if test -n "$link_static_flag"; then
4357 dlopen_self=$dlopen_self_static
4359 prefer_static_libs=yes
4361 -static)
4362 if test -z "$pic_flag" && test -n "$link_static_flag"; then
4363 dlopen_self=$dlopen_self_static
4365 prefer_static_libs=built
4367 -static-libtool-libs)
4368 if test -z "$pic_flag" && test -n "$link_static_flag"; then
4369 dlopen_self=$dlopen_self_static
4371 prefer_static_libs=yes
4373 esac
4374 build_libtool_libs=no
4375 build_old_libs=yes
4376 break
4378 esac
4379 done
4381 # See if our shared archives depend on static archives.
4382 test -n "$old_archive_from_new_cmds" && build_old_libs=yes
4384 # Go through the arguments, transforming them on the way.
4385 while test "$#" -gt 0; do
4386 arg="$1"
4387 shift
4388 func_quote_for_eval "$arg"
4389 qarg=$func_quote_for_eval_unquoted_result
4390 func_append libtool_args " $func_quote_for_eval_result"
4392 # If the previous option needs an argument, assign it.
4393 if test -n "$prev"; then
4394 case $prev in
4395 output)
4396 func_append compile_command " @OUTPUT@"
4397 func_append finalize_command " @OUTPUT@"
4399 esac
4401 case $prev in
4402 bindir)
4403 bindir="$arg"
4404 prev=
4405 continue
4407 dlfiles|dlprefiles)
4408 if test "$preload" = no; then
4409 # Add the symbol object into the linking commands.
4410 func_append compile_command " @SYMFILE@"
4411 func_append finalize_command " @SYMFILE@"
4412 preload=yes
4414 case $arg in
4415 *.la | *.lo) ;; # We handle these cases below.
4416 force)
4417 if test "$dlself" = no; then
4418 dlself=needless
4419 export_dynamic=yes
4421 prev=
4422 continue
4424 self)
4425 if test "$prev" = dlprefiles; then
4426 dlself=yes
4427 elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
4428 dlself=yes
4429 else
4430 dlself=needless
4431 export_dynamic=yes
4433 prev=
4434 continue
4437 if test "$prev" = dlfiles; then
4438 dlfiles="$dlfiles $arg"
4439 else
4440 dlprefiles="$dlprefiles $arg"
4442 prev=
4443 continue
4445 esac
4447 expsyms)
4448 export_symbols="$arg"
4449 test -f "$arg" \
4450 || func_fatal_error "symbol file \`$arg' does not exist"
4451 prev=
4452 continue
4454 expsyms_regex)
4455 export_symbols_regex="$arg"
4456 prev=
4457 continue
4459 framework)
4460 case $host in
4461 *-*-darwin*)
4462 case "$deplibs " in
4463 *" $qarg.ltframework "*) ;;
4464 *) deplibs="$deplibs $qarg.ltframework" # this is fixed later
4466 esac
4468 esac
4469 prev=
4470 continue
4472 inst_prefix)
4473 inst_prefix_dir="$arg"
4474 prev=
4475 continue
4477 objectlist)
4478 if test -f "$arg"; then
4479 save_arg=$arg
4480 moreargs=
4481 for fil in `cat "$save_arg"`
4483 # moreargs="$moreargs $fil"
4484 arg=$fil
4485 # A libtool-controlled object.
4487 # Check to see that this really is a libtool object.
4488 if func_lalib_unsafe_p "$arg"; then
4489 pic_object=
4490 non_pic_object=
4492 # Read the .lo file
4493 func_source "$arg"
4495 if test -z "$pic_object" ||
4496 test -z "$non_pic_object" ||
4497 test "$pic_object" = none &&
4498 test "$non_pic_object" = none; then
4499 func_fatal_error "cannot find name of object for \`$arg'"
4502 # Extract subdirectory from the argument.
4503 func_dirname "$arg" "/" ""
4504 xdir="$func_dirname_result"
4506 if test "$pic_object" != none; then
4507 # Prepend the subdirectory the object is found in.
4508 pic_object="$xdir$pic_object"
4510 if test "$prev" = dlfiles; then
4511 if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
4512 dlfiles="$dlfiles $pic_object"
4513 prev=
4514 continue
4515 else
4516 # If libtool objects are unsupported, then we need to preload.
4517 prev=dlprefiles
4521 # CHECK ME: I think I busted this. -Ossama
4522 if test "$prev" = dlprefiles; then
4523 # Preload the old-style object.
4524 dlprefiles="$dlprefiles $pic_object"
4525 prev=
4528 # A PIC object.
4529 func_append libobjs " $pic_object"
4530 arg="$pic_object"
4533 # Non-PIC object.
4534 if test "$non_pic_object" != none; then
4535 # Prepend the subdirectory the object is found in.
4536 non_pic_object="$xdir$non_pic_object"
4538 # A standard non-PIC object
4539 func_append non_pic_objects " $non_pic_object"
4540 if test -z "$pic_object" || test "$pic_object" = none ; then
4541 arg="$non_pic_object"
4543 else
4544 # If the PIC object exists, use it instead.
4545 # $xdir was prepended to $pic_object above.
4546 non_pic_object="$pic_object"
4547 func_append non_pic_objects " $non_pic_object"
4549 else
4550 # Only an error if not doing a dry-run.
4551 if $opt_dry_run; then
4552 # Extract subdirectory from the argument.
4553 func_dirname "$arg" "/" ""
4554 xdir="$func_dirname_result"
4556 func_lo2o "$arg"
4557 pic_object=$xdir$objdir/$func_lo2o_result
4558 non_pic_object=$xdir$func_lo2o_result
4559 func_append libobjs " $pic_object"
4560 func_append non_pic_objects " $non_pic_object"
4561 else
4562 func_fatal_error "\`$arg' is not a valid libtool object"
4565 done
4566 else
4567 func_fatal_error "link input file \`$arg' does not exist"
4569 arg=$save_arg
4570 prev=
4571 continue
4573 precious_regex)
4574 precious_files_regex="$arg"
4575 prev=
4576 continue
4578 release)
4579 release="-$arg"
4580 prev=
4581 continue
4583 rpath | xrpath)
4584 # We need an absolute path.
4585 case $arg in
4586 [\\/]* | [A-Za-z]:[\\/]*) ;;
4588 func_fatal_error "only absolute run-paths are allowed"
4590 esac
4591 if test "$prev" = rpath; then
4592 case "$rpath " in
4593 *" $arg "*) ;;
4594 *) rpath="$rpath $arg" ;;
4595 esac
4596 else
4597 case "$xrpath " in
4598 *" $arg "*) ;;
4599 *) xrpath="$xrpath $arg" ;;
4600 esac
4602 prev=
4603 continue
4605 shrext)
4606 shrext_cmds="$arg"
4607 prev=
4608 continue
4610 weak)
4611 weak_libs="$weak_libs $arg"
4612 prev=
4613 continue
4615 xcclinker)
4616 linker_flags="$linker_flags $qarg"
4617 compiler_flags="$compiler_flags $qarg"
4618 prev=
4619 func_append compile_command " $qarg"
4620 func_append finalize_command " $qarg"
4621 continue
4623 xcompiler)
4624 compiler_flags="$compiler_flags $qarg"
4625 prev=
4626 func_append compile_command " $qarg"
4627 func_append finalize_command " $qarg"
4628 continue
4630 xlinker)
4631 linker_flags="$linker_flags $qarg"
4632 compiler_flags="$compiler_flags $wl$qarg"
4633 prev=
4634 func_append compile_command " $wl$qarg"
4635 func_append finalize_command " $wl$qarg"
4636 continue
4639 eval "$prev=\"\$arg\""
4640 prev=
4641 continue
4643 esac
4644 fi # test -n "$prev"
4646 prevarg="$arg"
4648 case $arg in
4649 -all-static)
4650 if test -n "$link_static_flag"; then
4651 # See comment for -static flag below, for more details.
4652 func_append compile_command " $link_static_flag"
4653 func_append finalize_command " $link_static_flag"
4655 continue
4658 -allow-undefined)
4659 # FIXME: remove this flag sometime in the future.
4660 func_fatal_error "\`-allow-undefined' must not be used because it is the default"
4663 -avoid-version)
4664 avoid_version=yes
4665 continue
4668 -bindir)
4669 prev=bindir
4670 continue
4673 -dlopen)
4674 prev=dlfiles
4675 continue
4678 -dlpreopen)
4679 prev=dlprefiles
4680 continue
4683 -export-dynamic)
4684 export_dynamic=yes
4685 continue
4688 -export-symbols | -export-symbols-regex)
4689 if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
4690 func_fatal_error "more than one -exported-symbols argument is not allowed"
4692 if test "X$arg" = "X-export-symbols"; then
4693 prev=expsyms
4694 else
4695 prev=expsyms_regex
4697 continue
4700 -framework)
4701 prev=framework
4702 continue
4705 -inst-prefix-dir)
4706 prev=inst_prefix
4707 continue
4710 # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
4711 # so, if we see these flags be careful not to treat them like -L
4712 -L[A-Z][A-Z]*:*)
4713 case $with_gcc/$host in
4714 no/*-*-irix* | /*-*-irix*)
4715 func_append compile_command " $arg"
4716 func_append finalize_command " $arg"
4718 esac
4719 continue
4722 -L*)
4723 func_stripname '-L' '' "$arg"
4724 dir=$func_stripname_result
4725 if test -z "$dir"; then
4726 if test "$#" -gt 0; then
4727 func_fatal_error "require no space between \`-L' and \`$1'"
4728 else
4729 func_fatal_error "need path for \`-L' option"
4732 # We need an absolute path.
4733 case $dir in
4734 [\\/]* | [A-Za-z]:[\\/]*) ;;
4736 absdir=`cd "$dir" && pwd`
4737 test -z "$absdir" && \
4738 func_fatal_error "cannot determine absolute directory name of \`$dir'"
4739 dir="$absdir"
4741 esac
4742 case "$deplibs " in
4743 *" -L$dir "*) ;;
4745 deplibs="$deplibs -L$dir"
4746 lib_search_path="$lib_search_path $dir"
4748 esac
4749 case $host in
4750 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
4751 testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
4752 case :$dllsearchpath: in
4753 *":$dir:"*) ;;
4754 ::) dllsearchpath=$dir;;
4755 *) dllsearchpath="$dllsearchpath:$dir";;
4756 esac
4757 case :$dllsearchpath: in
4758 *":$testbindir:"*) ;;
4759 ::) dllsearchpath=$testbindir;;
4760 *) dllsearchpath="$dllsearchpath:$testbindir";;
4761 esac
4763 esac
4764 continue
4767 -l*)
4768 if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
4769 case $host in
4770 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
4771 # These systems don't actually have a C or math library (as such)
4772 continue
4774 *-*-os2*)
4775 # These systems don't actually have a C library (as such)
4776 test "X$arg" = "X-lc" && continue
4778 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
4779 # Do not include libc due to us having libc/libc_r.
4780 test "X$arg" = "X-lc" && continue
4782 *-*-rhapsody* | *-*-darwin1.[012])
4783 # Rhapsody C and math libraries are in the System framework
4784 deplibs="$deplibs System.ltframework"
4785 continue
4787 *-*-sco3.2v5* | *-*-sco5v6*)
4788 # Causes problems with __ctype
4789 test "X$arg" = "X-lc" && continue
4791 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
4792 # Compiler inserts libc in the correct place for threads to work
4793 test "X$arg" = "X-lc" && continue
4795 *-*-linux*)
4796 test "X$arg" = "X-lc" && continue
4798 esac
4799 elif test "X$arg" = "X-lc_r"; then
4800 case $host in
4801 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
4802 # Do not include libc_r directly, use -pthread flag.
4803 continue
4805 esac
4807 deplibs="$deplibs $arg"
4808 continue
4811 -module)
4812 module=yes
4813 continue
4816 # Tru64 UNIX uses -model [arg] to determine the layout of C++
4817 # classes, name mangling, and exception handling.
4818 # Darwin uses the -arch flag to determine output architecture.
4819 -model|-arch|-isysroot)
4820 compiler_flags="$compiler_flags $arg"
4821 func_append compile_command " $arg"
4822 func_append finalize_command " $arg"
4823 prev=xcompiler
4824 continue
4827 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
4828 compiler_flags="$compiler_flags $arg"
4829 func_append compile_command " $arg"
4830 func_append finalize_command " $arg"
4831 case "$new_inherited_linker_flags " in
4832 *" $arg "*) ;;
4833 * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
4834 esac
4835 continue
4838 -multi_module)
4839 single_module="${wl}-multi_module"
4840 continue
4843 -no-fast-install)
4844 fast_install=no
4845 continue
4848 -no-install)
4849 case $host in
4850 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
4851 # The PATH hackery in wrapper scripts is required on Windows
4852 # and Darwin in order for the loader to find any dlls it needs.
4853 func_warning "\`-no-install' is ignored for $host"
4854 func_warning "assuming \`-no-fast-install' instead"
4855 fast_install=no
4857 *) no_install=yes ;;
4858 esac
4859 continue
4862 -no-undefined)
4863 allow_undefined=no
4864 continue
4867 -objectlist)
4868 prev=objectlist
4869 continue
4872 -o) prev=output ;;
4874 -precious-files-regex)
4875 prev=precious_regex
4876 continue
4879 -release)
4880 prev=release
4881 continue
4884 -rpath)
4885 prev=rpath
4886 continue
4890 prev=xrpath
4891 continue
4894 -R*)
4895 func_stripname '-R' '' "$arg"
4896 dir=$func_stripname_result
4897 # We need an absolute path.
4898 case $dir in
4899 [\\/]* | [A-Za-z]:[\\/]*) ;;
4901 func_fatal_error "only absolute run-paths are allowed"
4903 esac
4904 case "$xrpath " in
4905 *" $dir "*) ;;
4906 *) xrpath="$xrpath $dir" ;;
4907 esac
4908 continue
4911 -shared)
4912 # The effects of -shared are defined in a previous loop.
4913 continue
4916 -shrext)
4917 prev=shrext
4918 continue
4921 -static | -static-libtool-libs)
4922 # The effects of -static are defined in a previous loop.
4923 # We used to do the same as -all-static on platforms that
4924 # didn't have a PIC flag, but the assumption that the effects
4925 # would be equivalent was wrong. It would break on at least
4926 # Digital Unix and AIX.
4927 continue
4930 -thread-safe)
4931 thread_safe=yes
4932 continue
4935 -version-info)
4936 prev=vinfo
4937 continue
4940 -version-number)
4941 prev=vinfo
4942 vinfo_number=yes
4943 continue
4946 -weak)
4947 prev=weak
4948 continue
4951 -Wc,*)
4952 func_stripname '-Wc,' '' "$arg"
4953 args=$func_stripname_result
4954 arg=
4955 save_ifs="$IFS"; IFS=','
4956 for flag in $args; do
4957 IFS="$save_ifs"
4958 func_quote_for_eval "$flag"
4959 arg="$arg $func_quote_for_eval_result"
4960 compiler_flags="$compiler_flags $func_quote_for_eval_result"
4961 done
4962 IFS="$save_ifs"
4963 func_stripname ' ' '' "$arg"
4964 arg=$func_stripname_result
4967 -Wl,*)
4968 func_stripname '-Wl,' '' "$arg"
4969 args=$func_stripname_result
4970 arg=
4971 save_ifs="$IFS"; IFS=','
4972 for flag in $args; do
4973 IFS="$save_ifs"
4974 func_quote_for_eval "$flag"
4975 arg="$arg $wl$func_quote_for_eval_result"
4976 compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
4977 linker_flags="$linker_flags $func_quote_for_eval_result"
4978 done
4979 IFS="$save_ifs"
4980 func_stripname ' ' '' "$arg"
4981 arg=$func_stripname_result
4984 -Xcompiler)
4985 prev=xcompiler
4986 continue
4989 -Xlinker)
4990 prev=xlinker
4991 continue
4994 -XCClinker)
4995 prev=xcclinker
4996 continue
4999 # -msg_* for osf cc
5000 -msg_*)
5001 func_quote_for_eval "$arg"
5002 arg="$func_quote_for_eval_result"
5005 # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
5006 # -r[0-9][0-9]* specifies the processor on the SGI compiler
5007 # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
5008 # +DA*, +DD* enable 64-bit mode on the HP compiler
5009 # -q* pass through compiler args for the IBM compiler
5010 # -m*, -t[45]*, -txscale* pass through architecture-specific
5011 # compiler args for GCC
5012 # -F/path gives path to uninstalled frameworks, gcc on darwin
5013 # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
5014 # @file GCC response files
5015 # -tp=* Portland pgcc target processor selection
5016 -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
5017 -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*)
5018 func_quote_for_eval "$arg"
5019 arg="$func_quote_for_eval_result"
5020 func_append compile_command " $arg"
5021 func_append finalize_command " $arg"
5022 compiler_flags="$compiler_flags $arg"
5023 continue
5026 # Some other compiler flag.
5027 -* | +*)
5028 func_quote_for_eval "$arg"
5029 arg="$func_quote_for_eval_result"
5032 *.$objext)
5033 # A standard object.
5034 objs="$objs $arg"
5037 *.lo)
5038 # A libtool-controlled object.
5040 # Check to see that this really is a libtool object.
5041 if func_lalib_unsafe_p "$arg"; then
5042 pic_object=
5043 non_pic_object=
5045 # Read the .lo file
5046 func_source "$arg"
5048 if test -z "$pic_object" ||
5049 test -z "$non_pic_object" ||
5050 test "$pic_object" = none &&
5051 test "$non_pic_object" = none; then
5052 func_fatal_error "cannot find name of object for \`$arg'"
5055 # Extract subdirectory from the argument.
5056 func_dirname "$arg" "/" ""
5057 xdir="$func_dirname_result"
5059 if test "$pic_object" != none; then
5060 # Prepend the subdirectory the object is found in.
5061 pic_object="$xdir$pic_object"
5063 if test "$prev" = dlfiles; then
5064 if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5065 dlfiles="$dlfiles $pic_object"
5066 prev=
5067 continue
5068 else
5069 # If libtool objects are unsupported, then we need to preload.
5070 prev=dlprefiles
5074 # CHECK ME: I think I busted this. -Ossama
5075 if test "$prev" = dlprefiles; then
5076 # Preload the old-style object.
5077 dlprefiles="$dlprefiles $pic_object"
5078 prev=
5081 # A PIC object.
5082 func_append libobjs " $pic_object"
5083 arg="$pic_object"
5086 # Non-PIC object.
5087 if test "$non_pic_object" != none; then
5088 # Prepend the subdirectory the object is found in.
5089 non_pic_object="$xdir$non_pic_object"
5091 # A standard non-PIC object
5092 func_append non_pic_objects " $non_pic_object"
5093 if test -z "$pic_object" || test "$pic_object" = none ; then
5094 arg="$non_pic_object"
5096 else
5097 # If the PIC object exists, use it instead.
5098 # $xdir was prepended to $pic_object above.
5099 non_pic_object="$pic_object"
5100 func_append non_pic_objects " $non_pic_object"
5102 else
5103 # Only an error if not doing a dry-run.
5104 if $opt_dry_run; then
5105 # Extract subdirectory from the argument.
5106 func_dirname "$arg" "/" ""
5107 xdir="$func_dirname_result"
5109 func_lo2o "$arg"
5110 pic_object=$xdir$objdir/$func_lo2o_result
5111 non_pic_object=$xdir$func_lo2o_result
5112 func_append libobjs " $pic_object"
5113 func_append non_pic_objects " $non_pic_object"
5114 else
5115 func_fatal_error "\`$arg' is not a valid libtool object"
5120 *.$libext)
5121 # An archive.
5122 deplibs="$deplibs $arg"
5123 old_deplibs="$old_deplibs $arg"
5124 continue
5127 *.la)
5128 # A libtool-controlled library.
5130 if test "$prev" = dlfiles; then
5131 # This library was specified with -dlopen.
5132 dlfiles="$dlfiles $arg"
5133 prev=
5134 elif test "$prev" = dlprefiles; then
5135 # The library was specified with -dlpreopen.
5136 dlprefiles="$dlprefiles $arg"
5137 prev=
5138 else
5139 deplibs="$deplibs $arg"
5141 continue
5144 # Some other compiler argument.
5146 # Unknown arguments in both finalize_command and compile_command need
5147 # to be aesthetically quoted because they are evaled later.
5148 func_quote_for_eval "$arg"
5149 arg="$func_quote_for_eval_result"
5151 esac # arg
5153 # Now actually substitute the argument into the commands.
5154 if test -n "$arg"; then
5155 func_append compile_command " $arg"
5156 func_append finalize_command " $arg"
5158 done # argument parsing loop
5160 test -n "$prev" && \
5161 func_fatal_help "the \`$prevarg' option requires an argument"
5163 if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
5164 eval "arg=\"$export_dynamic_flag_spec\""
5165 func_append compile_command " $arg"
5166 func_append finalize_command " $arg"
5169 oldlibs=
5170 # calculate the name of the file, without its directory
5171 func_basename "$output"
5172 outputname="$func_basename_result"
5173 libobjs_save="$libobjs"
5175 if test -n "$shlibpath_var"; then
5176 # get the directories listed in $shlibpath_var
5177 eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
5178 else
5179 shlib_search_path=
5181 eval "sys_lib_search_path=\"$sys_lib_search_path_spec\""
5182 eval "sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\""
5184 func_dirname "$output" "/" ""
5185 output_objdir="$func_dirname_result$objdir"
5186 # Create the object directory.
5187 func_mkdir_p "$output_objdir"
5189 # Determine the type of output
5190 case $output in
5192 func_fatal_help "you must specify an output file"
5194 *.$libext) linkmode=oldlib ;;
5195 *.lo | *.$objext) linkmode=obj ;;
5196 *.la) linkmode=lib ;;
5197 *) linkmode=prog ;; # Anything else should be a program.
5198 esac
5200 specialdeplibs=
5202 libs=
5203 # Find all interdependent deplibs by searching for libraries
5204 # that are linked more than once (e.g. -la -lb -la)
5205 for deplib in $deplibs; do
5206 if $opt_duplicate_deps ; then
5207 case "$libs " in
5208 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5209 esac
5211 libs="$libs $deplib"
5212 done
5214 if test "$linkmode" = lib; then
5215 libs="$predeps $libs $compiler_lib_search_path $postdeps"
5217 # Compute libraries that are listed more than once in $predeps
5218 # $postdeps and mark them as special (i.e., whose duplicates are
5219 # not to be eliminated).
5220 pre_post_deps=
5221 if $opt_duplicate_compiler_generated_deps; then
5222 for pre_post_dep in $predeps $postdeps; do
5223 case "$pre_post_deps " in
5224 *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
5225 esac
5226 pre_post_deps="$pre_post_deps $pre_post_dep"
5227 done
5229 pre_post_deps=
5232 deplibs=
5233 newdependency_libs=
5234 newlib_search_path=
5235 need_relink=no # whether we're linking any uninstalled libtool libraries
5236 notinst_deplibs= # not-installed libtool libraries
5237 notinst_path= # paths that contain not-installed libtool libraries
5239 case $linkmode in
5240 lib)
5241 passes="conv dlpreopen link"
5242 for file in $dlfiles $dlprefiles; do
5243 case $file in
5244 *.la) ;;
5246 func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
5248 esac
5249 done
5251 prog)
5252 compile_deplibs=
5253 finalize_deplibs=
5254 alldeplibs=no
5255 newdlfiles=
5256 newdlprefiles=
5257 passes="conv scan dlopen dlpreopen link"
5259 *) passes="conv"
5261 esac
5263 for pass in $passes; do
5264 # The preopen pass in lib mode reverses $deplibs; put it back here
5265 # so that -L comes before libs that need it for instance...
5266 if test "$linkmode,$pass" = "lib,link"; then
5267 ## FIXME: Find the place where the list is rebuilt in the wrong
5268 ## order, and fix it there properly
5269 tmp_deplibs=
5270 for deplib in $deplibs; do
5271 tmp_deplibs="$deplib $tmp_deplibs"
5272 done
5273 deplibs="$tmp_deplibs"
5276 if test "$linkmode,$pass" = "lib,link" ||
5277 test "$linkmode,$pass" = "prog,scan"; then
5278 libs="$deplibs"
5279 deplibs=
5281 if test "$linkmode" = prog; then
5282 case $pass in
5283 dlopen) libs="$dlfiles" ;;
5284 dlpreopen) libs="$dlprefiles" ;;
5285 link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
5286 esac
5288 if test "$linkmode,$pass" = "lib,dlpreopen"; then
5289 # Collect and forward deplibs of preopened libtool libs
5290 for lib in $dlprefiles; do
5291 # Ignore non-libtool-libs
5292 dependency_libs=
5293 case $lib in
5294 *.la) func_source "$lib" ;;
5295 esac
5297 # Collect preopened libtool deplibs, except any this library
5298 # has declared as weak libs
5299 for deplib in $dependency_libs; do
5300 func_basename "$deplib"
5301 deplib_base=$func_basename_result
5302 case " $weak_libs " in
5303 *" $deplib_base "*) ;;
5304 *) deplibs="$deplibs $deplib" ;;
5305 esac
5306 done
5307 done
5308 libs="$dlprefiles"
5310 if test "$pass" = dlopen; then
5311 # Collect dlpreopened libraries
5312 save_deplibs="$deplibs"
5313 deplibs=
5316 for deplib in $libs; do
5317 lib=
5318 found=no
5319 case $deplib in
5320 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
5321 if test "$linkmode,$pass" = "prog,link"; then
5322 compile_deplibs="$deplib $compile_deplibs"
5323 finalize_deplibs="$deplib $finalize_deplibs"
5324 else
5325 compiler_flags="$compiler_flags $deplib"
5326 if test "$linkmode" = lib ; then
5327 case "$new_inherited_linker_flags " in
5328 *" $deplib "*) ;;
5329 * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
5330 esac
5333 continue
5335 -l*)
5336 if test "$linkmode" != lib && test "$linkmode" != prog; then
5337 func_warning "\`-l' is ignored for archives/objects"
5338 continue
5340 func_stripname '-l' '' "$deplib"
5341 name=$func_stripname_result
5342 if test "$linkmode" = lib; then
5343 searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
5344 else
5345 searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
5347 for searchdir in $searchdirs; do
5348 for search_ext in .la $std_shrext .so .a; do
5349 # Search the libtool library
5350 lib="$searchdir/lib${name}${search_ext}"
5351 if test -f "$lib"; then
5352 if test "$search_ext" = ".la"; then
5353 found=yes
5354 else
5355 found=no
5357 break 2
5359 done
5360 done
5361 if test "$found" != yes; then
5362 # deplib doesn't seem to be a libtool library
5363 if test "$linkmode,$pass" = "prog,link"; then
5364 compile_deplibs="$deplib $compile_deplibs"
5365 finalize_deplibs="$deplib $finalize_deplibs"
5366 else
5367 deplibs="$deplib $deplibs"
5368 test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
5370 continue
5371 else # deplib is a libtool library
5372 # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
5373 # We need to do some special things here, and not later.
5374 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
5375 case " $predeps $postdeps " in
5376 *" $deplib "*)
5377 if func_lalib_p "$lib"; then
5378 library_names=
5379 old_library=
5380 func_source "$lib"
5381 for l in $old_library $library_names; do
5382 ll="$l"
5383 done
5384 if test "X$ll" = "X$old_library" ; then # only static version available
5385 found=no
5386 func_dirname "$lib" "" "."
5387 ladir="$func_dirname_result"
5388 lib=$ladir/$old_library
5389 if test "$linkmode,$pass" = "prog,link"; then
5390 compile_deplibs="$deplib $compile_deplibs"
5391 finalize_deplibs="$deplib $finalize_deplibs"
5392 else
5393 deplibs="$deplib $deplibs"
5394 test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
5396 continue
5400 *) ;;
5401 esac
5404 ;; # -l
5405 *.ltframework)
5406 if test "$linkmode,$pass" = "prog,link"; then
5407 compile_deplibs="$deplib $compile_deplibs"
5408 finalize_deplibs="$deplib $finalize_deplibs"
5409 else
5410 deplibs="$deplib $deplibs"
5411 if test "$linkmode" = lib ; then
5412 case "$new_inherited_linker_flags " in
5413 *" $deplib "*) ;;
5414 * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
5415 esac
5418 continue
5420 -L*)
5421 case $linkmode in
5422 lib)
5423 deplibs="$deplib $deplibs"
5424 test "$pass" = conv && continue
5425 newdependency_libs="$deplib $newdependency_libs"
5426 func_stripname '-L' '' "$deplib"
5427 newlib_search_path="$newlib_search_path $func_stripname_result"
5429 prog)
5430 if test "$pass" = conv; then
5431 deplibs="$deplib $deplibs"
5432 continue
5434 if test "$pass" = scan; then
5435 deplibs="$deplib $deplibs"
5436 else
5437 compile_deplibs="$deplib $compile_deplibs"
5438 finalize_deplibs="$deplib $finalize_deplibs"
5440 func_stripname '-L' '' "$deplib"
5441 newlib_search_path="$newlib_search_path $func_stripname_result"
5444 func_warning "\`-L' is ignored for archives/objects"
5446 esac # linkmode
5447 continue
5448 ;; # -L
5449 -R*)
5450 if test "$pass" = link; then
5451 func_stripname '-R' '' "$deplib"
5452 dir=$func_stripname_result
5453 # Make sure the xrpath contains only unique directories.
5454 case "$xrpath " in
5455 *" $dir "*) ;;
5456 *) xrpath="$xrpath $dir" ;;
5457 esac
5459 deplibs="$deplib $deplibs"
5460 continue
5462 *.la) lib="$deplib" ;;
5463 *.$libext)
5464 if test "$pass" = conv; then
5465 deplibs="$deplib $deplibs"
5466 continue
5468 case $linkmode in
5469 lib)
5470 # Linking convenience modules into shared libraries is allowed,
5471 # but linking other static libraries is non-portable.
5472 case " $dlpreconveniencelibs " in
5473 *" $deplib "*) ;;
5475 valid_a_lib=no
5476 case $deplibs_check_method in
5477 match_pattern*)
5478 set dummy $deplibs_check_method; shift
5479 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
5480 if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
5481 | $EGREP "$match_pattern_regex" > /dev/null; then
5482 valid_a_lib=yes
5485 pass_all)
5486 valid_a_lib=yes
5488 esac
5489 if test "$valid_a_lib" != yes; then
5490 echo
5491 $ECHO "*** Warning: Trying to link with static lib archive $deplib."
5492 echo "*** I have the capability to make that library automatically link in when"
5493 echo "*** you link to this library. But I can only do this if you have a"
5494 echo "*** shared version of the library, which you do not appear to have"
5495 echo "*** because the file extensions .$libext of this argument makes me believe"
5496 echo "*** that it is just a static archive that I should not use here."
5497 else
5498 echo
5499 $ECHO "*** Warning: Linking the shared library $output against the"
5500 $ECHO "*** static library $deplib is not portable!"
5501 deplibs="$deplib $deplibs"
5504 esac
5505 continue
5507 prog)
5508 if test "$pass" != link; then
5509 deplibs="$deplib $deplibs"
5510 else
5511 compile_deplibs="$deplib $compile_deplibs"
5512 finalize_deplibs="$deplib $finalize_deplibs"
5514 continue
5516 esac # linkmode
5517 ;; # *.$libext
5518 *.lo | *.$objext)
5519 if test "$pass" = conv; then
5520 deplibs="$deplib $deplibs"
5521 elif test "$linkmode" = prog; then
5522 if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
5523 # If there is no dlopen support or we're linking statically,
5524 # we need to preload.
5525 newdlprefiles="$newdlprefiles $deplib"
5526 compile_deplibs="$deplib $compile_deplibs"
5527 finalize_deplibs="$deplib $finalize_deplibs"
5528 else
5529 newdlfiles="$newdlfiles $deplib"
5532 continue
5534 %DEPLIBS%)
5535 alldeplibs=yes
5536 continue
5538 esac # case $deplib
5540 if test "$found" = yes || test -f "$lib"; then :
5541 else
5542 func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
5545 # Check to see that this really is a libtool archive.
5546 func_lalib_unsafe_p "$lib" \
5547 || func_fatal_error "\`$lib' is not a valid libtool archive"
5549 func_dirname "$lib" "" "."
5550 ladir="$func_dirname_result"
5552 dlname=
5553 dlopen=
5554 dlpreopen=
5555 libdir=
5556 library_names=
5557 old_library=
5558 inherited_linker_flags=
5559 # If the library was installed with an old release of libtool,
5560 # it will not redefine variables installed, or shouldnotlink
5561 installed=yes
5562 shouldnotlink=no
5563 avoidtemprpath=
5566 # Read the .la file
5567 func_source "$lib"
5569 # Convert "-framework foo" to "foo.ltframework"
5570 if test -n "$inherited_linker_flags"; then
5571 tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
5572 for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
5573 case " $new_inherited_linker_flags " in
5574 *" $tmp_inherited_linker_flag "*) ;;
5575 *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
5576 esac
5577 done
5579 dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
5580 if test "$linkmode,$pass" = "lib,link" ||
5581 test "$linkmode,$pass" = "prog,scan" ||
5582 { test "$linkmode" != prog && test "$linkmode" != lib; }; then
5583 test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
5584 test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
5587 if test "$pass" = conv; then
5588 # Only check for convenience libraries
5589 deplibs="$lib $deplibs"
5590 if test -z "$libdir"; then
5591 if test -z "$old_library"; then
5592 func_fatal_error "cannot find name of link library for \`$lib'"
5594 # It is a libtool convenience library, so add in its objects.
5595 convenience="$convenience $ladir/$objdir/$old_library"
5596 old_convenience="$old_convenience $ladir/$objdir/$old_library"
5597 elif test "$linkmode" != prog && test "$linkmode" != lib; then
5598 func_fatal_error "\`$lib' is not a convenience library"
5600 tmp_libs=
5601 for deplib in $dependency_libs; do
5602 deplibs="$deplib $deplibs"
5603 if $opt_duplicate_deps ; then
5604 case "$tmp_libs " in
5605 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5606 esac
5608 tmp_libs="$tmp_libs $deplib"
5609 done
5610 continue
5611 fi # $pass = conv
5614 # Get the name of the library we link against.
5615 linklib=
5616 for l in $old_library $library_names; do
5617 linklib="$l"
5618 done
5619 if test -z "$linklib"; then
5620 func_fatal_error "cannot find name of link library for \`$lib'"
5623 # This library was specified with -dlopen.
5624 if test "$pass" = dlopen; then
5625 if test -z "$libdir"; then
5626 func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
5628 if test -z "$dlname" ||
5629 test "$dlopen_support" != yes ||
5630 test "$build_libtool_libs" = no; then
5631 # If there is no dlname, no dlopen support or we're linking
5632 # statically, we need to preload. We also need to preload any
5633 # dependent libraries so libltdl's deplib preloader doesn't
5634 # bomb out in the load deplibs phase.
5635 dlprefiles="$dlprefiles $lib $dependency_libs"
5636 else
5637 newdlfiles="$newdlfiles $lib"
5639 continue
5640 fi # $pass = dlopen
5642 # We need an absolute path.
5643 case $ladir in
5644 [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
5646 abs_ladir=`cd "$ladir" && pwd`
5647 if test -z "$abs_ladir"; then
5648 func_warning "cannot determine absolute directory name of \`$ladir'"
5649 func_warning "passing it literally to the linker, although it might fail"
5650 abs_ladir="$ladir"
5653 esac
5654 func_basename "$lib"
5655 laname="$func_basename_result"
5657 # Find the relevant object directory and library name.
5658 if test "X$installed" = Xyes; then
5659 if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
5660 func_warning "library \`$lib' was moved."
5661 dir="$ladir"
5662 absdir="$abs_ladir"
5663 libdir="$abs_ladir"
5664 else
5665 dir="$libdir"
5666 absdir="$libdir"
5668 test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
5669 else
5670 if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
5671 dir="$ladir"
5672 absdir="$abs_ladir"
5673 # Remove this search path later
5674 notinst_path="$notinst_path $abs_ladir"
5675 else
5676 dir="$ladir/$objdir"
5677 absdir="$abs_ladir/$objdir"
5678 # Remove this search path later
5679 notinst_path="$notinst_path $abs_ladir"
5681 fi # $installed = yes
5682 func_stripname 'lib' '.la' "$laname"
5683 name=$func_stripname_result
5685 # This library was specified with -dlpreopen.
5686 if test "$pass" = dlpreopen; then
5687 if test -z "$libdir" && test "$linkmode" = prog; then
5688 func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
5690 # Prefer using a static library (so that no silly _DYNAMIC symbols
5691 # are required to link).
5692 if test -n "$old_library"; then
5693 newdlprefiles="$newdlprefiles $dir/$old_library"
5694 # Keep a list of preopened convenience libraries to check
5695 # that they are being used correctly in the link pass.
5696 test -z "$libdir" && \
5697 dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
5698 # Otherwise, use the dlname, so that lt_dlopen finds it.
5699 elif test -n "$dlname"; then
5700 newdlprefiles="$newdlprefiles $dir/$dlname"
5701 else
5702 newdlprefiles="$newdlprefiles $dir/$linklib"
5704 fi # $pass = dlpreopen
5706 if test -z "$libdir"; then
5707 # Link the convenience library
5708 if test "$linkmode" = lib; then
5709 deplibs="$dir/$old_library $deplibs"
5710 elif test "$linkmode,$pass" = "prog,link"; then
5711 compile_deplibs="$dir/$old_library $compile_deplibs"
5712 finalize_deplibs="$dir/$old_library $finalize_deplibs"
5713 else
5714 deplibs="$lib $deplibs" # used for prog,scan pass
5716 continue
5720 if test "$linkmode" = prog && test "$pass" != link; then
5721 newlib_search_path="$newlib_search_path $ladir"
5722 deplibs="$lib $deplibs"
5724 linkalldeplibs=no
5725 if test "$link_all_deplibs" != no || test -z "$library_names" ||
5726 test "$build_libtool_libs" = no; then
5727 linkalldeplibs=yes
5730 tmp_libs=
5731 for deplib in $dependency_libs; do
5732 case $deplib in
5733 -L*) func_stripname '-L' '' "$deplib"
5734 newlib_search_path="$newlib_search_path $func_stripname_result"
5736 esac
5737 # Need to link against all dependency_libs?
5738 if test "$linkalldeplibs" = yes; then
5739 deplibs="$deplib $deplibs"
5740 else
5741 # Need to hardcode shared library paths
5742 # or/and link against static libraries
5743 newdependency_libs="$deplib $newdependency_libs"
5745 if $opt_duplicate_deps ; then
5746 case "$tmp_libs " in
5747 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5748 esac
5750 tmp_libs="$tmp_libs $deplib"
5751 done # for deplib
5752 continue
5753 fi # $linkmode = prog...
5755 if test "$linkmode,$pass" = "prog,link"; then
5756 if test -n "$library_names" &&
5757 { { test "$prefer_static_libs" = no ||
5758 test "$prefer_static_libs,$installed" = "built,yes"; } ||
5759 test -z "$old_library"; }; then
5760 # We need to hardcode the library path
5761 if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
5762 # Make sure the rpath contains only unique directories.
5763 case "$temp_rpath:" in
5764 *"$absdir:"*) ;;
5765 *) temp_rpath="$temp_rpath$absdir:" ;;
5766 esac
5769 # Hardcode the library path.
5770 # Skip directories that are in the system default run-time
5771 # search path.
5772 case " $sys_lib_dlsearch_path " in
5773 *" $absdir "*) ;;
5775 case "$compile_rpath " in
5776 *" $absdir "*) ;;
5777 *) compile_rpath="$compile_rpath $absdir"
5778 esac
5780 esac
5781 case " $sys_lib_dlsearch_path " in
5782 *" $libdir "*) ;;
5784 case "$finalize_rpath " in
5785 *" $libdir "*) ;;
5786 *) finalize_rpath="$finalize_rpath $libdir"
5787 esac
5789 esac
5790 fi # $linkmode,$pass = prog,link...
5792 if test "$alldeplibs" = yes &&
5793 { test "$deplibs_check_method" = pass_all ||
5794 { test "$build_libtool_libs" = yes &&
5795 test -n "$library_names"; }; }; then
5796 # We only need to search for static libraries
5797 continue
5801 link_static=no # Whether the deplib will be linked statically
5802 use_static_libs=$prefer_static_libs
5803 if test "$use_static_libs" = built && test "$installed" = yes; then
5804 use_static_libs=no
5806 if test -n "$library_names" &&
5807 { test "$use_static_libs" = no || test -z "$old_library"; }; then
5808 case $host in
5809 *cygwin* | *mingw* | *cegcc*)
5810 # No point in relinking DLLs because paths are not encoded
5811 notinst_deplibs="$notinst_deplibs $lib"
5812 need_relink=no
5815 if test "$installed" = no; then
5816 notinst_deplibs="$notinst_deplibs $lib"
5817 need_relink=yes
5820 esac
5821 # This is a shared library
5823 # Warn about portability, can't link against -module's on some
5824 # systems (darwin). Don't bleat about dlopened modules though!
5825 dlopenmodule=""
5826 for dlpremoduletest in $dlprefiles; do
5827 if test "X$dlpremoduletest" = "X$lib"; then
5828 dlopenmodule="$dlpremoduletest"
5829 break
5831 done
5832 if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
5833 echo
5834 if test "$linkmode" = prog; then
5835 $ECHO "*** Warning: Linking the executable $output against the loadable module"
5836 else
5837 $ECHO "*** Warning: Linking the shared library $output against the loadable module"
5839 $ECHO "*** $linklib is not portable!"
5841 if test "$linkmode" = lib &&
5842 test "$hardcode_into_libs" = yes; then
5843 # Hardcode the library path.
5844 # Skip directories that are in the system default run-time
5845 # search path.
5846 case " $sys_lib_dlsearch_path " in
5847 *" $absdir "*) ;;
5849 case "$compile_rpath " in
5850 *" $absdir "*) ;;
5851 *) compile_rpath="$compile_rpath $absdir"
5852 esac
5854 esac
5855 case " $sys_lib_dlsearch_path " in
5856 *" $libdir "*) ;;
5858 case "$finalize_rpath " in
5859 *" $libdir "*) ;;
5860 *) finalize_rpath="$finalize_rpath $libdir"
5861 esac
5863 esac
5866 if test -n "$old_archive_from_expsyms_cmds"; then
5867 # figure out the soname
5868 set dummy $library_names
5869 shift
5870 realname="$1"
5871 shift
5872 eval "libname=\"$libname_spec\""
5873 # use dlname if we got it. it's perfectly good, no?
5874 if test -n "$dlname"; then
5875 soname="$dlname"
5876 elif test -n "$soname_spec"; then
5877 # bleh windows
5878 case $host in
5879 *cygwin* | mingw* | *cegcc*)
5880 func_arith $current - $age
5881 major=$func_arith_result
5882 versuffix="-$major"
5884 esac
5885 eval "soname=\"$soname_spec\""
5886 else
5887 soname="$realname"
5890 # Make a new name for the extract_expsyms_cmds to use
5891 soroot="$soname"
5892 func_basename "$soroot"
5893 soname="$func_basename_result"
5894 func_stripname 'lib' '.dll' "$soname"
5895 newlib=libimp-$func_stripname_result.a
5897 # If the library has no export list, then create one now
5898 if test -f "$output_objdir/$soname-def"; then :
5899 else
5900 func_verbose "extracting exported symbol list from \`$soname'"
5901 func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
5904 # Create $newlib
5905 if test -f "$output_objdir/$newlib"; then :; else
5906 func_verbose "generating import library for \`$soname'"
5907 func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
5909 # make sure the library variables are pointing to the new library
5910 dir=$output_objdir
5911 linklib=$newlib
5912 fi # test -n "$old_archive_from_expsyms_cmds"
5914 if test "$linkmode" = prog || test "$mode" != relink; then
5915 add_shlibpath=
5916 add_dir=
5917 add=
5918 lib_linked=yes
5919 case $hardcode_action in
5920 immediate | unsupported)
5921 if test "$hardcode_direct" = no; then
5922 add="$dir/$linklib"
5923 case $host in
5924 *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
5925 *-*-sysv4*uw2*) add_dir="-L$dir" ;;
5926 *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
5927 *-*-unixware7*) add_dir="-L$dir" ;;
5928 *-*-darwin* )
5929 # if the lib is a (non-dlopened) module then we can not
5930 # link against it, someone is ignoring the earlier warnings
5931 if /usr/bin/file -L $add 2> /dev/null |
5932 $GREP ": [^:]* bundle" >/dev/null ; then
5933 if test "X$dlopenmodule" != "X$lib"; then
5934 $ECHO "*** Warning: lib $linklib is a module, not a shared library"
5935 if test -z "$old_library" ; then
5936 echo
5937 echo "*** And there doesn't seem to be a static archive available"
5938 echo "*** The link will probably fail, sorry"
5939 else
5940 add="$dir/$old_library"
5942 elif test -n "$old_library"; then
5943 add="$dir/$old_library"
5946 esac
5947 elif test "$hardcode_minus_L" = no; then
5948 case $host in
5949 *-*-sunos*) add_shlibpath="$dir" ;;
5950 esac
5951 add_dir="-L$dir"
5952 add="-l$name"
5953 elif test "$hardcode_shlibpath_var" = no; then
5954 add_shlibpath="$dir"
5955 add="-l$name"
5956 else
5957 lib_linked=no
5960 relink)
5961 if test "$hardcode_direct" = yes &&
5962 test "$hardcode_direct_absolute" = no; then
5963 add="$dir/$linklib"
5964 elif test "$hardcode_minus_L" = yes; then
5965 add_dir="-L$absdir"
5966 # Try looking first in the location we're being installed to.
5967 if test -n "$inst_prefix_dir"; then
5968 case $libdir in
5969 [\\/]*)
5970 add_dir="$add_dir -L$inst_prefix_dir$libdir"
5972 esac
5974 add="-l$name"
5975 elif test "$hardcode_shlibpath_var" = yes; then
5976 add_shlibpath="$dir"
5977 add="-l$name"
5978 else
5979 lib_linked=no
5982 *) lib_linked=no ;;
5983 esac
5985 if test "$lib_linked" != yes; then
5986 func_fatal_configuration "unsupported hardcode properties"
5989 if test -n "$add_shlibpath"; then
5990 case :$compile_shlibpath: in
5991 *":$add_shlibpath:"*) ;;
5992 *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
5993 esac
5995 if test "$linkmode" = prog; then
5996 test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
5997 test -n "$add" && compile_deplibs="$add $compile_deplibs"
5998 else
5999 test -n "$add_dir" && deplibs="$add_dir $deplibs"
6000 test -n "$add" && deplibs="$add $deplibs"
6001 if test "$hardcode_direct" != yes &&
6002 test "$hardcode_minus_L" != yes &&
6003 test "$hardcode_shlibpath_var" = yes; then
6004 case :$finalize_shlibpath: in
6005 *":$libdir:"*) ;;
6006 *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
6007 esac
6012 if test "$linkmode" = prog || test "$mode" = relink; then
6013 add_shlibpath=
6014 add_dir=
6015 add=
6016 # Finalize command for both is simple: just hardcode it.
6017 if test "$hardcode_direct" = yes &&
6018 test "$hardcode_direct_absolute" = no; then
6019 add="$libdir/$linklib"
6020 elif test "$hardcode_minus_L" = yes; then
6021 add_dir="-L$libdir"
6022 add="-l$name"
6023 elif test "$hardcode_shlibpath_var" = yes; then
6024 case :$finalize_shlibpath: in
6025 *":$libdir:"*) ;;
6026 *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
6027 esac
6028 add="-l$name"
6029 elif test "$hardcode_automatic" = yes; then
6030 if test -n "$inst_prefix_dir" &&
6031 test -f "$inst_prefix_dir$libdir/$linklib" ; then
6032 add="$inst_prefix_dir$libdir/$linklib"
6033 else
6034 add="$libdir/$linklib"
6036 else
6037 # We cannot seem to hardcode it, guess we'll fake it.
6038 add_dir="-L$libdir"
6039 # Try looking first in the location we're being installed to.
6040 if test -n "$inst_prefix_dir"; then
6041 case $libdir in
6042 [\\/]*)
6043 add_dir="$add_dir -L$inst_prefix_dir$libdir"
6045 esac
6047 add="-l$name"
6050 if test "$linkmode" = prog; then
6051 test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
6052 test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
6053 else
6054 test -n "$add_dir" && deplibs="$add_dir $deplibs"
6055 test -n "$add" && deplibs="$add $deplibs"
6058 elif test "$linkmode" = prog; then
6059 # Here we assume that one of hardcode_direct or hardcode_minus_L
6060 # is not unsupported. This is valid on all known static and
6061 # shared platforms.
6062 if test "$hardcode_direct" != unsupported; then
6063 test -n "$old_library" && linklib="$old_library"
6064 compile_deplibs="$dir/$linklib $compile_deplibs"
6065 finalize_deplibs="$dir/$linklib $finalize_deplibs"
6066 else
6067 compile_deplibs="-l$name -L$dir $compile_deplibs"
6068 finalize_deplibs="-l$name -L$dir $finalize_deplibs"
6070 elif test "$build_libtool_libs" = yes; then
6071 # Not a shared library
6072 if test "$deplibs_check_method" != pass_all; then
6073 # We're trying link a shared library against a static one
6074 # but the system doesn't support it.
6076 # Just print a warning and add the library to dependency_libs so
6077 # that the program can be linked against the static library.
6078 echo
6079 $ECHO "*** Warning: This system can not link to static lib archive $lib."
6080 echo "*** I have the capability to make that library automatically link in when"
6081 echo "*** you link to this library. But I can only do this if you have a"
6082 echo "*** shared version of the library, which you do not appear to have."
6083 if test "$module" = yes; then
6084 echo "*** But as you try to build a module library, libtool will still create "
6085 echo "*** a static module, that should work as long as the dlopening application"
6086 echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
6087 if test -z "$global_symbol_pipe"; then
6088 echo
6089 echo "*** However, this would only work if libtool was able to extract symbol"
6090 echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
6091 echo "*** not find such a program. So, this module is probably useless."
6092 echo "*** \`nm' from GNU binutils and a full rebuild may help."
6094 if test "$build_old_libs" = no; then
6095 build_libtool_libs=module
6096 build_old_libs=yes
6097 else
6098 build_libtool_libs=no
6101 else
6102 deplibs="$dir/$old_library $deplibs"
6103 link_static=yes
6105 fi # link shared/static library?
6107 if test "$linkmode" = lib; then
6108 if test -n "$dependency_libs" &&
6109 { test "$hardcode_into_libs" != yes ||
6110 test "$build_old_libs" = yes ||
6111 test "$link_static" = yes; }; then
6112 # Extract -R from dependency_libs
6113 temp_deplibs=
6114 for libdir in $dependency_libs; do
6115 case $libdir in
6116 -R*) func_stripname '-R' '' "$libdir"
6117 temp_xrpath=$func_stripname_result
6118 case " $xrpath " in
6119 *" $temp_xrpath "*) ;;
6120 *) xrpath="$xrpath $temp_xrpath";;
6121 esac;;
6122 *) temp_deplibs="$temp_deplibs $libdir";;
6123 esac
6124 done
6125 dependency_libs="$temp_deplibs"
6128 newlib_search_path="$newlib_search_path $absdir"
6129 # Link against this library
6130 test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
6131 # ... and its dependency_libs
6132 tmp_libs=
6133 for deplib in $dependency_libs; do
6134 newdependency_libs="$deplib $newdependency_libs"
6135 if $opt_duplicate_deps ; then
6136 case "$tmp_libs " in
6137 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
6138 esac
6140 tmp_libs="$tmp_libs $deplib"
6141 done
6143 if test "$link_all_deplibs" != no; then
6144 # Add the search paths of all dependency libraries
6145 for deplib in $dependency_libs; do
6146 path=
6147 case $deplib in
6148 -L*) path="$deplib" ;;
6149 *.la)
6150 func_dirname "$deplib" "" "."
6151 dir="$func_dirname_result"
6152 # We need an absolute path.
6153 case $dir in
6154 [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
6156 absdir=`cd "$dir" && pwd`
6157 if test -z "$absdir"; then
6158 func_warning "cannot determine absolute directory name of \`$dir'"
6159 absdir="$dir"
6162 esac
6163 if $GREP "^installed=no" $deplib > /dev/null; then
6164 case $host in
6165 *-*-darwin*)
6166 depdepl=
6167 deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
6168 if test -n "$deplibrary_names" ; then
6169 for tmp in $deplibrary_names ; do
6170 depdepl=$tmp
6171 done
6172 if test -f "$absdir/$objdir/$depdepl" ; then
6173 depdepl="$absdir/$objdir/$depdepl"
6174 darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
6175 if test -z "$darwin_install_name"; then
6176 darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
6178 compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
6179 linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
6180 path=
6185 path="-L$absdir/$objdir"
6187 esac
6188 else
6189 libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
6190 test -z "$libdir" && \
6191 func_fatal_error "\`$deplib' is not a valid libtool archive"
6192 test "$absdir" != "$libdir" && \
6193 func_warning "\`$deplib' seems to be moved"
6195 path="-L$absdir"
6198 esac
6199 case " $deplibs " in
6200 *" $path "*) ;;
6201 *) deplibs="$path $deplibs" ;;
6202 esac
6203 done
6204 fi # link_all_deplibs != no
6205 fi # linkmode = lib
6206 done # for deplib in $libs
6207 if test "$pass" = link; then
6208 if test "$linkmode" = "prog"; then
6209 compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
6210 finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
6211 else
6212 compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
6215 dependency_libs="$newdependency_libs"
6216 if test "$pass" = dlpreopen; then
6217 # Link the dlpreopened libraries before other libraries
6218 for deplib in $save_deplibs; do
6219 deplibs="$deplib $deplibs"
6220 done
6222 if test "$pass" != dlopen; then
6223 if test "$pass" != conv; then
6224 # Make sure lib_search_path contains only unique directories.
6225 lib_search_path=
6226 for dir in $newlib_search_path; do
6227 case "$lib_search_path " in
6228 *" $dir "*) ;;
6229 *) lib_search_path="$lib_search_path $dir" ;;
6230 esac
6231 done
6232 newlib_search_path=
6235 if test "$linkmode,$pass" != "prog,link"; then
6236 vars="deplibs"
6237 else
6238 vars="compile_deplibs finalize_deplibs"
6240 for var in $vars dependency_libs; do
6241 # Add libraries to $var in reverse order
6242 eval tmp_libs=\$$var
6243 new_libs=
6244 for deplib in $tmp_libs; do
6245 # FIXME: Pedantically, this is the right thing to do, so
6246 # that some nasty dependency loop isn't accidentally
6247 # broken:
6248 #new_libs="$deplib $new_libs"
6249 # Pragmatically, this seems to cause very few problems in
6250 # practice:
6251 case $deplib in
6252 -L*) new_libs="$deplib $new_libs" ;;
6253 -R*) ;;
6255 # And here is the reason: when a library appears more
6256 # than once as an explicit dependence of a library, or
6257 # is implicitly linked in more than once by the
6258 # compiler, it is considered special, and multiple
6259 # occurrences thereof are not removed. Compare this
6260 # with having the same library being listed as a
6261 # dependency of multiple other libraries: in this case,
6262 # we know (pedantically, we assume) the library does not
6263 # need to be listed more than once, so we keep only the
6264 # last copy. This is not always right, but it is rare
6265 # enough that we require users that really mean to play
6266 # such unportable linking tricks to link the library
6267 # using -Wl,-lname, so that libtool does not consider it
6268 # for duplicate removal.
6269 case " $specialdeplibs " in
6270 *" $deplib "*) new_libs="$deplib $new_libs" ;;
6272 case " $new_libs " in
6273 *" $deplib "*) ;;
6274 *) new_libs="$deplib $new_libs" ;;
6275 esac
6277 esac
6279 esac
6280 done
6281 tmp_libs=
6282 for deplib in $new_libs; do
6283 case $deplib in
6284 -L*)
6285 case " $tmp_libs " in
6286 *" $deplib "*) ;;
6287 *) tmp_libs="$tmp_libs $deplib" ;;
6288 esac
6290 *) tmp_libs="$tmp_libs $deplib" ;;
6291 esac
6292 done
6293 eval $var=\$tmp_libs
6294 done # for var
6296 # Last step: remove runtime libs from dependency_libs
6297 # (they stay in deplibs)
6298 tmp_libs=
6299 for i in $dependency_libs ; do
6300 case " $predeps $postdeps $compiler_lib_search_path " in
6301 *" $i "*)
6302 i=""
6304 esac
6305 if test -n "$i" ; then
6306 tmp_libs="$tmp_libs $i"
6308 done
6309 dependency_libs=$tmp_libs
6310 done # for pass
6311 if test "$linkmode" = prog; then
6312 dlfiles="$newdlfiles"
6314 if test "$linkmode" = prog || test "$linkmode" = lib; then
6315 dlprefiles="$newdlprefiles"
6318 case $linkmode in
6319 oldlib)
6320 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
6321 func_warning "\`-dlopen' is ignored for archives"
6324 case " $deplibs" in
6325 *\ -l* | *\ -L*)
6326 func_warning "\`-l' and \`-L' are ignored for archives" ;;
6327 esac
6329 test -n "$rpath" && \
6330 func_warning "\`-rpath' is ignored for archives"
6332 test -n "$xrpath" && \
6333 func_warning "\`-R' is ignored for archives"
6335 test -n "$vinfo" && \
6336 func_warning "\`-version-info/-version-number' is ignored for archives"
6338 test -n "$release" && \
6339 func_warning "\`-release' is ignored for archives"
6341 test -n "$export_symbols$export_symbols_regex" && \
6342 func_warning "\`-export-symbols' is ignored for archives"
6344 # Now set the variables for building old libraries.
6345 build_libtool_libs=no
6346 oldlibs="$output"
6347 objs="$objs$old_deplibs"
6350 lib)
6351 # Make sure we only generate libraries of the form `libNAME.la'.
6352 case $outputname in
6353 lib*)
6354 func_stripname 'lib' '.la' "$outputname"
6355 name=$func_stripname_result
6356 eval "shared_ext=\"$shrext_cmds\""
6357 eval "libname=\"$libname_spec\""
6360 test "$module" = no && \
6361 func_fatal_help "libtool library \`$output' must begin with \`lib'"
6363 if test "$need_lib_prefix" != no; then
6364 # Add the "lib" prefix for modules if required
6365 func_stripname '' '.la' "$outputname"
6366 name=$func_stripname_result
6367 eval "shared_ext=\"$shrext_cmds\""
6368 eval "libname=\"$libname_spec\""
6369 else
6370 func_stripname '' '.la' "$outputname"
6371 libname=$func_stripname_result
6374 esac
6376 if test -n "$objs"; then
6377 if test "$deplibs_check_method" != pass_all; then
6378 func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
6379 else
6380 echo
6381 $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
6382 $ECHO "*** objects $objs is not portable!"
6383 libobjs="$libobjs $objs"
6387 test "$dlself" != no && \
6388 func_warning "\`-dlopen self' is ignored for libtool libraries"
6390 set dummy $rpath
6391 shift
6392 test "$#" -gt 1 && \
6393 func_warning "ignoring multiple \`-rpath's for a libtool library"
6395 install_libdir="$1"
6397 oldlibs=
6398 if test -z "$rpath"; then
6399 if test "$build_libtool_libs" = yes; then
6400 # Building a libtool convenience library.
6401 # Some compilers have problems with a `.al' extension so
6402 # convenience libraries should have the same extension an
6403 # archive normally would.
6404 oldlibs="$output_objdir/$libname.$libext $oldlibs"
6405 build_libtool_libs=convenience
6406 build_old_libs=yes
6409 test -n "$vinfo" && \
6410 func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
6412 test -n "$release" && \
6413 func_warning "\`-release' is ignored for convenience libraries"
6414 else
6416 # Parse the version information argument.
6417 save_ifs="$IFS"; IFS=':'
6418 set dummy $vinfo 0 0 0
6419 shift
6420 IFS="$save_ifs"
6422 test -n "$7" && \
6423 func_fatal_help "too many parameters to \`-version-info'"
6425 # convert absolute version numbers to libtool ages
6426 # this retains compatibility with .la files and attempts
6427 # to make the code below a bit more comprehensible
6429 case $vinfo_number in
6430 yes)
6431 number_major="$1"
6432 number_minor="$2"
6433 number_revision="$3"
6435 # There are really only two kinds -- those that
6436 # use the current revision as the major version
6437 # and those that subtract age and use age as
6438 # a minor version. But, then there is irix
6439 # which has an extra 1 added just for fun
6441 case $version_type in
6442 darwin|linux|osf|windows|none)
6443 func_arith $number_major + $number_minor
6444 current=$func_arith_result
6445 age="$number_minor"
6446 revision="$number_revision"
6448 freebsd-aout|freebsd-elf|qnx|sunos)
6449 current="$number_major"
6450 revision="$number_minor"
6451 age="0"
6453 irix|nonstopux)
6454 func_arith $number_major + $number_minor
6455 current=$func_arith_result
6456 age="$number_minor"
6457 revision="$number_minor"
6458 lt_irix_increment=no
6460 esac
6463 current="$1"
6464 revision="$2"
6465 age="$3"
6467 esac
6469 # Check that each of the things are valid numbers.
6470 case $current in
6471 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]) ;;
6473 func_error "CURRENT \`$current' must be a nonnegative integer"
6474 func_fatal_error "\`$vinfo' is not valid version information"
6476 esac
6478 case $revision in
6479 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]) ;;
6481 func_error "REVISION \`$revision' must be a nonnegative integer"
6482 func_fatal_error "\`$vinfo' is not valid version information"
6484 esac
6486 case $age in
6487 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]) ;;
6489 func_error "AGE \`$age' must be a nonnegative integer"
6490 func_fatal_error "\`$vinfo' is not valid version information"
6492 esac
6494 if test "$age" -gt "$current"; then
6495 func_error "AGE \`$age' is greater than the current interface number \`$current'"
6496 func_fatal_error "\`$vinfo' is not valid version information"
6499 # Calculate the version variables.
6500 major=
6501 versuffix=
6502 verstring=
6503 case $version_type in
6504 none) ;;
6506 darwin)
6507 # Like Linux, but with the current version available in
6508 # verstring for coding it into the library header
6509 func_arith $current - $age
6510 major=.$func_arith_result
6511 versuffix="$major.$age.$revision"
6512 # Darwin ld doesn't like 0 for these options...
6513 func_arith $current + 1
6514 minor_current=$func_arith_result
6515 xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
6516 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
6519 freebsd-aout)
6520 major=".$current"
6521 versuffix=".$current.$revision";
6524 freebsd-elf)
6525 major=".$current"
6526 versuffix=".$current"
6529 irix | nonstopux)
6530 if test "X$lt_irix_increment" = "Xno"; then
6531 func_arith $current - $age
6532 else
6533 func_arith $current - $age + 1
6535 major=$func_arith_result
6537 case $version_type in
6538 nonstopux) verstring_prefix=nonstopux ;;
6539 *) verstring_prefix=sgi ;;
6540 esac
6541 verstring="$verstring_prefix$major.$revision"
6543 # Add in all the interfaces that we are compatible with.
6544 loop=$revision
6545 while test "$loop" -ne 0; do
6546 func_arith $revision - $loop
6547 iface=$func_arith_result
6548 func_arith $loop - 1
6549 loop=$func_arith_result
6550 verstring="$verstring_prefix$major.$iface:$verstring"
6551 done
6553 # Before this point, $major must not contain `.'.
6554 major=.$major
6555 versuffix="$major.$revision"
6558 linux)
6559 func_arith $current - $age
6560 major=.$func_arith_result
6561 versuffix="$major.$age.$revision"
6564 osf)
6565 func_arith $current - $age
6566 major=.$func_arith_result
6567 versuffix=".$current.$age.$revision"
6568 verstring="$current.$age.$revision"
6570 # Add in all the interfaces that we are compatible with.
6571 loop=$age
6572 while test "$loop" -ne 0; do
6573 func_arith $current - $loop
6574 iface=$func_arith_result
6575 func_arith $loop - 1
6576 loop=$func_arith_result
6577 verstring="$verstring:${iface}.0"
6578 done
6580 # Make executables depend on our current version.
6581 verstring="$verstring:${current}.0"
6584 qnx)
6585 major=".$current"
6586 versuffix=".$current"
6589 sunos)
6590 major=".$current"
6591 versuffix=".$current.$revision"
6594 windows)
6595 # Use '-' rather than '.', since we only want one
6596 # extension on DOS 8.3 filesystems.
6597 func_arith $current - $age
6598 major=$func_arith_result
6599 versuffix="-$major"
6603 func_fatal_configuration "unknown library version type \`$version_type'"
6605 esac
6607 # Clear the version info if we defaulted, and they specified a release.
6608 if test -z "$vinfo" && test -n "$release"; then
6609 major=
6610 case $version_type in
6611 darwin)
6612 # we can't check for "0.0" in archive_cmds due to quoting
6613 # problems, so we reset it completely
6614 verstring=
6617 verstring="0.0"
6619 esac
6620 if test "$need_version" = no; then
6621 versuffix=
6622 else
6623 versuffix=".0.0"
6627 # Remove version info from name if versioning should be avoided
6628 if test "$avoid_version" = yes && test "$need_version" = no; then
6629 major=
6630 versuffix=
6631 verstring=""
6634 # Check to see if the archive will have undefined symbols.
6635 if test "$allow_undefined" = yes; then
6636 if test "$allow_undefined_flag" = unsupported; then
6637 func_warning "undefined symbols not allowed in $host shared libraries"
6638 build_libtool_libs=no
6639 build_old_libs=yes
6641 else
6642 # Don't allow undefined symbols.
6643 allow_undefined_flag="$no_undefined_flag"
6648 func_generate_dlsyms "$libname" "$libname" "yes"
6649 libobjs="$libobjs $symfileobj"
6650 test "X$libobjs" = "X " && libobjs=
6652 if test "$mode" != relink; then
6653 # Remove our outputs, but don't remove object files since they
6654 # may have been created when compiling PIC objects.
6655 removelist=
6656 tempremovelist=`$ECHO "$output_objdir/*"`
6657 for p in $tempremovelist; do
6658 case $p in
6659 *.$objext | *.gcno)
6661 $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
6662 if test "X$precious_files_regex" != "X"; then
6663 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
6664 then
6665 continue
6668 removelist="$removelist $p"
6670 *) ;;
6671 esac
6672 done
6673 test -n "$removelist" && \
6674 func_show_eval "${RM}r \$removelist"
6677 # Now set the variables for building old libraries.
6678 if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
6679 oldlibs="$oldlibs $output_objdir/$libname.$libext"
6681 # Transform .lo files to .o files.
6682 oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
6685 # Eliminate all temporary directories.
6686 #for path in $notinst_path; do
6687 # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
6688 # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
6689 # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
6690 #done
6692 if test -n "$xrpath"; then
6693 # If the user specified any rpath flags, then add them.
6694 temp_xrpath=
6695 for libdir in $xrpath; do
6696 temp_xrpath="$temp_xrpath -R$libdir"
6697 case "$finalize_rpath " in
6698 *" $libdir "*) ;;
6699 *) finalize_rpath="$finalize_rpath $libdir" ;;
6700 esac
6701 done
6702 if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
6703 dependency_libs="$temp_xrpath $dependency_libs"
6707 # Make sure dlfiles contains only unique files that won't be dlpreopened
6708 old_dlfiles="$dlfiles"
6709 dlfiles=
6710 for lib in $old_dlfiles; do
6711 case " $dlprefiles $dlfiles " in
6712 *" $lib "*) ;;
6713 *) dlfiles="$dlfiles $lib" ;;
6714 esac
6715 done
6717 # Make sure dlprefiles contains only unique files
6718 old_dlprefiles="$dlprefiles"
6719 dlprefiles=
6720 for lib in $old_dlprefiles; do
6721 case "$dlprefiles " in
6722 *" $lib "*) ;;
6723 *) dlprefiles="$dlprefiles $lib" ;;
6724 esac
6725 done
6727 if test "$build_libtool_libs" = yes; then
6728 if test -n "$rpath"; then
6729 case $host in
6730 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
6731 # these systems don't actually have a c library (as such)!
6733 *-*-rhapsody* | *-*-darwin1.[012])
6734 # Rhapsody C library is in the System framework
6735 deplibs="$deplibs System.ltframework"
6737 *-*-netbsd*)
6738 # Don't link with libc until the a.out ld.so is fixed.
6740 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
6741 # Do not include libc due to us having libc/libc_r.
6743 *-*-sco3.2v5* | *-*-sco5v6*)
6744 # Causes problems with __ctype
6746 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
6747 # Compiler inserts libc in the correct place for threads to work
6750 # Add libc to deplibs on all other systems if necessary.
6751 if test "$build_libtool_need_lc" = "yes"; then
6752 deplibs="$deplibs -lc"
6755 esac
6758 # Transform deplibs into only deplibs that can be linked in shared.
6759 name_save=$name
6760 libname_save=$libname
6761 release_save=$release
6762 versuffix_save=$versuffix
6763 major_save=$major
6764 # I'm not sure if I'm treating the release correctly. I think
6765 # release should show up in the -l (ie -lgmp5) so we don't want to
6766 # add it in twice. Is that correct?
6767 release=""
6768 versuffix=""
6769 major=""
6770 newdeplibs=
6771 droppeddeps=no
6772 case $deplibs_check_method in
6773 pass_all)
6774 # Don't check for shared/static. Everything works.
6775 # This might be a little naive. We might want to check
6776 # whether the library exists or not. But this is on
6777 # osf3 & osf4 and I'm not really sure... Just
6778 # implementing what was already the behavior.
6779 newdeplibs=$deplibs
6781 test_compile)
6782 # This code stresses the "libraries are programs" paradigm to its
6783 # limits. Maybe even breaks it. We compile a program, linking it
6784 # against the deplibs as a proxy for the library. Then we can check
6785 # whether they linked in statically or dynamically with ldd.
6786 $opt_dry_run || $RM conftest.c
6787 cat > conftest.c <<EOF
6788 int main() { return 0; }
6790 $opt_dry_run || $RM conftest
6791 if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
6792 ldd_output=`ldd conftest`
6793 for i in $deplibs; do
6794 case $i in
6795 -l*)
6796 func_stripname -l '' "$i"
6797 name=$func_stripname_result
6798 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6799 case " $predeps $postdeps " in
6800 *" $i "*)
6801 newdeplibs="$newdeplibs $i"
6802 i=""
6804 esac
6806 if test -n "$i" ; then
6807 eval "libname=\"$libname_spec\""
6808 eval "deplib_matches=\"$library_names_spec\""
6809 set dummy $deplib_matches; shift
6810 deplib_match=$1
6811 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
6812 newdeplibs="$newdeplibs $i"
6813 else
6814 droppeddeps=yes
6815 echo
6816 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
6817 echo "*** I have the capability to make that library automatically link in when"
6818 echo "*** you link to this library. But I can only do this if you have a"
6819 echo "*** shared version of the library, which I believe you do not have"
6820 echo "*** because a test_compile did reveal that the linker did not use it for"
6821 echo "*** its dynamic dependency list that programs get resolved with at runtime."
6826 newdeplibs="$newdeplibs $i"
6828 esac
6829 done
6830 else
6831 # Error occurred in the first compile. Let's try to salvage
6832 # the situation: Compile a separate program for each library.
6833 for i in $deplibs; do
6834 case $i in
6835 -l*)
6836 func_stripname -l '' "$i"
6837 name=$func_stripname_result
6838 $opt_dry_run || $RM conftest
6839 if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
6840 ldd_output=`ldd conftest`
6841 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6842 case " $predeps $postdeps " in
6843 *" $i "*)
6844 newdeplibs="$newdeplibs $i"
6845 i=""
6847 esac
6849 if test -n "$i" ; then
6850 eval "libname=\"$libname_spec\""
6851 eval "deplib_matches=\"$library_names_spec\""
6852 set dummy $deplib_matches; shift
6853 deplib_match=$1
6854 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
6855 newdeplibs="$newdeplibs $i"
6856 else
6857 droppeddeps=yes
6858 echo
6859 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
6860 echo "*** I have the capability to make that library automatically link in when"
6861 echo "*** you link to this library. But I can only do this if you have a"
6862 echo "*** shared version of the library, which you do not appear to have"
6863 echo "*** because a test_compile did reveal that the linker did not use this one"
6864 echo "*** as a dynamic dependency that programs can get resolved with at runtime."
6867 else
6868 droppeddeps=yes
6869 echo
6870 $ECHO "*** Warning! Library $i is needed by this library but I was not able to"
6871 echo "*** make it link in! You will probably need to install it or some"
6872 echo "*** library that it depends on before this library will be fully"
6873 echo "*** functional. Installing it before continuing would be even better."
6877 newdeplibs="$newdeplibs $i"
6879 esac
6880 done
6883 file_magic*)
6884 set dummy $deplibs_check_method; shift
6885 file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6886 for a_deplib in $deplibs; do
6887 case $a_deplib in
6888 -l*)
6889 func_stripname -l '' "$a_deplib"
6890 name=$func_stripname_result
6891 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6892 case " $predeps $postdeps " in
6893 *" $a_deplib "*)
6894 newdeplibs="$newdeplibs $a_deplib"
6895 a_deplib=""
6897 esac
6899 if test -n "$a_deplib" ; then
6900 eval "libname=\"$libname_spec\""
6901 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
6902 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
6903 for potent_lib in $potential_libs; do
6904 # Follow soft links.
6905 if ls -lLd "$potent_lib" 2>/dev/null |
6906 $GREP " -> " >/dev/null; then
6907 continue
6909 # The statement above tries to avoid entering an
6910 # endless loop below, in case of cyclic links.
6911 # We might still enter an endless loop, since a link
6912 # loop can be closed while we follow links,
6913 # but so what?
6914 potlib="$potent_lib"
6915 while test -h "$potlib" 2>/dev/null; do
6916 potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
6917 case $potliblink in
6918 [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
6919 *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
6920 esac
6921 done
6922 if eval "$file_magic_cmd \"\$potlib\"" 2>/dev/null |
6923 $SED -e 10q |
6924 $EGREP "$file_magic_regex" > /dev/null; then
6925 newdeplibs="$newdeplibs $a_deplib"
6926 a_deplib=""
6927 break 2
6929 done
6930 done
6932 if test -n "$a_deplib" ; then
6933 droppeddeps=yes
6934 echo
6935 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
6936 echo "*** I have the capability to make that library automatically link in when"
6937 echo "*** you link to this library. But I can only do this if you have a"
6938 echo "*** shared version of the library, which you do not appear to have"
6939 echo "*** because I did check the linker path looking for a file starting"
6940 if test -z "$potlib" ; then
6941 $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
6942 else
6943 $ECHO "*** with $libname and none of the candidates passed a file format test"
6944 $ECHO "*** using a file magic. Last file checked: $potlib"
6949 # Add a -L argument.
6950 newdeplibs="$newdeplibs $a_deplib"
6952 esac
6953 done # Gone through all deplibs.
6955 match_pattern*)
6956 set dummy $deplibs_check_method; shift
6957 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6958 for a_deplib in $deplibs; do
6959 case $a_deplib in
6960 -l*)
6961 func_stripname -l '' "$a_deplib"
6962 name=$func_stripname_result
6963 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6964 case " $predeps $postdeps " in
6965 *" $a_deplib "*)
6966 newdeplibs="$newdeplibs $a_deplib"
6967 a_deplib=""
6969 esac
6971 if test -n "$a_deplib" ; then
6972 eval "libname=\"$libname_spec\""
6973 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
6974 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
6975 for potent_lib in $potential_libs; do
6976 potlib="$potent_lib" # see symlink-check above in file_magic test
6977 if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
6978 $EGREP "$match_pattern_regex" > /dev/null; then
6979 newdeplibs="$newdeplibs $a_deplib"
6980 a_deplib=""
6981 break 2
6983 done
6984 done
6986 if test -n "$a_deplib" ; then
6987 droppeddeps=yes
6988 echo
6989 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
6990 echo "*** I have the capability to make that library automatically link in when"
6991 echo "*** you link to this library. But I can only do this if you have a"
6992 echo "*** shared version of the library, which you do not appear to have"
6993 echo "*** because I did check the linker path looking for a file starting"
6994 if test -z "$potlib" ; then
6995 $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
6996 else
6997 $ECHO "*** with $libname and none of the candidates passed a file format test"
6998 $ECHO "*** using a regex pattern. Last file checked: $potlib"
7003 # Add a -L argument.
7004 newdeplibs="$newdeplibs $a_deplib"
7006 esac
7007 done # Gone through all deplibs.
7009 none | unknown | *)
7010 newdeplibs=""
7011 tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
7012 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7013 for i in $predeps $postdeps ; do
7014 # can't use Xsed below, because $i might contain '/'
7015 tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
7016 done
7018 case $tmp_deplibs in
7019 *[!\ \ ]*)
7020 echo
7021 if test "X$deplibs_check_method" = "Xnone"; then
7022 echo "*** Warning: inter-library dependencies are not supported in this platform."
7023 else
7024 echo "*** Warning: inter-library dependencies are not known to be supported."
7026 echo "*** All declared inter-library dependencies are being dropped."
7027 droppeddeps=yes
7029 esac
7031 esac
7032 versuffix=$versuffix_save
7033 major=$major_save
7034 release=$release_save
7035 libname=$libname_save
7036 name=$name_save
7038 case $host in
7039 *-*-rhapsody* | *-*-darwin1.[012])
7040 # On Rhapsody replace the C library with the System framework
7041 newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
7043 esac
7045 if test "$droppeddeps" = yes; then
7046 if test "$module" = yes; then
7047 echo
7048 echo "*** Warning: libtool could not satisfy all declared inter-library"
7049 $ECHO "*** dependencies of module $libname. Therefore, libtool will create"
7050 echo "*** a static module, that should work as long as the dlopening"
7051 echo "*** application is linked with the -dlopen flag."
7052 if test -z "$global_symbol_pipe"; then
7053 echo
7054 echo "*** However, this would only work if libtool was able to extract symbol"
7055 echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
7056 echo "*** not find such a program. So, this module is probably useless."
7057 echo "*** \`nm' from GNU binutils and a full rebuild may help."
7059 if test "$build_old_libs" = no; then
7060 oldlibs="$output_objdir/$libname.$libext"
7061 build_libtool_libs=module
7062 build_old_libs=yes
7063 else
7064 build_libtool_libs=no
7066 else
7067 echo "*** The inter-library dependencies that have been dropped here will be"
7068 echo "*** automatically added whenever a program is linked with this library"
7069 echo "*** or is declared to -dlopen it."
7071 if test "$allow_undefined" = no; then
7072 echo
7073 echo "*** Since this library must not contain undefined symbols,"
7074 echo "*** because either the platform does not support them or"
7075 echo "*** it was explicitly requested with -no-undefined,"
7076 echo "*** libtool will only create a static version of it."
7077 if test "$build_old_libs" = no; then
7078 oldlibs="$output_objdir/$libname.$libext"
7079 build_libtool_libs=module
7080 build_old_libs=yes
7081 else
7082 build_libtool_libs=no
7087 # Done checking deplibs!
7088 deplibs=$newdeplibs
7090 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
7091 case $host in
7092 *-*-darwin*)
7093 newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7094 new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7095 deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7097 esac
7099 # move library search paths that coincide with paths to not yet
7100 # installed libraries to the beginning of the library search list
7101 new_libs=
7102 for path in $notinst_path; do
7103 case " $new_libs " in
7104 *" -L$path/$objdir "*) ;;
7106 case " $deplibs " in
7107 *" -L$path/$objdir "*)
7108 new_libs="$new_libs -L$path/$objdir" ;;
7109 esac
7111 esac
7112 done
7113 for deplib in $deplibs; do
7114 case $deplib in
7115 -L*)
7116 case " $new_libs " in
7117 *" $deplib "*) ;;
7118 *) new_libs="$new_libs $deplib" ;;
7119 esac
7121 *) new_libs="$new_libs $deplib" ;;
7122 esac
7123 done
7124 deplibs="$new_libs"
7126 # All the library-specific variables (install_libdir is set above).
7127 library_names=
7128 old_library=
7129 dlname=
7131 # Test again, we may have decided not to build it any more
7132 if test "$build_libtool_libs" = yes; then
7133 if test "$hardcode_into_libs" = yes; then
7134 # Hardcode the library paths
7135 hardcode_libdirs=
7136 dep_rpath=
7137 rpath="$finalize_rpath"
7138 test "$mode" != relink && rpath="$compile_rpath$rpath"
7139 for libdir in $rpath; do
7140 if test -n "$hardcode_libdir_flag_spec"; then
7141 if test -n "$hardcode_libdir_separator"; then
7142 if test -z "$hardcode_libdirs"; then
7143 hardcode_libdirs="$libdir"
7144 else
7145 # Just accumulate the unique libdirs.
7146 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
7147 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
7150 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
7152 esac
7154 else
7155 eval "flag=\"$hardcode_libdir_flag_spec\""
7156 dep_rpath="$dep_rpath $flag"
7158 elif test -n "$runpath_var"; then
7159 case "$perm_rpath " in
7160 *" $libdir "*) ;;
7161 *) perm_rpath="$perm_rpath $libdir" ;;
7162 esac
7164 done
7165 # Substitute the hardcoded libdirs into the rpath.
7166 if test -n "$hardcode_libdir_separator" &&
7167 test -n "$hardcode_libdirs"; then
7168 libdir="$hardcode_libdirs"
7169 if test -n "$hardcode_libdir_flag_spec_ld"; then
7170 eval "dep_rpath=\"$hardcode_libdir_flag_spec_ld\""
7171 else
7172 eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
7175 if test -n "$runpath_var" && test -n "$perm_rpath"; then
7176 # We should set the runpath_var.
7177 rpath=
7178 for dir in $perm_rpath; do
7179 rpath="$rpath$dir:"
7180 done
7181 eval $runpath_var=\$rpath\$$runpath_var
7182 export $runpath_var
7184 test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
7187 shlibpath="$finalize_shlibpath"
7188 test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
7189 if test -n "$shlibpath"; then
7190 eval $shlibpath_var=\$shlibpath\$$shlibpath_var
7191 export $shlibpath_var
7194 # Get the real and link names of the library.
7195 eval "shared_ext=\"$shrext_cmds\""
7196 eval "library_names=\"$library_names_spec\""
7197 set dummy $library_names
7198 shift
7199 realname="$1"
7200 shift
7202 if test -n "$soname_spec"; then
7203 eval "soname=\"$soname_spec\""
7204 else
7205 soname="$realname"
7207 if test -z "$dlname"; then
7208 dlname=$soname
7211 lib="$output_objdir/$realname"
7212 linknames=
7213 for link
7215 linknames="$linknames $link"
7216 done
7218 # Use standard objects if they are pic
7219 test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
7220 test "X$libobjs" = "X " && libobjs=
7222 delfiles=
7223 if test -n "$export_symbols" && test -n "$include_expsyms"; then
7224 $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
7225 export_symbols="$output_objdir/$libname.uexp"
7226 delfiles="$delfiles $export_symbols"
7229 orig_export_symbols=
7230 case $host_os in
7231 cygwin* | mingw* | cegcc*)
7232 if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
7233 # exporting using user supplied symfile
7234 if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
7235 # and it's NOT already a .def file. Must figure out
7236 # which of the given symbols are data symbols and tag
7237 # them as such. So, trigger use of export_symbols_cmds.
7238 # export_symbols gets reassigned inside the "prepare
7239 # the list of exported symbols" if statement, so the
7240 # include_expsyms logic still works.
7241 orig_export_symbols="$export_symbols"
7242 export_symbols=
7243 always_export_symbols=yes
7247 esac
7249 # Prepare the list of exported symbols
7250 if test -z "$export_symbols"; then
7251 if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
7252 func_verbose "generating symbol list for \`$libname.la'"
7253 export_symbols="$output_objdir/$libname.exp"
7254 $opt_dry_run || $RM $export_symbols
7255 cmds=$export_symbols_cmds
7256 save_ifs="$IFS"; IFS='~'
7257 for cmd in $cmds; do
7258 IFS="$save_ifs"
7259 eval "cmd=\"$cmd\""
7260 func_len " $cmd"
7261 len=$func_len_result
7262 if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
7263 func_show_eval "$cmd" 'exit $?'
7264 skipped_export=false
7265 else
7266 # The command line is too long to execute in one step.
7267 func_verbose "using reloadable object file for export list..."
7268 skipped_export=:
7269 # Break out early, otherwise skipped_export may be
7270 # set to false by a later but shorter cmd.
7271 break
7273 done
7274 IFS="$save_ifs"
7275 if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
7276 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
7277 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
7282 if test -n "$export_symbols" && test -n "$include_expsyms"; then
7283 tmp_export_symbols="$export_symbols"
7284 test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
7285 $opt_dry_run || $ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"
7288 if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
7289 # The given exports_symbols file has to be filtered, so filter it.
7290 func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
7291 # FIXME: $output_objdir/$libname.filter potentially contains lots of
7292 # 's' commands which not all seds can handle. GNU sed should be fine
7293 # though. Also, the filter scales superlinearly with the number of
7294 # global variables. join(1) would be nice here, but unfortunately
7295 # isn't a blessed tool.
7296 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
7297 delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
7298 export_symbols=$output_objdir/$libname.def
7299 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
7302 tmp_deplibs=
7303 for test_deplib in $deplibs; do
7304 case " $convenience " in
7305 *" $test_deplib "*) ;;
7307 tmp_deplibs="$tmp_deplibs $test_deplib"
7309 esac
7310 done
7311 deplibs="$tmp_deplibs"
7313 if test -n "$convenience"; then
7314 if test -n "$whole_archive_flag_spec" &&
7315 test "$compiler_needs_object" = yes &&
7316 test -z "$libobjs"; then
7317 # extract the archives, so we have objects to list.
7318 # TODO: could optimize this to just extract one archive.
7319 whole_archive_flag_spec=
7321 if test -n "$whole_archive_flag_spec"; then
7322 save_libobjs=$libobjs
7323 eval "libobjs=\"\$libobjs $whole_archive_flag_spec\""
7324 test "X$libobjs" = "X " && libobjs=
7325 else
7326 gentop="$output_objdir/${outputname}x"
7327 generated="$generated $gentop"
7329 func_extract_archives $gentop $convenience
7330 libobjs="$libobjs $func_extract_archives_result"
7331 test "X$libobjs" = "X " && libobjs=
7335 if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
7336 eval "flag=\"$thread_safe_flag_spec\""
7337 linker_flags="$linker_flags $flag"
7340 # Make a backup of the uninstalled library when relinking
7341 if test "$mode" = relink; then
7342 $opt_dry_run || (cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U) || exit $?
7345 # Do each of the archive commands.
7346 if test "$module" = yes && test -n "$module_cmds" ; then
7347 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
7348 eval "test_cmds=\"$module_expsym_cmds\""
7349 cmds=$module_expsym_cmds
7350 else
7351 eval "test_cmds=\"$module_cmds\""
7352 cmds=$module_cmds
7354 else
7355 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
7356 eval "test_cmds=\"$archive_expsym_cmds\""
7357 cmds=$archive_expsym_cmds
7358 else
7359 eval "test_cmds=\"$archive_cmds\""
7360 cmds=$archive_cmds
7364 if test "X$skipped_export" != "X:" &&
7365 func_len " $test_cmds" &&
7366 len=$func_len_result &&
7367 test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
7369 else
7370 # The command line is too long to link in one step, link piecewise
7371 # or, if using GNU ld and skipped_export is not :, use a linker
7372 # script.
7374 # Save the value of $output and $libobjs because we want to
7375 # use them later. If we have whole_archive_flag_spec, we
7376 # want to use save_libobjs as it was before
7377 # whole_archive_flag_spec was expanded, because we can't
7378 # assume the linker understands whole_archive_flag_spec.
7379 # This may have to be revisited, in case too many
7380 # convenience libraries get linked in and end up exceeding
7381 # the spec.
7382 if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
7383 save_libobjs=$libobjs
7385 save_output=$output
7386 func_basename "$output"
7387 output_la=$func_basename_result
7389 # Clear the reloadable object creation command queue and
7390 # initialize k to one.
7391 test_cmds=
7392 concat_cmds=
7393 objlist=
7394 last_robj=
7397 if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
7398 output=${output_objdir}/${output_la}.lnkscript
7399 func_verbose "creating GNU ld script: $output"
7400 echo 'INPUT (' > $output
7401 for obj in $save_libobjs
7403 $ECHO "$obj" >> $output
7404 done
7405 echo ')' >> $output
7406 delfiles="$delfiles $output"
7407 elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
7408 output=${output_objdir}/${output_la}.lnk
7409 func_verbose "creating linker input file list: $output"
7410 : > $output
7411 set x $save_libobjs
7412 shift
7413 firstobj=
7414 if test "$compiler_needs_object" = yes; then
7415 firstobj="$1 "
7416 shift
7418 for obj
7420 $ECHO "$obj" >> $output
7421 done
7422 delfiles="$delfiles $output"
7423 output=$firstobj\"$file_list_spec$output\"
7424 else
7425 if test -n "$save_libobjs"; then
7426 func_verbose "creating reloadable object files..."
7427 output=$output_objdir/$output_la-${k}.$objext
7428 eval "test_cmds=\"$reload_cmds\""
7429 func_len " $test_cmds"
7430 len0=$func_len_result
7431 len=$len0
7433 # Loop over the list of objects to be linked.
7434 for obj in $save_libobjs
7436 func_len " $obj"
7437 func_arith $len + $func_len_result
7438 len=$func_arith_result
7439 if test "X$objlist" = X ||
7440 test "$len" -lt "$max_cmd_len"; then
7441 func_append objlist " $obj"
7442 else
7443 # The command $test_cmds is almost too long, add a
7444 # command to the queue.
7445 if test "$k" -eq 1 ; then
7446 # The first file doesn't have a previous command to add.
7447 reload_objs=$objlist
7448 eval "concat_cmds=\"$reload_cmds\""
7449 else
7450 # All subsequent reloadable object files will link in
7451 # the last one created.
7452 reload_objs="$objlist $last_robj"
7453 eval "concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\""
7455 last_robj=$output_objdir/$output_la-${k}.$objext
7456 func_arith $k + 1
7457 k=$func_arith_result
7458 output=$output_objdir/$output_la-${k}.$objext
7459 objlist=" $obj"
7460 func_len " $last_robj"
7461 func_arith $len0 + $func_len_result
7462 len=$func_arith_result
7464 done
7465 # Handle the remaining objects by creating one last
7466 # reloadable object file. All subsequent reloadable object
7467 # files will link in the last one created.
7468 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
7469 reload_objs="$objlist $last_robj"
7470 eval "concat_cmds=\"\${concat_cmds}$reload_cmds\""
7471 if test -n "$last_robj"; then
7472 eval "concat_cmds=\"\${concat_cmds}~\$RM $last_robj\""
7474 delfiles="$delfiles $output"
7476 else
7477 output=
7480 if ${skipped_export-false}; then
7481 func_verbose "generating symbol list for \`$libname.la'"
7482 export_symbols="$output_objdir/$libname.exp"
7483 $opt_dry_run || $RM $export_symbols
7484 libobjs=$output
7485 # Append the command to create the export file.
7486 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
7487 eval "concat_cmds=\"\$concat_cmds$export_symbols_cmds\""
7488 if test -n "$last_robj"; then
7489 eval "concat_cmds=\"\$concat_cmds~\$RM $last_robj\""
7493 test -n "$save_libobjs" &&
7494 func_verbose "creating a temporary reloadable object file: $output"
7496 # Loop through the commands generated above and execute them.
7497 save_ifs="$IFS"; IFS='~'
7498 for cmd in $concat_cmds; do
7499 IFS="$save_ifs"
7500 $opt_silent || {
7501 func_quote_for_expand "$cmd"
7502 eval "func_echo $func_quote_for_expand_result"
7504 $opt_dry_run || eval "$cmd" || {
7505 lt_exit=$?
7507 # Restore the uninstalled library and exit
7508 if test "$mode" = relink; then
7509 ( cd "$output_objdir" && \
7510 $RM "${realname}T" && \
7511 $MV "${realname}U" "$realname" )
7514 exit $lt_exit
7516 done
7517 IFS="$save_ifs"
7519 if test -n "$export_symbols_regex" && ${skipped_export-false}; then
7520 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
7521 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
7525 if ${skipped_export-false}; then
7526 if test -n "$export_symbols" && test -n "$include_expsyms"; then
7527 tmp_export_symbols="$export_symbols"
7528 test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
7529 $opt_dry_run || $ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"
7532 if test -n "$orig_export_symbols"; then
7533 # The given exports_symbols file has to be filtered, so filter it.
7534 func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
7535 # FIXME: $output_objdir/$libname.filter potentially contains lots of
7536 # 's' commands which not all seds can handle. GNU sed should be fine
7537 # though. Also, the filter scales superlinearly with the number of
7538 # global variables. join(1) would be nice here, but unfortunately
7539 # isn't a blessed tool.
7540 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
7541 delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
7542 export_symbols=$output_objdir/$libname.def
7543 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
7547 libobjs=$output
7548 # Restore the value of output.
7549 output=$save_output
7551 if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
7552 eval "libobjs=\"\$libobjs $whole_archive_flag_spec\""
7553 test "X$libobjs" = "X " && libobjs=
7555 # Expand the library linking commands again to reset the
7556 # value of $libobjs for piecewise linking.
7558 # Do each of the archive commands.
7559 if test "$module" = yes && test -n "$module_cmds" ; then
7560 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
7561 cmds=$module_expsym_cmds
7562 else
7563 cmds=$module_cmds
7565 else
7566 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
7567 cmds=$archive_expsym_cmds
7568 else
7569 cmds=$archive_cmds
7574 if test -n "$delfiles"; then
7575 # Append the command to remove temporary files to $cmds.
7576 eval "cmds=\"\$cmds~\$RM $delfiles\""
7579 # Add any objects from preloaded convenience libraries
7580 if test -n "$dlprefiles"; then
7581 gentop="$output_objdir/${outputname}x"
7582 generated="$generated $gentop"
7584 func_extract_archives $gentop $dlprefiles
7585 libobjs="$libobjs $func_extract_archives_result"
7586 test "X$libobjs" = "X " && libobjs=
7589 save_ifs="$IFS"; IFS='~'
7590 for cmd in $cmds; do
7591 IFS="$save_ifs"
7592 eval "cmd=\"$cmd\""
7593 $opt_silent || {
7594 func_quote_for_expand "$cmd"
7595 eval "func_echo $func_quote_for_expand_result"
7597 $opt_dry_run || eval "$cmd" || {
7598 lt_exit=$?
7600 # Restore the uninstalled library and exit
7601 if test "$mode" = relink; then
7602 ( cd "$output_objdir" && \
7603 $RM "${realname}T" && \
7604 $MV "${realname}U" "$realname" )
7607 exit $lt_exit
7609 done
7610 IFS="$save_ifs"
7612 # Restore the uninstalled library and exit
7613 if test "$mode" = relink; then
7614 $opt_dry_run || (cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname) || exit $?
7616 if test -n "$convenience"; then
7617 if test -z "$whole_archive_flag_spec"; then
7618 func_show_eval '${RM}r "$gentop"'
7622 exit $EXIT_SUCCESS
7625 # Create links to the real library.
7626 for linkname in $linknames; do
7627 if test "$realname" != "$linkname"; then
7628 func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
7630 done
7632 # If -module or -export-dynamic was specified, set the dlname.
7633 if test "$module" = yes || test "$export_dynamic" = yes; then
7634 # On all known operating systems, these are identical.
7635 dlname="$soname"
7640 obj)
7641 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
7642 func_warning "\`-dlopen' is ignored for objects"
7645 case " $deplibs" in
7646 *\ -l* | *\ -L*)
7647 func_warning "\`-l' and \`-L' are ignored for objects" ;;
7648 esac
7650 test -n "$rpath" && \
7651 func_warning "\`-rpath' is ignored for objects"
7653 test -n "$xrpath" && \
7654 func_warning "\`-R' is ignored for objects"
7656 test -n "$vinfo" && \
7657 func_warning "\`-version-info' is ignored for objects"
7659 test -n "$release" && \
7660 func_warning "\`-release' is ignored for objects"
7662 case $output in
7663 *.lo)
7664 test -n "$objs$old_deplibs" && \
7665 func_fatal_error "cannot build library object \`$output' from non-libtool objects"
7667 libobj=$output
7668 func_lo2o "$libobj"
7669 obj=$func_lo2o_result
7672 libobj=
7673 obj="$output"
7675 esac
7677 # Delete the old objects.
7678 $opt_dry_run || $RM $obj $libobj
7680 # Objects from convenience libraries. This assumes
7681 # single-version convenience libraries. Whenever we create
7682 # different ones for PIC/non-PIC, this we'll have to duplicate
7683 # the extraction.
7684 reload_conv_objs=
7685 gentop=
7686 # reload_cmds runs $LD directly, so let us get rid of
7687 # -Wl from whole_archive_flag_spec and hope we can get by with
7688 # turning comma into space..
7691 if test -n "$convenience"; then
7692 if test -n "$whole_archive_flag_spec"; then
7693 eval "tmp_whole_archive_flags=\"$whole_archive_flag_spec\""
7694 reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
7695 else
7696 gentop="$output_objdir/${obj}x"
7697 generated="$generated $gentop"
7699 func_extract_archives $gentop $convenience
7700 reload_conv_objs="$reload_objs $func_extract_archives_result"
7704 # Create the old-style object.
7705 reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
7707 output="$obj"
7708 func_execute_cmds "$reload_cmds" 'exit $?'
7710 # Exit if we aren't doing a library object file.
7711 if test -z "$libobj"; then
7712 if test -n "$gentop"; then
7713 func_show_eval '${RM}r "$gentop"'
7716 exit $EXIT_SUCCESS
7719 if test "$build_libtool_libs" != yes; then
7720 if test -n "$gentop"; then
7721 func_show_eval '${RM}r "$gentop"'
7724 # Create an invalid libtool object if no PIC, so that we don't
7725 # accidentally link it into a program.
7726 # $show "echo timestamp > $libobj"
7727 # $opt_dry_run || echo timestamp > $libobj || exit $?
7728 exit $EXIT_SUCCESS
7731 if test -n "$pic_flag" || test "$pic_mode" != default; then
7732 # Only do commands if we really have different PIC objects.
7733 reload_objs="$libobjs $reload_conv_objs"
7734 output="$libobj"
7735 func_execute_cmds "$reload_cmds" 'exit $?'
7738 if test -n "$gentop"; then
7739 func_show_eval '${RM}r "$gentop"'
7742 exit $EXIT_SUCCESS
7745 prog)
7746 case $host in
7747 *cygwin*) func_stripname '' '.exe' "$output"
7748 output=$func_stripname_result.exe;;
7749 esac
7750 test -n "$vinfo" && \
7751 func_warning "\`-version-info' is ignored for programs"
7753 test -n "$release" && \
7754 func_warning "\`-release' is ignored for programs"
7756 test "$preload" = yes \
7757 && test "$dlopen_support" = unknown \
7758 && test "$dlopen_self" = unknown \
7759 && test "$dlopen_self_static" = unknown && \
7760 func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
7762 case $host in
7763 *-*-rhapsody* | *-*-darwin1.[012])
7764 # On Rhapsody replace the C library is the System framework
7765 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
7766 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
7768 esac
7770 case $host in
7771 *-*-darwin*)
7772 # Don't allow lazy linking, it breaks C++ global constructors
7773 # But is supposedly fixed on 10.4 or later (yay!).
7774 if test "$tagname" = CXX ; then
7775 case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
7776 10.[0123])
7777 compile_command="$compile_command ${wl}-bind_at_load"
7778 finalize_command="$finalize_command ${wl}-bind_at_load"
7780 esac
7782 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
7783 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7784 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7786 esac
7789 # move library search paths that coincide with paths to not yet
7790 # installed libraries to the beginning of the library search list
7791 new_libs=
7792 for path in $notinst_path; do
7793 case " $new_libs " in
7794 *" -L$path/$objdir "*) ;;
7796 case " $compile_deplibs " in
7797 *" -L$path/$objdir "*)
7798 new_libs="$new_libs -L$path/$objdir" ;;
7799 esac
7801 esac
7802 done
7803 for deplib in $compile_deplibs; do
7804 case $deplib in
7805 -L*)
7806 case " $new_libs " in
7807 *" $deplib "*) ;;
7808 *) new_libs="$new_libs $deplib" ;;
7809 esac
7811 *) new_libs="$new_libs $deplib" ;;
7812 esac
7813 done
7814 compile_deplibs="$new_libs"
7817 compile_command="$compile_command $compile_deplibs"
7818 finalize_command="$finalize_command $finalize_deplibs"
7820 if test -n "$rpath$xrpath"; then
7821 # If the user specified any rpath flags, then add them.
7822 for libdir in $rpath $xrpath; do
7823 # This is the magic to use -rpath.
7824 case "$finalize_rpath " in
7825 *" $libdir "*) ;;
7826 *) finalize_rpath="$finalize_rpath $libdir" ;;
7827 esac
7828 done
7831 # Now hardcode the library paths
7832 rpath=
7833 hardcode_libdirs=
7834 for libdir in $compile_rpath $finalize_rpath; do
7835 if test -n "$hardcode_libdir_flag_spec"; then
7836 if test -n "$hardcode_libdir_separator"; then
7837 if test -z "$hardcode_libdirs"; then
7838 hardcode_libdirs="$libdir"
7839 else
7840 # Just accumulate the unique libdirs.
7841 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
7842 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
7845 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
7847 esac
7849 else
7850 eval "flag=\"$hardcode_libdir_flag_spec\""
7851 rpath="$rpath $flag"
7853 elif test -n "$runpath_var"; then
7854 case "$perm_rpath " in
7855 *" $libdir "*) ;;
7856 *) perm_rpath="$perm_rpath $libdir" ;;
7857 esac
7859 case $host in
7860 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
7861 testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
7862 case :$dllsearchpath: in
7863 *":$libdir:"*) ;;
7864 ::) dllsearchpath=$libdir;;
7865 *) dllsearchpath="$dllsearchpath:$libdir";;
7866 esac
7867 case :$dllsearchpath: in
7868 *":$testbindir:"*) ;;
7869 ::) dllsearchpath=$testbindir;;
7870 *) dllsearchpath="$dllsearchpath:$testbindir";;
7871 esac
7873 esac
7874 done
7875 # Substitute the hardcoded libdirs into the rpath.
7876 if test -n "$hardcode_libdir_separator" &&
7877 test -n "$hardcode_libdirs"; then
7878 libdir="$hardcode_libdirs"
7879 eval "rpath=\" $hardcode_libdir_flag_spec\""
7881 compile_rpath="$rpath"
7883 rpath=
7884 hardcode_libdirs=
7885 for libdir in $finalize_rpath; do
7886 if test -n "$hardcode_libdir_flag_spec"; then
7887 if test -n "$hardcode_libdir_separator"; then
7888 if test -z "$hardcode_libdirs"; then
7889 hardcode_libdirs="$libdir"
7890 else
7891 # Just accumulate the unique libdirs.
7892 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
7893 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
7896 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
7898 esac
7900 else
7901 eval "flag=\"$hardcode_libdir_flag_spec\""
7902 rpath="$rpath $flag"
7904 elif test -n "$runpath_var"; then
7905 case "$finalize_perm_rpath " in
7906 *" $libdir "*) ;;
7907 *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
7908 esac
7910 done
7911 # Substitute the hardcoded libdirs into the rpath.
7912 if test -n "$hardcode_libdir_separator" &&
7913 test -n "$hardcode_libdirs"; then
7914 libdir="$hardcode_libdirs"
7915 eval "rpath=\" $hardcode_libdir_flag_spec\""
7917 finalize_rpath="$rpath"
7919 if test -n "$libobjs" && test "$build_old_libs" = yes; then
7920 # Transform all the library objects into standard objects.
7921 compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
7922 finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
7925 func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
7927 # template prelinking step
7928 if test -n "$prelink_cmds"; then
7929 func_execute_cmds "$prelink_cmds" 'exit $?'
7932 wrappers_required=yes
7933 case $host in
7934 *cegcc* | *mingw32ce*)
7935 # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
7936 wrappers_required=no
7938 *cygwin* | *mingw* )
7939 if test "$build_libtool_libs" != yes; then
7940 wrappers_required=no
7944 if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
7945 wrappers_required=no
7948 esac
7949 if test "$wrappers_required" = no; then
7950 # Replace the output file specification.
7951 compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
7952 link_command="$compile_command$compile_rpath"
7954 # We have no uninstalled library dependencies, so finalize right now.
7955 exit_status=0
7956 func_show_eval "$link_command" 'exit_status=$?'
7958 # Delete the generated files.
7959 if test -f "$output_objdir/${outputname}S.${objext}"; then
7960 func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
7963 exit $exit_status
7966 if test -n "$compile_shlibpath$finalize_shlibpath"; then
7967 compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
7969 if test -n "$finalize_shlibpath"; then
7970 finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
7973 compile_var=
7974 finalize_var=
7975 if test -n "$runpath_var"; then
7976 if test -n "$perm_rpath"; then
7977 # We should set the runpath_var.
7978 rpath=
7979 for dir in $perm_rpath; do
7980 rpath="$rpath$dir:"
7981 done
7982 compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
7984 if test -n "$finalize_perm_rpath"; then
7985 # We should set the runpath_var.
7986 rpath=
7987 for dir in $finalize_perm_rpath; do
7988 rpath="$rpath$dir:"
7989 done
7990 finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
7994 if test "$no_install" = yes; then
7995 # We don't need to create a wrapper script.
7996 link_command="$compile_var$compile_command$compile_rpath"
7997 # Replace the output file specification.
7998 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
7999 # Delete the old output file.
8000 $opt_dry_run || $RM $output
8001 # Link the executable and exit
8002 func_show_eval "$link_command" 'exit $?'
8003 exit $EXIT_SUCCESS
8006 if test "$hardcode_action" = relink; then
8007 # Fast installation is not supported
8008 link_command="$compile_var$compile_command$compile_rpath"
8009 relink_command="$finalize_var$finalize_command$finalize_rpath"
8011 func_warning "this platform does not like uninstalled shared libraries"
8012 func_warning "\`$output' will be relinked during installation"
8013 else
8014 if test "$fast_install" != no; then
8015 link_command="$finalize_var$compile_command$finalize_rpath"
8016 if test "$fast_install" = yes; then
8017 relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
8018 else
8019 # fast_install is set to needless
8020 relink_command=
8022 else
8023 link_command="$compile_var$compile_command$compile_rpath"
8024 relink_command="$finalize_var$finalize_command$finalize_rpath"
8028 # Replace the output file specification.
8029 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
8031 # Delete the old output files.
8032 $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
8034 func_show_eval "$link_command" 'exit $?'
8036 # Now create the wrapper script.
8037 func_verbose "creating $output"
8039 # Quote the relink command for shipping.
8040 if test -n "$relink_command"; then
8041 # Preserve any variables that may affect compiler behavior
8042 for var in $variables_saved_for_relink; do
8043 if eval test -z \"\${$var+set}\"; then
8044 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
8045 elif eval var_value=\$$var; test -z "$var_value"; then
8046 relink_command="$var=; export $var; $relink_command"
8047 else
8048 func_quote_for_eval "$var_value"
8049 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
8051 done
8052 relink_command="(cd `pwd`; $relink_command)"
8053 relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
8056 # Only actually do things if not in dry run mode.
8057 $opt_dry_run || {
8058 # win32 will think the script is a binary if it has
8059 # a .exe suffix, so we strip it off here.
8060 case $output in
8061 *.exe) func_stripname '' '.exe' "$output"
8062 output=$func_stripname_result ;;
8063 esac
8064 # test for cygwin because mv fails w/o .exe extensions
8065 case $host in
8066 *cygwin*)
8067 exeext=.exe
8068 func_stripname '' '.exe' "$outputname"
8069 outputname=$func_stripname_result ;;
8070 *) exeext= ;;
8071 esac
8072 case $host in
8073 *cygwin* | *mingw* )
8074 func_dirname_and_basename "$output" "" "."
8075 output_name=$func_basename_result
8076 output_path=$func_dirname_result
8077 cwrappersource="$output_path/$objdir/lt-$output_name.c"
8078 cwrapper="$output_path/$output_name.exe"
8079 $RM $cwrappersource $cwrapper
8080 trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
8082 func_emit_cwrapperexe_src > $cwrappersource
8084 # The wrapper executable is built using the $host compiler,
8085 # because it contains $host paths and files. If cross-
8086 # compiling, it, like the target executable, must be
8087 # executed on the $host or under an emulation environment.
8088 $opt_dry_run || {
8089 $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
8090 $STRIP $cwrapper
8093 # Now, create the wrapper script for func_source use:
8094 func_ltwrapper_scriptname $cwrapper
8095 $RM $func_ltwrapper_scriptname_result
8096 trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
8097 $opt_dry_run || {
8098 # note: this script will not be executed, so do not chmod.
8099 if test "x$build" = "x$host" ; then
8100 $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
8101 else
8102 func_emit_wrapper no > $func_ltwrapper_scriptname_result
8107 $RM $output
8108 trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
8110 func_emit_wrapper no > $output
8111 chmod +x $output
8113 esac
8115 exit $EXIT_SUCCESS
8117 esac
8119 # See if we need to build an old-fashioned archive.
8120 for oldlib in $oldlibs; do
8122 if test "$build_libtool_libs" = convenience; then
8123 oldobjs="$libobjs_save $symfileobj"
8124 addlibs="$convenience"
8125 build_libtool_libs=no
8126 else
8127 if test "$build_libtool_libs" = module; then
8128 oldobjs="$libobjs_save"
8129 build_libtool_libs=no
8130 else
8131 oldobjs="$old_deplibs $non_pic_objects"
8132 if test "$preload" = yes && test -f "$symfileobj"; then
8133 oldobjs="$oldobjs $symfileobj"
8136 addlibs="$old_convenience"
8139 if test -n "$addlibs"; then
8140 gentop="$output_objdir/${outputname}x"
8141 generated="$generated $gentop"
8143 func_extract_archives $gentop $addlibs
8144 oldobjs="$oldobjs $func_extract_archives_result"
8147 # Do each command in the archive commands.
8148 if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
8149 cmds=$old_archive_from_new_cmds
8150 else
8152 # Add any objects from preloaded convenience libraries
8153 if test -n "$dlprefiles"; then
8154 gentop="$output_objdir/${outputname}x"
8155 generated="$generated $gentop"
8157 func_extract_archives $gentop $dlprefiles
8158 oldobjs="$oldobjs $func_extract_archives_result"
8161 # POSIX demands no paths to be encoded in archives. We have
8162 # to avoid creating archives with duplicate basenames if we
8163 # might have to extract them afterwards, e.g., when creating a
8164 # static archive out of a convenience library, or when linking
8165 # the entirety of a libtool archive into another (currently
8166 # not supported by libtool).
8167 if (for obj in $oldobjs
8169 func_basename "$obj"
8170 $ECHO "$func_basename_result"
8171 done | sort | sort -uc >/dev/null 2>&1); then
8173 else
8174 echo "copying selected object files to avoid basename conflicts..."
8175 gentop="$output_objdir/${outputname}x"
8176 generated="$generated $gentop"
8177 func_mkdir_p "$gentop"
8178 save_oldobjs=$oldobjs
8179 oldobjs=
8180 counter=1
8181 for obj in $save_oldobjs
8183 func_basename "$obj"
8184 objbase="$func_basename_result"
8185 case " $oldobjs " in
8186 " ") oldobjs=$obj ;;
8187 *[\ /]"$objbase "*)
8188 while :; do
8189 # Make sure we don't pick an alternate name that also
8190 # overlaps.
8191 newobj=lt$counter-$objbase
8192 func_arith $counter + 1
8193 counter=$func_arith_result
8194 case " $oldobjs " in
8195 *[\ /]"$newobj "*) ;;
8196 *) if test ! -f "$gentop/$newobj"; then break; fi ;;
8197 esac
8198 done
8199 func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
8200 oldobjs="$oldobjs $gentop/$newobj"
8202 *) oldobjs="$oldobjs $obj" ;;
8203 esac
8204 done
8206 eval "cmds=\"$old_archive_cmds\""
8208 func_len " $cmds"
8209 len=$func_len_result
8210 if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
8211 cmds=$old_archive_cmds
8212 else
8213 # the command line is too long to link in one step, link in parts
8214 func_verbose "using piecewise archive linking..."
8215 save_RANLIB=$RANLIB
8216 RANLIB=:
8217 objlist=
8218 concat_cmds=
8219 save_oldobjs=$oldobjs
8220 oldobjs=
8221 # Is there a better way of finding the last object in the list?
8222 for obj in $save_oldobjs
8224 last_oldobj=$obj
8225 done
8226 eval "test_cmds=\"$old_archive_cmds\""
8227 func_len " $test_cmds"
8228 len0=$func_len_result
8229 len=$len0
8230 for obj in $save_oldobjs
8232 func_len " $obj"
8233 func_arith $len + $func_len_result
8234 len=$func_arith_result
8235 func_append objlist " $obj"
8236 if test "$len" -lt "$max_cmd_len"; then
8238 else
8239 # the above command should be used before it gets too long
8240 oldobjs=$objlist
8241 if test "$obj" = "$last_oldobj" ; then
8242 RANLIB=$save_RANLIB
8244 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8245 eval "concat_cmds=\"\${concat_cmds}$old_archive_cmds\""
8246 objlist=
8247 len=$len0
8249 done
8250 RANLIB=$save_RANLIB
8251 oldobjs=$objlist
8252 if test "X$oldobjs" = "X" ; then
8253 eval "cmds=\"\$concat_cmds\""
8254 else
8255 eval "cmds=\"\$concat_cmds~\$old_archive_cmds\""
8259 func_execute_cmds "$cmds" 'exit $?'
8260 done
8262 test -n "$generated" && \
8263 func_show_eval "${RM}r$generated"
8265 # Now create the libtool archive.
8266 case $output in
8267 *.la)
8268 old_library=
8269 test "$build_old_libs" = yes && old_library="$libname.$libext"
8270 func_verbose "creating $output"
8272 # Preserve any variables that may affect compiler behavior
8273 for var in $variables_saved_for_relink; do
8274 if eval test -z \"\${$var+set}\"; then
8275 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
8276 elif eval var_value=\$$var; test -z "$var_value"; then
8277 relink_command="$var=; export $var; $relink_command"
8278 else
8279 func_quote_for_eval "$var_value"
8280 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
8282 done
8283 # Quote the link command for shipping.
8284 relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
8285 relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
8286 if test "$hardcode_automatic" = yes ; then
8287 relink_command=
8290 # Only create the output if not a dry run.
8291 $opt_dry_run || {
8292 for installed in no yes; do
8293 if test "$installed" = yes; then
8294 if test -z "$install_libdir"; then
8295 break
8297 output="$output_objdir/$outputname"i
8298 # Replace all uninstalled libtool libraries with the installed ones
8299 newdependency_libs=
8300 for deplib in $dependency_libs; do
8301 case $deplib in
8302 *.la)
8303 func_basename "$deplib"
8304 name="$func_basename_result"
8305 libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
8306 test -z "$libdir" && \
8307 func_fatal_error "\`$deplib' is not a valid libtool archive"
8308 newdependency_libs="$newdependency_libs $libdir/$name"
8310 *) newdependency_libs="$newdependency_libs $deplib" ;;
8311 esac
8312 done
8313 dependency_libs="$newdependency_libs"
8314 newdlfiles=
8316 for lib in $dlfiles; do
8317 case $lib in
8318 *.la)
8319 func_basename "$lib"
8320 name="$func_basename_result"
8321 libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
8322 test -z "$libdir" && \
8323 func_fatal_error "\`$lib' is not a valid libtool archive"
8324 newdlfiles="$newdlfiles $libdir/$name"
8326 *) newdlfiles="$newdlfiles $lib" ;;
8327 esac
8328 done
8329 dlfiles="$newdlfiles"
8330 newdlprefiles=
8331 for lib in $dlprefiles; do
8332 case $lib in
8333 *.la)
8334 # Only pass preopened files to the pseudo-archive (for
8335 # eventual linking with the app. that links it) if we
8336 # didn't already link the preopened objects directly into
8337 # the library:
8338 func_basename "$lib"
8339 name="$func_basename_result"
8340 libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
8341 test -z "$libdir" && \
8342 func_fatal_error "\`$lib' is not a valid libtool archive"
8343 newdlprefiles="$newdlprefiles $libdir/$name"
8345 esac
8346 done
8347 dlprefiles="$newdlprefiles"
8348 else
8349 newdlfiles=
8350 for lib in $dlfiles; do
8351 case $lib in
8352 [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
8353 *) abs=`pwd`"/$lib" ;;
8354 esac
8355 newdlfiles="$newdlfiles $abs"
8356 done
8357 dlfiles="$newdlfiles"
8358 newdlprefiles=
8359 for lib in $dlprefiles; do
8360 case $lib in
8361 [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
8362 *) abs=`pwd`"/$lib" ;;
8363 esac
8364 newdlprefiles="$newdlprefiles $abs"
8365 done
8366 dlprefiles="$newdlprefiles"
8368 $RM $output
8369 # place dlname in correct position for cygwin
8370 # In fact, it would be nice if we could use this code for all target
8371 # systems that can't hard-code library paths into their executables
8372 # and that have no shared library path variable independent of PATH,
8373 # but it turns out we can't easily determine that from inspecting
8374 # libtool variables, so we have to hard-code the OSs to which it
8375 # applies here; at the moment, that means platforms that use the PE
8376 # object format with DLL files. See the long comment at the top of
8377 # tests/bindir.at for full details.
8378 tdlname=$dlname
8379 case $host,$output,$installed,$module,$dlname in
8380 *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
8381 # If a -bindir argument was supplied, place the dll there.
8382 if test "x$bindir" != x ;
8383 then
8384 func_relative_path "$install_libdir" "$bindir"
8385 tdlname=$func_relative_path_result$dlname
8386 else
8387 # Otherwise fall back on heuristic.
8388 tdlname=../bin/$dlname
8391 esac
8392 $ECHO > $output "\
8393 # $outputname - a libtool library file
8394 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
8396 # Please DO NOT delete this file!
8397 # It is necessary for linking the library.
8399 # The name that we can dlopen(3).
8400 dlname='$tdlname'
8402 # Names of this library.
8403 library_names='$library_names'
8405 # The name of the static archive.
8406 old_library='$old_library'
8408 # Linker flags that can not go in dependency_libs.
8409 inherited_linker_flags='$new_inherited_linker_flags'
8411 # Libraries that this one depends upon.
8412 dependency_libs='$dependency_libs'
8414 # Names of additional weak libraries provided by this library
8415 weak_library_names='$weak_libs'
8417 # Version information for $libname.
8418 current=$current
8419 age=$age
8420 revision=$revision
8422 # Is this an already installed library?
8423 installed=$installed
8425 # Should we warn about portability when linking against -modules?
8426 shouldnotlink=$module
8428 # Files to dlopen/dlpreopen
8429 dlopen='$dlfiles'
8430 dlpreopen='$dlprefiles'
8432 # Directory that this library needs to be installed in:
8433 libdir='$install_libdir'"
8434 if test "$installed" = no && test "$need_relink" = yes; then
8435 $ECHO >> $output "\
8436 relink_command=\"$relink_command\""
8438 done
8441 # Do a symbolic link so that the libtool archive can be found in
8442 # LD_LIBRARY_PATH before the program is installed.
8443 func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
8445 esac
8446 exit $EXIT_SUCCESS
8449 { test "$mode" = link || test "$mode" = relink; } &&
8450 func_mode_link ${1+"$@"}
8453 # func_mode_uninstall arg...
8454 func_mode_uninstall ()
8456 $opt_debug
8457 RM="$nonopt"
8458 files=
8459 rmforce=
8460 exit_status=0
8462 # This variable tells wrapper scripts just to set variables rather
8463 # than running their programs.
8464 libtool_install_magic="$magic"
8466 for arg
8468 case $arg in
8469 -f) RM="$RM $arg"; rmforce=yes ;;
8470 -*) RM="$RM $arg" ;;
8471 *) files="$files $arg" ;;
8472 esac
8473 done
8475 test -z "$RM" && \
8476 func_fatal_help "you must specify an RM program"
8478 rmdirs=
8480 origobjdir="$objdir"
8481 for file in $files; do
8482 func_dirname "$file" "" "."
8483 dir="$func_dirname_result"
8484 if test "X$dir" = X.; then
8485 objdir="$origobjdir"
8486 else
8487 objdir="$dir/$origobjdir"
8489 func_basename "$file"
8490 name="$func_basename_result"
8491 test "$mode" = uninstall && objdir="$dir"
8493 # Remember objdir for removal later, being careful to avoid duplicates
8494 if test "$mode" = clean; then
8495 case " $rmdirs " in
8496 *" $objdir "*) ;;
8497 *) rmdirs="$rmdirs $objdir" ;;
8498 esac
8501 # Don't error if the file doesn't exist and rm -f was used.
8502 if { test -L "$file"; } >/dev/null 2>&1 ||
8503 { test -h "$file"; } >/dev/null 2>&1 ||
8504 test -f "$file"; then
8506 elif test -d "$file"; then
8507 exit_status=1
8508 continue
8509 elif test "$rmforce" = yes; then
8510 continue
8513 rmfiles="$file"
8515 case $name in
8516 *.la)
8517 # Possibly a libtool archive, so verify it.
8518 if func_lalib_p "$file"; then
8519 func_source $dir/$name
8521 # Delete the libtool libraries and symlinks.
8522 for n in $library_names; do
8523 rmfiles="$rmfiles $objdir/$n"
8524 done
8525 test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
8527 case "$mode" in
8528 clean)
8529 case " $library_names " in
8530 # " " in the beginning catches empty $dlname
8531 *" $dlname "*) ;;
8532 *) rmfiles="$rmfiles $objdir/$dlname" ;;
8533 esac
8534 test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
8536 uninstall)
8537 if test -n "$library_names"; then
8538 # Do each command in the postuninstall commands.
8539 func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
8542 if test -n "$old_library"; then
8543 # Do each command in the old_postuninstall commands.
8544 func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
8546 # FIXME: should reinstall the best remaining shared library.
8548 esac
8552 *.lo)
8553 # Possibly a libtool object, so verify it.
8554 if func_lalib_p "$file"; then
8556 # Read the .lo file
8557 func_source $dir/$name
8559 # Add PIC object to the list of files to remove.
8560 if test -n "$pic_object" &&
8561 test "$pic_object" != none; then
8562 rmfiles="$rmfiles $dir/$pic_object"
8565 # Add non-PIC object to the list of files to remove.
8566 if test -n "$non_pic_object" &&
8567 test "$non_pic_object" != none; then
8568 rmfiles="$rmfiles $dir/$non_pic_object"
8574 if test "$mode" = clean ; then
8575 noexename=$name
8576 case $file in
8577 *.exe)
8578 func_stripname '' '.exe' "$file"
8579 file=$func_stripname_result
8580 func_stripname '' '.exe' "$name"
8581 noexename=$func_stripname_result
8582 # $file with .exe has already been added to rmfiles,
8583 # add $file without .exe
8584 rmfiles="$rmfiles $file"
8586 esac
8587 # Do a test to see if this is a libtool program.
8588 if func_ltwrapper_p "$file"; then
8589 if func_ltwrapper_executable_p "$file"; then
8590 func_ltwrapper_scriptname "$file"
8591 relink_command=
8592 func_source $func_ltwrapper_scriptname_result
8593 rmfiles="$rmfiles $func_ltwrapper_scriptname_result"
8594 else
8595 relink_command=
8596 func_source $dir/$noexename
8599 # note $name still contains .exe if it was in $file originally
8600 # as does the version of $file that was added into $rmfiles
8601 rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
8602 if test "$fast_install" = yes && test -n "$relink_command"; then
8603 rmfiles="$rmfiles $objdir/lt-$name"
8605 if test "X$noexename" != "X$name" ; then
8606 rmfiles="$rmfiles $objdir/lt-${noexename}.c"
8611 esac
8612 func_show_eval "$RM $rmfiles" 'exit_status=1'
8613 done
8614 objdir="$origobjdir"
8616 # Try to remove the ${objdir}s in the directories where we deleted files
8617 for dir in $rmdirs; do
8618 if test -d "$dir"; then
8619 func_show_eval "rmdir $dir >/dev/null 2>&1"
8621 done
8623 exit $exit_status
8626 { test "$mode" = uninstall || test "$mode" = clean; } &&
8627 func_mode_uninstall ${1+"$@"}
8629 test -z "$mode" && {
8630 help="$generic_help"
8631 func_fatal_help "you must specify a MODE"
8634 test -z "$exec_cmd" && \
8635 func_fatal_help "invalid operation mode \`$mode'"
8637 if test -n "$exec_cmd"; then
8638 eval exec "$exec_cmd"
8639 exit $EXIT_FAILURE
8642 exit $exit_status
8645 # The TAGs below are defined such that we never get into a situation
8646 # in which we disable both kinds of libraries. Given conflicting
8647 # choices, we go for a static library, that is the most portable,
8648 # since we can't tell whether shared libraries were disabled because
8649 # the user asked for that or because the platform doesn't support
8650 # them. This is particularly important on AIX, because we don't
8651 # support having both static and shared libraries enabled at the same
8652 # time on that platform, so we default to a shared-only configuration.
8653 # If a disable-shared tag is given, we'll fallback to a static-only
8654 # configuration. But we'll never go from static-only to shared-only.
8656 # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
8657 build_libtool_libs=no
8658 build_old_libs=yes
8659 # ### END LIBTOOL TAG CONFIG: disable-shared
8661 # ### BEGIN LIBTOOL TAG CONFIG: disable-static
8662 build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
8663 # ### END LIBTOOL TAG CONFIG: disable-static
8665 # Local Variables:
8666 # mode:shell-script
8667 # sh-indentation:2
8668 # End:
8669 # vi:sw=2