blob: 7b6c74fb02367c9a9c484f377f750e6145d72f93 [file] [log] [blame]
mlcreech636a9952008-05-05 22:52:56 +00001# Generated from ltmain.m4sh.
2
3# ltmain.sh (GNU libtool) 2.2.4
4# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
5
6# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc.
7# This is free software; see the source for copying conditions. There is NO
8# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9
10# GNU Libtool is free software; you can redistribute it and/or modify
drh71eb93e2001-09-28 01:34:43 +000011# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation; either version 2 of the License, or
13# (at your option) any later version.
14#
mlcreech636a9952008-05-05 22:52:56 +000015# As a special exception to the GNU General Public License,
16# if you distribute this file as part of a program or library that
17# is built using GNU Libtool, you may include this file under the
18# same distribution terms that you use for the rest of that program.
19#
20# GNU Libtool is distributed in the hope that it will be useful, but
drh71eb93e2001-09-28 01:34:43 +000021# WITHOUT ANY WARRANTY; without even the implied warranty of
22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23# General Public License for more details.
24#
25# You should have received a copy of the GNU General Public License
mlcreech636a9952008-05-05 22:52:56 +000026# along with GNU Libtool; see the file COPYING. If not, a copy
27# can be downloaded from http://www.gnu.org/licenses/gpl.html,
28# or obtained by writing to the Free Software Foundation, Inc.,
29# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
drh71eb93e2001-09-28 01:34:43 +000030
mlcreech636a9952008-05-05 22:52:56 +000031# Usage: $progname [OPTION]... [MODE-ARG]...
32#
33# Provide generalized library-building support services.
34#
35# --config show all configuration variables
36# --debug enable verbose shell tracing
37# -n, --dry-run display commands without modifying any files
38# --features display basic configuration information and exit
39# --mode=MODE use operation mode MODE
40# --preserve-dup-deps don't remove duplicate dependency libraries
41# --quiet, --silent don't print informational messages
42# --tag=TAG use configuration variables from tag TAG
43# -v, --verbose print informational messages (default)
44# --version print version information
45# -h, --help print short or long help message
46#
47# MODE must be one of the following:
48#
49# clean remove files from the build directory
50# compile compile a source file into a libtool object
51# execute automatically set library path, then run a program
52# finish complete the installation of libtool libraries
53# install install libraries or executables
54# link create a library or an executable
55# uninstall remove libraries from an installed directory
56#
57# MODE-ARGS vary depending on the MODE.
58# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
59#
60# When reporting a bug, please describe a test case to reproduce it and
61# include the following information:
62#
63# host-triplet: $host
64# shell: $SHELL
65# compiler: $LTCC
66# compiler flags: $LTCFLAGS
67# linker: $LD (gnu? $with_gnu_ld)
68# $progname: (GNU libtool) 2.2.4
69# automake: $automake_version
70# autoconf: $autoconf_version
71#
72# Report bugs to <bug-libtool@gnu.org>.
73
74PROGRAM=ltmain.sh
75PACKAGE=libtool
76VERSION=2.2.4
77TIMESTAMP=""
78package_revision=1.2976
79
80# Be Bourne compatible
81if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
82 emulate sh
83 NULLCMD=:
84 # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
85 # is contrary to our usage. Disable this feature.
86 alias -g '${1+"$@"}'='"$@"'
87 setopt NO_GLOB_SUBST
88else
89 case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
90fi
91BIN_SH=xpg4; export BIN_SH # for Tru64
92DUALCASE=1; export DUALCASE # for MKS sh
93
94# NLS nuisances: We save the old values to restore during execute mode.
95# Only set LANG and LC_ALL to C if already set.
96# These must not be set unconditionally because not all systems understand
97# e.g. LANG=C (notably SCO).
98lt_user_locale=
99lt_safe_locale=
100for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
101do
102 eval "if test \"\${$lt_var+set}\" = set; then
103 save_$lt_var=\$$lt_var
104 $lt_var=C
105 export $lt_var
106 lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
107 lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
108 fi"
109done
110
111$lt_unset CDPATH
112
113
114
115
116
117: ${CP="cp -f"}
118: ${ECHO="echo"}
119: ${EGREP="/usr/bin/grep -E"}
120: ${FGREP="/usr/bin/grep -F"}
121: ${GREP="/usr/bin/grep"}
122: ${LN_S="ln -s"}
123: ${MAKE="make"}
124: ${MKDIR="mkdir"}
125: ${MV="mv -f"}
126: ${RM="rm -f"}
127: ${SED="/opt/local/bin/gsed"}
128: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
129: ${Xsed="$SED -e 1s/^X//"}
130
131# Global variables:
132EXIT_SUCCESS=0
133EXIT_FAILURE=1
134EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
135EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
136
137exit_status=$EXIT_SUCCESS
138
139# Make sure IFS has a sensible default
140lt_nl='
141'
142IFS=" $lt_nl"
143
144dirname="s,/[^/]*$,,"
145basename="s,^.*/,,"
146
147# func_dirname_and_basename file append nondir_replacement
148# perform func_basename and func_dirname in a single function
149# call:
150# dirname: Compute the dirname of FILE. If nonempty,
151# add APPEND to the result, otherwise set result
152# to NONDIR_REPLACEMENT.
153# value returned in "$func_dirname_result"
154# basename: Compute filename of FILE.
155# value retuned in "$func_basename_result"
156# Implementation must be kept synchronized with func_dirname
157# and func_basename. For efficiency, we do not delegate to
158# those functions but instead duplicate the functionality here.
159func_dirname_and_basename ()
160{
161 # Extract subdirectory from the argument.
162 func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
163 if test "X$func_dirname_result" = "X${1}"; then
164 func_dirname_result="${3}"
165 else
166 func_dirname_result="$func_dirname_result${2}"
167 fi
168 func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
169}
170
171# Generated shell functions inserted here.
vapier7f19c022007-02-17 14:46:31 +0000172
173# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
174# is ksh but when the shell is invoked as "sh" and the current value of
175# the _XPG environment variable is not equal to 1 (one), the special
176# positional parameter $0, within a function call, is the name of the
177# function.
178progpath="$0"
179
vapier7f19c022007-02-17 14:46:31 +0000180# The name of this program:
mlcreech636a9952008-05-05 22:52:56 +0000181# In the unlikely event $progname began with a '-', it would play havoc with
182# func_echo (imagine progname=-n), so we prepend ./ in that case:
183func_dirname_and_basename "$progpath"
184progname=$func_basename_result
185case $progname in
186 -*) progname=./$progname ;;
187esac
vapier7f19c022007-02-17 14:46:31 +0000188
mlcreech636a9952008-05-05 22:52:56 +0000189# Make sure we have an absolute path for reexecution:
190case $progpath in
191 [\\/]*|[A-Za-z]:\\*) ;;
192 *[\\/]*)
193 progdir=$func_dirname_result
194 progdir=`cd "$progdir" && pwd`
195 progpath="$progdir/$progname"
196 ;;
197 *)
198 save_IFS="$IFS"
199 IFS=:
200 for progdir in $PATH; do
201 IFS="$save_IFS"
202 test -x "$progdir/$progname" && break
203 done
204 IFS="$save_IFS"
205 test -n "$progdir" || progdir=`pwd`
206 progpath="$progdir/$progname"
207 ;;
208esac
vapier7f19c022007-02-17 14:46:31 +0000209
mlcreech636a9952008-05-05 22:52:56 +0000210# Sed substitution that helps us do robust quoting. It backslashifies
211# metacharacters that are still active within double-quoted strings.
212Xsed="${SED}"' -e 1s/^X//'
213sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
vapier7f19c022007-02-17 14:46:31 +0000214
mlcreech636a9952008-05-05 22:52:56 +0000215# Same as above, but do not quote variable references.
216double_quote_subst='s/\(["`\\]\)/\\\1/g'
vapier7f19c022007-02-17 14:46:31 +0000217
mlcreech636a9952008-05-05 22:52:56 +0000218# Re-`\' parameter expansions in output of double_quote_subst that were
219# `\'-ed in input to the same. If an odd number of `\' preceded a '$'
220# in input to double_quote_subst, that '$' was protected from expansion.
221# Since each input `\' is now two `\'s, look for any number of runs of
222# four `\'s followed by two `\'s and then a '$'. `\' that '$'.
223bs='\\'
224bs2='\\\\'
225bs4='\\\\\\\\'
226dollar='\$'
227sed_double_backslash="\
228 s/$bs4/&\\
229/g
230 s/^$bs2$dollar/$bs&/
231 s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
232 s/\n//g"
233
234# Standard options:
235opt_dry_run=false
236opt_help=false
237opt_quiet=false
238opt_verbose=false
239opt_warning=:
240
241# func_echo arg...
242# Echo program name prefixed message, along with the current mode
243# name if it has been set yet.
244func_echo ()
245{
246 $ECHO "$progname${mode+: }$mode: $*"
247}
248
249# func_verbose arg...
250# Echo program name prefixed message in verbose mode only.
251func_verbose ()
252{
253 $opt_verbose && func_echo ${1+"$@"}
254
255 # A bug in bash halts the script if the last line of a function
256 # fails when set -e is in force, so we need another command to
257 # work around that:
258 :
259}
260
261# func_error arg...
262# Echo program name prefixed message to standard error.
263func_error ()
264{
265 $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
266}
267
268# func_warning arg...
269# Echo program name prefixed warning message to standard error.
270func_warning ()
271{
272 $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
273
274 # bash bug again:
275 :
276}
277
278# func_fatal_error arg...
279# Echo program name prefixed message to standard error, and exit.
280func_fatal_error ()
281{
282 func_error ${1+"$@"}
283 exit $EXIT_FAILURE
284}
285
286# func_fatal_help arg...
287# Echo program name prefixed message to standard error, followed by
288# a help hint, and exit.
289func_fatal_help ()
290{
291 func_error ${1+"$@"}
292 func_fatal_error "$help"
293}
294help="Try \`$progname --help' for more information." ## default
295
296
297# func_grep expression filename
298# Check whether EXPRESSION matches any line of FILENAME, without output.
299func_grep ()
300{
301 $GREP "$1" "$2" >/dev/null 2>&1
302}
303
304
305# func_mkdir_p directory-path
306# Make sure the entire path to DIRECTORY-PATH is available.
307func_mkdir_p ()
308{
309 my_directory_path="$1"
310 my_dir_list=
311
312 if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
313
314 # Protect directory names starting with `-'
315 case $my_directory_path in
316 -*) my_directory_path="./$my_directory_path" ;;
317 esac
318
319 # While some portion of DIR does not yet exist...
320 while test ! -d "$my_directory_path"; do
321 # ...make a list in topmost first order. Use a colon delimited
322 # list incase some portion of path contains whitespace.
323 my_dir_list="$my_directory_path:$my_dir_list"
324
325 # If the last portion added has no slash in it, the list is done
326 case $my_directory_path in */*) ;; *) break ;; esac
327
328 # ...otherwise throw away the child directory and loop
329 my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"`
330 done
331 my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'`
332
333 save_mkdir_p_IFS="$IFS"; IFS=':'
334 for my_dir in $my_dir_list; do
335 IFS="$save_mkdir_p_IFS"
336 # mkdir can fail with a `File exist' error if two processes
337 # try to create one of the directories concurrently. Don't
338 # stop in that case!
339 $MKDIR "$my_dir" 2>/dev/null || :
340 done
341 IFS="$save_mkdir_p_IFS"
342
343 # Bail out if we (or some other process) failed to create a directory.
344 test -d "$my_directory_path" || \
345 func_fatal_error "Failed to create \`$1'"
346 fi
347}
348
349
350# func_mktempdir [string]
351# Make a temporary directory that won't clash with other running
352# libtool processes, and avoids race conditions if possible. If
353# given, STRING is the basename for that directory.
354func_mktempdir ()
355{
356 my_template="${TMPDIR-/tmp}/${1-$progname}"
357
358 if test "$opt_dry_run" = ":"; then
359 # Return a directory name, but don't create it in dry-run mode
360 my_tmpdir="${my_template}-$$"
361 else
362
363 # If mktemp works, use that first and foremost
364 my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
365
366 if test ! -d "$my_tmpdir"; then
367 # Failing that, at least try and use $RANDOM to avoid a race
368 my_tmpdir="${my_template}-${RANDOM-0}$$"
369
370 save_mktempdir_umask=`umask`
371 umask 0077
372 $MKDIR "$my_tmpdir"
373 umask $save_mktempdir_umask
374 fi
375
376 # If we're not in dry-run mode, bomb out on failure
377 test -d "$my_tmpdir" || \
378 func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
379 fi
380
381 $ECHO "X$my_tmpdir" | $Xsed
382}
383
384
385# func_quote_for_eval arg
386# Aesthetically quote ARG to be evaled later.
387# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
388# is double-quoted, suitable for a subsequent eval, whereas
389# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
390# which are still active within double quotes backslashified.
391func_quote_for_eval ()
392{
393 case $1 in
394 *[\\\`\"\$]*)
395 func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;;
396 *)
397 func_quote_for_eval_unquoted_result="$1" ;;
398 esac
399
400 case $func_quote_for_eval_unquoted_result in
401 # Double-quote args containing shell metacharacters to delay
402 # word splitting, command substitution and and variable
403 # expansion for a subsequent eval.
404 # Many Bourne shells cannot handle close brackets correctly
405 # in scan sets, so we specify it separately.
406 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
407 func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
408 ;;
409 *)
410 func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
411 esac
412}
413
414
415# func_quote_for_expand arg
416# Aesthetically quote ARG to be evaled later; same as above,
417# but do not quote variable references.
418func_quote_for_expand ()
419{
420 case $1 in
421 *[\\\`\"]*)
422 my_arg=`$ECHO "X$1" | $Xsed \
423 -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
424 *)
425 my_arg="$1" ;;
426 esac
427
428 case $my_arg in
429 # Double-quote args containing shell metacharacters to delay
430 # word splitting and command substitution for a subsequent eval.
431 # Many Bourne shells cannot handle close brackets correctly
432 # in scan sets, so we specify it separately.
433 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
434 my_arg="\"$my_arg\""
435 ;;
436 esac
437
438 func_quote_for_expand_result="$my_arg"
439}
440
441
442# func_show_eval cmd [fail_exp]
443# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
444# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
445# is given, then evaluate it.
446func_show_eval ()
447{
448 my_cmd="$1"
449 my_fail_exp="${2-:}"
450
451 ${opt_silent-false} || {
452 func_quote_for_expand "$my_cmd"
453 eval "func_echo $func_quote_for_expand_result"
454 }
455
456 if ${opt_dry_run-false}; then :; else
457 eval "$my_cmd"
458 my_status=$?
459 if test "$my_status" -eq 0; then :; else
460 eval "(exit $my_status); $my_fail_exp"
461 fi
462 fi
463}
464
465
466# func_show_eval_locale cmd [fail_exp]
467# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
468# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
469# is given, then evaluate it. Use the saved locale for evaluation.
470func_show_eval_locale ()
471{
472 my_cmd="$1"
473 my_fail_exp="${2-:}"
474
475 ${opt_silent-false} || {
476 func_quote_for_expand "$my_cmd"
477 eval "func_echo $func_quote_for_expand_result"
478 }
479
480 if ${opt_dry_run-false}; then :; else
481 eval "$lt_user_locale
482 $my_cmd"
483 my_status=$?
484 eval "$lt_safe_locale"
485 if test "$my_status" -eq 0; then :; else
486 eval "(exit $my_status); $my_fail_exp"
487 fi
488 fi
489}
490
491
492
493
494
495# func_version
496# Echo version message to standard output and exit.
497func_version ()
498{
499 $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / {
500 s/^# //
501 s/^# *$//
502 s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
503 p
504 }' < "$progpath"
505 exit $?
506}
507
508# func_usage
509# Echo short help message to standard output and exit.
510func_usage ()
511{
512 $SED -n '/^# Usage:/,/# -h/ {
513 s/^# //
514 s/^# *$//
515 s/\$progname/'$progname'/
516 p
517 }' < "$progpath"
518 $ECHO
519 $ECHO "run \`$progname --help | more' for full usage"
520 exit $?
521}
522
523# func_help
524# Echo long help message to standard output and exit.
525func_help ()
526{
527 $SED -n '/^# Usage:/,/# Report bugs to/ {
528 s/^# //
529 s/^# *$//
530 s*\$progname*'$progname'*
531 s*\$host*'"$host"'*
532 s*\$SHELL*'"$SHELL"'*
533 s*\$LTCC*'"$LTCC"'*
534 s*\$LTCFLAGS*'"$LTCFLAGS"'*
535 s*\$LD*'"$LD"'*
536 s/\$with_gnu_ld/'"$with_gnu_ld"'/
537 s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
538 s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
539 p
540 }' < "$progpath"
541 exit $?
542}
543
544# func_missing_arg argname
545# Echo program name prefixed message to standard error and set global
546# exit_cmd.
547func_missing_arg ()
548{
549 func_error "missing argument for $1"
550 exit_cmd=exit
551}
552
553exit_cmd=:
554
555
556
557
558
559# Check that we have a working $ECHO.
drh71eb93e2001-09-28 01:34:43 +0000560if test "X$1" = X--no-reexec; then
561 # Discard the --no-reexec flag, and continue.
562 shift
563elif test "X$1" = X--fallback-echo; then
564 # Avoid inline document here, it may be left over
565 :
mlcreech636a9952008-05-05 22:52:56 +0000566elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then
567 # Yippee, $ECHO works!
drh71eb93e2001-09-28 01:34:43 +0000568 :
569else
mlcreech636a9952008-05-05 22:52:56 +0000570 # Restart under the correct shell, and then maybe $ECHO will work.
vapier7f19c022007-02-17 14:46:31 +0000571 exec $SHELL "$progpath" --no-reexec ${1+"$@"}
drh71eb93e2001-09-28 01:34:43 +0000572fi
mlcreech636a9952008-05-05 22:52:56 +0000573# Same for EGREP, and just to be sure, do LTCC as well
574if test "x$EGREP" = x ; then
575 EGREP=egrep
576fi
577if test "x$LTCC" = x ; then
578 LTCC=${CC-gcc}
579fi
drh71eb93e2001-09-28 01:34:43 +0000580
581if test "X$1" = X--fallback-echo; then
582 # used as fallback echo
583 shift
584 cat <<EOF
585$*
586EOF
vapier7f19c022007-02-17 14:46:31 +0000587 exit $EXIT_SUCCESS
drh71eb93e2001-09-28 01:34:43 +0000588fi
589
drh71eb93e2001-09-28 01:34:43 +0000590magic="%%%MAGIC variable%%%"
mlcreech636a9952008-05-05 22:52:56 +0000591magic_exe="%%%MAGIC EXE variable%%%"
drh71eb93e2001-09-28 01:34:43 +0000592
593# Global variables.
mlcreech636a9952008-05-05 22:52:56 +0000594# $mode is unset
drh71eb93e2001-09-28 01:34:43 +0000595nonopt=
drh71eb93e2001-09-28 01:34:43 +0000596execute_dlfiles=
vapier7f19c022007-02-17 14:46:31 +0000597preserve_args=
drh71eb93e2001-09-28 01:34:43 +0000598lo2o="s/\\.lo\$/.${objext}/"
599o2lo="s/\\.${objext}\$/.lo/"
mlcreech636a9952008-05-05 22:52:56 +0000600extracted_archives=
601extracted_serial=0
drh71eb93e2001-09-28 01:34:43 +0000602
mlcreech636a9952008-05-05 22:52:56 +0000603opt_dry_run=false
604opt_duplicate_deps=false
605opt_silent=false
606opt_debug=:
vapier7f19c022007-02-17 14:46:31 +0000607
mlcreech636a9952008-05-05 22:52:56 +0000608# If this variable is set in any of the actions, the command in it
609# will be execed at the end. This prevents here-documents from being
610# left over by shells.
611exec_cmd=
a.rottmann964dbb12004-02-26 19:47:42 +0000612
mlcreech636a9952008-05-05 22:52:56 +0000613# func_fatal_configuration arg...
614# Echo program name prefixed message to standard error, followed by
615# a configuration failure hint, and exit.
616func_fatal_configuration ()
vapier7f19c022007-02-17 14:46:31 +0000617{
mlcreech636a9952008-05-05 22:52:56 +0000618 func_error ${1+"$@"}
619 func_error "See the $PACKAGE documentation for more information."
620 func_fatal_error "Fatal configuration error."
vapier7f19c022007-02-17 14:46:31 +0000621}
622
623
mlcreech636a9952008-05-05 22:52:56 +0000624# func_config
625# Display the configuration for all the tags in this script.
626func_config ()
vapier7f19c022007-02-17 14:46:31 +0000627{
mlcreech636a9952008-05-05 22:52:56 +0000628 re_begincf='^# ### BEGIN LIBTOOL'
629 re_endcf='^# ### END LIBTOOL'
630
631 # Default configuration.
632 $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
633
634 # Now print the configurations for the tags.
635 for tagname in $taglist; do
636 $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
637 done
638
639 exit $?
640}
641
642# func_features
643# Display the features supported by this script.
644func_features ()
645{
646 $ECHO "host: $host"
647 if test "$build_libtool_libs" = yes; then
648 $ECHO "enable shared libraries"
649 else
650 $ECHO "disable shared libraries"
a.rottmann964dbb12004-02-26 19:47:42 +0000651 fi
mlcreech636a9952008-05-05 22:52:56 +0000652 if test "$build_old_libs" = yes; then
653 $ECHO "enable static libraries"
654 else
655 $ECHO "disable static libraries"
656 fi
657
658 exit $?
659}
660
661# func_enable_tag tagname
662# Verify that TAGNAME is valid, and either flag an error and exit, or
663# enable the TAGNAME tag. We also add TAGNAME to the global $taglist
664# variable here.
665func_enable_tag ()
666{
667 # Global variable:
668 tagname="$1"
669
670 re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
671 re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
672 sed_extractcf="/$re_begincf/,/$re_endcf/p"
673
674 # Validate tagname.
675 case $tagname in
676 *[!-_A-Za-z0-9,/]*)
677 func_fatal_error "invalid tag name: $tagname"
a.rottmann964dbb12004-02-26 19:47:42 +0000678 ;;
mlcreech636a9952008-05-05 22:52:56 +0000679 esac
680
681 # Don't test for the "default" C tag, as we know it's
682 # there but not specially marked.
683 case $tagname in
684 CC) ;;
685 *)
686 if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
687 taglist="$taglist $tagname"
688
689 # Evaluate the configuration. Be careful to quote the path
690 # and the sed script, to avoid splitting on whitespace, but
691 # also don't use non-portable quotes within backquotes within
692 # quotes we have to do it in 2 steps:
693 extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
694 eval "$extractedcf"
695 else
696 func_error "ignoring unknown tag $tagname"
697 fi
698 ;;
699 esac
700}
701
702# Parse options once, thoroughly. This comes as soon as possible in
703# the script to make things like `libtool --version' happen quickly.
704{
705
706 # Shorthand for --mode=foo, only valid as the first argument
707 case $1 in
708 clean|clea|cle|cl)
709 shift; set dummy --mode clean ${1+"$@"}; shift
710 ;;
711 compile|compil|compi|comp|com|co|c)
712 shift; set dummy --mode compile ${1+"$@"}; shift
713 ;;
714 execute|execut|execu|exec|exe|ex|e)
715 shift; set dummy --mode execute ${1+"$@"}; shift
716 ;;
717 finish|finis|fini|fin|fi|f)
718 shift; set dummy --mode finish ${1+"$@"}; shift
719 ;;
720 install|instal|insta|inst|ins|in|i)
721 shift; set dummy --mode install ${1+"$@"}; shift
722 ;;
723 link|lin|li|l)
724 shift; set dummy --mode link ${1+"$@"}; shift
725 ;;
726 uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
727 shift; set dummy --mode uninstall ${1+"$@"}; shift
a.rottmann964dbb12004-02-26 19:47:42 +0000728 ;;
729 esac
mlcreech636a9952008-05-05 22:52:56 +0000730
731 # Parse non-mode specific arguments:
732 while test "$#" -gt 0; do
733 opt="$1"
734 shift
735
736 case $opt in
737 --config) func_config ;;
738
739 --debug) preserve_args="$preserve_args $opt"
740 func_echo "enabling shell trace mode"
741 opt_debug='set -x'
742 $opt_debug
743 ;;
744
745 -dlopen) test "$#" -eq 0 && func_missing_arg "$opt" && break
746 execute_dlfiles="$execute_dlfiles $1"
747 shift
748 ;;
749
750 --dry-run | -n) opt_dry_run=: ;;
751 --features) func_features ;;
752 --finish) mode="finish" ;;
753
754 --mode) test "$#" -eq 0 && func_missing_arg "$opt" && break
755 case $1 in
756 # Valid mode arguments:
757 clean) ;;
758 compile) ;;
759 execute) ;;
760 finish) ;;
761 install) ;;
762 link) ;;
763 relink) ;;
764 uninstall) ;;
765
766 # Catch anything else as an error
767 *) func_error "invalid argument for $opt"
768 exit_cmd=exit
769 break
770 ;;
771 esac
772
773 mode="$1"
774 shift
775 ;;
776
777 --preserve-dup-deps)
778 opt_duplicate_deps=: ;;
779
780 --quiet|--silent) preserve_args="$preserve_args $opt"
781 opt_silent=:
782 ;;
783
784 --verbose| -v) preserve_args="$preserve_args $opt"
785 opt_silent=false
786 ;;
787
788 --tag) test "$#" -eq 0 && func_missing_arg "$opt" && break
789 preserve_args="$preserve_args $opt $1"
790 func_enable_tag "$1" # tagname is set here
791 shift
792 ;;
793
794 # Separate optargs to long options:
795 -dlopen=*|--mode=*|--tag=*)
796 func_opt_split "$opt"
797 set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
798 shift
799 ;;
800
801 -\?|-h) func_usage ;;
802 --help) opt_help=: ;;
803 --version) func_version ;;
804
805 -*) func_fatal_help "unrecognized option \`$opt'" ;;
806
807 *) nonopt="$opt"
808 break
809 ;;
810 esac
811 done
812
813
814 case $host in
815 *cygwin* | *mingw* | *pw32*)
816 # don't eliminate duplications in $postdeps and $predeps
817 opt_duplicate_compiler_generated_deps=:
818 ;;
819 *)
820 opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
821 ;;
822 esac
823
824 # Having warned about all mis-specified options, bail out if
825 # anything was wrong.
826 $exit_cmd $EXIT_FAILURE
827}
828
829# func_check_version_match
830# Ensure that we are using m4 macros, and libtool script from the same
831# release of libtool.
832func_check_version_match ()
833{
834 if test "$package_revision" != "$macro_revision"; then
835 if test "$VERSION" != "$macro_version"; then
836 if test -z "$macro_version"; then
837 cat >&2 <<_LT_EOF
838$progname: Version mismatch error. This is $PACKAGE $VERSION, but the
839$progname: definition of this LT_INIT comes from an older release.
840$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
841$progname: and run autoconf again.
842_LT_EOF
843 else
844 cat >&2 <<_LT_EOF
845$progname: Version mismatch error. This is $PACKAGE $VERSION, but the
846$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
847$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
848$progname: and run autoconf again.
849_LT_EOF
850 fi
851 else
852 cat >&2 <<_LT_EOF
853$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
854$progname: but the definition of this LT_INIT comes from revision $macro_revision.
855$progname: You should recreate aclocal.m4 with macros from revision $package_revision
856$progname: of $PACKAGE $VERSION and run autoconf again.
857_LT_EOF
858 fi
859
860 exit $EXIT_MISMATCH
861 fi
862}
863
864
865## ----------- ##
866## Main. ##
867## ----------- ##
868
869$opt_help || {
870 # Sanity checks first:
871 func_check_version_match
872
873 if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
874 func_fatal_configuration "not configured to build any kind of library"
875 fi
876
877 test -z "$mode" && func_fatal_error "error: you must specify a MODE."
878
879
880 # Darwin sucks
881 eval std_shrext=\"$shrext_cmds\"
882
883
884 # Only execute mode is allowed to have -dlopen flags.
885 if test -n "$execute_dlfiles" && test "$mode" != execute; then
886 func_error "unrecognized option \`-dlopen'"
887 $ECHO "$help" 1>&2
888 exit $EXIT_FAILURE
889 fi
890
891 # Change the help message to a mode-specific one.
892 generic_help="$help"
893 help="Try \`$progname --help --mode=$mode' for more information."
894}
895
896
897# func_lalib_p file
898# True iff FILE is a libtool `.la' library or `.lo' object file.
899# This function is only a basic sanity check; it will hardly flush out
900# determined imposters.
901func_lalib_p ()
902{
903 $SED -e 4q "$1" 2>/dev/null \
904 | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
905}
906
907# func_lalib_unsafe_p file
908# True iff FILE is a libtool `.la' library or `.lo' object file.
909# This function implements the same check as func_lalib_p without
910# resorting to external programs. To this end, it redirects stdin and
911# closes it afterwards, without saving the original file descriptor.
912# As a safety measure, use it only where a negative result would be
913# fatal anyway. Works if `file' does not exist.
914func_lalib_unsafe_p ()
915{
916 lalib_p=no
917 if test -r "$1" && exec 5<&0 <"$1"; then
918 for lalib_p_l in 1 2 3 4
919 do
920 read lalib_p_line
921 case "$lalib_p_line" in
922 \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
923 esac
924 done
925 exec 0<&5 5<&-
926 fi
927 test "$lalib_p" = yes
928}
929
930# func_ltwrapper_script_p file
931# True iff FILE is a libtool wrapper script
932# This function is only a basic sanity check; it will hardly flush out
933# determined imposters.
934func_ltwrapper_script_p ()
935{
936 func_lalib_p "$1"
937}
938
939# func_ltwrapper_executable_p file
940# True iff FILE is a libtool wrapper executable
941# This function is only a basic sanity check; it will hardly flush out
942# determined imposters.
943func_ltwrapper_executable_p ()
944{
945 func_ltwrapper_exec_suffix=
946 case $1 in
947 *.exe) ;;
948 *) func_ltwrapper_exec_suffix=.exe ;;
949 esac
950 $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
951}
952
953# func_ltwrapper_scriptname file
954# Assumes file is an ltwrapper_executable
955# uses $file to determine the appropriate filename for a
956# temporary ltwrapper_script.
957func_ltwrapper_scriptname ()
958{
959 func_ltwrapper_scriptname_result=""
960 if func_ltwrapper_executable_p "$1"; then
961 func_dirname_and_basename "$1" "" "."
962 func_stripname '' '.exe' "$func_basename_result"
963 func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
964 fi
965}
966
967# func_ltwrapper_p file
968# True iff FILE is a libtool wrapper script or wrapper executable
969# This function is only a basic sanity check; it will hardly flush out
970# determined imposters.
971func_ltwrapper_p ()
972{
973 func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
974}
975
976
977# func_execute_cmds commands fail_cmd
978# Execute tilde-delimited COMMANDS.
979# If FAIL_CMD is given, eval that upon failure.
980# FAIL_CMD may read-access the current command in variable CMD!
981func_execute_cmds ()
982{
983 $opt_debug
984 save_ifs=$IFS; IFS='~'
985 for cmd in $1; do
986 IFS=$save_ifs
987 eval cmd=\"$cmd\"
988 func_show_eval "$cmd" "${2-:}"
989 done
990 IFS=$save_ifs
991}
992
993
994# func_source file
995# Source FILE, adding directory component if necessary.
996# Note that it is not necessary on cygwin/mingw to append a dot to
997# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
998# behavior happens only for exec(3), not for open(2)! Also, sourcing
999# `FILE.' does not work on cygwin managed mounts.
1000func_source ()
1001{
1002 $opt_debug
1003 case $1 in
1004 */* | *\\*) . "$1" ;;
1005 *) . "./$1" ;;
1006 esac
a.rottmann964dbb12004-02-26 19:47:42 +00001007}
1008
vapier7f19c022007-02-17 14:46:31 +00001009
1010# func_infer_tag arg
1011# Infer tagged configuration to use if any are available and
1012# if one wasn't chosen via the "--tag" command line option.
1013# Only attempt this if the compiler in the base compile
1014# command doesn't match the default compiler.
1015# arg is usually of the form 'gcc ...'
1016func_infer_tag ()
1017{
mlcreech636a9952008-05-05 22:52:56 +00001018 $opt_debug
vapier7f19c022007-02-17 14:46:31 +00001019 if test -n "$available_tags" && test -z "$tagname"; then
1020 CC_quoted=
1021 for arg in $CC; do
mlcreech636a9952008-05-05 22:52:56 +00001022 func_quote_for_eval "$arg"
1023 CC_quoted="$CC_quoted $func_quote_for_eval_result"
vapier7f19c022007-02-17 14:46:31 +00001024 done
1025 case $@ in
1026 # Blanks in the command may have been stripped by the calling shell,
1027 # but not from the CC environment variable when configure was run.
mlcreech636a9952008-05-05 22:52:56 +00001028 " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;;
vapier7f19c022007-02-17 14:46:31 +00001029 # Blanks at the start of $base_compile will cause this to fail
1030 # if we don't check for them as well.
1031 *)
1032 for z in $available_tags; do
mlcreech636a9952008-05-05 22:52:56 +00001033 if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
vapier7f19c022007-02-17 14:46:31 +00001034 # Evaluate the configuration.
1035 eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1036 CC_quoted=
1037 for arg in $CC; do
mlcreech636a9952008-05-05 22:52:56 +00001038 # Double-quote args containing other shell metacharacters.
1039 func_quote_for_eval "$arg"
1040 CC_quoted="$CC_quoted $func_quote_for_eval_result"
1041 done
vapier7f19c022007-02-17 14:46:31 +00001042 case "$@ " in
mlcreech636a9952008-05-05 22:52:56 +00001043 " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*)
vapier7f19c022007-02-17 14:46:31 +00001044 # The compiler in the base compile command matches
1045 # the one in the tagged configuration.
1046 # Assume this is the tagged configuration we want.
1047 tagname=$z
1048 break
1049 ;;
1050 esac
1051 fi
1052 done
1053 # If $tagname still isn't set, then no tagged configuration
1054 # was found and let the user know that the "--tag" command
1055 # line option must be used.
1056 if test -z "$tagname"; then
mlcreech636a9952008-05-05 22:52:56 +00001057 func_echo "unable to infer tagged configuration"
1058 func_fatal_error "specify a tag with \`--tag'"
1059# else
1060# func_verbose "using $tagname tagged configuration"
vapier7f19c022007-02-17 14:46:31 +00001061 fi
1062 ;;
1063 esac
1064 fi
1065}
1066
1067
mlcreech636a9952008-05-05 22:52:56 +00001068
1069# func_write_libtool_object output_name pic_name nonpic_name
1070# Create a libtool object file (analogous to a ".la" file),
1071# but don't create it if we're doing a dry run.
1072func_write_libtool_object ()
vapier7f19c022007-02-17 14:46:31 +00001073{
mlcreech636a9952008-05-05 22:52:56 +00001074 write_libobj=${1}
drh71eb93e2001-09-28 01:34:43 +00001075 if test "$build_libtool_libs" = yes; then
mlcreech636a9952008-05-05 22:52:56 +00001076 write_lobj=\'${2}\'
drh71eb93e2001-09-28 01:34:43 +00001077 else
mlcreech636a9952008-05-05 22:52:56 +00001078 write_lobj=none
drh71eb93e2001-09-28 01:34:43 +00001079 fi
mlcreech636a9952008-05-05 22:52:56 +00001080
drh71eb93e2001-09-28 01:34:43 +00001081 if test "$build_old_libs" = yes; then
mlcreech636a9952008-05-05 22:52:56 +00001082 write_oldobj=\'${3}\'
drh71eb93e2001-09-28 01:34:43 +00001083 else
mlcreech636a9952008-05-05 22:52:56 +00001084 write_oldobj=none
drh71eb93e2001-09-28 01:34:43 +00001085 fi
drh71eb93e2001-09-28 01:34:43 +00001086
mlcreech636a9952008-05-05 22:52:56 +00001087 $opt_dry_run || {
1088 cat >${write_libobj}T <<EOF
1089# $write_libobj - a libtool object file
1090# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1091#
1092# Please DO NOT delete this file!
1093# It is necessary for linking the library.
drh71eb93e2001-09-28 01:34:43 +00001094
mlcreech636a9952008-05-05 22:52:56 +00001095# Name of the PIC object.
1096pic_object=$write_lobj
drh71eb93e2001-09-28 01:34:43 +00001097
mlcreech636a9952008-05-05 22:52:56 +00001098# Name of the non-PIC object
1099non_pic_object=$write_oldobj
a.rottmann62507b62003-03-24 09:40:34 +00001100
mlcreech636a9952008-05-05 22:52:56 +00001101EOF
1102 $MV "${write_libobj}T" "${write_libobj}"
1103 }
1104}
a.rottmann964dbb12004-02-26 19:47:42 +00001105
mlcreech636a9952008-05-05 22:52:56 +00001106# func_mode_compile arg...
1107func_mode_compile ()
1108{
1109 $opt_debug
drh71eb93e2001-09-28 01:34:43 +00001110 # Get the compilation command and the source file.
1111 base_compile=
a.rottmann964dbb12004-02-26 19:47:42 +00001112 srcfile="$nonopt" # always keep a non-empty value in "srcfile"
1113 suppress_opt=yes
drh71eb93e2001-09-28 01:34:43 +00001114 suppress_output=
a.rottmann964dbb12004-02-26 19:47:42 +00001115 arg_mode=normal
1116 libobj=
1117 later=
mlcreech636a9952008-05-05 22:52:56 +00001118 pie_flag=
drh71eb93e2001-09-28 01:34:43 +00001119
drh71eb93e2001-09-28 01:34:43 +00001120 for arg
1121 do
vapier7f19c022007-02-17 14:46:31 +00001122 case $arg_mode in
a.rottmann964dbb12004-02-26 19:47:42 +00001123 arg )
1124 # do not "continue". Instead, add this to base_compile
1125 lastarg="$arg"
1126 arg_mode=normal
1127 ;;
drh71eb93e2001-09-28 01:34:43 +00001128
a.rottmann964dbb12004-02-26 19:47:42 +00001129 target )
1130 libobj="$arg"
1131 arg_mode=normal
drh71eb93e2001-09-28 01:34:43 +00001132 continue
1133 ;;
a.rottmann964dbb12004-02-26 19:47:42 +00001134
1135 normal )
1136 # Accept any command-line options.
1137 case $arg in
1138 -o)
mlcreech636a9952008-05-05 22:52:56 +00001139 test -n "$libobj" && \
1140 func_fatal_error "you cannot specify \`-o' more than once"
a.rottmann964dbb12004-02-26 19:47:42 +00001141 arg_mode=target
1142 continue
1143 ;;
1144
mlcreech636a9952008-05-05 22:52:56 +00001145 -pie | -fpie | -fPIE)
1146 pie_flag="$pie_flag $arg"
1147 continue
1148 ;;
1149
1150 -shared | -static | -prefer-pic | -prefer-non-pic)
a.rottmann964dbb12004-02-26 19:47:42 +00001151 later="$later $arg"
1152 continue
1153 ;;
1154
1155 -no-suppress)
1156 suppress_opt=no
1157 continue
1158 ;;
1159
1160 -Xcompiler)
1161 arg_mode=arg # the next one goes into the "base_compile" arg list
1162 continue # The current "srcfile" will either be retained or
1163 ;; # replaced later. I would guess that would be a bug.
1164
1165 -Wc,*)
mlcreech636a9952008-05-05 22:52:56 +00001166 func_stripname '-Wc,' '' "$arg"
1167 args=$func_stripname_result
a.rottmann964dbb12004-02-26 19:47:42 +00001168 lastarg=
1169 save_ifs="$IFS"; IFS=','
mlcreech636a9952008-05-05 22:52:56 +00001170 for arg in $args; do
a.rottmann964dbb12004-02-26 19:47:42 +00001171 IFS="$save_ifs"
mlcreech636a9952008-05-05 22:52:56 +00001172 func_quote_for_eval "$arg"
1173 lastarg="$lastarg $func_quote_for_eval_result"
a.rottmann964dbb12004-02-26 19:47:42 +00001174 done
1175 IFS="$save_ifs"
mlcreech636a9952008-05-05 22:52:56 +00001176 func_stripname ' ' '' "$lastarg"
1177 lastarg=$func_stripname_result
a.rottmann964dbb12004-02-26 19:47:42 +00001178
1179 # Add the arguments to base_compile.
1180 base_compile="$base_compile $lastarg"
1181 continue
1182 ;;
1183
mlcreech636a9952008-05-05 22:52:56 +00001184 *)
a.rottmann964dbb12004-02-26 19:47:42 +00001185 # Accept the current argument as the source file.
1186 # The previous "srcfile" becomes the current argument.
1187 #
1188 lastarg="$srcfile"
1189 srcfile="$arg"
1190 ;;
1191 esac # case $arg
1192 ;;
1193 esac # case $arg_mode
1194
1195 # Aesthetically quote the previous argument.
mlcreech636a9952008-05-05 22:52:56 +00001196 func_quote_for_eval "$lastarg"
1197 base_compile="$base_compile $func_quote_for_eval_result"
a.rottmann964dbb12004-02-26 19:47:42 +00001198 done # for arg
drh71eb93e2001-09-28 01:34:43 +00001199
a.rottmann964dbb12004-02-26 19:47:42 +00001200 case $arg_mode in
1201 arg)
mlcreech636a9952008-05-05 22:52:56 +00001202 func_fatal_error "you must specify an argument for -Xcompile"
a.rottmann964dbb12004-02-26 19:47:42 +00001203 ;;
1204 target)
mlcreech636a9952008-05-05 22:52:56 +00001205 func_fatal_error "you must specify a target with \`-o'"
a.rottmann964dbb12004-02-26 19:47:42 +00001206 ;;
1207 *)
1208 # Get the name of the library object.
mlcreech636a9952008-05-05 22:52:56 +00001209 test -z "$libobj" && {
1210 func_basename "$srcfile"
1211 libobj="$func_basename_result"
1212 }
a.rottmann964dbb12004-02-26 19:47:42 +00001213 ;;
1214 esac
1215
1216 # Recognize several different file suffixes.
1217 # If the user specifies -o file.o, it is replaced with file.lo
a.rottmann964dbb12004-02-26 19:47:42 +00001218 case $libobj in
mlcreech636a9952008-05-05 22:52:56 +00001219 *.[cCFSifmso] | \
1220 *.ada | *.adb | *.ads | *.asm | \
1221 *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
1222 *.[fF][09]? | *.for | *.java | *.obj | *.sx)
1223 func_xform "$libobj"
1224 libobj=$func_xform_result
1225 ;;
a.rottmann964dbb12004-02-26 19:47:42 +00001226 esac
1227
a.rottmann964dbb12004-02-26 19:47:42 +00001228 case $libobj in
mlcreech636a9952008-05-05 22:52:56 +00001229 *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
a.rottmann964dbb12004-02-26 19:47:42 +00001230 *)
mlcreech636a9952008-05-05 22:52:56 +00001231 func_fatal_error "cannot determine name of library object from \`$libobj'"
a.rottmann964dbb12004-02-26 19:47:42 +00001232 ;;
1233 esac
1234
vapier7f19c022007-02-17 14:46:31 +00001235 func_infer_tag $base_compile
a.rottmann964dbb12004-02-26 19:47:42 +00001236
1237 for arg in $later; do
1238 case $arg in
mlcreech636a9952008-05-05 22:52:56 +00001239 -shared)
1240 test "$build_libtool_libs" != yes && \
1241 func_fatal_configuration "can not build a shared library"
1242 build_old_libs=no
1243 continue
1244 ;;
1245
drh71eb93e2001-09-28 01:34:43 +00001246 -static)
mlcreech636a9952008-05-05 22:52:56 +00001247 build_libtool_libs=no
drh71eb93e2001-09-28 01:34:43 +00001248 build_old_libs=yes
1249 continue
1250 ;;
1251
1252 -prefer-pic)
1253 pic_mode=yes
1254 continue
1255 ;;
1256
1257 -prefer-non-pic)
1258 pic_mode=no
1259 continue
1260 ;;
drh71eb93e2001-09-28 01:34:43 +00001261 esac
drh71eb93e2001-09-28 01:34:43 +00001262 done
1263
mlcreech636a9952008-05-05 22:52:56 +00001264 func_quote_for_eval "$libobj"
1265 test "X$libobj" != "X$func_quote_for_eval_result" \
1266 && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
1267 && func_warning "libobj name \`$libobj' may not contain shell special characters."
1268 func_dirname_and_basename "$obj" "/" ""
1269 objname="$func_basename_result"
1270 xdir="$func_dirname_result"
a.rottmann964dbb12004-02-26 19:47:42 +00001271 lobj=${xdir}$objdir/$objname
drh71eb93e2001-09-28 01:34:43 +00001272
mlcreech636a9952008-05-05 22:52:56 +00001273 test -z "$base_compile" && \
1274 func_fatal_help "you must specify a compilation command"
drh71eb93e2001-09-28 01:34:43 +00001275
1276 # Delete any leftover library objects.
1277 if test "$build_old_libs" = yes; then
a.rottmann964dbb12004-02-26 19:47:42 +00001278 removelist="$obj $lobj $libobj ${libobj}T"
drh71eb93e2001-09-28 01:34:43 +00001279 else
a.rottmann964dbb12004-02-26 19:47:42 +00001280 removelist="$lobj $libobj ${libobj}T"
drh71eb93e2001-09-28 01:34:43 +00001281 fi
1282
drh71eb93e2001-09-28 01:34:43 +00001283 # On Cygwin there's no "real" PIC flag so we must build both object types
1284 case $host_os in
1285 cygwin* | mingw* | pw32* | os2*)
1286 pic_mode=default
1287 ;;
1288 esac
1289 if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
1290 # non-PIC code in shared libraries is not supported
1291 pic_mode=default
1292 fi
1293
1294 # Calculate the filename of the output object if compiler does
1295 # not support -o with -c
1296 if test "$compiler_c_o" = no; then
mlcreech636a9952008-05-05 22:52:56 +00001297 output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
drh71eb93e2001-09-28 01:34:43 +00001298 lockfile="$output_obj.lock"
drh71eb93e2001-09-28 01:34:43 +00001299 else
a.rottmann964dbb12004-02-26 19:47:42 +00001300 output_obj=
drh71eb93e2001-09-28 01:34:43 +00001301 need_locks=no
1302 lockfile=
1303 fi
1304
1305 # Lock this critical section if it is needed
1306 # We use this script file to make the link, it avoids creating a new file
1307 if test "$need_locks" = yes; then
mlcreech636a9952008-05-05 22:52:56 +00001308 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
1309 func_echo "Waiting for $lockfile to be removed"
drh71eb93e2001-09-28 01:34:43 +00001310 sleep 2
1311 done
1312 elif test "$need_locks" = warn; then
1313 if test -f "$lockfile"; then
mlcreech636a9952008-05-05 22:52:56 +00001314 $ECHO "\
drh71eb93e2001-09-28 01:34:43 +00001315*** ERROR, $lockfile exists and contains:
1316`cat $lockfile 2>/dev/null`
1317
1318This indicates that another process is trying to use the same
1319temporary object file, and libtool could not work around it because
1320your compiler does not support \`-c' and \`-o' together. If you
1321repeat this compilation, it may succeed, by chance, but you had better
1322avoid parallel builds (make -j) in this platform, or get a better
1323compiler."
1324
mlcreech636a9952008-05-05 22:52:56 +00001325 $opt_dry_run || $RM $removelist
vapier7f19c022007-02-17 14:46:31 +00001326 exit $EXIT_FAILURE
drh71eb93e2001-09-28 01:34:43 +00001327 fi
mlcreech636a9952008-05-05 22:52:56 +00001328 removelist="$removelist $output_obj"
1329 $ECHO "$srcfile" > "$lockfile"
drh71eb93e2001-09-28 01:34:43 +00001330 fi
1331
mlcreech636a9952008-05-05 22:52:56 +00001332 $opt_dry_run || $RM $removelist
1333 removelist="$removelist $lockfile"
1334 trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
1335
drh71eb93e2001-09-28 01:34:43 +00001336 if test -n "$fix_srcfile_path"; then
1337 eval srcfile=\"$fix_srcfile_path\"
1338 fi
mlcreech636a9952008-05-05 22:52:56 +00001339 func_quote_for_eval "$srcfile"
1340 qsrcfile=$func_quote_for_eval_result
a.rottmann964dbb12004-02-26 19:47:42 +00001341
drh71eb93e2001-09-28 01:34:43 +00001342 # Only build a PIC object if we are building libtool libraries.
1343 if test "$build_libtool_libs" = yes; then
1344 # Without this assignment, base_compile gets emptied.
1345 fbsd_hideous_sh_bug=$base_compile
1346
1347 if test "$pic_mode" != no; then
vapier7f19c022007-02-17 14:46:31 +00001348 command="$base_compile $qsrcfile $pic_flag"
drh71eb93e2001-09-28 01:34:43 +00001349 else
1350 # Don't build PIC code
vapier7f19c022007-02-17 14:46:31 +00001351 command="$base_compile $qsrcfile"
drh71eb93e2001-09-28 01:34:43 +00001352 fi
1353
mlcreech636a9952008-05-05 22:52:56 +00001354 func_mkdir_p "$xdir$objdir"
a.rottmann964dbb12004-02-26 19:47:42 +00001355
1356 if test -z "$output_obj"; then
1357 # Place PIC objects in $objdir
1358 command="$command -o $lobj"
drh71eb93e2001-09-28 01:34:43 +00001359 fi
1360
mlcreech636a9952008-05-05 22:52:56 +00001361 func_show_eval_locale "$command" \
1362 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
drh71eb93e2001-09-28 01:34:43 +00001363
1364 if test "$need_locks" = warn &&
a.rottmann964dbb12004-02-26 19:47:42 +00001365 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
mlcreech636a9952008-05-05 22:52:56 +00001366 $ECHO "\
drh71eb93e2001-09-28 01:34:43 +00001367*** ERROR, $lockfile contains:
1368`cat $lockfile 2>/dev/null`
1369
1370but it should contain:
1371$srcfile
1372
1373This indicates that another process is trying to use the same
1374temporary object file, and libtool could not work around it because
1375your compiler does not support \`-c' and \`-o' together. If you
1376repeat this compilation, it may succeed, by chance, but you had better
1377avoid parallel builds (make -j) in this platform, or get a better
1378compiler."
1379
mlcreech636a9952008-05-05 22:52:56 +00001380 $opt_dry_run || $RM $removelist
vapier7f19c022007-02-17 14:46:31 +00001381 exit $EXIT_FAILURE
drh71eb93e2001-09-28 01:34:43 +00001382 fi
1383
1384 # Just move the object if needed, then go on to compile the next one
a.rottmann964dbb12004-02-26 19:47:42 +00001385 if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
mlcreech636a9952008-05-05 22:52:56 +00001386 func_show_eval '$MV "$output_obj" "$lobj"' \
1387 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
drh71eb93e2001-09-28 01:34:43 +00001388 fi
1389
drh71eb93e2001-09-28 01:34:43 +00001390 # Allow error messages only from the first compilation.
a.rottmann964dbb12004-02-26 19:47:42 +00001391 if test "$suppress_opt" = yes; then
mlcreech636a9952008-05-05 22:52:56 +00001392 suppress_output=' >/dev/null 2>&1'
a.rottmann964dbb12004-02-26 19:47:42 +00001393 fi
drh71eb93e2001-09-28 01:34:43 +00001394 fi
1395
1396 # Only build a position-dependent object if we build old libraries.
1397 if test "$build_old_libs" = yes; then
1398 if test "$pic_mode" != yes; then
1399 # Don't build PIC code
mlcreech636a9952008-05-05 22:52:56 +00001400 command="$base_compile $qsrcfile$pie_flag"
drh71eb93e2001-09-28 01:34:43 +00001401 else
vapier7f19c022007-02-17 14:46:31 +00001402 command="$base_compile $qsrcfile $pic_flag"
drh71eb93e2001-09-28 01:34:43 +00001403 fi
1404 if test "$compiler_c_o" = yes; then
1405 command="$command -o $obj"
1406 fi
1407
1408 # Suppress compiler output if we already did a PIC compilation.
1409 command="$command$suppress_output"
mlcreech636a9952008-05-05 22:52:56 +00001410 func_show_eval_locale "$command" \
1411 '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
drh71eb93e2001-09-28 01:34:43 +00001412
1413 if test "$need_locks" = warn &&
a.rottmann964dbb12004-02-26 19:47:42 +00001414 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
mlcreech636a9952008-05-05 22:52:56 +00001415 $ECHO "\
drh71eb93e2001-09-28 01:34:43 +00001416*** ERROR, $lockfile contains:
1417`cat $lockfile 2>/dev/null`
1418
1419but it should contain:
1420$srcfile
1421
1422This indicates that another process is trying to use the same
1423temporary object file, and libtool could not work around it because
1424your compiler does not support \`-c' and \`-o' together. If you
1425repeat this compilation, it may succeed, by chance, but you had better
1426avoid parallel builds (make -j) in this platform, or get a better
1427compiler."
1428
mlcreech636a9952008-05-05 22:52:56 +00001429 $opt_dry_run || $RM $removelist
vapier7f19c022007-02-17 14:46:31 +00001430 exit $EXIT_FAILURE
drh71eb93e2001-09-28 01:34:43 +00001431 fi
1432
1433 # Just move the object if needed
a.rottmann964dbb12004-02-26 19:47:42 +00001434 if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
mlcreech636a9952008-05-05 22:52:56 +00001435 func_show_eval '$MV "$output_obj" "$obj"' \
1436 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
drh71eb93e2001-09-28 01:34:43 +00001437 fi
drh71eb93e2001-09-28 01:34:43 +00001438 fi
1439
mlcreech636a9952008-05-05 22:52:56 +00001440 $opt_dry_run || {
1441 func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
a.rottmann964dbb12004-02-26 19:47:42 +00001442
mlcreech636a9952008-05-05 22:52:56 +00001443 # Unlock the critical section if it was locked
1444 if test "$need_locks" != no; then
1445 removelist=$lockfile
1446 $RM "$lockfile"
1447 fi
1448 }
drh71eb93e2001-09-28 01:34:43 +00001449
vapier7f19c022007-02-17 14:46:31 +00001450 exit $EXIT_SUCCESS
mlcreech636a9952008-05-05 22:52:56 +00001451}
drh71eb93e2001-09-28 01:34:43 +00001452
mlcreech636a9952008-05-05 22:52:56 +00001453$opt_help || {
1454test "$mode" = compile && func_mode_compile ${1+"$@"}
1455}
1456
1457func_mode_help ()
1458{
1459 # We need to display help for each of the modes.
1460 case $mode in
1461 "")
1462 # Generic help is extracted from the usage comments
1463 # at the start of this file.
1464 func_help
1465 ;;
1466
1467 clean)
1468 $ECHO \
1469"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
1470
1471Remove files from the build directory.
1472
1473RM is the name of the program to use to delete files associated with each FILE
1474(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
1475to RM.
1476
1477If FILE is a libtool library, object or program, all the files associated
1478with it are deleted. Otherwise, only FILE itself is deleted using RM."
1479 ;;
1480
1481 compile)
1482 $ECHO \
1483"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
1484
1485Compile a source file into a libtool library object.
1486
1487This mode accepts the following additional options:
1488
1489 -o OUTPUT-FILE set the output file name to OUTPUT-FILE
1490 -no-suppress do not suppress compiler output for multiple passes
1491 -prefer-pic try to building PIC objects only
1492 -prefer-non-pic try to building non-PIC objects only
1493 -shared do not build a \`.o' file suitable for static linking
1494 -static only build a \`.o' file suitable for static linking
1495
1496COMPILE-COMMAND is a command to be used in creating a \`standard' object file
1497from the given SOURCEFILE.
1498
1499The output file name is determined by removing the directory component from
1500SOURCEFILE, then substituting the C source code suffix \`.c' with the
1501library object suffix, \`.lo'."
1502 ;;
1503
1504 execute)
1505 $ECHO \
1506"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
1507
1508Automatically set library path, then run a program.
1509
1510This mode accepts the following additional options:
1511
1512 -dlopen FILE add the directory containing FILE to the library path
1513
1514This mode sets the library path environment variable according to \`-dlopen'
1515flags.
1516
1517If any of the ARGS are libtool executable wrappers, then they are translated
1518into their corresponding uninstalled binary, and any of their required library
1519directories are added to the library path.
1520
1521Then, COMMAND is executed, with ARGS as arguments."
1522 ;;
1523
1524 finish)
1525 $ECHO \
1526"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
1527
1528Complete the installation of libtool libraries.
1529
1530Each LIBDIR is a directory that contains libtool libraries.
1531
1532The commands that this mode executes may require superuser privileges. Use
1533the \`--dry-run' option if you just want to see what would be executed."
1534 ;;
1535
1536 install)
1537 $ECHO \
1538"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
1539
1540Install executables or libraries.
1541
1542INSTALL-COMMAND is the installation command. The first component should be
1543either the \`install' or \`cp' program.
1544
1545The following components of INSTALL-COMMAND are treated specially:
1546
1547 -inst-prefix PREFIX-DIR Use PREFIX-DIR as a staging area for installation
1548
1549The rest of the components are interpreted as arguments to that command (only
1550BSD-compatible install options are recognized)."
1551 ;;
1552
1553 link)
1554 $ECHO \
1555"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
1556
1557Link object files or libraries together to form another library, or to
1558create an executable program.
1559
1560LINK-COMMAND is a command using the C compiler that you would use to create
1561a program from several object files.
1562
1563The following components of LINK-COMMAND are treated specially:
1564
1565 -all-static do not do any dynamic linking at all
1566 -avoid-version do not add a version suffix if possible
1567 -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime
1568 -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
1569 -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
1570 -export-symbols SYMFILE
1571 try to export only the symbols listed in SYMFILE
1572 -export-symbols-regex REGEX
1573 try to export only the symbols matching REGEX
1574 -LLIBDIR search LIBDIR for required installed libraries
1575 -lNAME OUTPUT-FILE requires the installed library libNAME
1576 -module build a library that can dlopened
1577 -no-fast-install disable the fast-install mode
1578 -no-install link a not-installable executable
1579 -no-undefined declare that a library does not refer to external symbols
1580 -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
1581 -objectlist FILE Use a list of object files found in FILE to specify objects
1582 -precious-files-regex REGEX
1583 don't remove output files matching REGEX
1584 -release RELEASE specify package release information
1585 -rpath LIBDIR the created library will eventually be installed in LIBDIR
1586 -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
1587 -shared only do dynamic linking of libtool libraries
1588 -shrext SUFFIX override the standard shared library file extension
1589 -static do not do any dynamic linking of uninstalled libtool libraries
1590 -static-libtool-libs
1591 do not do any dynamic linking of libtool libraries
1592 -version-info CURRENT[:REVISION[:AGE]]
1593 specify library version info [each variable defaults to 0]
1594 -weak LIBNAME declare that the target provides the LIBNAME interface
1595
1596All other options (arguments beginning with \`-') are ignored.
1597
1598Every other argument is treated as a filename. Files ending in \`.la' are
1599treated as uninstalled libtool libraries, other files are standard or library
1600object files.
1601
1602If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
1603only library objects (\`.lo' files) may be specified, and \`-rpath' is
1604required, except when creating a convenience library.
1605
1606If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
1607using \`ar' and \`ranlib', or on Windows using \`lib'.
1608
1609If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
1610is created, otherwise an executable program is created."
1611 ;;
1612
1613 uninstall)
1614 $ECHO \
1615"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
1616
1617Remove libraries from an installation directory.
1618
1619RM is the name of the program to use to delete files associated with each FILE
1620(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
1621to RM.
1622
1623If FILE is a libtool library, all the files associated with it are deleted.
1624Otherwise, only FILE itself is deleted using RM."
1625 ;;
1626
1627 *)
1628 func_fatal_help "invalid operation mode \`$mode'"
1629 ;;
1630 esac
1631
1632 $ECHO
1633 $ECHO "Try \`$progname --help' for more information about other modes."
1634
1635 exit $?
1636}
1637
1638 # Now that we've collected a possible --mode arg, show help if necessary
1639 $opt_help && func_mode_help
1640
1641
1642# func_mode_execute arg...
1643func_mode_execute ()
1644{
1645 $opt_debug
1646 # The first argument is the command name.
1647 cmd="$nonopt"
1648 test -z "$cmd" && \
1649 func_fatal_help "you must specify a COMMAND"
1650
1651 # Handle -dlopen flags immediately.
1652 for file in $execute_dlfiles; do
1653 test -f "$file" \
1654 || func_fatal_help "\`$file' is not a file"
1655
1656 dir=
1657 case $file in
1658 *.la)
1659 # Check to see that this really is a libtool archive.
1660 func_lalib_unsafe_p "$file" \
1661 || func_fatal_help "\`$lib' is not a valid libtool archive"
1662
1663 # Read the libtool library.
1664 dlname=
1665 library_names=
1666 func_source "$file"
1667
1668 # Skip this library if it cannot be dlopened.
1669 if test -z "$dlname"; then
1670 # Warn if it was a shared library.
1671 test -n "$library_names" && \
1672 func_warning "\`$file' was not linked with \`-export-dynamic'"
1673 continue
1674 fi
1675
1676 func_dirname "$file" "" "."
1677 dir="$func_dirname_result"
1678
1679 if test -f "$dir/$objdir/$dlname"; then
1680 dir="$dir/$objdir"
1681 else
1682 if test ! -f "$dir/$dlname"; then
1683 func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
1684 fi
1685 fi
1686 ;;
1687
1688 *.lo)
1689 # Just add the directory containing the .lo file.
1690 func_dirname "$file" "" "."
1691 dir="$func_dirname_result"
1692 ;;
1693
1694 *)
1695 func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
1696 continue
1697 ;;
1698 esac
1699
1700 # Get the absolute pathname.
1701 absdir=`cd "$dir" && pwd`
1702 test -n "$absdir" && dir="$absdir"
1703
1704 # Now add the directory to shlibpath_var.
1705 if eval "test -z \"\$$shlibpath_var\""; then
1706 eval "$shlibpath_var=\"\$dir\""
1707 else
1708 eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
1709 fi
1710 done
1711
1712 # This variable tells wrapper scripts just to set shlibpath_var
1713 # rather than running their programs.
1714 libtool_execute_magic="$magic"
1715
1716 # Check if any of the arguments is a wrapper script.
1717 args=
1718 for file
1719 do
1720 case $file in
1721 -*) ;;
1722 *)
1723 # Do a test to see if this is really a libtool program.
1724 if func_ltwrapper_script_p "$file"; then
1725 func_source "$file"
1726 # Transform arg to wrapped name.
1727 file="$progdir/$program"
1728 elif func_ltwrapper_executable_p "$file"; then
1729 func_ltwrapper_scriptname "$file"
1730 func_source "$func_ltwrapper_scriptname_result"
1731 # Transform arg to wrapped name.
1732 file="$progdir/$program"
1733 fi
1734 ;;
1735 esac
1736 # Quote arguments (to preserve shell metacharacters).
1737 func_quote_for_eval "$file"
1738 args="$args $func_quote_for_eval_result"
1739 done
1740
1741 if test "X$opt_dry_run" = Xfalse; then
1742 if test -n "$shlibpath_var"; then
1743 # Export the shlibpath_var.
1744 eval "export $shlibpath_var"
1745 fi
1746
1747 # Restore saved environment variables
1748 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
1749 do
1750 eval "if test \"\${save_$lt_var+set}\" = set; then
1751 $lt_var=\$save_$lt_var; export $lt_var
1752 else
1753 $lt_unset $lt_var
1754 fi"
1755 done
1756
1757 # Now prepare to actually exec the command.
1758 exec_cmd="\$cmd$args"
1759 else
1760 # Display what would be done.
1761 if test -n "$shlibpath_var"; then
1762 eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
1763 $ECHO "export $shlibpath_var"
1764 fi
1765 $ECHO "$cmd$args"
1766 exit $EXIT_SUCCESS
1767 fi
1768}
1769
1770test "$mode" = execute && func_mode_execute ${1+"$@"}
1771
1772
1773# func_mode_finish arg...
1774func_mode_finish ()
1775{
1776 $opt_debug
1777 libdirs="$nonopt"
1778 admincmds=
1779
1780 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
1781 for dir
1782 do
1783 libdirs="$libdirs $dir"
1784 done
1785
1786 for libdir in $libdirs; do
1787 if test -n "$finish_cmds"; then
1788 # Do each command in the finish commands.
1789 func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
1790'"$cmd"'"'
1791 fi
1792 if test -n "$finish_eval"; then
1793 # Do the single finish_eval.
1794 eval cmds=\"$finish_eval\"
1795 $opt_dry_run || eval "$cmds" || admincmds="$admincmds
1796 $cmds"
1797 fi
1798 done
1799 fi
1800
1801 # Exit here if they wanted silent mode.
1802 $opt_silent && exit $EXIT_SUCCESS
1803
1804 $ECHO "X----------------------------------------------------------------------" | $Xsed
1805 $ECHO "Libraries have been installed in:"
1806 for libdir in $libdirs; do
1807 $ECHO " $libdir"
1808 done
1809 $ECHO
1810 $ECHO "If you ever happen to want to link against installed libraries"
1811 $ECHO "in a given directory, LIBDIR, you must either use libtool, and"
1812 $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'"
1813 $ECHO "flag during linking and do at least one of the following:"
1814 if test -n "$shlibpath_var"; then
1815 $ECHO " - add LIBDIR to the \`$shlibpath_var' environment variable"
1816 $ECHO " during execution"
1817 fi
1818 if test -n "$runpath_var"; then
1819 $ECHO " - add LIBDIR to the \`$runpath_var' environment variable"
1820 $ECHO " during linking"
1821 fi
1822 if test -n "$hardcode_libdir_flag_spec"; then
1823 libdir=LIBDIR
1824 eval flag=\"$hardcode_libdir_flag_spec\"
1825
1826 $ECHO " - use the \`$flag' linker flag"
1827 fi
1828 if test -n "$admincmds"; then
1829 $ECHO " - have your system administrator run these commands:$admincmds"
1830 fi
1831 if test -f /etc/ld.so.conf; then
1832 $ECHO " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
1833 fi
1834 $ECHO
1835
1836 $ECHO "See any operating system documentation about shared libraries for"
1837 case $host in
1838 solaris2.[6789]|solaris2.1[0-9])
1839 $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual"
1840 $ECHO "pages."
1841 ;;
1842 *)
1843 $ECHO "more information, such as the ld(1) and ld.so(8) manual pages."
1844 ;;
1845 esac
1846 $ECHO "X----------------------------------------------------------------------" | $Xsed
1847 exit $EXIT_SUCCESS
1848}
1849
1850test "$mode" = finish && func_mode_finish ${1+"$@"}
1851
1852
1853# func_mode_install arg...
1854func_mode_install ()
1855{
1856 $opt_debug
1857 # There may be an optional sh(1) argument at the beginning of
1858 # install_prog (especially on Windows NT).
1859 if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
1860 # Allow the use of GNU shtool's install command.
1861 $ECHO "X$nonopt" | $GREP shtool >/dev/null; then
1862 # Aesthetically quote it.
1863 func_quote_for_eval "$nonopt"
1864 install_prog="$func_quote_for_eval_result "
1865 arg=$1
1866 shift
1867 else
1868 install_prog=
1869 arg=$nonopt
1870 fi
1871
1872 # The real first argument should be the name of the installation program.
1873 # Aesthetically quote it.
1874 func_quote_for_eval "$arg"
1875 install_prog="$install_prog$func_quote_for_eval_result"
1876
1877 # We need to accept at least all the BSD install flags.
1878 dest=
1879 files=
1880 opts=
1881 prev=
1882 install_type=
1883 isdir=no
1884 stripme=
1885 for arg
1886 do
1887 if test -n "$dest"; then
1888 files="$files $dest"
1889 dest=$arg
1890 continue
1891 fi
1892
1893 case $arg in
1894 -d) isdir=yes ;;
1895 -f)
1896 case " $install_prog " in
1897 *[\\\ /]cp\ *) ;;
1898 *) prev=$arg ;;
1899 esac
1900 ;;
1901 -g | -m | -o)
1902 prev=$arg
1903 ;;
1904 -s)
1905 stripme=" -s"
1906 continue
1907 ;;
1908 -*)
1909 ;;
1910 *)
1911 # If the previous option needed an argument, then skip it.
1912 if test -n "$prev"; then
1913 prev=
1914 else
1915 dest=$arg
1916 continue
1917 fi
1918 ;;
1919 esac
1920
1921 # Aesthetically quote the argument.
1922 func_quote_for_eval "$arg"
1923 install_prog="$install_prog $func_quote_for_eval_result"
1924 done
1925
1926 test -z "$install_prog" && \
1927 func_fatal_help "you must specify an install program"
1928
1929 test -n "$prev" && \
1930 func_fatal_help "the \`$prev' option requires an argument"
1931
1932 if test -z "$files"; then
1933 if test -z "$dest"; then
1934 func_fatal_help "no file or destination specified"
1935 else
1936 func_fatal_help "you must specify a destination"
1937 fi
1938 fi
1939
1940 # Strip any trailing slash from the destination.
1941 func_stripname '' '/' "$dest"
1942 dest=$func_stripname_result
1943
1944 # Check to see that the destination is a directory.
1945 test -d "$dest" && isdir=yes
1946 if test "$isdir" = yes; then
1947 destdir="$dest"
1948 destname=
1949 else
1950 func_dirname_and_basename "$dest" "" "."
1951 destdir="$func_dirname_result"
1952 destname="$func_basename_result"
1953
1954 # Not a directory, so check to see that there is only one file specified.
1955 set dummy $files; shift
1956 test "$#" -gt 1 && \
1957 func_fatal_help "\`$dest' is not a directory"
1958 fi
1959 case $destdir in
1960 [\\/]* | [A-Za-z]:[\\/]*) ;;
1961 *)
1962 for file in $files; do
1963 case $file in
1964 *.lo) ;;
1965 *)
1966 func_fatal_help "\`$destdir' must be an absolute directory name"
1967 ;;
1968 esac
1969 done
1970 ;;
1971 esac
1972
1973 # This variable tells wrapper scripts just to set variables rather
1974 # than running their programs.
1975 libtool_install_magic="$magic"
1976
1977 staticlibs=
1978 future_libdirs=
1979 current_libdirs=
1980 for file in $files; do
1981
1982 # Do each installation.
1983 case $file in
1984 *.$libext)
1985 # Do the static libraries later.
1986 staticlibs="$staticlibs $file"
1987 ;;
1988
1989 *.la)
1990 # Check to see that this really is a libtool archive.
1991 func_lalib_unsafe_p "$file" \
1992 || func_fatal_help "\`$file' is not a valid libtool archive"
1993
1994 library_names=
1995 old_library=
1996 relink_command=
1997 func_source "$file"
1998
1999 # Add the libdir to current_libdirs if it is the destination.
2000 if test "X$destdir" = "X$libdir"; then
2001 case "$current_libdirs " in
2002 *" $libdir "*) ;;
2003 *) current_libdirs="$current_libdirs $libdir" ;;
2004 esac
2005 else
2006 # Note the libdir as a future libdir.
2007 case "$future_libdirs " in
2008 *" $libdir "*) ;;
2009 *) future_libdirs="$future_libdirs $libdir" ;;
2010 esac
2011 fi
2012
2013 func_dirname "$file" "/" ""
2014 dir="$func_dirname_result"
2015 dir="$dir$objdir"
2016
2017 if test -n "$relink_command"; then
2018 # Determine the prefix the user has applied to our future dir.
2019 inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"`
2020
2021 # Don't allow the user to place us outside of our expected
2022 # location b/c this prevents finding dependent libraries that
2023 # are installed to the same prefix.
2024 # At present, this check doesn't affect windows .dll's that
2025 # are installed into $libdir/../bin (currently, that works fine)
2026 # but it's something to keep an eye on.
2027 test "$inst_prefix_dir" = "$destdir" && \
2028 func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2029
2030 if test -n "$inst_prefix_dir"; then
2031 # Stick the inst_prefix_dir data into the link command.
2032 relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2033 else
2034 relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"`
2035 fi
2036
2037 func_warning "relinking \`$file'"
2038 func_show_eval "$relink_command" \
2039 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2040 fi
2041
2042 # See the names of the shared library.
2043 set dummy $library_names; shift
2044 if test -n "$1"; then
2045 realname="$1"
2046 shift
2047
2048 srcname="$realname"
2049 test -n "$relink_command" && srcname="$realname"T
2050
2051 # Install the shared library and build the symlinks.
2052 func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \
2053 'exit $?'
2054 tstripme="$stripme"
2055 case $host_os in
2056 cygwin* | mingw* | pw32*)
2057 case $realname in
2058 *.dll.a)
2059 tstripme=""
2060 ;;
2061 esac
2062 ;;
2063 esac
2064 if test -n "$tstripme" && test -n "$striplib"; then
2065 func_show_eval "$striplib $destdir/$realname" 'exit $?'
2066 fi
2067
2068 if test "$#" -gt 0; then
2069 # Delete the old symlinks, and create new ones.
2070 # Try `ln -sf' first, because the `ln' binary might depend on
2071 # the symlink we replace! Solaris /bin/ln does not understand -f,
2072 # so we also need to try rm && ln -s.
2073 for linkname
2074 do
2075 test "$linkname" != "$realname" \
2076 && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
2077 done
2078 fi
2079
2080 # Do each command in the postinstall commands.
2081 lib="$destdir/$realname"
2082 func_execute_cmds "$postinstall_cmds" 'exit $?'
2083 fi
2084
2085 # Install the pseudo-library for information purposes.
2086 func_basename "$file"
2087 name="$func_basename_result"
2088 instname="$dir/$name"i
2089 func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
2090
2091 # Maybe install the static library, too.
2092 test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
2093 ;;
2094
2095 *.lo)
2096 # Install (i.e. copy) a libtool object.
2097
2098 # Figure out destination file name, if it wasn't already specified.
2099 if test -n "$destname"; then
2100 destfile="$destdir/$destname"
2101 else
2102 func_basename "$file"
2103 destfile="$func_basename_result"
2104 destfile="$destdir/$destfile"
2105 fi
2106
2107 # Deduce the name of the destination old-style object file.
2108 case $destfile in
2109 *.lo)
2110 func_lo2o "$destfile"
2111 staticdest=$func_lo2o_result
2112 ;;
2113 *.$objext)
2114 staticdest="$destfile"
2115 destfile=
2116 ;;
2117 *)
2118 func_fatal_help "cannot copy a libtool object to \`$destfile'"
2119 ;;
2120 esac
2121
2122 # Install the libtool object if requested.
2123 test -n "$destfile" && \
2124 func_show_eval "$install_prog $file $destfile" 'exit $?'
2125
2126 # Install the old object if enabled.
2127 if test "$build_old_libs" = yes; then
2128 # Deduce the name of the old-style object file.
2129 func_lo2o "$file"
2130 staticobj=$func_lo2o_result
2131 func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
2132 fi
2133 exit $EXIT_SUCCESS
2134 ;;
2135
2136 *)
2137 # Figure out destination file name, if it wasn't already specified.
2138 if test -n "$destname"; then
2139 destfile="$destdir/$destname"
2140 else
2141 func_basename "$file"
2142 destfile="$func_basename_result"
2143 destfile="$destdir/$destfile"
2144 fi
2145
2146 # If the file is missing, and there is a .exe on the end, strip it
2147 # because it is most likely a libtool script we actually want to
2148 # install
2149 stripped_ext=""
2150 case $file in
2151 *.exe)
2152 if test ! -f "$file"; then
2153 func_stripname '' '.exe' "$file"
2154 file=$func_stripname_result
2155 stripped_ext=".exe"
2156 fi
2157 ;;
2158 esac
2159
2160 # Do a test to see if this is really a libtool program.
2161 case $host in
2162 *cygwin*|*mingw*)
2163 if func_ltwrapper_executable_p "$file"; then
2164 func_ltwrapper_scriptname "$file"
2165 wrapper=$func_ltwrapper_scriptname_result
2166 else
2167 func_stripname '' '.exe' "$file"
2168 wrapper=$func_stripname_result
2169 fi
2170 ;;
2171 *)
2172 wrapper=$file
2173 ;;
2174 esac
2175 if func_ltwrapper_script_p "$wrapper"; then
2176 notinst_deplibs=
2177 relink_command=
2178
2179 func_source "$wrapper"
2180
2181 # Check the variables that should have been set.
2182 test -z "$generated_by_libtool_version" && \
2183 func_fatal_error "invalid libtool wrapper script \`$wrapper'"
2184
2185 finalize=yes
2186 for lib in $notinst_deplibs; do
2187 # Check to see that each library is installed.
2188 libdir=
2189 if test -f "$lib"; then
2190 func_source "$lib"
2191 fi
2192 libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
2193 if test -n "$libdir" && test ! -f "$libfile"; then
2194 func_warning "\`$lib' has not been installed in \`$libdir'"
2195 finalize=no
2196 fi
2197 done
2198
2199 relink_command=
2200 func_source "$wrapper"
2201
2202 outputname=
2203 if test "$fast_install" = no && test -n "$relink_command"; then
2204 $opt_dry_run || {
2205 if test "$finalize" = yes; then
2206 tmpdir=`func_mktempdir`
2207 func_basename "$file$stripped_ext"
2208 file="$func_basename_result"
2209 outputname="$tmpdir/$file"
2210 # Replace the output file specification.
2211 relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
2212
2213 $opt_silent || {
2214 func_quote_for_expand "$relink_command"
2215 eval "func_echo $func_quote_for_expand_result"
2216 }
2217 if eval "$relink_command"; then :
2218 else
2219 func_error "error: relink \`$file' with the above command before installing it"
2220 $opt_dry_run || ${RM}r "$tmpdir"
2221 continue
2222 fi
2223 file="$outputname"
2224 else
2225 func_warning "cannot relink \`$file'"
2226 fi
2227 }
2228 else
2229 # Install the binary that we compiled earlier.
2230 file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
2231 fi
2232 fi
2233
2234 # remove .exe since cygwin /usr/bin/install will append another
2235 # one anyway
2236 case $install_prog,$host in
2237 */usr/bin/install*,*cygwin*)
2238 case $file:$destfile in
2239 *.exe:*.exe)
2240 # this is ok
2241 ;;
2242 *.exe:*)
2243 destfile=$destfile.exe
2244 ;;
2245 *:*.exe)
2246 func_stripname '' '.exe' "$destfile"
2247 destfile=$func_stripname_result
2248 ;;
2249 esac
2250 ;;
2251 esac
2252 func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
2253 $opt_dry_run || if test -n "$outputname"; then
2254 ${RM}r "$tmpdir"
2255 fi
2256 ;;
2257 esac
2258 done
2259
2260 for file in $staticlibs; do
2261 func_basename "$file"
2262 name="$func_basename_result"
2263
2264 # Set up the ranlib parameters.
2265 oldlib="$destdir/$name"
2266
2267 func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
2268
2269 if test -n "$stripme" && test -n "$old_striplib"; then
2270 func_show_eval "$old_striplib $oldlib" 'exit $?'
2271 fi
2272
2273 # Do each command in the postinstall commands.
2274 func_execute_cmds "$old_postinstall_cmds" 'exit $?'
2275 done
2276
2277 test -n "$future_libdirs" && \
2278 func_warning "remember to run \`$progname --finish$future_libdirs'"
2279
2280 if test -n "$current_libdirs"; then
2281 # Maybe just do a dry run.
2282 $opt_dry_run && current_libdirs=" -n$current_libdirs"
2283 exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
2284 else
2285 exit $EXIT_SUCCESS
2286 fi
2287}
2288
2289test "$mode" = install && func_mode_install ${1+"$@"}
2290
2291
2292# func_generate_dlsyms outputname originator pic_p
2293# Extract symbols from dlprefiles and create ${outputname}S.o with
2294# a dlpreopen symbol table.
2295func_generate_dlsyms ()
2296{
2297 $opt_debug
2298 my_outputname="$1"
2299 my_originator="$2"
2300 my_pic_p="${3-no}"
2301 my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
2302 my_dlsyms=
2303
2304 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
2305 if test -n "$NM" && test -n "$global_symbol_pipe"; then
2306 my_dlsyms="${my_outputname}S.c"
2307 else
2308 func_error "not configured to extract global symbols from dlpreopened files"
2309 fi
2310 fi
2311
2312 if test -n "$my_dlsyms"; then
2313 case $my_dlsyms in
2314 "") ;;
2315 *.c)
2316 # Discover the nlist of each of the dlfiles.
2317 nlist="$output_objdir/${my_outputname}.nm"
2318
2319 func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
2320
2321 # Parse the name list into a source file.
2322 func_verbose "creating $output_objdir/$my_dlsyms"
2323
2324 $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
2325/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
2326/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
2327
2328#ifdef __cplusplus
2329extern \"C\" {
2330#endif
2331
2332/* External symbol declarations for the compiler. */\
2333"
2334
2335 if test "$dlself" = yes; then
2336 func_verbose "generating symbol list for \`$output'"
2337
2338 $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
2339
2340 # Add our own program objects to the symbol list.
2341 progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
2342 for progfile in $progfiles; do
2343 func_verbose "extracting global C symbols from \`$progfile'"
2344 $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
2345 done
2346
2347 if test -n "$exclude_expsyms"; then
2348 $opt_dry_run || {
2349 eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
2350 eval '$MV "$nlist"T "$nlist"'
2351 }
2352 fi
2353
2354 if test -n "$export_symbols_regex"; then
2355 $opt_dry_run || {
2356 eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
2357 eval '$MV "$nlist"T "$nlist"'
2358 }
2359 fi
2360
2361 # Prepare the list of exported symbols
2362 if test -z "$export_symbols"; then
2363 export_symbols="$output_objdir/$outputname.exp"
2364 $opt_dry_run || {
2365 $RM $export_symbols
2366 eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
2367 case $host in
2368 *cygwin* | *mingw* )
2369 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
2370 eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
2371 ;;
2372 esac
2373 }
2374 else
2375 $opt_dry_run || {
2376 eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
2377 eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
2378 eval '$MV "$nlist"T "$nlist"'
2379 case $host in
2380 *cygwin | *mingw* )
2381 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
2382 eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
2383 ;;
2384 esac
2385 }
2386 fi
2387 fi
2388
2389 for dlprefile in $dlprefiles; do
2390 func_verbose "extracting global C symbols from \`$dlprefile'"
2391 func_basename "$dlprefile"
2392 name="$func_basename_result"
2393 $opt_dry_run || {
2394 eval '$ECHO ": $name " >> "$nlist"'
2395 eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
2396 }
2397 done
2398
2399 $opt_dry_run || {
2400 # Make sure we have at least an empty file.
2401 test -f "$nlist" || : > "$nlist"
2402
2403 if test -n "$exclude_expsyms"; then
2404 $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
2405 $MV "$nlist"T "$nlist"
2406 fi
2407
2408 # Try sorting and uniquifying the output.
2409 if $GREP -v "^: " < "$nlist" |
2410 if sort -k 3 </dev/null >/dev/null 2>&1; then
2411 sort -k 3
2412 else
2413 sort +2
2414 fi |
2415 uniq > "$nlist"S; then
2416 :
2417 else
2418 $GREP -v "^: " < "$nlist" > "$nlist"S
2419 fi
2420
2421 if test -f "$nlist"S; then
2422 eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
2423 else
2424 $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms"
2425 fi
2426
2427 $ECHO >> "$output_objdir/$my_dlsyms" "\
2428
2429/* The mapping between symbol names and symbols. */
2430typedef struct {
2431 const char *name;
2432 void *address;
2433} lt_dlsymlist;
2434"
2435 case $host in
2436 *cygwin* | *mingw* )
2437 $ECHO >> "$output_objdir/$my_dlsyms" "\
2438/* DATA imports from DLLs on WIN32 con't be const, because
2439 runtime relocations are performed -- see ld's documentation
2440 on pseudo-relocs. */"
2441 lt_dlsym_const= ;;
2442 *osf5*)
2443 echo >> "$output_objdir/$my_dlsyms" "\
2444/* This system does not cope well with relocations in const data */"
2445 lt_dlsym_const= ;;
2446 *)
2447 lt_dlsym_const=const ;;
2448 esac
2449
2450 $ECHO >> "$output_objdir/$my_dlsyms" "\
2451extern $lt_dlsym_const lt_dlsymlist
2452lt_${my_prefix}_LTX_preloaded_symbols[];
2453$lt_dlsym_const lt_dlsymlist
2454lt_${my_prefix}_LTX_preloaded_symbols[] =
2455{\
2456 { \"$my_originator\", (void *) 0 },"
2457
2458 case $need_lib_prefix in
2459 no)
2460 eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
2461 ;;
2462 *)
2463 eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
2464 ;;
2465 esac
2466 $ECHO >> "$output_objdir/$my_dlsyms" "\
2467 {0, (void *) 0}
2468};
2469
2470/* This works around a problem in FreeBSD linker */
2471#ifdef FREEBSD_WORKAROUND
2472static const void *lt_preloaded_setup() {
2473 return lt_${my_prefix}_LTX_preloaded_symbols;
2474}
2475#endif
2476
2477#ifdef __cplusplus
2478}
2479#endif\
2480"
2481 } # !$opt_dry_run
2482
2483 pic_flag_for_symtable=
2484 case "$compile_command " in
2485 *" -static "*) ;;
2486 *)
2487 case $host in
2488 # compiling the symbol table file with pic_flag works around
2489 # a FreeBSD bug that causes programs to crash when -lm is
2490 # linked before any other PIC object. But we must not use
2491 # pic_flag when linking with -static. The problem exists in
2492 # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
2493 *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
2494 pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
2495 *-*-hpux*)
2496 pic_flag_for_symtable=" $pic_flag" ;;
2497 *)
2498 if test "X$my_pic_p" != Xno; then
2499 pic_flag_for_symtable=" $pic_flag"
2500 fi
2501 ;;
2502 esac
2503 ;;
2504 esac
2505 symtab_cflags=
2506 for arg in $LTCFLAGS; do
2507 case $arg in
2508 -pie | -fpie | -fPIE) ;;
2509 *) symtab_cflags="$symtab_cflags $arg" ;;
2510 esac
2511 done
2512
2513 # Now compile the dynamic symbol file.
2514 func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
2515
2516 # Clean up the generated files.
2517 func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
2518
2519 # Transform the symbol file into the correct name.
2520 symfileobj="$output_objdir/${my_outputname}S.$objext"
2521 case $host in
2522 *cygwin* | *mingw* )
2523 if test -f "$output_objdir/$my_outputname.def"; then
2524 compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
2525 finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
2526 else
2527 compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2528 finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2529 fi
2530 ;;
2531 *)
2532 compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2533 finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2534 ;;
2535 esac
2536 ;;
2537 *)
2538 func_fatal_error "unknown suffix for \`$my_dlsyms'"
2539 ;;
2540 esac
2541 else
2542 # We keep going just in case the user didn't refer to
2543 # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
2544 # really was required.
2545
2546 # Nullify the symbol file.
2547 compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
2548 finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
2549 fi
2550}
2551
2552# func_win32_libid arg
2553# return the library type of file 'arg'
2554#
2555# Need a lot of goo to handle *both* DLLs and import libs
2556# Has to be a shell function in order to 'eat' the argument
2557# that is supplied when $file_magic_command is called.
2558func_win32_libid ()
2559{
2560 $opt_debug
2561 win32_libid_type="unknown"
2562 win32_fileres=`file -L $1 2>/dev/null`
2563 case $win32_fileres in
2564 *ar\ archive\ import\ library*) # definitely import
2565 win32_libid_type="x86 archive import"
2566 ;;
2567 *ar\ archive*) # could be an import, or static
2568 if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
2569 $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
2570 win32_nmres=`eval $NM -f posix -A $1 |
2571 $SED -n -e '
2572 1,100{
2573 / I /{
2574 s,.*,import,
2575 p
2576 q
2577 }
2578 }'`
2579 case $win32_nmres in
2580 import*) win32_libid_type="x86 archive import";;
2581 *) win32_libid_type="x86 archive static";;
2582 esac
2583 fi
2584 ;;
2585 *DLL*)
2586 win32_libid_type="x86 DLL"
2587 ;;
2588 *executable*) # but shell scripts are "executable" too...
2589 case $win32_fileres in
2590 *MS\ Windows\ PE\ Intel*)
2591 win32_libid_type="x86 DLL"
2592 ;;
2593 esac
2594 ;;
2595 esac
2596 $ECHO "$win32_libid_type"
2597}
2598
2599
2600
2601# func_extract_an_archive dir oldlib
2602func_extract_an_archive ()
2603{
2604 $opt_debug
2605 f_ex_an_ar_dir="$1"; shift
2606 f_ex_an_ar_oldlib="$1"
2607 func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?'
2608 if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
2609 :
2610 else
2611 func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
2612 fi
2613}
2614
2615
2616# func_extract_archives gentop oldlib ...
2617func_extract_archives ()
2618{
2619 $opt_debug
2620 my_gentop="$1"; shift
2621 my_oldlibs=${1+"$@"}
2622 my_oldobjs=""
2623 my_xlib=""
2624 my_xabs=""
2625 my_xdir=""
2626
2627 for my_xlib in $my_oldlibs; do
2628 # Extract the objects.
2629 case $my_xlib in
2630 [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
2631 *) my_xabs=`pwd`"/$my_xlib" ;;
2632 esac
2633 func_basename "$my_xlib"
2634 my_xlib="$func_basename_result"
2635 my_xlib_u=$my_xlib
2636 while :; do
2637 case " $extracted_archives " in
2638 *" $my_xlib_u "*)
2639 func_arith $extracted_serial + 1
2640 extracted_serial=$func_arith_result
2641 my_xlib_u=lt$extracted_serial-$my_xlib ;;
2642 *) break ;;
2643 esac
2644 done
2645 extracted_archives="$extracted_archives $my_xlib_u"
2646 my_xdir="$my_gentop/$my_xlib_u"
2647
2648 func_mkdir_p "$my_xdir"
2649
2650 case $host in
2651 *-darwin*)
2652 func_verbose "Extracting $my_xabs"
2653 # Do not bother doing anything if just a dry run
2654 $opt_dry_run || {
2655 darwin_orig_dir=`pwd`
2656 cd $my_xdir || exit $?
2657 darwin_archive=$my_xabs
2658 darwin_curdir=`pwd`
2659 darwin_base_archive=`basename "$darwin_archive"`
2660 darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
2661 if test -n "$darwin_arches"; then
2662 darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
2663 darwin_arch=
2664 func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
2665 for darwin_arch in $darwin_arches ; do
2666 func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
2667 $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
2668 cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
2669 func_extract_an_archive "`pwd`" "${darwin_base_archive}"
2670 cd "$darwin_curdir"
2671 $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
2672 done # $darwin_arches
2673 ## Okay now we've a bunch of thin objects, gotta fatten them up :)
2674 darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
2675 darwin_file=
2676 darwin_files=
2677 for darwin_file in $darwin_filelist; do
2678 darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
2679 $LIPO -create -output "$darwin_file" $darwin_files
2680 done # $darwin_filelist
2681 $RM -rf unfat-$$
2682 cd "$darwin_orig_dir"
2683 else
2684 cd $darwin_orig_dir
2685 func_extract_an_archive "$my_xdir" "$my_xabs"
2686 fi # $darwin_arches
2687 } # !$opt_dry_run
2688 ;;
2689 *)
2690 func_extract_an_archive "$my_xdir" "$my_xabs"
2691 ;;
2692 esac
2693 my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
2694 done
2695
2696 func_extract_archives_result="$my_oldobjs"
2697}
2698
2699
2700
2701# func_emit_wrapper arg
2702#
2703# emit a libtool wrapper script on stdout
2704# don't directly open a file because we may want to
2705# incorporate the script contents within a cygwin/mingw
2706# wrapper executable. Must ONLY be called from within
2707# func_mode_link because it depends on a number of variable
2708# set therein.
2709#
2710# arg is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
2711# variable will take. If 'yes', then the emitted script
2712# will assume that the directory in which it is stored is
2713# the '.lib' directory. This is a cygwin/mingw-specific
2714# behavior.
2715func_emit_wrapper ()
2716{
2717 func_emit_wrapper_arg1=no
2718 if test -n "$1" ; then
2719 func_emit_wrapper_arg1=$1
2720 fi
2721
2722 $ECHO "\
2723#! $SHELL
2724
2725# $output - temporary wrapper script for $objdir/$outputname
2726# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
2727#
2728# The $output program cannot be directly executed until all the libtool
2729# libraries that it depends on are installed.
2730#
2731# This wrapper script should never be moved out of the build directory.
2732# If it is, it will not operate correctly.
2733
2734# Sed substitution that helps us do robust quoting. It backslashifies
2735# metacharacters that are still active within double-quoted strings.
2736Xsed='${SED} -e 1s/^X//'
2737sed_quote_subst='$sed_quote_subst'
2738
2739# Be Bourne compatible
2740if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
2741 emulate sh
2742 NULLCMD=:
2743 # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
2744 # is contrary to our usage. Disable this feature.
2745 alias -g '\${1+\"\$@\"}'='\"\$@\"'
2746 setopt NO_GLOB_SUBST
2747else
2748 case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
2749fi
2750BIN_SH=xpg4; export BIN_SH # for Tru64
2751DUALCASE=1; export DUALCASE # for MKS sh
2752
2753# The HP-UX ksh and POSIX shell print the target directory to stdout
2754# if CDPATH is set.
2755(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
2756
2757relink_command=\"$relink_command\"
2758
2759# This environment variable determines our operation mode.
2760if test \"\$libtool_install_magic\" = \"$magic\"; then
2761 # install mode needs the following variables:
2762 generated_by_libtool_version='$macro_version'
2763 notinst_deplibs='$notinst_deplibs'
2764else
2765 # When we are sourced in execute mode, \$file and \$ECHO are already set.
2766 if test \"\$libtool_execute_magic\" != \"$magic\"; then
2767 ECHO=\"$qecho\"
2768 file=\"\$0\"
2769 # Make sure echo works.
2770 if test \"X\$1\" = X--no-reexec; then
2771 # Discard the --no-reexec flag, and continue.
2772 shift
2773 elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then
2774 # Yippee, \$ECHO works!
2775 :
2776 else
2777 # Restart under the correct shell, and then maybe \$ECHO will work.
2778 exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
2779 fi
2780 fi\
2781"
2782 $ECHO "\
2783
2784 # Find the directory that this script lives in.
2785 thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
2786 test \"x\$thisdir\" = \"x\$file\" && thisdir=.
2787
2788 # Follow symbolic links until we get to the real thisdir.
2789 file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
2790 while test -n \"\$file\"; do
2791 destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
2792
2793 # If there was a directory component, then change thisdir.
2794 if test \"x\$destdir\" != \"x\$file\"; then
2795 case \"\$destdir\" in
2796 [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
2797 *) thisdir=\"\$thisdir/\$destdir\" ;;
2798 esac
2799 fi
2800
2801 file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
2802 file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
2803 done
2804
2805 # Usually 'no', except on cygwin/mingw when embedded into
2806 # the cwrapper.
2807 WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
2808 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
2809 # special case for '.'
2810 if test \"\$thisdir\" = \".\"; then
2811 thisdir=\`pwd\`
2812 fi
2813 # remove .libs from thisdir
2814 case \"\$thisdir\" in
2815 *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;;
2816 $objdir ) thisdir=. ;;
2817 esac
2818 fi
2819
2820 # Try to get the absolute directory name.
2821 absdir=\`cd \"\$thisdir\" && pwd\`
2822 test -n \"\$absdir\" && thisdir=\"\$absdir\"
2823"
2824
2825 if test "$fast_install" = yes; then
2826 $ECHO "\
2827 program=lt-'$outputname'$exeext
2828 progdir=\"\$thisdir/$objdir\"
2829
2830 if test ! -f \"\$progdir/\$program\" ||
2831 { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
2832 test \"X\$file\" != \"X\$progdir/\$program\"; }; then
2833
2834 file=\"\$\$-\$program\"
2835
2836 if test ! -d \"\$progdir\"; then
2837 $MKDIR \"\$progdir\"
2838 else
2839 $RM \"\$progdir/\$file\"
2840 fi"
2841
2842 $ECHO "\
2843
2844 # relink executable if necessary
2845 if test -n \"\$relink_command\"; then
2846 if relink_command_output=\`eval \$relink_command 2>&1\`; then :
2847 else
2848 $ECHO \"\$relink_command_output\" >&2
2849 $RM \"\$progdir/\$file\"
2850 exit 1
2851 fi
2852 fi
2853
2854 $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
2855 { $RM \"\$progdir/\$program\";
2856 $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
2857 $RM \"\$progdir/\$file\"
2858 fi"
2859 else
2860 $ECHO "\
2861 program='$outputname'
2862 progdir=\"\$thisdir/$objdir\"
2863"
2864 fi
2865
2866 $ECHO "\
2867
2868 if test -f \"\$progdir/\$program\"; then"
2869
2870 # Export our shlibpath_var if we have one.
2871 if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
2872 $ECHO "\
2873 # Add our own library path to $shlibpath_var
2874 $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
2875
2876 # Some systems cannot cope with colon-terminated $shlibpath_var
2877 # The second colon is a workaround for a bug in BeOS R4 sed
2878 $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
2879
2880 export $shlibpath_var
2881"
2882 fi
2883
2884 # fixup the dll searchpath if we need to.
2885 if test -n "$dllsearchpath"; then
2886 $ECHO "\
2887 # Add the dll search path components to the executable PATH
2888 PATH=$dllsearchpath:\$PATH
2889"
2890 fi
2891
2892 $ECHO "\
2893 if test \"\$libtool_execute_magic\" != \"$magic\"; then
2894 # Run the actual program with our arguments.
2895"
2896 case $host in
2897 # Backslashes separate directories on plain windows
2898 *-*-mingw | *-*-os2*)
2899 $ECHO "\
2900 exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
2901"
2902 ;;
2903
2904 *)
2905 $ECHO "\
2906 exec \"\$progdir/\$program\" \${1+\"\$@\"}
2907"
2908 ;;
2909 esac
2910 $ECHO "\
2911 \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
2912 exit 1
2913 fi
2914 else
2915 # The program doesn't exist.
2916 \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
2917 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
2918 $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
2919 exit 1
2920 fi
2921fi\
2922"
2923}
2924# end: func_emit_wrapper
2925
2926# func_emit_cwrapperexe_src
2927# emit the source code for a wrapper executable on stdout
2928# Must ONLY be called from within func_mode_link because
2929# it depends on a number of variable set therein.
2930func_emit_cwrapperexe_src ()
2931{
2932 cat <<EOF
2933
2934/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
2935 Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
2936
2937 The $output program cannot be directly executed until all the libtool
2938 libraries that it depends on are installed.
2939
2940 This wrapper executable should never be moved out of the build directory.
2941 If it is, it will not operate correctly.
2942
2943 Currently, it simply execs the wrapper *script* "$SHELL $output",
2944 but could eventually absorb all of the scripts functionality and
2945 exec $objdir/$outputname directly.
2946*/
2947EOF
2948 cat <<"EOF"
2949#include <stdio.h>
2950#include <stdlib.h>
2951#ifdef _MSC_VER
2952# include <direct.h>
2953# include <process.h>
2954# include <io.h>
2955# define setmode _setmode
2956#else
2957# include <unistd.h>
2958# include <stdint.h>
2959# ifdef __CYGWIN__
2960# include <io.h>
2961# endif
2962#endif
2963#include <malloc.h>
2964#include <stdarg.h>
2965#include <assert.h>
2966#include <string.h>
2967#include <ctype.h>
2968#include <errno.h>
2969#include <fcntl.h>
2970#include <sys/stat.h>
2971
2972#if defined(PATH_MAX)
2973# define LT_PATHMAX PATH_MAX
2974#elif defined(MAXPATHLEN)
2975# define LT_PATHMAX MAXPATHLEN
2976#else
2977# define LT_PATHMAX 1024
2978#endif
2979
2980#ifndef S_IXOTH
2981# define S_IXOTH 0
2982#endif
2983#ifndef S_IXGRP
2984# define S_IXGRP 0
2985#endif
2986
2987#ifdef _MSC_VER
2988# define S_IXUSR _S_IEXEC
2989# define stat _stat
2990# ifndef _INTPTR_T_DEFINED
2991# define intptr_t int
2992# endif
2993#endif
2994
2995#ifndef DIR_SEPARATOR
2996# define DIR_SEPARATOR '/'
2997# define PATH_SEPARATOR ':'
2998#endif
2999
3000#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
3001 defined (__OS2__)
3002# define HAVE_DOS_BASED_FILE_SYSTEM
3003# define FOPEN_WB "wb"
3004# ifndef DIR_SEPARATOR_2
3005# define DIR_SEPARATOR_2 '\\'
3006# endif
3007# ifndef PATH_SEPARATOR_2
3008# define PATH_SEPARATOR_2 ';'
3009# endif
3010#endif
3011
3012#ifndef DIR_SEPARATOR_2
3013# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
3014#else /* DIR_SEPARATOR_2 */
3015# define IS_DIR_SEPARATOR(ch) \
3016 (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
3017#endif /* DIR_SEPARATOR_2 */
3018
3019#ifndef PATH_SEPARATOR_2
3020# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
3021#else /* PATH_SEPARATOR_2 */
3022# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
3023#endif /* PATH_SEPARATOR_2 */
3024
3025#ifdef __CYGWIN__
3026# define FOPEN_WB "wb"
3027#endif
3028
3029#ifndef FOPEN_WB
3030# define FOPEN_WB "w"
3031#endif
3032#ifndef _O_BINARY
3033# define _O_BINARY 0
3034#endif
3035
3036#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
3037#define XFREE(stale) do { \
3038 if (stale) { free ((void *) stale); stale = 0; } \
3039} while (0)
3040
3041#undef LTWRAPPER_DEBUGPRINTF
3042#if defined DEBUGWRAPPER
3043# define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args
3044static void
3045ltwrapper_debugprintf (const char *fmt, ...)
3046{
3047 va_list args;
3048 va_start (args, fmt);
3049 (void) vfprintf (stderr, fmt, args);
3050 va_end (args);
3051}
3052#else
3053# define LTWRAPPER_DEBUGPRINTF(args)
3054#endif
3055
3056const char *program_name = NULL;
3057
3058void *xmalloc (size_t num);
3059char *xstrdup (const char *string);
3060const char *base_name (const char *name);
3061char *find_executable (const char *wrapper);
3062char *chase_symlinks (const char *pathspec);
3063int make_executable (const char *path);
3064int check_executable (const char *path);
3065char *strendzap (char *str, const char *pat);
3066void lt_fatal (const char *message, ...);
3067
3068static const char *script_text =
3069EOF
3070
3071 func_emit_wrapper yes |
3072 $SED -e 's/\([\\"]\)/\\\1/g' \
3073 -e 's/^/ "/' -e 's/$/\\n"/'
3074 echo ";"
3075
3076 cat <<EOF
3077const char * MAGIC_EXE = "$magic_exe";
3078
3079int
3080main (int argc, char *argv[])
3081{
3082 char **newargz;
3083 char *tmp_pathspec;
3084 char *actual_cwrapper_path;
3085 char *shwrapper_name;
3086 intptr_t rval = 127;
3087 FILE *shwrapper;
3088
3089 const char *dumpscript_opt = "--lt-dump-script";
3090 int i;
3091
3092 program_name = (char *) xstrdup (base_name (argv[0]));
3093 LTWRAPPER_DEBUGPRINTF (("(main) argv[0] : %s\n", argv[0]));
3094 LTWRAPPER_DEBUGPRINTF (("(main) program_name : %s\n", program_name));
3095
3096 /* very simple arg parsing; don't want to rely on getopt */
3097 for (i = 1; i < argc; i++)
3098 {
3099 if (strcmp (argv[i], dumpscript_opt) == 0)
3100 {
3101EOF
3102 case "$host" in
3103 *mingw* | *cygwin* )
3104 # make stdout use "unix" line endings
3105 echo " setmode(1,_O_BINARY);"
3106 ;;
3107 esac
3108
3109 cat <<EOF
3110 printf ("%s", script_text);
3111 return 0;
3112 }
3113 }
3114
3115 newargz = XMALLOC (char *, argc + 2);
3116EOF
3117
3118 if test -n "$TARGETSHELL" ; then
3119 # no path translation at all
3120 lt_newargv0=$TARGETSHELL
3121 else
3122 case "$host" in
3123 *mingw* )
3124 # awkward: cmd appends spaces to result
3125 lt_sed_strip_trailing_spaces="s/[ ]*\$//"
3126 lt_newargv0=`( cmd //c echo $SHELL | $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo $SHELL`
3127 case $lt_newargv0 in
3128 *.exe | *.EXE) ;;
3129 *) lt_newargv0=$lt_newargv0.exe ;;
3130 esac
3131 ;;
3132 * ) lt_newargv0=$SHELL ;;
3133 esac
3134 fi
3135
3136 cat <<EOF
3137 newargz[0] = (char *) xstrdup ("$lt_newargv0");
3138EOF
3139
3140 cat <<"EOF"
3141 tmp_pathspec = find_executable (argv[0]);
3142 if (tmp_pathspec == NULL)
3143 lt_fatal ("Couldn't find %s", argv[0]);
3144 LTWRAPPER_DEBUGPRINTF (("(main) found exe (before symlink chase) at : %s\n",
3145 tmp_pathspec));
3146
3147 actual_cwrapper_path = chase_symlinks (tmp_pathspec);
3148 LTWRAPPER_DEBUGPRINTF (("(main) found exe (after symlink chase) at : %s\n",
3149 actual_cwrapper_path));
3150 XFREE (tmp_pathspec);
3151
3152 shwrapper_name = (char *) xstrdup (base_name (actual_cwrapper_path));
3153 strendzap (actual_cwrapper_path, shwrapper_name);
3154
3155 /* shwrapper_name transforms */
3156 strendzap (shwrapper_name, ".exe");
3157 tmp_pathspec = XMALLOC (char, (strlen (shwrapper_name) +
3158 strlen ("_ltshwrapperTMP") + 1));
3159 strcpy (tmp_pathspec, shwrapper_name);
3160 strcat (tmp_pathspec, "_ltshwrapperTMP");
3161 XFREE (shwrapper_name);
3162 shwrapper_name = tmp_pathspec;
3163 tmp_pathspec = 0;
3164 LTWRAPPER_DEBUGPRINTF (("(main) libtool shell wrapper name: %s\n",
3165 shwrapper_name));
3166EOF
3167
3168 cat <<EOF
3169 newargz[1] =
3170 XMALLOC (char, (strlen (actual_cwrapper_path) +
3171 strlen ("$objdir") + 1 + strlen (shwrapper_name) + 1));
3172 strcpy (newargz[1], actual_cwrapper_path);
3173 strcat (newargz[1], "$objdir");
3174 strcat (newargz[1], "/");
3175 strcat (newargz[1], shwrapper_name);
3176EOF
3177
3178
3179 case $host_os in
3180 mingw*)
3181 cat <<"EOF"
3182 {
3183 char* p;
3184 while ((p = strchr (newargz[1], '\\')) != NULL)
3185 {
3186 *p = '/';
3187 }
3188 }
3189EOF
3190 ;;
3191 esac
3192
3193 cat <<"EOF"
3194 XFREE (shwrapper_name);
3195 XFREE (actual_cwrapper_path);
3196
3197 /* always write in binary mode */
3198 if ((shwrapper = fopen (newargz[1], FOPEN_WB)) == 0)
3199 {
3200 lt_fatal ("Could not open %s for writing", newargz[1]);
3201 }
3202 fprintf (shwrapper, "%s", script_text);
3203 fclose (shwrapper);
3204
3205 make_executable (newargz[1]);
3206
3207 for (i = 1; i < argc; i++)
3208 newargz[i + 1] = xstrdup (argv[i]);
3209 newargz[argc + 1] = NULL;
3210
3211 for (i = 0; i < argc + 1; i++)
3212 {
3213 LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d] : %s\n", i, newargz[i]));
3214 }
3215
3216EOF
3217
3218 case $host_os in
3219 mingw*)
3220 cat <<EOF
3221 /* execv doesn't actually work on mingw as expected on unix */
3222 rval = _spawnv (_P_WAIT, "$lt_newargv0", (const char * const *) newargz);
3223 if (rval == -1)
3224 {
3225 /* failed to start process */
3226 LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"$lt_newargv0\": errno = %d\n", errno));
3227 return 127;
3228 }
3229 return rval;
3230}
3231EOF
3232 ;;
3233 *)
3234 cat <<EOF
3235 execv ("$lt_newargv0", newargz);
3236 return rval; /* =127, but avoids unused variable warning */
3237}
3238EOF
3239 ;;
3240 esac
3241
3242 cat <<"EOF"
3243
3244void *
3245xmalloc (size_t num)
3246{
3247 void *p = (void *) malloc (num);
3248 if (!p)
3249 lt_fatal ("Memory exhausted");
3250
3251 return p;
3252}
3253
3254char *
3255xstrdup (const char *string)
3256{
3257 return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
3258 string) : NULL;
3259}
3260
3261const char *
3262base_name (const char *name)
3263{
3264 const char *base;
3265
3266#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3267 /* Skip over the disk name in MSDOS pathnames. */
3268 if (isalpha ((unsigned char) name[0]) && name[1] == ':')
3269 name += 2;
3270#endif
3271
3272 for (base = name; *name; name++)
3273 if (IS_DIR_SEPARATOR (*name))
3274 base = name + 1;
3275 return base;
3276}
3277
3278int
3279check_executable (const char *path)
3280{
3281 struct stat st;
3282
3283 LTWRAPPER_DEBUGPRINTF (("(check_executable) : %s\n",
3284 path ? (*path ? path : "EMPTY!") : "NULL!"));
3285 if ((!path) || (!*path))
3286 return 0;
3287
3288 if ((stat (path, &st) >= 0)
3289 && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
3290 return 1;
3291 else
3292 return 0;
3293}
3294
3295int
3296make_executable (const char *path)
3297{
3298 int rval = 0;
3299 struct stat st;
3300
3301 LTWRAPPER_DEBUGPRINTF (("(make_executable) : %s\n",
3302 path ? (*path ? path : "EMPTY!") : "NULL!"));
3303 if ((!path) || (!*path))
3304 return 0;
3305
3306 if (stat (path, &st) >= 0)
3307 {
3308 rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
3309 }
3310 return rval;
3311}
3312
3313/* Searches for the full path of the wrapper. Returns
3314 newly allocated full path name if found, NULL otherwise
3315 Does not chase symlinks, even on platforms that support them.
3316*/
3317char *
3318find_executable (const char *wrapper)
3319{
3320 int has_slash = 0;
3321 const char *p;
3322 const char *p_next;
3323 /* static buffer for getcwd */
3324 char tmp[LT_PATHMAX + 1];
3325 int tmp_len;
3326 char *concat_name;
3327
3328 LTWRAPPER_DEBUGPRINTF (("(find_executable) : %s\n",
3329 wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"));
3330
3331 if ((wrapper == NULL) || (*wrapper == '\0'))
3332 return NULL;
3333
3334 /* Absolute path? */
3335#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3336 if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
3337 {
3338 concat_name = xstrdup (wrapper);
3339 if (check_executable (concat_name))
3340 return concat_name;
3341 XFREE (concat_name);
3342 }
3343 else
3344 {
3345#endif
3346 if (IS_DIR_SEPARATOR (wrapper[0]))
3347 {
3348 concat_name = xstrdup (wrapper);
3349 if (check_executable (concat_name))
3350 return concat_name;
3351 XFREE (concat_name);
3352 }
3353#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3354 }
3355#endif
3356
3357 for (p = wrapper; *p; p++)
3358 if (*p == '/')
3359 {
3360 has_slash = 1;
3361 break;
3362 }
3363 if (!has_slash)
3364 {
3365 /* no slashes; search PATH */
3366 const char *path = getenv ("PATH");
3367 if (path != NULL)
3368 {
3369 for (p = path; *p; p = p_next)
3370 {
3371 const char *q;
3372 size_t p_len;
3373 for (q = p; *q; q++)
3374 if (IS_PATH_SEPARATOR (*q))
3375 break;
3376 p_len = q - p;
3377 p_next = (*q == '\0' ? q : q + 1);
3378 if (p_len == 0)
3379 {
3380 /* empty path: current directory */
3381 if (getcwd (tmp, LT_PATHMAX) == NULL)
3382 lt_fatal ("getcwd failed");
3383 tmp_len = strlen (tmp);
3384 concat_name =
3385 XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
3386 memcpy (concat_name, tmp, tmp_len);
3387 concat_name[tmp_len] = '/';
3388 strcpy (concat_name + tmp_len + 1, wrapper);
3389 }
3390 else
3391 {
3392 concat_name =
3393 XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
3394 memcpy (concat_name, p, p_len);
3395 concat_name[p_len] = '/';
3396 strcpy (concat_name + p_len + 1, wrapper);
3397 }
3398 if (check_executable (concat_name))
3399 return concat_name;
3400 XFREE (concat_name);
3401 }
3402 }
3403 /* not found in PATH; assume curdir */
3404 }
3405 /* Relative path | not found in path: prepend cwd */
3406 if (getcwd (tmp, LT_PATHMAX) == NULL)
3407 lt_fatal ("getcwd failed");
3408 tmp_len = strlen (tmp);
3409 concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
3410 memcpy (concat_name, tmp, tmp_len);
3411 concat_name[tmp_len] = '/';
3412 strcpy (concat_name + tmp_len + 1, wrapper);
3413
3414 if (check_executable (concat_name))
3415 return concat_name;
3416 XFREE (concat_name);
3417 return NULL;
3418}
3419
3420char *
3421chase_symlinks (const char *pathspec)
3422{
3423#ifndef S_ISLNK
3424 return xstrdup (pathspec);
3425#else
3426 char buf[LT_PATHMAX];
3427 struct stat s;
3428 char *tmp_pathspec = xstrdup (pathspec);
3429 char *p;
3430 int has_symlinks = 0;
3431 while (strlen (tmp_pathspec) && !has_symlinks)
3432 {
3433 LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n",
3434 tmp_pathspec));
3435 if (lstat (tmp_pathspec, &s) == 0)
3436 {
3437 if (S_ISLNK (s.st_mode) != 0)
3438 {
3439 has_symlinks = 1;
3440 break;
3441 }
3442
3443 /* search backwards for last DIR_SEPARATOR */
3444 p = tmp_pathspec + strlen (tmp_pathspec) - 1;
3445 while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
3446 p--;
3447 if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
3448 {
3449 /* no more DIR_SEPARATORS left */
3450 break;
3451 }
3452 *p = '\0';
3453 }
3454 else
3455 {
3456 char *errstr = strerror (errno);
3457 lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr);
3458 }
3459 }
3460 XFREE (tmp_pathspec);
3461
3462 if (!has_symlinks)
3463 {
3464 return xstrdup (pathspec);
3465 }
3466
3467 tmp_pathspec = realpath (pathspec, buf);
3468 if (tmp_pathspec == 0)
3469 {
3470 lt_fatal ("Could not follow symlinks for %s", pathspec);
3471 }
3472 return xstrdup (tmp_pathspec);
3473#endif
3474}
3475
3476char *
3477strendzap (char *str, const char *pat)
3478{
3479 size_t len, patlen;
3480
3481 assert (str != NULL);
3482 assert (pat != NULL);
3483
3484 len = strlen (str);
3485 patlen = strlen (pat);
3486
3487 if (patlen <= len)
3488 {
3489 str += len - patlen;
3490 if (strcmp (str, pat) == 0)
3491 *str = '\0';
3492 }
3493 return str;
3494}
3495
3496static void
3497lt_error_core (int exit_status, const char *mode,
3498 const char *message, va_list ap)
3499{
3500 fprintf (stderr, "%s: %s: ", program_name, mode);
3501 vfprintf (stderr, message, ap);
3502 fprintf (stderr, ".\n");
3503
3504 if (exit_status >= 0)
3505 exit (exit_status);
3506}
3507
3508void
3509lt_fatal (const char *message, ...)
3510{
3511 va_list ap;
3512 va_start (ap, message);
3513 lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
3514 va_end (ap);
3515}
3516EOF
3517}
3518# end: func_emit_cwrapperexe_src
3519
3520# func_mode_link arg...
3521func_mode_link ()
3522{
3523 $opt_debug
drh71eb93e2001-09-28 01:34:43 +00003524 case $host in
3525 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
3526 # It is impossible to link a dll without this setting, and
3527 # we shouldn't force the makefile maintainer to figure out
3528 # which system we are compiling for in order to pass an extra
a.rottmann964dbb12004-02-26 19:47:42 +00003529 # flag for every libtool invocation.
drh71eb93e2001-09-28 01:34:43 +00003530 # allow_undefined=no
3531
3532 # FIXME: Unfortunately, there are problems with the above when trying
3533 # to make a dll which has undefined symbols, in which case not
3534 # even a static library is built. For now, we need to specify
3535 # -no-undefined on the libtool link line when we can be certain
3536 # that all symbols are satisfied, otherwise we get a static library.
3537 allow_undefined=yes
3538 ;;
3539 *)
3540 allow_undefined=yes
3541 ;;
3542 esac
mlcreech636a9952008-05-05 22:52:56 +00003543 libtool_args=$nonopt
a.rottmann964dbb12004-02-26 19:47:42 +00003544 base_compile="$nonopt $@"
mlcreech636a9952008-05-05 22:52:56 +00003545 compile_command=$nonopt
3546 finalize_command=$nonopt
drh71eb93e2001-09-28 01:34:43 +00003547
3548 compile_rpath=
3549 finalize_rpath=
3550 compile_shlibpath=
3551 finalize_shlibpath=
3552 convenience=
3553 old_convenience=
3554 deplibs=
3555 old_deplibs=
3556 compiler_flags=
3557 linker_flags=
3558 dllsearchpath=
3559 lib_search_path=`pwd`
a.rottmann62507b62003-03-24 09:40:34 +00003560 inst_prefix_dir=
mlcreech636a9952008-05-05 22:52:56 +00003561 new_inherited_linker_flags=
drh71eb93e2001-09-28 01:34:43 +00003562
3563 avoid_version=no
3564 dlfiles=
3565 dlprefiles=
3566 dlself=no
3567 export_dynamic=no
3568 export_symbols=
3569 export_symbols_regex=
3570 generated=
3571 libobjs=
3572 ltlibs=
3573 module=no
3574 no_install=no
3575 objs=
a.rottmann964dbb12004-02-26 19:47:42 +00003576 non_pic_objects=
3577 precious_files_regex=
drh71eb93e2001-09-28 01:34:43 +00003578 prefer_static_libs=no
3579 preload=no
3580 prev=
3581 prevarg=
3582 release=
3583 rpath=
3584 xrpath=
3585 perm_rpath=
3586 temp_rpath=
3587 thread_safe=no
3588 vinfo=
a.rottmann964dbb12004-02-26 19:47:42 +00003589 vinfo_number=no
mlcreech636a9952008-05-05 22:52:56 +00003590 weak_libs=
3591 single_module="${wl}-single_module"
vapier7f19c022007-02-17 14:46:31 +00003592 func_infer_tag $base_compile
drh71eb93e2001-09-28 01:34:43 +00003593
3594 # We need to know -static, to get the right output filenames.
3595 for arg
3596 do
3597 case $arg in
mlcreech636a9952008-05-05 22:52:56 +00003598 -shared)
3599 test "$build_libtool_libs" != yes && \
3600 func_fatal_configuration "can not build a shared library"
3601 build_old_libs=no
3602 break
3603 ;;
3604 -all-static | -static | -static-libtool-libs)
3605 case $arg in
3606 -all-static)
drh71eb93e2001-09-28 01:34:43 +00003607 if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
mlcreech636a9952008-05-05 22:52:56 +00003608 func_warning "complete static linking is impossible in this configuration"
drh71eb93e2001-09-28 01:34:43 +00003609 fi
3610 if test -n "$link_static_flag"; then
3611 dlopen_self=$dlopen_self_static
3612 fi
vapier7f19c022007-02-17 14:46:31 +00003613 prefer_static_libs=yes
mlcreech636a9952008-05-05 22:52:56 +00003614 ;;
3615 -static)
drh71eb93e2001-09-28 01:34:43 +00003616 if test -z "$pic_flag" && test -n "$link_static_flag"; then
3617 dlopen_self=$dlopen_self_static
3618 fi
vapier7f19c022007-02-17 14:46:31 +00003619 prefer_static_libs=built
mlcreech636a9952008-05-05 22:52:56 +00003620 ;;
3621 -static-libtool-libs)
3622 if test -z "$pic_flag" && test -n "$link_static_flag"; then
3623 dlopen_self=$dlopen_self_static
3624 fi
3625 prefer_static_libs=yes
3626 ;;
3627 esac
drh71eb93e2001-09-28 01:34:43 +00003628 build_libtool_libs=no
3629 build_old_libs=yes
drh71eb93e2001-09-28 01:34:43 +00003630 break
3631 ;;
3632 esac
3633 done
3634
3635 # See if our shared archives depend on static archives.
3636 test -n "$old_archive_from_new_cmds" && build_old_libs=yes
3637
3638 # Go through the arguments, transforming them on the way.
a.rottmann964dbb12004-02-26 19:47:42 +00003639 while test "$#" -gt 0; do
drh71eb93e2001-09-28 01:34:43 +00003640 arg="$1"
drh71eb93e2001-09-28 01:34:43 +00003641 shift
mlcreech636a9952008-05-05 22:52:56 +00003642 func_quote_for_eval "$arg"
3643 qarg=$func_quote_for_eval_unquoted_result
3644 func_append libtool_args " $func_quote_for_eval_result"
drh71eb93e2001-09-28 01:34:43 +00003645
3646 # If the previous option needs an argument, assign it.
3647 if test -n "$prev"; then
3648 case $prev in
3649 output)
mlcreech636a9952008-05-05 22:52:56 +00003650 func_append compile_command " @OUTPUT@"
3651 func_append finalize_command " @OUTPUT@"
drh71eb93e2001-09-28 01:34:43 +00003652 ;;
3653 esac
3654
3655 case $prev in
3656 dlfiles|dlprefiles)
3657 if test "$preload" = no; then
3658 # Add the symbol object into the linking commands.
mlcreech636a9952008-05-05 22:52:56 +00003659 func_append compile_command " @SYMFILE@"
3660 func_append finalize_command " @SYMFILE@"
drh71eb93e2001-09-28 01:34:43 +00003661 preload=yes
3662 fi
3663 case $arg in
3664 *.la | *.lo) ;; # We handle these cases below.
3665 force)
3666 if test "$dlself" = no; then
3667 dlself=needless
3668 export_dynamic=yes
3669 fi
3670 prev=
3671 continue
3672 ;;
3673 self)
3674 if test "$prev" = dlprefiles; then
3675 dlself=yes
3676 elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
3677 dlself=yes
3678 else
3679 dlself=needless
3680 export_dynamic=yes
3681 fi
3682 prev=
3683 continue
3684 ;;
3685 *)
3686 if test "$prev" = dlfiles; then
3687 dlfiles="$dlfiles $arg"
3688 else
3689 dlprefiles="$dlprefiles $arg"
3690 fi
3691 prev=
3692 continue
3693 ;;
3694 esac
3695 ;;
3696 expsyms)
3697 export_symbols="$arg"
mlcreech636a9952008-05-05 22:52:56 +00003698 test -f "$arg" \
3699 || func_fatal_error "symbol file \`$arg' does not exist"
drh71eb93e2001-09-28 01:34:43 +00003700 prev=
3701 continue
3702 ;;
3703 expsyms_regex)
3704 export_symbols_regex="$arg"
3705 prev=
3706 continue
3707 ;;
mlcreech636a9952008-05-05 22:52:56 +00003708 framework)
3709 case $host in
3710 *-*-darwin*)
3711 case "$deplibs " in
3712 *" $qarg.ltframework "*) ;;
3713 *) deplibs="$deplibs $qarg.ltframework" # this is fixed later
3714 ;;
3715 esac
3716 ;;
3717 esac
3718 prev=
3719 continue
3720 ;;
a.rottmann62507b62003-03-24 09:40:34 +00003721 inst_prefix)
3722 inst_prefix_dir="$arg"
drh71eb93e2001-09-28 01:34:43 +00003723 prev=
3724 continue
3725 ;;
a.rottmann964dbb12004-02-26 19:47:42 +00003726 objectlist)
3727 if test -f "$arg"; then
3728 save_arg=$arg
3729 moreargs=
mlcreech636a9952008-05-05 22:52:56 +00003730 for fil in `cat "$save_arg"`
a.rottmann964dbb12004-02-26 19:47:42 +00003731 do
3732# moreargs="$moreargs $fil"
3733 arg=$fil
3734 # A libtool-controlled object.
3735
3736 # Check to see that this really is a libtool object.
mlcreech636a9952008-05-05 22:52:56 +00003737 if func_lalib_unsafe_p "$arg"; then
a.rottmann964dbb12004-02-26 19:47:42 +00003738 pic_object=
3739 non_pic_object=
3740
3741 # Read the .lo file
mlcreech636a9952008-05-05 22:52:56 +00003742 func_source "$arg"
a.rottmann964dbb12004-02-26 19:47:42 +00003743
mlcreech636a9952008-05-05 22:52:56 +00003744 if test -z "$pic_object" ||
a.rottmann964dbb12004-02-26 19:47:42 +00003745 test -z "$non_pic_object" ||
mlcreech636a9952008-05-05 22:52:56 +00003746 test "$pic_object" = none &&
a.rottmann964dbb12004-02-26 19:47:42 +00003747 test "$non_pic_object" = none; then
mlcreech636a9952008-05-05 22:52:56 +00003748 func_fatal_error "cannot find name of object for \`$arg'"
a.rottmann964dbb12004-02-26 19:47:42 +00003749 fi
3750
3751 # Extract subdirectory from the argument.
mlcreech636a9952008-05-05 22:52:56 +00003752 func_dirname "$arg" "/" ""
3753 xdir="$func_dirname_result"
a.rottmann964dbb12004-02-26 19:47:42 +00003754
3755 if test "$pic_object" != none; then
3756 # Prepend the subdirectory the object is found in.
3757 pic_object="$xdir$pic_object"
3758
3759 if test "$prev" = dlfiles; then
3760 if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
3761 dlfiles="$dlfiles $pic_object"
3762 prev=
3763 continue
3764 else
3765 # If libtool objects are unsupported, then we need to preload.
3766 prev=dlprefiles
3767 fi
3768 fi
3769
3770 # CHECK ME: I think I busted this. -Ossama
3771 if test "$prev" = dlprefiles; then
3772 # Preload the old-style object.
3773 dlprefiles="$dlprefiles $pic_object"
3774 prev=
3775 fi
3776
3777 # A PIC object.
mlcreech636a9952008-05-05 22:52:56 +00003778 func_append libobjs " $pic_object"
a.rottmann964dbb12004-02-26 19:47:42 +00003779 arg="$pic_object"
3780 fi
3781
3782 # Non-PIC object.
3783 if test "$non_pic_object" != none; then
3784 # Prepend the subdirectory the object is found in.
3785 non_pic_object="$xdir$non_pic_object"
3786
3787 # A standard non-PIC object
mlcreech636a9952008-05-05 22:52:56 +00003788 func_append non_pic_objects " $non_pic_object"
a.rottmann964dbb12004-02-26 19:47:42 +00003789 if test -z "$pic_object" || test "$pic_object" = none ; then
3790 arg="$non_pic_object"
3791 fi
vapier7f19c022007-02-17 14:46:31 +00003792 else
3793 # If the PIC object exists, use it instead.
3794 # $xdir was prepended to $pic_object above.
3795 non_pic_object="$pic_object"
mlcreech636a9952008-05-05 22:52:56 +00003796 func_append non_pic_objects " $non_pic_object"
a.rottmann964dbb12004-02-26 19:47:42 +00003797 fi
3798 else
3799 # Only an error if not doing a dry-run.
mlcreech636a9952008-05-05 22:52:56 +00003800 if $opt_dry_run; then
a.rottmann964dbb12004-02-26 19:47:42 +00003801 # Extract subdirectory from the argument.
mlcreech636a9952008-05-05 22:52:56 +00003802 func_dirname "$arg" "/" ""
3803 xdir="$func_dirname_result"
a.rottmann964dbb12004-02-26 19:47:42 +00003804
mlcreech636a9952008-05-05 22:52:56 +00003805 func_lo2o "$arg"
3806 pic_object=$xdir$objdir/$func_lo2o_result
3807 non_pic_object=$xdir$func_lo2o_result
3808 func_append libobjs " $pic_object"
3809 func_append non_pic_objects " $non_pic_object"
3810 else
3811 func_fatal_error "\`$arg' is not a valid libtool object"
a.rottmann964dbb12004-02-26 19:47:42 +00003812 fi
3813 fi
3814 done
3815 else
mlcreech636a9952008-05-05 22:52:56 +00003816 func_fatal_error "link input file \`$arg' does not exist"
a.rottmann964dbb12004-02-26 19:47:42 +00003817 fi
3818 arg=$save_arg
3819 prev=
3820 continue
3821 ;;
mlcreech636a9952008-05-05 22:52:56 +00003822 precious_regex)
3823 precious_files_regex="$arg"
3824 prev=
3825 continue
3826 ;;
3827 release)
3828 release="-$arg"
3829 prev=
3830 continue
3831 ;;
drh71eb93e2001-09-28 01:34:43 +00003832 rpath | xrpath)
3833 # We need an absolute path.
3834 case $arg in
3835 [\\/]* | [A-Za-z]:[\\/]*) ;;
3836 *)
mlcreech636a9952008-05-05 22:52:56 +00003837 func_fatal_error "only absolute run-paths are allowed"
drh71eb93e2001-09-28 01:34:43 +00003838 ;;
3839 esac
3840 if test "$prev" = rpath; then
3841 case "$rpath " in
3842 *" $arg "*) ;;
3843 *) rpath="$rpath $arg" ;;
3844 esac
3845 else
3846 case "$xrpath " in
3847 *" $arg "*) ;;
3848 *) xrpath="$xrpath $arg" ;;
3849 esac
3850 fi
3851 prev=
3852 continue
3853 ;;
mlcreech636a9952008-05-05 22:52:56 +00003854 shrext)
3855 shrext_cmds="$arg"
drh71eb93e2001-09-28 01:34:43 +00003856 prev=
drh71eb93e2001-09-28 01:34:43 +00003857 continue
3858 ;;
mlcreech636a9952008-05-05 22:52:56 +00003859 weak)
3860 weak_libs="$weak_libs $arg"
drh71eb93e2001-09-28 01:34:43 +00003861 prev=
drh71eb93e2001-09-28 01:34:43 +00003862 continue
3863 ;;
a.rottmann964dbb12004-02-26 19:47:42 +00003864 xcclinker)
3865 linker_flags="$linker_flags $qarg"
3866 compiler_flags="$compiler_flags $qarg"
3867 prev=
mlcreech636a9952008-05-05 22:52:56 +00003868 func_append compile_command " $qarg"
3869 func_append finalize_command " $qarg"
a.rottmann964dbb12004-02-26 19:47:42 +00003870 continue
3871 ;;
mlcreech636a9952008-05-05 22:52:56 +00003872 xcompiler)
3873 compiler_flags="$compiler_flags $qarg"
vapier7f19c022007-02-17 14:46:31 +00003874 prev=
mlcreech636a9952008-05-05 22:52:56 +00003875 func_append compile_command " $qarg"
3876 func_append finalize_command " $qarg"
vapier7f19c022007-02-17 14:46:31 +00003877 continue
3878 ;;
mlcreech636a9952008-05-05 22:52:56 +00003879 xlinker)
3880 linker_flags="$linker_flags $qarg"
3881 compiler_flags="$compiler_flags $wl$qarg"
vapier7f19c022007-02-17 14:46:31 +00003882 prev=
mlcreech636a9952008-05-05 22:52:56 +00003883 func_append compile_command " $wl$qarg"
3884 func_append finalize_command " $wl$qarg"
vapier7f19c022007-02-17 14:46:31 +00003885 continue
3886 ;;
drh71eb93e2001-09-28 01:34:43 +00003887 *)
3888 eval "$prev=\"\$arg\""
3889 prev=
3890 continue
3891 ;;
3892 esac
a.rottmann964dbb12004-02-26 19:47:42 +00003893 fi # test -n "$prev"
drh71eb93e2001-09-28 01:34:43 +00003894
3895 prevarg="$arg"
3896
3897 case $arg in
3898 -all-static)
3899 if test -n "$link_static_flag"; then
mlcreech636a9952008-05-05 22:52:56 +00003900 # See comment for -static flag below, for more details.
3901 func_append compile_command " $link_static_flag"
3902 func_append finalize_command " $link_static_flag"
drh71eb93e2001-09-28 01:34:43 +00003903 fi
3904 continue
3905 ;;
3906
3907 -allow-undefined)
3908 # FIXME: remove this flag sometime in the future.
mlcreech636a9952008-05-05 22:52:56 +00003909 func_fatal_error "\`-allow-undefined' must not be used because it is the default"
drh71eb93e2001-09-28 01:34:43 +00003910 ;;
3911
3912 -avoid-version)
3913 avoid_version=yes
3914 continue
3915 ;;
3916
3917 -dlopen)
3918 prev=dlfiles
3919 continue
3920 ;;
3921
3922 -dlpreopen)
3923 prev=dlprefiles
3924 continue
3925 ;;
3926
3927 -export-dynamic)
3928 export_dynamic=yes
3929 continue
3930 ;;
3931
3932 -export-symbols | -export-symbols-regex)
3933 if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
mlcreech636a9952008-05-05 22:52:56 +00003934 func_fatal_error "more than one -exported-symbols argument is not allowed"
drh71eb93e2001-09-28 01:34:43 +00003935 fi
3936 if test "X$arg" = "X-export-symbols"; then
3937 prev=expsyms
3938 else
3939 prev=expsyms_regex
3940 fi
3941 continue
3942 ;;
3943
mlcreech636a9952008-05-05 22:52:56 +00003944 -framework)
3945 prev=framework
vapier7f19c022007-02-17 14:46:31 +00003946 continue
3947 ;;
3948
a.rottmann62507b62003-03-24 09:40:34 +00003949 -inst-prefix-dir)
a.rottmann964dbb12004-02-26 19:47:42 +00003950 prev=inst_prefix
3951 continue
3952 ;;
a.rottmann62507b62003-03-24 09:40:34 +00003953
drh71eb93e2001-09-28 01:34:43 +00003954 # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
3955 # so, if we see these flags be careful not to treat them like -L
3956 -L[A-Z][A-Z]*:*)
3957 case $with_gcc/$host in
a.rottmann964dbb12004-02-26 19:47:42 +00003958 no/*-*-irix* | /*-*-irix*)
mlcreech636a9952008-05-05 22:52:56 +00003959 func_append compile_command " $arg"
3960 func_append finalize_command " $arg"
drh71eb93e2001-09-28 01:34:43 +00003961 ;;
3962 esac
3963 continue
3964 ;;
3965
3966 -L*)
mlcreech636a9952008-05-05 22:52:56 +00003967 func_stripname '-L' '' "$arg"
3968 dir=$func_stripname_result
drh71eb93e2001-09-28 01:34:43 +00003969 # We need an absolute path.
3970 case $dir in
3971 [\\/]* | [A-Za-z]:[\\/]*) ;;
3972 *)
3973 absdir=`cd "$dir" && pwd`
mlcreech636a9952008-05-05 22:52:56 +00003974 test -z "$absdir" && \
3975 func_fatal_error "cannot determine absolute directory name of \`$dir'"
drh71eb93e2001-09-28 01:34:43 +00003976 dir="$absdir"
3977 ;;
3978 esac
3979 case "$deplibs " in
3980 *" -L$dir "*) ;;
3981 *)
3982 deplibs="$deplibs -L$dir"
3983 lib_search_path="$lib_search_path $dir"
3984 ;;
3985 esac
3986 case $host in
3987 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
mlcreech636a9952008-05-05 22:52:56 +00003988 testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'`
drh71eb93e2001-09-28 01:34:43 +00003989 case :$dllsearchpath: in
3990 *":$dir:"*) ;;
3991 *) dllsearchpath="$dllsearchpath:$dir";;
3992 esac
vapier7f19c022007-02-17 14:46:31 +00003993 case :$dllsearchpath: in
3994 *":$testbindir:"*) ;;
3995 *) dllsearchpath="$dllsearchpath:$testbindir";;
3996 esac
drh71eb93e2001-09-28 01:34:43 +00003997 ;;
3998 esac
3999 continue
4000 ;;
4001
4002 -l*)
4003 if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
4004 case $host in
vapier7f19c022007-02-17 14:46:31 +00004005 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
drh71eb93e2001-09-28 01:34:43 +00004006 # These systems don't actually have a C or math library (as such)
4007 continue
4008 ;;
vapier7f19c022007-02-17 14:46:31 +00004009 *-*-os2*)
drh71eb93e2001-09-28 01:34:43 +00004010 # These systems don't actually have a C library (as such)
4011 test "X$arg" = "X-lc" && continue
4012 ;;
vapier7f19c022007-02-17 14:46:31 +00004013 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
a.rottmann62507b62003-03-24 09:40:34 +00004014 # Do not include libc due to us having libc/libc_r.
4015 test "X$arg" = "X-lc" && continue
4016 ;;
a.rottmann964dbb12004-02-26 19:47:42 +00004017 *-*-rhapsody* | *-*-darwin1.[012])
4018 # Rhapsody C and math libraries are in the System framework
mlcreech636a9952008-05-05 22:52:56 +00004019 deplibs="$deplibs System.ltframework"
drh71eb93e2001-09-28 01:34:43 +00004020 continue
vapier7f19c022007-02-17 14:46:31 +00004021 ;;
4022 *-*-sco3.2v5* | *-*-sco5v6*)
4023 # Causes problems with __ctype
4024 test "X$arg" = "X-lc" && continue
4025 ;;
4026 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
4027 # Compiler inserts libc in the correct place for threads to work
4028 test "X$arg" = "X-lc" && continue
4029 ;;
drh71eb93e2001-09-28 01:34:43 +00004030 esac
a.rottmann964dbb12004-02-26 19:47:42 +00004031 elif test "X$arg" = "X-lc_r"; then
4032 case $host in
vapier7f19c022007-02-17 14:46:31 +00004033 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
a.rottmann964dbb12004-02-26 19:47:42 +00004034 # Do not include libc_r directly, use -pthread flag.
4035 continue
4036 ;;
4037 esac
drh71eb93e2001-09-28 01:34:43 +00004038 fi
drh71eb93e2001-09-28 01:34:43 +00004039 deplibs="$deplibs $arg"
4040 continue
4041 ;;
4042
4043 -module)
4044 module=yes
4045 continue
4046 ;;
4047
mlcreech636a9952008-05-05 22:52:56 +00004048 # Tru64 UNIX uses -model [arg] to determine the layout of C++
4049 # classes, name mangling, and exception handling.
4050 # Darwin uses the -arch flag to determine output architecture.
4051 -model|-arch|-isysroot)
4052 compiler_flags="$compiler_flags $arg"
4053 func_append compile_command " $arg"
4054 func_append finalize_command " $arg"
4055 prev=xcompiler
4056 continue
4057 ;;
vapier7f19c022007-02-17 14:46:31 +00004058
mlcreech636a9952008-05-05 22:52:56 +00004059 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
4060 compiler_flags="$compiler_flags $arg"
4061 func_append compile_command " $arg"
4062 func_append finalize_command " $arg"
4063 case "$new_inherited_linker_flags " in
4064 *" $arg "*) ;;
4065 * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
a.rottmann964dbb12004-02-26 19:47:42 +00004066 esac
mlcreech636a9952008-05-05 22:52:56 +00004067 continue
4068 ;;
a.rottmann964dbb12004-02-26 19:47:42 +00004069
mlcreech636a9952008-05-05 22:52:56 +00004070 -multi_module)
4071 single_module="${wl}-multi_module"
a.rottmann964dbb12004-02-26 19:47:42 +00004072 continue
4073 ;;
4074
drh71eb93e2001-09-28 01:34:43 +00004075 -no-fast-install)
4076 fast_install=no
4077 continue
4078 ;;
4079
4080 -no-install)
4081 case $host in
mlcreech636a9952008-05-05 22:52:56 +00004082 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin*)
drh71eb93e2001-09-28 01:34:43 +00004083 # The PATH hackery in wrapper scripts is required on Windows
mlcreech636a9952008-05-05 22:52:56 +00004084 # and Darwin in order for the loader to find any dlls it needs.
4085 func_warning "\`-no-install' is ignored for $host"
4086 func_warning "assuming \`-no-fast-install' instead"
drh71eb93e2001-09-28 01:34:43 +00004087 fast_install=no
4088 ;;
4089 *) no_install=yes ;;
4090 esac
4091 continue
4092 ;;
4093
4094 -no-undefined)
4095 allow_undefined=no
4096 continue
4097 ;;
4098
a.rottmann964dbb12004-02-26 19:47:42 +00004099 -objectlist)
4100 prev=objectlist
4101 continue
4102 ;;
4103
drh71eb93e2001-09-28 01:34:43 +00004104 -o) prev=output ;;
4105
a.rottmann964dbb12004-02-26 19:47:42 +00004106 -precious-files-regex)
4107 prev=precious_regex
4108 continue
4109 ;;
4110
drh71eb93e2001-09-28 01:34:43 +00004111 -release)
4112 prev=release
4113 continue
4114 ;;
4115
4116 -rpath)
4117 prev=rpath
4118 continue
4119 ;;
4120
4121 -R)
4122 prev=xrpath
4123 continue
4124 ;;
4125
4126 -R*)
mlcreech636a9952008-05-05 22:52:56 +00004127 func_stripname '-R' '' "$arg"
4128 dir=$func_stripname_result
drh71eb93e2001-09-28 01:34:43 +00004129 # We need an absolute path.
4130 case $dir in
4131 [\\/]* | [A-Za-z]:[\\/]*) ;;
4132 *)
mlcreech636a9952008-05-05 22:52:56 +00004133 func_fatal_error "only absolute run-paths are allowed"
drh71eb93e2001-09-28 01:34:43 +00004134 ;;
4135 esac
4136 case "$xrpath " in
4137 *" $dir "*) ;;
4138 *) xrpath="$xrpath $dir" ;;
4139 esac
4140 continue
4141 ;;
4142
mlcreech636a9952008-05-05 22:52:56 +00004143 -shared)
4144 # The effects of -shared are defined in a previous loop.
4145 continue
4146 ;;
4147
4148 -shrext)
4149 prev=shrext
4150 continue
4151 ;;
4152
4153 -static | -static-libtool-libs)
drh71eb93e2001-09-28 01:34:43 +00004154 # The effects of -static are defined in a previous loop.
4155 # We used to do the same as -all-static on platforms that
4156 # didn't have a PIC flag, but the assumption that the effects
4157 # would be equivalent was wrong. It would break on at least
4158 # Digital Unix and AIX.
4159 continue
4160 ;;
4161
4162 -thread-safe)
4163 thread_safe=yes
4164 continue
4165 ;;
4166
4167 -version-info)
4168 prev=vinfo
4169 continue
4170 ;;
mlcreech636a9952008-05-05 22:52:56 +00004171
a.rottmann964dbb12004-02-26 19:47:42 +00004172 -version-number)
4173 prev=vinfo
4174 vinfo_number=yes
4175 continue
4176 ;;
drh71eb93e2001-09-28 01:34:43 +00004177
mlcreech636a9952008-05-05 22:52:56 +00004178 -weak)
4179 prev=weak
4180 continue
4181 ;;
4182
drh71eb93e2001-09-28 01:34:43 +00004183 -Wc,*)
mlcreech636a9952008-05-05 22:52:56 +00004184 func_stripname '-Wc,' '' "$arg"
4185 args=$func_stripname_result
drh71eb93e2001-09-28 01:34:43 +00004186 arg=
a.rottmann62507b62003-03-24 09:40:34 +00004187 save_ifs="$IFS"; IFS=','
drh71eb93e2001-09-28 01:34:43 +00004188 for flag in $args; do
4189 IFS="$save_ifs"
mlcreech636a9952008-05-05 22:52:56 +00004190 func_quote_for_eval "$flag"
4191 arg="$arg $wl$func_quote_for_eval_result"
4192 compiler_flags="$compiler_flags $func_quote_for_eval_result"
drh71eb93e2001-09-28 01:34:43 +00004193 done
4194 IFS="$save_ifs"
mlcreech636a9952008-05-05 22:52:56 +00004195 func_stripname ' ' '' "$arg"
4196 arg=$func_stripname_result
drh71eb93e2001-09-28 01:34:43 +00004197 ;;
4198
4199 -Wl,*)
mlcreech636a9952008-05-05 22:52:56 +00004200 func_stripname '-Wl,' '' "$arg"
4201 args=$func_stripname_result
drh71eb93e2001-09-28 01:34:43 +00004202 arg=
a.rottmann62507b62003-03-24 09:40:34 +00004203 save_ifs="$IFS"; IFS=','
drh71eb93e2001-09-28 01:34:43 +00004204 for flag in $args; do
4205 IFS="$save_ifs"
mlcreech636a9952008-05-05 22:52:56 +00004206 func_quote_for_eval "$flag"
4207 arg="$arg $wl$func_quote_for_eval_result"
4208 compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
4209 linker_flags="$linker_flags $func_quote_for_eval_result"
drh71eb93e2001-09-28 01:34:43 +00004210 done
4211 IFS="$save_ifs"
mlcreech636a9952008-05-05 22:52:56 +00004212 func_stripname ' ' '' "$arg"
4213 arg=$func_stripname_result
drh71eb93e2001-09-28 01:34:43 +00004214 ;;
4215
4216 -Xcompiler)
4217 prev=xcompiler
4218 continue
4219 ;;
4220
4221 -Xlinker)
4222 prev=xlinker
4223 continue
4224 ;;
4225
a.rottmann964dbb12004-02-26 19:47:42 +00004226 -XCClinker)
4227 prev=xcclinker
4228 continue
4229 ;;
4230
mlcreech636a9952008-05-05 22:52:56 +00004231 # -msg_* for osf cc
4232 -msg_*)
4233 func_quote_for_eval "$arg"
4234 arg="$func_quote_for_eval_result"
4235 ;;
4236
4237 # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
4238 # -r[0-9][0-9]* specifies the processor on the SGI compiler
4239 # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
4240 # +DA*, +DD* enable 64-bit mode on the HP compiler
4241 # -q* pass through compiler args for the IBM compiler
4242 # -m*, -t[45]*, -txscale* pass through architecture-specific
4243 # compiler args for GCC
4244 # -F/path gives path to uninstalled frameworks, gcc on darwin
4245 # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
4246 # @file GCC response files
4247 -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
4248 -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
4249 func_quote_for_eval "$arg"
4250 arg="$func_quote_for_eval_result"
4251 func_append compile_command " $arg"
4252 func_append finalize_command " $arg"
4253 compiler_flags="$compiler_flags $arg"
4254 continue
4255 ;;
4256
drh71eb93e2001-09-28 01:34:43 +00004257 # Some other compiler flag.
4258 -* | +*)
mlcreech636a9952008-05-05 22:52:56 +00004259 func_quote_for_eval "$arg"
4260 arg="$func_quote_for_eval_result"
drh71eb93e2001-09-28 01:34:43 +00004261 ;;
4262
a.rottmann964dbb12004-02-26 19:47:42 +00004263 *.$objext)
4264 # A standard object.
4265 objs="$objs $arg"
4266 ;;
drh71eb93e2001-09-28 01:34:43 +00004267
a.rottmann964dbb12004-02-26 19:47:42 +00004268 *.lo)
4269 # A libtool-controlled object.
4270
4271 # Check to see that this really is a libtool object.
mlcreech636a9952008-05-05 22:52:56 +00004272 if func_lalib_unsafe_p "$arg"; then
a.rottmann964dbb12004-02-26 19:47:42 +00004273 pic_object=
4274 non_pic_object=
4275
4276 # Read the .lo file
mlcreech636a9952008-05-05 22:52:56 +00004277 func_source "$arg"
a.rottmann964dbb12004-02-26 19:47:42 +00004278
mlcreech636a9952008-05-05 22:52:56 +00004279 if test -z "$pic_object" ||
a.rottmann964dbb12004-02-26 19:47:42 +00004280 test -z "$non_pic_object" ||
mlcreech636a9952008-05-05 22:52:56 +00004281 test "$pic_object" = none &&
a.rottmann964dbb12004-02-26 19:47:42 +00004282 test "$non_pic_object" = none; then
mlcreech636a9952008-05-05 22:52:56 +00004283 func_fatal_error "cannot find name of object for \`$arg'"
a.rottmann964dbb12004-02-26 19:47:42 +00004284 fi
4285
4286 # Extract subdirectory from the argument.
mlcreech636a9952008-05-05 22:52:56 +00004287 func_dirname "$arg" "/" ""
4288 xdir="$func_dirname_result"
a.rottmann964dbb12004-02-26 19:47:42 +00004289
4290 if test "$pic_object" != none; then
4291 # Prepend the subdirectory the object is found in.
4292 pic_object="$xdir$pic_object"
4293
4294 if test "$prev" = dlfiles; then
4295 if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
4296 dlfiles="$dlfiles $pic_object"
4297 prev=
4298 continue
4299 else
4300 # If libtool objects are unsupported, then we need to preload.
4301 prev=dlprefiles
4302 fi
4303 fi
4304
4305 # CHECK ME: I think I busted this. -Ossama
4306 if test "$prev" = dlprefiles; then
4307 # Preload the old-style object.
4308 dlprefiles="$dlprefiles $pic_object"
4309 prev=
4310 fi
4311
4312 # A PIC object.
mlcreech636a9952008-05-05 22:52:56 +00004313 func_append libobjs " $pic_object"
a.rottmann964dbb12004-02-26 19:47:42 +00004314 arg="$pic_object"
4315 fi
4316
4317 # Non-PIC object.
4318 if test "$non_pic_object" != none; then
4319 # Prepend the subdirectory the object is found in.
4320 non_pic_object="$xdir$non_pic_object"
4321
4322 # A standard non-PIC object
mlcreech636a9952008-05-05 22:52:56 +00004323 func_append non_pic_objects " $non_pic_object"
a.rottmann964dbb12004-02-26 19:47:42 +00004324 if test -z "$pic_object" || test "$pic_object" = none ; then
4325 arg="$non_pic_object"
4326 fi
vapier7f19c022007-02-17 14:46:31 +00004327 else
4328 # If the PIC object exists, use it instead.
4329 # $xdir was prepended to $pic_object above.
4330 non_pic_object="$pic_object"
mlcreech636a9952008-05-05 22:52:56 +00004331 func_append non_pic_objects " $non_pic_object"
a.rottmann964dbb12004-02-26 19:47:42 +00004332 fi
4333 else
4334 # Only an error if not doing a dry-run.
mlcreech636a9952008-05-05 22:52:56 +00004335 if $opt_dry_run; then
a.rottmann964dbb12004-02-26 19:47:42 +00004336 # Extract subdirectory from the argument.
mlcreech636a9952008-05-05 22:52:56 +00004337 func_dirname "$arg" "/" ""
4338 xdir="$func_dirname_result"
a.rottmann964dbb12004-02-26 19:47:42 +00004339
mlcreech636a9952008-05-05 22:52:56 +00004340 func_lo2o "$arg"
4341 pic_object=$xdir$objdir/$func_lo2o_result
4342 non_pic_object=$xdir$func_lo2o_result
4343 func_append libobjs " $pic_object"
4344 func_append non_pic_objects " $non_pic_object"
4345 else
4346 func_fatal_error "\`$arg' is not a valid libtool object"
a.rottmann964dbb12004-02-26 19:47:42 +00004347 fi
drh71eb93e2001-09-28 01:34:43 +00004348 fi
4349 ;;
4350
4351 *.$libext)
4352 # An archive.
4353 deplibs="$deplibs $arg"
4354 old_deplibs="$old_deplibs $arg"
4355 continue
4356 ;;
4357
4358 *.la)
4359 # A libtool-controlled library.
4360
4361 if test "$prev" = dlfiles; then
4362 # This library was specified with -dlopen.
4363 dlfiles="$dlfiles $arg"
4364 prev=
4365 elif test "$prev" = dlprefiles; then
4366 # The library was specified with -dlpreopen.
4367 dlprefiles="$dlprefiles $arg"
4368 prev=
4369 else
4370 deplibs="$deplibs $arg"
4371 fi
4372 continue
4373 ;;
4374
4375 # Some other compiler argument.
4376 *)
4377 # Unknown arguments in both finalize_command and compile_command need
4378 # to be aesthetically quoted because they are evaled later.
mlcreech636a9952008-05-05 22:52:56 +00004379 func_quote_for_eval "$arg"
4380 arg="$func_quote_for_eval_result"
drh71eb93e2001-09-28 01:34:43 +00004381 ;;
4382 esac # arg
4383
4384 # Now actually substitute the argument into the commands.
4385 if test -n "$arg"; then
mlcreech636a9952008-05-05 22:52:56 +00004386 func_append compile_command " $arg"
4387 func_append finalize_command " $arg"
drh71eb93e2001-09-28 01:34:43 +00004388 fi
4389 done # argument parsing loop
4390
mlcreech636a9952008-05-05 22:52:56 +00004391 test -n "$prev" && \
4392 func_fatal_help "the \`$prevarg' option requires an argument"
drh71eb93e2001-09-28 01:34:43 +00004393
drh71eb93e2001-09-28 01:34:43 +00004394 if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
4395 eval arg=\"$export_dynamic_flag_spec\"
mlcreech636a9952008-05-05 22:52:56 +00004396 func_append compile_command " $arg"
4397 func_append finalize_command " $arg"
drh71eb93e2001-09-28 01:34:43 +00004398 fi
4399
a.rottmann964dbb12004-02-26 19:47:42 +00004400 oldlibs=
drh71eb93e2001-09-28 01:34:43 +00004401 # calculate the name of the file, without its directory
mlcreech636a9952008-05-05 22:52:56 +00004402 func_basename "$output"
4403 outputname="$func_basename_result"
drh71eb93e2001-09-28 01:34:43 +00004404 libobjs_save="$libobjs"
4405
4406 if test -n "$shlibpath_var"; then
4407 # get the directories listed in $shlibpath_var
mlcreech636a9952008-05-05 22:52:56 +00004408 eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
drh71eb93e2001-09-28 01:34:43 +00004409 else
4410 shlib_search_path=
4411 fi
4412 eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
4413 eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
4414
mlcreech636a9952008-05-05 22:52:56 +00004415 func_dirname "$output" "/" ""
4416 output_objdir="$func_dirname_result$objdir"
drh71eb93e2001-09-28 01:34:43 +00004417 # Create the object directory.
mlcreech636a9952008-05-05 22:52:56 +00004418 func_mkdir_p "$output_objdir"
drh71eb93e2001-09-28 01:34:43 +00004419
4420 # Determine the type of output
4421 case $output in
4422 "")
mlcreech636a9952008-05-05 22:52:56 +00004423 func_fatal_help "you must specify an output file"
drh71eb93e2001-09-28 01:34:43 +00004424 ;;
4425 *.$libext) linkmode=oldlib ;;
4426 *.lo | *.$objext) linkmode=obj ;;
4427 *.la) linkmode=lib ;;
4428 *) linkmode=prog ;; # Anything else should be a program.
4429 esac
4430
4431 specialdeplibs=
a.rottmann964dbb12004-02-26 19:47:42 +00004432
drh71eb93e2001-09-28 01:34:43 +00004433 libs=
4434 # Find all interdependent deplibs by searching for libraries
4435 # that are linked more than once (e.g. -la -lb -la)
4436 for deplib in $deplibs; do
mlcreech636a9952008-05-05 22:52:56 +00004437 if $opt_duplicate_deps ; then
a.rottmann62507b62003-03-24 09:40:34 +00004438 case "$libs " in
4439 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
4440 esac
4441 fi
drh71eb93e2001-09-28 01:34:43 +00004442 libs="$libs $deplib"
4443 done
a.rottmann964dbb12004-02-26 19:47:42 +00004444
4445 if test "$linkmode" = lib; then
4446 libs="$predeps $libs $compiler_lib_search_path $postdeps"
4447
4448 # Compute libraries that are listed more than once in $predeps
4449 # $postdeps and mark them as special (i.e., whose duplicates are
4450 # not to be eliminated).
4451 pre_post_deps=
mlcreech636a9952008-05-05 22:52:56 +00004452 if $opt_duplicate_compiler_generated_deps; then
a.rottmann964dbb12004-02-26 19:47:42 +00004453 for pre_post_dep in $predeps $postdeps; do
4454 case "$pre_post_deps " in
4455 *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
4456 esac
4457 pre_post_deps="$pre_post_deps $pre_post_dep"
4458 done
4459 fi
4460 pre_post_deps=
4461 fi
4462
drh71eb93e2001-09-28 01:34:43 +00004463 deplibs=
4464 newdependency_libs=
4465 newlib_search_path=
4466 need_relink=no # whether we're linking any uninstalled libtool libraries
4467 notinst_deplibs= # not-installed libtool libraries
mlcreech636a9952008-05-05 22:52:56 +00004468 notinst_path= # paths that contain not-installed libtool libraries
4469
drh71eb93e2001-09-28 01:34:43 +00004470 case $linkmode in
4471 lib)
mlcreech636a9952008-05-05 22:52:56 +00004472 passes="conv dlpreopen link"
drh71eb93e2001-09-28 01:34:43 +00004473 for file in $dlfiles $dlprefiles; do
4474 case $file in
4475 *.la) ;;
4476 *)
mlcreech636a9952008-05-05 22:52:56 +00004477 func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
drh71eb93e2001-09-28 01:34:43 +00004478 ;;
4479 esac
4480 done
4481 ;;
4482 prog)
4483 compile_deplibs=
4484 finalize_deplibs=
4485 alldeplibs=no
4486 newdlfiles=
4487 newdlprefiles=
4488 passes="conv scan dlopen dlpreopen link"
4489 ;;
4490 *) passes="conv"
4491 ;;
4492 esac
mlcreech636a9952008-05-05 22:52:56 +00004493
drh71eb93e2001-09-28 01:34:43 +00004494 for pass in $passes; do
mlcreech636a9952008-05-05 22:52:56 +00004495 # The preopen pass in lib mode reverses $deplibs; put it back here
4496 # so that -L comes before libs that need it for instance...
4497 if test "$linkmode,$pass" = "lib,link"; then
4498 ## FIXME: Find the place where the list is rebuilt in the wrong
4499 ## order, and fix it there properly
4500 tmp_deplibs=
4501 for deplib in $deplibs; do
4502 tmp_deplibs="$deplib $tmp_deplibs"
4503 done
4504 deplibs="$tmp_deplibs"
4505 fi
4506
a.rottmann964dbb12004-02-26 19:47:42 +00004507 if test "$linkmode,$pass" = "lib,link" ||
4508 test "$linkmode,$pass" = "prog,scan"; then
4509 libs="$deplibs"
4510 deplibs=
4511 fi
4512 if test "$linkmode" = prog; then
drh71eb93e2001-09-28 01:34:43 +00004513 case $pass in
a.rottmann964dbb12004-02-26 19:47:42 +00004514 dlopen) libs="$dlfiles" ;;
drh71eb93e2001-09-28 01:34:43 +00004515 dlpreopen) libs="$dlprefiles" ;;
4516 link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
4517 esac
4518 fi
mlcreech636a9952008-05-05 22:52:56 +00004519 if test "$linkmode,$pass" = "lib,dlpreopen"; then
4520 # Collect and forward deplibs of preopened libtool libs
4521 for lib in $dlprefiles; do
4522 # Ignore non-libtool-libs
4523 dependency_libs=
4524 case $lib in
4525 *.la) func_source "$lib" ;;
4526 esac
4527
4528 # Collect preopened libtool deplibs, except any this library
4529 # has declared as weak libs
4530 for deplib in $dependency_libs; do
4531 deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"`
4532 case " $weak_libs " in
4533 *" $deplib_base "*) ;;
4534 *) deplibs="$deplibs $deplib" ;;
4535 esac
4536 done
4537 done
4538 libs="$dlprefiles"
4539 fi
a.rottmann964dbb12004-02-26 19:47:42 +00004540 if test "$pass" = dlopen; then
4541 # Collect dlpreopened libraries
4542 save_deplibs="$deplibs"
4543 deplibs=
4544 fi
mlcreech636a9952008-05-05 22:52:56 +00004545
drh71eb93e2001-09-28 01:34:43 +00004546 for deplib in $libs; do
4547 lib=
4548 found=no
4549 case $deplib in
mlcreech636a9952008-05-05 22:52:56 +00004550 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
a.rottmann964dbb12004-02-26 19:47:42 +00004551 if test "$linkmode,$pass" = "prog,link"; then
4552 compile_deplibs="$deplib $compile_deplibs"
4553 finalize_deplibs="$deplib $finalize_deplibs"
4554 else
vapier7f19c022007-02-17 14:46:31 +00004555 compiler_flags="$compiler_flags $deplib"
mlcreech636a9952008-05-05 22:52:56 +00004556 if test "$linkmode" = lib ; then
4557 case "$new_inherited_linker_flags " in
4558 *" $deplib "*) ;;
4559 * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
4560 esac
4561 fi
a.rottmann964dbb12004-02-26 19:47:42 +00004562 fi
4563 continue
4564 ;;
drh71eb93e2001-09-28 01:34:43 +00004565 -l*)
a.rottmann964dbb12004-02-26 19:47:42 +00004566 if test "$linkmode" != lib && test "$linkmode" != prog; then
mlcreech636a9952008-05-05 22:52:56 +00004567 func_warning "\`-l' is ignored for archives/objects"
drh71eb93e2001-09-28 01:34:43 +00004568 continue
4569 fi
mlcreech636a9952008-05-05 22:52:56 +00004570 func_stripname '-l' '' "$deplib"
4571 name=$func_stripname_result
4572 if test "$linkmode" = lib; then
4573 searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
4574 else
4575 searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
4576 fi
4577 for searchdir in $searchdirs; do
vapier7f19c022007-02-17 14:46:31 +00004578 for search_ext in .la $std_shrext .so .a; do
a.rottmann964dbb12004-02-26 19:47:42 +00004579 # Search the libtool library
4580 lib="$searchdir/lib${name}${search_ext}"
4581 if test -f "$lib"; then
4582 if test "$search_ext" = ".la"; then
4583 found=yes
4584 else
4585 found=no
4586 fi
4587 break 2
4588 fi
4589 done
drh71eb93e2001-09-28 01:34:43 +00004590 done
4591 if test "$found" != yes; then
4592 # deplib doesn't seem to be a libtool library
4593 if test "$linkmode,$pass" = "prog,link"; then
4594 compile_deplibs="$deplib $compile_deplibs"
4595 finalize_deplibs="$deplib $finalize_deplibs"
4596 else
4597 deplibs="$deplib $deplibs"
a.rottmann964dbb12004-02-26 19:47:42 +00004598 test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
drh71eb93e2001-09-28 01:34:43 +00004599 fi
4600 continue
a.rottmann964dbb12004-02-26 19:47:42 +00004601 else # deplib is a libtool library
4602 # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
4603 # We need to do some special things here, and not later.
4604 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
4605 case " $predeps $postdeps " in
4606 *" $deplib "*)
mlcreech636a9952008-05-05 22:52:56 +00004607 if func_lalib_p "$lib"; then
a.rottmann964dbb12004-02-26 19:47:42 +00004608 library_names=
4609 old_library=
mlcreech636a9952008-05-05 22:52:56 +00004610 func_source "$lib"
a.rottmann964dbb12004-02-26 19:47:42 +00004611 for l in $old_library $library_names; do
4612 ll="$l"
4613 done
4614 if test "X$ll" = "X$old_library" ; then # only static version available
4615 found=no
mlcreech636a9952008-05-05 22:52:56 +00004616 func_dirname "$lib" "" "."
4617 ladir="$func_dirname_result"
a.rottmann964dbb12004-02-26 19:47:42 +00004618 lib=$ladir/$old_library
4619 if test "$linkmode,$pass" = "prog,link"; then
4620 compile_deplibs="$deplib $compile_deplibs"
4621 finalize_deplibs="$deplib $finalize_deplibs"
4622 else
4623 deplibs="$deplib $deplibs"
4624 test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
4625 fi
4626 continue
4627 fi
4628 fi
mlcreech636a9952008-05-05 22:52:56 +00004629 ;;
a.rottmann964dbb12004-02-26 19:47:42 +00004630 *) ;;
4631 esac
4632 fi
drh71eb93e2001-09-28 01:34:43 +00004633 fi
4634 ;; # -l
mlcreech636a9952008-05-05 22:52:56 +00004635 *.ltframework)
4636 if test "$linkmode,$pass" = "prog,link"; then
4637 compile_deplibs="$deplib $compile_deplibs"
4638 finalize_deplibs="$deplib $finalize_deplibs"
4639 else
4640 deplibs="$deplib $deplibs"
4641 if test "$linkmode" = lib ; then
4642 case "$new_inherited_linker_flags " in
4643 *" $deplib "*) ;;
4644 * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
4645 esac
4646 fi
4647 fi
4648 continue
4649 ;;
drh71eb93e2001-09-28 01:34:43 +00004650 -L*)
4651 case $linkmode in
4652 lib)
4653 deplibs="$deplib $deplibs"
a.rottmann964dbb12004-02-26 19:47:42 +00004654 test "$pass" = conv && continue
drh71eb93e2001-09-28 01:34:43 +00004655 newdependency_libs="$deplib $newdependency_libs"
mlcreech636a9952008-05-05 22:52:56 +00004656 func_stripname '-L' '' "$deplib"
4657 newlib_search_path="$newlib_search_path $func_stripname_result"
drh71eb93e2001-09-28 01:34:43 +00004658 ;;
4659 prog)
a.rottmann964dbb12004-02-26 19:47:42 +00004660 if test "$pass" = conv; then
drh71eb93e2001-09-28 01:34:43 +00004661 deplibs="$deplib $deplibs"
4662 continue
4663 fi
a.rottmann964dbb12004-02-26 19:47:42 +00004664 if test "$pass" = scan; then
drh71eb93e2001-09-28 01:34:43 +00004665 deplibs="$deplib $deplibs"
drh71eb93e2001-09-28 01:34:43 +00004666 else
4667 compile_deplibs="$deplib $compile_deplibs"
4668 finalize_deplibs="$deplib $finalize_deplibs"
4669 fi
mlcreech636a9952008-05-05 22:52:56 +00004670 func_stripname '-L' '' "$deplib"
4671 newlib_search_path="$newlib_search_path $func_stripname_result"
drh71eb93e2001-09-28 01:34:43 +00004672 ;;
4673 *)
mlcreech636a9952008-05-05 22:52:56 +00004674 func_warning "\`-L' is ignored for archives/objects"
drh71eb93e2001-09-28 01:34:43 +00004675 ;;
4676 esac # linkmode
4677 continue
4678 ;; # -L
4679 -R*)
a.rottmann964dbb12004-02-26 19:47:42 +00004680 if test "$pass" = link; then
mlcreech636a9952008-05-05 22:52:56 +00004681 func_stripname '-R' '' "$deplib"
4682 dir=$func_stripname_result
drh71eb93e2001-09-28 01:34:43 +00004683 # Make sure the xrpath contains only unique directories.
4684 case "$xrpath " in
4685 *" $dir "*) ;;
4686 *) xrpath="$xrpath $dir" ;;
4687 esac
4688 fi
4689 deplibs="$deplib $deplibs"
4690 continue
4691 ;;
4692 *.la) lib="$deplib" ;;
4693 *.$libext)
a.rottmann964dbb12004-02-26 19:47:42 +00004694 if test "$pass" = conv; then
drh71eb93e2001-09-28 01:34:43 +00004695 deplibs="$deplib $deplibs"
4696 continue
4697 fi
4698 case $linkmode in
4699 lib)
mlcreech636a9952008-05-05 22:52:56 +00004700 # Linking convenience modules into shared libraries is allowed,
4701 # but linking other static libraries is non-portable.
4702 case " $dlpreconveniencelibs " in
4703 *" $deplib "*) ;;
4704 *)
4705 valid_a_lib=no
4706 case $deplibs_check_method in
4707 match_pattern*)
4708 set dummy $deplibs_check_method; shift
4709 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
4710 if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \
vapier7f19c022007-02-17 14:46:31 +00004711 | $EGREP "$match_pattern_regex" > /dev/null; then
mlcreech636a9952008-05-05 22:52:56 +00004712 valid_a_lib=yes
4713 fi
4714 ;;
4715 pass_all)
vapier7f19c022007-02-17 14:46:31 +00004716 valid_a_lib=yes
vapier7f19c022007-02-17 14:46:31 +00004717 ;;
mlcreech636a9952008-05-05 22:52:56 +00004718 esac
4719 if test "$valid_a_lib" != yes; then
4720 $ECHO
4721 $ECHO "*** Warning: Trying to link with static lib archive $deplib."
4722 $ECHO "*** I have the capability to make that library automatically link in when"
4723 $ECHO "*** you link to this library. But I can only do this if you have a"
4724 $ECHO "*** shared version of the library, which you do not appear to have"
4725 $ECHO "*** because the file extensions .$libext of this argument makes me believe"
4726 $ECHO "*** that it is just a static archive that I should not use here."
4727 else
4728 $ECHO
4729 $ECHO "*** Warning: Linking the shared library $output against the"
4730 $ECHO "*** static library $deplib is not portable!"
4731 deplibs="$deplib $deplibs"
4732 fi
4733 ;;
4734 esac
drh71eb93e2001-09-28 01:34:43 +00004735 continue
4736 ;;
4737 prog)
a.rottmann964dbb12004-02-26 19:47:42 +00004738 if test "$pass" != link; then
drh71eb93e2001-09-28 01:34:43 +00004739 deplibs="$deplib $deplibs"
4740 else
4741 compile_deplibs="$deplib $compile_deplibs"
4742 finalize_deplibs="$deplib $finalize_deplibs"
4743 fi
4744 continue
4745 ;;
4746 esac # linkmode
4747 ;; # *.$libext
4748 *.lo | *.$objext)
a.rottmann964dbb12004-02-26 19:47:42 +00004749 if test "$pass" = conv; then
4750 deplibs="$deplib $deplibs"
4751 elif test "$linkmode" = prog; then
4752 if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
4753 # If there is no dlopen support or we're linking statically,
4754 # we need to preload.
4755 newdlprefiles="$newdlprefiles $deplib"
4756 compile_deplibs="$deplib $compile_deplibs"
4757 finalize_deplibs="$deplib $finalize_deplibs"
4758 else
4759 newdlfiles="$newdlfiles $deplib"
4760 fi
drh71eb93e2001-09-28 01:34:43 +00004761 fi
4762 continue
4763 ;;
4764 %DEPLIBS%)
4765 alldeplibs=yes
4766 continue
4767 ;;
4768 esac # case $deplib
mlcreech636a9952008-05-05 22:52:56 +00004769
a.rottmann964dbb12004-02-26 19:47:42 +00004770 if test "$found" = yes || test -f "$lib"; then :
drh71eb93e2001-09-28 01:34:43 +00004771 else
mlcreech636a9952008-05-05 22:52:56 +00004772 func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
drh71eb93e2001-09-28 01:34:43 +00004773 fi
4774
4775 # Check to see that this really is a libtool archive.
mlcreech636a9952008-05-05 22:52:56 +00004776 func_lalib_unsafe_p "$lib" \
4777 || func_fatal_error "\`$lib' is not a valid libtool archive"
drh71eb93e2001-09-28 01:34:43 +00004778
mlcreech636a9952008-05-05 22:52:56 +00004779 func_dirname "$lib" "" "."
4780 ladir="$func_dirname_result"
drh71eb93e2001-09-28 01:34:43 +00004781
4782 dlname=
4783 dlopen=
4784 dlpreopen=
4785 libdir=
4786 library_names=
4787 old_library=
mlcreech636a9952008-05-05 22:52:56 +00004788 inherited_linker_flags=
drh71eb93e2001-09-28 01:34:43 +00004789 # If the library was installed with an old release of libtool,
a.rottmann964dbb12004-02-26 19:47:42 +00004790 # it will not redefine variables installed, or shouldnotlink
drh71eb93e2001-09-28 01:34:43 +00004791 installed=yes
a.rottmann964dbb12004-02-26 19:47:42 +00004792 shouldnotlink=no
vapier7f19c022007-02-17 14:46:31 +00004793 avoidtemprpath=
4794
drh71eb93e2001-09-28 01:34:43 +00004795
4796 # Read the .la file
mlcreech636a9952008-05-05 22:52:56 +00004797 func_source "$lib"
drh71eb93e2001-09-28 01:34:43 +00004798
mlcreech636a9952008-05-05 22:52:56 +00004799 # Convert "-framework foo" to "foo.ltframework"
4800 if test -n "$inherited_linker_flags"; then
4801 tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'`
4802 for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
4803 case " $new_inherited_linker_flags " in
4804 *" $tmp_inherited_linker_flag "*) ;;
4805 *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
4806 esac
4807 done
4808 fi
4809 dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
drh71eb93e2001-09-28 01:34:43 +00004810 if test "$linkmode,$pass" = "lib,link" ||
4811 test "$linkmode,$pass" = "prog,scan" ||
a.rottmann964dbb12004-02-26 19:47:42 +00004812 { test "$linkmode" != prog && test "$linkmode" != lib; }; then
drh71eb93e2001-09-28 01:34:43 +00004813 test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
4814 test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
4815 fi
4816
a.rottmann964dbb12004-02-26 19:47:42 +00004817 if test "$pass" = conv; then
drh71eb93e2001-09-28 01:34:43 +00004818 # Only check for convenience libraries
4819 deplibs="$lib $deplibs"
4820 if test -z "$libdir"; then
4821 if test -z "$old_library"; then
mlcreech636a9952008-05-05 22:52:56 +00004822 func_fatal_error "cannot find name of link library for \`$lib'"
drh71eb93e2001-09-28 01:34:43 +00004823 fi
4824 # It is a libtool convenience library, so add in its objects.
4825 convenience="$convenience $ladir/$objdir/$old_library"
4826 old_convenience="$old_convenience $ladir/$objdir/$old_library"
a.rottmann964dbb12004-02-26 19:47:42 +00004827 elif test "$linkmode" != prog && test "$linkmode" != lib; then
mlcreech636a9952008-05-05 22:52:56 +00004828 func_fatal_error "\`$lib' is not a convenience library"
drh71eb93e2001-09-28 01:34:43 +00004829 fi
mlcreech636a9952008-05-05 22:52:56 +00004830 tmp_libs=
4831 for deplib in $dependency_libs; do
4832 deplibs="$deplib $deplibs"
4833 if $opt_duplicate_deps ; then
4834 case "$tmp_libs " in
4835 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
4836 esac
4837 fi
4838 tmp_libs="$tmp_libs $deplib"
4839 done
drh71eb93e2001-09-28 01:34:43 +00004840 continue
4841 fi # $pass = conv
4842
vapier7f19c022007-02-17 14:46:31 +00004843
drh71eb93e2001-09-28 01:34:43 +00004844 # Get the name of the library we link against.
4845 linklib=
4846 for l in $old_library $library_names; do
4847 linklib="$l"
4848 done
4849 if test -z "$linklib"; then
mlcreech636a9952008-05-05 22:52:56 +00004850 func_fatal_error "cannot find name of link library for \`$lib'"
drh71eb93e2001-09-28 01:34:43 +00004851 fi
4852
4853 # This library was specified with -dlopen.
a.rottmann964dbb12004-02-26 19:47:42 +00004854 if test "$pass" = dlopen; then
drh71eb93e2001-09-28 01:34:43 +00004855 if test -z "$libdir"; then
mlcreech636a9952008-05-05 22:52:56 +00004856 func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
drh71eb93e2001-09-28 01:34:43 +00004857 fi
vapier7f19c022007-02-17 14:46:31 +00004858 if test -z "$dlname" ||
4859 test "$dlopen_support" != yes ||
4860 test "$build_libtool_libs" = no; then
drh71eb93e2001-09-28 01:34:43 +00004861 # If there is no dlname, no dlopen support or we're linking
a.rottmann964dbb12004-02-26 19:47:42 +00004862 # statically, we need to preload. We also need to preload any
4863 # dependent libraries so libltdl's deplib preloader doesn't
4864 # bomb out in the load deplibs phase.
4865 dlprefiles="$dlprefiles $lib $dependency_libs"
drh71eb93e2001-09-28 01:34:43 +00004866 else
4867 newdlfiles="$newdlfiles $lib"
4868 fi
4869 continue
4870 fi # $pass = dlopen
4871
4872 # We need an absolute path.
4873 case $ladir in
4874 [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
4875 *)
4876 abs_ladir=`cd "$ladir" && pwd`
4877 if test -z "$abs_ladir"; then
mlcreech636a9952008-05-05 22:52:56 +00004878 func_warning "cannot determine absolute directory name of \`$ladir'"
4879 func_warning "passing it literally to the linker, although it might fail"
drh71eb93e2001-09-28 01:34:43 +00004880 abs_ladir="$ladir"
4881 fi
4882 ;;
4883 esac
mlcreech636a9952008-05-05 22:52:56 +00004884 func_basename "$lib"
4885 laname="$func_basename_result"
drh71eb93e2001-09-28 01:34:43 +00004886
4887 # Find the relevant object directory and library name.
4888 if test "X$installed" = Xyes; then
4889 if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
mlcreech636a9952008-05-05 22:52:56 +00004890 func_warning "library \`$lib' was moved."
drh71eb93e2001-09-28 01:34:43 +00004891 dir="$ladir"
4892 absdir="$abs_ladir"
4893 libdir="$abs_ladir"
4894 else
4895 dir="$libdir"
4896 absdir="$libdir"
4897 fi
vapier7f19c022007-02-17 14:46:31 +00004898 test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
drh71eb93e2001-09-28 01:34:43 +00004899 else
vapier7f19c022007-02-17 14:46:31 +00004900 if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
4901 dir="$ladir"
4902 absdir="$abs_ladir"
4903 # Remove this search path later
4904 notinst_path="$notinst_path $abs_ladir"
4905 else
4906 dir="$ladir/$objdir"
4907 absdir="$abs_ladir/$objdir"
4908 # Remove this search path later
4909 notinst_path="$notinst_path $abs_ladir"
4910 fi
drh71eb93e2001-09-28 01:34:43 +00004911 fi # $installed = yes
mlcreech636a9952008-05-05 22:52:56 +00004912 func_stripname 'lib' '.la' "$laname"
4913 name=$func_stripname_result
drh71eb93e2001-09-28 01:34:43 +00004914
4915 # This library was specified with -dlpreopen.
a.rottmann964dbb12004-02-26 19:47:42 +00004916 if test "$pass" = dlpreopen; then
mlcreech636a9952008-05-05 22:52:56 +00004917 if test -z "$libdir" && test "$linkmode" = prog; then
4918 func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
drh71eb93e2001-09-28 01:34:43 +00004919 fi
4920 # Prefer using a static library (so that no silly _DYNAMIC symbols
4921 # are required to link).
4922 if test -n "$old_library"; then
4923 newdlprefiles="$newdlprefiles $dir/$old_library"
mlcreech636a9952008-05-05 22:52:56 +00004924 # Keep a list of preopened convenience libraries to check
4925 # that they are being used correctly in the link pass.
4926 test -z "$libdir" && \
4927 dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
drh71eb93e2001-09-28 01:34:43 +00004928 # Otherwise, use the dlname, so that lt_dlopen finds it.
4929 elif test -n "$dlname"; then
4930 newdlprefiles="$newdlprefiles $dir/$dlname"
4931 else
4932 newdlprefiles="$newdlprefiles $dir/$linklib"
4933 fi
4934 fi # $pass = dlpreopen
4935
4936 if test -z "$libdir"; then
4937 # Link the convenience library
a.rottmann964dbb12004-02-26 19:47:42 +00004938 if test "$linkmode" = lib; then
drh71eb93e2001-09-28 01:34:43 +00004939 deplibs="$dir/$old_library $deplibs"
4940 elif test "$linkmode,$pass" = "prog,link"; then
4941 compile_deplibs="$dir/$old_library $compile_deplibs"
4942 finalize_deplibs="$dir/$old_library $finalize_deplibs"
4943 else
a.rottmann964dbb12004-02-26 19:47:42 +00004944 deplibs="$lib $deplibs" # used for prog,scan pass
drh71eb93e2001-09-28 01:34:43 +00004945 fi
4946 continue
4947 fi
4948
vapier7f19c022007-02-17 14:46:31 +00004949
a.rottmann964dbb12004-02-26 19:47:42 +00004950 if test "$linkmode" = prog && test "$pass" != link; then
drh71eb93e2001-09-28 01:34:43 +00004951 newlib_search_path="$newlib_search_path $ladir"
4952 deplibs="$lib $deplibs"
4953
4954 linkalldeplibs=no
4955 if test "$link_all_deplibs" != no || test -z "$library_names" ||
4956 test "$build_libtool_libs" = no; then
4957 linkalldeplibs=yes
4958 fi
4959
4960 tmp_libs=
4961 for deplib in $dependency_libs; do
4962 case $deplib in
mlcreech636a9952008-05-05 22:52:56 +00004963 -L*) func_stripname '-L' '' "$deplib"
4964 newlib_search_path="$newlib_search_path $func_stripname_result"
4965 ;;
drh71eb93e2001-09-28 01:34:43 +00004966 esac
4967 # Need to link against all dependency_libs?
a.rottmann964dbb12004-02-26 19:47:42 +00004968 if test "$linkalldeplibs" = yes; then
drh71eb93e2001-09-28 01:34:43 +00004969 deplibs="$deplib $deplibs"
4970 else
4971 # Need to hardcode shared library paths
4972 # or/and link against static libraries
4973 newdependency_libs="$deplib $newdependency_libs"
4974 fi
mlcreech636a9952008-05-05 22:52:56 +00004975 if $opt_duplicate_deps ; then
a.rottmann62507b62003-03-24 09:40:34 +00004976 case "$tmp_libs " in
4977 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
4978 esac
4979 fi
drh71eb93e2001-09-28 01:34:43 +00004980 tmp_libs="$tmp_libs $deplib"
4981 done # for deplib
4982 continue
4983 fi # $linkmode = prog...
4984
a.rottmann964dbb12004-02-26 19:47:42 +00004985 if test "$linkmode,$pass" = "prog,link"; then
4986 if test -n "$library_names" &&
mlcreech636a9952008-05-05 22:52:56 +00004987 { { test "$prefer_static_libs" = no ||
4988 test "$prefer_static_libs,$installed" = "built,yes"; } ||
4989 test -z "$old_library"; }; then
a.rottmann964dbb12004-02-26 19:47:42 +00004990 # We need to hardcode the library path
vapier7f19c022007-02-17 14:46:31 +00004991 if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
a.rottmann964dbb12004-02-26 19:47:42 +00004992 # Make sure the rpath contains only unique directories.
mlcreech636a9952008-05-05 22:52:56 +00004993 case "$temp_rpath:" in
4994 *"$absdir:"*) ;;
4995 *) temp_rpath="$temp_rpath$absdir:" ;;
a.rottmann964dbb12004-02-26 19:47:42 +00004996 esac
4997 fi
drh71eb93e2001-09-28 01:34:43 +00004998
4999 # Hardcode the library path.
5000 # Skip directories that are in the system default run-time
5001 # search path.
5002 case " $sys_lib_dlsearch_path " in
5003 *" $absdir "*) ;;
5004 *)
5005 case "$compile_rpath " in
5006 *" $absdir "*) ;;
5007 *) compile_rpath="$compile_rpath $absdir"
5008 esac
5009 ;;
5010 esac
5011 case " $sys_lib_dlsearch_path " in
5012 *" $libdir "*) ;;
5013 *)
5014 case "$finalize_rpath " in
5015 *" $libdir "*) ;;
5016 *) finalize_rpath="$finalize_rpath $libdir"
5017 esac
5018 ;;
5019 esac
5020 fi # $linkmode,$pass = prog,link...
5021
5022 if test "$alldeplibs" = yes &&
5023 { test "$deplibs_check_method" = pass_all ||
5024 { test "$build_libtool_libs" = yes &&
5025 test -n "$library_names"; }; }; then
5026 # We only need to search for static libraries
5027 continue
5028 fi
a.rottmann964dbb12004-02-26 19:47:42 +00005029 fi
a.rottmann62507b62003-03-24 09:40:34 +00005030
a.rottmann964dbb12004-02-26 19:47:42 +00005031 link_static=no # Whether the deplib will be linked statically
vapier7f19c022007-02-17 14:46:31 +00005032 use_static_libs=$prefer_static_libs
mlcreech636a9952008-05-05 22:52:56 +00005033 if test "$use_static_libs" = built && test "$installed" = yes; then
vapier7f19c022007-02-17 14:46:31 +00005034 use_static_libs=no
5035 fi
a.rottmann964dbb12004-02-26 19:47:42 +00005036 if test -n "$library_names" &&
vapier7f19c022007-02-17 14:46:31 +00005037 { test "$use_static_libs" = no || test -z "$old_library"; }; then
mlcreech636a9952008-05-05 22:52:56 +00005038 case $host in
5039 *cygwin* | *mingw*)
5040 # No point in relinking DLLs because paths are not encoded
5041 notinst_deplibs="$notinst_deplibs $lib"
5042 need_relink=no
5043 ;;
5044 *)
5045 if test "$installed" = no; then
5046 notinst_deplibs="$notinst_deplibs $lib"
5047 need_relink=yes
5048 fi
5049 ;;
5050 esac
a.rottmann964dbb12004-02-26 19:47:42 +00005051 # This is a shared library
vapier7f19c022007-02-17 14:46:31 +00005052
mlcreech636a9952008-05-05 22:52:56 +00005053 # Warn about portability, can't link against -module's on some
5054 # systems (darwin). Don't bleat about dlopened modules though!
5055 dlopenmodule=""
5056 for dlpremoduletest in $dlprefiles; do
5057 if test "X$dlpremoduletest" = "X$lib"; then
5058 dlopenmodule="$dlpremoduletest"
5059 break
a.rottmann964dbb12004-02-26 19:47:42 +00005060 fi
mlcreech636a9952008-05-05 22:52:56 +00005061 done
5062 if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
5063 $ECHO
5064 if test "$linkmode" = prog; then
5065 $ECHO "*** Warning: Linking the executable $output against the loadable module"
5066 else
5067 $ECHO "*** Warning: Linking the shared library $output against the loadable module"
5068 fi
5069 $ECHO "*** $linklib is not portable!"
vapier7f19c022007-02-17 14:46:31 +00005070 fi
a.rottmann964dbb12004-02-26 19:47:42 +00005071 if test "$linkmode" = lib &&
5072 test "$hardcode_into_libs" = yes; then
5073 # Hardcode the library path.
5074 # Skip directories that are in the system default run-time
5075 # search path.
5076 case " $sys_lib_dlsearch_path " in
5077 *" $absdir "*) ;;
5078 *)
5079 case "$compile_rpath " in
5080 *" $absdir "*) ;;
5081 *) compile_rpath="$compile_rpath $absdir"
5082 esac
5083 ;;
5084 esac
5085 case " $sys_lib_dlsearch_path " in
5086 *" $libdir "*) ;;
5087 *)
5088 case "$finalize_rpath " in
5089 *" $libdir "*) ;;
5090 *) finalize_rpath="$finalize_rpath $libdir"
5091 esac
5092 ;;
5093 esac
5094 fi
drh71eb93e2001-09-28 01:34:43 +00005095
5096 if test -n "$old_archive_from_expsyms_cmds"; then
5097 # figure out the soname
5098 set dummy $library_names
mlcreech636a9952008-05-05 22:52:56 +00005099 shift
5100 realname="$1"
5101 shift
5102 libname=`eval "\\$ECHO \"$libname_spec\""`
drh71eb93e2001-09-28 01:34:43 +00005103 # use dlname if we got it. it's perfectly good, no?
5104 if test -n "$dlname"; then
5105 soname="$dlname"
5106 elif test -n "$soname_spec"; then
5107 # bleh windows
5108 case $host in
a.rottmann964dbb12004-02-26 19:47:42 +00005109 *cygwin* | mingw*)
mlcreech636a9952008-05-05 22:52:56 +00005110 func_arith $current - $age
5111 major=$func_arith_result
drh71eb93e2001-09-28 01:34:43 +00005112 versuffix="-$major"
5113 ;;
5114 esac
5115 eval soname=\"$soname_spec\"
5116 else
5117 soname="$realname"
5118 fi
5119
5120 # Make a new name for the extract_expsyms_cmds to use
5121 soroot="$soname"
mlcreech636a9952008-05-05 22:52:56 +00005122 func_basename "$soroot"
5123 soname="$func_basename_result"
5124 func_stripname 'lib' '.dll' "$soname"
5125 newlib=libimp-$func_stripname_result.a
drh71eb93e2001-09-28 01:34:43 +00005126
5127 # If the library has no export list, then create one now
5128 if test -f "$output_objdir/$soname-def"; then :
5129 else
mlcreech636a9952008-05-05 22:52:56 +00005130 func_verbose "extracting exported symbol list from \`$soname'"
5131 func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
drh71eb93e2001-09-28 01:34:43 +00005132 fi
5133
5134 # Create $newlib
5135 if test -f "$output_objdir/$newlib"; then :; else
mlcreech636a9952008-05-05 22:52:56 +00005136 func_verbose "generating import library for \`$soname'"
5137 func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
drh71eb93e2001-09-28 01:34:43 +00005138 fi
5139 # make sure the library variables are pointing to the new library
5140 dir=$output_objdir
5141 linklib=$newlib
a.rottmann964dbb12004-02-26 19:47:42 +00005142 fi # test -n "$old_archive_from_expsyms_cmds"
drh71eb93e2001-09-28 01:34:43 +00005143
a.rottmann964dbb12004-02-26 19:47:42 +00005144 if test "$linkmode" = prog || test "$mode" != relink; then
drh71eb93e2001-09-28 01:34:43 +00005145 add_shlibpath=
5146 add_dir=
5147 add=
5148 lib_linked=yes
5149 case $hardcode_action in
5150 immediate | unsupported)
5151 if test "$hardcode_direct" = no; then
5152 add="$dir/$linklib"
a.rottmann964dbb12004-02-26 19:47:42 +00005153 case $host in
vapier7f19c022007-02-17 14:46:31 +00005154 *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
5155 *-*-sysv4*uw2*) add_dir="-L$dir" ;;
5156 *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
5157 *-*-unixware7*) add_dir="-L$dir" ;;
a.rottmann964dbb12004-02-26 19:47:42 +00005158 *-*-darwin* )
mlcreech636a9952008-05-05 22:52:56 +00005159 # if the lib is a (non-dlopened) module then we can not
5160 # link against it, someone is ignoring the earlier warnings
vapier7f19c022007-02-17 14:46:31 +00005161 if /usr/bin/file -L $add 2> /dev/null |
mlcreech636a9952008-05-05 22:52:56 +00005162 $GREP ": [^:]* bundle" >/dev/null ; then
5163 if test "X$dlopenmodule" != "X$lib"; then
5164 $ECHO "*** Warning: lib $linklib is a module, not a shared library"
5165 if test -z "$old_library" ; then
5166 $ECHO
5167 $ECHO "*** And there doesn't seem to be a static archive available"
5168 $ECHO "*** The link will probably fail, sorry"
5169 else
5170 add="$dir/$old_library"
5171 fi
5172 elif test -n "$old_library"; then
5173 add="$dir/$old_library"
vapier7f19c022007-02-17 14:46:31 +00005174 fi
a.rottmann964dbb12004-02-26 19:47:42 +00005175 fi
5176 esac
drh71eb93e2001-09-28 01:34:43 +00005177 elif test "$hardcode_minus_L" = no; then
5178 case $host in
5179 *-*-sunos*) add_shlibpath="$dir" ;;
5180 esac
5181 add_dir="-L$dir"
5182 add="-l$name"
5183 elif test "$hardcode_shlibpath_var" = no; then
5184 add_shlibpath="$dir"
5185 add="-l$name"
5186 else
5187 lib_linked=no
5188 fi
5189 ;;
5190 relink)
mlcreech636a9952008-05-05 22:52:56 +00005191 if test "$hardcode_direct" = yes &&
5192 test "$hardcode_direct_absolute" = no; then
drh71eb93e2001-09-28 01:34:43 +00005193 add="$dir/$linklib"
5194 elif test "$hardcode_minus_L" = yes; then
5195 add_dir="-L$dir"
a.rottmann62507b62003-03-24 09:40:34 +00005196 # Try looking first in the location we're being installed to.
5197 if test -n "$inst_prefix_dir"; then
vapier7f19c022007-02-17 14:46:31 +00005198 case $libdir in
a.rottmann964dbb12004-02-26 19:47:42 +00005199 [\\/]*)
5200 add_dir="$add_dir -L$inst_prefix_dir$libdir"
5201 ;;
a.rottmann62507b62003-03-24 09:40:34 +00005202 esac
5203 fi
drh71eb93e2001-09-28 01:34:43 +00005204 add="-l$name"
5205 elif test "$hardcode_shlibpath_var" = yes; then
5206 add_shlibpath="$dir"
5207 add="-l$name"
5208 else
5209 lib_linked=no
5210 fi
5211 ;;
5212 *) lib_linked=no ;;
5213 esac
5214
5215 if test "$lib_linked" != yes; then
mlcreech636a9952008-05-05 22:52:56 +00005216 func_fatal_configuration "unsupported hardcode properties"
drh71eb93e2001-09-28 01:34:43 +00005217 fi
5218
5219 if test -n "$add_shlibpath"; then
5220 case :$compile_shlibpath: in
5221 *":$add_shlibpath:"*) ;;
5222 *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
5223 esac
5224 fi
a.rottmann964dbb12004-02-26 19:47:42 +00005225 if test "$linkmode" = prog; then
drh71eb93e2001-09-28 01:34:43 +00005226 test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
5227 test -n "$add" && compile_deplibs="$add $compile_deplibs"
5228 else
5229 test -n "$add_dir" && deplibs="$add_dir $deplibs"
5230 test -n "$add" && deplibs="$add $deplibs"
mlcreech636a9952008-05-05 22:52:56 +00005231 if test "$hardcode_direct" != yes &&
5232 test "$hardcode_minus_L" != yes &&
drh71eb93e2001-09-28 01:34:43 +00005233 test "$hardcode_shlibpath_var" = yes; then
5234 case :$finalize_shlibpath: in
5235 *":$libdir:"*) ;;
5236 *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
5237 esac
5238 fi
5239 fi
5240 fi
5241
a.rottmann964dbb12004-02-26 19:47:42 +00005242 if test "$linkmode" = prog || test "$mode" = relink; then
drh71eb93e2001-09-28 01:34:43 +00005243 add_shlibpath=
5244 add_dir=
5245 add=
5246 # Finalize command for both is simple: just hardcode it.
mlcreech636a9952008-05-05 22:52:56 +00005247 if test "$hardcode_direct" = yes &&
5248 test "$hardcode_direct_absolute" = no; then
drh71eb93e2001-09-28 01:34:43 +00005249 add="$libdir/$linklib"
5250 elif test "$hardcode_minus_L" = yes; then
5251 add_dir="-L$libdir"
5252 add="-l$name"
5253 elif test "$hardcode_shlibpath_var" = yes; then
5254 case :$finalize_shlibpath: in
5255 *":$libdir:"*) ;;
5256 *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
5257 esac
5258 add="-l$name"
a.rottmann964dbb12004-02-26 19:47:42 +00005259 elif test "$hardcode_automatic" = yes; then
vapier7f19c022007-02-17 14:46:31 +00005260 if test -n "$inst_prefix_dir" &&
5261 test -f "$inst_prefix_dir$libdir/$linklib" ; then
mlcreech636a9952008-05-05 22:52:56 +00005262 add="$inst_prefix_dir$libdir/$linklib"
a.rottmann964dbb12004-02-26 19:47:42 +00005263 else
mlcreech636a9952008-05-05 22:52:56 +00005264 add="$libdir/$linklib"
a.rottmann964dbb12004-02-26 19:47:42 +00005265 fi
drh71eb93e2001-09-28 01:34:43 +00005266 else
5267 # We cannot seem to hardcode it, guess we'll fake it.
5268 add_dir="-L$libdir"
a.rottmann62507b62003-03-24 09:40:34 +00005269 # Try looking first in the location we're being installed to.
5270 if test -n "$inst_prefix_dir"; then
vapier7f19c022007-02-17 14:46:31 +00005271 case $libdir in
a.rottmann964dbb12004-02-26 19:47:42 +00005272 [\\/]*)
5273 add_dir="$add_dir -L$inst_prefix_dir$libdir"
5274 ;;
a.rottmann62507b62003-03-24 09:40:34 +00005275 esac
5276 fi
drh71eb93e2001-09-28 01:34:43 +00005277 add="-l$name"
5278 fi
5279
a.rottmann964dbb12004-02-26 19:47:42 +00005280 if test "$linkmode" = prog; then
drh71eb93e2001-09-28 01:34:43 +00005281 test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
5282 test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
5283 else
5284 test -n "$add_dir" && deplibs="$add_dir $deplibs"
5285 test -n "$add" && deplibs="$add $deplibs"
5286 fi
5287 fi
a.rottmann964dbb12004-02-26 19:47:42 +00005288 elif test "$linkmode" = prog; then
drh71eb93e2001-09-28 01:34:43 +00005289 # Here we assume that one of hardcode_direct or hardcode_minus_L
5290 # is not unsupported. This is valid on all known static and
5291 # shared platforms.
5292 if test "$hardcode_direct" != unsupported; then
5293 test -n "$old_library" && linklib="$old_library"
5294 compile_deplibs="$dir/$linklib $compile_deplibs"
5295 finalize_deplibs="$dir/$linklib $finalize_deplibs"
5296 else
5297 compile_deplibs="-l$name -L$dir $compile_deplibs"
5298 finalize_deplibs="-l$name -L$dir $finalize_deplibs"
5299 fi
5300 elif test "$build_libtool_libs" = yes; then
5301 # Not a shared library
5302 if test "$deplibs_check_method" != pass_all; then
5303 # We're trying link a shared library against a static one
5304 # but the system doesn't support it.
5305
5306 # Just print a warning and add the library to dependency_libs so
5307 # that the program can be linked against the static library.
mlcreech636a9952008-05-05 22:52:56 +00005308 $ECHO
5309 $ECHO "*** Warning: This system can not link to static lib archive $lib."
5310 $ECHO "*** I have the capability to make that library automatically link in when"
5311 $ECHO "*** you link to this library. But I can only do this if you have a"
5312 $ECHO "*** shared version of the library, which you do not appear to have."
drh71eb93e2001-09-28 01:34:43 +00005313 if test "$module" = yes; then
mlcreech636a9952008-05-05 22:52:56 +00005314 $ECHO "*** But as you try to build a module library, libtool will still create "
5315 $ECHO "*** a static module, that should work as long as the dlopening application"
5316 $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime."
drh71eb93e2001-09-28 01:34:43 +00005317 if test -z "$global_symbol_pipe"; then
mlcreech636a9952008-05-05 22:52:56 +00005318 $ECHO
5319 $ECHO "*** However, this would only work if libtool was able to extract symbol"
5320 $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
5321 $ECHO "*** not find such a program. So, this module is probably useless."
5322 $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
drh71eb93e2001-09-28 01:34:43 +00005323 fi
5324 if test "$build_old_libs" = no; then
a.rottmann62507b62003-03-24 09:40:34 +00005325 build_libtool_libs=module
5326 build_old_libs=yes
drh71eb93e2001-09-28 01:34:43 +00005327 else
a.rottmann62507b62003-03-24 09:40:34 +00005328 build_libtool_libs=no
drh71eb93e2001-09-28 01:34:43 +00005329 fi
5330 fi
5331 else
drh71eb93e2001-09-28 01:34:43 +00005332 deplibs="$dir/$old_library $deplibs"
5333 link_static=yes
5334 fi
5335 fi # link shared/static library?
5336
a.rottmann964dbb12004-02-26 19:47:42 +00005337 if test "$linkmode" = lib; then
drh71eb93e2001-09-28 01:34:43 +00005338 if test -n "$dependency_libs" &&
vapier7f19c022007-02-17 14:46:31 +00005339 { test "$hardcode_into_libs" != yes ||
5340 test "$build_old_libs" = yes ||
a.rottmann964dbb12004-02-26 19:47:42 +00005341 test "$link_static" = yes; }; then
drh71eb93e2001-09-28 01:34:43 +00005342 # Extract -R from dependency_libs
5343 temp_deplibs=
5344 for libdir in $dependency_libs; do
5345 case $libdir in
mlcreech636a9952008-05-05 22:52:56 +00005346 -R*) func_stripname '-R' '' "$libdir"
5347 temp_xrpath=$func_stripname_result
drh71eb93e2001-09-28 01:34:43 +00005348 case " $xrpath " in
5349 *" $temp_xrpath "*) ;;
5350 *) xrpath="$xrpath $temp_xrpath";;
5351 esac;;
5352 *) temp_deplibs="$temp_deplibs $libdir";;
5353 esac
5354 done
5355 dependency_libs="$temp_deplibs"
5356 fi
5357
5358 newlib_search_path="$newlib_search_path $absdir"
5359 # Link against this library
5360 test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
5361 # ... and its dependency_libs
5362 tmp_libs=
5363 for deplib in $dependency_libs; do
5364 newdependency_libs="$deplib $newdependency_libs"
mlcreech636a9952008-05-05 22:52:56 +00005365 if $opt_duplicate_deps ; then
a.rottmann62507b62003-03-24 09:40:34 +00005366 case "$tmp_libs " in
5367 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5368 esac
5369 fi
drh71eb93e2001-09-28 01:34:43 +00005370 tmp_libs="$tmp_libs $deplib"
5371 done
5372
a.rottmann964dbb12004-02-26 19:47:42 +00005373 if test "$link_all_deplibs" != no; then
drh71eb93e2001-09-28 01:34:43 +00005374 # Add the search paths of all dependency libraries
5375 for deplib in $dependency_libs; do
5376 case $deplib in
5377 -L*) path="$deplib" ;;
5378 *.la)
mlcreech636a9952008-05-05 22:52:56 +00005379 func_dirname "$deplib" "" "."
5380 dir="$func_dirname_result"
drh71eb93e2001-09-28 01:34:43 +00005381 # We need an absolute path.
5382 case $dir in
5383 [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
5384 *)
5385 absdir=`cd "$dir" && pwd`
5386 if test -z "$absdir"; then
mlcreech636a9952008-05-05 22:52:56 +00005387 func_warning "cannot determine absolute directory name of \`$dir'"
drh71eb93e2001-09-28 01:34:43 +00005388 absdir="$dir"
5389 fi
5390 ;;
5391 esac
mlcreech636a9952008-05-05 22:52:56 +00005392 if $GREP "^installed=no" $deplib > /dev/null; then
a.rottmann964dbb12004-02-26 19:47:42 +00005393 case $host in
5394 *-*-darwin*)
mlcreech636a9952008-05-05 22:52:56 +00005395 depdepl=
a.rottmann964dbb12004-02-26 19:47:42 +00005396 eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
5397 if test -n "$deplibrary_names" ; then
5398 for tmp in $deplibrary_names ; do
5399 depdepl=$tmp
5400 done
mlcreech636a9952008-05-05 22:52:56 +00005401 if test -f "$absdir/$objdir/$depdepl" ; then
5402 depdepl="$absdir/$objdir/$depdepl"
5403 darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
5404 if test -z "$darwin_install_name"; then
5405 darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
5406 fi
5407 compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
5408 linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
5409 path=
vapier7f19c022007-02-17 14:46:31 +00005410 fi
a.rottmann964dbb12004-02-26 19:47:42 +00005411 fi
a.rottmann964dbb12004-02-26 19:47:42 +00005412 ;;
5413 *)
mlcreech636a9952008-05-05 22:52:56 +00005414 path="-L$absdir/$objdir"
vapier7f19c022007-02-17 14:46:31 +00005415 ;;
5416 esac
mlcreech636a9952008-05-05 22:52:56 +00005417 else
5418 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
5419 test -z "$libdir" && \
5420 func_fatal_error "\`$deplib' is not a valid libtool archive"
5421 test "$absdir" != "$libdir" && \
5422 func_warning "\`$deplib' seems to be moved"
5423
5424 path="-L$absdir"
5425 fi
a.rottmann964dbb12004-02-26 19:47:42 +00005426 ;;
drh71eb93e2001-09-28 01:34:43 +00005427 esac
5428 case " $deplibs " in
5429 *" $path "*) ;;
vapier7f19c022007-02-17 14:46:31 +00005430 *) deplibs="$path $deplibs" ;;
5431 esac
drh71eb93e2001-09-28 01:34:43 +00005432 done
5433 fi # link_all_deplibs != no
5434 fi # linkmode = lib
5435 done # for deplib in $libs
mlcreech636a9952008-05-05 22:52:56 +00005436 if test "$pass" = link; then
5437 if test "$linkmode" = "prog"; then
5438 compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
5439 finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
5440 else
5441 compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
5442 fi
5443 fi
a.rottmann964dbb12004-02-26 19:47:42 +00005444 dependency_libs="$newdependency_libs"
5445 if test "$pass" = dlpreopen; then
drh71eb93e2001-09-28 01:34:43 +00005446 # Link the dlpreopened libraries before other libraries
5447 for deplib in $save_deplibs; do
5448 deplibs="$deplib $deplibs"
5449 done
5450 fi
a.rottmann964dbb12004-02-26 19:47:42 +00005451 if test "$pass" != dlopen; then
5452 if test "$pass" != conv; then
drh71eb93e2001-09-28 01:34:43 +00005453 # Make sure lib_search_path contains only unique directories.
5454 lib_search_path=
5455 for dir in $newlib_search_path; do
5456 case "$lib_search_path " in
5457 *" $dir "*) ;;
5458 *) lib_search_path="$lib_search_path $dir" ;;
5459 esac
5460 done
5461 newlib_search_path=
5462 fi
5463
5464 if test "$linkmode,$pass" != "prog,link"; then
5465 vars="deplibs"
5466 else
5467 vars="compile_deplibs finalize_deplibs"
5468 fi
5469 for var in $vars dependency_libs; do
5470 # Add libraries to $var in reverse order
5471 eval tmp_libs=\"\$$var\"
5472 new_libs=
5473 for deplib in $tmp_libs; do
a.rottmann964dbb12004-02-26 19:47:42 +00005474 # FIXME: Pedantically, this is the right thing to do, so
5475 # that some nasty dependency loop isn't accidentally
5476 # broken:
5477 #new_libs="$deplib $new_libs"
5478 # Pragmatically, this seems to cause very few problems in
5479 # practice:
drh71eb93e2001-09-28 01:34:43 +00005480 case $deplib in
a.rottmann62507b62003-03-24 09:40:34 +00005481 -L*) new_libs="$deplib $new_libs" ;;
a.rottmann964dbb12004-02-26 19:47:42 +00005482 -R*) ;;
a.rottmann62507b62003-03-24 09:40:34 +00005483 *)
a.rottmann964dbb12004-02-26 19:47:42 +00005484 # And here is the reason: when a library appears more
5485 # than once as an explicit dependence of a library, or
5486 # is implicitly linked in more than once by the
5487 # compiler, it is considered special, and multiple
5488 # occurrences thereof are not removed. Compare this
5489 # with having the same library being listed as a
5490 # dependency of multiple other libraries: in this case,
5491 # we know (pedantically, we assume) the library does not
5492 # need to be listed more than once, so we keep only the
5493 # last copy. This is not always right, but it is rare
5494 # enough that we require users that really mean to play
5495 # such unportable linking tricks to link the library
5496 # using -Wl,-lname, so that libtool does not consider it
5497 # for duplicate removal.
a.rottmann62507b62003-03-24 09:40:34 +00005498 case " $specialdeplibs " in
5499 *" $deplib "*) new_libs="$deplib $new_libs" ;;
5500 *)
5501 case " $new_libs " in
5502 *" $deplib "*) ;;
5503 *) new_libs="$deplib $new_libs" ;;
5504 esac
5505 ;;
5506 esac
5507 ;;
5508 esac
drh71eb93e2001-09-28 01:34:43 +00005509 done
5510 tmp_libs=
5511 for deplib in $new_libs; do
5512 case $deplib in
5513 -L*)
5514 case " $tmp_libs " in
5515 *" $deplib "*) ;;
5516 *) tmp_libs="$tmp_libs $deplib" ;;
5517 esac
5518 ;;
5519 *) tmp_libs="$tmp_libs $deplib" ;;
5520 esac
5521 done
5522 eval $var=\"$tmp_libs\"
5523 done # for var
5524 fi
vapier7f19c022007-02-17 14:46:31 +00005525 # Last step: remove runtime libs from dependency_libs
5526 # (they stay in deplibs)
a.rottmann964dbb12004-02-26 19:47:42 +00005527 tmp_libs=
5528 for i in $dependency_libs ; do
5529 case " $predeps $postdeps $compiler_lib_search_path " in
5530 *" $i "*)
5531 i=""
5532 ;;
5533 esac
5534 if test -n "$i" ; then
5535 tmp_libs="$tmp_libs $i"
5536 fi
5537 done
5538 dependency_libs=$tmp_libs
drh71eb93e2001-09-28 01:34:43 +00005539 done # for pass
a.rottmann964dbb12004-02-26 19:47:42 +00005540 if test "$linkmode" = prog; then
drh71eb93e2001-09-28 01:34:43 +00005541 dlfiles="$newdlfiles"
mlcreech636a9952008-05-05 22:52:56 +00005542 fi
5543 if test "$linkmode" = prog || test "$linkmode" = lib; then
drh71eb93e2001-09-28 01:34:43 +00005544 dlprefiles="$newdlprefiles"
5545 fi
5546
5547 case $linkmode in
5548 oldlib)
drh71eb93e2001-09-28 01:34:43 +00005549 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
mlcreech636a9952008-05-05 22:52:56 +00005550 func_warning "\`-dlopen' is ignored for archives"
drh71eb93e2001-09-28 01:34:43 +00005551 fi
5552
mlcreech636a9952008-05-05 22:52:56 +00005553 case " $deplibs" in
5554 *\ -l* | *\ -L*)
5555 func_warning "\`-l' and \`-L' are ignored for archives" ;;
5556 esac
drh71eb93e2001-09-28 01:34:43 +00005557
mlcreech636a9952008-05-05 22:52:56 +00005558 test -n "$rpath" && \
5559 func_warning "\`-rpath' is ignored for archives"
drh71eb93e2001-09-28 01:34:43 +00005560
mlcreech636a9952008-05-05 22:52:56 +00005561 test -n "$xrpath" && \
5562 func_warning "\`-R' is ignored for archives"
drh71eb93e2001-09-28 01:34:43 +00005563
mlcreech636a9952008-05-05 22:52:56 +00005564 test -n "$vinfo" && \
5565 func_warning "\`-version-info/-version-number' is ignored for archives"
drh71eb93e2001-09-28 01:34:43 +00005566
mlcreech636a9952008-05-05 22:52:56 +00005567 test -n "$release" && \
5568 func_warning "\`-release' is ignored for archives"
5569
5570 test -n "$export_symbols$export_symbols_regex" && \
5571 func_warning "\`-export-symbols' is ignored for archives"
drh71eb93e2001-09-28 01:34:43 +00005572
5573 # Now set the variables for building old libraries.
5574 build_libtool_libs=no
5575 oldlibs="$output"
5576 objs="$objs$old_deplibs"
5577 ;;
5578
5579 lib)
5580 # Make sure we only generate libraries of the form `libNAME.la'.
5581 case $outputname in
5582 lib*)
mlcreech636a9952008-05-05 22:52:56 +00005583 func_stripname 'lib' '.la' "$outputname"
5584 name=$func_stripname_result
vapier7f19c022007-02-17 14:46:31 +00005585 eval shared_ext=\"$shrext_cmds\"
drh71eb93e2001-09-28 01:34:43 +00005586 eval libname=\"$libname_spec\"
5587 ;;
5588 *)
mlcreech636a9952008-05-05 22:52:56 +00005589 test "$module" = no && \
5590 func_fatal_help "libtool library \`$output' must begin with \`lib'"
5591
drh71eb93e2001-09-28 01:34:43 +00005592 if test "$need_lib_prefix" != no; then
5593 # Add the "lib" prefix for modules if required
mlcreech636a9952008-05-05 22:52:56 +00005594 func_stripname '' '.la' "$outputname"
5595 name=$func_stripname_result
vapier7f19c022007-02-17 14:46:31 +00005596 eval shared_ext=\"$shrext_cmds\"
drh71eb93e2001-09-28 01:34:43 +00005597 eval libname=\"$libname_spec\"
5598 else
mlcreech636a9952008-05-05 22:52:56 +00005599 func_stripname '' '.la' "$outputname"
5600 libname=$func_stripname_result
drh71eb93e2001-09-28 01:34:43 +00005601 fi
5602 ;;
5603 esac
5604
5605 if test -n "$objs"; then
5606 if test "$deplibs_check_method" != pass_all; then
mlcreech636a9952008-05-05 22:52:56 +00005607 func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
drh71eb93e2001-09-28 01:34:43 +00005608 else
mlcreech636a9952008-05-05 22:52:56 +00005609 $ECHO
5610 $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
5611 $ECHO "*** objects $objs is not portable!"
drh71eb93e2001-09-28 01:34:43 +00005612 libobjs="$libobjs $objs"
5613 fi
5614 fi
5615
mlcreech636a9952008-05-05 22:52:56 +00005616 test "$dlself" != no && \
5617 func_warning "\`-dlopen self' is ignored for libtool libraries"
drh71eb93e2001-09-28 01:34:43 +00005618
5619 set dummy $rpath
mlcreech636a9952008-05-05 22:52:56 +00005620 shift
5621 test "$#" -gt 1 && \
5622 func_warning "ignoring multiple \`-rpath's for a libtool library"
5623
5624 install_libdir="$1"
drh71eb93e2001-09-28 01:34:43 +00005625
5626 oldlibs=
5627 if test -z "$rpath"; then
5628 if test "$build_libtool_libs" = yes; then
5629 # Building a libtool convenience library.
a.rottmann964dbb12004-02-26 19:47:42 +00005630 # Some compilers have problems with a `.al' extension so
5631 # convenience libraries should have the same extension an
5632 # archive normally would.
drh71eb93e2001-09-28 01:34:43 +00005633 oldlibs="$output_objdir/$libname.$libext $oldlibs"
5634 build_libtool_libs=convenience
5635 build_old_libs=yes
5636 fi
5637
mlcreech636a9952008-05-05 22:52:56 +00005638 test -n "$vinfo" && \
5639 func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
drh71eb93e2001-09-28 01:34:43 +00005640
mlcreech636a9952008-05-05 22:52:56 +00005641 test -n "$release" && \
5642 func_warning "\`-release' is ignored for convenience libraries"
drh71eb93e2001-09-28 01:34:43 +00005643 else
5644
5645 # Parse the version information argument.
a.rottmann62507b62003-03-24 09:40:34 +00005646 save_ifs="$IFS"; IFS=':'
drh71eb93e2001-09-28 01:34:43 +00005647 set dummy $vinfo 0 0 0
mlcreech636a9952008-05-05 22:52:56 +00005648 shift
drh71eb93e2001-09-28 01:34:43 +00005649 IFS="$save_ifs"
5650
mlcreech636a9952008-05-05 22:52:56 +00005651 test -n "$7" && \
5652 func_fatal_help "too many parameters to \`-version-info'"
drh71eb93e2001-09-28 01:34:43 +00005653
a.rottmann964dbb12004-02-26 19:47:42 +00005654 # convert absolute version numbers to libtool ages
5655 # this retains compatibility with .la files and attempts
5656 # to make the code below a bit more comprehensible
vapier7f19c022007-02-17 14:46:31 +00005657
a.rottmann964dbb12004-02-26 19:47:42 +00005658 case $vinfo_number in
5659 yes)
mlcreech636a9952008-05-05 22:52:56 +00005660 number_major="$1"
5661 number_minor="$2"
5662 number_revision="$3"
a.rottmann964dbb12004-02-26 19:47:42 +00005663 #
5664 # There are really only two kinds -- those that
5665 # use the current revision as the major version
5666 # and those that subtract age and use age as
5667 # a minor version. But, then there is irix
5668 # which has an extra 1 added just for fun
5669 #
5670 case $version_type in
mlcreech636a9952008-05-05 22:52:56 +00005671 darwin|linux|osf|windows|none)
5672 func_arith $number_major + $number_minor
5673 current=$func_arith_result
a.rottmann964dbb12004-02-26 19:47:42 +00005674 age="$number_minor"
5675 revision="$number_revision"
5676 ;;
5677 freebsd-aout|freebsd-elf|sunos)
5678 current="$number_major"
5679 revision="$number_minor"
5680 age="0"
5681 ;;
5682 irix|nonstopux)
mlcreech636a9952008-05-05 22:52:56 +00005683 func_arith $number_major + $number_minor
5684 current=$func_arith_result
a.rottmann964dbb12004-02-26 19:47:42 +00005685 age="$number_minor"
5686 revision="$number_minor"
mlcreech636a9952008-05-05 22:52:56 +00005687 lt_irix_increment=no
a.rottmann964dbb12004-02-26 19:47:42 +00005688 ;;
5689 esac
5690 ;;
5691 no)
mlcreech636a9952008-05-05 22:52:56 +00005692 current="$1"
5693 revision="$2"
5694 age="$3"
a.rottmann964dbb12004-02-26 19:47:42 +00005695 ;;
5696 esac
drh71eb93e2001-09-28 01:34:43 +00005697
5698 # Check that each of the things are valid numbers.
5699 case $current in
vapier7f19c022007-02-17 14:46:31 +00005700 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]) ;;
drh71eb93e2001-09-28 01:34:43 +00005701 *)
mlcreech636a9952008-05-05 22:52:56 +00005702 func_error "CURRENT \`$current' must be a nonnegative integer"
5703 func_fatal_error "\`$vinfo' is not valid version information"
drh71eb93e2001-09-28 01:34:43 +00005704 ;;
5705 esac
5706
5707 case $revision in
vapier7f19c022007-02-17 14:46:31 +00005708 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]) ;;
drh71eb93e2001-09-28 01:34:43 +00005709 *)
mlcreech636a9952008-05-05 22:52:56 +00005710 func_error "REVISION \`$revision' must be a nonnegative integer"
5711 func_fatal_error "\`$vinfo' is not valid version information"
drh71eb93e2001-09-28 01:34:43 +00005712 ;;
5713 esac
5714
5715 case $age in
vapier7f19c022007-02-17 14:46:31 +00005716 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]) ;;
drh71eb93e2001-09-28 01:34:43 +00005717 *)
mlcreech636a9952008-05-05 22:52:56 +00005718 func_error "AGE \`$age' must be a nonnegative integer"
5719 func_fatal_error "\`$vinfo' is not valid version information"
drh71eb93e2001-09-28 01:34:43 +00005720 ;;
5721 esac
5722
a.rottmann964dbb12004-02-26 19:47:42 +00005723 if test "$age" -gt "$current"; then
mlcreech636a9952008-05-05 22:52:56 +00005724 func_error "AGE \`$age' is greater than the current interface number \`$current'"
5725 func_fatal_error "\`$vinfo' is not valid version information"
drh71eb93e2001-09-28 01:34:43 +00005726 fi
5727
5728 # Calculate the version variables.
5729 major=
5730 versuffix=
5731 verstring=
5732 case $version_type in
5733 none) ;;
5734
5735 darwin)
5736 # Like Linux, but with the current version available in
5737 # verstring for coding it into the library header
mlcreech636a9952008-05-05 22:52:56 +00005738 func_arith $current - $age
5739 major=.$func_arith_result
drh71eb93e2001-09-28 01:34:43 +00005740 versuffix="$major.$age.$revision"
5741 # Darwin ld doesn't like 0 for these options...
mlcreech636a9952008-05-05 22:52:56 +00005742 func_arith $current + 1
5743 minor_current=$func_arith_result
5744 xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
5745 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
drh71eb93e2001-09-28 01:34:43 +00005746 ;;
5747
5748 freebsd-aout)
5749 major=".$current"
5750 versuffix=".$current.$revision";
5751 ;;
5752
5753 freebsd-elf)
5754 major=".$current"
mlcreech636a9952008-05-05 22:52:56 +00005755 versuffix=".$current"
drh71eb93e2001-09-28 01:34:43 +00005756 ;;
5757
a.rottmann62507b62003-03-24 09:40:34 +00005758 irix | nonstopux)
mlcreech636a9952008-05-05 22:52:56 +00005759 if test "X$lt_irix_increment" = "Xno"; then
5760 func_arith $current - $age
5761 else
5762 func_arith $current - $age + 1
5763 fi
5764 major=$func_arith_result
a.rottmann62507b62003-03-24 09:40:34 +00005765
5766 case $version_type in
5767 nonstopux) verstring_prefix=nonstopux ;;
5768 *) verstring_prefix=sgi ;;
5769 esac
5770 verstring="$verstring_prefix$major.$revision"
drh71eb93e2001-09-28 01:34:43 +00005771
5772 # Add in all the interfaces that we are compatible with.
5773 loop=$revision
a.rottmann964dbb12004-02-26 19:47:42 +00005774 while test "$loop" -ne 0; do
mlcreech636a9952008-05-05 22:52:56 +00005775 func_arith $revision - $loop
5776 iface=$func_arith_result
5777 func_arith $loop - 1
5778 loop=$func_arith_result
a.rottmann62507b62003-03-24 09:40:34 +00005779 verstring="$verstring_prefix$major.$iface:$verstring"
drh71eb93e2001-09-28 01:34:43 +00005780 done
5781
5782 # Before this point, $major must not contain `.'.
5783 major=.$major
5784 versuffix="$major.$revision"
5785 ;;
5786
5787 linux)
mlcreech636a9952008-05-05 22:52:56 +00005788 func_arith $current - $age
5789 major=.$func_arith_result
drh71eb93e2001-09-28 01:34:43 +00005790 versuffix="$major.$age.$revision"
5791 ;;
5792
5793 osf)
mlcreech636a9952008-05-05 22:52:56 +00005794 func_arith $current - $age
5795 major=.$func_arith_result
drh71eb93e2001-09-28 01:34:43 +00005796 versuffix=".$current.$age.$revision"
5797 verstring="$current.$age.$revision"
5798
5799 # Add in all the interfaces that we are compatible with.
5800 loop=$age
a.rottmann964dbb12004-02-26 19:47:42 +00005801 while test "$loop" -ne 0; do
mlcreech636a9952008-05-05 22:52:56 +00005802 func_arith $current - $loop
5803 iface=$func_arith_result
5804 func_arith $loop - 1
5805 loop=$func_arith_result
drh71eb93e2001-09-28 01:34:43 +00005806 verstring="$verstring:${iface}.0"
5807 done
5808
5809 # Make executables depend on our current version.
5810 verstring="$verstring:${current}.0"
5811 ;;
5812
mlcreech636a9952008-05-05 22:52:56 +00005813 qnx)
5814 major=".$current"
5815 versuffix=".$current"
5816 ;;
5817
drh71eb93e2001-09-28 01:34:43 +00005818 sunos)
5819 major=".$current"
5820 versuffix=".$current.$revision"
5821 ;;
5822
5823 windows)
5824 # Use '-' rather than '.', since we only want one
5825 # extension on DOS 8.3 filesystems.
mlcreech636a9952008-05-05 22:52:56 +00005826 func_arith $current - $age
5827 major=$func_arith_result
drh71eb93e2001-09-28 01:34:43 +00005828 versuffix="-$major"
5829 ;;
5830
5831 *)
mlcreech636a9952008-05-05 22:52:56 +00005832 func_fatal_configuration "unknown library version type \`$version_type'"
drh71eb93e2001-09-28 01:34:43 +00005833 ;;
5834 esac
5835
5836 # Clear the version info if we defaulted, and they specified a release.
5837 if test -z "$vinfo" && test -n "$release"; then
5838 major=
a.rottmann62507b62003-03-24 09:40:34 +00005839 case $version_type in
5840 darwin)
5841 # we can't check for "0.0" in archive_cmds due to quoting
5842 # problems, so we reset it completely
a.rottmann964dbb12004-02-26 19:47:42 +00005843 verstring=
a.rottmann62507b62003-03-24 09:40:34 +00005844 ;;
5845 *)
5846 verstring="0.0"
5847 ;;
5848 esac
drh71eb93e2001-09-28 01:34:43 +00005849 if test "$need_version" = no; then
5850 versuffix=
5851 else
5852 versuffix=".0.0"
5853 fi
5854 fi
5855
5856 # Remove version info from name if versioning should be avoided
5857 if test "$avoid_version" = yes && test "$need_version" = no; then
5858 major=
5859 versuffix=
5860 verstring=""
5861 fi
5862
5863 # Check to see if the archive will have undefined symbols.
5864 if test "$allow_undefined" = yes; then
5865 if test "$allow_undefined_flag" = unsupported; then
mlcreech636a9952008-05-05 22:52:56 +00005866 func_warning "undefined symbols not allowed in $host shared libraries"
drh71eb93e2001-09-28 01:34:43 +00005867 build_libtool_libs=no
5868 build_old_libs=yes
5869 fi
5870 else
5871 # Don't allow undefined symbols.
5872 allow_undefined_flag="$no_undefined_flag"
5873 fi
mlcreech636a9952008-05-05 22:52:56 +00005874
drh71eb93e2001-09-28 01:34:43 +00005875 fi
5876
mlcreech636a9952008-05-05 22:52:56 +00005877 func_generate_dlsyms "$libname" "$libname" "yes"
5878 libobjs="$libobjs $symfileobj"
5879 test "X$libobjs" = "X " && libobjs=
5880
drh71eb93e2001-09-28 01:34:43 +00005881 if test "$mode" != relink; then
a.rottmann964dbb12004-02-26 19:47:42 +00005882 # Remove our outputs, but don't remove object files since they
5883 # may have been created when compiling PIC objects.
5884 removelist=
mlcreech636a9952008-05-05 22:52:56 +00005885 tempremovelist=`$ECHO "$output_objdir/*"`
a.rottmann964dbb12004-02-26 19:47:42 +00005886 for p in $tempremovelist; do
5887 case $p in
5888 *.$objext)
5889 ;;
5890 $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
vapier7f19c022007-02-17 14:46:31 +00005891 if test "X$precious_files_regex" != "X"; then
mlcreech636a9952008-05-05 22:52:56 +00005892 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
5893 then
vapier7f19c022007-02-17 14:46:31 +00005894 continue
5895 fi
a.rottmann964dbb12004-02-26 19:47:42 +00005896 fi
5897 removelist="$removelist $p"
5898 ;;
5899 *) ;;
5900 esac
5901 done
mlcreech636a9952008-05-05 22:52:56 +00005902 test -n "$removelist" && \
5903 func_show_eval "${RM}r \$removelist"
drh71eb93e2001-09-28 01:34:43 +00005904 fi
5905
5906 # Now set the variables for building old libraries.
5907 if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
5908 oldlibs="$oldlibs $output_objdir/$libname.$libext"
5909
5910 # Transform .lo files to .o files.
mlcreech636a9952008-05-05 22:52:56 +00005911 oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
drh71eb93e2001-09-28 01:34:43 +00005912 fi
5913
5914 # Eliminate all temporary directories.
mlcreech636a9952008-05-05 22:52:56 +00005915 #for path in $notinst_path; do
5916 # lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"`
5917 # deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"`
5918 # dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"`
5919 #done
drh71eb93e2001-09-28 01:34:43 +00005920
5921 if test -n "$xrpath"; then
5922 # If the user specified any rpath flags, then add them.
5923 temp_xrpath=
5924 for libdir in $xrpath; do
5925 temp_xrpath="$temp_xrpath -R$libdir"
5926 case "$finalize_rpath " in
5927 *" $libdir "*) ;;
5928 *) finalize_rpath="$finalize_rpath $libdir" ;;
5929 esac
5930 done
a.rottmann964dbb12004-02-26 19:47:42 +00005931 if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
drh71eb93e2001-09-28 01:34:43 +00005932 dependency_libs="$temp_xrpath $dependency_libs"
5933 fi
5934 fi
5935
5936 # Make sure dlfiles contains only unique files that won't be dlpreopened
5937 old_dlfiles="$dlfiles"
5938 dlfiles=
5939 for lib in $old_dlfiles; do
5940 case " $dlprefiles $dlfiles " in
5941 *" $lib "*) ;;
5942 *) dlfiles="$dlfiles $lib" ;;
5943 esac
5944 done
5945
5946 # Make sure dlprefiles contains only unique files
5947 old_dlprefiles="$dlprefiles"
5948 dlprefiles=
5949 for lib in $old_dlprefiles; do
5950 case "$dlprefiles " in
5951 *" $lib "*) ;;
5952 *) dlprefiles="$dlprefiles $lib" ;;
5953 esac
5954 done
5955
5956 if test "$build_libtool_libs" = yes; then
5957 if test -n "$rpath"; then
5958 case $host in
5959 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
5960 # these systems don't actually have a c library (as such)!
5961 ;;
5962 *-*-rhapsody* | *-*-darwin1.[012])
5963 # Rhapsody C library is in the System framework
mlcreech636a9952008-05-05 22:52:56 +00005964 deplibs="$deplibs System.ltframework"
drh71eb93e2001-09-28 01:34:43 +00005965 ;;
5966 *-*-netbsd*)
5967 # Don't link with libc until the a.out ld.so is fixed.
5968 ;;
vapier7f19c022007-02-17 14:46:31 +00005969 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
a.rottmann62507b62003-03-24 09:40:34 +00005970 # Do not include libc due to us having libc/libc_r.
vapier7f19c022007-02-17 14:46:31 +00005971 ;;
5972 *-*-sco3.2v5* | *-*-sco5v6*)
5973 # Causes problems with __ctype
5974 ;;
5975 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
5976 # Compiler inserts libc in the correct place for threads to work
a.rottmann62507b62003-03-24 09:40:34 +00005977 ;;
mlcreech636a9952008-05-05 22:52:56 +00005978 *)
drh71eb93e2001-09-28 01:34:43 +00005979 # Add libc to deplibs on all other systems if necessary.
a.rottmann964dbb12004-02-26 19:47:42 +00005980 if test "$build_libtool_need_lc" = "yes"; then
drh71eb93e2001-09-28 01:34:43 +00005981 deplibs="$deplibs -lc"
5982 fi
5983 ;;
5984 esac
5985 fi
5986
5987 # Transform deplibs into only deplibs that can be linked in shared.
5988 name_save=$name
5989 libname_save=$libname
5990 release_save=$release
5991 versuffix_save=$versuffix
5992 major_save=$major
5993 # I'm not sure if I'm treating the release correctly. I think
5994 # release should show up in the -l (ie -lgmp5) so we don't want to
5995 # add it in twice. Is that correct?
5996 release=""
5997 versuffix=""
5998 major=""
5999 newdeplibs=
6000 droppeddeps=no
6001 case $deplibs_check_method in
6002 pass_all)
6003 # Don't check for shared/static. Everything works.
6004 # This might be a little naive. We might want to check
6005 # whether the library exists or not. But this is on
6006 # osf3 & osf4 and I'm not really sure... Just
a.rottmann964dbb12004-02-26 19:47:42 +00006007 # implementing what was already the behavior.
drh71eb93e2001-09-28 01:34:43 +00006008 newdeplibs=$deplibs
6009 ;;
6010 test_compile)
6011 # This code stresses the "libraries are programs" paradigm to its
6012 # limits. Maybe even breaks it. We compile a program, linking it
6013 # against the deplibs as a proxy for the library. Then we can check
6014 # whether they linked in statically or dynamically with ldd.
mlcreech636a9952008-05-05 22:52:56 +00006015 $opt_dry_run || $RM conftest.c
drh71eb93e2001-09-28 01:34:43 +00006016 cat > conftest.c <<EOF
6017 int main() { return 0; }
6018EOF
mlcreech636a9952008-05-05 22:52:56 +00006019 $opt_dry_run || $RM conftest
6020 if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
drh71eb93e2001-09-28 01:34:43 +00006021 ldd_output=`ldd conftest`
6022 for i in $deplibs; do
mlcreech636a9952008-05-05 22:52:56 +00006023 case $i in
6024 -l*)
6025 func_stripname -l '' "$i"
6026 name=$func_stripname_result
a.rottmann964dbb12004-02-26 19:47:42 +00006027 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6028 case " $predeps $postdeps " in
6029 *" $i "*)
6030 newdeplibs="$newdeplibs $i"
6031 i=""
6032 ;;
6033 esac
mlcreech636a9952008-05-05 22:52:56 +00006034 fi
a.rottmann964dbb12004-02-26 19:47:42 +00006035 if test -n "$i" ; then
mlcreech636a9952008-05-05 22:52:56 +00006036 libname=`eval "\\$ECHO \"$libname_spec\""`
6037 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
6038 set dummy $deplib_matches; shift
6039 deplib_match=$1
drh71eb93e2001-09-28 01:34:43 +00006040 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
6041 newdeplibs="$newdeplibs $i"
6042 else
6043 droppeddeps=yes
mlcreech636a9952008-05-05 22:52:56 +00006044 $ECHO
6045 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
6046 $ECHO "*** I have the capability to make that library automatically link in when"
6047 $ECHO "*** you link to this library. But I can only do this if you have a"
6048 $ECHO "*** shared version of the library, which I believe you do not have"
6049 $ECHO "*** because a test_compile did reveal that the linker did not use it for"
6050 $ECHO "*** its dynamic dependency list that programs get resolved with at runtime."
a.rottmann964dbb12004-02-26 19:47:42 +00006051 fi
6052 fi
mlcreech636a9952008-05-05 22:52:56 +00006053 ;;
6054 *)
a.rottmann964dbb12004-02-26 19:47:42 +00006055 newdeplibs="$newdeplibs $i"
mlcreech636a9952008-05-05 22:52:56 +00006056 ;;
6057 esac
a.rottmann964dbb12004-02-26 19:47:42 +00006058 done
6059 else
6060 # Error occurred in the first compile. Let's try to salvage
6061 # the situation: Compile a separate program for each library.
6062 for i in $deplibs; do
mlcreech636a9952008-05-05 22:52:56 +00006063 case $i in
6064 -l*)
6065 func_stripname -l '' "$i"
6066 name=$func_stripname_result
6067 $opt_dry_run || $RM conftest
6068 if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
a.rottmann964dbb12004-02-26 19:47:42 +00006069 ldd_output=`ldd conftest`
6070 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6071 case " $predeps $postdeps " in
6072 *" $i "*)
6073 newdeplibs="$newdeplibs $i"
6074 i=""
6075 ;;
6076 esac
6077 fi
6078 if test -n "$i" ; then
mlcreech636a9952008-05-05 22:52:56 +00006079 libname=`eval "\\$ECHO \"$libname_spec\""`
6080 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
6081 set dummy $deplib_matches; shift
6082 deplib_match=$1
a.rottmann964dbb12004-02-26 19:47:42 +00006083 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
6084 newdeplibs="$newdeplibs $i"
6085 else
6086 droppeddeps=yes
mlcreech636a9952008-05-05 22:52:56 +00006087 $ECHO
6088 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
6089 $ECHO "*** I have the capability to make that library automatically link in when"
6090 $ECHO "*** you link to this library. But I can only do this if you have a"
6091 $ECHO "*** shared version of the library, which you do not appear to have"
6092 $ECHO "*** because a test_compile did reveal that the linker did not use this one"
6093 $ECHO "*** as a dynamic dependency that programs can get resolved with at runtime."
a.rottmann964dbb12004-02-26 19:47:42 +00006094 fi
drh71eb93e2001-09-28 01:34:43 +00006095 fi
6096 else
6097 droppeddeps=yes
mlcreech636a9952008-05-05 22:52:56 +00006098 $ECHO
6099 $ECHO "*** Warning! Library $i is needed by this library but I was not able to"
6100 $ECHO "*** make it link in! You will probably need to install it or some"
6101 $ECHO "*** library that it depends on before this library will be fully"
6102 $ECHO "*** functional. Installing it before continuing would be even better."
drh71eb93e2001-09-28 01:34:43 +00006103 fi
mlcreech636a9952008-05-05 22:52:56 +00006104 ;;
6105 *)
drh71eb93e2001-09-28 01:34:43 +00006106 newdeplibs="$newdeplibs $i"
mlcreech636a9952008-05-05 22:52:56 +00006107 ;;
6108 esac
drh71eb93e2001-09-28 01:34:43 +00006109 done
6110 fi
6111 ;;
6112 file_magic*)
mlcreech636a9952008-05-05 22:52:56 +00006113 set dummy $deplibs_check_method; shift
6114 file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
drh71eb93e2001-09-28 01:34:43 +00006115 for a_deplib in $deplibs; do
mlcreech636a9952008-05-05 22:52:56 +00006116 case $a_deplib in
6117 -l*)
6118 func_stripname -l '' "$a_deplib"
6119 name=$func_stripname_result
a.rottmann964dbb12004-02-26 19:47:42 +00006120 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6121 case " $predeps $postdeps " in
6122 *" $a_deplib "*)
6123 newdeplibs="$newdeplibs $a_deplib"
6124 a_deplib=""
6125 ;;
6126 esac
6127 fi
6128 if test -n "$a_deplib" ; then
mlcreech636a9952008-05-05 22:52:56 +00006129 libname=`eval "\\$ECHO \"$libname_spec\""`
a.rottmann964dbb12004-02-26 19:47:42 +00006130 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
6131 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
6132 for potent_lib in $potential_libs; do
drh71eb93e2001-09-28 01:34:43 +00006133 # Follow soft links.
mlcreech636a9952008-05-05 22:52:56 +00006134 if ls -lLd "$potent_lib" 2>/dev/null |
6135 $GREP " -> " >/dev/null; then
drh71eb93e2001-09-28 01:34:43 +00006136 continue
6137 fi
6138 # The statement above tries to avoid entering an
6139 # endless loop below, in case of cyclic links.
6140 # We might still enter an endless loop, since a link
6141 # loop can be closed while we follow links,
6142 # but so what?
6143 potlib="$potent_lib"
6144 while test -h "$potlib" 2>/dev/null; do
a.rottmann62507b62003-03-24 09:40:34 +00006145 potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
drh71eb93e2001-09-28 01:34:43 +00006146 case $potliblink in
6147 [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
mlcreech636a9952008-05-05 22:52:56 +00006148 *) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
drh71eb93e2001-09-28 01:34:43 +00006149 esac
6150 done
mlcreech636a9952008-05-05 22:52:56 +00006151 if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
6152 $SED -e 10q |
6153 $EGREP "$file_magic_regex" > /dev/null; then
drh71eb93e2001-09-28 01:34:43 +00006154 newdeplibs="$newdeplibs $a_deplib"
6155 a_deplib=""
6156 break 2
6157 fi
a.rottmann964dbb12004-02-26 19:47:42 +00006158 done
6159 done
6160 fi
drh71eb93e2001-09-28 01:34:43 +00006161 if test -n "$a_deplib" ; then
6162 droppeddeps=yes
mlcreech636a9952008-05-05 22:52:56 +00006163 $ECHO
6164 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
6165 $ECHO "*** I have the capability to make that library automatically link in when"
6166 $ECHO "*** you link to this library. But I can only do this if you have a"
6167 $ECHO "*** shared version of the library, which you do not appear to have"
6168 $ECHO "*** because I did check the linker path looking for a file starting"
a.rottmann62507b62003-03-24 09:40:34 +00006169 if test -z "$potlib" ; then
mlcreech636a9952008-05-05 22:52:56 +00006170 $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
a.rottmann62507b62003-03-24 09:40:34 +00006171 else
mlcreech636a9952008-05-05 22:52:56 +00006172 $ECHO "*** with $libname and none of the candidates passed a file format test"
6173 $ECHO "*** using a file magic. Last file checked: $potlib"
a.rottmann62507b62003-03-24 09:40:34 +00006174 fi
drh71eb93e2001-09-28 01:34:43 +00006175 fi
mlcreech636a9952008-05-05 22:52:56 +00006176 ;;
6177 *)
drh71eb93e2001-09-28 01:34:43 +00006178 # Add a -L argument.
6179 newdeplibs="$newdeplibs $a_deplib"
mlcreech636a9952008-05-05 22:52:56 +00006180 ;;
6181 esac
drh71eb93e2001-09-28 01:34:43 +00006182 done # Gone through all deplibs.
6183 ;;
6184 match_pattern*)
mlcreech636a9952008-05-05 22:52:56 +00006185 set dummy $deplibs_check_method; shift
6186 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
drh71eb93e2001-09-28 01:34:43 +00006187 for a_deplib in $deplibs; do
mlcreech636a9952008-05-05 22:52:56 +00006188 case $a_deplib in
6189 -l*)
6190 func_stripname -l '' "$a_deplib"
6191 name=$func_stripname_result
a.rottmann964dbb12004-02-26 19:47:42 +00006192 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6193 case " $predeps $postdeps " in
6194 *" $a_deplib "*)
6195 newdeplibs="$newdeplibs $a_deplib"
6196 a_deplib=""
6197 ;;
6198 esac
6199 fi
6200 if test -n "$a_deplib" ; then
mlcreech636a9952008-05-05 22:52:56 +00006201 libname=`eval "\\$ECHO \"$libname_spec\""`
a.rottmann964dbb12004-02-26 19:47:42 +00006202 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
6203 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
6204 for potent_lib in $potential_libs; do
6205 potlib="$potent_lib" # see symlink-check above in file_magic test
mlcreech636a9952008-05-05 22:52:56 +00006206 if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \
6207 $EGREP "$match_pattern_regex" > /dev/null; then
a.rottmann964dbb12004-02-26 19:47:42 +00006208 newdeplibs="$newdeplibs $a_deplib"
6209 a_deplib=""
6210 break 2
6211 fi
6212 done
drh71eb93e2001-09-28 01:34:43 +00006213 done
a.rottmann964dbb12004-02-26 19:47:42 +00006214 fi
drh71eb93e2001-09-28 01:34:43 +00006215 if test -n "$a_deplib" ; then
6216 droppeddeps=yes
mlcreech636a9952008-05-05 22:52:56 +00006217 $ECHO
6218 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
6219 $ECHO "*** I have the capability to make that library automatically link in when"
6220 $ECHO "*** you link to this library. But I can only do this if you have a"
6221 $ECHO "*** shared version of the library, which you do not appear to have"
6222 $ECHO "*** because I did check the linker path looking for a file starting"
a.rottmann62507b62003-03-24 09:40:34 +00006223 if test -z "$potlib" ; then
mlcreech636a9952008-05-05 22:52:56 +00006224 $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
a.rottmann62507b62003-03-24 09:40:34 +00006225 else
mlcreech636a9952008-05-05 22:52:56 +00006226 $ECHO "*** with $libname and none of the candidates passed a file format test"
6227 $ECHO "*** using a regex pattern. Last file checked: $potlib"
a.rottmann62507b62003-03-24 09:40:34 +00006228 fi
drh71eb93e2001-09-28 01:34:43 +00006229 fi
mlcreech636a9952008-05-05 22:52:56 +00006230 ;;
6231 *)
drh71eb93e2001-09-28 01:34:43 +00006232 # Add a -L argument.
6233 newdeplibs="$newdeplibs $a_deplib"
mlcreech636a9952008-05-05 22:52:56 +00006234 ;;
6235 esac
drh71eb93e2001-09-28 01:34:43 +00006236 done # Gone through all deplibs.
6237 ;;
6238 none | unknown | *)
6239 newdeplibs=""
mlcreech636a9952008-05-05 22:52:56 +00006240 tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \
6241 -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'`
a.rottmann964dbb12004-02-26 19:47:42 +00006242 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6243 for i in $predeps $postdeps ; do
6244 # can't use Xsed below, because $i might contain '/'
mlcreech636a9952008-05-05 22:52:56 +00006245 tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"`
a.rottmann964dbb12004-02-26 19:47:42 +00006246 done
6247 fi
mlcreech636a9952008-05-05 22:52:56 +00006248 if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' |
6249 $GREP . >/dev/null; then
6250 $ECHO
drh71eb93e2001-09-28 01:34:43 +00006251 if test "X$deplibs_check_method" = "Xnone"; then
mlcreech636a9952008-05-05 22:52:56 +00006252 $ECHO "*** Warning: inter-library dependencies are not supported in this platform."
drh71eb93e2001-09-28 01:34:43 +00006253 else
mlcreech636a9952008-05-05 22:52:56 +00006254 $ECHO "*** Warning: inter-library dependencies are not known to be supported."
drh71eb93e2001-09-28 01:34:43 +00006255 fi
mlcreech636a9952008-05-05 22:52:56 +00006256 $ECHO "*** All declared inter-library dependencies are being dropped."
drh71eb93e2001-09-28 01:34:43 +00006257 droppeddeps=yes
6258 fi
6259 ;;
6260 esac
6261 versuffix=$versuffix_save
6262 major=$major_save
6263 release=$release_save
6264 libname=$libname_save
6265 name=$name_save
6266
6267 case $host in
6268 *-*-rhapsody* | *-*-darwin1.[012])
mlcreech636a9952008-05-05 22:52:56 +00006269 # On Rhapsody replace the C library with the System framework
6270 newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
drh71eb93e2001-09-28 01:34:43 +00006271 ;;
6272 esac
6273
6274 if test "$droppeddeps" = yes; then
6275 if test "$module" = yes; then
mlcreech636a9952008-05-05 22:52:56 +00006276 $ECHO
6277 $ECHO "*** Warning: libtool could not satisfy all declared inter-library"
6278 $ECHO "*** dependencies of module $libname. Therefore, libtool will create"
6279 $ECHO "*** a static module, that should work as long as the dlopening"
6280 $ECHO "*** application is linked with the -dlopen flag."
drh71eb93e2001-09-28 01:34:43 +00006281 if test -z "$global_symbol_pipe"; then
mlcreech636a9952008-05-05 22:52:56 +00006282 $ECHO
6283 $ECHO "*** However, this would only work if libtool was able to extract symbol"
6284 $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
6285 $ECHO "*** not find such a program. So, this module is probably useless."
6286 $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
drh71eb93e2001-09-28 01:34:43 +00006287 fi
6288 if test "$build_old_libs" = no; then
6289 oldlibs="$output_objdir/$libname.$libext"
6290 build_libtool_libs=module
6291 build_old_libs=yes
6292 else
6293 build_libtool_libs=no
6294 fi
6295 else
mlcreech636a9952008-05-05 22:52:56 +00006296 $ECHO "*** The inter-library dependencies that have been dropped here will be"
6297 $ECHO "*** automatically added whenever a program is linked with this library"
6298 $ECHO "*** or is declared to -dlopen it."
drh71eb93e2001-09-28 01:34:43 +00006299
a.rottmann964dbb12004-02-26 19:47:42 +00006300 if test "$allow_undefined" = no; then
mlcreech636a9952008-05-05 22:52:56 +00006301 $ECHO
6302 $ECHO "*** Since this library must not contain undefined symbols,"
6303 $ECHO "*** because either the platform does not support them or"
6304 $ECHO "*** it was explicitly requested with -no-undefined,"
6305 $ECHO "*** libtool will only create a static version of it."
drh71eb93e2001-09-28 01:34:43 +00006306 if test "$build_old_libs" = no; then
6307 oldlibs="$output_objdir/$libname.$libext"
6308 build_libtool_libs=module
6309 build_old_libs=yes
6310 else
6311 build_libtool_libs=no
6312 fi
6313 fi
6314 fi
6315 fi
6316 # Done checking deplibs!
6317 deplibs=$newdeplibs
6318 fi
mlcreech636a9952008-05-05 22:52:56 +00006319 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
6320 case $host in
6321 *-*-darwin*)
6322 newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6323 new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6324 deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6325 ;;
6326 esac
vapier7f19c022007-02-17 14:46:31 +00006327
6328 # move library search paths that coincide with paths to not yet
6329 # installed libraries to the beginning of the library search list
6330 new_libs=
6331 for path in $notinst_path; do
6332 case " $new_libs " in
6333 *" -L$path/$objdir "*) ;;
6334 *)
6335 case " $deplibs " in
6336 *" -L$path/$objdir "*)
6337 new_libs="$new_libs -L$path/$objdir" ;;
6338 esac
6339 ;;
6340 esac
6341 done
6342 for deplib in $deplibs; do
6343 case $deplib in
6344 -L*)
6345 case " $new_libs " in
6346 *" $deplib "*) ;;
6347 *) new_libs="$new_libs $deplib" ;;
6348 esac
6349 ;;
6350 *) new_libs="$new_libs $deplib" ;;
6351 esac
6352 done
6353 deplibs="$new_libs"
6354
drh71eb93e2001-09-28 01:34:43 +00006355 # All the library-specific variables (install_libdir is set above).
6356 library_names=
6357 old_library=
6358 dlname=
6359
6360 # Test again, we may have decided not to build it any more
6361 if test "$build_libtool_libs" = yes; then
a.rottmann964dbb12004-02-26 19:47:42 +00006362 if test "$hardcode_into_libs" = yes; then
drh71eb93e2001-09-28 01:34:43 +00006363 # Hardcode the library paths
6364 hardcode_libdirs=
6365 dep_rpath=
6366 rpath="$finalize_rpath"
6367 test "$mode" != relink && rpath="$compile_rpath$rpath"
6368 for libdir in $rpath; do
6369 if test -n "$hardcode_libdir_flag_spec"; then
6370 if test -n "$hardcode_libdir_separator"; then
6371 if test -z "$hardcode_libdirs"; then
6372 hardcode_libdirs="$libdir"
6373 else
6374 # Just accumulate the unique libdirs.
6375 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
6376 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
6377 ;;
6378 *)
6379 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
6380 ;;
6381 esac
6382 fi
6383 else
6384 eval flag=\"$hardcode_libdir_flag_spec\"
6385 dep_rpath="$dep_rpath $flag"
6386 fi
6387 elif test -n "$runpath_var"; then
6388 case "$perm_rpath " in
6389 *" $libdir "*) ;;
6390 *) perm_rpath="$perm_rpath $libdir" ;;
6391 esac
6392 fi
6393 done
6394 # Substitute the hardcoded libdirs into the rpath.
6395 if test -n "$hardcode_libdir_separator" &&
6396 test -n "$hardcode_libdirs"; then
6397 libdir="$hardcode_libdirs"
a.rottmann964dbb12004-02-26 19:47:42 +00006398 if test -n "$hardcode_libdir_flag_spec_ld"; then
6399 eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
6400 else
6401 eval dep_rpath=\"$hardcode_libdir_flag_spec\"
6402 fi
drh71eb93e2001-09-28 01:34:43 +00006403 fi
6404 if test -n "$runpath_var" && test -n "$perm_rpath"; then
6405 # We should set the runpath_var.
6406 rpath=
6407 for dir in $perm_rpath; do
6408 rpath="$rpath$dir:"
6409 done
6410 eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
6411 fi
6412 test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
6413 fi
6414
6415 shlibpath="$finalize_shlibpath"
6416 test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
6417 if test -n "$shlibpath"; then
6418 eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
6419 fi
6420
6421 # Get the real and link names of the library.
vapier7f19c022007-02-17 14:46:31 +00006422 eval shared_ext=\"$shrext_cmds\"
drh71eb93e2001-09-28 01:34:43 +00006423 eval library_names=\"$library_names_spec\"
6424 set dummy $library_names
mlcreech636a9952008-05-05 22:52:56 +00006425 shift
6426 realname="$1"
6427 shift
drh71eb93e2001-09-28 01:34:43 +00006428
6429 if test -n "$soname_spec"; then
6430 eval soname=\"$soname_spec\"
6431 else
6432 soname="$realname"
6433 fi
a.rottmann964dbb12004-02-26 19:47:42 +00006434 if test -z "$dlname"; then
6435 dlname=$soname
6436 fi
drh71eb93e2001-09-28 01:34:43 +00006437
6438 lib="$output_objdir/$realname"
vapier7f19c022007-02-17 14:46:31 +00006439 linknames=
drh71eb93e2001-09-28 01:34:43 +00006440 for link
6441 do
6442 linknames="$linknames $link"
6443 done
6444
6445 # Use standard objects if they are pic
mlcreech636a9952008-05-05 22:52:56 +00006446 test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
6447 test "X$libobjs" = "X " && libobjs=
6448
6449 delfiles=
6450 if test -n "$export_symbols" && test -n "$include_expsyms"; then
6451 $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
6452 export_symbols="$output_objdir/$libname.uexp"
6453 delfiles="$delfiles $export_symbols"
6454 fi
6455
6456 orig_export_symbols=
6457 case $host_os in
6458 cygwin* | mingw*)
6459 if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
6460 # exporting using user supplied symfile
6461 if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
6462 # and it's NOT already a .def file. Must figure out
6463 # which of the given symbols are data symbols and tag
6464 # them as such. So, trigger use of export_symbols_cmds.
6465 # export_symbols gets reassigned inside the "prepare
6466 # the list of exported symbols" if statement, so the
6467 # include_expsyms logic still works.
6468 orig_export_symbols="$export_symbols"
6469 export_symbols=
6470 always_export_symbols=yes
6471 fi
6472 fi
6473 ;;
6474 esac
drh71eb93e2001-09-28 01:34:43 +00006475
6476 # Prepare the list of exported symbols
6477 if test -z "$export_symbols"; then
6478 if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
mlcreech636a9952008-05-05 22:52:56 +00006479 func_verbose "generating symbol list for \`$libname.la'"
drh71eb93e2001-09-28 01:34:43 +00006480 export_symbols="$output_objdir/$libname.exp"
mlcreech636a9952008-05-05 22:52:56 +00006481 $opt_dry_run || $RM $export_symbols
a.rottmann964dbb12004-02-26 19:47:42 +00006482 cmds=$export_symbols_cmds
a.rottmann62507b62003-03-24 09:40:34 +00006483 save_ifs="$IFS"; IFS='~'
drh71eb93e2001-09-28 01:34:43 +00006484 for cmd in $cmds; do
6485 IFS="$save_ifs"
a.rottmann964dbb12004-02-26 19:47:42 +00006486 eval cmd=\"$cmd\"
mlcreech636a9952008-05-05 22:52:56 +00006487 func_len " $cmd"
6488 len=$func_len_result
6489 if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
6490 func_show_eval "$cmd" 'exit $?'
6491 skipped_export=false
a.rottmann964dbb12004-02-26 19:47:42 +00006492 else
mlcreech636a9952008-05-05 22:52:56 +00006493 # The command line is too long to execute in one step.
6494 func_verbose "using reloadable object file for export list..."
6495 skipped_export=:
vapier7f19c022007-02-17 14:46:31 +00006496 # Break out early, otherwise skipped_export may be
6497 # set to false by a later but shorter cmd.
6498 break
a.rottmann964dbb12004-02-26 19:47:42 +00006499 fi
drh71eb93e2001-09-28 01:34:43 +00006500 done
6501 IFS="$save_ifs"
mlcreech636a9952008-05-05 22:52:56 +00006502 if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
6503 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
6504 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
drh71eb93e2001-09-28 01:34:43 +00006505 fi
6506 fi
6507 fi
6508
6509 if test -n "$export_symbols" && test -n "$include_expsyms"; then
mlcreech636a9952008-05-05 22:52:56 +00006510 tmp_export_symbols="$export_symbols"
6511 test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
6512 $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
6513 fi
6514
6515 if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
6516 # The given exports_symbols file has to be filtered, so filter it.
6517 func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
6518 # FIXME: $output_objdir/$libname.filter potentially contains lots of
6519 # 's' commands which not all seds can handle. GNU sed should be fine
6520 # though. Also, the filter scales superlinearly with the number of
6521 # global variables. join(1) would be nice here, but unfortunately
6522 # isn't a blessed tool.
6523 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
6524 delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
6525 export_symbols=$output_objdir/$libname.def
6526 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
drh71eb93e2001-09-28 01:34:43 +00006527 fi
6528
a.rottmann964dbb12004-02-26 19:47:42 +00006529 tmp_deplibs=
6530 for test_deplib in $deplibs; do
mlcreech636a9952008-05-05 22:52:56 +00006531 case " $convenience " in
6532 *" $test_deplib "*) ;;
6533 *)
6534 tmp_deplibs="$tmp_deplibs $test_deplib"
6535 ;;
6536 esac
a.rottmann964dbb12004-02-26 19:47:42 +00006537 done
vapier7f19c022007-02-17 14:46:31 +00006538 deplibs="$tmp_deplibs"
a.rottmann964dbb12004-02-26 19:47:42 +00006539
drh71eb93e2001-09-28 01:34:43 +00006540 if test -n "$convenience"; then
mlcreech636a9952008-05-05 22:52:56 +00006541 if test -n "$whole_archive_flag_spec" &&
6542 test "$compiler_needs_object" = yes &&
6543 test -z "$libobjs"; then
6544 # extract the archives, so we have objects to list.
6545 # TODO: could optimize this to just extract one archive.
6546 whole_archive_flag_spec=
6547 fi
drh71eb93e2001-09-28 01:34:43 +00006548 if test -n "$whole_archive_flag_spec"; then
a.rottmann964dbb12004-02-26 19:47:42 +00006549 save_libobjs=$libobjs
drh71eb93e2001-09-28 01:34:43 +00006550 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
mlcreech636a9952008-05-05 22:52:56 +00006551 test "X$libobjs" = "X " && libobjs=
drh71eb93e2001-09-28 01:34:43 +00006552 else
6553 gentop="$output_objdir/${outputname}x"
drh71eb93e2001-09-28 01:34:43 +00006554 generated="$generated $gentop"
6555
vapier7f19c022007-02-17 14:46:31 +00006556 func_extract_archives $gentop $convenience
6557 libobjs="$libobjs $func_extract_archives_result"
mlcreech636a9952008-05-05 22:52:56 +00006558 test "X$libobjs" = "X " && libobjs=
drh71eb93e2001-09-28 01:34:43 +00006559 fi
6560 fi
mlcreech636a9952008-05-05 22:52:56 +00006561
drh71eb93e2001-09-28 01:34:43 +00006562 if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
6563 eval flag=\"$thread_safe_flag_spec\"
6564 linker_flags="$linker_flags $flag"
6565 fi
6566
6567 # Make a backup of the uninstalled library when relinking
6568 if test "$mode" = relink; then
mlcreech636a9952008-05-05 22:52:56 +00006569 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
drh71eb93e2001-09-28 01:34:43 +00006570 fi
6571
6572 # Do each of the archive commands.
a.rottmann964dbb12004-02-26 19:47:42 +00006573 if test "$module" = yes && test -n "$module_cmds" ; then
6574 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
6575 eval test_cmds=\"$module_expsym_cmds\"
6576 cmds=$module_expsym_cmds
6577 else
6578 eval test_cmds=\"$module_cmds\"
6579 cmds=$module_cmds
6580 fi
drh71eb93e2001-09-28 01:34:43 +00006581 else
mlcreech636a9952008-05-05 22:52:56 +00006582 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
6583 eval test_cmds=\"$archive_expsym_cmds\"
6584 cmds=$archive_expsym_cmds
6585 else
6586 eval test_cmds=\"$archive_cmds\"
6587 cmds=$archive_cmds
a.rottmann964dbb12004-02-26 19:47:42 +00006588 fi
6589 fi
6590
vapier7f19c022007-02-17 14:46:31 +00006591 if test "X$skipped_export" != "X:" &&
mlcreech636a9952008-05-05 22:52:56 +00006592 func_len " $test_cmds" &&
6593 len=$func_len_result &&
6594 test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
a.rottmann964dbb12004-02-26 19:47:42 +00006595 :
6596 else
mlcreech636a9952008-05-05 22:52:56 +00006597 # The command line is too long to link in one step, link piecewise
6598 # or, if using GNU ld and skipped_export is not :, use a linker
6599 # script.
a.rottmann964dbb12004-02-26 19:47:42 +00006600
6601 # Save the value of $output and $libobjs because we want to
6602 # use them later. If we have whole_archive_flag_spec, we
6603 # want to use save_libobjs as it was before
6604 # whole_archive_flag_spec was expanded, because we can't
6605 # assume the linker understands whole_archive_flag_spec.
6606 # This may have to be revisited, in case too many
6607 # convenience libraries get linked in and end up exceeding
6608 # the spec.
6609 if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
6610 save_libobjs=$libobjs
6611 fi
6612 save_output=$output
mlcreech636a9952008-05-05 22:52:56 +00006613 output_la=`$ECHO "X$output" | $Xsed -e "$basename"`
a.rottmann964dbb12004-02-26 19:47:42 +00006614
6615 # Clear the reloadable object creation command queue and
6616 # initialize k to one.
6617 test_cmds=
6618 concat_cmds=
6619 objlist=
a.rottmann964dbb12004-02-26 19:47:42 +00006620 last_robj=
6621 k=1
mlcreech636a9952008-05-05 22:52:56 +00006622
6623 if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
6624 output=${output_objdir}/${output_la}.lnkscript
6625 func_verbose "creating GNU ld script: $output"
6626 $ECHO 'INPUT (' > $output
6627 for obj in $save_libobjs
6628 do
6629 $ECHO "$obj" >> $output
6630 done
6631 $ECHO ')' >> $output
6632 delfiles="$delfiles $output"
6633 elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
6634 output=${output_objdir}/${output_la}.lnk
6635 func_verbose "creating linker input file list: $output"
6636 : > $output
6637 set x $save_libobjs
6638 shift
6639 firstobj=
6640 if test "$compiler_needs_object" = yes; then
6641 firstobj="$1 "
6642 shift
a.rottmann964dbb12004-02-26 19:47:42 +00006643 fi
mlcreech636a9952008-05-05 22:52:56 +00006644 for obj
6645 do
6646 $ECHO "$obj" >> $output
6647 done
6648 delfiles="$delfiles $output"
6649 output=$firstobj\"$file_list_spec$output\"
6650 else
6651 if test -n "$save_libobjs"; then
6652 func_verbose "creating reloadable object files..."
6653 output=$output_objdir/$output_la-${k}.$objext
6654 eval test_cmds=\"$reload_cmds\"
6655 func_len " $test_cmds"
6656 len0=$func_len_result
6657 len=$len0
a.rottmann964dbb12004-02-26 19:47:42 +00006658
mlcreech636a9952008-05-05 22:52:56 +00006659 # Loop over the list of objects to be linked.
6660 for obj in $save_libobjs
6661 do
6662 func_len " $obj"
6663 func_arith $len + $func_len_result
6664 len=$func_arith_result
6665 if test "X$objlist" = X ||
6666 test "$len" -lt "$max_cmd_len"; then
6667 func_append objlist " $obj"
6668 else
6669 # The command $test_cmds is almost too long, add a
6670 # command to the queue.
6671 if test "$k" -eq 1 ; then
6672 # The first file doesn't have a previous command to add.
6673 eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
6674 else
6675 # All subsequent reloadable object files will link in
6676 # the last one created.
6677 eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\"
6678 fi
6679 last_robj=$output_objdir/$output_la-${k}.$objext
6680 func_arith $k + 1
6681 k=$func_arith_result
6682 output=$output_objdir/$output_la-${k}.$objext
6683 objlist=$obj
6684 func_len " $last_robj"
6685 func_arith $len0 + $func_len_result
6686 len=$func_arith_result
6687 fi
6688 done
6689 # Handle the remaining objects by creating one last
6690 # reloadable object file. All subsequent reloadable object
6691 # files will link in the last one created.
6692 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
6693 eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
6694 if test -n "$last_robj"; then
6695 eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
6696 fi
6697 delfiles="$delfiles $output"
a.rottmann964dbb12004-02-26 19:47:42 +00006698
mlcreech636a9952008-05-05 22:52:56 +00006699 else
6700 output=
6701 fi
a.rottmann964dbb12004-02-26 19:47:42 +00006702
mlcreech636a9952008-05-05 22:52:56 +00006703 if ${skipped_export-false}; then
6704 func_verbose "generating symbol list for \`$libname.la'"
6705 export_symbols="$output_objdir/$libname.exp"
6706 $opt_dry_run || $RM $export_symbols
6707 libobjs=$output
6708 # Append the command to create the export file.
6709 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
6710 eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
6711 if test -n "$last_robj"; then
6712 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
6713 fi
6714 fi
a.rottmann964dbb12004-02-26 19:47:42 +00006715
mlcreech636a9952008-05-05 22:52:56 +00006716 test -n "$save_libobjs" &&
6717 func_verbose "creating a temporary reloadable object file: $output"
6718
6719 # Loop through the commands generated above and execute them.
6720 save_ifs="$IFS"; IFS='~'
6721 for cmd in $concat_cmds; do
6722 IFS="$save_ifs"
6723 $opt_silent || {
6724 func_quote_for_expand "$cmd"
6725 eval "func_echo $func_quote_for_expand_result"
6726 }
6727 $opt_dry_run || eval "$cmd" || {
6728 lt_exit=$?
6729
6730 # Restore the uninstalled library and exit
6731 if test "$mode" = relink; then
6732 ( cd "$output_objdir" && \
6733 $RM "${realname}T" && \
6734 $MV "${realname}U" "$realname" )
6735 fi
6736
6737 exit $lt_exit
6738 }
6739 done
a.rottmann964dbb12004-02-26 19:47:42 +00006740 IFS="$save_ifs"
mlcreech636a9952008-05-05 22:52:56 +00006741
6742 if test -n "$export_symbols_regex" && ${skipped_export-false}; then
6743 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
6744 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
6745 fi
6746 fi
6747
6748 if ${skipped_export-false}; then
6749 if test -n "$export_symbols" && test -n "$include_expsyms"; then
6750 tmp_export_symbols="$export_symbols"
6751 test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
6752 $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
6753 fi
6754
6755 if test -n "$orig_export_symbols"; then
6756 # The given exports_symbols file has to be filtered, so filter it.
6757 func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
6758 # FIXME: $output_objdir/$libname.filter potentially contains lots of
6759 # 's' commands which not all seds can handle. GNU sed should be fine
6760 # though. Also, the filter scales superlinearly with the number of
6761 # global variables. join(1) would be nice here, but unfortunately
6762 # isn't a blessed tool.
6763 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
6764 delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
6765 export_symbols=$output_objdir/$libname.def
6766 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
6767 fi
6768 fi
a.rottmann964dbb12004-02-26 19:47:42 +00006769
6770 libobjs=$output
6771 # Restore the value of output.
6772 output=$save_output
6773
6774 if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
6775 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
mlcreech636a9952008-05-05 22:52:56 +00006776 test "X$libobjs" = "X " && libobjs=
a.rottmann964dbb12004-02-26 19:47:42 +00006777 fi
6778 # Expand the library linking commands again to reset the
6779 # value of $libobjs for piecewise linking.
6780
6781 # Do each of the archive commands.
6782 if test "$module" = yes && test -n "$module_cmds" ; then
6783 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
6784 cmds=$module_expsym_cmds
6785 else
6786 cmds=$module_cmds
6787 fi
6788 else
mlcreech636a9952008-05-05 22:52:56 +00006789 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
6790 cmds=$archive_expsym_cmds
6791 else
6792 cmds=$archive_cmds
a.rottmann964dbb12004-02-26 19:47:42 +00006793 fi
6794 fi
drh71eb93e2001-09-28 01:34:43 +00006795 fi
mlcreech636a9952008-05-05 22:52:56 +00006796
6797 if test -n "$delfiles"; then
6798 # Append the command to remove temporary files to $cmds.
6799 eval cmds=\"\$cmds~\$RM $delfiles\"
6800 fi
6801
6802 # Add any objects from preloaded convenience libraries
6803 if test -n "$dlprefiles"; then
6804 gentop="$output_objdir/${outputname}x"
6805 generated="$generated $gentop"
6806
6807 func_extract_archives $gentop $dlprefiles
6808 libobjs="$libobjs $func_extract_archives_result"
6809 test "X$libobjs" = "X " && libobjs=
6810 fi
6811
a.rottmann62507b62003-03-24 09:40:34 +00006812 save_ifs="$IFS"; IFS='~'
6813 for cmd in $cmds; do
6814 IFS="$save_ifs"
a.rottmann964dbb12004-02-26 19:47:42 +00006815 eval cmd=\"$cmd\"
mlcreech636a9952008-05-05 22:52:56 +00006816 $opt_silent || {
6817 func_quote_for_expand "$cmd"
6818 eval "func_echo $func_quote_for_expand_result"
6819 }
6820 $opt_dry_run || eval "$cmd" || {
vapier7f19c022007-02-17 14:46:31 +00006821 lt_exit=$?
6822
6823 # Restore the uninstalled library and exit
6824 if test "$mode" = relink; then
mlcreech636a9952008-05-05 22:52:56 +00006825 ( cd "$output_objdir" && \
6826 $RM "${realname}T" && \
6827 $MV "${realname}U" "$realname" )
vapier7f19c022007-02-17 14:46:31 +00006828 fi
6829
6830 exit $lt_exit
6831 }
a.rottmann62507b62003-03-24 09:40:34 +00006832 done
6833 IFS="$save_ifs"
drh71eb93e2001-09-28 01:34:43 +00006834
6835 # Restore the uninstalled library and exit
6836 if test "$mode" = relink; then
mlcreech636a9952008-05-05 22:52:56 +00006837 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
vapier7f19c022007-02-17 14:46:31 +00006838
6839 if test -n "$convenience"; then
6840 if test -z "$whole_archive_flag_spec"; then
mlcreech636a9952008-05-05 22:52:56 +00006841 func_show_eval '${RM}r "$gentop"'
vapier7f19c022007-02-17 14:46:31 +00006842 fi
6843 fi
6844
6845 exit $EXIT_SUCCESS
drh71eb93e2001-09-28 01:34:43 +00006846 fi
6847
6848 # Create links to the real library.
6849 for linkname in $linknames; do
6850 if test "$realname" != "$linkname"; then
mlcreech636a9952008-05-05 22:52:56 +00006851 func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
drh71eb93e2001-09-28 01:34:43 +00006852 fi
6853 done
6854
6855 # If -module or -export-dynamic was specified, set the dlname.
6856 if test "$module" = yes || test "$export_dynamic" = yes; then
6857 # On all known operating systems, these are identical.
6858 dlname="$soname"
6859 fi
6860 fi
6861 ;;
6862
6863 obj)
drh71eb93e2001-09-28 01:34:43 +00006864 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
mlcreech636a9952008-05-05 22:52:56 +00006865 func_warning "\`-dlopen' is ignored for objects"
drh71eb93e2001-09-28 01:34:43 +00006866 fi
6867
mlcreech636a9952008-05-05 22:52:56 +00006868 case " $deplibs" in
6869 *\ -l* | *\ -L*)
6870 func_warning "\`-l' and \`-L' are ignored for objects" ;;
6871 esac
drh71eb93e2001-09-28 01:34:43 +00006872
mlcreech636a9952008-05-05 22:52:56 +00006873 test -n "$rpath" && \
6874 func_warning "\`-rpath' is ignored for objects"
drh71eb93e2001-09-28 01:34:43 +00006875
mlcreech636a9952008-05-05 22:52:56 +00006876 test -n "$xrpath" && \
6877 func_warning "\`-R' is ignored for objects"
drh71eb93e2001-09-28 01:34:43 +00006878
mlcreech636a9952008-05-05 22:52:56 +00006879 test -n "$vinfo" && \
6880 func_warning "\`-version-info' is ignored for objects"
6881
6882 test -n "$release" && \
6883 func_warning "\`-release' is ignored for objects"
drh71eb93e2001-09-28 01:34:43 +00006884
6885 case $output in
6886 *.lo)
mlcreech636a9952008-05-05 22:52:56 +00006887 test -n "$objs$old_deplibs" && \
6888 func_fatal_error "cannot build library object \`$output' from non-libtool objects"
6889
6890 libobj=$output
6891 func_lo2o "$libobj"
6892 obj=$func_lo2o_result
drh71eb93e2001-09-28 01:34:43 +00006893 ;;
6894 *)
6895 libobj=
6896 obj="$output"
6897 ;;
6898 esac
6899
6900 # Delete the old objects.
mlcreech636a9952008-05-05 22:52:56 +00006901 $opt_dry_run || $RM $obj $libobj
drh71eb93e2001-09-28 01:34:43 +00006902
6903 # Objects from convenience libraries. This assumes
6904 # single-version convenience libraries. Whenever we create
6905 # different ones for PIC/non-PIC, this we'll have to duplicate
6906 # the extraction.
6907 reload_conv_objs=
6908 gentop=
6909 # reload_cmds runs $LD directly, so let us get rid of
mlcreech636a9952008-05-05 22:52:56 +00006910 # -Wl from whole_archive_flag_spec and hope we can get by with
6911 # turning comma into space..
drh71eb93e2001-09-28 01:34:43 +00006912 wl=
6913
6914 if test -n "$convenience"; then
6915 if test -n "$whole_archive_flag_spec"; then
mlcreech636a9952008-05-05 22:52:56 +00006916 eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
6917 reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
drh71eb93e2001-09-28 01:34:43 +00006918 else
6919 gentop="$output_objdir/${obj}x"
drh71eb93e2001-09-28 01:34:43 +00006920 generated="$generated $gentop"
6921
vapier7f19c022007-02-17 14:46:31 +00006922 func_extract_archives $gentop $convenience
6923 reload_conv_objs="$reload_objs $func_extract_archives_result"
drh71eb93e2001-09-28 01:34:43 +00006924 fi
6925 fi
6926
6927 # Create the old-style object.
mlcreech636a9952008-05-05 22:52:56 +00006928 reload_objs="$objs$old_deplibs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
drh71eb93e2001-09-28 01:34:43 +00006929
6930 output="$obj"
mlcreech636a9952008-05-05 22:52:56 +00006931 func_execute_cmds "$reload_cmds" 'exit $?'
drh71eb93e2001-09-28 01:34:43 +00006932
6933 # Exit if we aren't doing a library object file.
6934 if test -z "$libobj"; then
6935 if test -n "$gentop"; then
mlcreech636a9952008-05-05 22:52:56 +00006936 func_show_eval '${RM}r "$gentop"'
drh71eb93e2001-09-28 01:34:43 +00006937 fi
6938
vapier7f19c022007-02-17 14:46:31 +00006939 exit $EXIT_SUCCESS
drh71eb93e2001-09-28 01:34:43 +00006940 fi
6941
6942 if test "$build_libtool_libs" != yes; then
6943 if test -n "$gentop"; then
mlcreech636a9952008-05-05 22:52:56 +00006944 func_show_eval '${RM}r "$gentop"'
drh71eb93e2001-09-28 01:34:43 +00006945 fi
6946
6947 # Create an invalid libtool object if no PIC, so that we don't
6948 # accidentally link it into a program.
a.rottmann964dbb12004-02-26 19:47:42 +00006949 # $show "echo timestamp > $libobj"
mlcreech636a9952008-05-05 22:52:56 +00006950 # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
vapier7f19c022007-02-17 14:46:31 +00006951 exit $EXIT_SUCCESS
drh71eb93e2001-09-28 01:34:43 +00006952 fi
6953
6954 if test -n "$pic_flag" || test "$pic_mode" != default; then
6955 # Only do commands if we really have different PIC objects.
6956 reload_objs="$libobjs $reload_conv_objs"
6957 output="$libobj"
mlcreech636a9952008-05-05 22:52:56 +00006958 func_execute_cmds "$reload_cmds" 'exit $?'
drh71eb93e2001-09-28 01:34:43 +00006959 fi
6960
6961 if test -n "$gentop"; then
mlcreech636a9952008-05-05 22:52:56 +00006962 func_show_eval '${RM}r "$gentop"'
drh71eb93e2001-09-28 01:34:43 +00006963 fi
6964
vapier7f19c022007-02-17 14:46:31 +00006965 exit $EXIT_SUCCESS
drh71eb93e2001-09-28 01:34:43 +00006966 ;;
6967
6968 prog)
6969 case $host in
mlcreech636a9952008-05-05 22:52:56 +00006970 *cygwin*) func_stripname '' '.exe' "$output"
6971 output=$func_stripname_result.exe;;
drh71eb93e2001-09-28 01:34:43 +00006972 esac
mlcreech636a9952008-05-05 22:52:56 +00006973 test -n "$vinfo" && \
6974 func_warning "\`-version-info' is ignored for programs"
drh71eb93e2001-09-28 01:34:43 +00006975
mlcreech636a9952008-05-05 22:52:56 +00006976 test -n "$release" && \
6977 func_warning "\`-release' is ignored for programs"
drh71eb93e2001-09-28 01:34:43 +00006978
mlcreech636a9952008-05-05 22:52:56 +00006979 test "$preload" = yes \
6980 && test "$dlopen_support" = unknown \
6981 && test "$dlopen_self" = unknown \
6982 && test "$dlopen_self_static" = unknown && \
6983 func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
drh71eb93e2001-09-28 01:34:43 +00006984
6985 case $host in
6986 *-*-rhapsody* | *-*-darwin1.[012])
6987 # On Rhapsody replace the C library is the System framework
mlcreech636a9952008-05-05 22:52:56 +00006988 compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
6989 finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
drh71eb93e2001-09-28 01:34:43 +00006990 ;;
6991 esac
6992
a.rottmann964dbb12004-02-26 19:47:42 +00006993 case $host in
mlcreech636a9952008-05-05 22:52:56 +00006994 *-*-darwin*)
6995 # Don't allow lazy linking, it breaks C++ global constructors
6996 # But is supposedly fixed on 10.4 or later (yay!).
6997 if test "$tagname" = CXX ; then
6998 case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
6999 10.[0123])
7000 compile_command="$compile_command ${wl}-bind_at_load"
7001 finalize_command="$finalize_command ${wl}-bind_at_load"
7002 ;;
7003 esac
7004 fi
7005 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
7006 compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
7007 finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
7008 ;;
a.rottmann964dbb12004-02-26 19:47:42 +00007009 esac
7010
vapier7f19c022007-02-17 14:46:31 +00007011
7012 # move library search paths that coincide with paths to not yet
7013 # installed libraries to the beginning of the library search list
7014 new_libs=
7015 for path in $notinst_path; do
7016 case " $new_libs " in
7017 *" -L$path/$objdir "*) ;;
7018 *)
7019 case " $compile_deplibs " in
7020 *" -L$path/$objdir "*)
7021 new_libs="$new_libs -L$path/$objdir" ;;
7022 esac
7023 ;;
7024 esac
7025 done
7026 for deplib in $compile_deplibs; do
7027 case $deplib in
7028 -L*)
7029 case " $new_libs " in
7030 *" $deplib "*) ;;
7031 *) new_libs="$new_libs $deplib" ;;
7032 esac
7033 ;;
7034 *) new_libs="$new_libs $deplib" ;;
7035 esac
7036 done
7037 compile_deplibs="$new_libs"
7038
7039
drh71eb93e2001-09-28 01:34:43 +00007040 compile_command="$compile_command $compile_deplibs"
7041 finalize_command="$finalize_command $finalize_deplibs"
7042
7043 if test -n "$rpath$xrpath"; then
7044 # If the user specified any rpath flags, then add them.
7045 for libdir in $rpath $xrpath; do
7046 # This is the magic to use -rpath.
7047 case "$finalize_rpath " in
7048 *" $libdir "*) ;;
7049 *) finalize_rpath="$finalize_rpath $libdir" ;;
7050 esac
7051 done
7052 fi
7053
7054 # Now hardcode the library paths
7055 rpath=
7056 hardcode_libdirs=
7057 for libdir in $compile_rpath $finalize_rpath; do
7058 if test -n "$hardcode_libdir_flag_spec"; then
7059 if test -n "$hardcode_libdir_separator"; then
7060 if test -z "$hardcode_libdirs"; then
7061 hardcode_libdirs="$libdir"
7062 else
7063 # Just accumulate the unique libdirs.
7064 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
7065 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
7066 ;;
7067 *)
7068 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
7069 ;;
7070 esac
7071 fi
7072 else
7073 eval flag=\"$hardcode_libdir_flag_spec\"
7074 rpath="$rpath $flag"
7075 fi
7076 elif test -n "$runpath_var"; then
7077 case "$perm_rpath " in
7078 *" $libdir "*) ;;
7079 *) perm_rpath="$perm_rpath $libdir" ;;
7080 esac
7081 fi
7082 case $host in
7083 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
mlcreech636a9952008-05-05 22:52:56 +00007084 testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
drh71eb93e2001-09-28 01:34:43 +00007085 case :$dllsearchpath: in
7086 *":$libdir:"*) ;;
7087 *) dllsearchpath="$dllsearchpath:$libdir";;
7088 esac
vapier7f19c022007-02-17 14:46:31 +00007089 case :$dllsearchpath: in
7090 *":$testbindir:"*) ;;
7091 *) dllsearchpath="$dllsearchpath:$testbindir";;
7092 esac
drh71eb93e2001-09-28 01:34:43 +00007093 ;;
7094 esac
7095 done
7096 # Substitute the hardcoded libdirs into the rpath.
7097 if test -n "$hardcode_libdir_separator" &&
7098 test -n "$hardcode_libdirs"; then
7099 libdir="$hardcode_libdirs"
7100 eval rpath=\" $hardcode_libdir_flag_spec\"
7101 fi
7102 compile_rpath="$rpath"
7103
7104 rpath=
7105 hardcode_libdirs=
7106 for libdir in $finalize_rpath; do
7107 if test -n "$hardcode_libdir_flag_spec"; then
7108 if test -n "$hardcode_libdir_separator"; then
7109 if test -z "$hardcode_libdirs"; then
7110 hardcode_libdirs="$libdir"
7111 else
7112 # Just accumulate the unique libdirs.
7113 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
7114 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
7115 ;;
7116 *)
7117 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
7118 ;;
7119 esac
7120 fi
7121 else
7122 eval flag=\"$hardcode_libdir_flag_spec\"
7123 rpath="$rpath $flag"
7124 fi
7125 elif test -n "$runpath_var"; then
7126 case "$finalize_perm_rpath " in
7127 *" $libdir "*) ;;
7128 *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
7129 esac
7130 fi
7131 done
7132 # Substitute the hardcoded libdirs into the rpath.
7133 if test -n "$hardcode_libdir_separator" &&
7134 test -n "$hardcode_libdirs"; then
7135 libdir="$hardcode_libdirs"
7136 eval rpath=\" $hardcode_libdir_flag_spec\"
7137 fi
7138 finalize_rpath="$rpath"
7139
7140 if test -n "$libobjs" && test "$build_old_libs" = yes; then
7141 # Transform all the library objects into standard objects.
mlcreech636a9952008-05-05 22:52:56 +00007142 compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
7143 finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
drh71eb93e2001-09-28 01:34:43 +00007144 fi
7145
mlcreech636a9952008-05-05 22:52:56 +00007146 func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
7147
7148 # template prelinking step
7149 if test -n "$prelink_cmds"; then
7150 func_execute_cmds "$prelink_cmds" 'exit $?'
drh71eb93e2001-09-28 01:34:43 +00007151 fi
7152
mlcreech636a9952008-05-05 22:52:56 +00007153 wrappers_required=yes
7154 case $host in
7155 *cygwin* | *mingw* )
7156 if test "$build_libtool_libs" != yes; then
7157 wrappers_required=no
7158 fi
7159 ;;
7160 *)
7161 if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
7162 wrappers_required=no
7163 fi
7164 ;;
7165 esac
7166 if test "$wrappers_required" = no; then
drh71eb93e2001-09-28 01:34:43 +00007167 # Replace the output file specification.
mlcreech636a9952008-05-05 22:52:56 +00007168 compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
drh71eb93e2001-09-28 01:34:43 +00007169 link_command="$compile_command$compile_rpath"
7170
7171 # We have no uninstalled library dependencies, so finalize right now.
mlcreech636a9952008-05-05 22:52:56 +00007172 exit_status=0
7173 func_show_eval "$link_command" 'exit_status=$?'
drh71eb93e2001-09-28 01:34:43 +00007174
7175 # Delete the generated files.
mlcreech636a9952008-05-05 22:52:56 +00007176 if test -f "$output_objdir/${outputname}S.${objext}"; then
7177 func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
drh71eb93e2001-09-28 01:34:43 +00007178 fi
7179
vapier7f19c022007-02-17 14:46:31 +00007180 exit $exit_status
drh71eb93e2001-09-28 01:34:43 +00007181 fi
7182
drh71eb93e2001-09-28 01:34:43 +00007183 if test -n "$compile_shlibpath$finalize_shlibpath"; then
7184 compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
7185 fi
7186 if test -n "$finalize_shlibpath"; then
7187 finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
7188 fi
7189
7190 compile_var=
7191 finalize_var=
7192 if test -n "$runpath_var"; then
7193 if test -n "$perm_rpath"; then
7194 # We should set the runpath_var.
7195 rpath=
7196 for dir in $perm_rpath; do
7197 rpath="$rpath$dir:"
7198 done
7199 compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
7200 fi
7201 if test -n "$finalize_perm_rpath"; then
7202 # We should set the runpath_var.
7203 rpath=
7204 for dir in $finalize_perm_rpath; do
7205 rpath="$rpath$dir:"
7206 done
7207 finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
7208 fi
7209 fi
7210
7211 if test "$no_install" = yes; then
7212 # We don't need to create a wrapper script.
7213 link_command="$compile_var$compile_command$compile_rpath"
7214 # Replace the output file specification.
mlcreech636a9952008-05-05 22:52:56 +00007215 link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
drh71eb93e2001-09-28 01:34:43 +00007216 # Delete the old output file.
mlcreech636a9952008-05-05 22:52:56 +00007217 $opt_dry_run || $RM $output
drh71eb93e2001-09-28 01:34:43 +00007218 # Link the executable and exit
mlcreech636a9952008-05-05 22:52:56 +00007219 func_show_eval "$link_command" 'exit $?'
vapier7f19c022007-02-17 14:46:31 +00007220 exit $EXIT_SUCCESS
drh71eb93e2001-09-28 01:34:43 +00007221 fi
7222
7223 if test "$hardcode_action" = relink; then
7224 # Fast installation is not supported
7225 link_command="$compile_var$compile_command$compile_rpath"
7226 relink_command="$finalize_var$finalize_command$finalize_rpath"
7227
mlcreech636a9952008-05-05 22:52:56 +00007228 func_warning "this platform does not like uninstalled shared libraries"
7229 func_warning "\`$output' will be relinked during installation"
drh71eb93e2001-09-28 01:34:43 +00007230 else
7231 if test "$fast_install" != no; then
7232 link_command="$finalize_var$compile_command$finalize_rpath"
7233 if test "$fast_install" = yes; then
mlcreech636a9952008-05-05 22:52:56 +00007234 relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
drh71eb93e2001-09-28 01:34:43 +00007235 else
7236 # fast_install is set to needless
7237 relink_command=
7238 fi
7239 else
7240 link_command="$compile_var$compile_command$compile_rpath"
7241 relink_command="$finalize_var$finalize_command$finalize_rpath"
7242 fi
7243 fi
7244
7245 # Replace the output file specification.
mlcreech636a9952008-05-05 22:52:56 +00007246 link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
drh71eb93e2001-09-28 01:34:43 +00007247
7248 # Delete the old output files.
mlcreech636a9952008-05-05 22:52:56 +00007249 $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
drh71eb93e2001-09-28 01:34:43 +00007250
mlcreech636a9952008-05-05 22:52:56 +00007251 func_show_eval "$link_command" 'exit $?'
drh71eb93e2001-09-28 01:34:43 +00007252
7253 # Now create the wrapper script.
mlcreech636a9952008-05-05 22:52:56 +00007254 func_verbose "creating $output"
drh71eb93e2001-09-28 01:34:43 +00007255
7256 # Quote the relink command for shipping.
7257 if test -n "$relink_command"; then
7258 # Preserve any variables that may affect compiler behavior
7259 for var in $variables_saved_for_relink; do
7260 if eval test -z \"\${$var+set}\"; then
mlcreech636a9952008-05-05 22:52:56 +00007261 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
drh71eb93e2001-09-28 01:34:43 +00007262 elif eval var_value=\$$var; test -z "$var_value"; then
7263 relink_command="$var=; export $var; $relink_command"
7264 else
mlcreech636a9952008-05-05 22:52:56 +00007265 func_quote_for_eval "$var_value"
7266 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
drh71eb93e2001-09-28 01:34:43 +00007267 fi
7268 done
a.rottmann62507b62003-03-24 09:40:34 +00007269 relink_command="(cd `pwd`; $relink_command)"
mlcreech636a9952008-05-05 22:52:56 +00007270 relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
drh71eb93e2001-09-28 01:34:43 +00007271 fi
7272
mlcreech636a9952008-05-05 22:52:56 +00007273 # Quote $ECHO for shipping.
7274 if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then
vapier7f19c022007-02-17 14:46:31 +00007275 case $progpath in
7276 [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
7277 *) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
drh71eb93e2001-09-28 01:34:43 +00007278 esac
mlcreech636a9952008-05-05 22:52:56 +00007279 qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"`
drh71eb93e2001-09-28 01:34:43 +00007280 else
mlcreech636a9952008-05-05 22:52:56 +00007281 qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"`
drh71eb93e2001-09-28 01:34:43 +00007282 fi
7283
mlcreech636a9952008-05-05 22:52:56 +00007284 # Only actually do things if not in dry run mode.
7285 $opt_dry_run || {
drh71eb93e2001-09-28 01:34:43 +00007286 # win32 will think the script is a binary if it has
7287 # a .exe suffix, so we strip it off here.
7288 case $output in
mlcreech636a9952008-05-05 22:52:56 +00007289 *.exe) func_stripname '' '.exe' "$output"
7290 output=$func_stripname_result ;;
drh71eb93e2001-09-28 01:34:43 +00007291 esac
7292 # test for cygwin because mv fails w/o .exe extensions
7293 case $host in
a.rottmann964dbb12004-02-26 19:47:42 +00007294 *cygwin*)
7295 exeext=.exe
mlcreech636a9952008-05-05 22:52:56 +00007296 func_stripname '' '.exe' "$outputname"
7297 outputname=$func_stripname_result ;;
drh71eb93e2001-09-28 01:34:43 +00007298 *) exeext= ;;
7299 esac
a.rottmann964dbb12004-02-26 19:47:42 +00007300 case $host in
7301 *cygwin* | *mingw* )
mlcreech636a9952008-05-05 22:52:56 +00007302 func_dirname_and_basename "$output" "" "."
7303 output_name=$func_basename_result
7304 output_path=$func_dirname_result
7305 cwrappersource="$output_path/$objdir/lt-$output_name.c"
7306 cwrapper="$output_path/$output_name.exe"
7307 $RM $cwrappersource $cwrapper
7308 trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
a.rottmann964dbb12004-02-26 19:47:42 +00007309
mlcreech636a9952008-05-05 22:52:56 +00007310 func_emit_cwrapperexe_src > $cwrappersource
a.rottmann964dbb12004-02-26 19:47:42 +00007311
mlcreech636a9952008-05-05 22:52:56 +00007312 # we should really use a build-platform specific compiler
7313 # here, but OTOH, the wrappers (shell script and this C one)
7314 # are only useful if you want to execute the "real" binary.
7315 # Since the "real" binary is built for $host, then this
7316 # wrapper might as well be built for $host, too.
7317 $opt_dry_run || {
7318 $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
7319 $STRIP $cwrapper
7320 }
a.rottmann964dbb12004-02-26 19:47:42 +00007321
mlcreech636a9952008-05-05 22:52:56 +00007322 # Now, create the wrapper script for func_source use:
7323 func_ltwrapper_scriptname $cwrapper
7324 $RM $func_ltwrapper_scriptname_result
7325 trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
7326 $opt_dry_run || {
7327 # note: this script will not be executed, so do not chmod.
7328 if test "x$build" = "x$host" ; then
7329 $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
7330 else
7331 func_emit_wrapper no > $func_ltwrapper_scriptname_result
7332 fi
7333 }
drh71eb93e2001-09-28 01:34:43 +00007334 ;;
mlcreech636a9952008-05-05 22:52:56 +00007335 * )
7336 $RM $output
7337 trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
drh71eb93e2001-09-28 01:34:43 +00007338
mlcreech636a9952008-05-05 22:52:56 +00007339 func_emit_wrapper no > $output
7340 chmod +x $output
drh71eb93e2001-09-28 01:34:43 +00007341 ;;
7342 esac
mlcreech636a9952008-05-05 22:52:56 +00007343 }
vapier7f19c022007-02-17 14:46:31 +00007344 exit $EXIT_SUCCESS
drh71eb93e2001-09-28 01:34:43 +00007345 ;;
7346 esac
7347
7348 # See if we need to build an old-fashioned archive.
7349 for oldlib in $oldlibs; do
7350
7351 if test "$build_libtool_libs" = convenience; then
mlcreech636a9952008-05-05 22:52:56 +00007352 oldobjs="$libobjs_save $symfileobj"
drh71eb93e2001-09-28 01:34:43 +00007353 addlibs="$convenience"
7354 build_libtool_libs=no
7355 else
7356 if test "$build_libtool_libs" = module; then
7357 oldobjs="$libobjs_save"
7358 build_libtool_libs=no
7359 else
a.rottmann964dbb12004-02-26 19:47:42 +00007360 oldobjs="$old_deplibs $non_pic_objects"
mlcreech636a9952008-05-05 22:52:56 +00007361 if test "$preload" = yes && test -f "$symfileobj"; then
7362 oldobjs="$oldobjs $symfileobj"
7363 fi
drh71eb93e2001-09-28 01:34:43 +00007364 fi
7365 addlibs="$old_convenience"
7366 fi
7367
7368 if test -n "$addlibs"; then
7369 gentop="$output_objdir/${outputname}x"
drh71eb93e2001-09-28 01:34:43 +00007370 generated="$generated $gentop"
7371
vapier7f19c022007-02-17 14:46:31 +00007372 func_extract_archives $gentop $addlibs
7373 oldobjs="$oldobjs $func_extract_archives_result"
drh71eb93e2001-09-28 01:34:43 +00007374 fi
7375
7376 # Do each command in the archive commands.
7377 if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
mlcreech636a9952008-05-05 22:52:56 +00007378 cmds=$old_archive_from_new_cmds
drh71eb93e2001-09-28 01:34:43 +00007379 else
mlcreech636a9952008-05-05 22:52:56 +00007380
7381 # Add any objects from preloaded convenience libraries
7382 if test -n "$dlprefiles"; then
7383 gentop="$output_objdir/${outputname}x"
7384 generated="$generated $gentop"
7385
7386 func_extract_archives $gentop $dlprefiles
7387 oldobjs="$oldobjs $func_extract_archives_result"
7388 fi
7389
vapier7f19c022007-02-17 14:46:31 +00007390 # POSIX demands no paths to be encoded in archives. We have
7391 # to avoid creating archives with duplicate basenames if we
7392 # might have to extract them afterwards, e.g., when creating a
7393 # static archive out of a convenience library, or when linking
7394 # the entirety of a libtool archive into another (currently
7395 # not supported by libtool).
7396 if (for obj in $oldobjs
7397 do
mlcreech636a9952008-05-05 22:52:56 +00007398 func_basename "$obj"
7399 $ECHO "$func_basename_result"
vapier7f19c022007-02-17 14:46:31 +00007400 done | sort | sort -uc >/dev/null 2>&1); then
7401 :
7402 else
mlcreech636a9952008-05-05 22:52:56 +00007403 $ECHO "copying selected object files to avoid basename conflicts..."
7404 gentop="$output_objdir/${outputname}x"
7405 generated="$generated $gentop"
7406 func_mkdir_p "$gentop"
vapier7f19c022007-02-17 14:46:31 +00007407 save_oldobjs=$oldobjs
7408 oldobjs=
7409 counter=1
7410 for obj in $save_oldobjs
7411 do
mlcreech636a9952008-05-05 22:52:56 +00007412 func_basename "$obj"
7413 objbase="$func_basename_result"
vapier7f19c022007-02-17 14:46:31 +00007414 case " $oldobjs " in
7415 " ") oldobjs=$obj ;;
7416 *[\ /]"$objbase "*)
7417 while :; do
7418 # Make sure we don't pick an alternate name that also
7419 # overlaps.
7420 newobj=lt$counter-$objbase
mlcreech636a9952008-05-05 22:52:56 +00007421 func_arith $counter + 1
7422 counter=$func_arith_result
vapier7f19c022007-02-17 14:46:31 +00007423 case " $oldobjs " in
7424 *[\ /]"$newobj "*) ;;
7425 *) if test ! -f "$gentop/$newobj"; then break; fi ;;
7426 esac
7427 done
mlcreech636a9952008-05-05 22:52:56 +00007428 func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
vapier7f19c022007-02-17 14:46:31 +00007429 oldobjs="$oldobjs $gentop/$newobj"
7430 ;;
7431 *) oldobjs="$oldobjs $obj" ;;
7432 esac
7433 done
7434 fi
a.rottmann62507b62003-03-24 09:40:34 +00007435 eval cmds=\"$old_archive_cmds\"
a.rottmann964dbb12004-02-26 19:47:42 +00007436
mlcreech636a9952008-05-05 22:52:56 +00007437 func_len " $cmds"
7438 len=$func_len_result
7439 if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
a.rottmann964dbb12004-02-26 19:47:42 +00007440 cmds=$old_archive_cmds
7441 else
7442 # the command line is too long to link in one step, link in parts
mlcreech636a9952008-05-05 22:52:56 +00007443 func_verbose "using piecewise archive linking..."
a.rottmann964dbb12004-02-26 19:47:42 +00007444 save_RANLIB=$RANLIB
7445 RANLIB=:
7446 objlist=
7447 concat_cmds=
7448 save_oldobjs=$oldobjs
mlcreech636a9952008-05-05 22:52:56 +00007449 oldobjs=
a.rottmann964dbb12004-02-26 19:47:42 +00007450 # Is there a better way of finding the last object in the list?
7451 for obj in $save_oldobjs
7452 do
7453 last_oldobj=$obj
vapier7f19c022007-02-17 14:46:31 +00007454 done
mlcreech636a9952008-05-05 22:52:56 +00007455 eval test_cmds=\"$old_archive_cmds\"
7456 func_len " $test_cmds"
7457 len0=$func_len_result
7458 len=$len0
a.rottmann964dbb12004-02-26 19:47:42 +00007459 for obj in $save_oldobjs
7460 do
mlcreech636a9952008-05-05 22:52:56 +00007461 func_len " $obj"
7462 func_arith $len + $func_len_result
7463 len=$func_arith_result
7464 func_append objlist " $obj"
7465 if test "$len" -lt "$max_cmd_len"; then
a.rottmann964dbb12004-02-26 19:47:42 +00007466 :
7467 else
7468 # the above command should be used before it gets too long
7469 oldobjs=$objlist
7470 if test "$obj" = "$last_oldobj" ; then
mlcreech636a9952008-05-05 22:52:56 +00007471 RANLIB=$save_RANLIB
vapier7f19c022007-02-17 14:46:31 +00007472 fi
a.rottmann964dbb12004-02-26 19:47:42 +00007473 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
7474 eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
7475 objlist=
mlcreech636a9952008-05-05 22:52:56 +00007476 len=$len0
a.rottmann964dbb12004-02-26 19:47:42 +00007477 fi
7478 done
7479 RANLIB=$save_RANLIB
7480 oldobjs=$objlist
7481 if test "X$oldobjs" = "X" ; then
7482 eval cmds=\"\$concat_cmds\"
7483 else
7484 eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
7485 fi
7486 fi
drh71eb93e2001-09-28 01:34:43 +00007487 fi
mlcreech636a9952008-05-05 22:52:56 +00007488 func_execute_cmds "$cmds" 'exit $?'
drh71eb93e2001-09-28 01:34:43 +00007489 done
7490
mlcreech636a9952008-05-05 22:52:56 +00007491 test -n "$generated" && \
7492 func_show_eval "${RM}r$generated"
drh71eb93e2001-09-28 01:34:43 +00007493
7494 # Now create the libtool archive.
7495 case $output in
7496 *.la)
7497 old_library=
7498 test "$build_old_libs" = yes && old_library="$libname.$libext"
mlcreech636a9952008-05-05 22:52:56 +00007499 func_verbose "creating $output"
drh71eb93e2001-09-28 01:34:43 +00007500
7501 # Preserve any variables that may affect compiler behavior
7502 for var in $variables_saved_for_relink; do
7503 if eval test -z \"\${$var+set}\"; then
mlcreech636a9952008-05-05 22:52:56 +00007504 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
drh71eb93e2001-09-28 01:34:43 +00007505 elif eval var_value=\$$var; test -z "$var_value"; then
7506 relink_command="$var=; export $var; $relink_command"
7507 else
mlcreech636a9952008-05-05 22:52:56 +00007508 func_quote_for_eval "$var_value"
7509 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
drh71eb93e2001-09-28 01:34:43 +00007510 fi
7511 done
7512 # Quote the link command for shipping.
vapier7f19c022007-02-17 14:46:31 +00007513 relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
mlcreech636a9952008-05-05 22:52:56 +00007514 relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
a.rottmann964dbb12004-02-26 19:47:42 +00007515 if test "$hardcode_automatic" = yes ; then
vapier7f19c022007-02-17 14:46:31 +00007516 relink_command=
7517 fi
7518
drh71eb93e2001-09-28 01:34:43 +00007519 # Only create the output if not a dry run.
mlcreech636a9952008-05-05 22:52:56 +00007520 $opt_dry_run || {
drh71eb93e2001-09-28 01:34:43 +00007521 for installed in no yes; do
7522 if test "$installed" = yes; then
7523 if test -z "$install_libdir"; then
7524 break
7525 fi
7526 output="$output_objdir/$outputname"i
7527 # Replace all uninstalled libtool libraries with the installed ones
7528 newdependency_libs=
7529 for deplib in $dependency_libs; do
7530 case $deplib in
7531 *.la)
mlcreech636a9952008-05-05 22:52:56 +00007532 func_basename "$deplib"
7533 name="$func_basename_result"
a.rottmann62507b62003-03-24 09:40:34 +00007534 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
mlcreech636a9952008-05-05 22:52:56 +00007535 test -z "$libdir" && \
7536 func_fatal_error "\`$deplib' is not a valid libtool archive"
7537 if test "x$EGREP" = x ; then
vapier7f19c022007-02-17 14:46:31 +00007538 EGREP=egrep
7539 fi
7540 # We do not want portage's install root ($D) present. Check only for
7541 # this if the .la is being installed.
7542 if test "$installed" = yes && test "$D"; then
7543 eval mynewdependency_lib=`echo "$libdir/$name" |sed -e "s:$D:/:g" -e 's:/\+:/:g'`
7544 else
7545 mynewdependency_lib="$libdir/$name"
7546 fi
7547 # Do not add duplicates
7548 if test "$mynewdependency_lib"; then
7549 my_little_ninja_foo_1=`echo $newdependency_libs |$EGREP -e "$mynewdependency_lib"`
7550 if test -z "$my_little_ninja_foo_1"; then
7551 newdependency_libs="$newdependency_libs $mynewdependency_lib"
7552 fi
7553 fi
drh71eb93e2001-09-28 01:34:43 +00007554 ;;
vapier7f19c022007-02-17 14:46:31 +00007555 *)
7556 if test "$installed" = yes; then
7557 # Rather use S=WORKDIR if our version of portage supports it.
7558 # This is because some ebuild (gcc) do not use $S as buildroot.
7559 if test "$PWORKDIR"; then
7560 S="$PWORKDIR"
7561 fi
7562 # We do not want portage's build root ($S) present.
7563 my_little_ninja_foo_2=`echo $deplib |$EGREP -e "$S"`
7564 # We do not want portage's install root ($D) present.
7565 my_little_ninja_foo_3=`echo $deplib |$EGREP -e "$D"`
7566 if test -n "$my_little_ninja_foo_2" && test "$S"; then
7567 mynewdependency_lib=""
7568 elif test -n "$my_little_ninja_foo_3" && test "$D"; then
7569 eval mynewdependency_lib=`echo "$deplib" |sed -e "s:$D:/:g" -e 's:/\+:/:g'`
7570 else
7571 mynewdependency_lib="$deplib"
7572 fi
7573 else
7574 mynewdependency_lib="$deplib"
7575 fi
7576 # Do not add duplicates
7577 if test "$mynewdependency_lib"; then
7578 my_little_ninja_foo_4=`echo $newdependency_libs |$EGREP -e "$mynewdependency_lib"`
7579 if test -z "$my_little_ninja_foo_4"; then
7580 newdependency_libs="$newdependency_libs $mynewdependency_lib"
7581 fi
7582 fi
7583 ;;
drh71eb93e2001-09-28 01:34:43 +00007584 esac
7585 done
7586 dependency_libs="$newdependency_libs"
7587 newdlfiles=
mlcreech636a9952008-05-05 22:52:56 +00007588
drh71eb93e2001-09-28 01:34:43 +00007589 for lib in $dlfiles; do
mlcreech636a9952008-05-05 22:52:56 +00007590 case $lib in
7591 *.la)
7592 func_basename "$lib"
7593 name="$func_basename_result"
7594 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
7595 test -z "$libdir" && \
7596 func_fatal_error "\`$lib' is not a valid libtool archive"
7597 newdlfiles="$newdlfiles $libdir/$name"
7598 ;;
7599 *) newdlfiles="$newdlfiles $lib" ;;
7600 esac
drh71eb93e2001-09-28 01:34:43 +00007601 done
7602 dlfiles="$newdlfiles"
7603 newdlprefiles=
7604 for lib in $dlprefiles; do
mlcreech636a9952008-05-05 22:52:56 +00007605 case $lib in
7606 *.la)
7607 # Only pass preopened files to the pseudo-archive (for
7608 # eventual linking with the app. that links it) if we
7609 # didn't already link the preopened objects directly into
7610 # the library:
7611 func_basename "$lib"
7612 name="$func_basename_result"
7613 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
7614 test -z "$libdir" && \
7615 func_fatal_error "\`$lib' is not a valid libtool archive"
7616 newdlprefiles="$newdlprefiles $libdir/$name"
7617 ;;
7618 esac
drh71eb93e2001-09-28 01:34:43 +00007619 done
7620 dlprefiles="$newdlprefiles"
a.rottmann964dbb12004-02-26 19:47:42 +00007621 else
7622 newdlfiles=
7623 for lib in $dlfiles; do
vapier7f19c022007-02-17 14:46:31 +00007624 case $lib in
a.rottmann964dbb12004-02-26 19:47:42 +00007625 [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
7626 *) abs=`pwd`"/$lib" ;;
7627 esac
7628 newdlfiles="$newdlfiles $abs"
7629 done
7630 dlfiles="$newdlfiles"
7631 newdlprefiles=
7632 for lib in $dlprefiles; do
vapier7f19c022007-02-17 14:46:31 +00007633 case $lib in
a.rottmann964dbb12004-02-26 19:47:42 +00007634 [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
7635 *) abs=`pwd`"/$lib" ;;
7636 esac
7637 newdlprefiles="$newdlprefiles $abs"
7638 done
7639 dlprefiles="$newdlprefiles"
drh71eb93e2001-09-28 01:34:43 +00007640 fi
mlcreech636a9952008-05-05 22:52:56 +00007641 $RM $output
drh71eb93e2001-09-28 01:34:43 +00007642 # place dlname in correct position for cygwin
7643 tdlname=$dlname
7644 case $host,$output,$installed,$module,$dlname in
a.rottmann964dbb12004-02-26 19:47:42 +00007645 *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
drh71eb93e2001-09-28 01:34:43 +00007646 esac
vapier7f19c022007-02-17 14:46:31 +00007647 # Do not add duplicates
7648 if test "$installed" = yes && test "$D"; then
7649 install_libdir=`echo "$install_libdir" |sed -e "s:$D:/:g" -e 's:/\+:/:g'`
7650 fi
mlcreech636a9952008-05-05 22:52:56 +00007651 $ECHO > $output "\
drh71eb93e2001-09-28 01:34:43 +00007652# $outputname - a libtool library file
mlcreech636a9952008-05-05 22:52:56 +00007653# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
drh71eb93e2001-09-28 01:34:43 +00007654#
7655# Please DO NOT delete this file!
7656# It is necessary for linking the library.
7657
7658# The name that we can dlopen(3).
7659dlname='$tdlname'
7660
7661# Names of this library.
7662library_names='$library_names'
7663
7664# The name of the static archive.
7665old_library='$old_library'
7666
mlcreech636a9952008-05-05 22:52:56 +00007667# Linker flags that can not go in dependency_libs.
7668inherited_linker_flags='$new_inherited_linker_flags'
7669
drh71eb93e2001-09-28 01:34:43 +00007670# Libraries that this one depends upon.
7671dependency_libs='$dependency_libs'
7672
mlcreech636a9952008-05-05 22:52:56 +00007673# Names of additional weak libraries provided by this library
7674weak_library_names='$weak_libs'
7675
drh71eb93e2001-09-28 01:34:43 +00007676# Version information for $libname.
7677current=$current
7678age=$age
7679revision=$revision
7680
7681# Is this an already installed library?
7682installed=$installed
7683
a.rottmann964dbb12004-02-26 19:47:42 +00007684# Should we warn about portability when linking against -modules?
7685shouldnotlink=$module
7686
drh71eb93e2001-09-28 01:34:43 +00007687# Files to dlopen/dlpreopen
7688dlopen='$dlfiles'
7689dlpreopen='$dlprefiles'
7690
7691# Directory that this library needs to be installed in:
7692libdir='$install_libdir'"
a.rottmann964dbb12004-02-26 19:47:42 +00007693 if test "$installed" = no && test "$need_relink" = yes; then
mlcreech636a9952008-05-05 22:52:56 +00007694 $ECHO >> $output "\
drh71eb93e2001-09-28 01:34:43 +00007695relink_command=\"$relink_command\""
7696 fi
7697 done
mlcreech636a9952008-05-05 22:52:56 +00007698 }
drh71eb93e2001-09-28 01:34:43 +00007699
7700 # Do a symbolic link so that the libtool archive can be found in
7701 # LD_LIBRARY_PATH before the program is installed.
mlcreech636a9952008-05-05 22:52:56 +00007702 func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
drh71eb93e2001-09-28 01:34:43 +00007703 ;;
7704 esac
vapier7f19c022007-02-17 14:46:31 +00007705 exit $EXIT_SUCCESS
mlcreech636a9952008-05-05 22:52:56 +00007706}
drh71eb93e2001-09-28 01:34:43 +00007707
mlcreech636a9952008-05-05 22:52:56 +00007708{ test "$mode" = link || test "$mode" = relink; } &&
7709 func_mode_link ${1+"$@"}
drh71eb93e2001-09-28 01:34:43 +00007710
drh71eb93e2001-09-28 01:34:43 +00007711
mlcreech636a9952008-05-05 22:52:56 +00007712# func_mode_uninstall arg...
7713func_mode_uninstall ()
7714{
7715 $opt_debug
7716 RM="$nonopt"
drh71eb93e2001-09-28 01:34:43 +00007717 files=
7718 rmforce=
7719 exit_status=0
7720
7721 # This variable tells wrapper scripts just to set variables rather
7722 # than running their programs.
7723 libtool_install_magic="$magic"
7724
7725 for arg
7726 do
7727 case $arg in
mlcreech636a9952008-05-05 22:52:56 +00007728 -f) RM="$RM $arg"; rmforce=yes ;;
7729 -*) RM="$RM $arg" ;;
drh71eb93e2001-09-28 01:34:43 +00007730 *) files="$files $arg" ;;
7731 esac
7732 done
7733
mlcreech636a9952008-05-05 22:52:56 +00007734 test -z "$RM" && \
7735 func_fatal_help "you must specify an RM program"
drh71eb93e2001-09-28 01:34:43 +00007736
7737 rmdirs=
7738
a.rottmann964dbb12004-02-26 19:47:42 +00007739 origobjdir="$objdir"
drh71eb93e2001-09-28 01:34:43 +00007740 for file in $files; do
mlcreech636a9952008-05-05 22:52:56 +00007741 func_dirname "$file" "" "."
7742 dir="$func_dirname_result"
7743 if test "X$dir" = X.; then
a.rottmann964dbb12004-02-26 19:47:42 +00007744 objdir="$origobjdir"
drh71eb93e2001-09-28 01:34:43 +00007745 else
a.rottmann964dbb12004-02-26 19:47:42 +00007746 objdir="$dir/$origobjdir"
drh71eb93e2001-09-28 01:34:43 +00007747 fi
mlcreech636a9952008-05-05 22:52:56 +00007748 func_basename "$file"
7749 name="$func_basename_result"
a.rottmann964dbb12004-02-26 19:47:42 +00007750 test "$mode" = uninstall && objdir="$dir"
drh71eb93e2001-09-28 01:34:43 +00007751
7752 # Remember objdir for removal later, being careful to avoid duplicates
a.rottmann964dbb12004-02-26 19:47:42 +00007753 if test "$mode" = clean; then
drh71eb93e2001-09-28 01:34:43 +00007754 case " $rmdirs " in
7755 *" $objdir "*) ;;
7756 *) rmdirs="$rmdirs $objdir" ;;
7757 esac
7758 fi
7759
7760 # Don't error if the file doesn't exist and rm -f was used.
mlcreech636a9952008-05-05 22:52:56 +00007761 if { test -L "$file"; } >/dev/null 2>&1 ||
7762 { test -h "$file"; } >/dev/null 2>&1 ||
7763 test -f "$file"; then
a.rottmann62507b62003-03-24 09:40:34 +00007764 :
drh71eb93e2001-09-28 01:34:43 +00007765 elif test -d "$file"; then
a.rottmann62507b62003-03-24 09:40:34 +00007766 exit_status=1
drh71eb93e2001-09-28 01:34:43 +00007767 continue
7768 elif test "$rmforce" = yes; then
a.rottmann62507b62003-03-24 09:40:34 +00007769 continue
drh71eb93e2001-09-28 01:34:43 +00007770 fi
7771
7772 rmfiles="$file"
7773
7774 case $name in
7775 *.la)
7776 # Possibly a libtool archive, so verify it.
mlcreech636a9952008-05-05 22:52:56 +00007777 if func_lalib_p "$file"; then
7778 func_source $dir/$name
drh71eb93e2001-09-28 01:34:43 +00007779
7780 # Delete the libtool libraries and symlinks.
7781 for n in $library_names; do
7782 rmfiles="$rmfiles $objdir/$n"
7783 done
7784 test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
drh71eb93e2001-09-28 01:34:43 +00007785
vapier7f19c022007-02-17 14:46:31 +00007786 case "$mode" in
7787 clean)
7788 case " $library_names " in
7789 # " " in the beginning catches empty $dlname
7790 *" $dlname "*) ;;
7791 *) rmfiles="$rmfiles $objdir/$dlname" ;;
7792 esac
mlcreech636a9952008-05-05 22:52:56 +00007793 test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
vapier7f19c022007-02-17 14:46:31 +00007794 ;;
7795 uninstall)
drh71eb93e2001-09-28 01:34:43 +00007796 if test -n "$library_names"; then
7797 # Do each command in the postuninstall commands.
mlcreech636a9952008-05-05 22:52:56 +00007798 func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
drh71eb93e2001-09-28 01:34:43 +00007799 fi
7800
7801 if test -n "$old_library"; then
7802 # Do each command in the old_postuninstall commands.
mlcreech636a9952008-05-05 22:52:56 +00007803 func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
drh71eb93e2001-09-28 01:34:43 +00007804 fi
7805 # FIXME: should reinstall the best remaining shared library.
vapier7f19c022007-02-17 14:46:31 +00007806 ;;
7807 esac
drh71eb93e2001-09-28 01:34:43 +00007808 fi
7809 ;;
7810
7811 *.lo)
a.rottmann964dbb12004-02-26 19:47:42 +00007812 # Possibly a libtool object, so verify it.
mlcreech636a9952008-05-05 22:52:56 +00007813 if func_lalib_p "$file"; then
a.rottmann964dbb12004-02-26 19:47:42 +00007814
7815 # Read the .lo file
mlcreech636a9952008-05-05 22:52:56 +00007816 func_source $dir/$name
a.rottmann964dbb12004-02-26 19:47:42 +00007817
7818 # Add PIC object to the list of files to remove.
mlcreech636a9952008-05-05 22:52:56 +00007819 if test -n "$pic_object" &&
7820 test "$pic_object" != none; then
a.rottmann964dbb12004-02-26 19:47:42 +00007821 rmfiles="$rmfiles $dir/$pic_object"
7822 fi
7823
7824 # Add non-PIC object to the list of files to remove.
mlcreech636a9952008-05-05 22:52:56 +00007825 if test -n "$non_pic_object" &&
7826 test "$non_pic_object" != none; then
a.rottmann964dbb12004-02-26 19:47:42 +00007827 rmfiles="$rmfiles $dir/$non_pic_object"
7828 fi
drh71eb93e2001-09-28 01:34:43 +00007829 fi
7830 ;;
7831
7832 *)
a.rottmann964dbb12004-02-26 19:47:42 +00007833 if test "$mode" = clean ; then
7834 noexename=$name
7835 case $file in
vapier7f19c022007-02-17 14:46:31 +00007836 *.exe)
mlcreech636a9952008-05-05 22:52:56 +00007837 func_stripname '' '.exe' "$file"
7838 file=$func_stripname_result
7839 func_stripname '' '.exe' "$name"
7840 noexename=$func_stripname_result
a.rottmann964dbb12004-02-26 19:47:42 +00007841 # $file with .exe has already been added to rmfiles,
7842 # add $file without .exe
7843 rmfiles="$rmfiles $file"
7844 ;;
7845 esac
7846 # Do a test to see if this is a libtool program.
mlcreech636a9952008-05-05 22:52:56 +00007847 if func_ltwrapper_p "$file"; then
7848 if func_ltwrapper_executable_p "$file"; then
7849 func_ltwrapper_scriptname "$file"
7850 relink_command=
7851 func_source $func_ltwrapper_scriptname_result
7852 rmfiles="$rmfiles $func_ltwrapper_scriptname_result"
7853 else
7854 relink_command=
7855 func_source $dir/$noexename
7856 fi
drh71eb93e2001-09-28 01:34:43 +00007857
a.rottmann964dbb12004-02-26 19:47:42 +00007858 # note $name still contains .exe if it was in $file originally
7859 # as does the version of $file that was added into $rmfiles
7860 rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
7861 if test "$fast_install" = yes && test -n "$relink_command"; then
7862 rmfiles="$rmfiles $objdir/lt-$name"
7863 fi
7864 if test "X$noexename" != "X$name" ; then
7865 rmfiles="$rmfiles $objdir/lt-${noexename}.c"
7866 fi
drh71eb93e2001-09-28 01:34:43 +00007867 fi
7868 fi
7869 ;;
7870 esac
mlcreech636a9952008-05-05 22:52:56 +00007871 func_show_eval "$RM $rmfiles" 'exit_status=1'
drh71eb93e2001-09-28 01:34:43 +00007872 done
a.rottmann964dbb12004-02-26 19:47:42 +00007873 objdir="$origobjdir"
drh71eb93e2001-09-28 01:34:43 +00007874
7875 # Try to remove the ${objdir}s in the directories where we deleted files
7876 for dir in $rmdirs; do
7877 if test -d "$dir"; then
mlcreech636a9952008-05-05 22:52:56 +00007878 func_show_eval "rmdir $dir >/dev/null 2>&1"
drh71eb93e2001-09-28 01:34:43 +00007879 fi
7880 done
7881
7882 exit $exit_status
mlcreech636a9952008-05-05 22:52:56 +00007883}
drh71eb93e2001-09-28 01:34:43 +00007884
mlcreech636a9952008-05-05 22:52:56 +00007885{ test "$mode" = uninstall || test "$mode" = clean; } &&
7886 func_mode_uninstall ${1+"$@"}
drh71eb93e2001-09-28 01:34:43 +00007887
mlcreech636a9952008-05-05 22:52:56 +00007888test -z "$mode" && {
7889 help="$generic_help"
7890 func_fatal_help "you must specify a MODE"
7891}
7892
7893test -z "$exec_cmd" && \
7894 func_fatal_help "invalid operation mode \`$mode'"
drh71eb93e2001-09-28 01:34:43 +00007895
7896if test -n "$exec_cmd"; then
mlcreech636a9952008-05-05 22:52:56 +00007897 eval exec "$exec_cmd"
vapier7f19c022007-02-17 14:46:31 +00007898 exit $EXIT_FAILURE
drh71eb93e2001-09-28 01:34:43 +00007899fi
7900
mlcreech636a9952008-05-05 22:52:56 +00007901exit $exit_status
drh71eb93e2001-09-28 01:34:43 +00007902
drh71eb93e2001-09-28 01:34:43 +00007903
a.rottmann964dbb12004-02-26 19:47:42 +00007904# The TAGs below are defined such that we never get into a situation
7905# in which we disable both kinds of libraries. Given conflicting
7906# choices, we go for a static library, that is the most portable,
7907# since we can't tell whether shared libraries were disabled because
7908# the user asked for that or because the platform doesn't support
7909# them. This is particularly important on AIX, because we don't
7910# support having both static and shared libraries enabled at the same
7911# time on that platform, so we default to a shared-only configuration.
7912# If a disable-shared tag is given, we'll fallback to a static-only
7913# configuration. But we'll never go from static-only to shared-only.
7914
7915# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
mlcreech636a9952008-05-05 22:52:56 +00007916build_libtool_libs=no
7917build_old_libs=yes
a.rottmann964dbb12004-02-26 19:47:42 +00007918# ### END LIBTOOL TAG CONFIG: disable-shared
7919
7920# ### BEGIN LIBTOOL TAG CONFIG: disable-static
mlcreech636a9952008-05-05 22:52:56 +00007921build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
a.rottmann964dbb12004-02-26 19:47:42 +00007922# ### END LIBTOOL TAG CONFIG: disable-static
7923
drh71eb93e2001-09-28 01:34:43 +00007924# Local Variables:
7925# mode:shell-script
7926# sh-indentation:2
7927# End:
mlcreech636a9952008-05-05 22:52:56 +00007928# vi:sw=2
7929