blob: 174e49238b5c4bd99bccd54dae46965f0c4f04f2 [file] [log] [blame]
Lev Walkine7c4b962010-11-09 03:10:36 -08001# Generated from ltmain.m4sh.
Lev Walkin4da95cf2010-10-16 02:46:32 -07002
Lev Walkine7c4b962010-11-09 03:10:36 -08003# ltmain.sh (GNU libtool) 2.2.4
Lev Walkin4da95cf2010-10-16 02:46:32 -07004# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
5
Lev Walkine7c4b962010-11-09 03:10:36 -08006# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc.
Lev Walkin4da95cf2010-10-16 02:46:32 -07007# 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
Lev Walkinf15320b2004-06-03 03:38:44 +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#
Lev Walkin4da95cf2010-10-16 02:46:32 -070015# 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
Lev Walkinf15320b2004-06-03 03:38:44 +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
Lev Walkin4da95cf2010-10-16 02:46:32 -070026# 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.
Lev Walkinf15320b2004-06-03 03:38:44 +000030
Lev Walkin4da95cf2010-10-16 02:46:32 -070031# Usage: $progname [OPTION]... [MODE-ARG]...
32#
33# Provide generalized library-building support services.
34#
Lev Walkine7c4b962010-11-09 03:10:36 -080035# --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
Lev Walkin4da95cf2010-10-16 02:46:32 -070046#
47# MODE must be one of the following:
48#
Lev Walkine7c4b962010-11-09 03:10:36 -080049# 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
Lev Walkin4da95cf2010-10-16 02:46:32 -070056#
Lev Walkine7c4b962010-11-09 03:10:36 -080057# MODE-ARGS vary depending on the MODE.
Lev Walkin4da95cf2010-10-16 02:46:32 -070058# 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#
Lev Walkine7c4b962010-11-09 03:10:36 -080063# 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
Lev Walkin4da95cf2010-10-16 02:46:32 -070071#
72# Report bugs to <bug-libtool@gnu.org>.
Lev Walkin4da95cf2010-10-16 02:46:32 -070073
Lev Walkine7c4b962010-11-09 03:10:36 -080074PROGRAM=ltmain.sh
Lev Walkin4da95cf2010-10-16 02:46:32 -070075PACKAGE=libtool
Lev Walkine7c4b962010-11-09 03:10:36 -080076VERSION=2.2.4
Lev Walkin4da95cf2010-10-16 02:46:32 -070077TIMESTAMP=""
Lev Walkine7c4b962010-11-09 03:10:36 -080078package_revision=1.2976
Lev Walkin4da95cf2010-10-16 02:46:32 -070079
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
Lev Walkin4da95cf2010-10-16 02:46:32 -070094# NLS nuisances: We save the old values to restore during execute mode.
Lev Walkine7c4b962010-11-09 03:10:36 -080095# 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).
Lev Walkin4da95cf2010-10-16 02:46:32 -070098lt_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
Lev Walkin4da95cf2010-10-16 02:46:32 -0700110
111$lt_unset CDPATH
112
Lev Walkin8e8b5482004-06-17 23:42:48 +0000113
Lev Walkin8e8b5482004-06-17 23:42:48 +0000114
Lev Walkin4da95cf2010-10-16 02:46:32 -0700115
116
117: ${CP="cp -f"}
Lev Walkine7c4b962010-11-09 03:10:36 -0800118: ${ECHO="echo"}
119: ${EGREP="/usr/bin/grep -E"}
120: ${FGREP="/usr/bin/grep -F"}
121: ${GREP="/usr/bin/grep"}
Lev Walkin4da95cf2010-10-16 02:46:32 -0700122: ${LN_S="ln -s"}
123: ${MAKE="make"}
124: ${MKDIR="mkdir"}
125: ${MV="mv -f"}
126: ${RM="rm -f"}
Lev Walkine7c4b962010-11-09 03:10:36 -0800127: ${SED="/opt/local/bin/gsed"}
Lev Walkin4da95cf2010-10-16 02:46:32 -0700128: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
129: ${Xsed="$SED -e 1s/^X//"}
Lev Walkin8e8b5482004-06-17 23:42:48 +0000130
131# Global variables:
132EXIT_SUCCESS=0
133EXIT_FAILURE=1
Lev Walkin4da95cf2010-10-16 02:46:32 -0700134EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
135EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
Lev Walkin8e8b5482004-06-17 23:42:48 +0000136
Lev Walkin4da95cf2010-10-16 02:46:32 -0700137exit_status=$EXIT_SUCCESS
138
139# Make sure IFS has a sensible default
140lt_nl='
141'
142IFS=" $lt_nl"
143
144dirname="s,/[^/]*$,,"
145basename="s,^.*/,,"
146
Lev Walkin4da95cf2010-10-16 02:46:32 -0700147# 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{
Lev Walkine7c4b962010-11-09 03:10:36 -0800161 # 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"`
Lev Walkin4da95cf2010-10-16 02:46:32 -0700169}
170
Lev Walkine7c4b962010-11-09 03:10:36 -0800171# Generated shell functions inserted here.
Lev Walkin4da95cf2010-10-16 02:46:32 -0700172
Lev Walkine7c4b962010-11-09 03:10:36 -0800173# 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"
Lev Walkin4da95cf2010-10-16 02:46:32 -0700179
180# The name of this program:
Lev Walkine7c4b962010-11-09 03:10:36 -0800181# 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:
Lev Walkin4da95cf2010-10-16 02:46:32 -0700183func_dirname_and_basename "$progpath"
184progname=$func_basename_result
Lev Walkine7c4b962010-11-09 03:10:36 -0800185case $progname in
186 -*) progname=./$progname ;;
187esac
Lev Walkin4da95cf2010-10-16 02:46:32 -0700188
189# 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
Lev Walkinf15320b2004-06-03 03:38:44 +0000209
210# Sed substitution that helps us do robust quoting. It backslashifies
211# metacharacters that are still active within double-quoted strings.
Lev Walkin8e8b5482004-06-17 23:42:48 +0000212Xsed="${SED}"' -e 1s/^X//'
Lev Walkin4da95cf2010-10-16 02:46:32 -0700213sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
214
215# Same as above, but do not quote variable references.
216double_quote_subst='s/\(["`\\]\)/\\\1/g'
217
Lev Walkin4da95cf2010-10-16 02:46:32 -0700218# 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{
Lev Walkine7c4b962010-11-09 03:10:36 -0800246 $ECHO "$progname${mode+: }$mode: $*"
Lev Walkin4da95cf2010-10-16 02:46:32 -0700247}
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
Lev Walkin4da95cf2010-10-16 02:46:32 -0700261# func_error arg...
262# Echo program name prefixed message to standard error.
263func_error ()
264{
Lev Walkine7c4b962010-11-09 03:10:36 -0800265 $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
Lev Walkin4da95cf2010-10-16 02:46:32 -0700266}
267
268# func_warning arg...
269# Echo program name prefixed warning message to standard error.
270func_warning ()
271{
Lev Walkine7c4b962010-11-09 03:10:36 -0800272 $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
Lev Walkin4da95cf2010-10-16 02:46:32 -0700273
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
Lev Walkine7c4b962010-11-09 03:10:36 -0800329 my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"`
Lev Walkin4da95cf2010-10-16 02:46:32 -0700330 done
Lev Walkine7c4b962010-11-09 03:10:36 -0800331 my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'`
Lev Walkin4da95cf2010-10-16 02:46:32 -0700332
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
Lev Walkine7c4b962010-11-09 03:10:36 -0800381 $ECHO "X$my_tmpdir" | $Xsed
Lev Walkin4da95cf2010-10-16 02:46:32 -0700382}
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 *[\\\`\"\$]*)
Lev Walkine7c4b962010-11-09 03:10:36 -0800395 func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -0700396 *)
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 *[\\\`\"]*)
Lev Walkine7c4b962010-11-09 03:10:36 -0800422 my_arg=`$ECHO "X$1" | $Xsed \
Lev Walkin4da95cf2010-10-16 02:46:32 -0700423 -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
Lev Walkine7c4b962010-11-09 03:10:36 -0800491
492
Lev Walkin4da95cf2010-10-16 02:46:32 -0700493
494
495# func_version
496# Echo version message to standard output and exit.
497func_version ()
498{
Lev Walkine7c4b962010-11-09 03:10:36 -0800499 $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / {
Lev Walkin4da95cf2010-10-16 02:46:32 -0700500 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{
Lev Walkine7c4b962010-11-09 03:10:36 -0800512 $SED -n '/^# Usage:/,/# -h/ {
Lev Walkin4da95cf2010-10-16 02:46:32 -0700513 s/^# //
514 s/^# *$//
515 s/\$progname/'$progname'/
516 p
517 }' < "$progpath"
Lev Walkine7c4b962010-11-09 03:10:36 -0800518 $ECHO
Lev Walkin4da95cf2010-10-16 02:46:32 -0700519 $ECHO "run \`$progname --help | more' for full usage"
520 exit $?
521}
522
Lev Walkine7c4b962010-11-09 03:10:36 -0800523# func_help
524# Echo long help message to standard output and exit.
Lev Walkin4da95cf2010-10-16 02:46:32 -0700525func_help ()
526{
Lev Walkin4da95cf2010-10-16 02:46:32 -0700527 $SED -n '/^# Usage:/,/# Report bugs to/ {
Lev Walkin4da95cf2010-10-16 02:46:32 -0700528 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
Lev Walkine7c4b962010-11-09 03:10:36 -0800540 }' < "$progpath"
541 exit $?
Lev Walkin4da95cf2010-10-16 02:46:32 -0700542}
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{
Lev Walkine7c4b962010-11-09 03:10:36 -0800549 func_error "missing argument for $1"
Lev Walkin4da95cf2010-10-16 02:46:32 -0700550 exit_cmd=exit
551}
552
Lev Walkin4da95cf2010-10-16 02:46:32 -0700553exit_cmd=:
554
555
556
557
558
Lev Walkine7c4b962010-11-09 03:10:36 -0800559# Check that we have a working $ECHO.
560if 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 :
566elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then
567 # Yippee, $ECHO works!
568 :
569else
570 # Restart under the correct shell, and then maybe $ECHO will work.
571 exec $SHELL "$progpath" --no-reexec ${1+"$@"}
572fi
573
574if test "X$1" = X--fallback-echo; then
575 # used as fallback echo
576 shift
577 cat <<EOF
578$*
579EOF
580 exit $EXIT_SUCCESS
581fi
582
Lev Walkin4da95cf2010-10-16 02:46:32 -0700583magic="%%%MAGIC variable%%%"
584magic_exe="%%%MAGIC EXE variable%%%"
585
586# Global variables.
Lev Walkine7c4b962010-11-09 03:10:36 -0800587# $mode is unset
Lev Walkin4da95cf2010-10-16 02:46:32 -0700588nonopt=
Lev Walkine7c4b962010-11-09 03:10:36 -0800589execute_dlfiles=
Lev Walkin4da95cf2010-10-16 02:46:32 -0700590preserve_args=
591lo2o="s/\\.lo\$/.${objext}/"
592o2lo="s/\\.${objext}\$/.lo/"
593extracted_archives=
594extracted_serial=0
595
Lev Walkine7c4b962010-11-09 03:10:36 -0800596opt_dry_run=false
597opt_duplicate_deps=false
598opt_silent=false
599opt_debug=:
600
Lev Walkin4da95cf2010-10-16 02:46:32 -0700601# If this variable is set in any of the actions, the command in it
602# will be execed at the end. This prevents here-documents from being
603# left over by shells.
604exec_cmd=
605
Lev Walkin4da95cf2010-10-16 02:46:32 -0700606# func_fatal_configuration arg...
607# Echo program name prefixed message to standard error, followed by
608# a configuration failure hint, and exit.
609func_fatal_configuration ()
610{
611 func_error ${1+"$@"}
612 func_error "See the $PACKAGE documentation for more information."
613 func_fatal_error "Fatal configuration error."
614}
615
616
617# func_config
618# Display the configuration for all the tags in this script.
619func_config ()
620{
621 re_begincf='^# ### BEGIN LIBTOOL'
622 re_endcf='^# ### END LIBTOOL'
623
624 # Default configuration.
625 $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
626
627 # Now print the configurations for the tags.
628 for tagname in $taglist; do
629 $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
630 done
631
632 exit $?
633}
634
635# func_features
636# Display the features supported by this script.
637func_features ()
638{
Lev Walkine7c4b962010-11-09 03:10:36 -0800639 $ECHO "host: $host"
Lev Walkin4da95cf2010-10-16 02:46:32 -0700640 if test "$build_libtool_libs" = yes; then
Lev Walkine7c4b962010-11-09 03:10:36 -0800641 $ECHO "enable shared libraries"
Lev Walkin4da95cf2010-10-16 02:46:32 -0700642 else
Lev Walkine7c4b962010-11-09 03:10:36 -0800643 $ECHO "disable shared libraries"
Lev Walkin4da95cf2010-10-16 02:46:32 -0700644 fi
645 if test "$build_old_libs" = yes; then
Lev Walkine7c4b962010-11-09 03:10:36 -0800646 $ECHO "enable static libraries"
Lev Walkin4da95cf2010-10-16 02:46:32 -0700647 else
Lev Walkine7c4b962010-11-09 03:10:36 -0800648 $ECHO "disable static libraries"
Lev Walkin4da95cf2010-10-16 02:46:32 -0700649 fi
650
651 exit $?
652}
653
654# func_enable_tag tagname
655# Verify that TAGNAME is valid, and either flag an error and exit, or
656# enable the TAGNAME tag. We also add TAGNAME to the global $taglist
657# variable here.
658func_enable_tag ()
659{
660 # Global variable:
661 tagname="$1"
662
663 re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
664 re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
665 sed_extractcf="/$re_begincf/,/$re_endcf/p"
666
667 # Validate tagname.
668 case $tagname in
669 *[!-_A-Za-z0-9,/]*)
670 func_fatal_error "invalid tag name: $tagname"
671 ;;
672 esac
673
674 # Don't test for the "default" C tag, as we know it's
675 # there but not specially marked.
676 case $tagname in
677 CC) ;;
678 *)
679 if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
680 taglist="$taglist $tagname"
681
682 # Evaluate the configuration. Be careful to quote the path
683 # and the sed script, to avoid splitting on whitespace, but
684 # also don't use non-portable quotes within backquotes within
685 # quotes we have to do it in 2 steps:
686 extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
687 eval "$extractedcf"
688 else
689 func_error "ignoring unknown tag $tagname"
690 fi
691 ;;
692 esac
693}
694
Lev Walkine7c4b962010-11-09 03:10:36 -0800695# Parse options once, thoroughly. This comes as soon as possible in
696# the script to make things like `libtool --version' happen quickly.
697{
698
699 # Shorthand for --mode=foo, only valid as the first argument
700 case $1 in
701 clean|clea|cle|cl)
702 shift; set dummy --mode clean ${1+"$@"}; shift
703 ;;
704 compile|compil|compi|comp|com|co|c)
705 shift; set dummy --mode compile ${1+"$@"}; shift
706 ;;
707 execute|execut|execu|exec|exe|ex|e)
708 shift; set dummy --mode execute ${1+"$@"}; shift
709 ;;
710 finish|finis|fini|fin|fi|f)
711 shift; set dummy --mode finish ${1+"$@"}; shift
712 ;;
713 install|instal|insta|inst|ins|in|i)
714 shift; set dummy --mode install ${1+"$@"}; shift
715 ;;
716 link|lin|li|l)
717 shift; set dummy --mode link ${1+"$@"}; shift
718 ;;
719 uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
720 shift; set dummy --mode uninstall ${1+"$@"}; shift
721 ;;
722 esac
723
724 # Parse non-mode specific arguments:
725 while test "$#" -gt 0; do
726 opt="$1"
727 shift
728
729 case $opt in
730 --config) func_config ;;
731
732 --debug) preserve_args="$preserve_args $opt"
733 func_echo "enabling shell trace mode"
734 opt_debug='set -x'
735 $opt_debug
736 ;;
737
738 -dlopen) test "$#" -eq 0 && func_missing_arg "$opt" && break
739 execute_dlfiles="$execute_dlfiles $1"
740 shift
741 ;;
742
743 --dry-run | -n) opt_dry_run=: ;;
744 --features) func_features ;;
745 --finish) mode="finish" ;;
746
747 --mode) test "$#" -eq 0 && func_missing_arg "$opt" && break
748 case $1 in
749 # Valid mode arguments:
750 clean) ;;
751 compile) ;;
752 execute) ;;
753 finish) ;;
754 install) ;;
755 link) ;;
756 relink) ;;
757 uninstall) ;;
758
759 # Catch anything else as an error
760 *) func_error "invalid argument for $opt"
761 exit_cmd=exit
762 break
763 ;;
764 esac
765
766 mode="$1"
767 shift
768 ;;
769
770 --preserve-dup-deps)
771 opt_duplicate_deps=: ;;
772
773 --quiet|--silent) preserve_args="$preserve_args $opt"
774 opt_silent=:
775 ;;
776
777 --verbose| -v) preserve_args="$preserve_args $opt"
778 opt_silent=false
779 ;;
780
781 --tag) test "$#" -eq 0 && func_missing_arg "$opt" && break
782 preserve_args="$preserve_args $opt $1"
783 func_enable_tag "$1" # tagname is set here
784 shift
785 ;;
786
787 # Separate optargs to long options:
788 -dlopen=*|--mode=*|--tag=*)
789 func_opt_split "$opt"
790 set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
791 shift
792 ;;
793
794 -\?|-h) func_usage ;;
795 --help) opt_help=: ;;
796 --version) func_version ;;
797
798 -*) func_fatal_help "unrecognized option \`$opt'" ;;
799
800 *) nonopt="$opt"
801 break
802 ;;
803 esac
804 done
805
806
807 case $host in
808 *cygwin* | *mingw* | *pw32*)
809 # don't eliminate duplications in $postdeps and $predeps
810 opt_duplicate_compiler_generated_deps=:
811 ;;
812 *)
813 opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
814 ;;
815 esac
816
817 # Having warned about all mis-specified options, bail out if
818 # anything was wrong.
819 $exit_cmd $EXIT_FAILURE
820}
821
Lev Walkin4da95cf2010-10-16 02:46:32 -0700822# func_check_version_match
823# Ensure that we are using m4 macros, and libtool script from the same
824# release of libtool.
825func_check_version_match ()
826{
827 if test "$package_revision" != "$macro_revision"; then
828 if test "$VERSION" != "$macro_version"; then
829 if test -z "$macro_version"; then
830 cat >&2 <<_LT_EOF
831$progname: Version mismatch error. This is $PACKAGE $VERSION, but the
832$progname: definition of this LT_INIT comes from an older release.
833$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
834$progname: and run autoconf again.
835_LT_EOF
836 else
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 $PACKAGE $macro_version.
840$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
841$progname: and run autoconf again.
842_LT_EOF
843 fi
844 else
845 cat >&2 <<_LT_EOF
846$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
847$progname: but the definition of this LT_INIT comes from revision $macro_revision.
848$progname: You should recreate aclocal.m4 with macros from revision $package_revision
849$progname: of $PACKAGE $VERSION and run autoconf again.
850_LT_EOF
851 fi
852
853 exit $EXIT_MISMATCH
854 fi
855}
856
857
Lev Walkin4da95cf2010-10-16 02:46:32 -0700858## ----------- ##
859## Main. ##
860## ----------- ##
861
Lev Walkine7c4b962010-11-09 03:10:36 -0800862$opt_help || {
863 # Sanity checks first:
864 func_check_version_match
865
866 if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
867 func_fatal_configuration "not configured to build any kind of library"
868 fi
869
870 test -z "$mode" && func_fatal_error "error: you must specify a MODE."
871
872
873 # Darwin sucks
874 eval std_shrext=\"$shrext_cmds\"
875
876
877 # Only execute mode is allowed to have -dlopen flags.
878 if test -n "$execute_dlfiles" && test "$mode" != execute; then
879 func_error "unrecognized option \`-dlopen'"
880 $ECHO "$help" 1>&2
881 exit $EXIT_FAILURE
882 fi
883
884 # Change the help message to a mode-specific one.
885 generic_help="$help"
886 help="Try \`$progname --help --mode=$mode' for more information."
887}
888
889
Lev Walkin4da95cf2010-10-16 02:46:32 -0700890# func_lalib_p file
891# True iff FILE is a libtool `.la' library or `.lo' object file.
892# This function is only a basic sanity check; it will hardly flush out
893# determined imposters.
894func_lalib_p ()
895{
Lev Walkine7c4b962010-11-09 03:10:36 -0800896 $SED -e 4q "$1" 2>/dev/null \
897 | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
Lev Walkin4da95cf2010-10-16 02:46:32 -0700898}
899
900# func_lalib_unsafe_p file
901# True iff FILE is a libtool `.la' library or `.lo' object file.
902# This function implements the same check as func_lalib_p without
903# resorting to external programs. To this end, it redirects stdin and
904# closes it afterwards, without saving the original file descriptor.
905# As a safety measure, use it only where a negative result would be
906# fatal anyway. Works if `file' does not exist.
907func_lalib_unsafe_p ()
908{
909 lalib_p=no
Lev Walkine7c4b962010-11-09 03:10:36 -0800910 if test -r "$1" && exec 5<&0 <"$1"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -0700911 for lalib_p_l in 1 2 3 4
912 do
913 read lalib_p_line
914 case "$lalib_p_line" in
915 \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
916 esac
917 done
918 exec 0<&5 5<&-
919 fi
920 test "$lalib_p" = yes
921}
922
923# func_ltwrapper_script_p file
924# True iff FILE is a libtool wrapper script
925# This function is only a basic sanity check; it will hardly flush out
926# determined imposters.
927func_ltwrapper_script_p ()
928{
929 func_lalib_p "$1"
930}
931
932# func_ltwrapper_executable_p file
933# True iff FILE is a libtool wrapper executable
934# This function is only a basic sanity check; it will hardly flush out
935# determined imposters.
936func_ltwrapper_executable_p ()
937{
938 func_ltwrapper_exec_suffix=
939 case $1 in
940 *.exe) ;;
941 *) func_ltwrapper_exec_suffix=.exe ;;
942 esac
943 $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
944}
945
946# func_ltwrapper_scriptname file
947# Assumes file is an ltwrapper_executable
948# uses $file to determine the appropriate filename for a
949# temporary ltwrapper_script.
950func_ltwrapper_scriptname ()
951{
Lev Walkine7c4b962010-11-09 03:10:36 -0800952 func_ltwrapper_scriptname_result=""
953 if func_ltwrapper_executable_p "$1"; then
954 func_dirname_and_basename "$1" "" "."
955 func_stripname '' '.exe' "$func_basename_result"
956 func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
957 fi
Lev Walkin4da95cf2010-10-16 02:46:32 -0700958}
959
960# func_ltwrapper_p file
961# True iff FILE is a libtool wrapper script or wrapper executable
962# This function is only a basic sanity check; it will hardly flush out
963# determined imposters.
964func_ltwrapper_p ()
965{
966 func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
967}
968
969
970# func_execute_cmds commands fail_cmd
971# Execute tilde-delimited COMMANDS.
972# If FAIL_CMD is given, eval that upon failure.
973# FAIL_CMD may read-access the current command in variable CMD!
974func_execute_cmds ()
975{
976 $opt_debug
977 save_ifs=$IFS; IFS='~'
978 for cmd in $1; do
979 IFS=$save_ifs
980 eval cmd=\"$cmd\"
981 func_show_eval "$cmd" "${2-:}"
982 done
983 IFS=$save_ifs
984}
985
986
987# func_source file
988# Source FILE, adding directory component if necessary.
989# Note that it is not necessary on cygwin/mingw to append a dot to
990# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
991# behavior happens only for exec(3), not for open(2)! Also, sourcing
992# `FILE.' does not work on cygwin managed mounts.
993func_source ()
994{
995 $opt_debug
996 case $1 in
997 */* | *\\*) . "$1" ;;
998 *) . "./$1" ;;
999 esac
1000}
1001
1002
Lev Walkin8e8b5482004-06-17 23:42:48 +00001003# func_infer_tag arg
1004# Infer tagged configuration to use if any are available and
1005# if one wasn't chosen via the "--tag" command line option.
1006# Only attempt this if the compiler in the base compile
1007# command doesn't match the default compiler.
1008# arg is usually of the form 'gcc ...'
Lev Walkin4da95cf2010-10-16 02:46:32 -07001009func_infer_tag ()
1010{
1011 $opt_debug
Lev Walkin8e8b5482004-06-17 23:42:48 +00001012 if test -n "$available_tags" && test -z "$tagname"; then
1013 CC_quoted=
1014 for arg in $CC; do
Lev Walkine7c4b962010-11-09 03:10:36 -08001015 func_quote_for_eval "$arg"
1016 CC_quoted="$CC_quoted $func_quote_for_eval_result"
Lev Walkin8e8b5482004-06-17 23:42:48 +00001017 done
1018 case $@ in
1019 # Blanks in the command may have been stripped by the calling shell,
1020 # but not from the CC environment variable when configure was run.
Lev Walkine7c4b962010-11-09 03:10:36 -08001021 " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00001022 # Blanks at the start of $base_compile will cause this to fail
1023 # if we don't check for them as well.
1024 *)
1025 for z in $available_tags; do
Lev Walkin4da95cf2010-10-16 02:46:32 -07001026 if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00001027 # Evaluate the configuration.
1028 eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1029 CC_quoted=
1030 for arg in $CC; do
Lev Walkin4da95cf2010-10-16 02:46:32 -07001031 # Double-quote args containing other shell metacharacters.
Lev Walkine7c4b962010-11-09 03:10:36 -08001032 func_quote_for_eval "$arg"
1033 CC_quoted="$CC_quoted $func_quote_for_eval_result"
Lev Walkin4da95cf2010-10-16 02:46:32 -07001034 done
Lev Walkin8e8b5482004-06-17 23:42:48 +00001035 case "$@ " in
Lev Walkine7c4b962010-11-09 03:10:36 -08001036 " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*)
Lev Walkin8e8b5482004-06-17 23:42:48 +00001037 # The compiler in the base compile command matches
1038 # the one in the tagged configuration.
1039 # Assume this is the tagged configuration we want.
1040 tagname=$z
1041 break
1042 ;;
1043 esac
1044 fi
1045 done
1046 # If $tagname still isn't set, then no tagged configuration
1047 # was found and let the user know that the "--tag" command
1048 # line option must be used.
1049 if test -z "$tagname"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07001050 func_echo "unable to infer tagged configuration"
1051 func_fatal_error "specify a tag with \`--tag'"
1052# else
1053# func_verbose "using $tagname tagged configuration"
Lev Walkin8e8b5482004-06-17 23:42:48 +00001054 fi
1055 ;;
1056 esac
1057 fi
1058}
Lev Walkin8e8b5482004-06-17 23:42:48 +00001059
Lev Walkin8e8b5482004-06-17 23:42:48 +00001060
Lev Walkinf15320b2004-06-03 03:38:44 +00001061
Lev Walkin4da95cf2010-10-16 02:46:32 -07001062# func_write_libtool_object output_name pic_name nonpic_name
1063# Create a libtool object file (analogous to a ".la" file),
1064# but don't create it if we're doing a dry run.
1065func_write_libtool_object ()
1066{
1067 write_libobj=${1}
Lev Walkinf15320b2004-06-03 03:38:44 +00001068 if test "$build_libtool_libs" = yes; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07001069 write_lobj=\'${2}\'
Lev Walkinf15320b2004-06-03 03:38:44 +00001070 else
Lev Walkin4da95cf2010-10-16 02:46:32 -07001071 write_lobj=none
Lev Walkinf15320b2004-06-03 03:38:44 +00001072 fi
Lev Walkin4da95cf2010-10-16 02:46:32 -07001073
Lev Walkinf15320b2004-06-03 03:38:44 +00001074 if test "$build_old_libs" = yes; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07001075 write_oldobj=\'${3}\'
Lev Walkinf15320b2004-06-03 03:38:44 +00001076 else
Lev Walkin4da95cf2010-10-16 02:46:32 -07001077 write_oldobj=none
Lev Walkinf15320b2004-06-03 03:38:44 +00001078 fi
Lev Walkinf15320b2004-06-03 03:38:44 +00001079
Lev Walkin4da95cf2010-10-16 02:46:32 -07001080 $opt_dry_run || {
1081 cat >${write_libobj}T <<EOF
1082# $write_libobj - a libtool object file
1083# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1084#
1085# Please DO NOT delete this file!
1086# It is necessary for linking the library.
Lev Walkinf15320b2004-06-03 03:38:44 +00001087
Lev Walkin4da95cf2010-10-16 02:46:32 -07001088# Name of the PIC object.
1089pic_object=$write_lobj
Lev Walkinf15320b2004-06-03 03:38:44 +00001090
Lev Walkin4da95cf2010-10-16 02:46:32 -07001091# Name of the non-PIC object
1092non_pic_object=$write_oldobj
Lev Walkin8e8b5482004-06-17 23:42:48 +00001093
Lev Walkin4da95cf2010-10-16 02:46:32 -07001094EOF
1095 $MV "${write_libobj}T" "${write_libobj}"
1096 }
1097}
Lev Walkin8e8b5482004-06-17 23:42:48 +00001098
Lev Walkin4da95cf2010-10-16 02:46:32 -07001099# func_mode_compile arg...
1100func_mode_compile ()
1101{
1102 $opt_debug
Lev Walkinf15320b2004-06-03 03:38:44 +00001103 # Get the compilation command and the source file.
1104 base_compile=
Lev Walkin8e8b5482004-06-17 23:42:48 +00001105 srcfile="$nonopt" # always keep a non-empty value in "srcfile"
1106 suppress_opt=yes
Lev Walkinf15320b2004-06-03 03:38:44 +00001107 suppress_output=
Lev Walkin8e8b5482004-06-17 23:42:48 +00001108 arg_mode=normal
1109 libobj=
1110 later=
Lev Walkin4da95cf2010-10-16 02:46:32 -07001111 pie_flag=
Lev Walkinf15320b2004-06-03 03:38:44 +00001112
Lev Walkinf15320b2004-06-03 03:38:44 +00001113 for arg
1114 do
Lev Walkin4da95cf2010-10-16 02:46:32 -07001115 case $arg_mode in
Lev Walkin8e8b5482004-06-17 23:42:48 +00001116 arg )
1117 # do not "continue". Instead, add this to base_compile
1118 lastarg="$arg"
1119 arg_mode=normal
Lev Walkinf15320b2004-06-03 03:38:44 +00001120 ;;
1121
Lev Walkin8e8b5482004-06-17 23:42:48 +00001122 target )
Lev Walkinf15320b2004-06-03 03:38:44 +00001123 libobj="$arg"
Lev Walkin8e8b5482004-06-17 23:42:48 +00001124 arg_mode=normal
Lev Walkinf15320b2004-06-03 03:38:44 +00001125 continue
1126 ;;
Lev Walkinf15320b2004-06-03 03:38:44 +00001127
Lev Walkin8e8b5482004-06-17 23:42:48 +00001128 normal )
1129 # Accept any command-line options.
1130 case $arg in
1131 -o)
Lev Walkin4da95cf2010-10-16 02:46:32 -07001132 test -n "$libobj" && \
1133 func_fatal_error "you cannot specify \`-o' more than once"
Lev Walkin8e8b5482004-06-17 23:42:48 +00001134 arg_mode=target
1135 continue
1136 ;;
1137
Lev Walkin4da95cf2010-10-16 02:46:32 -07001138 -pie | -fpie | -fPIE)
Lev Walkine7c4b962010-11-09 03:10:36 -08001139 pie_flag="$pie_flag $arg"
Lev Walkin4da95cf2010-10-16 02:46:32 -07001140 continue
1141 ;;
1142
1143 -shared | -static | -prefer-pic | -prefer-non-pic)
Lev Walkine7c4b962010-11-09 03:10:36 -08001144 later="$later $arg"
Lev Walkin8e8b5482004-06-17 23:42:48 +00001145 continue
1146 ;;
1147
1148 -no-suppress)
1149 suppress_opt=no
1150 continue
1151 ;;
1152
1153 -Xcompiler)
1154 arg_mode=arg # the next one goes into the "base_compile" arg list
1155 continue # The current "srcfile" will either be retained or
1156 ;; # replaced later. I would guess that would be a bug.
1157
1158 -Wc,*)
Lev Walkin4da95cf2010-10-16 02:46:32 -07001159 func_stripname '-Wc,' '' "$arg"
1160 args=$func_stripname_result
Lev Walkin8e8b5482004-06-17 23:42:48 +00001161 lastarg=
1162 save_ifs="$IFS"; IFS=','
Lev Walkin4da95cf2010-10-16 02:46:32 -07001163 for arg in $args; do
Lev Walkin8e8b5482004-06-17 23:42:48 +00001164 IFS="$save_ifs"
Lev Walkine7c4b962010-11-09 03:10:36 -08001165 func_quote_for_eval "$arg"
1166 lastarg="$lastarg $func_quote_for_eval_result"
Lev Walkin8e8b5482004-06-17 23:42:48 +00001167 done
1168 IFS="$save_ifs"
Lev Walkin4da95cf2010-10-16 02:46:32 -07001169 func_stripname ' ' '' "$lastarg"
1170 lastarg=$func_stripname_result
Lev Walkin8e8b5482004-06-17 23:42:48 +00001171
1172 # Add the arguments to base_compile.
Lev Walkine7c4b962010-11-09 03:10:36 -08001173 base_compile="$base_compile $lastarg"
Lev Walkin8e8b5482004-06-17 23:42:48 +00001174 continue
1175 ;;
1176
Lev Walkin4da95cf2010-10-16 02:46:32 -07001177 *)
Lev Walkin8e8b5482004-06-17 23:42:48 +00001178 # Accept the current argument as the source file.
1179 # The previous "srcfile" becomes the current argument.
1180 #
1181 lastarg="$srcfile"
1182 srcfile="$arg"
1183 ;;
1184 esac # case $arg
1185 ;;
1186 esac # case $arg_mode
Lev Walkinf15320b2004-06-03 03:38:44 +00001187
1188 # Aesthetically quote the previous argument.
Lev Walkine7c4b962010-11-09 03:10:36 -08001189 func_quote_for_eval "$lastarg"
1190 base_compile="$base_compile $func_quote_for_eval_result"
Lev Walkin8e8b5482004-06-17 23:42:48 +00001191 done # for arg
Lev Walkinf15320b2004-06-03 03:38:44 +00001192
Lev Walkin8e8b5482004-06-17 23:42:48 +00001193 case $arg_mode in
1194 arg)
Lev Walkin4da95cf2010-10-16 02:46:32 -07001195 func_fatal_error "you must specify an argument for -Xcompile"
Lev Walkinf15320b2004-06-03 03:38:44 +00001196 ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00001197 target)
Lev Walkin4da95cf2010-10-16 02:46:32 -07001198 func_fatal_error "you must specify a target with \`-o'"
Lev Walkinf15320b2004-06-03 03:38:44 +00001199 ;;
1200 *)
Lev Walkin8e8b5482004-06-17 23:42:48 +00001201 # Get the name of the library object.
Lev Walkin4da95cf2010-10-16 02:46:32 -07001202 test -z "$libobj" && {
1203 func_basename "$srcfile"
1204 libobj="$func_basename_result"
1205 }
Lev Walkinf15320b2004-06-03 03:38:44 +00001206 ;;
1207 esac
1208
1209 # Recognize several different file suffixes.
1210 # If the user specifies -o file.o, it is replaced with file.lo
Lev Walkin8e8b5482004-06-17 23:42:48 +00001211 case $libobj in
Lev Walkin4da95cf2010-10-16 02:46:32 -07001212 *.[cCFSifmso] | \
1213 *.ada | *.adb | *.ads | *.asm | \
1214 *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
Lev Walkine7c4b962010-11-09 03:10:36 -08001215 *.[fF][09]? | *.for | *.java | *.obj | *.sx)
Lev Walkin4da95cf2010-10-16 02:46:32 -07001216 func_xform "$libobj"
1217 libobj=$func_xform_result
1218 ;;
Lev Walkinf15320b2004-06-03 03:38:44 +00001219 esac
1220
Lev Walkin8e8b5482004-06-17 23:42:48 +00001221 case $libobj in
Lev Walkin4da95cf2010-10-16 02:46:32 -07001222 *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
Lev Walkinf15320b2004-06-03 03:38:44 +00001223 *)
Lev Walkin4da95cf2010-10-16 02:46:32 -07001224 func_fatal_error "cannot determine name of library object from \`$libobj'"
Lev Walkinf15320b2004-06-03 03:38:44 +00001225 ;;
1226 esac
1227
Lev Walkin8e8b5482004-06-17 23:42:48 +00001228 func_infer_tag $base_compile
1229
1230 for arg in $later; do
1231 case $arg in
Lev Walkin4da95cf2010-10-16 02:46:32 -07001232 -shared)
1233 test "$build_libtool_libs" != yes && \
1234 func_fatal_configuration "can not build a shared library"
1235 build_old_libs=no
1236 continue
1237 ;;
1238
Lev Walkin8e8b5482004-06-17 23:42:48 +00001239 -static)
Lev Walkin4da95cf2010-10-16 02:46:32 -07001240 build_libtool_libs=no
Lev Walkin8e8b5482004-06-17 23:42:48 +00001241 build_old_libs=yes
1242 continue
1243 ;;
1244
1245 -prefer-pic)
1246 pic_mode=yes
1247 continue
1248 ;;
1249
1250 -prefer-non-pic)
1251 pic_mode=no
1252 continue
1253 ;;
1254 esac
1255 done
1256
Lev Walkin4da95cf2010-10-16 02:46:32 -07001257 func_quote_for_eval "$libobj"
1258 test "X$libobj" != "X$func_quote_for_eval_result" \
1259 && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
1260 && func_warning "libobj name \`$libobj' may not contain shell special characters."
1261 func_dirname_and_basename "$obj" "/" ""
1262 objname="$func_basename_result"
1263 xdir="$func_dirname_result"
Lev Walkin8e8b5482004-06-17 23:42:48 +00001264 lobj=${xdir}$objdir/$objname
1265
Lev Walkin4da95cf2010-10-16 02:46:32 -07001266 test -z "$base_compile" && \
1267 func_fatal_help "you must specify a compilation command"
Lev Walkinf15320b2004-06-03 03:38:44 +00001268
1269 # Delete any leftover library objects.
1270 if test "$build_old_libs" = yes; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00001271 removelist="$obj $lobj $libobj ${libobj}T"
Lev Walkinf15320b2004-06-03 03:38:44 +00001272 else
Lev Walkin8e8b5482004-06-17 23:42:48 +00001273 removelist="$lobj $libobj ${libobj}T"
Lev Walkinf15320b2004-06-03 03:38:44 +00001274 fi
1275
Lev Walkin8e8b5482004-06-17 23:42:48 +00001276 # On Cygwin there's no "real" PIC flag so we must build both object types
1277 case $host_os in
Lev Walkine7c4b962010-11-09 03:10:36 -08001278 cygwin* | mingw* | pw32* | os2*)
Lev Walkin8e8b5482004-06-17 23:42:48 +00001279 pic_mode=default
1280 ;;
1281 esac
1282 if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
1283 # non-PIC code in shared libraries is not supported
1284 pic_mode=default
1285 fi
Lev Walkinf15320b2004-06-03 03:38:44 +00001286
1287 # Calculate the filename of the output object if compiler does
1288 # not support -o with -c
1289 if test "$compiler_c_o" = no; then
Lev Walkine7c4b962010-11-09 03:10:36 -08001290 output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
Lev Walkinf15320b2004-06-03 03:38:44 +00001291 lockfile="$output_obj.lock"
Lev Walkinf15320b2004-06-03 03:38:44 +00001292 else
Lev Walkin8e8b5482004-06-17 23:42:48 +00001293 output_obj=
Lev Walkinf15320b2004-06-03 03:38:44 +00001294 need_locks=no
1295 lockfile=
1296 fi
1297
1298 # Lock this critical section if it is needed
1299 # We use this script file to make the link, it avoids creating a new file
1300 if test "$need_locks" = yes; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07001301 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
1302 func_echo "Waiting for $lockfile to be removed"
Lev Walkinf15320b2004-06-03 03:38:44 +00001303 sleep 2
1304 done
1305 elif test "$need_locks" = warn; then
1306 if test -f "$lockfile"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07001307 $ECHO "\
Lev Walkinf15320b2004-06-03 03:38:44 +00001308*** ERROR, $lockfile exists and contains:
1309`cat $lockfile 2>/dev/null`
1310
1311This indicates that another process is trying to use the same
1312temporary object file, and libtool could not work around it because
1313your compiler does not support \`-c' and \`-o' together. If you
1314repeat this compilation, it may succeed, by chance, but you had better
1315avoid parallel builds (make -j) in this platform, or get a better
1316compiler."
1317
Lev Walkin4da95cf2010-10-16 02:46:32 -07001318 $opt_dry_run || $RM $removelist
Lev Walkin8e8b5482004-06-17 23:42:48 +00001319 exit $EXIT_FAILURE
Lev Walkinf15320b2004-06-03 03:38:44 +00001320 fi
Lev Walkine7c4b962010-11-09 03:10:36 -08001321 removelist="$removelist $output_obj"
Lev Walkin4da95cf2010-10-16 02:46:32 -07001322 $ECHO "$srcfile" > "$lockfile"
Lev Walkinf15320b2004-06-03 03:38:44 +00001323 fi
1324
Lev Walkin4da95cf2010-10-16 02:46:32 -07001325 $opt_dry_run || $RM $removelist
Lev Walkine7c4b962010-11-09 03:10:36 -08001326 removelist="$removelist $lockfile"
Lev Walkin4da95cf2010-10-16 02:46:32 -07001327 trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
Lev Walkinf15320b2004-06-03 03:38:44 +00001328
Lev Walkine7c4b962010-11-09 03:10:36 -08001329 if test -n "$fix_srcfile_path"; then
1330 eval srcfile=\"$fix_srcfile_path\"
1331 fi
Lev Walkin4da95cf2010-10-16 02:46:32 -07001332 func_quote_for_eval "$srcfile"
1333 qsrcfile=$func_quote_for_eval_result
Lev Walkin8e8b5482004-06-17 23:42:48 +00001334
Lev Walkinf15320b2004-06-03 03:38:44 +00001335 # Only build a PIC object if we are building libtool libraries.
1336 if test "$build_libtool_libs" = yes; then
1337 # Without this assignment, base_compile gets emptied.
1338 fbsd_hideous_sh_bug=$base_compile
1339
Lev Walkin8e8b5482004-06-17 23:42:48 +00001340 if test "$pic_mode" != no; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07001341 command="$base_compile $qsrcfile $pic_flag"
Lev Walkin8e8b5482004-06-17 23:42:48 +00001342 else
1343 # Don't build PIC code
Lev Walkin4da95cf2010-10-16 02:46:32 -07001344 command="$base_compile $qsrcfile"
Lev Walkinf15320b2004-06-03 03:38:44 +00001345 fi
1346
Lev Walkin4da95cf2010-10-16 02:46:32 -07001347 func_mkdir_p "$xdir$objdir"
Lev Walkin8e8b5482004-06-17 23:42:48 +00001348
1349 if test -z "$output_obj"; then
1350 # Place PIC objects in $objdir
Lev Walkine7c4b962010-11-09 03:10:36 -08001351 command="$command -o $lobj"
Lev Walkin8e8b5482004-06-17 23:42:48 +00001352 fi
1353
Lev Walkin4da95cf2010-10-16 02:46:32 -07001354 func_show_eval_locale "$command" \
1355 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
Lev Walkinf15320b2004-06-03 03:38:44 +00001356
1357 if test "$need_locks" = warn &&
Lev Walkin8e8b5482004-06-17 23:42:48 +00001358 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07001359 $ECHO "\
Lev Walkinf15320b2004-06-03 03:38:44 +00001360*** ERROR, $lockfile contains:
1361`cat $lockfile 2>/dev/null`
1362
1363but it should contain:
1364$srcfile
1365
1366This indicates that another process is trying to use the same
1367temporary object file, and libtool could not work around it because
1368your compiler does not support \`-c' and \`-o' together. If you
1369repeat this compilation, it may succeed, by chance, but you had better
1370avoid parallel builds (make -j) in this platform, or get a better
1371compiler."
1372
Lev Walkin4da95cf2010-10-16 02:46:32 -07001373 $opt_dry_run || $RM $removelist
Lev Walkin8e8b5482004-06-17 23:42:48 +00001374 exit $EXIT_FAILURE
Lev Walkinf15320b2004-06-03 03:38:44 +00001375 fi
1376
1377 # Just move the object if needed, then go on to compile the next one
Lev Walkin8e8b5482004-06-17 23:42:48 +00001378 if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07001379 func_show_eval '$MV "$output_obj" "$lobj"' \
1380 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
Lev Walkinf15320b2004-06-03 03:38:44 +00001381 fi
1382
Lev Walkinf15320b2004-06-03 03:38:44 +00001383 # Allow error messages only from the first compilation.
Lev Walkin8e8b5482004-06-17 23:42:48 +00001384 if test "$suppress_opt" = yes; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07001385 suppress_output=' >/dev/null 2>&1'
Lev Walkin8e8b5482004-06-17 23:42:48 +00001386 fi
Lev Walkinf15320b2004-06-03 03:38:44 +00001387 fi
1388
1389 # Only build a position-dependent object if we build old libraries.
1390 if test "$build_old_libs" = yes; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00001391 if test "$pic_mode" != yes; then
1392 # Don't build PIC code
Lev Walkin4da95cf2010-10-16 02:46:32 -07001393 command="$base_compile $qsrcfile$pie_flag"
Lev Walkin8e8b5482004-06-17 23:42:48 +00001394 else
Lev Walkin4da95cf2010-10-16 02:46:32 -07001395 command="$base_compile $qsrcfile $pic_flag"
Lev Walkin8e8b5482004-06-17 23:42:48 +00001396 fi
Lev Walkinf15320b2004-06-03 03:38:44 +00001397 if test "$compiler_c_o" = yes; then
Lev Walkine7c4b962010-11-09 03:10:36 -08001398 command="$command -o $obj"
Lev Walkinf15320b2004-06-03 03:38:44 +00001399 fi
1400
1401 # Suppress compiler output if we already did a PIC compilation.
Lev Walkine7c4b962010-11-09 03:10:36 -08001402 command="$command$suppress_output"
Lev Walkin4da95cf2010-10-16 02:46:32 -07001403 func_show_eval_locale "$command" \
1404 '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
Lev Walkinf15320b2004-06-03 03:38:44 +00001405
1406 if test "$need_locks" = warn &&
Lev Walkin8e8b5482004-06-17 23:42:48 +00001407 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07001408 $ECHO "\
Lev Walkinf15320b2004-06-03 03:38:44 +00001409*** ERROR, $lockfile contains:
1410`cat $lockfile 2>/dev/null`
1411
1412but it should contain:
1413$srcfile
1414
1415This indicates that another process is trying to use the same
1416temporary object file, and libtool could not work around it because
1417your compiler does not support \`-c' and \`-o' together. If you
1418repeat this compilation, it may succeed, by chance, but you had better
1419avoid parallel builds (make -j) in this platform, or get a better
1420compiler."
1421
Lev Walkin4da95cf2010-10-16 02:46:32 -07001422 $opt_dry_run || $RM $removelist
Lev Walkin8e8b5482004-06-17 23:42:48 +00001423 exit $EXIT_FAILURE
Lev Walkinf15320b2004-06-03 03:38:44 +00001424 fi
1425
1426 # Just move the object if needed
Lev Walkin8e8b5482004-06-17 23:42:48 +00001427 if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07001428 func_show_eval '$MV "$output_obj" "$obj"' \
1429 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
Lev Walkinf15320b2004-06-03 03:38:44 +00001430 fi
Lev Walkinf15320b2004-06-03 03:38:44 +00001431 fi
1432
Lev Walkin4da95cf2010-10-16 02:46:32 -07001433 $opt_dry_run || {
1434 func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
Lev Walkin8e8b5482004-06-17 23:42:48 +00001435
Lev Walkin4da95cf2010-10-16 02:46:32 -07001436 # Unlock the critical section if it was locked
1437 if test "$need_locks" != no; then
1438 removelist=$lockfile
1439 $RM "$lockfile"
1440 fi
1441 }
Lev Walkinf15320b2004-06-03 03:38:44 +00001442
Lev Walkin8e8b5482004-06-17 23:42:48 +00001443 exit $EXIT_SUCCESS
Lev Walkin4da95cf2010-10-16 02:46:32 -07001444}
1445
1446$opt_help || {
Lev Walkine7c4b962010-11-09 03:10:36 -08001447test "$mode" = compile && func_mode_compile ${1+"$@"}
Lev Walkin4da95cf2010-10-16 02:46:32 -07001448}
1449
1450func_mode_help ()
1451{
1452 # We need to display help for each of the modes.
Lev Walkine7c4b962010-11-09 03:10:36 -08001453 case $mode in
Lev Walkin4da95cf2010-10-16 02:46:32 -07001454 "")
1455 # Generic help is extracted from the usage comments
1456 # at the start of this file.
1457 func_help
1458 ;;
1459
1460 clean)
1461 $ECHO \
1462"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
1463
1464Remove files from the build directory.
1465
1466RM is the name of the program to use to delete files associated with each FILE
1467(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
1468to RM.
1469
1470If FILE is a libtool library, object or program, all the files associated
1471with it are deleted. Otherwise, only FILE itself is deleted using RM."
1472 ;;
1473
1474 compile)
1475 $ECHO \
1476"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
1477
1478Compile a source file into a libtool library object.
1479
1480This mode accepts the following additional options:
1481
1482 -o OUTPUT-FILE set the output file name to OUTPUT-FILE
1483 -no-suppress do not suppress compiler output for multiple passes
Lev Walkine7c4b962010-11-09 03:10:36 -08001484 -prefer-pic try to building PIC objects only
1485 -prefer-non-pic try to building non-PIC objects only
Lev Walkin4da95cf2010-10-16 02:46:32 -07001486 -shared do not build a \`.o' file suitable for static linking
1487 -static only build a \`.o' file suitable for static linking
Lev Walkin4da95cf2010-10-16 02:46:32 -07001488
1489COMPILE-COMMAND is a command to be used in creating a \`standard' object file
1490from the given SOURCEFILE.
1491
1492The output file name is determined by removing the directory component from
1493SOURCEFILE, then substituting the C source code suffix \`.c' with the
1494library object suffix, \`.lo'."
1495 ;;
1496
1497 execute)
1498 $ECHO \
1499"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
1500
1501Automatically set library path, then run a program.
1502
1503This mode accepts the following additional options:
1504
1505 -dlopen FILE add the directory containing FILE to the library path
1506
1507This mode sets the library path environment variable according to \`-dlopen'
1508flags.
1509
1510If any of the ARGS are libtool executable wrappers, then they are translated
1511into their corresponding uninstalled binary, and any of their required library
1512directories are added to the library path.
1513
1514Then, COMMAND is executed, with ARGS as arguments."
1515 ;;
1516
1517 finish)
1518 $ECHO \
1519"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
1520
1521Complete the installation of libtool libraries.
1522
1523Each LIBDIR is a directory that contains libtool libraries.
1524
1525The commands that this mode executes may require superuser privileges. Use
1526the \`--dry-run' option if you just want to see what would be executed."
1527 ;;
1528
1529 install)
1530 $ECHO \
1531"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
1532
1533Install executables or libraries.
1534
1535INSTALL-COMMAND is the installation command. The first component should be
1536either the \`install' or \`cp' program.
1537
1538The following components of INSTALL-COMMAND are treated specially:
1539
Lev Walkine7c4b962010-11-09 03:10:36 -08001540 -inst-prefix PREFIX-DIR Use PREFIX-DIR as a staging area for installation
Lev Walkin4da95cf2010-10-16 02:46:32 -07001541
1542The rest of the components are interpreted as arguments to that command (only
1543BSD-compatible install options are recognized)."
1544 ;;
1545
1546 link)
1547 $ECHO \
1548"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
1549
1550Link object files or libraries together to form another library, or to
1551create an executable program.
1552
1553LINK-COMMAND is a command using the C compiler that you would use to create
1554a program from several object files.
1555
1556The following components of LINK-COMMAND are treated specially:
1557
1558 -all-static do not do any dynamic linking at all
1559 -avoid-version do not add a version suffix if possible
Lev Walkin4da95cf2010-10-16 02:46:32 -07001560 -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime
1561 -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
1562 -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
1563 -export-symbols SYMFILE
1564 try to export only the symbols listed in SYMFILE
1565 -export-symbols-regex REGEX
1566 try to export only the symbols matching REGEX
1567 -LLIBDIR search LIBDIR for required installed libraries
1568 -lNAME OUTPUT-FILE requires the installed library libNAME
1569 -module build a library that can dlopened
1570 -no-fast-install disable the fast-install mode
1571 -no-install link a not-installable executable
1572 -no-undefined declare that a library does not refer to external symbols
1573 -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
1574 -objectlist FILE Use a list of object files found in FILE to specify objects
1575 -precious-files-regex REGEX
1576 don't remove output files matching REGEX
1577 -release RELEASE specify package release information
1578 -rpath LIBDIR the created library will eventually be installed in LIBDIR
1579 -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
1580 -shared only do dynamic linking of libtool libraries
1581 -shrext SUFFIX override the standard shared library file extension
1582 -static do not do any dynamic linking of uninstalled libtool libraries
1583 -static-libtool-libs
1584 do not do any dynamic linking of libtool libraries
1585 -version-info CURRENT[:REVISION[:AGE]]
1586 specify library version info [each variable defaults to 0]
1587 -weak LIBNAME declare that the target provides the LIBNAME interface
Lev Walkin4da95cf2010-10-16 02:46:32 -07001588
1589All other options (arguments beginning with \`-') are ignored.
1590
1591Every other argument is treated as a filename. Files ending in \`.la' are
1592treated as uninstalled libtool libraries, other files are standard or library
1593object files.
1594
1595If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
1596only library objects (\`.lo' files) may be specified, and \`-rpath' is
1597required, except when creating a convenience library.
1598
1599If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
1600using \`ar' and \`ranlib', or on Windows using \`lib'.
1601
1602If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
1603is created, otherwise an executable program is created."
1604 ;;
1605
1606 uninstall)
1607 $ECHO \
1608"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
1609
1610Remove libraries from an installation directory.
1611
1612RM is the name of the program to use to delete files associated with each FILE
1613(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
1614to RM.
1615
1616If FILE is a libtool library, all the files associated with it are deleted.
1617Otherwise, only FILE itself is deleted using RM."
1618 ;;
1619
1620 *)
Lev Walkine7c4b962010-11-09 03:10:36 -08001621 func_fatal_help "invalid operation mode \`$mode'"
Lev Walkin4da95cf2010-10-16 02:46:32 -07001622 ;;
1623 esac
1624
Lev Walkine7c4b962010-11-09 03:10:36 -08001625 $ECHO
Lev Walkin4da95cf2010-10-16 02:46:32 -07001626 $ECHO "Try \`$progname --help' for more information about other modes."
Lev Walkine7c4b962010-11-09 03:10:36 -08001627
1628 exit $?
Lev Walkin4da95cf2010-10-16 02:46:32 -07001629}
1630
Lev Walkine7c4b962010-11-09 03:10:36 -08001631 # Now that we've collected a possible --mode arg, show help if necessary
1632 $opt_help && func_mode_help
Lev Walkin4da95cf2010-10-16 02:46:32 -07001633
1634
1635# func_mode_execute arg...
1636func_mode_execute ()
1637{
1638 $opt_debug
1639 # The first argument is the command name.
1640 cmd="$nonopt"
1641 test -z "$cmd" && \
1642 func_fatal_help "you must specify a COMMAND"
1643
1644 # Handle -dlopen flags immediately.
Lev Walkine7c4b962010-11-09 03:10:36 -08001645 for file in $execute_dlfiles; do
Lev Walkin4da95cf2010-10-16 02:46:32 -07001646 test -f "$file" \
1647 || func_fatal_help "\`$file' is not a file"
1648
1649 dir=
1650 case $file in
1651 *.la)
Lev Walkin4da95cf2010-10-16 02:46:32 -07001652 # Check to see that this really is a libtool archive.
1653 func_lalib_unsafe_p "$file" \
1654 || func_fatal_help "\`$lib' is not a valid libtool archive"
1655
1656 # Read the libtool library.
1657 dlname=
1658 library_names=
1659 func_source "$file"
1660
1661 # Skip this library if it cannot be dlopened.
1662 if test -z "$dlname"; then
1663 # Warn if it was a shared library.
1664 test -n "$library_names" && \
1665 func_warning "\`$file' was not linked with \`-export-dynamic'"
1666 continue
1667 fi
1668
1669 func_dirname "$file" "" "."
1670 dir="$func_dirname_result"
1671
1672 if test -f "$dir/$objdir/$dlname"; then
Lev Walkine7c4b962010-11-09 03:10:36 -08001673 dir="$dir/$objdir"
Lev Walkin4da95cf2010-10-16 02:46:32 -07001674 else
1675 if test ! -f "$dir/$dlname"; then
1676 func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
1677 fi
1678 fi
1679 ;;
1680
1681 *.lo)
1682 # Just add the directory containing the .lo file.
1683 func_dirname "$file" "" "."
1684 dir="$func_dirname_result"
1685 ;;
1686
1687 *)
1688 func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
1689 continue
1690 ;;
1691 esac
1692
1693 # Get the absolute pathname.
1694 absdir=`cd "$dir" && pwd`
1695 test -n "$absdir" && dir="$absdir"
1696
1697 # Now add the directory to shlibpath_var.
1698 if eval "test -z \"\$$shlibpath_var\""; then
1699 eval "$shlibpath_var=\"\$dir\""
1700 else
1701 eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
1702 fi
1703 done
1704
1705 # This variable tells wrapper scripts just to set shlibpath_var
1706 # rather than running their programs.
1707 libtool_execute_magic="$magic"
1708
1709 # Check if any of the arguments is a wrapper script.
1710 args=
1711 for file
1712 do
1713 case $file in
Lev Walkine7c4b962010-11-09 03:10:36 -08001714 -*) ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07001715 *)
1716 # Do a test to see if this is really a libtool program.
1717 if func_ltwrapper_script_p "$file"; then
1718 func_source "$file"
1719 # Transform arg to wrapped name.
1720 file="$progdir/$program"
1721 elif func_ltwrapper_executable_p "$file"; then
1722 func_ltwrapper_scriptname "$file"
1723 func_source "$func_ltwrapper_scriptname_result"
1724 # Transform arg to wrapped name.
1725 file="$progdir/$program"
1726 fi
1727 ;;
1728 esac
1729 # Quote arguments (to preserve shell metacharacters).
Lev Walkine7c4b962010-11-09 03:10:36 -08001730 func_quote_for_eval "$file"
1731 args="$args $func_quote_for_eval_result"
Lev Walkin4da95cf2010-10-16 02:46:32 -07001732 done
1733
1734 if test "X$opt_dry_run" = Xfalse; then
1735 if test -n "$shlibpath_var"; then
1736 # Export the shlibpath_var.
1737 eval "export $shlibpath_var"
1738 fi
1739
1740 # Restore saved environment variables
1741 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
1742 do
1743 eval "if test \"\${save_$lt_var+set}\" = set; then
1744 $lt_var=\$save_$lt_var; export $lt_var
1745 else
1746 $lt_unset $lt_var
1747 fi"
1748 done
1749
1750 # Now prepare to actually exec the command.
1751 exec_cmd="\$cmd$args"
1752 else
1753 # Display what would be done.
1754 if test -n "$shlibpath_var"; then
1755 eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
Lev Walkine7c4b962010-11-09 03:10:36 -08001756 $ECHO "export $shlibpath_var"
Lev Walkin4da95cf2010-10-16 02:46:32 -07001757 fi
1758 $ECHO "$cmd$args"
1759 exit $EXIT_SUCCESS
1760 fi
1761}
1762
Lev Walkine7c4b962010-11-09 03:10:36 -08001763test "$mode" = execute && func_mode_execute ${1+"$@"}
Lev Walkin4da95cf2010-10-16 02:46:32 -07001764
1765
1766# func_mode_finish arg...
1767func_mode_finish ()
1768{
1769 $opt_debug
Lev Walkine7c4b962010-11-09 03:10:36 -08001770 libdirs="$nonopt"
Lev Walkin4da95cf2010-10-16 02:46:32 -07001771 admincmds=
1772
Lev Walkin4da95cf2010-10-16 02:46:32 -07001773 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
Lev Walkine7c4b962010-11-09 03:10:36 -08001774 for dir
1775 do
1776 libdirs="$libdirs $dir"
1777 done
1778
Lev Walkin4da95cf2010-10-16 02:46:32 -07001779 for libdir in $libdirs; do
1780 if test -n "$finish_cmds"; then
1781 # Do each command in the finish commands.
1782 func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
1783'"$cmd"'"'
1784 fi
1785 if test -n "$finish_eval"; then
1786 # Do the single finish_eval.
1787 eval cmds=\"$finish_eval\"
Lev Walkine7c4b962010-11-09 03:10:36 -08001788 $opt_dry_run || eval "$cmds" || admincmds="$admincmds
Lev Walkin4da95cf2010-10-16 02:46:32 -07001789 $cmds"
1790 fi
1791 done
1792 fi
1793
1794 # Exit here if they wanted silent mode.
1795 $opt_silent && exit $EXIT_SUCCESS
1796
Lev Walkine7c4b962010-11-09 03:10:36 -08001797 $ECHO "X----------------------------------------------------------------------" | $Xsed
1798 $ECHO "Libraries have been installed in:"
1799 for libdir in $libdirs; do
1800 $ECHO " $libdir"
1801 done
1802 $ECHO
1803 $ECHO "If you ever happen to want to link against installed libraries"
1804 $ECHO "in a given directory, LIBDIR, you must either use libtool, and"
1805 $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'"
1806 $ECHO "flag during linking and do at least one of the following:"
1807 if test -n "$shlibpath_var"; then
1808 $ECHO " - add LIBDIR to the \`$shlibpath_var' environment variable"
1809 $ECHO " during execution"
Lev Walkin4da95cf2010-10-16 02:46:32 -07001810 fi
Lev Walkine7c4b962010-11-09 03:10:36 -08001811 if test -n "$runpath_var"; then
1812 $ECHO " - add LIBDIR to the \`$runpath_var' environment variable"
1813 $ECHO " during linking"
1814 fi
1815 if test -n "$hardcode_libdir_flag_spec"; then
1816 libdir=LIBDIR
1817 eval flag=\"$hardcode_libdir_flag_spec\"
1818
1819 $ECHO " - use the \`$flag' linker flag"
1820 fi
1821 if test -n "$admincmds"; then
1822 $ECHO " - have your system administrator run these commands:$admincmds"
1823 fi
1824 if test -f /etc/ld.so.conf; then
1825 $ECHO " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
1826 fi
1827 $ECHO
1828
1829 $ECHO "See any operating system documentation about shared libraries for"
1830 case $host in
1831 solaris2.[6789]|solaris2.1[0-9])
1832 $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual"
1833 $ECHO "pages."
1834 ;;
1835 *)
1836 $ECHO "more information, such as the ld(1) and ld.so(8) manual pages."
1837 ;;
1838 esac
1839 $ECHO "X----------------------------------------------------------------------" | $Xsed
Lev Walkin4da95cf2010-10-16 02:46:32 -07001840 exit $EXIT_SUCCESS
1841}
1842
Lev Walkine7c4b962010-11-09 03:10:36 -08001843test "$mode" = finish && func_mode_finish ${1+"$@"}
Lev Walkin4da95cf2010-10-16 02:46:32 -07001844
1845
1846# func_mode_install arg...
1847func_mode_install ()
1848{
1849 $opt_debug
1850 # There may be an optional sh(1) argument at the beginning of
1851 # install_prog (especially on Windows NT).
1852 if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
1853 # Allow the use of GNU shtool's install command.
Lev Walkine7c4b962010-11-09 03:10:36 -08001854 $ECHO "X$nonopt" | $GREP shtool >/dev/null; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07001855 # Aesthetically quote it.
1856 func_quote_for_eval "$nonopt"
1857 install_prog="$func_quote_for_eval_result "
1858 arg=$1
1859 shift
1860 else
1861 install_prog=
1862 arg=$nonopt
1863 fi
1864
1865 # The real first argument should be the name of the installation program.
1866 # Aesthetically quote it.
1867 func_quote_for_eval "$arg"
Lev Walkine7c4b962010-11-09 03:10:36 -08001868 install_prog="$install_prog$func_quote_for_eval_result"
Lev Walkin4da95cf2010-10-16 02:46:32 -07001869
1870 # We need to accept at least all the BSD install flags.
1871 dest=
1872 files=
1873 opts=
1874 prev=
1875 install_type=
1876 isdir=no
1877 stripme=
Lev Walkin4da95cf2010-10-16 02:46:32 -07001878 for arg
1879 do
Lev Walkin4da95cf2010-10-16 02:46:32 -07001880 if test -n "$dest"; then
Lev Walkine7c4b962010-11-09 03:10:36 -08001881 files="$files $dest"
Lev Walkin4da95cf2010-10-16 02:46:32 -07001882 dest=$arg
1883 continue
1884 fi
1885
1886 case $arg in
1887 -d) isdir=yes ;;
1888 -f)
Lev Walkine7c4b962010-11-09 03:10:36 -08001889 case " $install_prog " in
1890 *[\\\ /]cp\ *) ;;
1891 *) prev=$arg ;;
1892 esac
Lev Walkin4da95cf2010-10-16 02:46:32 -07001893 ;;
1894 -g | -m | -o)
1895 prev=$arg
1896 ;;
1897 -s)
1898 stripme=" -s"
1899 continue
1900 ;;
1901 -*)
1902 ;;
1903 *)
1904 # If the previous option needed an argument, then skip it.
1905 if test -n "$prev"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07001906 prev=
1907 else
1908 dest=$arg
1909 continue
1910 fi
1911 ;;
1912 esac
1913
1914 # Aesthetically quote the argument.
1915 func_quote_for_eval "$arg"
Lev Walkine7c4b962010-11-09 03:10:36 -08001916 install_prog="$install_prog $func_quote_for_eval_result"
Lev Walkin4da95cf2010-10-16 02:46:32 -07001917 done
1918
1919 test -z "$install_prog" && \
1920 func_fatal_help "you must specify an install program"
1921
1922 test -n "$prev" && \
1923 func_fatal_help "the \`$prev' option requires an argument"
1924
Lev Walkin4da95cf2010-10-16 02:46:32 -07001925 if test -z "$files"; then
1926 if test -z "$dest"; then
1927 func_fatal_help "no file or destination specified"
1928 else
1929 func_fatal_help "you must specify a destination"
1930 fi
1931 fi
1932
1933 # Strip any trailing slash from the destination.
1934 func_stripname '' '/' "$dest"
1935 dest=$func_stripname_result
1936
1937 # Check to see that the destination is a directory.
1938 test -d "$dest" && isdir=yes
1939 if test "$isdir" = yes; then
1940 destdir="$dest"
1941 destname=
1942 else
1943 func_dirname_and_basename "$dest" "" "."
1944 destdir="$func_dirname_result"
1945 destname="$func_basename_result"
1946
1947 # Not a directory, so check to see that there is only one file specified.
1948 set dummy $files; shift
1949 test "$#" -gt 1 && \
1950 func_fatal_help "\`$dest' is not a directory"
1951 fi
1952 case $destdir in
1953 [\\/]* | [A-Za-z]:[\\/]*) ;;
1954 *)
1955 for file in $files; do
1956 case $file in
1957 *.lo) ;;
1958 *)
1959 func_fatal_help "\`$destdir' must be an absolute directory name"
1960 ;;
1961 esac
1962 done
1963 ;;
1964 esac
1965
1966 # This variable tells wrapper scripts just to set variables rather
1967 # than running their programs.
1968 libtool_install_magic="$magic"
1969
1970 staticlibs=
1971 future_libdirs=
1972 current_libdirs=
1973 for file in $files; do
1974
1975 # Do each installation.
1976 case $file in
1977 *.$libext)
1978 # Do the static libraries later.
Lev Walkine7c4b962010-11-09 03:10:36 -08001979 staticlibs="$staticlibs $file"
Lev Walkin4da95cf2010-10-16 02:46:32 -07001980 ;;
1981
1982 *.la)
Lev Walkin4da95cf2010-10-16 02:46:32 -07001983 # Check to see that this really is a libtool archive.
1984 func_lalib_unsafe_p "$file" \
1985 || func_fatal_help "\`$file' is not a valid libtool archive"
1986
1987 library_names=
1988 old_library=
1989 relink_command=
1990 func_source "$file"
1991
1992 # Add the libdir to current_libdirs if it is the destination.
1993 if test "X$destdir" = "X$libdir"; then
1994 case "$current_libdirs " in
1995 *" $libdir "*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08001996 *) current_libdirs="$current_libdirs $libdir" ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07001997 esac
1998 else
1999 # Note the libdir as a future libdir.
2000 case "$future_libdirs " in
2001 *" $libdir "*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08002002 *) future_libdirs="$future_libdirs $libdir" ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07002003 esac
2004 fi
2005
2006 func_dirname "$file" "/" ""
2007 dir="$func_dirname_result"
Lev Walkine7c4b962010-11-09 03:10:36 -08002008 dir="$dir$objdir"
Lev Walkin4da95cf2010-10-16 02:46:32 -07002009
2010 if test -n "$relink_command"; then
2011 # Determine the prefix the user has applied to our future dir.
Lev Walkine7c4b962010-11-09 03:10:36 -08002012 inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"`
Lev Walkin4da95cf2010-10-16 02:46:32 -07002013
2014 # Don't allow the user to place us outside of our expected
2015 # location b/c this prevents finding dependent libraries that
2016 # are installed to the same prefix.
2017 # At present, this check doesn't affect windows .dll's that
2018 # are installed into $libdir/../bin (currently, that works fine)
2019 # but it's something to keep an eye on.
2020 test "$inst_prefix_dir" = "$destdir" && \
2021 func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2022
2023 if test -n "$inst_prefix_dir"; then
2024 # Stick the inst_prefix_dir data into the link command.
Lev Walkine7c4b962010-11-09 03:10:36 -08002025 relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
Lev Walkin4da95cf2010-10-16 02:46:32 -07002026 else
Lev Walkine7c4b962010-11-09 03:10:36 -08002027 relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"`
Lev Walkin4da95cf2010-10-16 02:46:32 -07002028 fi
2029
2030 func_warning "relinking \`$file'"
2031 func_show_eval "$relink_command" \
2032 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2033 fi
2034
2035 # See the names of the shared library.
2036 set dummy $library_names; shift
2037 if test -n "$1"; then
2038 realname="$1"
2039 shift
2040
2041 srcname="$realname"
2042 test -n "$relink_command" && srcname="$realname"T
2043
2044 # Install the shared library and build the symlinks.
Lev Walkine7c4b962010-11-09 03:10:36 -08002045 func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \
Lev Walkin4da95cf2010-10-16 02:46:32 -07002046 'exit $?'
2047 tstripme="$stripme"
2048 case $host_os in
Lev Walkine7c4b962010-11-09 03:10:36 -08002049 cygwin* | mingw* | pw32*)
Lev Walkin4da95cf2010-10-16 02:46:32 -07002050 case $realname in
2051 *.dll.a)
2052 tstripme=""
2053 ;;
2054 esac
2055 ;;
2056 esac
2057 if test -n "$tstripme" && test -n "$striplib"; then
2058 func_show_eval "$striplib $destdir/$realname" 'exit $?'
2059 fi
2060
2061 if test "$#" -gt 0; then
2062 # Delete the old symlinks, and create new ones.
2063 # Try `ln -sf' first, because the `ln' binary might depend on
2064 # the symlink we replace! Solaris /bin/ln does not understand -f,
2065 # so we also need to try rm && ln -s.
2066 for linkname
2067 do
2068 test "$linkname" != "$realname" \
2069 && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
2070 done
2071 fi
2072
2073 # Do each command in the postinstall commands.
2074 lib="$destdir/$realname"
2075 func_execute_cmds "$postinstall_cmds" 'exit $?'
2076 fi
2077
2078 # Install the pseudo-library for information purposes.
2079 func_basename "$file"
2080 name="$func_basename_result"
2081 instname="$dir/$name"i
2082 func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
2083
2084 # Maybe install the static library, too.
Lev Walkine7c4b962010-11-09 03:10:36 -08002085 test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
Lev Walkin4da95cf2010-10-16 02:46:32 -07002086 ;;
2087
2088 *.lo)
2089 # Install (i.e. copy) a libtool object.
2090
2091 # Figure out destination file name, if it wasn't already specified.
2092 if test -n "$destname"; then
2093 destfile="$destdir/$destname"
2094 else
2095 func_basename "$file"
2096 destfile="$func_basename_result"
2097 destfile="$destdir/$destfile"
2098 fi
2099
2100 # Deduce the name of the destination old-style object file.
2101 case $destfile in
2102 *.lo)
2103 func_lo2o "$destfile"
2104 staticdest=$func_lo2o_result
2105 ;;
2106 *.$objext)
2107 staticdest="$destfile"
2108 destfile=
2109 ;;
2110 *)
2111 func_fatal_help "cannot copy a libtool object to \`$destfile'"
2112 ;;
2113 esac
2114
2115 # Install the libtool object if requested.
2116 test -n "$destfile" && \
2117 func_show_eval "$install_prog $file $destfile" 'exit $?'
2118
2119 # Install the old object if enabled.
2120 if test "$build_old_libs" = yes; then
2121 # Deduce the name of the old-style object file.
2122 func_lo2o "$file"
2123 staticobj=$func_lo2o_result
2124 func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
2125 fi
2126 exit $EXIT_SUCCESS
2127 ;;
2128
2129 *)
2130 # Figure out destination file name, if it wasn't already specified.
2131 if test -n "$destname"; then
2132 destfile="$destdir/$destname"
2133 else
2134 func_basename "$file"
2135 destfile="$func_basename_result"
2136 destfile="$destdir/$destfile"
2137 fi
2138
2139 # If the file is missing, and there is a .exe on the end, strip it
2140 # because it is most likely a libtool script we actually want to
2141 # install
2142 stripped_ext=""
2143 case $file in
2144 *.exe)
2145 if test ! -f "$file"; then
2146 func_stripname '' '.exe' "$file"
2147 file=$func_stripname_result
2148 stripped_ext=".exe"
2149 fi
2150 ;;
2151 esac
2152
2153 # Do a test to see if this is really a libtool program.
2154 case $host in
Lev Walkine7c4b962010-11-09 03:10:36 -08002155 *cygwin*|*mingw*)
Lev Walkin4da95cf2010-10-16 02:46:32 -07002156 if func_ltwrapper_executable_p "$file"; then
2157 func_ltwrapper_scriptname "$file"
2158 wrapper=$func_ltwrapper_scriptname_result
2159 else
2160 func_stripname '' '.exe' "$file"
2161 wrapper=$func_stripname_result
2162 fi
2163 ;;
2164 *)
2165 wrapper=$file
2166 ;;
2167 esac
2168 if func_ltwrapper_script_p "$wrapper"; then
2169 notinst_deplibs=
2170 relink_command=
2171
2172 func_source "$wrapper"
2173
2174 # Check the variables that should have been set.
2175 test -z "$generated_by_libtool_version" && \
2176 func_fatal_error "invalid libtool wrapper script \`$wrapper'"
2177
2178 finalize=yes
2179 for lib in $notinst_deplibs; do
2180 # Check to see that each library is installed.
2181 libdir=
2182 if test -f "$lib"; then
2183 func_source "$lib"
2184 fi
Lev Walkine7c4b962010-11-09 03:10:36 -08002185 libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
Lev Walkin4da95cf2010-10-16 02:46:32 -07002186 if test -n "$libdir" && test ! -f "$libfile"; then
2187 func_warning "\`$lib' has not been installed in \`$libdir'"
2188 finalize=no
2189 fi
2190 done
2191
2192 relink_command=
2193 func_source "$wrapper"
2194
2195 outputname=
2196 if test "$fast_install" = no && test -n "$relink_command"; then
2197 $opt_dry_run || {
2198 if test "$finalize" = yes; then
2199 tmpdir=`func_mktempdir`
2200 func_basename "$file$stripped_ext"
2201 file="$func_basename_result"
2202 outputname="$tmpdir/$file"
2203 # Replace the output file specification.
Lev Walkine7c4b962010-11-09 03:10:36 -08002204 relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
Lev Walkin4da95cf2010-10-16 02:46:32 -07002205
2206 $opt_silent || {
2207 func_quote_for_expand "$relink_command"
2208 eval "func_echo $func_quote_for_expand_result"
2209 }
2210 if eval "$relink_command"; then :
2211 else
2212 func_error "error: relink \`$file' with the above command before installing it"
2213 $opt_dry_run || ${RM}r "$tmpdir"
2214 continue
2215 fi
2216 file="$outputname"
2217 else
2218 func_warning "cannot relink \`$file'"
2219 fi
2220 }
2221 else
2222 # Install the binary that we compiled earlier.
Lev Walkine7c4b962010-11-09 03:10:36 -08002223 file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
Lev Walkin4da95cf2010-10-16 02:46:32 -07002224 fi
2225 fi
2226
2227 # remove .exe since cygwin /usr/bin/install will append another
2228 # one anyway
2229 case $install_prog,$host in
2230 */usr/bin/install*,*cygwin*)
2231 case $file:$destfile in
2232 *.exe:*.exe)
2233 # this is ok
2234 ;;
2235 *.exe:*)
2236 destfile=$destfile.exe
2237 ;;
2238 *:*.exe)
2239 func_stripname '' '.exe' "$destfile"
2240 destfile=$func_stripname_result
2241 ;;
2242 esac
2243 ;;
2244 esac
2245 func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
2246 $opt_dry_run || if test -n "$outputname"; then
2247 ${RM}r "$tmpdir"
2248 fi
2249 ;;
2250 esac
2251 done
2252
2253 for file in $staticlibs; do
2254 func_basename "$file"
2255 name="$func_basename_result"
2256
2257 # Set up the ranlib parameters.
2258 oldlib="$destdir/$name"
2259
2260 func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
2261
2262 if test -n "$stripme" && test -n "$old_striplib"; then
2263 func_show_eval "$old_striplib $oldlib" 'exit $?'
2264 fi
2265
2266 # Do each command in the postinstall commands.
2267 func_execute_cmds "$old_postinstall_cmds" 'exit $?'
2268 done
2269
2270 test -n "$future_libdirs" && \
2271 func_warning "remember to run \`$progname --finish$future_libdirs'"
2272
2273 if test -n "$current_libdirs"; then
2274 # Maybe just do a dry run.
2275 $opt_dry_run && current_libdirs=" -n$current_libdirs"
2276 exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
2277 else
2278 exit $EXIT_SUCCESS
2279 fi
2280}
2281
Lev Walkine7c4b962010-11-09 03:10:36 -08002282test "$mode" = install && func_mode_install ${1+"$@"}
Lev Walkin4da95cf2010-10-16 02:46:32 -07002283
2284
2285# func_generate_dlsyms outputname originator pic_p
2286# Extract symbols from dlprefiles and create ${outputname}S.o with
2287# a dlpreopen symbol table.
2288func_generate_dlsyms ()
2289{
2290 $opt_debug
2291 my_outputname="$1"
2292 my_originator="$2"
2293 my_pic_p="${3-no}"
2294 my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
2295 my_dlsyms=
2296
2297 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
2298 if test -n "$NM" && test -n "$global_symbol_pipe"; then
2299 my_dlsyms="${my_outputname}S.c"
2300 else
2301 func_error "not configured to extract global symbols from dlpreopened files"
2302 fi
2303 fi
2304
2305 if test -n "$my_dlsyms"; then
2306 case $my_dlsyms in
2307 "") ;;
2308 *.c)
2309 # Discover the nlist of each of the dlfiles.
2310 nlist="$output_objdir/${my_outputname}.nm"
2311
2312 func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
2313
2314 # Parse the name list into a source file.
2315 func_verbose "creating $output_objdir/$my_dlsyms"
2316
2317 $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
2318/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
2319/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
2320
2321#ifdef __cplusplus
2322extern \"C\" {
2323#endif
2324
Lev Walkin4da95cf2010-10-16 02:46:32 -07002325/* External symbol declarations for the compiler. */\
2326"
2327
2328 if test "$dlself" = yes; then
2329 func_verbose "generating symbol list for \`$output'"
2330
2331 $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
2332
2333 # Add our own program objects to the symbol list.
Lev Walkine7c4b962010-11-09 03:10:36 -08002334 progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
Lev Walkin4da95cf2010-10-16 02:46:32 -07002335 for progfile in $progfiles; do
Lev Walkine7c4b962010-11-09 03:10:36 -08002336 func_verbose "extracting global C symbols from \`$progfile'"
2337 $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
Lev Walkin4da95cf2010-10-16 02:46:32 -07002338 done
2339
2340 if test -n "$exclude_expsyms"; then
2341 $opt_dry_run || {
2342 eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
2343 eval '$MV "$nlist"T "$nlist"'
2344 }
2345 fi
2346
2347 if test -n "$export_symbols_regex"; then
2348 $opt_dry_run || {
2349 eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
2350 eval '$MV "$nlist"T "$nlist"'
2351 }
2352 fi
2353
2354 # Prepare the list of exported symbols
2355 if test -z "$export_symbols"; then
2356 export_symbols="$output_objdir/$outputname.exp"
2357 $opt_dry_run || {
2358 $RM $export_symbols
2359 eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
2360 case $host in
Lev Walkine7c4b962010-11-09 03:10:36 -08002361 *cygwin* | *mingw* )
Lev Walkin4da95cf2010-10-16 02:46:32 -07002362 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
2363 eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
2364 ;;
2365 esac
2366 }
2367 else
2368 $opt_dry_run || {
2369 eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
2370 eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
2371 eval '$MV "$nlist"T "$nlist"'
2372 case $host in
Lev Walkine7c4b962010-11-09 03:10:36 -08002373 *cygwin | *mingw* )
Lev Walkin4da95cf2010-10-16 02:46:32 -07002374 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
2375 eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
2376 ;;
2377 esac
2378 }
2379 fi
2380 fi
2381
2382 for dlprefile in $dlprefiles; do
2383 func_verbose "extracting global C symbols from \`$dlprefile'"
2384 func_basename "$dlprefile"
2385 name="$func_basename_result"
Lev Walkine7c4b962010-11-09 03:10:36 -08002386 $opt_dry_run || {
2387 eval '$ECHO ": $name " >> "$nlist"'
2388 eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
2389 }
Lev Walkin4da95cf2010-10-16 02:46:32 -07002390 done
2391
2392 $opt_dry_run || {
2393 # Make sure we have at least an empty file.
2394 test -f "$nlist" || : > "$nlist"
2395
2396 if test -n "$exclude_expsyms"; then
2397 $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
2398 $MV "$nlist"T "$nlist"
2399 fi
2400
2401 # Try sorting and uniquifying the output.
2402 if $GREP -v "^: " < "$nlist" |
2403 if sort -k 3 </dev/null >/dev/null 2>&1; then
2404 sort -k 3
2405 else
2406 sort +2
2407 fi |
2408 uniq > "$nlist"S; then
2409 :
2410 else
2411 $GREP -v "^: " < "$nlist" > "$nlist"S
2412 fi
2413
2414 if test -f "$nlist"S; then
2415 eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
2416 else
Lev Walkine7c4b962010-11-09 03:10:36 -08002417 $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms"
Lev Walkin4da95cf2010-10-16 02:46:32 -07002418 fi
2419
Lev Walkine7c4b962010-11-09 03:10:36 -08002420 $ECHO >> "$output_objdir/$my_dlsyms" "\
Lev Walkin4da95cf2010-10-16 02:46:32 -07002421
2422/* The mapping between symbol names and symbols. */
2423typedef struct {
2424 const char *name;
2425 void *address;
2426} lt_dlsymlist;
Lev Walkine7c4b962010-11-09 03:10:36 -08002427"
2428 case $host in
2429 *cygwin* | *mingw* )
2430 $ECHO >> "$output_objdir/$my_dlsyms" "\
2431/* DATA imports from DLLs on WIN32 con't be const, because
2432 runtime relocations are performed -- see ld's documentation
2433 on pseudo-relocs. */"
2434 lt_dlsym_const= ;;
2435 *osf5*)
2436 echo >> "$output_objdir/$my_dlsyms" "\
2437/* This system does not cope well with relocations in const data */"
2438 lt_dlsym_const= ;;
2439 *)
2440 lt_dlsym_const=const ;;
2441 esac
2442
2443 $ECHO >> "$output_objdir/$my_dlsyms" "\
2444extern $lt_dlsym_const lt_dlsymlist
Lev Walkin4da95cf2010-10-16 02:46:32 -07002445lt_${my_prefix}_LTX_preloaded_symbols[];
Lev Walkine7c4b962010-11-09 03:10:36 -08002446$lt_dlsym_const lt_dlsymlist
Lev Walkin4da95cf2010-10-16 02:46:32 -07002447lt_${my_prefix}_LTX_preloaded_symbols[] =
2448{\
2449 { \"$my_originator\", (void *) 0 },"
2450
2451 case $need_lib_prefix in
2452 no)
2453 eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
2454 ;;
2455 *)
2456 eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
2457 ;;
2458 esac
Lev Walkine7c4b962010-11-09 03:10:36 -08002459 $ECHO >> "$output_objdir/$my_dlsyms" "\
Lev Walkin4da95cf2010-10-16 02:46:32 -07002460 {0, (void *) 0}
2461};
2462
2463/* This works around a problem in FreeBSD linker */
2464#ifdef FREEBSD_WORKAROUND
2465static const void *lt_preloaded_setup() {
2466 return lt_${my_prefix}_LTX_preloaded_symbols;
2467}
2468#endif
2469
2470#ifdef __cplusplus
2471}
2472#endif\
2473"
2474 } # !$opt_dry_run
2475
2476 pic_flag_for_symtable=
2477 case "$compile_command " in
2478 *" -static "*) ;;
2479 *)
2480 case $host in
2481 # compiling the symbol table file with pic_flag works around
2482 # a FreeBSD bug that causes programs to crash when -lm is
2483 # linked before any other PIC object. But we must not use
2484 # pic_flag when linking with -static. The problem exists in
2485 # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
2486 *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
2487 pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
2488 *-*-hpux*)
2489 pic_flag_for_symtable=" $pic_flag" ;;
2490 *)
2491 if test "X$my_pic_p" != Xno; then
2492 pic_flag_for_symtable=" $pic_flag"
2493 fi
2494 ;;
2495 esac
2496 ;;
2497 esac
2498 symtab_cflags=
2499 for arg in $LTCFLAGS; do
2500 case $arg in
2501 -pie | -fpie | -fPIE) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08002502 *) symtab_cflags="$symtab_cflags $arg" ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07002503 esac
2504 done
2505
2506 # Now compile the dynamic symbol file.
2507 func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
2508
2509 # Clean up the generated files.
2510 func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
2511
2512 # Transform the symbol file into the correct name.
2513 symfileobj="$output_objdir/${my_outputname}S.$objext"
2514 case $host in
Lev Walkine7c4b962010-11-09 03:10:36 -08002515 *cygwin* | *mingw* )
Lev Walkin4da95cf2010-10-16 02:46:32 -07002516 if test -f "$output_objdir/$my_outputname.def"; then
Lev Walkine7c4b962010-11-09 03:10:36 -08002517 compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
2518 finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
Lev Walkin4da95cf2010-10-16 02:46:32 -07002519 else
Lev Walkine7c4b962010-11-09 03:10:36 -08002520 compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2521 finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
Lev Walkin4da95cf2010-10-16 02:46:32 -07002522 fi
2523 ;;
2524 *)
Lev Walkine7c4b962010-11-09 03:10:36 -08002525 compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2526 finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
Lev Walkin4da95cf2010-10-16 02:46:32 -07002527 ;;
2528 esac
2529 ;;
2530 *)
2531 func_fatal_error "unknown suffix for \`$my_dlsyms'"
2532 ;;
2533 esac
2534 else
2535 # We keep going just in case the user didn't refer to
2536 # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
2537 # really was required.
2538
2539 # Nullify the symbol file.
Lev Walkine7c4b962010-11-09 03:10:36 -08002540 compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
2541 finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
Lev Walkin4da95cf2010-10-16 02:46:32 -07002542 fi
2543}
2544
2545# func_win32_libid arg
2546# return the library type of file 'arg'
2547#
2548# Need a lot of goo to handle *both* DLLs and import libs
2549# Has to be a shell function in order to 'eat' the argument
2550# that is supplied when $file_magic_command is called.
Lev Walkin4da95cf2010-10-16 02:46:32 -07002551func_win32_libid ()
2552{
2553 $opt_debug
2554 win32_libid_type="unknown"
2555 win32_fileres=`file -L $1 2>/dev/null`
2556 case $win32_fileres in
2557 *ar\ archive\ import\ library*) # definitely import
2558 win32_libid_type="x86 archive import"
2559 ;;
2560 *ar\ archive*) # could be an import, or static
Lev Walkin4da95cf2010-10-16 02:46:32 -07002561 if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
Lev Walkine7c4b962010-11-09 03:10:36 -08002562 $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
2563 win32_nmres=`eval $NM -f posix -A $1 |
Lev Walkin4da95cf2010-10-16 02:46:32 -07002564 $SED -n -e '
2565 1,100{
2566 / I /{
2567 s,.*,import,
2568 p
2569 q
2570 }
2571 }'`
2572 case $win32_nmres in
2573 import*) win32_libid_type="x86 archive import";;
2574 *) win32_libid_type="x86 archive static";;
2575 esac
2576 fi
2577 ;;
2578 *DLL*)
2579 win32_libid_type="x86 DLL"
2580 ;;
2581 *executable*) # but shell scripts are "executable" too...
2582 case $win32_fileres in
2583 *MS\ Windows\ PE\ Intel*)
2584 win32_libid_type="x86 DLL"
2585 ;;
2586 esac
2587 ;;
2588 esac
2589 $ECHO "$win32_libid_type"
2590}
2591
Lev Walkin4da95cf2010-10-16 02:46:32 -07002592
2593
2594# func_extract_an_archive dir oldlib
2595func_extract_an_archive ()
2596{
2597 $opt_debug
2598 f_ex_an_ar_dir="$1"; shift
2599 f_ex_an_ar_oldlib="$1"
Lev Walkine7c4b962010-11-09 03:10:36 -08002600 func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?'
Lev Walkin4da95cf2010-10-16 02:46:32 -07002601 if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
2602 :
2603 else
2604 func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
2605 fi
2606}
2607
2608
2609# func_extract_archives gentop oldlib ...
2610func_extract_archives ()
2611{
2612 $opt_debug
2613 my_gentop="$1"; shift
2614 my_oldlibs=${1+"$@"}
2615 my_oldobjs=""
2616 my_xlib=""
2617 my_xabs=""
2618 my_xdir=""
2619
2620 for my_xlib in $my_oldlibs; do
2621 # Extract the objects.
2622 case $my_xlib in
2623 [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
2624 *) my_xabs=`pwd`"/$my_xlib" ;;
2625 esac
2626 func_basename "$my_xlib"
2627 my_xlib="$func_basename_result"
2628 my_xlib_u=$my_xlib
2629 while :; do
2630 case " $extracted_archives " in
2631 *" $my_xlib_u "*)
2632 func_arith $extracted_serial + 1
2633 extracted_serial=$func_arith_result
2634 my_xlib_u=lt$extracted_serial-$my_xlib ;;
2635 *) break ;;
2636 esac
2637 done
2638 extracted_archives="$extracted_archives $my_xlib_u"
2639 my_xdir="$my_gentop/$my_xlib_u"
2640
2641 func_mkdir_p "$my_xdir"
2642
2643 case $host in
2644 *-darwin*)
2645 func_verbose "Extracting $my_xabs"
2646 # Do not bother doing anything if just a dry run
2647 $opt_dry_run || {
2648 darwin_orig_dir=`pwd`
2649 cd $my_xdir || exit $?
2650 darwin_archive=$my_xabs
2651 darwin_curdir=`pwd`
2652 darwin_base_archive=`basename "$darwin_archive"`
2653 darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
2654 if test -n "$darwin_arches"; then
2655 darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
2656 darwin_arch=
2657 func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
2658 for darwin_arch in $darwin_arches ; do
2659 func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
2660 $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
2661 cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
2662 func_extract_an_archive "`pwd`" "${darwin_base_archive}"
2663 cd "$darwin_curdir"
2664 $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
2665 done # $darwin_arches
2666 ## Okay now we've a bunch of thin objects, gotta fatten them up :)
2667 darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
2668 darwin_file=
2669 darwin_files=
2670 for darwin_file in $darwin_filelist; do
Lev Walkine7c4b962010-11-09 03:10:36 -08002671 darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
Lev Walkin4da95cf2010-10-16 02:46:32 -07002672 $LIPO -create -output "$darwin_file" $darwin_files
2673 done # $darwin_filelist
2674 $RM -rf unfat-$$
2675 cd "$darwin_orig_dir"
2676 else
2677 cd $darwin_orig_dir
2678 func_extract_an_archive "$my_xdir" "$my_xabs"
2679 fi # $darwin_arches
2680 } # !$opt_dry_run
2681 ;;
2682 *)
2683 func_extract_an_archive "$my_xdir" "$my_xabs"
2684 ;;
2685 esac
Lev Walkine7c4b962010-11-09 03:10:36 -08002686 my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
Lev Walkin4da95cf2010-10-16 02:46:32 -07002687 done
2688
2689 func_extract_archives_result="$my_oldobjs"
2690}
2691
2692
Lev Walkine7c4b962010-11-09 03:10:36 -08002693
2694# func_emit_wrapper arg
Lev Walkin4da95cf2010-10-16 02:46:32 -07002695#
Lev Walkine7c4b962010-11-09 03:10:36 -08002696# emit a libtool wrapper script on stdout
2697# don't directly open a file because we may want to
Lev Walkin4da95cf2010-10-16 02:46:32 -07002698# incorporate the script contents within a cygwin/mingw
2699# wrapper executable. Must ONLY be called from within
Lev Walkine7c4b962010-11-09 03:10:36 -08002700# func_mode_link because it depends on a number of variable
Lev Walkin4da95cf2010-10-16 02:46:32 -07002701# set therein.
2702#
Lev Walkine7c4b962010-11-09 03:10:36 -08002703# arg is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
Lev Walkin4da95cf2010-10-16 02:46:32 -07002704# variable will take. If 'yes', then the emitted script
2705# will assume that the directory in which it is stored is
Lev Walkine7c4b962010-11-09 03:10:36 -08002706# the '.lib' directory. This is a cygwin/mingw-specific
Lev Walkin4da95cf2010-10-16 02:46:32 -07002707# behavior.
2708func_emit_wrapper ()
2709{
Lev Walkine7c4b962010-11-09 03:10:36 -08002710 func_emit_wrapper_arg1=no
2711 if test -n "$1" ; then
2712 func_emit_wrapper_arg1=$1
2713 fi
Lev Walkin4da95cf2010-10-16 02:46:32 -07002714
2715 $ECHO "\
2716#! $SHELL
2717
2718# $output - temporary wrapper script for $objdir/$outputname
2719# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
2720#
2721# The $output program cannot be directly executed until all the libtool
2722# libraries that it depends on are installed.
2723#
2724# This wrapper script should never be moved out of the build directory.
2725# If it is, it will not operate correctly.
2726
2727# Sed substitution that helps us do robust quoting. It backslashifies
2728# metacharacters that are still active within double-quoted strings.
Lev Walkine7c4b962010-11-09 03:10:36 -08002729Xsed='${SED} -e 1s/^X//'
Lev Walkin4da95cf2010-10-16 02:46:32 -07002730sed_quote_subst='$sed_quote_subst'
2731
2732# Be Bourne compatible
2733if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
2734 emulate sh
2735 NULLCMD=:
2736 # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
2737 # is contrary to our usage. Disable this feature.
2738 alias -g '\${1+\"\$@\"}'='\"\$@\"'
2739 setopt NO_GLOB_SUBST
2740else
2741 case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
2742fi
2743BIN_SH=xpg4; export BIN_SH # for Tru64
2744DUALCASE=1; export DUALCASE # for MKS sh
2745
2746# The HP-UX ksh and POSIX shell print the target directory to stdout
2747# if CDPATH is set.
2748(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
2749
2750relink_command=\"$relink_command\"
2751
2752# This environment variable determines our operation mode.
2753if test \"\$libtool_install_magic\" = \"$magic\"; then
2754 # install mode needs the following variables:
2755 generated_by_libtool_version='$macro_version'
2756 notinst_deplibs='$notinst_deplibs'
2757else
2758 # When we are sourced in execute mode, \$file and \$ECHO are already set.
2759 if test \"\$libtool_execute_magic\" != \"$magic\"; then
Lev Walkine7c4b962010-11-09 03:10:36 -08002760 ECHO=\"$qecho\"
2761 file=\"\$0\"
2762 # Make sure echo works.
2763 if test \"X\$1\" = X--no-reexec; then
2764 # Discard the --no-reexec flag, and continue.
2765 shift
2766 elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then
2767 # Yippee, \$ECHO works!
2768 :
2769 else
2770 # Restart under the correct shell, and then maybe \$ECHO will work.
2771 exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
2772 fi
2773 fi\
Lev Walkin4da95cf2010-10-16 02:46:32 -07002774"
Lev Walkine7c4b962010-11-09 03:10:36 -08002775 $ECHO "\
Lev Walkin4da95cf2010-10-16 02:46:32 -07002776
2777 # Find the directory that this script lives in.
Lev Walkine7c4b962010-11-09 03:10:36 -08002778 thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
Lev Walkin4da95cf2010-10-16 02:46:32 -07002779 test \"x\$thisdir\" = \"x\$file\" && thisdir=.
2780
2781 # Follow symbolic links until we get to the real thisdir.
Lev Walkine7c4b962010-11-09 03:10:36 -08002782 file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
Lev Walkin4da95cf2010-10-16 02:46:32 -07002783 while test -n \"\$file\"; do
Lev Walkine7c4b962010-11-09 03:10:36 -08002784 destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
Lev Walkin4da95cf2010-10-16 02:46:32 -07002785
2786 # If there was a directory component, then change thisdir.
2787 if test \"x\$destdir\" != \"x\$file\"; then
2788 case \"\$destdir\" in
2789 [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
2790 *) thisdir=\"\$thisdir/\$destdir\" ;;
2791 esac
2792 fi
2793
Lev Walkine7c4b962010-11-09 03:10:36 -08002794 file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
2795 file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
Lev Walkin4da95cf2010-10-16 02:46:32 -07002796 done
2797
2798 # Usually 'no', except on cygwin/mingw when embedded into
2799 # the cwrapper.
2800 WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
2801 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
2802 # special case for '.'
2803 if test \"\$thisdir\" = \".\"; then
2804 thisdir=\`pwd\`
2805 fi
2806 # remove .libs from thisdir
2807 case \"\$thisdir\" in
Lev Walkine7c4b962010-11-09 03:10:36 -08002808 *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07002809 $objdir ) thisdir=. ;;
2810 esac
2811 fi
2812
2813 # Try to get the absolute directory name.
2814 absdir=\`cd \"\$thisdir\" && pwd\`
2815 test -n \"\$absdir\" && thisdir=\"\$absdir\"
2816"
2817
2818 if test "$fast_install" = yes; then
2819 $ECHO "\
2820 program=lt-'$outputname'$exeext
2821 progdir=\"\$thisdir/$objdir\"
2822
2823 if test ! -f \"\$progdir/\$program\" ||
2824 { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
2825 test \"X\$file\" != \"X\$progdir/\$program\"; }; then
2826
2827 file=\"\$\$-\$program\"
2828
2829 if test ! -d \"\$progdir\"; then
2830 $MKDIR \"\$progdir\"
2831 else
2832 $RM \"\$progdir/\$file\"
2833 fi"
2834
2835 $ECHO "\
2836
2837 # relink executable if necessary
2838 if test -n \"\$relink_command\"; then
2839 if relink_command_output=\`eval \$relink_command 2>&1\`; then :
2840 else
2841 $ECHO \"\$relink_command_output\" >&2
2842 $RM \"\$progdir/\$file\"
2843 exit 1
2844 fi
2845 fi
2846
2847 $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
2848 { $RM \"\$progdir/\$program\";
2849 $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
2850 $RM \"\$progdir/\$file\"
2851 fi"
2852 else
2853 $ECHO "\
2854 program='$outputname'
2855 progdir=\"\$thisdir/$objdir\"
2856"
2857 fi
2858
2859 $ECHO "\
2860
2861 if test -f \"\$progdir/\$program\"; then"
2862
Lev Walkin4da95cf2010-10-16 02:46:32 -07002863 # Export our shlibpath_var if we have one.
2864 if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
2865 $ECHO "\
2866 # Add our own library path to $shlibpath_var
2867 $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
2868
2869 # Some systems cannot cope with colon-terminated $shlibpath_var
2870 # The second colon is a workaround for a bug in BeOS R4 sed
Lev Walkine7c4b962010-11-09 03:10:36 -08002871 $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
Lev Walkin4da95cf2010-10-16 02:46:32 -07002872
2873 export $shlibpath_var
2874"
2875 fi
2876
Lev Walkine7c4b962010-11-09 03:10:36 -08002877 # fixup the dll searchpath if we need to.
2878 if test -n "$dllsearchpath"; then
2879 $ECHO "\
2880 # Add the dll search path components to the executable PATH
2881 PATH=$dllsearchpath:\$PATH
2882"
2883 fi
2884
Lev Walkin4da95cf2010-10-16 02:46:32 -07002885 $ECHO "\
2886 if test \"\$libtool_execute_magic\" != \"$magic\"; then
2887 # Run the actual program with our arguments.
Lev Walkine7c4b962010-11-09 03:10:36 -08002888"
2889 case $host in
2890 # Backslashes separate directories on plain windows
2891 *-*-mingw | *-*-os2*)
2892 $ECHO "\
2893 exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
2894"
2895 ;;
2896
2897 *)
2898 $ECHO "\
2899 exec \"\$progdir/\$program\" \${1+\"\$@\"}
2900"
2901 ;;
2902 esac
2903 $ECHO "\
2904 \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
2905 exit 1
Lev Walkin4da95cf2010-10-16 02:46:32 -07002906 fi
2907 else
2908 # The program doesn't exist.
2909 \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
2910 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
Lev Walkine7c4b962010-11-09 03:10:36 -08002911 $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
Lev Walkin4da95cf2010-10-16 02:46:32 -07002912 exit 1
2913 fi
2914fi\
2915"
2916}
Lev Walkine7c4b962010-11-09 03:10:36 -08002917# end: func_emit_wrapper
Lev Walkin4da95cf2010-10-16 02:46:32 -07002918
2919# func_emit_cwrapperexe_src
2920# emit the source code for a wrapper executable on stdout
2921# Must ONLY be called from within func_mode_link because
2922# it depends on a number of variable set therein.
2923func_emit_cwrapperexe_src ()
2924{
2925 cat <<EOF
2926
2927/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
2928 Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
2929
2930 The $output program cannot be directly executed until all the libtool
2931 libraries that it depends on are installed.
2932
2933 This wrapper executable should never be moved out of the build directory.
2934 If it is, it will not operate correctly.
Lev Walkine7c4b962010-11-09 03:10:36 -08002935
2936 Currently, it simply execs the wrapper *script* "$SHELL $output",
2937 but could eventually absorb all of the scripts functionality and
2938 exec $objdir/$outputname directly.
Lev Walkin4da95cf2010-10-16 02:46:32 -07002939*/
2940EOF
2941 cat <<"EOF"
Lev Walkin4da95cf2010-10-16 02:46:32 -07002942#include <stdio.h>
2943#include <stdlib.h>
2944#ifdef _MSC_VER
2945# include <direct.h>
2946# include <process.h>
2947# include <io.h>
Lev Walkine7c4b962010-11-09 03:10:36 -08002948# define setmode _setmode
Lev Walkin4da95cf2010-10-16 02:46:32 -07002949#else
2950# include <unistd.h>
2951# include <stdint.h>
2952# ifdef __CYGWIN__
2953# include <io.h>
2954# endif
2955#endif
2956#include <malloc.h>
2957#include <stdarg.h>
2958#include <assert.h>
2959#include <string.h>
2960#include <ctype.h>
2961#include <errno.h>
2962#include <fcntl.h>
2963#include <sys/stat.h>
2964
Lev Walkin4da95cf2010-10-16 02:46:32 -07002965#if defined(PATH_MAX)
2966# define LT_PATHMAX PATH_MAX
2967#elif defined(MAXPATHLEN)
2968# define LT_PATHMAX MAXPATHLEN
2969#else
2970# define LT_PATHMAX 1024
2971#endif
2972
2973#ifndef S_IXOTH
2974# define S_IXOTH 0
2975#endif
2976#ifndef S_IXGRP
2977# define S_IXGRP 0
2978#endif
2979
Lev Walkine7c4b962010-11-09 03:10:36 -08002980#ifdef _MSC_VER
2981# define S_IXUSR _S_IEXEC
2982# define stat _stat
2983# ifndef _INTPTR_T_DEFINED
2984# define intptr_t int
2985# endif
2986#endif
2987
Lev Walkin4da95cf2010-10-16 02:46:32 -07002988#ifndef DIR_SEPARATOR
2989# define DIR_SEPARATOR '/'
2990# define PATH_SEPARATOR ':'
2991#endif
2992
2993#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
2994 defined (__OS2__)
2995# define HAVE_DOS_BASED_FILE_SYSTEM
2996# define FOPEN_WB "wb"
2997# ifndef DIR_SEPARATOR_2
2998# define DIR_SEPARATOR_2 '\\'
2999# endif
3000# ifndef PATH_SEPARATOR_2
3001# define PATH_SEPARATOR_2 ';'
3002# endif
3003#endif
3004
3005#ifndef DIR_SEPARATOR_2
3006# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
3007#else /* DIR_SEPARATOR_2 */
3008# define IS_DIR_SEPARATOR(ch) \
3009 (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
3010#endif /* DIR_SEPARATOR_2 */
3011
3012#ifndef PATH_SEPARATOR_2
3013# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
3014#else /* PATH_SEPARATOR_2 */
3015# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
3016#endif /* PATH_SEPARATOR_2 */
3017
Lev Walkine7c4b962010-11-09 03:10:36 -08003018#ifdef __CYGWIN__
3019# define FOPEN_WB "wb"
3020#endif
3021
Lev Walkin4da95cf2010-10-16 02:46:32 -07003022#ifndef FOPEN_WB
3023# define FOPEN_WB "w"
3024#endif
3025#ifndef _O_BINARY
3026# define _O_BINARY 0
3027#endif
3028
3029#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
3030#define XFREE(stale) do { \
3031 if (stale) { free ((void *) stale); stale = 0; } \
3032} while (0)
3033
Lev Walkine7c4b962010-11-09 03:10:36 -08003034#undef LTWRAPPER_DEBUGPRINTF
3035#if defined DEBUGWRAPPER
3036# define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args
3037static void
3038ltwrapper_debugprintf (const char *fmt, ...)
3039{
3040 va_list args;
3041 va_start (args, fmt);
3042 (void) vfprintf (stderr, fmt, args);
3043 va_end (args);
3044}
Lev Walkin4da95cf2010-10-16 02:46:32 -07003045#else
Lev Walkine7c4b962010-11-09 03:10:36 -08003046# define LTWRAPPER_DEBUGPRINTF(args)
Lev Walkin4da95cf2010-10-16 02:46:32 -07003047#endif
3048
Lev Walkine7c4b962010-11-09 03:10:36 -08003049const char *program_name = NULL;
Lev Walkin4da95cf2010-10-16 02:46:32 -07003050
3051void *xmalloc (size_t num);
3052char *xstrdup (const char *string);
3053const char *base_name (const char *name);
3054char *find_executable (const char *wrapper);
3055char *chase_symlinks (const char *pathspec);
3056int make_executable (const char *path);
3057int check_executable (const char *path);
3058char *strendzap (char *str, const char *pat);
Lev Walkine7c4b962010-11-09 03:10:36 -08003059void lt_fatal (const char *message, ...);
3060
3061static const char *script_text =
Lev Walkin4da95cf2010-10-16 02:46:32 -07003062EOF
3063
Lev Walkine7c4b962010-11-09 03:10:36 -08003064 func_emit_wrapper yes |
3065 $SED -e 's/\([\\"]\)/\\\1/g' \
3066 -e 's/^/ "/' -e 's/$/\\n"/'
3067 echo ";"
3068
Lev Walkin4da95cf2010-10-16 02:46:32 -07003069 cat <<EOF
Lev Walkine7c4b962010-11-09 03:10:36 -08003070const char * MAGIC_EXE = "$magic_exe";
Lev Walkin4da95cf2010-10-16 02:46:32 -07003071
3072int
3073main (int argc, char *argv[])
3074{
3075 char **newargz;
Lev Walkin4da95cf2010-10-16 02:46:32 -07003076 char *tmp_pathspec;
3077 char *actual_cwrapper_path;
Lev Walkine7c4b962010-11-09 03:10:36 -08003078 char *shwrapper_name;
Lev Walkin4da95cf2010-10-16 02:46:32 -07003079 intptr_t rval = 127;
Lev Walkine7c4b962010-11-09 03:10:36 -08003080 FILE *shwrapper;
Lev Walkin4da95cf2010-10-16 02:46:32 -07003081
Lev Walkine7c4b962010-11-09 03:10:36 -08003082 const char *dumpscript_opt = "--lt-dump-script";
Lev Walkin4da95cf2010-10-16 02:46:32 -07003083 int i;
3084
3085 program_name = (char *) xstrdup (base_name (argv[0]));
Lev Walkine7c4b962010-11-09 03:10:36 -08003086 LTWRAPPER_DEBUGPRINTF (("(main) argv[0] : %s\n", argv[0]));
3087 LTWRAPPER_DEBUGPRINTF (("(main) program_name : %s\n", program_name));
Lev Walkin4da95cf2010-10-16 02:46:32 -07003088
Lev Walkine7c4b962010-11-09 03:10:36 -08003089 /* very simple arg parsing; don't want to rely on getopt */
Lev Walkin4da95cf2010-10-16 02:46:32 -07003090 for (i = 1; i < argc; i++)
3091 {
3092 if (strcmp (argv[i], dumpscript_opt) == 0)
3093 {
3094EOF
3095 case "$host" in
3096 *mingw* | *cygwin* )
3097 # make stdout use "unix" line endings
3098 echo " setmode(1,_O_BINARY);"
3099 ;;
3100 esac
3101
Lev Walkine7c4b962010-11-09 03:10:36 -08003102 cat <<EOF
3103 printf ("%s", script_text);
Lev Walkin4da95cf2010-10-16 02:46:32 -07003104 return 0;
3105 }
Lev Walkin4da95cf2010-10-16 02:46:32 -07003106 }
Lev Walkin4da95cf2010-10-16 02:46:32 -07003107
Lev Walkine7c4b962010-11-09 03:10:36 -08003108 newargz = XMALLOC (char *, argc + 2);
Lev Walkin4da95cf2010-10-16 02:46:32 -07003109EOF
Lev Walkine7c4b962010-11-09 03:10:36 -08003110
3111 if test -n "$TARGETSHELL" ; then
3112 # no path translation at all
3113 lt_newargv0=$TARGETSHELL
3114 else
3115 case "$host" in
3116 *mingw* )
3117 # awkward: cmd appends spaces to result
3118 lt_sed_strip_trailing_spaces="s/[ ]*\$//"
3119 lt_newargv0=`( cmd //c echo $SHELL | $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo $SHELL`
3120 case $lt_newargv0 in
3121 *.exe | *.EXE) ;;
3122 *) lt_newargv0=$lt_newargv0.exe ;;
3123 esac
3124 ;;
3125 * ) lt_newargv0=$SHELL ;;
3126 esac
3127 fi
3128
3129 cat <<EOF
3130 newargz[0] = (char *) xstrdup ("$lt_newargv0");
Lev Walkin4da95cf2010-10-16 02:46:32 -07003131EOF
Lev Walkine7c4b962010-11-09 03:10:36 -08003132
Lev Walkin4da95cf2010-10-16 02:46:32 -07003133 cat <<"EOF"
Lev Walkin4da95cf2010-10-16 02:46:32 -07003134 tmp_pathspec = find_executable (argv[0]);
3135 if (tmp_pathspec == NULL)
Lev Walkine7c4b962010-11-09 03:10:36 -08003136 lt_fatal ("Couldn't find %s", argv[0]);
3137 LTWRAPPER_DEBUGPRINTF (("(main) found exe (before symlink chase) at : %s\n",
3138 tmp_pathspec));
Lev Walkin4da95cf2010-10-16 02:46:32 -07003139
3140 actual_cwrapper_path = chase_symlinks (tmp_pathspec);
Lev Walkine7c4b962010-11-09 03:10:36 -08003141 LTWRAPPER_DEBUGPRINTF (("(main) found exe (after symlink chase) at : %s\n",
3142 actual_cwrapper_path));
Lev Walkin4da95cf2010-10-16 02:46:32 -07003143 XFREE (tmp_pathspec);
3144
Lev Walkine7c4b962010-11-09 03:10:36 -08003145 shwrapper_name = (char *) xstrdup (base_name (actual_cwrapper_path));
3146 strendzap (actual_cwrapper_path, shwrapper_name);
Lev Walkin4da95cf2010-10-16 02:46:32 -07003147
Lev Walkine7c4b962010-11-09 03:10:36 -08003148 /* shwrapper_name transforms */
3149 strendzap (shwrapper_name, ".exe");
3150 tmp_pathspec = XMALLOC (char, (strlen (shwrapper_name) +
3151 strlen ("_ltshwrapperTMP") + 1));
3152 strcpy (tmp_pathspec, shwrapper_name);
3153 strcat (tmp_pathspec, "_ltshwrapperTMP");
3154 XFREE (shwrapper_name);
3155 shwrapper_name = tmp_pathspec;
Lev Walkin4da95cf2010-10-16 02:46:32 -07003156 tmp_pathspec = 0;
Lev Walkine7c4b962010-11-09 03:10:36 -08003157 LTWRAPPER_DEBUGPRINTF (("(main) libtool shell wrapper name: %s\n",
3158 shwrapper_name));
Lev Walkin4da95cf2010-10-16 02:46:32 -07003159EOF
3160
3161 cat <<EOF
Lev Walkine7c4b962010-11-09 03:10:36 -08003162 newargz[1] =
Lev Walkin4da95cf2010-10-16 02:46:32 -07003163 XMALLOC (char, (strlen (actual_cwrapper_path) +
Lev Walkine7c4b962010-11-09 03:10:36 -08003164 strlen ("$objdir") + 1 + strlen (shwrapper_name) + 1));
3165 strcpy (newargz[1], actual_cwrapper_path);
3166 strcat (newargz[1], "$objdir");
3167 strcat (newargz[1], "/");
3168 strcat (newargz[1], shwrapper_name);
Lev Walkin4da95cf2010-10-16 02:46:32 -07003169EOF
3170
Lev Walkin4da95cf2010-10-16 02:46:32 -07003171
3172 case $host_os in
3173 mingw*)
3174 cat <<"EOF"
3175 {
3176 char* p;
Lev Walkine7c4b962010-11-09 03:10:36 -08003177 while ((p = strchr (newargz[1], '\\')) != NULL)
Lev Walkin4da95cf2010-10-16 02:46:32 -07003178 {
3179 *p = '/';
3180 }
3181 }
3182EOF
3183 ;;
3184 esac
3185
3186 cat <<"EOF"
Lev Walkine7c4b962010-11-09 03:10:36 -08003187 XFREE (shwrapper_name);
Lev Walkin4da95cf2010-10-16 02:46:32 -07003188 XFREE (actual_cwrapper_path);
Lev Walkin4da95cf2010-10-16 02:46:32 -07003189
Lev Walkine7c4b962010-11-09 03:10:36 -08003190 /* always write in binary mode */
3191 if ((shwrapper = fopen (newargz[1], FOPEN_WB)) == 0)
Lev Walkin4da95cf2010-10-16 02:46:32 -07003192 {
Lev Walkine7c4b962010-11-09 03:10:36 -08003193 lt_fatal ("Could not open %s for writing", newargz[1]);
3194 }
3195 fprintf (shwrapper, "%s", script_text);
3196 fclose (shwrapper);
3197
3198 make_executable (newargz[1]);
3199
3200 for (i = 1; i < argc; i++)
3201 newargz[i + 1] = xstrdup (argv[i]);
3202 newargz[argc + 1] = NULL;
3203
3204 for (i = 0; i < argc + 1; i++)
3205 {
3206 LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d] : %s\n", i, newargz[i]));
Lev Walkin4da95cf2010-10-16 02:46:32 -07003207 }
3208
3209EOF
3210
3211 case $host_os in
3212 mingw*)
Lev Walkine7c4b962010-11-09 03:10:36 -08003213 cat <<EOF
Lev Walkin4da95cf2010-10-16 02:46:32 -07003214 /* execv doesn't actually work on mingw as expected on unix */
Lev Walkine7c4b962010-11-09 03:10:36 -08003215 rval = _spawnv (_P_WAIT, "$lt_newargv0", (const char * const *) newargz);
Lev Walkin4da95cf2010-10-16 02:46:32 -07003216 if (rval == -1)
3217 {
3218 /* failed to start process */
Lev Walkine7c4b962010-11-09 03:10:36 -08003219 LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"$lt_newargv0\": errno = %d\n", errno));
Lev Walkin4da95cf2010-10-16 02:46:32 -07003220 return 127;
3221 }
3222 return rval;
Lev Walkine7c4b962010-11-09 03:10:36 -08003223}
Lev Walkin4da95cf2010-10-16 02:46:32 -07003224EOF
3225 ;;
3226 *)
Lev Walkine7c4b962010-11-09 03:10:36 -08003227 cat <<EOF
3228 execv ("$lt_newargv0", newargz);
Lev Walkin4da95cf2010-10-16 02:46:32 -07003229 return rval; /* =127, but avoids unused variable warning */
Lev Walkine7c4b962010-11-09 03:10:36 -08003230}
Lev Walkin4da95cf2010-10-16 02:46:32 -07003231EOF
3232 ;;
3233 esac
3234
3235 cat <<"EOF"
Lev Walkin4da95cf2010-10-16 02:46:32 -07003236
3237void *
3238xmalloc (size_t num)
3239{
3240 void *p = (void *) malloc (num);
3241 if (!p)
Lev Walkine7c4b962010-11-09 03:10:36 -08003242 lt_fatal ("Memory exhausted");
Lev Walkin4da95cf2010-10-16 02:46:32 -07003243
3244 return p;
3245}
3246
3247char *
3248xstrdup (const char *string)
3249{
3250 return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
3251 string) : NULL;
3252}
3253
3254const char *
3255base_name (const char *name)
3256{
3257 const char *base;
3258
3259#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3260 /* Skip over the disk name in MSDOS pathnames. */
3261 if (isalpha ((unsigned char) name[0]) && name[1] == ':')
3262 name += 2;
3263#endif
3264
3265 for (base = name; *name; name++)
3266 if (IS_DIR_SEPARATOR (*name))
3267 base = name + 1;
3268 return base;
3269}
3270
3271int
3272check_executable (const char *path)
3273{
3274 struct stat st;
3275
Lev Walkine7c4b962010-11-09 03:10:36 -08003276 LTWRAPPER_DEBUGPRINTF (("(check_executable) : %s\n",
3277 path ? (*path ? path : "EMPTY!") : "NULL!"));
Lev Walkin4da95cf2010-10-16 02:46:32 -07003278 if ((!path) || (!*path))
3279 return 0;
3280
3281 if ((stat (path, &st) >= 0)
3282 && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
3283 return 1;
3284 else
3285 return 0;
3286}
3287
3288int
3289make_executable (const char *path)
3290{
3291 int rval = 0;
3292 struct stat st;
3293
Lev Walkine7c4b962010-11-09 03:10:36 -08003294 LTWRAPPER_DEBUGPRINTF (("(make_executable) : %s\n",
3295 path ? (*path ? path : "EMPTY!") : "NULL!"));
Lev Walkin4da95cf2010-10-16 02:46:32 -07003296 if ((!path) || (!*path))
3297 return 0;
3298
3299 if (stat (path, &st) >= 0)
3300 {
3301 rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
3302 }
3303 return rval;
3304}
3305
3306/* Searches for the full path of the wrapper. Returns
3307 newly allocated full path name if found, NULL otherwise
3308 Does not chase symlinks, even on platforms that support them.
3309*/
3310char *
3311find_executable (const char *wrapper)
3312{
3313 int has_slash = 0;
3314 const char *p;
3315 const char *p_next;
3316 /* static buffer for getcwd */
3317 char tmp[LT_PATHMAX + 1];
3318 int tmp_len;
3319 char *concat_name;
3320
Lev Walkine7c4b962010-11-09 03:10:36 -08003321 LTWRAPPER_DEBUGPRINTF (("(find_executable) : %s\n",
3322 wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"));
Lev Walkin4da95cf2010-10-16 02:46:32 -07003323
3324 if ((wrapper == NULL) || (*wrapper == '\0'))
3325 return NULL;
3326
3327 /* Absolute path? */
3328#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3329 if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
3330 {
3331 concat_name = xstrdup (wrapper);
3332 if (check_executable (concat_name))
3333 return concat_name;
3334 XFREE (concat_name);
3335 }
3336 else
3337 {
3338#endif
3339 if (IS_DIR_SEPARATOR (wrapper[0]))
3340 {
3341 concat_name = xstrdup (wrapper);
3342 if (check_executable (concat_name))
3343 return concat_name;
3344 XFREE (concat_name);
3345 }
3346#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3347 }
3348#endif
3349
3350 for (p = wrapper; *p; p++)
3351 if (*p == '/')
3352 {
3353 has_slash = 1;
3354 break;
3355 }
3356 if (!has_slash)
3357 {
3358 /* no slashes; search PATH */
3359 const char *path = getenv ("PATH");
3360 if (path != NULL)
3361 {
3362 for (p = path; *p; p = p_next)
3363 {
3364 const char *q;
3365 size_t p_len;
3366 for (q = p; *q; q++)
3367 if (IS_PATH_SEPARATOR (*q))
3368 break;
3369 p_len = q - p;
3370 p_next = (*q == '\0' ? q : q + 1);
3371 if (p_len == 0)
3372 {
3373 /* empty path: current directory */
3374 if (getcwd (tmp, LT_PATHMAX) == NULL)
Lev Walkine7c4b962010-11-09 03:10:36 -08003375 lt_fatal ("getcwd failed");
Lev Walkin4da95cf2010-10-16 02:46:32 -07003376 tmp_len = strlen (tmp);
3377 concat_name =
3378 XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
3379 memcpy (concat_name, tmp, tmp_len);
3380 concat_name[tmp_len] = '/';
3381 strcpy (concat_name + tmp_len + 1, wrapper);
3382 }
3383 else
3384 {
3385 concat_name =
3386 XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
3387 memcpy (concat_name, p, p_len);
3388 concat_name[p_len] = '/';
3389 strcpy (concat_name + p_len + 1, wrapper);
3390 }
3391 if (check_executable (concat_name))
3392 return concat_name;
3393 XFREE (concat_name);
3394 }
3395 }
3396 /* not found in PATH; assume curdir */
3397 }
3398 /* Relative path | not found in path: prepend cwd */
3399 if (getcwd (tmp, LT_PATHMAX) == NULL)
Lev Walkine7c4b962010-11-09 03:10:36 -08003400 lt_fatal ("getcwd failed");
Lev Walkin4da95cf2010-10-16 02:46:32 -07003401 tmp_len = strlen (tmp);
3402 concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
3403 memcpy (concat_name, tmp, tmp_len);
3404 concat_name[tmp_len] = '/';
3405 strcpy (concat_name + tmp_len + 1, wrapper);
3406
3407 if (check_executable (concat_name))
3408 return concat_name;
3409 XFREE (concat_name);
3410 return NULL;
3411}
3412
3413char *
3414chase_symlinks (const char *pathspec)
3415{
3416#ifndef S_ISLNK
3417 return xstrdup (pathspec);
3418#else
3419 char buf[LT_PATHMAX];
3420 struct stat s;
3421 char *tmp_pathspec = xstrdup (pathspec);
3422 char *p;
3423 int has_symlinks = 0;
3424 while (strlen (tmp_pathspec) && !has_symlinks)
3425 {
Lev Walkine7c4b962010-11-09 03:10:36 -08003426 LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n",
3427 tmp_pathspec));
Lev Walkin4da95cf2010-10-16 02:46:32 -07003428 if (lstat (tmp_pathspec, &s) == 0)
3429 {
3430 if (S_ISLNK (s.st_mode) != 0)
3431 {
3432 has_symlinks = 1;
3433 break;
3434 }
3435
3436 /* search backwards for last DIR_SEPARATOR */
3437 p = tmp_pathspec + strlen (tmp_pathspec) - 1;
3438 while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
3439 p--;
3440 if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
3441 {
3442 /* no more DIR_SEPARATORS left */
3443 break;
3444 }
3445 *p = '\0';
3446 }
3447 else
3448 {
Lev Walkine7c4b962010-11-09 03:10:36 -08003449 char *errstr = strerror (errno);
3450 lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr);
Lev Walkin4da95cf2010-10-16 02:46:32 -07003451 }
3452 }
3453 XFREE (tmp_pathspec);
3454
3455 if (!has_symlinks)
3456 {
3457 return xstrdup (pathspec);
3458 }
3459
3460 tmp_pathspec = realpath (pathspec, buf);
3461 if (tmp_pathspec == 0)
3462 {
Lev Walkine7c4b962010-11-09 03:10:36 -08003463 lt_fatal ("Could not follow symlinks for %s", pathspec);
Lev Walkin4da95cf2010-10-16 02:46:32 -07003464 }
3465 return xstrdup (tmp_pathspec);
3466#endif
3467}
3468
3469char *
3470strendzap (char *str, const char *pat)
3471{
3472 size_t len, patlen;
3473
3474 assert (str != NULL);
3475 assert (pat != NULL);
3476
3477 len = strlen (str);
3478 patlen = strlen (pat);
3479
3480 if (patlen <= len)
3481 {
3482 str += len - patlen;
3483 if (strcmp (str, pat) == 0)
3484 *str = '\0';
3485 }
3486 return str;
3487}
3488
Lev Walkin4da95cf2010-10-16 02:46:32 -07003489static void
Lev Walkine7c4b962010-11-09 03:10:36 -08003490lt_error_core (int exit_status, const char *mode,
Lev Walkin4da95cf2010-10-16 02:46:32 -07003491 const char *message, va_list ap)
3492{
Lev Walkine7c4b962010-11-09 03:10:36 -08003493 fprintf (stderr, "%s: %s: ", program_name, mode);
Lev Walkin4da95cf2010-10-16 02:46:32 -07003494 vfprintf (stderr, message, ap);
3495 fprintf (stderr, ".\n");
3496
3497 if (exit_status >= 0)
3498 exit (exit_status);
3499}
3500
3501void
Lev Walkine7c4b962010-11-09 03:10:36 -08003502lt_fatal (const char *message, ...)
Lev Walkin4da95cf2010-10-16 02:46:32 -07003503{
3504 va_list ap;
3505 va_start (ap, message);
Lev Walkine7c4b962010-11-09 03:10:36 -08003506 lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
Lev Walkin4da95cf2010-10-16 02:46:32 -07003507 va_end (ap);
3508}
Lev Walkin4da95cf2010-10-16 02:46:32 -07003509EOF
3510}
3511# end: func_emit_cwrapperexe_src
3512
Lev Walkin4da95cf2010-10-16 02:46:32 -07003513# func_mode_link arg...
3514func_mode_link ()
3515{
3516 $opt_debug
Lev Walkin8e8b5482004-06-17 23:42:48 +00003517 case $host in
Lev Walkine7c4b962010-11-09 03:10:36 -08003518 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
Lev Walkinf15320b2004-06-03 03:38:44 +00003519 # It is impossible to link a dll without this setting, and
3520 # we shouldn't force the makefile maintainer to figure out
3521 # which system we are compiling for in order to pass an extra
Lev Walkin8e8b5482004-06-17 23:42:48 +00003522 # flag for every libtool invocation.
Lev Walkinf15320b2004-06-03 03:38:44 +00003523 # allow_undefined=no
3524
3525 # FIXME: Unfortunately, there are problems with the above when trying
3526 # to make a dll which has undefined symbols, in which case not
3527 # even a static library is built. For now, we need to specify
3528 # -no-undefined on the libtool link line when we can be certain
3529 # that all symbols are satisfied, otherwise we get a static library.
3530 allow_undefined=yes
Lev Walkinf15320b2004-06-03 03:38:44 +00003531 ;;
3532 *)
3533 allow_undefined=yes
3534 ;;
3535 esac
Lev Walkin4da95cf2010-10-16 02:46:32 -07003536 libtool_args=$nonopt
Lev Walkin8e8b5482004-06-17 23:42:48 +00003537 base_compile="$nonopt $@"
Lev Walkin4da95cf2010-10-16 02:46:32 -07003538 compile_command=$nonopt
3539 finalize_command=$nonopt
Lev Walkinf15320b2004-06-03 03:38:44 +00003540
3541 compile_rpath=
3542 finalize_rpath=
3543 compile_shlibpath=
3544 finalize_shlibpath=
3545 convenience=
3546 old_convenience=
3547 deplibs=
Lev Walkin8e8b5482004-06-17 23:42:48 +00003548 old_deplibs=
3549 compiler_flags=
3550 linker_flags=
3551 dllsearchpath=
3552 lib_search_path=`pwd`
3553 inst_prefix_dir=
Lev Walkin4da95cf2010-10-16 02:46:32 -07003554 new_inherited_linker_flags=
Lev Walkinf15320b2004-06-03 03:38:44 +00003555
Lev Walkinf15320b2004-06-03 03:38:44 +00003556 avoid_version=no
3557 dlfiles=
3558 dlprefiles=
3559 dlself=no
3560 export_dynamic=no
3561 export_symbols=
3562 export_symbols_regex=
3563 generated=
3564 libobjs=
Lev Walkinf15320b2004-06-03 03:38:44 +00003565 ltlibs=
3566 module=no
Lev Walkin8e8b5482004-06-17 23:42:48 +00003567 no_install=no
Lev Walkinf15320b2004-06-03 03:38:44 +00003568 objs=
Lev Walkin8e8b5482004-06-17 23:42:48 +00003569 non_pic_objects=
3570 precious_files_regex=
Lev Walkinf15320b2004-06-03 03:38:44 +00003571 prefer_static_libs=no
3572 preload=no
3573 prev=
3574 prevarg=
3575 release=
3576 rpath=
3577 xrpath=
3578 perm_rpath=
3579 temp_rpath=
3580 thread_safe=no
3581 vinfo=
Lev Walkin8e8b5482004-06-17 23:42:48 +00003582 vinfo_number=no
Lev Walkin4da95cf2010-10-16 02:46:32 -07003583 weak_libs=
3584 single_module="${wl}-single_module"
Lev Walkin8e8b5482004-06-17 23:42:48 +00003585 func_infer_tag $base_compile
Lev Walkinf15320b2004-06-03 03:38:44 +00003586
3587 # We need to know -static, to get the right output filenames.
3588 for arg
3589 do
Lev Walkin8e8b5482004-06-17 23:42:48 +00003590 case $arg in
Lev Walkin4da95cf2010-10-16 02:46:32 -07003591 -shared)
3592 test "$build_libtool_libs" != yes && \
3593 func_fatal_configuration "can not build a shared library"
3594 build_old_libs=no
3595 break
3596 ;;
3597 -all-static | -static | -static-libtool-libs)
3598 case $arg in
3599 -all-static)
Lev Walkinf15320b2004-06-03 03:38:44 +00003600 if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07003601 func_warning "complete static linking is impossible in this configuration"
Lev Walkinf15320b2004-06-03 03:38:44 +00003602 fi
3603 if test -n "$link_static_flag"; then
3604 dlopen_self=$dlopen_self_static
3605 fi
Lev Walkin4da95cf2010-10-16 02:46:32 -07003606 prefer_static_libs=yes
3607 ;;
3608 -static)
Lev Walkinf15320b2004-06-03 03:38:44 +00003609 if test -z "$pic_flag" && test -n "$link_static_flag"; then
3610 dlopen_self=$dlopen_self_static
3611 fi
Lev Walkin4da95cf2010-10-16 02:46:32 -07003612 prefer_static_libs=built
3613 ;;
3614 -static-libtool-libs)
3615 if test -z "$pic_flag" && test -n "$link_static_flag"; then
3616 dlopen_self=$dlopen_self_static
3617 fi
3618 prefer_static_libs=yes
3619 ;;
3620 esac
Lev Walkinf15320b2004-06-03 03:38:44 +00003621 build_libtool_libs=no
3622 build_old_libs=yes
Lev Walkinf15320b2004-06-03 03:38:44 +00003623 break
3624 ;;
3625 esac
3626 done
3627
3628 # See if our shared archives depend on static archives.
3629 test -n "$old_archive_from_new_cmds" && build_old_libs=yes
3630
3631 # Go through the arguments, transforming them on the way.
Lev Walkin8e8b5482004-06-17 23:42:48 +00003632 while test "$#" -gt 0; do
Lev Walkinf15320b2004-06-03 03:38:44 +00003633 arg="$1"
3634 shift
Lev Walkin4da95cf2010-10-16 02:46:32 -07003635 func_quote_for_eval "$arg"
3636 qarg=$func_quote_for_eval_unquoted_result
3637 func_append libtool_args " $func_quote_for_eval_result"
Lev Walkinf15320b2004-06-03 03:38:44 +00003638
3639 # If the previous option needs an argument, assign it.
3640 if test -n "$prev"; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00003641 case $prev in
Lev Walkinf15320b2004-06-03 03:38:44 +00003642 output)
Lev Walkin4da95cf2010-10-16 02:46:32 -07003643 func_append compile_command " @OUTPUT@"
3644 func_append finalize_command " @OUTPUT@"
Lev Walkinf15320b2004-06-03 03:38:44 +00003645 ;;
3646 esac
3647
Lev Walkin8e8b5482004-06-17 23:42:48 +00003648 case $prev in
Lev Walkinf15320b2004-06-03 03:38:44 +00003649 dlfiles|dlprefiles)
3650 if test "$preload" = no; then
3651 # Add the symbol object into the linking commands.
Lev Walkin4da95cf2010-10-16 02:46:32 -07003652 func_append compile_command " @SYMFILE@"
3653 func_append finalize_command " @SYMFILE@"
Lev Walkinf15320b2004-06-03 03:38:44 +00003654 preload=yes
3655 fi
Lev Walkin8e8b5482004-06-17 23:42:48 +00003656 case $arg in
Lev Walkinf15320b2004-06-03 03:38:44 +00003657 *.la | *.lo) ;; # We handle these cases below.
3658 force)
3659 if test "$dlself" = no; then
3660 dlself=needless
3661 export_dynamic=yes
3662 fi
3663 prev=
3664 continue
3665 ;;
3666 self)
3667 if test "$prev" = dlprefiles; then
3668 dlself=yes
3669 elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
3670 dlself=yes
3671 else
3672 dlself=needless
3673 export_dynamic=yes
3674 fi
3675 prev=
3676 continue
3677 ;;
3678 *)
3679 if test "$prev" = dlfiles; then
Lev Walkine7c4b962010-11-09 03:10:36 -08003680 dlfiles="$dlfiles $arg"
Lev Walkinf15320b2004-06-03 03:38:44 +00003681 else
Lev Walkine7c4b962010-11-09 03:10:36 -08003682 dlprefiles="$dlprefiles $arg"
Lev Walkinf15320b2004-06-03 03:38:44 +00003683 fi
3684 prev=
Lev Walkin8e8b5482004-06-17 23:42:48 +00003685 continue
Lev Walkinf15320b2004-06-03 03:38:44 +00003686 ;;
3687 esac
3688 ;;
3689 expsyms)
3690 export_symbols="$arg"
Lev Walkin4da95cf2010-10-16 02:46:32 -07003691 test -f "$arg" \
3692 || func_fatal_error "symbol file \`$arg' does not exist"
Lev Walkinf15320b2004-06-03 03:38:44 +00003693 prev=
3694 continue
3695 ;;
3696 expsyms_regex)
3697 export_symbols_regex="$arg"
3698 prev=
3699 continue
3700 ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07003701 framework)
3702 case $host in
3703 *-*-darwin*)
3704 case "$deplibs " in
3705 *" $qarg.ltframework "*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08003706 *) deplibs="$deplibs $qarg.ltframework" # this is fixed later
Lev Walkin4da95cf2010-10-16 02:46:32 -07003707 ;;
3708 esac
3709 ;;
3710 esac
3711 prev=
3712 continue
3713 ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00003714 inst_prefix)
3715 inst_prefix_dir="$arg"
3716 prev=
3717 continue
3718 ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07003719 objectlist)
3720 if test -f "$arg"; then
3721 save_arg=$arg
3722 moreargs=
3723 for fil in `cat "$save_arg"`
3724 do
Lev Walkine7c4b962010-11-09 03:10:36 -08003725# moreargs="$moreargs $fil"
Lev Walkin4da95cf2010-10-16 02:46:32 -07003726 arg=$fil
3727 # A libtool-controlled object.
3728
3729 # Check to see that this really is a libtool object.
3730 if func_lalib_unsafe_p "$arg"; then
3731 pic_object=
3732 non_pic_object=
3733
3734 # Read the .lo file
3735 func_source "$arg"
3736
3737 if test -z "$pic_object" ||
3738 test -z "$non_pic_object" ||
3739 test "$pic_object" = none &&
3740 test "$non_pic_object" = none; then
3741 func_fatal_error "cannot find name of object for \`$arg'"
3742 fi
3743
3744 # Extract subdirectory from the argument.
3745 func_dirname "$arg" "/" ""
3746 xdir="$func_dirname_result"
3747
3748 if test "$pic_object" != none; then
3749 # Prepend the subdirectory the object is found in.
3750 pic_object="$xdir$pic_object"
3751
3752 if test "$prev" = dlfiles; then
3753 if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
Lev Walkine7c4b962010-11-09 03:10:36 -08003754 dlfiles="$dlfiles $pic_object"
Lev Walkin4da95cf2010-10-16 02:46:32 -07003755 prev=
3756 continue
3757 else
3758 # If libtool objects are unsupported, then we need to preload.
3759 prev=dlprefiles
3760 fi
3761 fi
3762
3763 # CHECK ME: I think I busted this. -Ossama
3764 if test "$prev" = dlprefiles; then
3765 # Preload the old-style object.
Lev Walkine7c4b962010-11-09 03:10:36 -08003766 dlprefiles="$dlprefiles $pic_object"
Lev Walkin4da95cf2010-10-16 02:46:32 -07003767 prev=
3768 fi
3769
3770 # A PIC object.
3771 func_append libobjs " $pic_object"
3772 arg="$pic_object"
3773 fi
3774
3775 # Non-PIC object.
3776 if test "$non_pic_object" != none; then
3777 # Prepend the subdirectory the object is found in.
3778 non_pic_object="$xdir$non_pic_object"
3779
3780 # A standard non-PIC object
3781 func_append non_pic_objects " $non_pic_object"
3782 if test -z "$pic_object" || test "$pic_object" = none ; then
3783 arg="$non_pic_object"
3784 fi
3785 else
3786 # If the PIC object exists, use it instead.
3787 # $xdir was prepended to $pic_object above.
3788 non_pic_object="$pic_object"
3789 func_append non_pic_objects " $non_pic_object"
3790 fi
3791 else
3792 # Only an error if not doing a dry-run.
3793 if $opt_dry_run; then
3794 # Extract subdirectory from the argument.
3795 func_dirname "$arg" "/" ""
3796 xdir="$func_dirname_result"
3797
3798 func_lo2o "$arg"
3799 pic_object=$xdir$objdir/$func_lo2o_result
3800 non_pic_object=$xdir$func_lo2o_result
3801 func_append libobjs " $pic_object"
3802 func_append non_pic_objects " $non_pic_object"
3803 else
3804 func_fatal_error "\`$arg' is not a valid libtool object"
3805 fi
3806 fi
3807 done
3808 else
3809 func_fatal_error "link input file \`$arg' does not exist"
3810 fi
3811 arg=$save_arg
3812 prev=
3813 continue
3814 ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00003815 precious_regex)
3816 precious_files_regex="$arg"
3817 prev=
3818 continue
3819 ;;
Lev Walkinf15320b2004-06-03 03:38:44 +00003820 release)
Lev Walkin8e8b5482004-06-17 23:42:48 +00003821 release="-$arg"
3822 prev=
3823 continue
3824 ;;
Lev Walkinf15320b2004-06-03 03:38:44 +00003825 rpath | xrpath)
3826 # We need an absolute path.
Lev Walkin8e8b5482004-06-17 23:42:48 +00003827 case $arg in
Lev Walkinf15320b2004-06-03 03:38:44 +00003828 [\\/]* | [A-Za-z]:[\\/]*) ;;
3829 *)
Lev Walkin4da95cf2010-10-16 02:46:32 -07003830 func_fatal_error "only absolute run-paths are allowed"
Lev Walkinf15320b2004-06-03 03:38:44 +00003831 ;;
3832 esac
3833 if test "$prev" = rpath; then
3834 case "$rpath " in
3835 *" $arg "*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08003836 *) rpath="$rpath $arg" ;;
Lev Walkinf15320b2004-06-03 03:38:44 +00003837 esac
3838 else
3839 case "$xrpath " in
3840 *" $arg "*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08003841 *) xrpath="$xrpath $arg" ;;
Lev Walkinf15320b2004-06-03 03:38:44 +00003842 esac
3843 fi
3844 prev=
3845 continue
3846 ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07003847 shrext)
3848 shrext_cmds="$arg"
Lev Walkin8e8b5482004-06-17 23:42:48 +00003849 prev=
Lev Walkin8e8b5482004-06-17 23:42:48 +00003850 continue
3851 ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07003852 weak)
Lev Walkine7c4b962010-11-09 03:10:36 -08003853 weak_libs="$weak_libs $arg"
Lev Walkin8e8b5482004-06-17 23:42:48 +00003854 prev=
Lev Walkin8e8b5482004-06-17 23:42:48 +00003855 continue
3856 ;;
3857 xcclinker)
Lev Walkine7c4b962010-11-09 03:10:36 -08003858 linker_flags="$linker_flags $qarg"
3859 compiler_flags="$compiler_flags $qarg"
Lev Walkin8e8b5482004-06-17 23:42:48 +00003860 prev=
Lev Walkin4da95cf2010-10-16 02:46:32 -07003861 func_append compile_command " $qarg"
3862 func_append finalize_command " $qarg"
Lev Walkin8e8b5482004-06-17 23:42:48 +00003863 continue
3864 ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07003865 xcompiler)
Lev Walkine7c4b962010-11-09 03:10:36 -08003866 compiler_flags="$compiler_flags $qarg"
Lev Walkin8e8b5482004-06-17 23:42:48 +00003867 prev=
Lev Walkin4da95cf2010-10-16 02:46:32 -07003868 func_append compile_command " $qarg"
3869 func_append finalize_command " $qarg"
3870 continue
3871 ;;
3872 xlinker)
Lev Walkine7c4b962010-11-09 03:10:36 -08003873 linker_flags="$linker_flags $qarg"
3874 compiler_flags="$compiler_flags $wl$qarg"
Lev Walkin4da95cf2010-10-16 02:46:32 -07003875 prev=
3876 func_append compile_command " $wl$qarg"
3877 func_append finalize_command " $wl$qarg"
Lev Walkin8e8b5482004-06-17 23:42:48 +00003878 continue
3879 ;;
Lev Walkinf15320b2004-06-03 03:38:44 +00003880 *)
3881 eval "$prev=\"\$arg\""
3882 prev=
3883 continue
3884 ;;
3885 esac
Lev Walkin8e8b5482004-06-17 23:42:48 +00003886 fi # test -n "$prev"
Lev Walkinf15320b2004-06-03 03:38:44 +00003887
3888 prevarg="$arg"
3889
Lev Walkin8e8b5482004-06-17 23:42:48 +00003890 case $arg in
Lev Walkinf15320b2004-06-03 03:38:44 +00003891 -all-static)
3892 if test -n "$link_static_flag"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07003893 # See comment for -static flag below, for more details.
3894 func_append compile_command " $link_static_flag"
3895 func_append finalize_command " $link_static_flag"
Lev Walkinf15320b2004-06-03 03:38:44 +00003896 fi
3897 continue
3898 ;;
3899
3900 -allow-undefined)
3901 # FIXME: remove this flag sometime in the future.
Lev Walkin4da95cf2010-10-16 02:46:32 -07003902 func_fatal_error "\`-allow-undefined' must not be used because it is the default"
Lev Walkinf15320b2004-06-03 03:38:44 +00003903 ;;
3904
3905 -avoid-version)
Lev Walkinf15320b2004-06-03 03:38:44 +00003906 avoid_version=yes
3907 continue
3908 ;;
3909
3910 -dlopen)
3911 prev=dlfiles
3912 continue
3913 ;;
3914
3915 -dlpreopen)
3916 prev=dlprefiles
3917 continue
3918 ;;
3919
3920 -export-dynamic)
3921 export_dynamic=yes
3922 continue
3923 ;;
3924
3925 -export-symbols | -export-symbols-regex)
3926 if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07003927 func_fatal_error "more than one -exported-symbols argument is not allowed"
Lev Walkinf15320b2004-06-03 03:38:44 +00003928 fi
3929 if test "X$arg" = "X-export-symbols"; then
3930 prev=expsyms
3931 else
3932 prev=expsyms_regex
3933 fi
3934 continue
3935 ;;
3936
Lev Walkin4da95cf2010-10-16 02:46:32 -07003937 -framework)
3938 prev=framework
3939 continue
3940 ;;
3941
Lev Walkin8e8b5482004-06-17 23:42:48 +00003942 -inst-prefix-dir)
3943 prev=inst_prefix
3944 continue
3945 ;;
3946
3947 # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
3948 # so, if we see these flags be careful not to treat them like -L
3949 -L[A-Z][A-Z]*:*)
3950 case $with_gcc/$host in
3951 no/*-*-irix* | /*-*-irix*)
Lev Walkin4da95cf2010-10-16 02:46:32 -07003952 func_append compile_command " $arg"
3953 func_append finalize_command " $arg"
Lev Walkin8e8b5482004-06-17 23:42:48 +00003954 ;;
3955 esac
3956 continue
3957 ;;
3958
Lev Walkinf15320b2004-06-03 03:38:44 +00003959 -L*)
Lev Walkine7c4b962010-11-09 03:10:36 -08003960 func_stripname '-L' '' "$arg"
3961 dir=$func_stripname_result
Lev Walkinf15320b2004-06-03 03:38:44 +00003962 # We need an absolute path.
Lev Walkin8e8b5482004-06-17 23:42:48 +00003963 case $dir in
Lev Walkinf15320b2004-06-03 03:38:44 +00003964 [\\/]* | [A-Za-z]:[\\/]*) ;;
3965 *)
3966 absdir=`cd "$dir" && pwd`
Lev Walkin4da95cf2010-10-16 02:46:32 -07003967 test -z "$absdir" && \
3968 func_fatal_error "cannot determine absolute directory name of \`$dir'"
Lev Walkinf15320b2004-06-03 03:38:44 +00003969 dir="$absdir"
3970 ;;
3971 esac
Lev Walkin8e8b5482004-06-17 23:42:48 +00003972 case "$deplibs " in
Lev Walkine7c4b962010-11-09 03:10:36 -08003973 *" -L$dir "*) ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00003974 *)
Lev Walkine7c4b962010-11-09 03:10:36 -08003975 deplibs="$deplibs -L$dir"
3976 lib_search_path="$lib_search_path $dir"
Lev Walkin8e8b5482004-06-17 23:42:48 +00003977 ;;
Lev Walkinf15320b2004-06-03 03:38:44 +00003978 esac
Lev Walkin8e8b5482004-06-17 23:42:48 +00003979 case $host in
Lev Walkine7c4b962010-11-09 03:10:36 -08003980 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
3981 testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'`
Lev Walkin8e8b5482004-06-17 23:42:48 +00003982 case :$dllsearchpath: in
3983 *":$dir:"*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08003984 *) dllsearchpath="$dllsearchpath:$dir";;
Lev Walkin4da95cf2010-10-16 02:46:32 -07003985 esac
3986 case :$dllsearchpath: in
3987 *":$testbindir:"*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08003988 *) dllsearchpath="$dllsearchpath:$testbindir";;
Lev Walkinf15320b2004-06-03 03:38:44 +00003989 esac
3990 ;;
3991 esac
Lev Walkin8e8b5482004-06-17 23:42:48 +00003992 continue
Lev Walkinf15320b2004-06-03 03:38:44 +00003993 ;;
3994
3995 -l*)
Lev Walkin8e8b5482004-06-17 23:42:48 +00003996 if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
3997 case $host in
Lev Walkine7c4b962010-11-09 03:10:36 -08003998 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
Lev Walkin8e8b5482004-06-17 23:42:48 +00003999 # These systems don't actually have a C or math library (as such)
Lev Walkinf15320b2004-06-03 03:38:44 +00004000 continue
4001 ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07004002 *-*-os2*)
Lev Walkin8e8b5482004-06-17 23:42:48 +00004003 # These systems don't actually have a C library (as such)
4004 test "X$arg" = "X-lc" && continue
Lev Walkinf15320b2004-06-03 03:38:44 +00004005 ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07004006 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
Lev Walkin8e8b5482004-06-17 23:42:48 +00004007 # Do not include libc due to us having libc/libc_r.
4008 test "X$arg" = "X-lc" && continue
4009 ;;
4010 *-*-rhapsody* | *-*-darwin1.[012])
4011 # Rhapsody C and math libraries are in the System framework
Lev Walkine7c4b962010-11-09 03:10:36 -08004012 deplibs="$deplibs System.ltframework"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004013 continue
Lev Walkin4da95cf2010-10-16 02:46:32 -07004014 ;;
4015 *-*-sco3.2v5* | *-*-sco5v6*)
4016 # Causes problems with __ctype
4017 test "X$arg" = "X-lc" && continue
4018 ;;
4019 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
4020 # Compiler inserts libc in the correct place for threads to work
4021 test "X$arg" = "X-lc" && continue
4022 ;;
Lev Walkinf15320b2004-06-03 03:38:44 +00004023 esac
Lev Walkin8e8b5482004-06-17 23:42:48 +00004024 elif test "X$arg" = "X-lc_r"; then
4025 case $host in
Lev Walkin4da95cf2010-10-16 02:46:32 -07004026 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
Lev Walkin8e8b5482004-06-17 23:42:48 +00004027 # Do not include libc_r directly, use -pthread flag.
4028 continue
4029 ;;
4030 esac
Lev Walkinf15320b2004-06-03 03:38:44 +00004031 fi
Lev Walkine7c4b962010-11-09 03:10:36 -08004032 deplibs="$deplibs $arg"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004033 continue
Lev Walkinf15320b2004-06-03 03:38:44 +00004034 ;;
4035
4036 -module)
4037 module=yes
4038 continue
4039 ;;
4040
Lev Walkin4da95cf2010-10-16 02:46:32 -07004041 # Tru64 UNIX uses -model [arg] to determine the layout of C++
4042 # classes, name mangling, and exception handling.
4043 # Darwin uses the -arch flag to determine output architecture.
Lev Walkine7c4b962010-11-09 03:10:36 -08004044 -model|-arch|-isysroot)
4045 compiler_flags="$compiler_flags $arg"
Lev Walkin4da95cf2010-10-16 02:46:32 -07004046 func_append compile_command " $arg"
4047 func_append finalize_command " $arg"
4048 prev=xcompiler
4049 continue
4050 ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00004051
Lev Walkin4da95cf2010-10-16 02:46:32 -07004052 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
Lev Walkine7c4b962010-11-09 03:10:36 -08004053 compiler_flags="$compiler_flags $arg"
Lev Walkin4da95cf2010-10-16 02:46:32 -07004054 func_append compile_command " $arg"
4055 func_append finalize_command " $arg"
4056 case "$new_inherited_linker_flags " in
4057 *" $arg "*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08004058 * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07004059 esac
4060 continue
4061 ;;
4062
4063 -multi_module)
4064 single_module="${wl}-multi_module"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004065 continue
4066 ;;
4067
4068 -no-fast-install)
4069 fast_install=no
4070 continue
4071 ;;
4072
4073 -no-install)
4074 case $host in
Lev Walkine7c4b962010-11-09 03:10:36 -08004075 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin*)
Lev Walkin8e8b5482004-06-17 23:42:48 +00004076 # The PATH hackery in wrapper scripts is required on Windows
Lev Walkin4da95cf2010-10-16 02:46:32 -07004077 # and Darwin in order for the loader to find any dlls it needs.
4078 func_warning "\`-no-install' is ignored for $host"
4079 func_warning "assuming \`-no-fast-install' instead"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004080 fast_install=no
4081 ;;
4082 *) no_install=yes ;;
4083 esac
4084 continue
4085 ;;
4086
Lev Walkinf15320b2004-06-03 03:38:44 +00004087 -no-undefined)
4088 allow_undefined=no
4089 continue
4090 ;;
4091
Lev Walkin8e8b5482004-06-17 23:42:48 +00004092 -objectlist)
4093 prev=objectlist
4094 continue
4095 ;;
4096
Lev Walkinf15320b2004-06-03 03:38:44 +00004097 -o) prev=output ;;
4098
Lev Walkin8e8b5482004-06-17 23:42:48 +00004099 -precious-files-regex)
4100 prev=precious_regex
4101 continue
4102 ;;
4103
Lev Walkinf15320b2004-06-03 03:38:44 +00004104 -release)
4105 prev=release
4106 continue
4107 ;;
4108
4109 -rpath)
4110 prev=rpath
4111 continue
4112 ;;
4113
4114 -R)
4115 prev=xrpath
4116 continue
4117 ;;
4118
4119 -R*)
Lev Walkin4da95cf2010-10-16 02:46:32 -07004120 func_stripname '-R' '' "$arg"
4121 dir=$func_stripname_result
Lev Walkinf15320b2004-06-03 03:38:44 +00004122 # We need an absolute path.
Lev Walkin8e8b5482004-06-17 23:42:48 +00004123 case $dir in
Lev Walkinf15320b2004-06-03 03:38:44 +00004124 [\\/]* | [A-Za-z]:[\\/]*) ;;
4125 *)
Lev Walkin4da95cf2010-10-16 02:46:32 -07004126 func_fatal_error "only absolute run-paths are allowed"
Lev Walkinf15320b2004-06-03 03:38:44 +00004127 ;;
4128 esac
4129 case "$xrpath " in
4130 *" $dir "*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08004131 *) xrpath="$xrpath $dir" ;;
Lev Walkinf15320b2004-06-03 03:38:44 +00004132 esac
4133 continue
4134 ;;
4135
Lev Walkin4da95cf2010-10-16 02:46:32 -07004136 -shared)
4137 # The effects of -shared are defined in a previous loop.
4138 continue
4139 ;;
4140
4141 -shrext)
4142 prev=shrext
4143 continue
4144 ;;
4145
4146 -static | -static-libtool-libs)
Lev Walkin8e8b5482004-06-17 23:42:48 +00004147 # The effects of -static are defined in a previous loop.
4148 # We used to do the same as -all-static on platforms that
4149 # didn't have a PIC flag, but the assumption that the effects
4150 # would be equivalent was wrong. It would break on at least
4151 # Digital Unix and AIX.
Lev Walkinf15320b2004-06-03 03:38:44 +00004152 continue
4153 ;;
4154
4155 -thread-safe)
4156 thread_safe=yes
4157 continue
4158 ;;
4159
4160 -version-info)
4161 prev=vinfo
4162 continue
4163 ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07004164
Lev Walkin8e8b5482004-06-17 23:42:48 +00004165 -version-number)
4166 prev=vinfo
4167 vinfo_number=yes
4168 continue
4169 ;;
4170
Lev Walkin4da95cf2010-10-16 02:46:32 -07004171 -weak)
4172 prev=weak
4173 continue
4174 ;;
4175
Lev Walkin8e8b5482004-06-17 23:42:48 +00004176 -Wc,*)
Lev Walkin4da95cf2010-10-16 02:46:32 -07004177 func_stripname '-Wc,' '' "$arg"
4178 args=$func_stripname_result
Lev Walkin8e8b5482004-06-17 23:42:48 +00004179 arg=
4180 save_ifs="$IFS"; IFS=','
4181 for flag in $args; do
4182 IFS="$save_ifs"
Lev Walkin4da95cf2010-10-16 02:46:32 -07004183 func_quote_for_eval "$flag"
Lev Walkine7c4b962010-11-09 03:10:36 -08004184 arg="$arg $wl$func_quote_for_eval_result"
4185 compiler_flags="$compiler_flags $func_quote_for_eval_result"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004186 done
4187 IFS="$save_ifs"
Lev Walkin4da95cf2010-10-16 02:46:32 -07004188 func_stripname ' ' '' "$arg"
4189 arg=$func_stripname_result
Lev Walkin8e8b5482004-06-17 23:42:48 +00004190 ;;
4191
4192 -Wl,*)
Lev Walkin4da95cf2010-10-16 02:46:32 -07004193 func_stripname '-Wl,' '' "$arg"
4194 args=$func_stripname_result
Lev Walkin8e8b5482004-06-17 23:42:48 +00004195 arg=
4196 save_ifs="$IFS"; IFS=','
4197 for flag in $args; do
4198 IFS="$save_ifs"
Lev Walkin4da95cf2010-10-16 02:46:32 -07004199 func_quote_for_eval "$flag"
Lev Walkine7c4b962010-11-09 03:10:36 -08004200 arg="$arg $wl$func_quote_for_eval_result"
4201 compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
4202 linker_flags="$linker_flags $func_quote_for_eval_result"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004203 done
4204 IFS="$save_ifs"
Lev Walkin4da95cf2010-10-16 02:46:32 -07004205 func_stripname ' ' '' "$arg"
4206 arg=$func_stripname_result
Lev Walkin8e8b5482004-06-17 23:42:48 +00004207 ;;
4208
4209 -Xcompiler)
4210 prev=xcompiler
4211 continue
4212 ;;
4213
4214 -Xlinker)
4215 prev=xlinker
4216 continue
4217 ;;
4218
4219 -XCClinker)
4220 prev=xcclinker
4221 continue
4222 ;;
Lev Walkinf15320b2004-06-03 03:38:44 +00004223
Lev Walkin4da95cf2010-10-16 02:46:32 -07004224 # -msg_* for osf cc
4225 -msg_*)
4226 func_quote_for_eval "$arg"
4227 arg="$func_quote_for_eval_result"
4228 ;;
4229
Lev Walkine7c4b962010-11-09 03:10:36 -08004230 # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
4231 # -r[0-9][0-9]* specifies the processor on the SGI compiler
4232 # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
4233 # +DA*, +DD* enable 64-bit mode on the HP compiler
4234 # -q* pass through compiler args for the IBM compiler
4235 # -m*, -t[45]*, -txscale* pass through architecture-specific
4236 # compiler args for GCC
4237 # -F/path gives path to uninstalled frameworks, gcc on darwin
4238 # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
4239 # @file GCC response files
Lev Walkin4da95cf2010-10-16 02:46:32 -07004240 -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
Lev Walkine7c4b962010-11-09 03:10:36 -08004241 -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
Lev Walkin4da95cf2010-10-16 02:46:32 -07004242 func_quote_for_eval "$arg"
4243 arg="$func_quote_for_eval_result"
4244 func_append compile_command " $arg"
4245 func_append finalize_command " $arg"
Lev Walkine7c4b962010-11-09 03:10:36 -08004246 compiler_flags="$compiler_flags $arg"
Lev Walkin4da95cf2010-10-16 02:46:32 -07004247 continue
4248 ;;
4249
Lev Walkinf15320b2004-06-03 03:38:44 +00004250 # Some other compiler flag.
4251 -* | +*)
Lev Walkin4da95cf2010-10-16 02:46:32 -07004252 func_quote_for_eval "$arg"
4253 arg="$func_quote_for_eval_result"
Lev Walkinf15320b2004-06-03 03:38:44 +00004254 ;;
4255
Lev Walkin8e8b5482004-06-17 23:42:48 +00004256 *.$objext)
Lev Walkinf15320b2004-06-03 03:38:44 +00004257 # A standard object.
Lev Walkine7c4b962010-11-09 03:10:36 -08004258 objs="$objs $arg"
Lev Walkinf15320b2004-06-03 03:38:44 +00004259 ;;
4260
4261 *.lo)
Lev Walkin8e8b5482004-06-17 23:42:48 +00004262 # A libtool-controlled object.
4263
4264 # Check to see that this really is a libtool object.
Lev Walkin4da95cf2010-10-16 02:46:32 -07004265 if func_lalib_unsafe_p "$arg"; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00004266 pic_object=
4267 non_pic_object=
4268
4269 # Read the .lo file
Lev Walkin4da95cf2010-10-16 02:46:32 -07004270 func_source "$arg"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004271
Lev Walkin4da95cf2010-10-16 02:46:32 -07004272 if test -z "$pic_object" ||
Lev Walkin8e8b5482004-06-17 23:42:48 +00004273 test -z "$non_pic_object" ||
Lev Walkin4da95cf2010-10-16 02:46:32 -07004274 test "$pic_object" = none &&
Lev Walkin8e8b5482004-06-17 23:42:48 +00004275 test "$non_pic_object" = none; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07004276 func_fatal_error "cannot find name of object for \`$arg'"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004277 fi
4278
4279 # Extract subdirectory from the argument.
Lev Walkin4da95cf2010-10-16 02:46:32 -07004280 func_dirname "$arg" "/" ""
4281 xdir="$func_dirname_result"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004282
4283 if test "$pic_object" != none; then
4284 # Prepend the subdirectory the object is found in.
4285 pic_object="$xdir$pic_object"
4286
4287 if test "$prev" = dlfiles; then
4288 if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
Lev Walkine7c4b962010-11-09 03:10:36 -08004289 dlfiles="$dlfiles $pic_object"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004290 prev=
4291 continue
4292 else
4293 # If libtool objects are unsupported, then we need to preload.
4294 prev=dlprefiles
4295 fi
4296 fi
4297
4298 # CHECK ME: I think I busted this. -Ossama
4299 if test "$prev" = dlprefiles; then
4300 # Preload the old-style object.
Lev Walkine7c4b962010-11-09 03:10:36 -08004301 dlprefiles="$dlprefiles $pic_object"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004302 prev=
4303 fi
4304
4305 # A PIC object.
Lev Walkin4da95cf2010-10-16 02:46:32 -07004306 func_append libobjs " $pic_object"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004307 arg="$pic_object"
4308 fi
4309
4310 # Non-PIC object.
4311 if test "$non_pic_object" != none; then
4312 # Prepend the subdirectory the object is found in.
4313 non_pic_object="$xdir$non_pic_object"
4314
4315 # A standard non-PIC object
Lev Walkin4da95cf2010-10-16 02:46:32 -07004316 func_append non_pic_objects " $non_pic_object"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004317 if test -z "$pic_object" || test "$pic_object" = none ; then
4318 arg="$non_pic_object"
4319 fi
Lev Walkin4da95cf2010-10-16 02:46:32 -07004320 else
4321 # If the PIC object exists, use it instead.
4322 # $xdir was prepended to $pic_object above.
4323 non_pic_object="$pic_object"
4324 func_append non_pic_objects " $non_pic_object"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004325 fi
4326 else
4327 # Only an error if not doing a dry-run.
Lev Walkin4da95cf2010-10-16 02:46:32 -07004328 if $opt_dry_run; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00004329 # Extract subdirectory from the argument.
Lev Walkin4da95cf2010-10-16 02:46:32 -07004330 func_dirname "$arg" "/" ""
4331 xdir="$func_dirname_result"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004332
Lev Walkin4da95cf2010-10-16 02:46:32 -07004333 func_lo2o "$arg"
4334 pic_object=$xdir$objdir/$func_lo2o_result
4335 non_pic_object=$xdir$func_lo2o_result
4336 func_append libobjs " $pic_object"
4337 func_append non_pic_objects " $non_pic_object"
4338 else
4339 func_fatal_error "\`$arg' is not a valid libtool object"
Lev Walkinf15320b2004-06-03 03:38:44 +00004340 fi
4341 fi
Lev Walkin8e8b5482004-06-17 23:42:48 +00004342 ;;
Lev Walkinf15320b2004-06-03 03:38:44 +00004343
Lev Walkin8e8b5482004-06-17 23:42:48 +00004344 *.$libext)
4345 # An archive.
Lev Walkine7c4b962010-11-09 03:10:36 -08004346 deplibs="$deplibs $arg"
4347 old_deplibs="$old_deplibs $arg"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004348 continue
Lev Walkinf15320b2004-06-03 03:38:44 +00004349 ;;
4350
4351 *.la)
4352 # A libtool-controlled library.
4353
Lev Walkinf15320b2004-06-03 03:38:44 +00004354 if test "$prev" = dlfiles; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00004355 # This library was specified with -dlopen.
Lev Walkine7c4b962010-11-09 03:10:36 -08004356 dlfiles="$dlfiles $arg"
Lev Walkinf15320b2004-06-03 03:38:44 +00004357 prev=
Lev Walkin8e8b5482004-06-17 23:42:48 +00004358 elif test "$prev" = dlprefiles; then
4359 # The library was specified with -dlpreopen.
Lev Walkine7c4b962010-11-09 03:10:36 -08004360 dlprefiles="$dlprefiles $arg"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004361 prev=
Lev Walkinf15320b2004-06-03 03:38:44 +00004362 else
Lev Walkine7c4b962010-11-09 03:10:36 -08004363 deplibs="$deplibs $arg"
Lev Walkinf15320b2004-06-03 03:38:44 +00004364 fi
Lev Walkinf15320b2004-06-03 03:38:44 +00004365 continue
4366 ;;
4367
4368 # Some other compiler argument.
4369 *)
4370 # Unknown arguments in both finalize_command and compile_command need
4371 # to be aesthetically quoted because they are evaled later.
Lev Walkin4da95cf2010-10-16 02:46:32 -07004372 func_quote_for_eval "$arg"
4373 arg="$func_quote_for_eval_result"
Lev Walkinf15320b2004-06-03 03:38:44 +00004374 ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00004375 esac # arg
Lev Walkinf15320b2004-06-03 03:38:44 +00004376
4377 # Now actually substitute the argument into the commands.
4378 if test -n "$arg"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07004379 func_append compile_command " $arg"
4380 func_append finalize_command " $arg"
Lev Walkinf15320b2004-06-03 03:38:44 +00004381 fi
Lev Walkin8e8b5482004-06-17 23:42:48 +00004382 done # argument parsing loop
Lev Walkinf15320b2004-06-03 03:38:44 +00004383
Lev Walkin4da95cf2010-10-16 02:46:32 -07004384 test -n "$prev" && \
4385 func_fatal_help "the \`$prevarg' option requires an argument"
Lev Walkinf15320b2004-06-03 03:38:44 +00004386
4387 if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
4388 eval arg=\"$export_dynamic_flag_spec\"
Lev Walkin4da95cf2010-10-16 02:46:32 -07004389 func_append compile_command " $arg"
4390 func_append finalize_command " $arg"
Lev Walkinf15320b2004-06-03 03:38:44 +00004391 fi
4392
4393 oldlibs=
4394 # calculate the name of the file, without its directory
Lev Walkin4da95cf2010-10-16 02:46:32 -07004395 func_basename "$output"
4396 outputname="$func_basename_result"
Lev Walkinf15320b2004-06-03 03:38:44 +00004397 libobjs_save="$libobjs"
4398
Lev Walkin8e8b5482004-06-17 23:42:48 +00004399 if test -n "$shlibpath_var"; then
4400 # get the directories listed in $shlibpath_var
Lev Walkine7c4b962010-11-09 03:10:36 -08004401 eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
Lev Walkin8e8b5482004-06-17 23:42:48 +00004402 else
4403 shlib_search_path=
4404 fi
4405 eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
4406 eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
4407
Lev Walkin4da95cf2010-10-16 02:46:32 -07004408 func_dirname "$output" "/" ""
4409 output_objdir="$func_dirname_result$objdir"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004410 # Create the object directory.
Lev Walkin4da95cf2010-10-16 02:46:32 -07004411 func_mkdir_p "$output_objdir"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004412
4413 # Determine the type of output
4414 case $output in
Lev Walkinf15320b2004-06-03 03:38:44 +00004415 "")
Lev Walkin4da95cf2010-10-16 02:46:32 -07004416 func_fatal_help "you must specify an output file"
Lev Walkinf15320b2004-06-03 03:38:44 +00004417 ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00004418 *.$libext) linkmode=oldlib ;;
4419 *.lo | *.$objext) linkmode=obj ;;
4420 *.la) linkmode=lib ;;
4421 *) linkmode=prog ;; # Anything else should be a program.
4422 esac
Lev Walkinf15320b2004-06-03 03:38:44 +00004423
Lev Walkin8e8b5482004-06-17 23:42:48 +00004424 specialdeplibs=
4425
4426 libs=
4427 # Find all interdependent deplibs by searching for libraries
4428 # that are linked more than once (e.g. -la -lb -la)
4429 for deplib in $deplibs; do
Lev Walkine7c4b962010-11-09 03:10:36 -08004430 if $opt_duplicate_deps ; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00004431 case "$libs " in
Lev Walkine7c4b962010-11-09 03:10:36 -08004432 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00004433 esac
Lev Walkinf15320b2004-06-03 03:38:44 +00004434 fi
Lev Walkine7c4b962010-11-09 03:10:36 -08004435 libs="$libs $deplib"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004436 done
Lev Walkinf15320b2004-06-03 03:38:44 +00004437
Lev Walkin8e8b5482004-06-17 23:42:48 +00004438 if test "$linkmode" = lib; then
4439 libs="$predeps $libs $compiler_lib_search_path $postdeps"
4440
4441 # Compute libraries that are listed more than once in $predeps
4442 # $postdeps and mark them as special (i.e., whose duplicates are
4443 # not to be eliminated).
4444 pre_post_deps=
Lev Walkin4da95cf2010-10-16 02:46:32 -07004445 if $opt_duplicate_compiler_generated_deps; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00004446 for pre_post_dep in $predeps $postdeps; do
4447 case "$pre_post_deps " in
Lev Walkine7c4b962010-11-09 03:10:36 -08004448 *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00004449 esac
Lev Walkine7c4b962010-11-09 03:10:36 -08004450 pre_post_deps="$pre_post_deps $pre_post_dep"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004451 done
4452 fi
4453 pre_post_deps=
4454 fi
4455
4456 deplibs=
4457 newdependency_libs=
4458 newlib_search_path=
4459 need_relink=no # whether we're linking any uninstalled libtool libraries
4460 notinst_deplibs= # not-installed libtool libraries
4461 notinst_path= # paths that contain not-installed libtool libraries
Lev Walkin4da95cf2010-10-16 02:46:32 -07004462
Lev Walkin8e8b5482004-06-17 23:42:48 +00004463 case $linkmode in
4464 lib)
Lev Walkin4da95cf2010-10-16 02:46:32 -07004465 passes="conv dlpreopen link"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004466 for file in $dlfiles $dlprefiles; do
4467 case $file in
4468 *.la) ;;
4469 *)
Lev Walkin4da95cf2010-10-16 02:46:32 -07004470 func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004471 ;;
4472 esac
4473 done
4474 ;;
4475 prog)
4476 compile_deplibs=
4477 finalize_deplibs=
4478 alldeplibs=no
4479 newdlfiles=
4480 newdlprefiles=
4481 passes="conv scan dlopen dlpreopen link"
4482 ;;
4483 *) passes="conv"
4484 ;;
4485 esac
Lev Walkin4da95cf2010-10-16 02:46:32 -07004486
Lev Walkin8e8b5482004-06-17 23:42:48 +00004487 for pass in $passes; do
Lev Walkin4da95cf2010-10-16 02:46:32 -07004488 # The preopen pass in lib mode reverses $deplibs; put it back here
4489 # so that -L comes before libs that need it for instance...
4490 if test "$linkmode,$pass" = "lib,link"; then
4491 ## FIXME: Find the place where the list is rebuilt in the wrong
4492 ## order, and fix it there properly
4493 tmp_deplibs=
4494 for deplib in $deplibs; do
4495 tmp_deplibs="$deplib $tmp_deplibs"
4496 done
4497 deplibs="$tmp_deplibs"
4498 fi
4499
Lev Walkin8e8b5482004-06-17 23:42:48 +00004500 if test "$linkmode,$pass" = "lib,link" ||
4501 test "$linkmode,$pass" = "prog,scan"; then
4502 libs="$deplibs"
4503 deplibs=
4504 fi
4505 if test "$linkmode" = prog; then
4506 case $pass in
4507 dlopen) libs="$dlfiles" ;;
4508 dlpreopen) libs="$dlprefiles" ;;
4509 link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
4510 esac
4511 fi
Lev Walkin4da95cf2010-10-16 02:46:32 -07004512 if test "$linkmode,$pass" = "lib,dlpreopen"; then
4513 # Collect and forward deplibs of preopened libtool libs
4514 for lib in $dlprefiles; do
4515 # Ignore non-libtool-libs
4516 dependency_libs=
Lev Walkin4da95cf2010-10-16 02:46:32 -07004517 case $lib in
Lev Walkine7c4b962010-11-09 03:10:36 -08004518 *.la) func_source "$lib" ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07004519 esac
4520
4521 # Collect preopened libtool deplibs, except any this library
4522 # has declared as weak libs
4523 for deplib in $dependency_libs; do
Lev Walkine7c4b962010-11-09 03:10:36 -08004524 deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"`
Lev Walkin4da95cf2010-10-16 02:46:32 -07004525 case " $weak_libs " in
4526 *" $deplib_base "*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08004527 *) deplibs="$deplibs $deplib" ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07004528 esac
4529 done
4530 done
4531 libs="$dlprefiles"
4532 fi
Lev Walkin8e8b5482004-06-17 23:42:48 +00004533 if test "$pass" = dlopen; then
4534 # Collect dlpreopened libraries
4535 save_deplibs="$deplibs"
4536 deplibs=
4537 fi
Lev Walkin4da95cf2010-10-16 02:46:32 -07004538
Lev Walkin8e8b5482004-06-17 23:42:48 +00004539 for deplib in $libs; do
4540 lib=
4541 found=no
4542 case $deplib in
Lev Walkin4da95cf2010-10-16 02:46:32 -07004543 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
Lev Walkin8e8b5482004-06-17 23:42:48 +00004544 if test "$linkmode,$pass" = "prog,link"; then
4545 compile_deplibs="$deplib $compile_deplibs"
4546 finalize_deplibs="$deplib $finalize_deplibs"
4547 else
Lev Walkine7c4b962010-11-09 03:10:36 -08004548 compiler_flags="$compiler_flags $deplib"
Lev Walkin4da95cf2010-10-16 02:46:32 -07004549 if test "$linkmode" = lib ; then
4550 case "$new_inherited_linker_flags " in
4551 *" $deplib "*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08004552 * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07004553 esac
4554 fi
Lev Walkin8e8b5482004-06-17 23:42:48 +00004555 fi
4556 continue
4557 ;;
4558 -l*)
4559 if test "$linkmode" != lib && test "$linkmode" != prog; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07004560 func_warning "\`-l' is ignored for archives/objects"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004561 continue
4562 fi
Lev Walkin4da95cf2010-10-16 02:46:32 -07004563 func_stripname '-l' '' "$deplib"
4564 name=$func_stripname_result
4565 if test "$linkmode" = lib; then
4566 searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
4567 else
4568 searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004569 fi
Lev Walkin4da95cf2010-10-16 02:46:32 -07004570 for searchdir in $searchdirs; do
Lev Walkin8e8b5482004-06-17 23:42:48 +00004571 for search_ext in .la $std_shrext .so .a; do
4572 # Search the libtool library
4573 lib="$searchdir/lib${name}${search_ext}"
4574 if test -f "$lib"; then
4575 if test "$search_ext" = ".la"; then
4576 found=yes
4577 else
4578 found=no
4579 fi
4580 break 2
4581 fi
4582 done
4583 done
4584 if test "$found" != yes; then
4585 # deplib doesn't seem to be a libtool library
4586 if test "$linkmode,$pass" = "prog,link"; then
4587 compile_deplibs="$deplib $compile_deplibs"
4588 finalize_deplibs="$deplib $finalize_deplibs"
4589 else
4590 deplibs="$deplib $deplibs"
4591 test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
4592 fi
4593 continue
4594 else # deplib is a libtool library
4595 # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
4596 # We need to do some special things here, and not later.
4597 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
4598 case " $predeps $postdeps " in
4599 *" $deplib "*)
Lev Walkin4da95cf2010-10-16 02:46:32 -07004600 if func_lalib_p "$lib"; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00004601 library_names=
4602 old_library=
Lev Walkin4da95cf2010-10-16 02:46:32 -07004603 func_source "$lib"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004604 for l in $old_library $library_names; do
4605 ll="$l"
4606 done
4607 if test "X$ll" = "X$old_library" ; then # only static version available
4608 found=no
Lev Walkin4da95cf2010-10-16 02:46:32 -07004609 func_dirname "$lib" "" "."
4610 ladir="$func_dirname_result"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004611 lib=$ladir/$old_library
4612 if test "$linkmode,$pass" = "prog,link"; then
4613 compile_deplibs="$deplib $compile_deplibs"
4614 finalize_deplibs="$deplib $finalize_deplibs"
4615 else
4616 deplibs="$deplib $deplibs"
4617 test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
4618 fi
4619 continue
4620 fi
4621 fi
Lev Walkin4da95cf2010-10-16 02:46:32 -07004622 ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00004623 *) ;;
4624 esac
4625 fi
4626 fi
4627 ;; # -l
Lev Walkin4da95cf2010-10-16 02:46:32 -07004628 *.ltframework)
4629 if test "$linkmode,$pass" = "prog,link"; then
4630 compile_deplibs="$deplib $compile_deplibs"
4631 finalize_deplibs="$deplib $finalize_deplibs"
4632 else
4633 deplibs="$deplib $deplibs"
4634 if test "$linkmode" = lib ; then
4635 case "$new_inherited_linker_flags " in
4636 *" $deplib "*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08004637 * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07004638 esac
4639 fi
4640 fi
4641 continue
4642 ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00004643 -L*)
4644 case $linkmode in
4645 lib)
4646 deplibs="$deplib $deplibs"
4647 test "$pass" = conv && continue
4648 newdependency_libs="$deplib $newdependency_libs"
Lev Walkin4da95cf2010-10-16 02:46:32 -07004649 func_stripname '-L' '' "$deplib"
Lev Walkine7c4b962010-11-09 03:10:36 -08004650 newlib_search_path="$newlib_search_path $func_stripname_result"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004651 ;;
4652 prog)
4653 if test "$pass" = conv; then
4654 deplibs="$deplib $deplibs"
4655 continue
4656 fi
4657 if test "$pass" = scan; then
4658 deplibs="$deplib $deplibs"
4659 else
4660 compile_deplibs="$deplib $compile_deplibs"
4661 finalize_deplibs="$deplib $finalize_deplibs"
4662 fi
Lev Walkin4da95cf2010-10-16 02:46:32 -07004663 func_stripname '-L' '' "$deplib"
Lev Walkine7c4b962010-11-09 03:10:36 -08004664 newlib_search_path="$newlib_search_path $func_stripname_result"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004665 ;;
4666 *)
Lev Walkin4da95cf2010-10-16 02:46:32 -07004667 func_warning "\`-L' is ignored for archives/objects"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004668 ;;
4669 esac # linkmode
4670 continue
4671 ;; # -L
4672 -R*)
4673 if test "$pass" = link; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07004674 func_stripname '-R' '' "$deplib"
Lev Walkine7c4b962010-11-09 03:10:36 -08004675 dir=$func_stripname_result
Lev Walkin8e8b5482004-06-17 23:42:48 +00004676 # Make sure the xrpath contains only unique directories.
4677 case "$xrpath " in
4678 *" $dir "*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08004679 *) xrpath="$xrpath $dir" ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00004680 esac
4681 fi
4682 deplibs="$deplib $deplibs"
4683 continue
4684 ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08004685 *.la) lib="$deplib" ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00004686 *.$libext)
4687 if test "$pass" = conv; then
4688 deplibs="$deplib $deplibs"
4689 continue
4690 fi
4691 case $linkmode in
4692 lib)
Lev Walkin4da95cf2010-10-16 02:46:32 -07004693 # Linking convenience modules into shared libraries is allowed,
4694 # but linking other static libraries is non-portable.
4695 case " $dlpreconveniencelibs " in
4696 *" $deplib "*) ;;
4697 *)
4698 valid_a_lib=no
4699 case $deplibs_check_method in
4700 match_pattern*)
4701 set dummy $deplibs_check_method; shift
4702 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
Lev Walkine7c4b962010-11-09 03:10:36 -08004703 if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \
Lev Walkin4da95cf2010-10-16 02:46:32 -07004704 | $EGREP "$match_pattern_regex" > /dev/null; then
4705 valid_a_lib=yes
4706 fi
4707 ;;
4708 pass_all)
4709 valid_a_lib=yes
4710 ;;
4711 esac
4712 if test "$valid_a_lib" != yes; then
Lev Walkine7c4b962010-11-09 03:10:36 -08004713 $ECHO
Lev Walkin4da95cf2010-10-16 02:46:32 -07004714 $ECHO "*** Warning: Trying to link with static lib archive $deplib."
Lev Walkine7c4b962010-11-09 03:10:36 -08004715 $ECHO "*** I have the capability to make that library automatically link in when"
4716 $ECHO "*** you link to this library. But I can only do this if you have a"
4717 $ECHO "*** shared version of the library, which you do not appear to have"
4718 $ECHO "*** because the file extensions .$libext of this argument makes me believe"
4719 $ECHO "*** that it is just a static archive that I should not use here."
Lev Walkin4da95cf2010-10-16 02:46:32 -07004720 else
Lev Walkine7c4b962010-11-09 03:10:36 -08004721 $ECHO
Lev Walkin4da95cf2010-10-16 02:46:32 -07004722 $ECHO "*** Warning: Linking the shared library $output against the"
4723 $ECHO "*** static library $deplib is not portable!"
4724 deplibs="$deplib $deplibs"
4725 fi
4726 ;;
4727 esac
Lev Walkin8e8b5482004-06-17 23:42:48 +00004728 continue
4729 ;;
4730 prog)
4731 if test "$pass" != link; then
4732 deplibs="$deplib $deplibs"
4733 else
4734 compile_deplibs="$deplib $compile_deplibs"
4735 finalize_deplibs="$deplib $finalize_deplibs"
4736 fi
4737 continue
4738 ;;
4739 esac # linkmode
4740 ;; # *.$libext
4741 *.lo | *.$objext)
4742 if test "$pass" = conv; then
4743 deplibs="$deplib $deplibs"
4744 elif test "$linkmode" = prog; then
4745 if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
4746 # If there is no dlopen support or we're linking statically,
4747 # we need to preload.
Lev Walkine7c4b962010-11-09 03:10:36 -08004748 newdlprefiles="$newdlprefiles $deplib"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004749 compile_deplibs="$deplib $compile_deplibs"
4750 finalize_deplibs="$deplib $finalize_deplibs"
4751 else
Lev Walkine7c4b962010-11-09 03:10:36 -08004752 newdlfiles="$newdlfiles $deplib"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004753 fi
4754 fi
4755 continue
4756 ;;
4757 %DEPLIBS%)
4758 alldeplibs=yes
4759 continue
4760 ;;
4761 esac # case $deplib
Lev Walkin4da95cf2010-10-16 02:46:32 -07004762
Lev Walkin8e8b5482004-06-17 23:42:48 +00004763 if test "$found" = yes || test -f "$lib"; then :
4764 else
Lev Walkin4da95cf2010-10-16 02:46:32 -07004765 func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004766 fi
4767
4768 # Check to see that this really is a libtool archive.
Lev Walkin4da95cf2010-10-16 02:46:32 -07004769 func_lalib_unsafe_p "$lib" \
4770 || func_fatal_error "\`$lib' is not a valid libtool archive"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004771
Lev Walkin4da95cf2010-10-16 02:46:32 -07004772 func_dirname "$lib" "" "."
4773 ladir="$func_dirname_result"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004774
4775 dlname=
4776 dlopen=
4777 dlpreopen=
4778 libdir=
4779 library_names=
4780 old_library=
Lev Walkin4da95cf2010-10-16 02:46:32 -07004781 inherited_linker_flags=
Lev Walkin8e8b5482004-06-17 23:42:48 +00004782 # If the library was installed with an old release of libtool,
4783 # it will not redefine variables installed, or shouldnotlink
4784 installed=yes
4785 shouldnotlink=no
Lev Walkin4da95cf2010-10-16 02:46:32 -07004786 avoidtemprpath=
4787
Lev Walkin8e8b5482004-06-17 23:42:48 +00004788
4789 # Read the .la file
Lev Walkin4da95cf2010-10-16 02:46:32 -07004790 func_source "$lib"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004791
Lev Walkin4da95cf2010-10-16 02:46:32 -07004792 # Convert "-framework foo" to "foo.ltframework"
4793 if test -n "$inherited_linker_flags"; then
Lev Walkine7c4b962010-11-09 03:10:36 -08004794 tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'`
Lev Walkin4da95cf2010-10-16 02:46:32 -07004795 for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
4796 case " $new_inherited_linker_flags " in
4797 *" $tmp_inherited_linker_flag "*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08004798 *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
Lev Walkin4da95cf2010-10-16 02:46:32 -07004799 esac
4800 done
4801 fi
Lev Walkine7c4b962010-11-09 03:10:36 -08004802 dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
Lev Walkin8e8b5482004-06-17 23:42:48 +00004803 if test "$linkmode,$pass" = "lib,link" ||
4804 test "$linkmode,$pass" = "prog,scan" ||
4805 { test "$linkmode" != prog && test "$linkmode" != lib; }; then
Lev Walkine7c4b962010-11-09 03:10:36 -08004806 test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
4807 test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004808 fi
4809
4810 if test "$pass" = conv; then
4811 # Only check for convenience libraries
4812 deplibs="$lib $deplibs"
4813 if test -z "$libdir"; then
4814 if test -z "$old_library"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07004815 func_fatal_error "cannot find name of link library for \`$lib'"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004816 fi
4817 # It is a libtool convenience library, so add in its objects.
Lev Walkine7c4b962010-11-09 03:10:36 -08004818 convenience="$convenience $ladir/$objdir/$old_library"
4819 old_convenience="$old_convenience $ladir/$objdir/$old_library"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004820 elif test "$linkmode" != prog && test "$linkmode" != lib; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07004821 func_fatal_error "\`$lib' is not a convenience library"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004822 fi
Lev Walkin4da95cf2010-10-16 02:46:32 -07004823 tmp_libs=
4824 for deplib in $dependency_libs; do
4825 deplibs="$deplib $deplibs"
Lev Walkine7c4b962010-11-09 03:10:36 -08004826 if $opt_duplicate_deps ; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07004827 case "$tmp_libs " in
Lev Walkine7c4b962010-11-09 03:10:36 -08004828 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07004829 esac
4830 fi
Lev Walkine7c4b962010-11-09 03:10:36 -08004831 tmp_libs="$tmp_libs $deplib"
Lev Walkin4da95cf2010-10-16 02:46:32 -07004832 done
Lev Walkin8e8b5482004-06-17 23:42:48 +00004833 continue
4834 fi # $pass = conv
4835
4836
4837 # Get the name of the library we link against.
4838 linklib=
Lev Walkine7c4b962010-11-09 03:10:36 -08004839 for l in $old_library $library_names; do
4840 linklib="$l"
4841 done
Lev Walkin8e8b5482004-06-17 23:42:48 +00004842 if test -z "$linklib"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07004843 func_fatal_error "cannot find name of link library for \`$lib'"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004844 fi
4845
4846 # This library was specified with -dlopen.
4847 if test "$pass" = dlopen; then
4848 if test -z "$libdir"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07004849 func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004850 fi
4851 if test -z "$dlname" ||
4852 test "$dlopen_support" != yes ||
4853 test "$build_libtool_libs" = no; then
4854 # If there is no dlname, no dlopen support or we're linking
4855 # statically, we need to preload. We also need to preload any
4856 # dependent libraries so libltdl's deplib preloader doesn't
4857 # bomb out in the load deplibs phase.
Lev Walkine7c4b962010-11-09 03:10:36 -08004858 dlprefiles="$dlprefiles $lib $dependency_libs"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004859 else
Lev Walkine7c4b962010-11-09 03:10:36 -08004860 newdlfiles="$newdlfiles $lib"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004861 fi
4862 continue
4863 fi # $pass = dlopen
4864
4865 # We need an absolute path.
4866 case $ladir in
4867 [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
4868 *)
4869 abs_ladir=`cd "$ladir" && pwd`
4870 if test -z "$abs_ladir"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07004871 func_warning "cannot determine absolute directory name of \`$ladir'"
4872 func_warning "passing it literally to the linker, although it might fail"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004873 abs_ladir="$ladir"
4874 fi
4875 ;;
4876 esac
Lev Walkin4da95cf2010-10-16 02:46:32 -07004877 func_basename "$lib"
4878 laname="$func_basename_result"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004879
4880 # Find the relevant object directory and library name.
4881 if test "X$installed" = Xyes; then
Lev Walkine7c4b962010-11-09 03:10:36 -08004882 if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07004883 func_warning "library \`$lib' was moved."
Lev Walkin8e8b5482004-06-17 23:42:48 +00004884 dir="$ladir"
4885 absdir="$abs_ladir"
4886 libdir="$abs_ladir"
4887 else
Lev Walkine7c4b962010-11-09 03:10:36 -08004888 dir="$libdir"
4889 absdir="$libdir"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004890 fi
Lev Walkin4da95cf2010-10-16 02:46:32 -07004891 test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
Lev Walkin8e8b5482004-06-17 23:42:48 +00004892 else
Lev Walkin4da95cf2010-10-16 02:46:32 -07004893 if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
4894 dir="$ladir"
4895 absdir="$abs_ladir"
4896 # Remove this search path later
Lev Walkine7c4b962010-11-09 03:10:36 -08004897 notinst_path="$notinst_path $abs_ladir"
Lev Walkin4da95cf2010-10-16 02:46:32 -07004898 else
4899 dir="$ladir/$objdir"
4900 absdir="$abs_ladir/$objdir"
4901 # Remove this search path later
Lev Walkine7c4b962010-11-09 03:10:36 -08004902 notinst_path="$notinst_path $abs_ladir"
Lev Walkin4da95cf2010-10-16 02:46:32 -07004903 fi
Lev Walkin8e8b5482004-06-17 23:42:48 +00004904 fi # $installed = yes
Lev Walkin4da95cf2010-10-16 02:46:32 -07004905 func_stripname 'lib' '.la' "$laname"
4906 name=$func_stripname_result
Lev Walkin8e8b5482004-06-17 23:42:48 +00004907
4908 # This library was specified with -dlpreopen.
4909 if test "$pass" = dlpreopen; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07004910 if test -z "$libdir" && test "$linkmode" = prog; then
4911 func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004912 fi
Lev Walkine7c4b962010-11-09 03:10:36 -08004913 # Prefer using a static library (so that no silly _DYNAMIC symbols
4914 # are required to link).
4915 if test -n "$old_library"; then
4916 newdlprefiles="$newdlprefiles $dir/$old_library"
4917 # Keep a list of preopened convenience libraries to check
4918 # that they are being used correctly in the link pass.
4919 test -z "$libdir" && \
4920 dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
4921 # Otherwise, use the dlname, so that lt_dlopen finds it.
4922 elif test -n "$dlname"; then
4923 newdlprefiles="$newdlprefiles $dir/$dlname"
4924 else
4925 newdlprefiles="$newdlprefiles $dir/$linklib"
4926 fi
Lev Walkin8e8b5482004-06-17 23:42:48 +00004927 fi # $pass = dlpreopen
4928
4929 if test -z "$libdir"; then
4930 # Link the convenience library
4931 if test "$linkmode" = lib; then
4932 deplibs="$dir/$old_library $deplibs"
4933 elif test "$linkmode,$pass" = "prog,link"; then
4934 compile_deplibs="$dir/$old_library $compile_deplibs"
4935 finalize_deplibs="$dir/$old_library $finalize_deplibs"
4936 else
4937 deplibs="$lib $deplibs" # used for prog,scan pass
4938 fi
4939 continue
4940 fi
4941
4942
4943 if test "$linkmode" = prog && test "$pass" != link; then
Lev Walkine7c4b962010-11-09 03:10:36 -08004944 newlib_search_path="$newlib_search_path $ladir"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004945 deplibs="$lib $deplibs"
4946
4947 linkalldeplibs=no
4948 if test "$link_all_deplibs" != no || test -z "$library_names" ||
4949 test "$build_libtool_libs" = no; then
4950 linkalldeplibs=yes
4951 fi
4952
4953 tmp_libs=
4954 for deplib in $dependency_libs; do
4955 case $deplib in
Lev Walkin4da95cf2010-10-16 02:46:32 -07004956 -L*) func_stripname '-L' '' "$deplib"
Lev Walkine7c4b962010-11-09 03:10:36 -08004957 newlib_search_path="$newlib_search_path $func_stripname_result"
Lev Walkin4da95cf2010-10-16 02:46:32 -07004958 ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00004959 esac
4960 # Need to link against all dependency_libs?
4961 if test "$linkalldeplibs" = yes; then
4962 deplibs="$deplib $deplibs"
4963 else
4964 # Need to hardcode shared library paths
4965 # or/and link against static libraries
4966 newdependency_libs="$deplib $newdependency_libs"
4967 fi
Lev Walkine7c4b962010-11-09 03:10:36 -08004968 if $opt_duplicate_deps ; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00004969 case "$tmp_libs " in
Lev Walkine7c4b962010-11-09 03:10:36 -08004970 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00004971 esac
4972 fi
Lev Walkine7c4b962010-11-09 03:10:36 -08004973 tmp_libs="$tmp_libs $deplib"
Lev Walkin8e8b5482004-06-17 23:42:48 +00004974 done # for deplib
4975 continue
4976 fi # $linkmode = prog...
4977
4978 if test "$linkmode,$pass" = "prog,link"; then
4979 if test -n "$library_names" &&
Lev Walkin4da95cf2010-10-16 02:46:32 -07004980 { { test "$prefer_static_libs" = no ||
4981 test "$prefer_static_libs,$installed" = "built,yes"; } ||
4982 test -z "$old_library"; }; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00004983 # We need to hardcode the library path
Lev Walkin4da95cf2010-10-16 02:46:32 -07004984 if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00004985 # Make sure the rpath contains only unique directories.
Lev Walkin4da95cf2010-10-16 02:46:32 -07004986 case "$temp_rpath:" in
4987 *"$absdir:"*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08004988 *) temp_rpath="$temp_rpath$absdir:" ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00004989 esac
4990 fi
4991
4992 # Hardcode the library path.
4993 # Skip directories that are in the system default run-time
4994 # search path.
4995 case " $sys_lib_dlsearch_path " in
4996 *" $absdir "*) ;;
4997 *)
4998 case "$compile_rpath " in
4999 *" $absdir "*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08005000 *) compile_rpath="$compile_rpath $absdir"
Lev Walkin8e8b5482004-06-17 23:42:48 +00005001 esac
5002 ;;
5003 esac
5004 case " $sys_lib_dlsearch_path " in
5005 *" $libdir "*) ;;
5006 *)
5007 case "$finalize_rpath " in
5008 *" $libdir "*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08005009 *) finalize_rpath="$finalize_rpath $libdir"
Lev Walkin8e8b5482004-06-17 23:42:48 +00005010 esac
5011 ;;
5012 esac
5013 fi # $linkmode,$pass = prog,link...
5014
5015 if test "$alldeplibs" = yes &&
5016 { test "$deplibs_check_method" = pass_all ||
5017 { test "$build_libtool_libs" = yes &&
5018 test -n "$library_names"; }; }; then
5019 # We only need to search for static libraries
5020 continue
5021 fi
5022 fi
5023
5024 link_static=no # Whether the deplib will be linked statically
Lev Walkin4da95cf2010-10-16 02:46:32 -07005025 use_static_libs=$prefer_static_libs
5026 if test "$use_static_libs" = built && test "$installed" = yes; then
5027 use_static_libs=no
5028 fi
Lev Walkin8e8b5482004-06-17 23:42:48 +00005029 if test -n "$library_names" &&
Lev Walkin4da95cf2010-10-16 02:46:32 -07005030 { test "$use_static_libs" = no || test -z "$old_library"; }; then
5031 case $host in
Lev Walkine7c4b962010-11-09 03:10:36 -08005032 *cygwin* | *mingw*)
Lev Walkin4da95cf2010-10-16 02:46:32 -07005033 # No point in relinking DLLs because paths are not encoded
Lev Walkine7c4b962010-11-09 03:10:36 -08005034 notinst_deplibs="$notinst_deplibs $lib"
Lev Walkin4da95cf2010-10-16 02:46:32 -07005035 need_relink=no
5036 ;;
5037 *)
5038 if test "$installed" = no; then
Lev Walkine7c4b962010-11-09 03:10:36 -08005039 notinst_deplibs="$notinst_deplibs $lib"
Lev Walkin4da95cf2010-10-16 02:46:32 -07005040 need_relink=yes
5041 fi
5042 ;;
5043 esac
Lev Walkin8e8b5482004-06-17 23:42:48 +00005044 # This is a shared library
5045
Lev Walkin4da95cf2010-10-16 02:46:32 -07005046 # Warn about portability, can't link against -module's on some
5047 # systems (darwin). Don't bleat about dlopened modules though!
5048 dlopenmodule=""
5049 for dlpremoduletest in $dlprefiles; do
5050 if test "X$dlpremoduletest" = "X$lib"; then
5051 dlopenmodule="$dlpremoduletest"
5052 break
Lev Walkin8e8b5482004-06-17 23:42:48 +00005053 fi
Lev Walkin4da95cf2010-10-16 02:46:32 -07005054 done
5055 if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
Lev Walkine7c4b962010-11-09 03:10:36 -08005056 $ECHO
Lev Walkin4da95cf2010-10-16 02:46:32 -07005057 if test "$linkmode" = prog; then
5058 $ECHO "*** Warning: Linking the executable $output against the loadable module"
5059 else
5060 $ECHO "*** Warning: Linking the shared library $output against the loadable module"
5061 fi
5062 $ECHO "*** $linklib is not portable!"
Lev Walkin8e8b5482004-06-17 23:42:48 +00005063 fi
5064 if test "$linkmode" = lib &&
5065 test "$hardcode_into_libs" = yes; then
5066 # Hardcode the library path.
5067 # Skip directories that are in the system default run-time
5068 # search path.
5069 case " $sys_lib_dlsearch_path " in
5070 *" $absdir "*) ;;
5071 *)
5072 case "$compile_rpath " in
5073 *" $absdir "*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08005074 *) compile_rpath="$compile_rpath $absdir"
Lev Walkin8e8b5482004-06-17 23:42:48 +00005075 esac
5076 ;;
5077 esac
5078 case " $sys_lib_dlsearch_path " in
5079 *" $libdir "*) ;;
5080 *)
5081 case "$finalize_rpath " in
5082 *" $libdir "*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08005083 *) finalize_rpath="$finalize_rpath $libdir"
Lev Walkin8e8b5482004-06-17 23:42:48 +00005084 esac
5085 ;;
5086 esac
5087 fi
5088
5089 if test -n "$old_archive_from_expsyms_cmds"; then
5090 # figure out the soname
5091 set dummy $library_names
Lev Walkin4da95cf2010-10-16 02:46:32 -07005092 shift
5093 realname="$1"
5094 shift
5095 libname=`eval "\\$ECHO \"$libname_spec\""`
Lev Walkin8e8b5482004-06-17 23:42:48 +00005096 # use dlname if we got it. it's perfectly good, no?
5097 if test -n "$dlname"; then
5098 soname="$dlname"
5099 elif test -n "$soname_spec"; then
5100 # bleh windows
5101 case $host in
Lev Walkine7c4b962010-11-09 03:10:36 -08005102 *cygwin* | mingw*)
Lev Walkin4da95cf2010-10-16 02:46:32 -07005103 func_arith $current - $age
5104 major=$func_arith_result
Lev Walkin8e8b5482004-06-17 23:42:48 +00005105 versuffix="-$major"
5106 ;;
5107 esac
5108 eval soname=\"$soname_spec\"
5109 else
5110 soname="$realname"
5111 fi
5112
5113 # Make a new name for the extract_expsyms_cmds to use
5114 soroot="$soname"
Lev Walkin4da95cf2010-10-16 02:46:32 -07005115 func_basename "$soroot"
5116 soname="$func_basename_result"
5117 func_stripname 'lib' '.dll' "$soname"
5118 newlib=libimp-$func_stripname_result.a
Lev Walkin8e8b5482004-06-17 23:42:48 +00005119
5120 # If the library has no export list, then create one now
5121 if test -f "$output_objdir/$soname-def"; then :
5122 else
Lev Walkin4da95cf2010-10-16 02:46:32 -07005123 func_verbose "extracting exported symbol list from \`$soname'"
5124 func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
Lev Walkin8e8b5482004-06-17 23:42:48 +00005125 fi
5126
5127 # Create $newlib
5128 if test -f "$output_objdir/$newlib"; then :; else
Lev Walkin4da95cf2010-10-16 02:46:32 -07005129 func_verbose "generating import library for \`$soname'"
5130 func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
Lev Walkin8e8b5482004-06-17 23:42:48 +00005131 fi
5132 # make sure the library variables are pointing to the new library
5133 dir=$output_objdir
5134 linklib=$newlib
5135 fi # test -n "$old_archive_from_expsyms_cmds"
5136
Lev Walkine7c4b962010-11-09 03:10:36 -08005137 if test "$linkmode" = prog || test "$mode" != relink; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00005138 add_shlibpath=
5139 add_dir=
5140 add=
5141 lib_linked=yes
5142 case $hardcode_action in
5143 immediate | unsupported)
5144 if test "$hardcode_direct" = no; then
5145 add="$dir/$linklib"
5146 case $host in
Lev Walkin4da95cf2010-10-16 02:46:32 -07005147 *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
5148 *-*-sysv4*uw2*) add_dir="-L$dir" ;;
5149 *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
5150 *-*-unixware7*) add_dir="-L$dir" ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00005151 *-*-darwin* )
Lev Walkin4da95cf2010-10-16 02:46:32 -07005152 # if the lib is a (non-dlopened) module then we can not
5153 # link against it, someone is ignoring the earlier warnings
5154 if /usr/bin/file -L $add 2> /dev/null |
5155 $GREP ": [^:]* bundle" >/dev/null ; then
5156 if test "X$dlopenmodule" != "X$lib"; then
5157 $ECHO "*** Warning: lib $linklib is a module, not a shared library"
5158 if test -z "$old_library" ; then
Lev Walkine7c4b962010-11-09 03:10:36 -08005159 $ECHO
5160 $ECHO "*** And there doesn't seem to be a static archive available"
5161 $ECHO "*** The link will probably fail, sorry"
Lev Walkin4da95cf2010-10-16 02:46:32 -07005162 else
5163 add="$dir/$old_library"
5164 fi
5165 elif test -n "$old_library"; then
5166 add="$dir/$old_library"
Lev Walkin8e8b5482004-06-17 23:42:48 +00005167 fi
5168 fi
5169 esac
5170 elif test "$hardcode_minus_L" = no; then
5171 case $host in
5172 *-*-sunos*) add_shlibpath="$dir" ;;
5173 esac
5174 add_dir="-L$dir"
5175 add="-l$name"
5176 elif test "$hardcode_shlibpath_var" = no; then
5177 add_shlibpath="$dir"
5178 add="-l$name"
5179 else
5180 lib_linked=no
5181 fi
5182 ;;
5183 relink)
Lev Walkin4da95cf2010-10-16 02:46:32 -07005184 if test "$hardcode_direct" = yes &&
5185 test "$hardcode_direct_absolute" = no; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00005186 add="$dir/$linklib"
5187 elif test "$hardcode_minus_L" = yes; then
5188 add_dir="-L$dir"
5189 # Try looking first in the location we're being installed to.
5190 if test -n "$inst_prefix_dir"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07005191 case $libdir in
Lev Walkin8e8b5482004-06-17 23:42:48 +00005192 [\\/]*)
Lev Walkine7c4b962010-11-09 03:10:36 -08005193 add_dir="$add_dir -L$inst_prefix_dir$libdir"
Lev Walkin8e8b5482004-06-17 23:42:48 +00005194 ;;
5195 esac
5196 fi
5197 add="-l$name"
5198 elif test "$hardcode_shlibpath_var" = yes; then
5199 add_shlibpath="$dir"
5200 add="-l$name"
5201 else
5202 lib_linked=no
5203 fi
5204 ;;
5205 *) lib_linked=no ;;
5206 esac
5207
5208 if test "$lib_linked" != yes; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07005209 func_fatal_configuration "unsupported hardcode properties"
Lev Walkin8e8b5482004-06-17 23:42:48 +00005210 fi
5211
5212 if test -n "$add_shlibpath"; then
5213 case :$compile_shlibpath: in
5214 *":$add_shlibpath:"*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08005215 *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00005216 esac
5217 fi
5218 if test "$linkmode" = prog; then
5219 test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
5220 test -n "$add" && compile_deplibs="$add $compile_deplibs"
5221 else
5222 test -n "$add_dir" && deplibs="$add_dir $deplibs"
5223 test -n "$add" && deplibs="$add $deplibs"
Lev Walkin4da95cf2010-10-16 02:46:32 -07005224 if test "$hardcode_direct" != yes &&
5225 test "$hardcode_minus_L" != yes &&
Lev Walkin8e8b5482004-06-17 23:42:48 +00005226 test "$hardcode_shlibpath_var" = yes; then
5227 case :$finalize_shlibpath: in
5228 *":$libdir:"*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08005229 *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00005230 esac
5231 fi
5232 fi
5233 fi
5234
Lev Walkine7c4b962010-11-09 03:10:36 -08005235 if test "$linkmode" = prog || test "$mode" = relink; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00005236 add_shlibpath=
5237 add_dir=
5238 add=
5239 # Finalize command for both is simple: just hardcode it.
Lev Walkin4da95cf2010-10-16 02:46:32 -07005240 if test "$hardcode_direct" = yes &&
5241 test "$hardcode_direct_absolute" = no; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00005242 add="$libdir/$linklib"
5243 elif test "$hardcode_minus_L" = yes; then
5244 add_dir="-L$libdir"
5245 add="-l$name"
5246 elif test "$hardcode_shlibpath_var" = yes; then
5247 case :$finalize_shlibpath: in
5248 *":$libdir:"*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08005249 *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00005250 esac
5251 add="-l$name"
5252 elif test "$hardcode_automatic" = yes; then
5253 if test -n "$inst_prefix_dir" &&
5254 test -f "$inst_prefix_dir$libdir/$linklib" ; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07005255 add="$inst_prefix_dir$libdir/$linklib"
Lev Walkin8e8b5482004-06-17 23:42:48 +00005256 else
Lev Walkin4da95cf2010-10-16 02:46:32 -07005257 add="$libdir/$linklib"
Lev Walkin8e8b5482004-06-17 23:42:48 +00005258 fi
5259 else
5260 # We cannot seem to hardcode it, guess we'll fake it.
5261 add_dir="-L$libdir"
5262 # Try looking first in the location we're being installed to.
5263 if test -n "$inst_prefix_dir"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07005264 case $libdir in
Lev Walkin8e8b5482004-06-17 23:42:48 +00005265 [\\/]*)
Lev Walkine7c4b962010-11-09 03:10:36 -08005266 add_dir="$add_dir -L$inst_prefix_dir$libdir"
Lev Walkin8e8b5482004-06-17 23:42:48 +00005267 ;;
5268 esac
5269 fi
5270 add="-l$name"
5271 fi
5272
5273 if test "$linkmode" = prog; then
5274 test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
5275 test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
5276 else
5277 test -n "$add_dir" && deplibs="$add_dir $deplibs"
5278 test -n "$add" && deplibs="$add $deplibs"
5279 fi
5280 fi
5281 elif test "$linkmode" = prog; then
5282 # Here we assume that one of hardcode_direct or hardcode_minus_L
5283 # is not unsupported. This is valid on all known static and
5284 # shared platforms.
5285 if test "$hardcode_direct" != unsupported; then
5286 test -n "$old_library" && linklib="$old_library"
5287 compile_deplibs="$dir/$linklib $compile_deplibs"
5288 finalize_deplibs="$dir/$linklib $finalize_deplibs"
5289 else
5290 compile_deplibs="-l$name -L$dir $compile_deplibs"
5291 finalize_deplibs="-l$name -L$dir $finalize_deplibs"
5292 fi
5293 elif test "$build_libtool_libs" = yes; then
5294 # Not a shared library
5295 if test "$deplibs_check_method" != pass_all; then
5296 # We're trying link a shared library against a static one
5297 # but the system doesn't support it.
5298
5299 # Just print a warning and add the library to dependency_libs so
5300 # that the program can be linked against the static library.
Lev Walkine7c4b962010-11-09 03:10:36 -08005301 $ECHO
Lev Walkin4da95cf2010-10-16 02:46:32 -07005302 $ECHO "*** Warning: This system can not link to static lib archive $lib."
Lev Walkine7c4b962010-11-09 03:10:36 -08005303 $ECHO "*** I have the capability to make that library automatically link in when"
5304 $ECHO "*** you link to this library. But I can only do this if you have a"
5305 $ECHO "*** shared version of the library, which you do not appear to have."
Lev Walkin8e8b5482004-06-17 23:42:48 +00005306 if test "$module" = yes; then
Lev Walkine7c4b962010-11-09 03:10:36 -08005307 $ECHO "*** But as you try to build a module library, libtool will still create "
5308 $ECHO "*** a static module, that should work as long as the dlopening application"
5309 $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime."
Lev Walkin8e8b5482004-06-17 23:42:48 +00005310 if test -z "$global_symbol_pipe"; then
Lev Walkine7c4b962010-11-09 03:10:36 -08005311 $ECHO
5312 $ECHO "*** However, this would only work if libtool was able to extract symbol"
5313 $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
5314 $ECHO "*** not find such a program. So, this module is probably useless."
5315 $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
Lev Walkin8e8b5482004-06-17 23:42:48 +00005316 fi
5317 if test "$build_old_libs" = no; then
5318 build_libtool_libs=module
5319 build_old_libs=yes
5320 else
5321 build_libtool_libs=no
5322 fi
5323 fi
5324 else
Lev Walkin8e8b5482004-06-17 23:42:48 +00005325 deplibs="$dir/$old_library $deplibs"
5326 link_static=yes
5327 fi
5328 fi # link shared/static library?
5329
5330 if test "$linkmode" = lib; then
5331 if test -n "$dependency_libs" &&
5332 { test "$hardcode_into_libs" != yes ||
5333 test "$build_old_libs" = yes ||
5334 test "$link_static" = yes; }; then
5335 # Extract -R from dependency_libs
5336 temp_deplibs=
5337 for libdir in $dependency_libs; do
5338 case $libdir in
Lev Walkin4da95cf2010-10-16 02:46:32 -07005339 -R*) func_stripname '-R' '' "$libdir"
5340 temp_xrpath=$func_stripname_result
Lev Walkin8e8b5482004-06-17 23:42:48 +00005341 case " $xrpath " in
5342 *" $temp_xrpath "*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08005343 *) xrpath="$xrpath $temp_xrpath";;
Lev Walkin8e8b5482004-06-17 23:42:48 +00005344 esac;;
Lev Walkine7c4b962010-11-09 03:10:36 -08005345 *) temp_deplibs="$temp_deplibs $libdir";;
Lev Walkin8e8b5482004-06-17 23:42:48 +00005346 esac
5347 done
5348 dependency_libs="$temp_deplibs"
5349 fi
5350
Lev Walkine7c4b962010-11-09 03:10:36 -08005351 newlib_search_path="$newlib_search_path $absdir"
Lev Walkin8e8b5482004-06-17 23:42:48 +00005352 # Link against this library
5353 test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
5354 # ... and its dependency_libs
5355 tmp_libs=
5356 for deplib in $dependency_libs; do
5357 newdependency_libs="$deplib $newdependency_libs"
Lev Walkine7c4b962010-11-09 03:10:36 -08005358 if $opt_duplicate_deps ; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00005359 case "$tmp_libs " in
Lev Walkine7c4b962010-11-09 03:10:36 -08005360 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00005361 esac
5362 fi
Lev Walkine7c4b962010-11-09 03:10:36 -08005363 tmp_libs="$tmp_libs $deplib"
Lev Walkin8e8b5482004-06-17 23:42:48 +00005364 done
5365
5366 if test "$link_all_deplibs" != no; then
5367 # Add the search paths of all dependency libraries
5368 for deplib in $dependency_libs; do
5369 case $deplib in
5370 -L*) path="$deplib" ;;
5371 *.la)
Lev Walkin4da95cf2010-10-16 02:46:32 -07005372 func_dirname "$deplib" "" "."
Lev Walkine7c4b962010-11-09 03:10:36 -08005373 dir="$func_dirname_result"
Lev Walkin8e8b5482004-06-17 23:42:48 +00005374 # We need an absolute path.
5375 case $dir in
5376 [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
5377 *)
5378 absdir=`cd "$dir" && pwd`
5379 if test -z "$absdir"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07005380 func_warning "cannot determine absolute directory name of \`$dir'"
Lev Walkin8e8b5482004-06-17 23:42:48 +00005381 absdir="$dir"
5382 fi
5383 ;;
5384 esac
Lev Walkin4da95cf2010-10-16 02:46:32 -07005385 if $GREP "^installed=no" $deplib > /dev/null; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00005386 case $host in
5387 *-*-darwin*)
Lev Walkin4da95cf2010-10-16 02:46:32 -07005388 depdepl=
Lev Walkin8e8b5482004-06-17 23:42:48 +00005389 eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
5390 if test -n "$deplibrary_names" ; then
5391 for tmp in $deplibrary_names ; do
5392 depdepl=$tmp
5393 done
Lev Walkin4da95cf2010-10-16 02:46:32 -07005394 if test -f "$absdir/$objdir/$depdepl" ; then
5395 depdepl="$absdir/$objdir/$depdepl"
5396 darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
5397 if test -z "$darwin_install_name"; then
5398 darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
5399 fi
Lev Walkine7c4b962010-11-09 03:10:36 -08005400 compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
5401 linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
Lev Walkin4da95cf2010-10-16 02:46:32 -07005402 path=
Lev Walkin8e8b5482004-06-17 23:42:48 +00005403 fi
Lev Walkin8e8b5482004-06-17 23:42:48 +00005404 fi
Lev Walkin8e8b5482004-06-17 23:42:48 +00005405 ;;
5406 *)
Lev Walkin4da95cf2010-10-16 02:46:32 -07005407 path="-L$absdir/$objdir"
Lev Walkin8e8b5482004-06-17 23:42:48 +00005408 ;;
5409 esac
Lev Walkin4da95cf2010-10-16 02:46:32 -07005410 else
5411 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
5412 test -z "$libdir" && \
5413 func_fatal_error "\`$deplib' is not a valid libtool archive"
5414 test "$absdir" != "$libdir" && \
5415 func_warning "\`$deplib' seems to be moved"
5416
5417 path="-L$absdir"
5418 fi
Lev Walkin8e8b5482004-06-17 23:42:48 +00005419 ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00005420 esac
5421 case " $deplibs " in
5422 *" $path "*) ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07005423 *) deplibs="$path $deplibs" ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00005424 esac
5425 done
5426 fi # link_all_deplibs != no
5427 fi # linkmode = lib
5428 done # for deplib in $libs
Lev Walkin4da95cf2010-10-16 02:46:32 -07005429 if test "$pass" = link; then
5430 if test "$linkmode" = "prog"; then
5431 compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
5432 finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
5433 else
Lev Walkine7c4b962010-11-09 03:10:36 -08005434 compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
Lev Walkin4da95cf2010-10-16 02:46:32 -07005435 fi
5436 fi
Lev Walkin8e8b5482004-06-17 23:42:48 +00005437 dependency_libs="$newdependency_libs"
5438 if test "$pass" = dlpreopen; then
5439 # Link the dlpreopened libraries before other libraries
5440 for deplib in $save_deplibs; do
5441 deplibs="$deplib $deplibs"
5442 done
5443 fi
5444 if test "$pass" != dlopen; then
5445 if test "$pass" != conv; then
5446 # Make sure lib_search_path contains only unique directories.
5447 lib_search_path=
5448 for dir in $newlib_search_path; do
5449 case "$lib_search_path " in
5450 *" $dir "*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08005451 *) lib_search_path="$lib_search_path $dir" ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00005452 esac
5453 done
5454 newlib_search_path=
5455 fi
5456
5457 if test "$linkmode,$pass" != "prog,link"; then
5458 vars="deplibs"
5459 else
5460 vars="compile_deplibs finalize_deplibs"
5461 fi
5462 for var in $vars dependency_libs; do
5463 # Add libraries to $var in reverse order
5464 eval tmp_libs=\"\$$var\"
5465 new_libs=
5466 for deplib in $tmp_libs; do
5467 # FIXME: Pedantically, this is the right thing to do, so
5468 # that some nasty dependency loop isn't accidentally
5469 # broken:
5470 #new_libs="$deplib $new_libs"
5471 # Pragmatically, this seems to cause very few problems in
5472 # practice:
5473 case $deplib in
5474 -L*) new_libs="$deplib $new_libs" ;;
5475 -R*) ;;
5476 *)
5477 # And here is the reason: when a library appears more
5478 # than once as an explicit dependence of a library, or
5479 # is implicitly linked in more than once by the
5480 # compiler, it is considered special, and multiple
5481 # occurrences thereof are not removed. Compare this
5482 # with having the same library being listed as a
5483 # dependency of multiple other libraries: in this case,
5484 # we know (pedantically, we assume) the library does not
5485 # need to be listed more than once, so we keep only the
5486 # last copy. This is not always right, but it is rare
5487 # enough that we require users that really mean to play
5488 # such unportable linking tricks to link the library
5489 # using -Wl,-lname, so that libtool does not consider it
5490 # for duplicate removal.
5491 case " $specialdeplibs " in
5492 *" $deplib "*) new_libs="$deplib $new_libs" ;;
5493 *)
5494 case " $new_libs " in
5495 *" $deplib "*) ;;
5496 *) new_libs="$deplib $new_libs" ;;
5497 esac
5498 ;;
5499 esac
5500 ;;
5501 esac
5502 done
5503 tmp_libs=
5504 for deplib in $new_libs; do
5505 case $deplib in
5506 -L*)
5507 case " $tmp_libs " in
5508 *" $deplib "*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08005509 *) tmp_libs="$tmp_libs $deplib" ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00005510 esac
5511 ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08005512 *) tmp_libs="$tmp_libs $deplib" ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00005513 esac
5514 done
5515 eval $var=\"$tmp_libs\"
5516 done # for var
5517 fi
5518 # Last step: remove runtime libs from dependency_libs
5519 # (they stay in deplibs)
5520 tmp_libs=
5521 for i in $dependency_libs ; do
5522 case " $predeps $postdeps $compiler_lib_search_path " in
5523 *" $i "*)
5524 i=""
5525 ;;
5526 esac
5527 if test -n "$i" ; then
Lev Walkine7c4b962010-11-09 03:10:36 -08005528 tmp_libs="$tmp_libs $i"
Lev Walkin8e8b5482004-06-17 23:42:48 +00005529 fi
5530 done
5531 dependency_libs=$tmp_libs
5532 done # for pass
5533 if test "$linkmode" = prog; then
5534 dlfiles="$newdlfiles"
Lev Walkin4da95cf2010-10-16 02:46:32 -07005535 fi
5536 if test "$linkmode" = prog || test "$linkmode" = lib; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00005537 dlprefiles="$newdlprefiles"
5538 fi
5539
5540 case $linkmode in
5541 oldlib)
Lev Walkinf15320b2004-06-03 03:38:44 +00005542 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07005543 func_warning "\`-dlopen' is ignored for archives"
Lev Walkinf15320b2004-06-03 03:38:44 +00005544 fi
5545
Lev Walkin4da95cf2010-10-16 02:46:32 -07005546 case " $deplibs" in
5547 *\ -l* | *\ -L*)
5548 func_warning "\`-l' and \`-L' are ignored for archives" ;;
5549 esac
Lev Walkinf15320b2004-06-03 03:38:44 +00005550
Lev Walkin4da95cf2010-10-16 02:46:32 -07005551 test -n "$rpath" && \
5552 func_warning "\`-rpath' is ignored for archives"
Lev Walkinf15320b2004-06-03 03:38:44 +00005553
Lev Walkin4da95cf2010-10-16 02:46:32 -07005554 test -n "$xrpath" && \
5555 func_warning "\`-R' is ignored for archives"
Lev Walkinf15320b2004-06-03 03:38:44 +00005556
Lev Walkin4da95cf2010-10-16 02:46:32 -07005557 test -n "$vinfo" && \
5558 func_warning "\`-version-info/-version-number' is ignored for archives"
Lev Walkinf15320b2004-06-03 03:38:44 +00005559
Lev Walkin4da95cf2010-10-16 02:46:32 -07005560 test -n "$release" && \
5561 func_warning "\`-release' is ignored for archives"
5562
5563 test -n "$export_symbols$export_symbols_regex" && \
5564 func_warning "\`-export-symbols' is ignored for archives"
Lev Walkinf15320b2004-06-03 03:38:44 +00005565
5566 # Now set the variables for building old libraries.
5567 build_libtool_libs=no
5568 oldlibs="$output"
Lev Walkine7c4b962010-11-09 03:10:36 -08005569 objs="$objs$old_deplibs"
Lev Walkinf15320b2004-06-03 03:38:44 +00005570 ;;
5571
Lev Walkin8e8b5482004-06-17 23:42:48 +00005572 lib)
Lev Walkinf15320b2004-06-03 03:38:44 +00005573 # Make sure we only generate libraries of the form `libNAME.la'.
Lev Walkin8e8b5482004-06-17 23:42:48 +00005574 case $outputname in
Lev Walkinf15320b2004-06-03 03:38:44 +00005575 lib*)
Lev Walkin4da95cf2010-10-16 02:46:32 -07005576 func_stripname 'lib' '.la' "$outputname"
5577 name=$func_stripname_result
Lev Walkin8e8b5482004-06-17 23:42:48 +00005578 eval shared_ext=\"$shrext_cmds\"
Lev Walkinf15320b2004-06-03 03:38:44 +00005579 eval libname=\"$libname_spec\"
5580 ;;
5581 *)
Lev Walkin4da95cf2010-10-16 02:46:32 -07005582 test "$module" = no && \
5583 func_fatal_help "libtool library \`$output' must begin with \`lib'"
5584
Lev Walkinf15320b2004-06-03 03:38:44 +00005585 if test "$need_lib_prefix" != no; then
5586 # Add the "lib" prefix for modules if required
Lev Walkin4da95cf2010-10-16 02:46:32 -07005587 func_stripname '' '.la' "$outputname"
5588 name=$func_stripname_result
Lev Walkin8e8b5482004-06-17 23:42:48 +00005589 eval shared_ext=\"$shrext_cmds\"
Lev Walkinf15320b2004-06-03 03:38:44 +00005590 eval libname=\"$libname_spec\"
5591 else
Lev Walkin4da95cf2010-10-16 02:46:32 -07005592 func_stripname '' '.la' "$outputname"
5593 libname=$func_stripname_result
Lev Walkinf15320b2004-06-03 03:38:44 +00005594 fi
5595 ;;
5596 esac
5597
Lev Walkinf15320b2004-06-03 03:38:44 +00005598 if test -n "$objs"; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00005599 if test "$deplibs_check_method" != pass_all; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07005600 func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
Lev Walkin8e8b5482004-06-17 23:42:48 +00005601 else
Lev Walkine7c4b962010-11-09 03:10:36 -08005602 $ECHO
Lev Walkin4da95cf2010-10-16 02:46:32 -07005603 $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
5604 $ECHO "*** objects $objs is not portable!"
Lev Walkine7c4b962010-11-09 03:10:36 -08005605 libobjs="$libobjs $objs"
Lev Walkin8e8b5482004-06-17 23:42:48 +00005606 fi
Lev Walkinf15320b2004-06-03 03:38:44 +00005607 fi
5608
Lev Walkin4da95cf2010-10-16 02:46:32 -07005609 test "$dlself" != no && \
5610 func_warning "\`-dlopen self' is ignored for libtool libraries"
Lev Walkinf15320b2004-06-03 03:38:44 +00005611
5612 set dummy $rpath
Lev Walkin4da95cf2010-10-16 02:46:32 -07005613 shift
5614 test "$#" -gt 1 && \
5615 func_warning "ignoring multiple \`-rpath's for a libtool library"
5616
5617 install_libdir="$1"
Lev Walkinf15320b2004-06-03 03:38:44 +00005618
5619 oldlibs=
5620 if test -z "$rpath"; then
5621 if test "$build_libtool_libs" = yes; then
5622 # Building a libtool convenience library.
Lev Walkin8e8b5482004-06-17 23:42:48 +00005623 # Some compilers have problems with a `.al' extension so
5624 # convenience libraries should have the same extension an
5625 # archive normally would.
Lev Walkinf15320b2004-06-03 03:38:44 +00005626 oldlibs="$output_objdir/$libname.$libext $oldlibs"
5627 build_libtool_libs=convenience
5628 build_old_libs=yes
5629 fi
Lev Walkinf15320b2004-06-03 03:38:44 +00005630
Lev Walkin4da95cf2010-10-16 02:46:32 -07005631 test -n "$vinfo" && \
5632 func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
Lev Walkinf15320b2004-06-03 03:38:44 +00005633
Lev Walkin4da95cf2010-10-16 02:46:32 -07005634 test -n "$release" && \
5635 func_warning "\`-release' is ignored for convenience libraries"
Lev Walkinf15320b2004-06-03 03:38:44 +00005636 else
5637
5638 # Parse the version information argument.
Lev Walkin8e8b5482004-06-17 23:42:48 +00005639 save_ifs="$IFS"; IFS=':'
Lev Walkinf15320b2004-06-03 03:38:44 +00005640 set dummy $vinfo 0 0 0
Lev Walkin4da95cf2010-10-16 02:46:32 -07005641 shift
Lev Walkinf15320b2004-06-03 03:38:44 +00005642 IFS="$save_ifs"
5643
Lev Walkin4da95cf2010-10-16 02:46:32 -07005644 test -n "$7" && \
5645 func_fatal_help "too many parameters to \`-version-info'"
Lev Walkinf15320b2004-06-03 03:38:44 +00005646
Lev Walkin8e8b5482004-06-17 23:42:48 +00005647 # convert absolute version numbers to libtool ages
5648 # this retains compatibility with .la files and attempts
5649 # to make the code below a bit more comprehensible
5650
5651 case $vinfo_number in
5652 yes)
Lev Walkin4da95cf2010-10-16 02:46:32 -07005653 number_major="$1"
5654 number_minor="$2"
5655 number_revision="$3"
Lev Walkin8e8b5482004-06-17 23:42:48 +00005656 #
5657 # There are really only two kinds -- those that
5658 # use the current revision as the major version
5659 # and those that subtract age and use age as
5660 # a minor version. But, then there is irix
5661 # which has an extra 1 added just for fun
5662 #
5663 case $version_type in
Lev Walkin4da95cf2010-10-16 02:46:32 -07005664 darwin|linux|osf|windows|none)
5665 func_arith $number_major + $number_minor
5666 current=$func_arith_result
Lev Walkin8e8b5482004-06-17 23:42:48 +00005667 age="$number_minor"
5668 revision="$number_revision"
5669 ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08005670 freebsd-aout|freebsd-elf|sunos)
Lev Walkin8e8b5482004-06-17 23:42:48 +00005671 current="$number_major"
5672 revision="$number_minor"
5673 age="0"
5674 ;;
5675 irix|nonstopux)
Lev Walkin4da95cf2010-10-16 02:46:32 -07005676 func_arith $number_major + $number_minor
5677 current=$func_arith_result
Lev Walkin8e8b5482004-06-17 23:42:48 +00005678 age="$number_minor"
5679 revision="$number_minor"
Lev Walkin4da95cf2010-10-16 02:46:32 -07005680 lt_irix_increment=no
Lev Walkin8e8b5482004-06-17 23:42:48 +00005681 ;;
5682 esac
5683 ;;
5684 no)
Lev Walkin4da95cf2010-10-16 02:46:32 -07005685 current="$1"
5686 revision="$2"
5687 age="$3"
Lev Walkin8e8b5482004-06-17 23:42:48 +00005688 ;;
5689 esac
Lev Walkinf15320b2004-06-03 03:38:44 +00005690
5691 # Check that each of the things are valid numbers.
Lev Walkin8e8b5482004-06-17 23:42:48 +00005692 case $current in
Lev Walkin4da95cf2010-10-16 02:46:32 -07005693 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]) ;;
Lev Walkinf15320b2004-06-03 03:38:44 +00005694 *)
Lev Walkin4da95cf2010-10-16 02:46:32 -07005695 func_error "CURRENT \`$current' must be a nonnegative integer"
5696 func_fatal_error "\`$vinfo' is not valid version information"
Lev Walkinf15320b2004-06-03 03:38:44 +00005697 ;;
5698 esac
5699
Lev Walkin8e8b5482004-06-17 23:42:48 +00005700 case $revision in
Lev Walkin4da95cf2010-10-16 02:46:32 -07005701 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]) ;;
Lev Walkinf15320b2004-06-03 03:38:44 +00005702 *)
Lev Walkin4da95cf2010-10-16 02:46:32 -07005703 func_error "REVISION \`$revision' must be a nonnegative integer"
5704 func_fatal_error "\`$vinfo' is not valid version information"
Lev Walkinf15320b2004-06-03 03:38:44 +00005705 ;;
5706 esac
5707
Lev Walkin8e8b5482004-06-17 23:42:48 +00005708 case $age in
Lev Walkin4da95cf2010-10-16 02:46:32 -07005709 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]) ;;
Lev Walkinf15320b2004-06-03 03:38:44 +00005710 *)
Lev Walkin4da95cf2010-10-16 02:46:32 -07005711 func_error "AGE \`$age' must be a nonnegative integer"
5712 func_fatal_error "\`$vinfo' is not valid version information"
Lev Walkinf15320b2004-06-03 03:38:44 +00005713 ;;
5714 esac
5715
Lev Walkin8e8b5482004-06-17 23:42:48 +00005716 if test "$age" -gt "$current"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07005717 func_error "AGE \`$age' is greater than the current interface number \`$current'"
5718 func_fatal_error "\`$vinfo' is not valid version information"
Lev Walkinf15320b2004-06-03 03:38:44 +00005719 fi
5720
5721 # Calculate the version variables.
5722 major=
5723 versuffix=
5724 verstring=
Lev Walkin8e8b5482004-06-17 23:42:48 +00005725 case $version_type in
Lev Walkinf15320b2004-06-03 03:38:44 +00005726 none) ;;
5727
Lev Walkin8e8b5482004-06-17 23:42:48 +00005728 darwin)
5729 # Like Linux, but with the current version available in
5730 # verstring for coding it into the library header
Lev Walkin4da95cf2010-10-16 02:46:32 -07005731 func_arith $current - $age
5732 major=.$func_arith_result
Lev Walkin8e8b5482004-06-17 23:42:48 +00005733 versuffix="$major.$age.$revision"
5734 # Darwin ld doesn't like 0 for these options...
Lev Walkin4da95cf2010-10-16 02:46:32 -07005735 func_arith $current + 1
5736 minor_current=$func_arith_result
5737 xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
Lev Walkin8e8b5482004-06-17 23:42:48 +00005738 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
5739 ;;
5740
5741 freebsd-aout)
5742 major=".$current"
5743 versuffix=".$current.$revision";
5744 ;;
5745
5746 freebsd-elf)
5747 major=".$current"
Lev Walkin4da95cf2010-10-16 02:46:32 -07005748 versuffix=".$current"
Lev Walkin8e8b5482004-06-17 23:42:48 +00005749 ;;
5750
5751 irix | nonstopux)
Lev Walkin4da95cf2010-10-16 02:46:32 -07005752 if test "X$lt_irix_increment" = "Xno"; then
5753 func_arith $current - $age
5754 else
5755 func_arith $current - $age + 1
5756 fi
5757 major=$func_arith_result
Lev Walkin8e8b5482004-06-17 23:42:48 +00005758
5759 case $version_type in
5760 nonstopux) verstring_prefix=nonstopux ;;
5761 *) verstring_prefix=sgi ;;
5762 esac
5763 verstring="$verstring_prefix$major.$revision"
Lev Walkinf15320b2004-06-03 03:38:44 +00005764
5765 # Add in all the interfaces that we are compatible with.
5766 loop=$revision
Lev Walkin8e8b5482004-06-17 23:42:48 +00005767 while test "$loop" -ne 0; do
Lev Walkin4da95cf2010-10-16 02:46:32 -07005768 func_arith $revision - $loop
5769 iface=$func_arith_result
5770 func_arith $loop - 1
5771 loop=$func_arith_result
Lev Walkin8e8b5482004-06-17 23:42:48 +00005772 verstring="$verstring_prefix$major.$iface:$verstring"
Lev Walkinf15320b2004-06-03 03:38:44 +00005773 done
Lev Walkin8e8b5482004-06-17 23:42:48 +00005774
5775 # Before this point, $major must not contain `.'.
5776 major=.$major
5777 versuffix="$major.$revision"
Lev Walkinf15320b2004-06-03 03:38:44 +00005778 ;;
5779
5780 linux)
Lev Walkin4da95cf2010-10-16 02:46:32 -07005781 func_arith $current - $age
5782 major=.$func_arith_result
Lev Walkinf15320b2004-06-03 03:38:44 +00005783 versuffix="$major.$age.$revision"
5784 ;;
5785
5786 osf)
Lev Walkin4da95cf2010-10-16 02:46:32 -07005787 func_arith $current - $age
5788 major=.$func_arith_result
Lev Walkinf15320b2004-06-03 03:38:44 +00005789 versuffix=".$current.$age.$revision"
5790 verstring="$current.$age.$revision"
5791
5792 # Add in all the interfaces that we are compatible with.
5793 loop=$age
Lev Walkin8e8b5482004-06-17 23:42:48 +00005794 while test "$loop" -ne 0; do
Lev Walkin4da95cf2010-10-16 02:46:32 -07005795 func_arith $current - $loop
5796 iface=$func_arith_result
5797 func_arith $loop - 1
5798 loop=$func_arith_result
Lev Walkinf15320b2004-06-03 03:38:44 +00005799 verstring="$verstring:${iface}.0"
5800 done
5801
5802 # Make executables depend on our current version.
Lev Walkine7c4b962010-11-09 03:10:36 -08005803 verstring="$verstring:${current}.0"
Lev Walkin4da95cf2010-10-16 02:46:32 -07005804 ;;
5805
5806 qnx)
5807 major=".$current"
5808 versuffix=".$current"
Lev Walkinf15320b2004-06-03 03:38:44 +00005809 ;;
5810
5811 sunos)
5812 major=".$current"
5813 versuffix=".$current.$revision"
5814 ;;
5815
Lev Walkinf15320b2004-06-03 03:38:44 +00005816 windows)
Lev Walkin8e8b5482004-06-17 23:42:48 +00005817 # Use '-' rather than '.', since we only want one
5818 # extension on DOS 8.3 filesystems.
Lev Walkin4da95cf2010-10-16 02:46:32 -07005819 func_arith $current - $age
5820 major=$func_arith_result
Lev Walkin8e8b5482004-06-17 23:42:48 +00005821 versuffix="-$major"
Lev Walkinf15320b2004-06-03 03:38:44 +00005822 ;;
5823
5824 *)
Lev Walkin4da95cf2010-10-16 02:46:32 -07005825 func_fatal_configuration "unknown library version type \`$version_type'"
Lev Walkinf15320b2004-06-03 03:38:44 +00005826 ;;
5827 esac
5828
5829 # Clear the version info if we defaulted, and they specified a release.
5830 if test -z "$vinfo" && test -n "$release"; then
5831 major=
Lev Walkin8e8b5482004-06-17 23:42:48 +00005832 case $version_type in
5833 darwin)
5834 # we can't check for "0.0" in archive_cmds due to quoting
5835 # problems, so we reset it completely
5836 verstring=
5837 ;;
5838 *)
5839 verstring="0.0"
5840 ;;
5841 esac
Lev Walkinf15320b2004-06-03 03:38:44 +00005842 if test "$need_version" = no; then
5843 versuffix=
5844 else
5845 versuffix=".0.0"
5846 fi
5847 fi
5848
5849 # Remove version info from name if versioning should be avoided
5850 if test "$avoid_version" = yes && test "$need_version" = no; then
5851 major=
5852 versuffix=
5853 verstring=""
5854 fi
Lev Walkin8e8b5482004-06-17 23:42:48 +00005855
Lev Walkinf15320b2004-06-03 03:38:44 +00005856 # Check to see if the archive will have undefined symbols.
5857 if test "$allow_undefined" = yes; then
5858 if test "$allow_undefined_flag" = unsupported; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07005859 func_warning "undefined symbols not allowed in $host shared libraries"
Lev Walkinf15320b2004-06-03 03:38:44 +00005860 build_libtool_libs=no
5861 build_old_libs=yes
5862 fi
5863 else
5864 # Don't allow undefined symbols.
5865 allow_undefined_flag="$no_undefined_flag"
5866 fi
Lev Walkin4da95cf2010-10-16 02:46:32 -07005867
Lev Walkinf15320b2004-06-03 03:38:44 +00005868 fi
5869
Lev Walkin4da95cf2010-10-16 02:46:32 -07005870 func_generate_dlsyms "$libname" "$libname" "yes"
Lev Walkine7c4b962010-11-09 03:10:36 -08005871 libobjs="$libobjs $symfileobj"
Lev Walkin4da95cf2010-10-16 02:46:32 -07005872 test "X$libobjs" = "X " && libobjs=
5873
Lev Walkine7c4b962010-11-09 03:10:36 -08005874 if test "$mode" != relink; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00005875 # Remove our outputs, but don't remove object files since they
5876 # may have been created when compiling PIC objects.
5877 removelist=
Lev Walkin4da95cf2010-10-16 02:46:32 -07005878 tempremovelist=`$ECHO "$output_objdir/*"`
Lev Walkin8e8b5482004-06-17 23:42:48 +00005879 for p in $tempremovelist; do
5880 case $p in
Lev Walkine7c4b962010-11-09 03:10:36 -08005881 *.$objext)
Lev Walkin8e8b5482004-06-17 23:42:48 +00005882 ;;
5883 $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
5884 if test "X$precious_files_regex" != "X"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07005885 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
5886 then
Lev Walkin8e8b5482004-06-17 23:42:48 +00005887 continue
5888 fi
5889 fi
Lev Walkine7c4b962010-11-09 03:10:36 -08005890 removelist="$removelist $p"
Lev Walkin8e8b5482004-06-17 23:42:48 +00005891 ;;
5892 *) ;;
Lev Walkinf15320b2004-06-03 03:38:44 +00005893 esac
5894 done
Lev Walkin4da95cf2010-10-16 02:46:32 -07005895 test -n "$removelist" && \
5896 func_show_eval "${RM}r \$removelist"
Lev Walkinf15320b2004-06-03 03:38:44 +00005897 fi
5898
5899 # Now set the variables for building old libraries.
5900 if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
Lev Walkine7c4b962010-11-09 03:10:36 -08005901 oldlibs="$oldlibs $output_objdir/$libname.$libext"
Lev Walkinf15320b2004-06-03 03:38:44 +00005902
5903 # Transform .lo files to .o files.
Lev Walkine7c4b962010-11-09 03:10:36 -08005904 oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
Lev Walkinf15320b2004-06-03 03:38:44 +00005905 fi
5906
Lev Walkin8e8b5482004-06-17 23:42:48 +00005907 # Eliminate all temporary directories.
Lev Walkin4da95cf2010-10-16 02:46:32 -07005908 #for path in $notinst_path; do
Lev Walkine7c4b962010-11-09 03:10:36 -08005909 # lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"`
5910 # deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"`
5911 # dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"`
Lev Walkin4da95cf2010-10-16 02:46:32 -07005912 #done
Lev Walkin8e8b5482004-06-17 23:42:48 +00005913
5914 if test -n "$xrpath"; then
5915 # If the user specified any rpath flags, then add them.
5916 temp_xrpath=
5917 for libdir in $xrpath; do
Lev Walkine7c4b962010-11-09 03:10:36 -08005918 temp_xrpath="$temp_xrpath -R$libdir"
Lev Walkin8e8b5482004-06-17 23:42:48 +00005919 case "$finalize_rpath " in
5920 *" $libdir "*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08005921 *) finalize_rpath="$finalize_rpath $libdir" ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00005922 esac
5923 done
5924 if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
5925 dependency_libs="$temp_xrpath $dependency_libs"
5926 fi
5927 fi
5928
5929 # Make sure dlfiles contains only unique files that won't be dlpreopened
5930 old_dlfiles="$dlfiles"
5931 dlfiles=
5932 for lib in $old_dlfiles; do
5933 case " $dlprefiles $dlfiles " in
5934 *" $lib "*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08005935 *) dlfiles="$dlfiles $lib" ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00005936 esac
5937 done
5938
5939 # Make sure dlprefiles contains only unique files
5940 old_dlprefiles="$dlprefiles"
5941 dlprefiles=
5942 for lib in $old_dlprefiles; do
5943 case "$dlprefiles " in
5944 *" $lib "*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08005945 *) dlprefiles="$dlprefiles $lib" ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00005946 esac
5947 done
5948
Lev Walkinf15320b2004-06-03 03:38:44 +00005949 if test "$build_libtool_libs" = yes; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00005950 if test -n "$rpath"; then
5951 case $host in
Lev Walkine7c4b962010-11-09 03:10:36 -08005952 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
Lev Walkin8e8b5482004-06-17 23:42:48 +00005953 # these systems don't actually have a c library (as such)!
5954 ;;
5955 *-*-rhapsody* | *-*-darwin1.[012])
5956 # Rhapsody C library is in the System framework
Lev Walkine7c4b962010-11-09 03:10:36 -08005957 deplibs="$deplibs System.ltframework"
Lev Walkin8e8b5482004-06-17 23:42:48 +00005958 ;;
5959 *-*-netbsd*)
5960 # Don't link with libc until the a.out ld.so is fixed.
5961 ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07005962 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
Lev Walkin8e8b5482004-06-17 23:42:48 +00005963 # Do not include libc due to us having libc/libc_r.
Lev Walkin8e8b5482004-06-17 23:42:48 +00005964 ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07005965 *-*-sco3.2v5* | *-*-sco5v6*)
5966 # Causes problems with __ctype
5967 ;;
5968 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
5969 # Compiler inserts libc in the correct place for threads to work
5970 ;;
5971 *)
Lev Walkin8e8b5482004-06-17 23:42:48 +00005972 # Add libc to deplibs on all other systems if necessary.
5973 if test "$build_libtool_need_lc" = "yes"; then
Lev Walkine7c4b962010-11-09 03:10:36 -08005974 deplibs="$deplibs -lc"
Lev Walkin8e8b5482004-06-17 23:42:48 +00005975 fi
5976 ;;
5977 esac
5978 fi
5979
Lev Walkinf15320b2004-06-03 03:38:44 +00005980 # Transform deplibs into only deplibs that can be linked in shared.
5981 name_save=$name
5982 libname_save=$libname
5983 release_save=$release
5984 versuffix_save=$versuffix
5985 major_save=$major
5986 # I'm not sure if I'm treating the release correctly. I think
5987 # release should show up in the -l (ie -lgmp5) so we don't want to
5988 # add it in twice. Is that correct?
5989 release=""
5990 versuffix=""
5991 major=""
5992 newdeplibs=
5993 droppeddeps=no
Lev Walkin8e8b5482004-06-17 23:42:48 +00005994 case $deplibs_check_method in
Lev Walkinf15320b2004-06-03 03:38:44 +00005995 pass_all)
5996 # Don't check for shared/static. Everything works.
5997 # This might be a little naive. We might want to check
5998 # whether the library exists or not. But this is on
5999 # osf3 & osf4 and I'm not really sure... Just
Lev Walkin8e8b5482004-06-17 23:42:48 +00006000 # implementing what was already the behavior.
Lev Walkinf15320b2004-06-03 03:38:44 +00006001 newdeplibs=$deplibs
6002 ;;
6003 test_compile)
6004 # This code stresses the "libraries are programs" paradigm to its
6005 # limits. Maybe even breaks it. We compile a program, linking it
6006 # against the deplibs as a proxy for the library. Then we can check
6007 # whether they linked in statically or dynamically with ldd.
Lev Walkin4da95cf2010-10-16 02:46:32 -07006008 $opt_dry_run || $RM conftest.c
Lev Walkinf15320b2004-06-03 03:38:44 +00006009 cat > conftest.c <<EOF
6010 int main() { return 0; }
6011EOF
Lev Walkin4da95cf2010-10-16 02:46:32 -07006012 $opt_dry_run || $RM conftest
6013 if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
Lev Walkinf15320b2004-06-03 03:38:44 +00006014 ldd_output=`ldd conftest`
6015 for i in $deplibs; do
Lev Walkin4da95cf2010-10-16 02:46:32 -07006016 case $i in
6017 -l*)
6018 func_stripname -l '' "$i"
6019 name=$func_stripname_result
Lev Walkin8e8b5482004-06-17 23:42:48 +00006020 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6021 case " $predeps $postdeps " in
6022 *" $i "*)
Lev Walkine7c4b962010-11-09 03:10:36 -08006023 newdeplibs="$newdeplibs $i"
Lev Walkin8e8b5482004-06-17 23:42:48 +00006024 i=""
6025 ;;
6026 esac
Lev Walkin4da95cf2010-10-16 02:46:32 -07006027 fi
Lev Walkin8e8b5482004-06-17 23:42:48 +00006028 if test -n "$i" ; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07006029 libname=`eval "\\$ECHO \"$libname_spec\""`
6030 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
6031 set dummy $deplib_matches; shift
6032 deplib_match=$1
Lev Walkinf15320b2004-06-03 03:38:44 +00006033 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
Lev Walkine7c4b962010-11-09 03:10:36 -08006034 newdeplibs="$newdeplibs $i"
Lev Walkinf15320b2004-06-03 03:38:44 +00006035 else
6036 droppeddeps=yes
Lev Walkine7c4b962010-11-09 03:10:36 -08006037 $ECHO
Lev Walkin4da95cf2010-10-16 02:46:32 -07006038 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
Lev Walkine7c4b962010-11-09 03:10:36 -08006039 $ECHO "*** I have the capability to make that library automatically link in when"
6040 $ECHO "*** you link to this library. But I can only do this if you have a"
6041 $ECHO "*** shared version of the library, which I believe you do not have"
6042 $ECHO "*** because a test_compile did reveal that the linker did not use it for"
6043 $ECHO "*** its dynamic dependency list that programs get resolved with at runtime."
Lev Walkin8e8b5482004-06-17 23:42:48 +00006044 fi
6045 fi
Lev Walkin4da95cf2010-10-16 02:46:32 -07006046 ;;
6047 *)
Lev Walkine7c4b962010-11-09 03:10:36 -08006048 newdeplibs="$newdeplibs $i"
Lev Walkin4da95cf2010-10-16 02:46:32 -07006049 ;;
6050 esac
Lev Walkin8e8b5482004-06-17 23:42:48 +00006051 done
6052 else
6053 # Error occurred in the first compile. Let's try to salvage
6054 # the situation: Compile a separate program for each library.
6055 for i in $deplibs; do
Lev Walkin4da95cf2010-10-16 02:46:32 -07006056 case $i in
6057 -l*)
6058 func_stripname -l '' "$i"
6059 name=$func_stripname_result
6060 $opt_dry_run || $RM conftest
6061 if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00006062 ldd_output=`ldd conftest`
6063 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6064 case " $predeps $postdeps " in
6065 *" $i "*)
Lev Walkine7c4b962010-11-09 03:10:36 -08006066 newdeplibs="$newdeplibs $i"
Lev Walkin8e8b5482004-06-17 23:42:48 +00006067 i=""
6068 ;;
6069 esac
6070 fi
6071 if test -n "$i" ; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07006072 libname=`eval "\\$ECHO \"$libname_spec\""`
6073 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
6074 set dummy $deplib_matches; shift
6075 deplib_match=$1
Lev Walkin8e8b5482004-06-17 23:42:48 +00006076 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
Lev Walkine7c4b962010-11-09 03:10:36 -08006077 newdeplibs="$newdeplibs $i"
Lev Walkin8e8b5482004-06-17 23:42:48 +00006078 else
6079 droppeddeps=yes
Lev Walkine7c4b962010-11-09 03:10:36 -08006080 $ECHO
Lev Walkin4da95cf2010-10-16 02:46:32 -07006081 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
Lev Walkine7c4b962010-11-09 03:10:36 -08006082 $ECHO "*** I have the capability to make that library automatically link in when"
6083 $ECHO "*** you link to this library. But I can only do this if you have a"
6084 $ECHO "*** shared version of the library, which you do not appear to have"
6085 $ECHO "*** because a test_compile did reveal that the linker did not use this one"
6086 $ECHO "*** as a dynamic dependency that programs can get resolved with at runtime."
Lev Walkin8e8b5482004-06-17 23:42:48 +00006087 fi
Lev Walkinf15320b2004-06-03 03:38:44 +00006088 fi
6089 else
6090 droppeddeps=yes
Lev Walkine7c4b962010-11-09 03:10:36 -08006091 $ECHO
Lev Walkin4da95cf2010-10-16 02:46:32 -07006092 $ECHO "*** Warning! Library $i is needed by this library but I was not able to"
Lev Walkine7c4b962010-11-09 03:10:36 -08006093 $ECHO "*** make it link in! You will probably need to install it or some"
6094 $ECHO "*** library that it depends on before this library will be fully"
6095 $ECHO "*** functional. Installing it before continuing would be even better."
Lev Walkinf15320b2004-06-03 03:38:44 +00006096 fi
Lev Walkin4da95cf2010-10-16 02:46:32 -07006097 ;;
6098 *)
Lev Walkine7c4b962010-11-09 03:10:36 -08006099 newdeplibs="$newdeplibs $i"
Lev Walkin4da95cf2010-10-16 02:46:32 -07006100 ;;
6101 esac
Lev Walkinf15320b2004-06-03 03:38:44 +00006102 done
6103 fi
6104 ;;
6105 file_magic*)
Lev Walkin4da95cf2010-10-16 02:46:32 -07006106 set dummy $deplibs_check_method; shift
6107 file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
Lev Walkinf15320b2004-06-03 03:38:44 +00006108 for a_deplib in $deplibs; do
Lev Walkin4da95cf2010-10-16 02:46:32 -07006109 case $a_deplib in
6110 -l*)
6111 func_stripname -l '' "$a_deplib"
6112 name=$func_stripname_result
Lev Walkin8e8b5482004-06-17 23:42:48 +00006113 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6114 case " $predeps $postdeps " in
6115 *" $a_deplib "*)
Lev Walkine7c4b962010-11-09 03:10:36 -08006116 newdeplibs="$newdeplibs $a_deplib"
Lev Walkin8e8b5482004-06-17 23:42:48 +00006117 a_deplib=""
6118 ;;
6119 esac
6120 fi
6121 if test -n "$a_deplib" ; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07006122 libname=`eval "\\$ECHO \"$libname_spec\""`
Lev Walkin8e8b5482004-06-17 23:42:48 +00006123 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
Lev Walkine7c4b962010-11-09 03:10:36 -08006124 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
Lev Walkin8e8b5482004-06-17 23:42:48 +00006125 for potent_lib in $potential_libs; do
Lev Walkinf15320b2004-06-03 03:38:44 +00006126 # Follow soft links.
Lev Walkin4da95cf2010-10-16 02:46:32 -07006127 if ls -lLd "$potent_lib" 2>/dev/null |
6128 $GREP " -> " >/dev/null; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00006129 continue
Lev Walkinf15320b2004-06-03 03:38:44 +00006130 fi
6131 # The statement above tries to avoid entering an
6132 # endless loop below, in case of cyclic links.
6133 # We might still enter an endless loop, since a link
6134 # loop can be closed while we follow links,
6135 # but so what?
6136 potlib="$potent_lib"
6137 while test -h "$potlib" 2>/dev/null; do
Lev Walkin8e8b5482004-06-17 23:42:48 +00006138 potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
6139 case $potliblink in
Lev Walkinf15320b2004-06-03 03:38:44 +00006140 [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
Lev Walkine7c4b962010-11-09 03:10:36 -08006141 *) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
Lev Walkinf15320b2004-06-03 03:38:44 +00006142 esac
6143 done
Lev Walkin4da95cf2010-10-16 02:46:32 -07006144 if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
6145 $SED -e 10q |
6146 $EGREP "$file_magic_regex" > /dev/null; then
Lev Walkine7c4b962010-11-09 03:10:36 -08006147 newdeplibs="$newdeplibs $a_deplib"
Lev Walkinf15320b2004-06-03 03:38:44 +00006148 a_deplib=""
6149 break 2
6150 fi
Lev Walkin8e8b5482004-06-17 23:42:48 +00006151 done
6152 done
6153 fi
Lev Walkinf15320b2004-06-03 03:38:44 +00006154 if test -n "$a_deplib" ; then
6155 droppeddeps=yes
Lev Walkine7c4b962010-11-09 03:10:36 -08006156 $ECHO
Lev Walkin4da95cf2010-10-16 02:46:32 -07006157 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
Lev Walkine7c4b962010-11-09 03:10:36 -08006158 $ECHO "*** I have the capability to make that library automatically link in when"
6159 $ECHO "*** you link to this library. But I can only do this if you have a"
6160 $ECHO "*** shared version of the library, which you do not appear to have"
6161 $ECHO "*** because I did check the linker path looking for a file starting"
Lev Walkin8e8b5482004-06-17 23:42:48 +00006162 if test -z "$potlib" ; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07006163 $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
Lev Walkin8e8b5482004-06-17 23:42:48 +00006164 else
Lev Walkin4da95cf2010-10-16 02:46:32 -07006165 $ECHO "*** with $libname and none of the candidates passed a file format test"
6166 $ECHO "*** using a file magic. Last file checked: $potlib"
Lev Walkin8e8b5482004-06-17 23:42:48 +00006167 fi
6168 fi
Lev Walkin4da95cf2010-10-16 02:46:32 -07006169 ;;
6170 *)
Lev Walkin8e8b5482004-06-17 23:42:48 +00006171 # Add a -L argument.
Lev Walkine7c4b962010-11-09 03:10:36 -08006172 newdeplibs="$newdeplibs $a_deplib"
Lev Walkin4da95cf2010-10-16 02:46:32 -07006173 ;;
6174 esac
Lev Walkin8e8b5482004-06-17 23:42:48 +00006175 done # Gone through all deplibs.
6176 ;;
6177 match_pattern*)
Lev Walkin4da95cf2010-10-16 02:46:32 -07006178 set dummy $deplibs_check_method; shift
6179 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
Lev Walkin8e8b5482004-06-17 23:42:48 +00006180 for a_deplib in $deplibs; do
Lev Walkin4da95cf2010-10-16 02:46:32 -07006181 case $a_deplib in
6182 -l*)
6183 func_stripname -l '' "$a_deplib"
6184 name=$func_stripname_result
Lev Walkin8e8b5482004-06-17 23:42:48 +00006185 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6186 case " $predeps $postdeps " in
6187 *" $a_deplib "*)
Lev Walkine7c4b962010-11-09 03:10:36 -08006188 newdeplibs="$newdeplibs $a_deplib"
Lev Walkin8e8b5482004-06-17 23:42:48 +00006189 a_deplib=""
6190 ;;
6191 esac
6192 fi
6193 if test -n "$a_deplib" ; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07006194 libname=`eval "\\$ECHO \"$libname_spec\""`
Lev Walkin8e8b5482004-06-17 23:42:48 +00006195 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
6196 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
6197 for potent_lib in $potential_libs; do
6198 potlib="$potent_lib" # see symlink-check above in file_magic test
Lev Walkine7c4b962010-11-09 03:10:36 -08006199 if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \
Lev Walkin4da95cf2010-10-16 02:46:32 -07006200 $EGREP "$match_pattern_regex" > /dev/null; then
Lev Walkine7c4b962010-11-09 03:10:36 -08006201 newdeplibs="$newdeplibs $a_deplib"
Lev Walkin8e8b5482004-06-17 23:42:48 +00006202 a_deplib=""
6203 break 2
6204 fi
6205 done
6206 done
6207 fi
6208 if test -n "$a_deplib" ; then
6209 droppeddeps=yes
Lev Walkine7c4b962010-11-09 03:10:36 -08006210 $ECHO
Lev Walkin4da95cf2010-10-16 02:46:32 -07006211 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
Lev Walkine7c4b962010-11-09 03:10:36 -08006212 $ECHO "*** I have the capability to make that library automatically link in when"
6213 $ECHO "*** you link to this library. But I can only do this if you have a"
6214 $ECHO "*** shared version of the library, which you do not appear to have"
6215 $ECHO "*** because I did check the linker path looking for a file starting"
Lev Walkin8e8b5482004-06-17 23:42:48 +00006216 if test -z "$potlib" ; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07006217 $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
Lev Walkin8e8b5482004-06-17 23:42:48 +00006218 else
Lev Walkin4da95cf2010-10-16 02:46:32 -07006219 $ECHO "*** with $libname and none of the candidates passed a file format test"
6220 $ECHO "*** using a regex pattern. Last file checked: $potlib"
Lev Walkin8e8b5482004-06-17 23:42:48 +00006221 fi
Lev Walkinf15320b2004-06-03 03:38:44 +00006222 fi
Lev Walkin4da95cf2010-10-16 02:46:32 -07006223 ;;
6224 *)
Lev Walkinf15320b2004-06-03 03:38:44 +00006225 # Add a -L argument.
Lev Walkine7c4b962010-11-09 03:10:36 -08006226 newdeplibs="$newdeplibs $a_deplib"
Lev Walkin4da95cf2010-10-16 02:46:32 -07006227 ;;
6228 esac
Lev Walkinf15320b2004-06-03 03:38:44 +00006229 done # Gone through all deplibs.
6230 ;;
6231 none | unknown | *)
6232 newdeplibs=""
Lev Walkine7c4b962010-11-09 03:10:36 -08006233 tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \
6234 -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'`
Lev Walkin8e8b5482004-06-17 23:42:48 +00006235 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6236 for i in $predeps $postdeps ; do
6237 # can't use Xsed below, because $i might contain '/'
Lev Walkine7c4b962010-11-09 03:10:36 -08006238 tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"`
Lev Walkin8e8b5482004-06-17 23:42:48 +00006239 done
6240 fi
Lev Walkine7c4b962010-11-09 03:10:36 -08006241 if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' |
6242 $GREP . >/dev/null; then
6243 $ECHO
Lev Walkinf15320b2004-06-03 03:38:44 +00006244 if test "X$deplibs_check_method" = "Xnone"; then
Lev Walkine7c4b962010-11-09 03:10:36 -08006245 $ECHO "*** Warning: inter-library dependencies are not supported in this platform."
Lev Walkinf15320b2004-06-03 03:38:44 +00006246 else
Lev Walkine7c4b962010-11-09 03:10:36 -08006247 $ECHO "*** Warning: inter-library dependencies are not known to be supported."
Lev Walkinf15320b2004-06-03 03:38:44 +00006248 fi
Lev Walkine7c4b962010-11-09 03:10:36 -08006249 $ECHO "*** All declared inter-library dependencies are being dropped."
Lev Walkinf15320b2004-06-03 03:38:44 +00006250 droppeddeps=yes
Lev Walkine7c4b962010-11-09 03:10:36 -08006251 fi
Lev Walkinf15320b2004-06-03 03:38:44 +00006252 ;;
6253 esac
6254 versuffix=$versuffix_save
6255 major=$major_save
6256 release=$release_save
6257 libname=$libname_save
6258 name=$name_save
6259
Lev Walkin8e8b5482004-06-17 23:42:48 +00006260 case $host in
6261 *-*-rhapsody* | *-*-darwin1.[012])
Lev Walkin4da95cf2010-10-16 02:46:32 -07006262 # On Rhapsody replace the C library with the System framework
Lev Walkine7c4b962010-11-09 03:10:36 -08006263 newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
Lev Walkin8e8b5482004-06-17 23:42:48 +00006264 ;;
6265 esac
6266
Lev Walkinf15320b2004-06-03 03:38:44 +00006267 if test "$droppeddeps" = yes; then
6268 if test "$module" = yes; then
Lev Walkine7c4b962010-11-09 03:10:36 -08006269 $ECHO
6270 $ECHO "*** Warning: libtool could not satisfy all declared inter-library"
Lev Walkin4da95cf2010-10-16 02:46:32 -07006271 $ECHO "*** dependencies of module $libname. Therefore, libtool will create"
Lev Walkine7c4b962010-11-09 03:10:36 -08006272 $ECHO "*** a static module, that should work as long as the dlopening"
6273 $ECHO "*** application is linked with the -dlopen flag."
Lev Walkinf15320b2004-06-03 03:38:44 +00006274 if test -z "$global_symbol_pipe"; then
Lev Walkine7c4b962010-11-09 03:10:36 -08006275 $ECHO
6276 $ECHO "*** However, this would only work if libtool was able to extract symbol"
6277 $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
6278 $ECHO "*** not find such a program. So, this module is probably useless."
6279 $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
Lev Walkinf15320b2004-06-03 03:38:44 +00006280 fi
6281 if test "$build_old_libs" = no; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00006282 oldlibs="$output_objdir/$libname.$libext"
Lev Walkinf15320b2004-06-03 03:38:44 +00006283 build_libtool_libs=module
6284 build_old_libs=yes
6285 else
6286 build_libtool_libs=no
6287 fi
6288 else
Lev Walkine7c4b962010-11-09 03:10:36 -08006289 $ECHO "*** The inter-library dependencies that have been dropped here will be"
6290 $ECHO "*** automatically added whenever a program is linked with this library"
6291 $ECHO "*** or is declared to -dlopen it."
Lev Walkin8e8b5482004-06-17 23:42:48 +00006292
6293 if test "$allow_undefined" = no; then
Lev Walkine7c4b962010-11-09 03:10:36 -08006294 $ECHO
6295 $ECHO "*** Since this library must not contain undefined symbols,"
6296 $ECHO "*** because either the platform does not support them or"
6297 $ECHO "*** it was explicitly requested with -no-undefined,"
6298 $ECHO "*** libtool will only create a static version of it."
Lev Walkin8e8b5482004-06-17 23:42:48 +00006299 if test "$build_old_libs" = no; then
6300 oldlibs="$output_objdir/$libname.$libext"
6301 build_libtool_libs=module
6302 build_old_libs=yes
6303 else
6304 build_libtool_libs=no
6305 fi
6306 fi
Lev Walkinf15320b2004-06-03 03:38:44 +00006307 fi
6308 fi
6309 # Done checking deplibs!
6310 deplibs=$newdeplibs
6311 fi
Lev Walkin4da95cf2010-10-16 02:46:32 -07006312 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
6313 case $host in
6314 *-*-darwin*)
Lev Walkine7c4b962010-11-09 03:10:36 -08006315 newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6316 new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6317 deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
Lev Walkin4da95cf2010-10-16 02:46:32 -07006318 ;;
6319 esac
6320
6321 # move library search paths that coincide with paths to not yet
6322 # installed libraries to the beginning of the library search list
6323 new_libs=
6324 for path in $notinst_path; do
6325 case " $new_libs " in
6326 *" -L$path/$objdir "*) ;;
6327 *)
6328 case " $deplibs " in
6329 *" -L$path/$objdir "*)
Lev Walkine7c4b962010-11-09 03:10:36 -08006330 new_libs="$new_libs -L$path/$objdir" ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07006331 esac
6332 ;;
6333 esac
6334 done
6335 for deplib in $deplibs; do
6336 case $deplib in
6337 -L*)
6338 case " $new_libs " in
6339 *" $deplib "*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08006340 *) new_libs="$new_libs $deplib" ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07006341 esac
6342 ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08006343 *) new_libs="$new_libs $deplib" ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07006344 esac
6345 done
6346 deplibs="$new_libs"
Lev Walkinf15320b2004-06-03 03:38:44 +00006347
6348 # All the library-specific variables (install_libdir is set above).
6349 library_names=
6350 old_library=
6351 dlname=
Lev Walkin8e8b5482004-06-17 23:42:48 +00006352
Lev Walkinf15320b2004-06-03 03:38:44 +00006353 # Test again, we may have decided not to build it any more
6354 if test "$build_libtool_libs" = yes; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00006355 if test "$hardcode_into_libs" = yes; then
6356 # Hardcode the library paths
6357 hardcode_libdirs=
6358 dep_rpath=
6359 rpath="$finalize_rpath"
Lev Walkine7c4b962010-11-09 03:10:36 -08006360 test "$mode" != relink && rpath="$compile_rpath$rpath"
Lev Walkin8e8b5482004-06-17 23:42:48 +00006361 for libdir in $rpath; do
6362 if test -n "$hardcode_libdir_flag_spec"; then
6363 if test -n "$hardcode_libdir_separator"; then
6364 if test -z "$hardcode_libdirs"; then
6365 hardcode_libdirs="$libdir"
6366 else
6367 # Just accumulate the unique libdirs.
6368 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
6369 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
6370 ;;
6371 *)
Lev Walkine7c4b962010-11-09 03:10:36 -08006372 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
Lev Walkin8e8b5482004-06-17 23:42:48 +00006373 ;;
6374 esac
6375 fi
6376 else
6377 eval flag=\"$hardcode_libdir_flag_spec\"
Lev Walkine7c4b962010-11-09 03:10:36 -08006378 dep_rpath="$dep_rpath $flag"
Lev Walkin8e8b5482004-06-17 23:42:48 +00006379 fi
6380 elif test -n "$runpath_var"; then
6381 case "$perm_rpath " in
6382 *" $libdir "*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08006383 *) perm_rpath="$perm_rpath $libdir" ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00006384 esac
6385 fi
6386 done
6387 # Substitute the hardcoded libdirs into the rpath.
6388 if test -n "$hardcode_libdir_separator" &&
6389 test -n "$hardcode_libdirs"; then
6390 libdir="$hardcode_libdirs"
6391 if test -n "$hardcode_libdir_flag_spec_ld"; then
6392 eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
6393 else
6394 eval dep_rpath=\"$hardcode_libdir_flag_spec\"
6395 fi
6396 fi
6397 if test -n "$runpath_var" && test -n "$perm_rpath"; then
6398 # We should set the runpath_var.
6399 rpath=
6400 for dir in $perm_rpath; do
Lev Walkine7c4b962010-11-09 03:10:36 -08006401 rpath="$rpath$dir:"
Lev Walkin8e8b5482004-06-17 23:42:48 +00006402 done
6403 eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
6404 fi
6405 test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
6406 fi
6407
6408 shlibpath="$finalize_shlibpath"
Lev Walkine7c4b962010-11-09 03:10:36 -08006409 test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
Lev Walkin8e8b5482004-06-17 23:42:48 +00006410 if test -n "$shlibpath"; then
6411 eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
6412 fi
6413
Lev Walkinf15320b2004-06-03 03:38:44 +00006414 # Get the real and link names of the library.
Lev Walkin8e8b5482004-06-17 23:42:48 +00006415 eval shared_ext=\"$shrext_cmds\"
Lev Walkinf15320b2004-06-03 03:38:44 +00006416 eval library_names=\"$library_names_spec\"
6417 set dummy $library_names
Lev Walkin4da95cf2010-10-16 02:46:32 -07006418 shift
6419 realname="$1"
6420 shift
Lev Walkinf15320b2004-06-03 03:38:44 +00006421
6422 if test -n "$soname_spec"; then
6423 eval soname=\"$soname_spec\"
6424 else
6425 soname="$realname"
6426 fi
Lev Walkin8e8b5482004-06-17 23:42:48 +00006427 if test -z "$dlname"; then
6428 dlname=$soname
6429 fi
Lev Walkinf15320b2004-06-03 03:38:44 +00006430
6431 lib="$output_objdir/$realname"
Lev Walkin4da95cf2010-10-16 02:46:32 -07006432 linknames=
Lev Walkinf15320b2004-06-03 03:38:44 +00006433 for link
6434 do
Lev Walkine7c4b962010-11-09 03:10:36 -08006435 linknames="$linknames $link"
Lev Walkinf15320b2004-06-03 03:38:44 +00006436 done
6437
Lev Walkinf15320b2004-06-03 03:38:44 +00006438 # Use standard objects if they are pic
Lev Walkine7c4b962010-11-09 03:10:36 -08006439 test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
Lev Walkin4da95cf2010-10-16 02:46:32 -07006440 test "X$libobjs" = "X " && libobjs=
6441
6442 delfiles=
6443 if test -n "$export_symbols" && test -n "$include_expsyms"; then
6444 $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
6445 export_symbols="$output_objdir/$libname.uexp"
Lev Walkine7c4b962010-11-09 03:10:36 -08006446 delfiles="$delfiles $export_symbols"
Lev Walkin4da95cf2010-10-16 02:46:32 -07006447 fi
6448
6449 orig_export_symbols=
6450 case $host_os in
Lev Walkine7c4b962010-11-09 03:10:36 -08006451 cygwin* | mingw*)
Lev Walkin4da95cf2010-10-16 02:46:32 -07006452 if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
6453 # exporting using user supplied symfile
6454 if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
6455 # and it's NOT already a .def file. Must figure out
6456 # which of the given symbols are data symbols and tag
6457 # them as such. So, trigger use of export_symbols_cmds.
6458 # export_symbols gets reassigned inside the "prepare
6459 # the list of exported symbols" if statement, so the
6460 # include_expsyms logic still works.
6461 orig_export_symbols="$export_symbols"
6462 export_symbols=
6463 always_export_symbols=yes
6464 fi
6465 fi
6466 ;;
6467 esac
Lev Walkinf15320b2004-06-03 03:38:44 +00006468
6469 # Prepare the list of exported symbols
6470 if test -z "$export_symbols"; then
6471 if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07006472 func_verbose "generating symbol list for \`$libname.la'"
Lev Walkinf15320b2004-06-03 03:38:44 +00006473 export_symbols="$output_objdir/$libname.exp"
Lev Walkin4da95cf2010-10-16 02:46:32 -07006474 $opt_dry_run || $RM $export_symbols
Lev Walkin8e8b5482004-06-17 23:42:48 +00006475 cmds=$export_symbols_cmds
6476 save_ifs="$IFS"; IFS='~'
Lev Walkine7c4b962010-11-09 03:10:36 -08006477 for cmd in $cmds; do
Lev Walkinf15320b2004-06-03 03:38:44 +00006478 IFS="$save_ifs"
Lev Walkine7c4b962010-11-09 03:10:36 -08006479 eval cmd=\"$cmd\"
6480 func_len " $cmd"
6481 len=$func_len_result
6482 if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07006483 func_show_eval "$cmd" 'exit $?'
6484 skipped_export=false
Lev Walkin8e8b5482004-06-17 23:42:48 +00006485 else
Lev Walkin4da95cf2010-10-16 02:46:32 -07006486 # The command line is too long to execute in one step.
6487 func_verbose "using reloadable object file for export list..."
6488 skipped_export=:
6489 # Break out early, otherwise skipped_export may be
6490 # set to false by a later but shorter cmd.
6491 break
Lev Walkin8e8b5482004-06-17 23:42:48 +00006492 fi
Lev Walkinf15320b2004-06-03 03:38:44 +00006493 done
6494 IFS="$save_ifs"
Lev Walkin4da95cf2010-10-16 02:46:32 -07006495 if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
6496 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
6497 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
Lev Walkinf15320b2004-06-03 03:38:44 +00006498 fi
6499 fi
6500 fi
6501
6502 if test -n "$export_symbols" && test -n "$include_expsyms"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07006503 tmp_export_symbols="$export_symbols"
6504 test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
Lev Walkine7c4b962010-11-09 03:10:36 -08006505 $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
Lev Walkin4da95cf2010-10-16 02:46:32 -07006506 fi
6507
6508 if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
6509 # The given exports_symbols file has to be filtered, so filter it.
6510 func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
6511 # FIXME: $output_objdir/$libname.filter potentially contains lots of
6512 # 's' commands which not all seds can handle. GNU sed should be fine
6513 # though. Also, the filter scales superlinearly with the number of
6514 # global variables. join(1) would be nice here, but unfortunately
6515 # isn't a blessed tool.
6516 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
Lev Walkine7c4b962010-11-09 03:10:36 -08006517 delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
Lev Walkin4da95cf2010-10-16 02:46:32 -07006518 export_symbols=$output_objdir/$libname.def
6519 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
Lev Walkinf15320b2004-06-03 03:38:44 +00006520 fi
6521
Lev Walkin8e8b5482004-06-17 23:42:48 +00006522 tmp_deplibs=
6523 for test_deplib in $deplibs; do
Lev Walkin4da95cf2010-10-16 02:46:32 -07006524 case " $convenience " in
6525 *" $test_deplib "*) ;;
6526 *)
Lev Walkine7c4b962010-11-09 03:10:36 -08006527 tmp_deplibs="$tmp_deplibs $test_deplib"
Lev Walkin4da95cf2010-10-16 02:46:32 -07006528 ;;
6529 esac
Lev Walkin8e8b5482004-06-17 23:42:48 +00006530 done
6531 deplibs="$tmp_deplibs"
6532
Lev Walkinf15320b2004-06-03 03:38:44 +00006533 if test -n "$convenience"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07006534 if test -n "$whole_archive_flag_spec" &&
6535 test "$compiler_needs_object" = yes &&
6536 test -z "$libobjs"; then
6537 # extract the archives, so we have objects to list.
6538 # TODO: could optimize this to just extract one archive.
6539 whole_archive_flag_spec=
6540 fi
Lev Walkinf15320b2004-06-03 03:38:44 +00006541 if test -n "$whole_archive_flag_spec"; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00006542 save_libobjs=$libobjs
Lev Walkinf15320b2004-06-03 03:38:44 +00006543 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
Lev Walkin4da95cf2010-10-16 02:46:32 -07006544 test "X$libobjs" = "X " && libobjs=
Lev Walkinf15320b2004-06-03 03:38:44 +00006545 else
6546 gentop="$output_objdir/${outputname}x"
Lev Walkine7c4b962010-11-09 03:10:36 -08006547 generated="$generated $gentop"
Lev Walkinf15320b2004-06-03 03:38:44 +00006548
Lev Walkin4da95cf2010-10-16 02:46:32 -07006549 func_extract_archives $gentop $convenience
Lev Walkine7c4b962010-11-09 03:10:36 -08006550 libobjs="$libobjs $func_extract_archives_result"
Lev Walkin4da95cf2010-10-16 02:46:32 -07006551 test "X$libobjs" = "X " && libobjs=
Lev Walkinf15320b2004-06-03 03:38:44 +00006552 fi
6553 fi
6554
6555 if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
6556 eval flag=\"$thread_safe_flag_spec\"
Lev Walkine7c4b962010-11-09 03:10:36 -08006557 linker_flags="$linker_flags $flag"
Lev Walkin8e8b5482004-06-17 23:42:48 +00006558 fi
6559
6560 # Make a backup of the uninstalled library when relinking
Lev Walkine7c4b962010-11-09 03:10:36 -08006561 if test "$mode" = relink; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07006562 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
Lev Walkinf15320b2004-06-03 03:38:44 +00006563 fi
6564
6565 # Do each of the archive commands.
Lev Walkin8e8b5482004-06-17 23:42:48 +00006566 if test "$module" = yes && test -n "$module_cmds" ; then
6567 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
6568 eval test_cmds=\"$module_expsym_cmds\"
6569 cmds=$module_expsym_cmds
6570 else
6571 eval test_cmds=\"$module_cmds\"
6572 cmds=$module_cmds
6573 fi
Lev Walkinf15320b2004-06-03 03:38:44 +00006574 else
Lev Walkin4da95cf2010-10-16 02:46:32 -07006575 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
6576 eval test_cmds=\"$archive_expsym_cmds\"
6577 cmds=$archive_expsym_cmds
6578 else
6579 eval test_cmds=\"$archive_cmds\"
6580 cmds=$archive_cmds
Lev Walkin8e8b5482004-06-17 23:42:48 +00006581 fi
Lev Walkinf15320b2004-06-03 03:38:44 +00006582 fi
Lev Walkin8e8b5482004-06-17 23:42:48 +00006583
Lev Walkin4da95cf2010-10-16 02:46:32 -07006584 if test "X$skipped_export" != "X:" &&
6585 func_len " $test_cmds" &&
6586 len=$func_len_result &&
6587 test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00006588 :
6589 else
Lev Walkin4da95cf2010-10-16 02:46:32 -07006590 # The command line is too long to link in one step, link piecewise
6591 # or, if using GNU ld and skipped_export is not :, use a linker
6592 # script.
Lev Walkin8e8b5482004-06-17 23:42:48 +00006593
6594 # Save the value of $output and $libobjs because we want to
6595 # use them later. If we have whole_archive_flag_spec, we
6596 # want to use save_libobjs as it was before
6597 # whole_archive_flag_spec was expanded, because we can't
6598 # assume the linker understands whole_archive_flag_spec.
6599 # This may have to be revisited, in case too many
6600 # convenience libraries get linked in and end up exceeding
6601 # the spec.
6602 if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
6603 save_libobjs=$libobjs
6604 fi
6605 save_output=$output
Lev Walkine7c4b962010-11-09 03:10:36 -08006606 output_la=`$ECHO "X$output" | $Xsed -e "$basename"`
Lev Walkin8e8b5482004-06-17 23:42:48 +00006607
6608 # Clear the reloadable object creation command queue and
6609 # initialize k to one.
6610 test_cmds=
6611 concat_cmds=
6612 objlist=
Lev Walkin8e8b5482004-06-17 23:42:48 +00006613 last_robj=
6614 k=1
Lev Walkin4da95cf2010-10-16 02:46:32 -07006615
6616 if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
6617 output=${output_objdir}/${output_la}.lnkscript
6618 func_verbose "creating GNU ld script: $output"
Lev Walkine7c4b962010-11-09 03:10:36 -08006619 $ECHO 'INPUT (' > $output
Lev Walkin4da95cf2010-10-16 02:46:32 -07006620 for obj in $save_libobjs
6621 do
Lev Walkine7c4b962010-11-09 03:10:36 -08006622 $ECHO "$obj" >> $output
Lev Walkin4da95cf2010-10-16 02:46:32 -07006623 done
Lev Walkine7c4b962010-11-09 03:10:36 -08006624 $ECHO ')' >> $output
6625 delfiles="$delfiles $output"
Lev Walkin4da95cf2010-10-16 02:46:32 -07006626 elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
6627 output=${output_objdir}/${output_la}.lnk
6628 func_verbose "creating linker input file list: $output"
6629 : > $output
6630 set x $save_libobjs
6631 shift
6632 firstobj=
6633 if test "$compiler_needs_object" = yes; then
6634 firstobj="$1 "
6635 shift
Lev Walkin8e8b5482004-06-17 23:42:48 +00006636 fi
Lev Walkin4da95cf2010-10-16 02:46:32 -07006637 for obj
6638 do
Lev Walkine7c4b962010-11-09 03:10:36 -08006639 $ECHO "$obj" >> $output
Lev Walkin4da95cf2010-10-16 02:46:32 -07006640 done
Lev Walkine7c4b962010-11-09 03:10:36 -08006641 delfiles="$delfiles $output"
6642 output=$firstobj\"$file_list_spec$output\"
Lev Walkin4da95cf2010-10-16 02:46:32 -07006643 else
6644 if test -n "$save_libobjs"; then
6645 func_verbose "creating reloadable object files..."
6646 output=$output_objdir/$output_la-${k}.$objext
6647 eval test_cmds=\"$reload_cmds\"
6648 func_len " $test_cmds"
6649 len0=$func_len_result
6650 len=$len0
Lev Walkin8e8b5482004-06-17 23:42:48 +00006651
Lev Walkin4da95cf2010-10-16 02:46:32 -07006652 # Loop over the list of objects to be linked.
6653 for obj in $save_libobjs
6654 do
6655 func_len " $obj"
6656 func_arith $len + $func_len_result
6657 len=$func_arith_result
6658 if test "X$objlist" = X ||
6659 test "$len" -lt "$max_cmd_len"; then
6660 func_append objlist " $obj"
6661 else
6662 # The command $test_cmds is almost too long, add a
6663 # command to the queue.
6664 if test "$k" -eq 1 ; then
6665 # The first file doesn't have a previous command to add.
Lev Walkine7c4b962010-11-09 03:10:36 -08006666 eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
Lev Walkin4da95cf2010-10-16 02:46:32 -07006667 else
6668 # All subsequent reloadable object files will link in
6669 # the last one created.
Lev Walkine7c4b962010-11-09 03:10:36 -08006670 eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\"
Lev Walkin4da95cf2010-10-16 02:46:32 -07006671 fi
6672 last_robj=$output_objdir/$output_la-${k}.$objext
6673 func_arith $k + 1
6674 k=$func_arith_result
6675 output=$output_objdir/$output_la-${k}.$objext
Lev Walkine7c4b962010-11-09 03:10:36 -08006676 objlist=$obj
Lev Walkin4da95cf2010-10-16 02:46:32 -07006677 func_len " $last_robj"
6678 func_arith $len0 + $func_len_result
6679 len=$func_arith_result
6680 fi
6681 done
6682 # Handle the remaining objects by creating one last
6683 # reloadable object file. All subsequent reloadable object
6684 # files will link in the last one created.
6685 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
Lev Walkine7c4b962010-11-09 03:10:36 -08006686 eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
Lev Walkin4da95cf2010-10-16 02:46:32 -07006687 if test -n "$last_robj"; then
6688 eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
6689 fi
Lev Walkine7c4b962010-11-09 03:10:36 -08006690 delfiles="$delfiles $output"
Lev Walkin8e8b5482004-06-17 23:42:48 +00006691
Lev Walkin4da95cf2010-10-16 02:46:32 -07006692 else
6693 output=
6694 fi
Lev Walkin8e8b5482004-06-17 23:42:48 +00006695
Lev Walkin4da95cf2010-10-16 02:46:32 -07006696 if ${skipped_export-false}; then
6697 func_verbose "generating symbol list for \`$libname.la'"
6698 export_symbols="$output_objdir/$libname.exp"
6699 $opt_dry_run || $RM $export_symbols
6700 libobjs=$output
6701 # Append the command to create the export file.
6702 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
6703 eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
6704 if test -n "$last_robj"; then
6705 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
6706 fi
6707 fi
Lev Walkin8e8b5482004-06-17 23:42:48 +00006708
Lev Walkin4da95cf2010-10-16 02:46:32 -07006709 test -n "$save_libobjs" &&
6710 func_verbose "creating a temporary reloadable object file: $output"
6711
6712 # Loop through the commands generated above and execute them.
6713 save_ifs="$IFS"; IFS='~'
6714 for cmd in $concat_cmds; do
6715 IFS="$save_ifs"
6716 $opt_silent || {
6717 func_quote_for_expand "$cmd"
6718 eval "func_echo $func_quote_for_expand_result"
6719 }
6720 $opt_dry_run || eval "$cmd" || {
6721 lt_exit=$?
6722
6723 # Restore the uninstalled library and exit
Lev Walkine7c4b962010-11-09 03:10:36 -08006724 if test "$mode" = relink; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07006725 ( cd "$output_objdir" && \
6726 $RM "${realname}T" && \
6727 $MV "${realname}U" "$realname" )
6728 fi
6729
6730 exit $lt_exit
6731 }
6732 done
Lev Walkin8e8b5482004-06-17 23:42:48 +00006733 IFS="$save_ifs"
Lev Walkin4da95cf2010-10-16 02:46:32 -07006734
6735 if test -n "$export_symbols_regex" && ${skipped_export-false}; then
6736 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
6737 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
6738 fi
6739 fi
6740
6741 if ${skipped_export-false}; then
6742 if test -n "$export_symbols" && test -n "$include_expsyms"; then
6743 tmp_export_symbols="$export_symbols"
6744 test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
Lev Walkine7c4b962010-11-09 03:10:36 -08006745 $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
Lev Walkin4da95cf2010-10-16 02:46:32 -07006746 fi
6747
6748 if test -n "$orig_export_symbols"; then
6749 # The given exports_symbols file has to be filtered, so filter it.
6750 func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
6751 # FIXME: $output_objdir/$libname.filter potentially contains lots of
6752 # 's' commands which not all seds can handle. GNU sed should be fine
6753 # though. Also, the filter scales superlinearly with the number of
6754 # global variables. join(1) would be nice here, but unfortunately
6755 # isn't a blessed tool.
6756 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
Lev Walkine7c4b962010-11-09 03:10:36 -08006757 delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
Lev Walkin4da95cf2010-10-16 02:46:32 -07006758 export_symbols=$output_objdir/$libname.def
6759 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
6760 fi
6761 fi
Lev Walkin8e8b5482004-06-17 23:42:48 +00006762
6763 libobjs=$output
6764 # Restore the value of output.
6765 output=$save_output
6766
6767 if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
6768 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
Lev Walkin4da95cf2010-10-16 02:46:32 -07006769 test "X$libobjs" = "X " && libobjs=
Lev Walkin8e8b5482004-06-17 23:42:48 +00006770 fi
6771 # Expand the library linking commands again to reset the
6772 # value of $libobjs for piecewise linking.
6773
6774 # Do each of the archive commands.
6775 if test "$module" = yes && test -n "$module_cmds" ; then
6776 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
6777 cmds=$module_expsym_cmds
6778 else
6779 cmds=$module_cmds
6780 fi
6781 else
Lev Walkin4da95cf2010-10-16 02:46:32 -07006782 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
6783 cmds=$archive_expsym_cmds
6784 else
6785 cmds=$archive_cmds
Lev Walkin8e8b5482004-06-17 23:42:48 +00006786 fi
6787 fi
Lev Walkin8e8b5482004-06-17 23:42:48 +00006788 fi
Lev Walkin4da95cf2010-10-16 02:46:32 -07006789
6790 if test -n "$delfiles"; then
6791 # Append the command to remove temporary files to $cmds.
6792 eval cmds=\"\$cmds~\$RM $delfiles\"
6793 fi
6794
6795 # Add any objects from preloaded convenience libraries
6796 if test -n "$dlprefiles"; then
6797 gentop="$output_objdir/${outputname}x"
Lev Walkine7c4b962010-11-09 03:10:36 -08006798 generated="$generated $gentop"
Lev Walkin4da95cf2010-10-16 02:46:32 -07006799
6800 func_extract_archives $gentop $dlprefiles
Lev Walkine7c4b962010-11-09 03:10:36 -08006801 libobjs="$libobjs $func_extract_archives_result"
Lev Walkin4da95cf2010-10-16 02:46:32 -07006802 test "X$libobjs" = "X " && libobjs=
6803 fi
6804
Lev Walkin8e8b5482004-06-17 23:42:48 +00006805 save_ifs="$IFS"; IFS='~'
Lev Walkinf15320b2004-06-03 03:38:44 +00006806 for cmd in $cmds; do
6807 IFS="$save_ifs"
Lev Walkin8e8b5482004-06-17 23:42:48 +00006808 eval cmd=\"$cmd\"
Lev Walkin4da95cf2010-10-16 02:46:32 -07006809 $opt_silent || {
6810 func_quote_for_expand "$cmd"
6811 eval "func_echo $func_quote_for_expand_result"
6812 }
6813 $opt_dry_run || eval "$cmd" || {
6814 lt_exit=$?
6815
6816 # Restore the uninstalled library and exit
Lev Walkine7c4b962010-11-09 03:10:36 -08006817 if test "$mode" = relink; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07006818 ( cd "$output_objdir" && \
6819 $RM "${realname}T" && \
6820 $MV "${realname}U" "$realname" )
6821 fi
6822
6823 exit $lt_exit
6824 }
Lev Walkinf15320b2004-06-03 03:38:44 +00006825 done
6826 IFS="$save_ifs"
6827
Lev Walkin8e8b5482004-06-17 23:42:48 +00006828 # Restore the uninstalled library and exit
Lev Walkine7c4b962010-11-09 03:10:36 -08006829 if test "$mode" = relink; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07006830 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
6831
6832 if test -n "$convenience"; then
6833 if test -z "$whole_archive_flag_spec"; then
6834 func_show_eval '${RM}r "$gentop"'
6835 fi
6836 fi
6837
Lev Walkin8e8b5482004-06-17 23:42:48 +00006838 exit $EXIT_SUCCESS
6839 fi
6840
Lev Walkinf15320b2004-06-03 03:38:44 +00006841 # Create links to the real library.
6842 for linkname in $linknames; do
6843 if test "$realname" != "$linkname"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07006844 func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
Lev Walkinf15320b2004-06-03 03:38:44 +00006845 fi
6846 done
6847
6848 # If -module or -export-dynamic was specified, set the dlname.
6849 if test "$module" = yes || test "$export_dynamic" = yes; then
6850 # On all known operating systems, these are identical.
6851 dlname="$soname"
6852 fi
6853 fi
6854 ;;
6855
Lev Walkin8e8b5482004-06-17 23:42:48 +00006856 obj)
Lev Walkinf15320b2004-06-03 03:38:44 +00006857 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07006858 func_warning "\`-dlopen' is ignored for objects"
Lev Walkinf15320b2004-06-03 03:38:44 +00006859 fi
6860
Lev Walkin4da95cf2010-10-16 02:46:32 -07006861 case " $deplibs" in
6862 *\ -l* | *\ -L*)
6863 func_warning "\`-l' and \`-L' are ignored for objects" ;;
6864 esac
Lev Walkinf15320b2004-06-03 03:38:44 +00006865
Lev Walkin4da95cf2010-10-16 02:46:32 -07006866 test -n "$rpath" && \
6867 func_warning "\`-rpath' is ignored for objects"
Lev Walkinf15320b2004-06-03 03:38:44 +00006868
Lev Walkin4da95cf2010-10-16 02:46:32 -07006869 test -n "$xrpath" && \
6870 func_warning "\`-R' is ignored for objects"
Lev Walkinf15320b2004-06-03 03:38:44 +00006871
Lev Walkin4da95cf2010-10-16 02:46:32 -07006872 test -n "$vinfo" && \
6873 func_warning "\`-version-info' is ignored for objects"
6874
6875 test -n "$release" && \
6876 func_warning "\`-release' is ignored for objects"
Lev Walkinf15320b2004-06-03 03:38:44 +00006877
Lev Walkin8e8b5482004-06-17 23:42:48 +00006878 case $output in
Lev Walkinf15320b2004-06-03 03:38:44 +00006879 *.lo)
Lev Walkin4da95cf2010-10-16 02:46:32 -07006880 test -n "$objs$old_deplibs" && \
6881 func_fatal_error "cannot build library object \`$output' from non-libtool objects"
6882
6883 libobj=$output
6884 func_lo2o "$libobj"
6885 obj=$func_lo2o_result
Lev Walkinf15320b2004-06-03 03:38:44 +00006886 ;;
6887 *)
6888 libobj=
6889 obj="$output"
6890 ;;
6891 esac
6892
6893 # Delete the old objects.
Lev Walkin4da95cf2010-10-16 02:46:32 -07006894 $opt_dry_run || $RM $obj $libobj
Lev Walkinf15320b2004-06-03 03:38:44 +00006895
6896 # Objects from convenience libraries. This assumes
6897 # single-version convenience libraries. Whenever we create
6898 # different ones for PIC/non-PIC, this we'll have to duplicate
6899 # the extraction.
6900 reload_conv_objs=
6901 gentop=
6902 # reload_cmds runs $LD directly, so let us get rid of
Lev Walkin4da95cf2010-10-16 02:46:32 -07006903 # -Wl from whole_archive_flag_spec and hope we can get by with
6904 # turning comma into space..
Lev Walkin8e8b5482004-06-17 23:42:48 +00006905 wl=
Lev Walkinf15320b2004-06-03 03:38:44 +00006906
6907 if test -n "$convenience"; then
6908 if test -n "$whole_archive_flag_spec"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07006909 eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
Lev Walkine7c4b962010-11-09 03:10:36 -08006910 reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
Lev Walkinf15320b2004-06-03 03:38:44 +00006911 else
6912 gentop="$output_objdir/${obj}x"
Lev Walkine7c4b962010-11-09 03:10:36 -08006913 generated="$generated $gentop"
Lev Walkinf15320b2004-06-03 03:38:44 +00006914
Lev Walkin4da95cf2010-10-16 02:46:32 -07006915 func_extract_archives $gentop $convenience
6916 reload_conv_objs="$reload_objs $func_extract_archives_result"
Lev Walkinf15320b2004-06-03 03:38:44 +00006917 fi
6918 fi
6919
6920 # Create the old-style object.
Lev Walkine7c4b962010-11-09 03:10:36 -08006921 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
Lev Walkinf15320b2004-06-03 03:38:44 +00006922
6923 output="$obj"
Lev Walkin4da95cf2010-10-16 02:46:32 -07006924 func_execute_cmds "$reload_cmds" 'exit $?'
Lev Walkinf15320b2004-06-03 03:38:44 +00006925
6926 # Exit if we aren't doing a library object file.
6927 if test -z "$libobj"; then
6928 if test -n "$gentop"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07006929 func_show_eval '${RM}r "$gentop"'
Lev Walkinf15320b2004-06-03 03:38:44 +00006930 fi
6931
Lev Walkin8e8b5482004-06-17 23:42:48 +00006932 exit $EXIT_SUCCESS
Lev Walkinf15320b2004-06-03 03:38:44 +00006933 fi
6934
6935 if test "$build_libtool_libs" != yes; then
6936 if test -n "$gentop"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07006937 func_show_eval '${RM}r "$gentop"'
Lev Walkinf15320b2004-06-03 03:38:44 +00006938 fi
6939
6940 # Create an invalid libtool object if no PIC, so that we don't
6941 # accidentally link it into a program.
Lev Walkin8e8b5482004-06-17 23:42:48 +00006942 # $show "echo timestamp > $libobj"
Lev Walkin4da95cf2010-10-16 02:46:32 -07006943 # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
Lev Walkin8e8b5482004-06-17 23:42:48 +00006944 exit $EXIT_SUCCESS
Lev Walkinf15320b2004-06-03 03:38:44 +00006945 fi
6946
Lev Walkin8e8b5482004-06-17 23:42:48 +00006947 if test -n "$pic_flag" || test "$pic_mode" != default; then
Lev Walkinf15320b2004-06-03 03:38:44 +00006948 # Only do commands if we really have different PIC objects.
6949 reload_objs="$libobjs $reload_conv_objs"
6950 output="$libobj"
Lev Walkin4da95cf2010-10-16 02:46:32 -07006951 func_execute_cmds "$reload_cmds" 'exit $?'
Lev Walkinf15320b2004-06-03 03:38:44 +00006952 fi
6953
6954 if test -n "$gentop"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07006955 func_show_eval '${RM}r "$gentop"'
Lev Walkinf15320b2004-06-03 03:38:44 +00006956 fi
6957
Lev Walkin8e8b5482004-06-17 23:42:48 +00006958 exit $EXIT_SUCCESS
Lev Walkinf15320b2004-06-03 03:38:44 +00006959 ;;
6960
Lev Walkin8e8b5482004-06-17 23:42:48 +00006961 prog)
6962 case $host in
Lev Walkin4da95cf2010-10-16 02:46:32 -07006963 *cygwin*) func_stripname '' '.exe' "$output"
6964 output=$func_stripname_result.exe;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00006965 esac
Lev Walkin4da95cf2010-10-16 02:46:32 -07006966 test -n "$vinfo" && \
6967 func_warning "\`-version-info' is ignored for programs"
Lev Walkinf15320b2004-06-03 03:38:44 +00006968
Lev Walkin4da95cf2010-10-16 02:46:32 -07006969 test -n "$release" && \
6970 func_warning "\`-release' is ignored for programs"
Lev Walkinf15320b2004-06-03 03:38:44 +00006971
Lev Walkin4da95cf2010-10-16 02:46:32 -07006972 test "$preload" = yes \
6973 && test "$dlopen_support" = unknown \
6974 && test "$dlopen_self" = unknown \
6975 && test "$dlopen_self_static" = unknown && \
6976 func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
Lev Walkin8e8b5482004-06-17 23:42:48 +00006977
6978 case $host in
6979 *-*-rhapsody* | *-*-darwin1.[012])
6980 # On Rhapsody replace the C library is the System framework
Lev Walkine7c4b962010-11-09 03:10:36 -08006981 compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
6982 finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
Lev Walkin8e8b5482004-06-17 23:42:48 +00006983 ;;
6984 esac
6985
6986 case $host in
Lev Walkin4da95cf2010-10-16 02:46:32 -07006987 *-*-darwin*)
6988 # Don't allow lazy linking, it breaks C++ global constructors
6989 # But is supposedly fixed on 10.4 or later (yay!).
6990 if test "$tagname" = CXX ; then
6991 case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
6992 10.[0123])
Lev Walkine7c4b962010-11-09 03:10:36 -08006993 compile_command="$compile_command ${wl}-bind_at_load"
6994 finalize_command="$finalize_command ${wl}-bind_at_load"
Lev Walkin4da95cf2010-10-16 02:46:32 -07006995 ;;
6996 esac
6997 fi
6998 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
Lev Walkine7c4b962010-11-09 03:10:36 -08006999 compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
7000 finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
Lev Walkin4da95cf2010-10-16 02:46:32 -07007001 ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00007002 esac
7003
Lev Walkin4da95cf2010-10-16 02:46:32 -07007004
7005 # move library search paths that coincide with paths to not yet
7006 # installed libraries to the beginning of the library search list
7007 new_libs=
7008 for path in $notinst_path; do
7009 case " $new_libs " in
7010 *" -L$path/$objdir "*) ;;
7011 *)
7012 case " $compile_deplibs " in
7013 *" -L$path/$objdir "*)
Lev Walkine7c4b962010-11-09 03:10:36 -08007014 new_libs="$new_libs -L$path/$objdir" ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07007015 esac
7016 ;;
7017 esac
7018 done
7019 for deplib in $compile_deplibs; do
7020 case $deplib in
7021 -L*)
7022 case " $new_libs " in
7023 *" $deplib "*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08007024 *) new_libs="$new_libs $deplib" ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07007025 esac
7026 ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08007027 *) new_libs="$new_libs $deplib" ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07007028 esac
7029 done
7030 compile_deplibs="$new_libs"
7031
7032
Lev Walkine7c4b962010-11-09 03:10:36 -08007033 compile_command="$compile_command $compile_deplibs"
7034 finalize_command="$finalize_command $finalize_deplibs"
Lev Walkin8e8b5482004-06-17 23:42:48 +00007035
Lev Walkinf15320b2004-06-03 03:38:44 +00007036 if test -n "$rpath$xrpath"; then
7037 # If the user specified any rpath flags, then add them.
7038 for libdir in $rpath $xrpath; do
7039 # This is the magic to use -rpath.
Lev Walkinf15320b2004-06-03 03:38:44 +00007040 case "$finalize_rpath " in
7041 *" $libdir "*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08007042 *) finalize_rpath="$finalize_rpath $libdir" ;;
Lev Walkinf15320b2004-06-03 03:38:44 +00007043 esac
7044 done
7045 fi
7046
7047 # Now hardcode the library paths
7048 rpath=
7049 hardcode_libdirs=
7050 for libdir in $compile_rpath $finalize_rpath; do
7051 if test -n "$hardcode_libdir_flag_spec"; then
7052 if test -n "$hardcode_libdir_separator"; then
7053 if test -z "$hardcode_libdirs"; then
7054 hardcode_libdirs="$libdir"
7055 else
7056 # Just accumulate the unique libdirs.
Lev Walkin8e8b5482004-06-17 23:42:48 +00007057 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
Lev Walkinf15320b2004-06-03 03:38:44 +00007058 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
7059 ;;
7060 *)
Lev Walkine7c4b962010-11-09 03:10:36 -08007061 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
Lev Walkinf15320b2004-06-03 03:38:44 +00007062 ;;
7063 esac
7064 fi
7065 else
7066 eval flag=\"$hardcode_libdir_flag_spec\"
Lev Walkine7c4b962010-11-09 03:10:36 -08007067 rpath="$rpath $flag"
Lev Walkinf15320b2004-06-03 03:38:44 +00007068 fi
7069 elif test -n "$runpath_var"; then
7070 case "$perm_rpath " in
7071 *" $libdir "*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08007072 *) perm_rpath="$perm_rpath $libdir" ;;
Lev Walkinf15320b2004-06-03 03:38:44 +00007073 esac
7074 fi
Lev Walkin8e8b5482004-06-17 23:42:48 +00007075 case $host in
Lev Walkine7c4b962010-11-09 03:10:36 -08007076 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
Lev Walkin4da95cf2010-10-16 02:46:32 -07007077 testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
Lev Walkin8e8b5482004-06-17 23:42:48 +00007078 case :$dllsearchpath: in
7079 *":$libdir:"*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08007080 *) dllsearchpath="$dllsearchpath:$libdir";;
Lev Walkin4da95cf2010-10-16 02:46:32 -07007081 esac
7082 case :$dllsearchpath: in
7083 *":$testbindir:"*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08007084 *) dllsearchpath="$dllsearchpath:$testbindir";;
Lev Walkin8e8b5482004-06-17 23:42:48 +00007085 esac
7086 ;;
7087 esac
Lev Walkinf15320b2004-06-03 03:38:44 +00007088 done
7089 # Substitute the hardcoded libdirs into the rpath.
7090 if test -n "$hardcode_libdir_separator" &&
7091 test -n "$hardcode_libdirs"; then
7092 libdir="$hardcode_libdirs"
7093 eval rpath=\" $hardcode_libdir_flag_spec\"
7094 fi
7095 compile_rpath="$rpath"
7096
7097 rpath=
7098 hardcode_libdirs=
7099 for libdir in $finalize_rpath; do
7100 if test -n "$hardcode_libdir_flag_spec"; then
7101 if test -n "$hardcode_libdir_separator"; then
7102 if test -z "$hardcode_libdirs"; then
7103 hardcode_libdirs="$libdir"
7104 else
7105 # Just accumulate the unique libdirs.
Lev Walkin8e8b5482004-06-17 23:42:48 +00007106 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
Lev Walkinf15320b2004-06-03 03:38:44 +00007107 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
7108 ;;
7109 *)
Lev Walkine7c4b962010-11-09 03:10:36 -08007110 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
Lev Walkinf15320b2004-06-03 03:38:44 +00007111 ;;
7112 esac
7113 fi
7114 else
7115 eval flag=\"$hardcode_libdir_flag_spec\"
Lev Walkine7c4b962010-11-09 03:10:36 -08007116 rpath="$rpath $flag"
Lev Walkinf15320b2004-06-03 03:38:44 +00007117 fi
7118 elif test -n "$runpath_var"; then
7119 case "$finalize_perm_rpath " in
7120 *" $libdir "*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08007121 *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
Lev Walkinf15320b2004-06-03 03:38:44 +00007122 esac
7123 fi
7124 done
7125 # Substitute the hardcoded libdirs into the rpath.
7126 if test -n "$hardcode_libdir_separator" &&
7127 test -n "$hardcode_libdirs"; then
7128 libdir="$hardcode_libdirs"
7129 eval rpath=\" $hardcode_libdir_flag_spec\"
7130 fi
7131 finalize_rpath="$rpath"
7132
Lev Walkinf15320b2004-06-03 03:38:44 +00007133 if test -n "$libobjs" && test "$build_old_libs" = yes; then
7134 # Transform all the library objects into standard objects.
Lev Walkine7c4b962010-11-09 03:10:36 -08007135 compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
7136 finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
Lev Walkinf15320b2004-06-03 03:38:44 +00007137 fi
7138
Lev Walkin4da95cf2010-10-16 02:46:32 -07007139 func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
7140
7141 # template prelinking step
7142 if test -n "$prelink_cmds"; then
7143 func_execute_cmds "$prelink_cmds" 'exit $?'
Lev Walkinf15320b2004-06-03 03:38:44 +00007144 fi
7145
Lev Walkin4da95cf2010-10-16 02:46:32 -07007146 wrappers_required=yes
7147 case $host in
Lev Walkin4da95cf2010-10-16 02:46:32 -07007148 *cygwin* | *mingw* )
7149 if test "$build_libtool_libs" != yes; then
7150 wrappers_required=no
7151 fi
7152 ;;
7153 *)
7154 if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
7155 wrappers_required=no
7156 fi
7157 ;;
7158 esac
7159 if test "$wrappers_required" = no; then
Lev Walkinf15320b2004-06-03 03:38:44 +00007160 # Replace the output file specification.
Lev Walkine7c4b962010-11-09 03:10:36 -08007161 compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
Lev Walkinf15320b2004-06-03 03:38:44 +00007162 link_command="$compile_command$compile_rpath"
7163
7164 # We have no uninstalled library dependencies, so finalize right now.
Lev Walkin4da95cf2010-10-16 02:46:32 -07007165 exit_status=0
7166 func_show_eval "$link_command" 'exit_status=$?'
Lev Walkin8e8b5482004-06-17 23:42:48 +00007167
Lev Walkin4da95cf2010-10-16 02:46:32 -07007168 # Delete the generated files.
7169 if test -f "$output_objdir/${outputname}S.${objext}"; then
7170 func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
7171 fi
Lev Walkinf15320b2004-06-03 03:38:44 +00007172
Lev Walkin4da95cf2010-10-16 02:46:32 -07007173 exit $exit_status
Lev Walkinf15320b2004-06-03 03:38:44 +00007174 fi
7175
7176 if test -n "$compile_shlibpath$finalize_shlibpath"; then
7177 compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
7178 fi
7179 if test -n "$finalize_shlibpath"; then
7180 finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
7181 fi
7182
7183 compile_var=
7184 finalize_var=
7185 if test -n "$runpath_var"; then
7186 if test -n "$perm_rpath"; then
7187 # We should set the runpath_var.
7188 rpath=
7189 for dir in $perm_rpath; do
Lev Walkine7c4b962010-11-09 03:10:36 -08007190 rpath="$rpath$dir:"
Lev Walkinf15320b2004-06-03 03:38:44 +00007191 done
7192 compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
7193 fi
7194 if test -n "$finalize_perm_rpath"; then
7195 # We should set the runpath_var.
7196 rpath=
7197 for dir in $finalize_perm_rpath; do
Lev Walkine7c4b962010-11-09 03:10:36 -08007198 rpath="$rpath$dir:"
Lev Walkinf15320b2004-06-03 03:38:44 +00007199 done
7200 finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
7201 fi
7202 fi
7203
Lev Walkin8e8b5482004-06-17 23:42:48 +00007204 if test "$no_install" = yes; then
7205 # We don't need to create a wrapper script.
7206 link_command="$compile_var$compile_command$compile_rpath"
7207 # Replace the output file specification.
Lev Walkine7c4b962010-11-09 03:10:36 -08007208 link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
Lev Walkin8e8b5482004-06-17 23:42:48 +00007209 # Delete the old output file.
Lev Walkin4da95cf2010-10-16 02:46:32 -07007210 $opt_dry_run || $RM $output
Lev Walkin8e8b5482004-06-17 23:42:48 +00007211 # Link the executable and exit
Lev Walkin4da95cf2010-10-16 02:46:32 -07007212 func_show_eval "$link_command" 'exit $?'
Lev Walkin8e8b5482004-06-17 23:42:48 +00007213 exit $EXIT_SUCCESS
7214 fi
7215
Lev Walkinf15320b2004-06-03 03:38:44 +00007216 if test "$hardcode_action" = relink; then
7217 # Fast installation is not supported
7218 link_command="$compile_var$compile_command$compile_rpath"
7219 relink_command="$finalize_var$finalize_command$finalize_rpath"
Lev Walkin8e8b5482004-06-17 23:42:48 +00007220
Lev Walkin4da95cf2010-10-16 02:46:32 -07007221 func_warning "this platform does not like uninstalled shared libraries"
7222 func_warning "\`$output' will be relinked during installation"
Lev Walkinf15320b2004-06-03 03:38:44 +00007223 else
7224 if test "$fast_install" != no; then
7225 link_command="$finalize_var$compile_command$finalize_rpath"
7226 if test "$fast_install" = yes; then
Lev Walkine7c4b962010-11-09 03:10:36 -08007227 relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
Lev Walkinf15320b2004-06-03 03:38:44 +00007228 else
7229 # fast_install is set to needless
7230 relink_command=
7231 fi
7232 else
7233 link_command="$compile_var$compile_command$compile_rpath"
7234 relink_command="$finalize_var$finalize_command$finalize_rpath"
7235 fi
7236 fi
7237
7238 # Replace the output file specification.
Lev Walkine7c4b962010-11-09 03:10:36 -08007239 link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
Lev Walkin8e8b5482004-06-17 23:42:48 +00007240
Lev Walkinf15320b2004-06-03 03:38:44 +00007241 # Delete the old output files.
Lev Walkin4da95cf2010-10-16 02:46:32 -07007242 $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
Lev Walkinf15320b2004-06-03 03:38:44 +00007243
Lev Walkin4da95cf2010-10-16 02:46:32 -07007244 func_show_eval "$link_command" 'exit $?'
7245
Lev Walkinf15320b2004-06-03 03:38:44 +00007246 # Now create the wrapper script.
Lev Walkin4da95cf2010-10-16 02:46:32 -07007247 func_verbose "creating $output"
Lev Walkinf15320b2004-06-03 03:38:44 +00007248
7249 # Quote the relink command for shipping.
7250 if test -n "$relink_command"; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00007251 # Preserve any variables that may affect compiler behavior
7252 for var in $variables_saved_for_relink; do
7253 if eval test -z \"\${$var+set}\"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07007254 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
Lev Walkin8e8b5482004-06-17 23:42:48 +00007255 elif eval var_value=\$$var; test -z "$var_value"; then
7256 relink_command="$var=; export $var; $relink_command"
7257 else
Lev Walkin4da95cf2010-10-16 02:46:32 -07007258 func_quote_for_eval "$var_value"
7259 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
Lev Walkin8e8b5482004-06-17 23:42:48 +00007260 fi
7261 done
7262 relink_command="(cd `pwd`; $relink_command)"
Lev Walkine7c4b962010-11-09 03:10:36 -08007263 relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
7264 fi
7265
7266 # Quote $ECHO for shipping.
7267 if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then
7268 case $progpath in
7269 [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
7270 *) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
7271 esac
7272 qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"`
7273 else
7274 qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"`
Lev Walkinf15320b2004-06-03 03:38:44 +00007275 fi
7276
Lev Walkin4da95cf2010-10-16 02:46:32 -07007277 # Only actually do things if not in dry run mode.
7278 $opt_dry_run || {
Lev Walkinf15320b2004-06-03 03:38:44 +00007279 # win32 will think the script is a binary if it has
7280 # a .exe suffix, so we strip it off here.
7281 case $output in
Lev Walkin4da95cf2010-10-16 02:46:32 -07007282 *.exe) func_stripname '' '.exe' "$output"
7283 output=$func_stripname_result ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00007284 esac
7285 # test for cygwin because mv fails w/o .exe extensions
7286 case $host in
7287 *cygwin*)
7288 exeext=.exe
Lev Walkin4da95cf2010-10-16 02:46:32 -07007289 func_stripname '' '.exe' "$outputname"
7290 outputname=$func_stripname_result ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00007291 *) exeext= ;;
7292 esac
7293 case $host in
7294 *cygwin* | *mingw* )
Lev Walkin4da95cf2010-10-16 02:46:32 -07007295 func_dirname_and_basename "$output" "" "."
7296 output_name=$func_basename_result
7297 output_path=$func_dirname_result
7298 cwrappersource="$output_path/$objdir/lt-$output_name.c"
7299 cwrapper="$output_path/$output_name.exe"
7300 $RM $cwrappersource $cwrapper
7301 trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
Lev Walkin8e8b5482004-06-17 23:42:48 +00007302
Lev Walkin4da95cf2010-10-16 02:46:32 -07007303 func_emit_cwrapperexe_src > $cwrappersource
Lev Walkin8e8b5482004-06-17 23:42:48 +00007304
Lev Walkine7c4b962010-11-09 03:10:36 -08007305 # we should really use a build-platform specific compiler
7306 # here, but OTOH, the wrappers (shell script and this C one)
7307 # are only useful if you want to execute the "real" binary.
7308 # Since the "real" binary is built for $host, then this
7309 # wrapper might as well be built for $host, too.
Lev Walkin4da95cf2010-10-16 02:46:32 -07007310 $opt_dry_run || {
7311 $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
7312 $STRIP $cwrapper
7313 }
Lev Walkin8e8b5482004-06-17 23:42:48 +00007314
Lev Walkin4da95cf2010-10-16 02:46:32 -07007315 # Now, create the wrapper script for func_source use:
7316 func_ltwrapper_scriptname $cwrapper
7317 $RM $func_ltwrapper_scriptname_result
7318 trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
7319 $opt_dry_run || {
7320 # note: this script will not be executed, so do not chmod.
7321 if test "x$build" = "x$host" ; then
7322 $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
7323 else
7324 func_emit_wrapper no > $func_ltwrapper_scriptname_result
7325 fi
7326 }
7327 ;;
7328 * )
7329 $RM $output
7330 trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
Lev Walkin8e8b5482004-06-17 23:42:48 +00007331
Lev Walkin4da95cf2010-10-16 02:46:32 -07007332 func_emit_wrapper no > $output
7333 chmod +x $output
Lev Walkin8e8b5482004-06-17 23:42:48 +00007334 ;;
Lev Walkinf15320b2004-06-03 03:38:44 +00007335 esac
Lev Walkin4da95cf2010-10-16 02:46:32 -07007336 }
Lev Walkin8e8b5482004-06-17 23:42:48 +00007337 exit $EXIT_SUCCESS
Lev Walkinf15320b2004-06-03 03:38:44 +00007338 ;;
7339 esac
7340
7341 # See if we need to build an old-fashioned archive.
7342 for oldlib in $oldlibs; do
7343
7344 if test "$build_libtool_libs" = convenience; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07007345 oldobjs="$libobjs_save $symfileobj"
Lev Walkinf15320b2004-06-03 03:38:44 +00007346 addlibs="$convenience"
7347 build_libtool_libs=no
7348 else
7349 if test "$build_libtool_libs" = module; then
7350 oldobjs="$libobjs_save"
7351 build_libtool_libs=no
7352 else
Lev Walkin8e8b5482004-06-17 23:42:48 +00007353 oldobjs="$old_deplibs $non_pic_objects"
Lev Walkin4da95cf2010-10-16 02:46:32 -07007354 if test "$preload" = yes && test -f "$symfileobj"; then
Lev Walkine7c4b962010-11-09 03:10:36 -08007355 oldobjs="$oldobjs $symfileobj"
Lev Walkin4da95cf2010-10-16 02:46:32 -07007356 fi
Lev Walkinf15320b2004-06-03 03:38:44 +00007357 fi
7358 addlibs="$old_convenience"
7359 fi
7360
7361 if test -n "$addlibs"; then
7362 gentop="$output_objdir/${outputname}x"
Lev Walkine7c4b962010-11-09 03:10:36 -08007363 generated="$generated $gentop"
Lev Walkin8e8b5482004-06-17 23:42:48 +00007364
Lev Walkin4da95cf2010-10-16 02:46:32 -07007365 func_extract_archives $gentop $addlibs
Lev Walkine7c4b962010-11-09 03:10:36 -08007366 oldobjs="$oldobjs $func_extract_archives_result"
Lev Walkinf15320b2004-06-03 03:38:44 +00007367 fi
7368
7369 # Do each command in the archive commands.
7370 if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07007371 cmds=$old_archive_from_new_cmds
Lev Walkinf15320b2004-06-03 03:38:44 +00007372 else
Lev Walkin4da95cf2010-10-16 02:46:32 -07007373
7374 # Add any objects from preloaded convenience libraries
7375 if test -n "$dlprefiles"; then
7376 gentop="$output_objdir/${outputname}x"
Lev Walkine7c4b962010-11-09 03:10:36 -08007377 generated="$generated $gentop"
Lev Walkin4da95cf2010-10-16 02:46:32 -07007378
7379 func_extract_archives $gentop $dlprefiles
Lev Walkine7c4b962010-11-09 03:10:36 -08007380 oldobjs="$oldobjs $func_extract_archives_result"
Lev Walkin4da95cf2010-10-16 02:46:32 -07007381 fi
7382
7383 # POSIX demands no paths to be encoded in archives. We have
7384 # to avoid creating archives with duplicate basenames if we
7385 # might have to extract them afterwards, e.g., when creating a
7386 # static archive out of a convenience library, or when linking
7387 # the entirety of a libtool archive into another (currently
7388 # not supported by libtool).
7389 if (for obj in $oldobjs
7390 do
7391 func_basename "$obj"
7392 $ECHO "$func_basename_result"
7393 done | sort | sort -uc >/dev/null 2>&1); then
7394 :
7395 else
Lev Walkine7c4b962010-11-09 03:10:36 -08007396 $ECHO "copying selected object files to avoid basename conflicts..."
Lev Walkin4da95cf2010-10-16 02:46:32 -07007397 gentop="$output_objdir/${outputname}x"
Lev Walkine7c4b962010-11-09 03:10:36 -08007398 generated="$generated $gentop"
Lev Walkin4da95cf2010-10-16 02:46:32 -07007399 func_mkdir_p "$gentop"
7400 save_oldobjs=$oldobjs
7401 oldobjs=
7402 counter=1
7403 for obj in $save_oldobjs
7404 do
7405 func_basename "$obj"
7406 objbase="$func_basename_result"
7407 case " $oldobjs " in
7408 " ") oldobjs=$obj ;;
7409 *[\ /]"$objbase "*)
7410 while :; do
7411 # Make sure we don't pick an alternate name that also
7412 # overlaps.
7413 newobj=lt$counter-$objbase
7414 func_arith $counter + 1
7415 counter=$func_arith_result
7416 case " $oldobjs " in
7417 *[\ /]"$newobj "*) ;;
7418 *) if test ! -f "$gentop/$newobj"; then break; fi ;;
7419 esac
7420 done
7421 func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
Lev Walkine7c4b962010-11-09 03:10:36 -08007422 oldobjs="$oldobjs $gentop/$newobj"
Lev Walkin4da95cf2010-10-16 02:46:32 -07007423 ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08007424 *) oldobjs="$oldobjs $obj" ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07007425 esac
7426 done
7427 fi
Lev Walkinf15320b2004-06-03 03:38:44 +00007428 eval cmds=\"$old_archive_cmds\"
Lev Walkin8e8b5482004-06-17 23:42:48 +00007429
Lev Walkin4da95cf2010-10-16 02:46:32 -07007430 func_len " $cmds"
7431 len=$func_len_result
7432 if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
7433 cmds=$old_archive_cmds
Lev Walkin8e8b5482004-06-17 23:42:48 +00007434 else
7435 # the command line is too long to link in one step, link in parts
Lev Walkin4da95cf2010-10-16 02:46:32 -07007436 func_verbose "using piecewise archive linking..."
Lev Walkin8e8b5482004-06-17 23:42:48 +00007437 save_RANLIB=$RANLIB
7438 RANLIB=:
7439 objlist=
7440 concat_cmds=
7441 save_oldobjs=$oldobjs
Lev Walkin4da95cf2010-10-16 02:46:32 -07007442 oldobjs=
Lev Walkin8e8b5482004-06-17 23:42:48 +00007443 # Is there a better way of finding the last object in the list?
7444 for obj in $save_oldobjs
7445 do
7446 last_oldobj=$obj
7447 done
Lev Walkin4da95cf2010-10-16 02:46:32 -07007448 eval test_cmds=\"$old_archive_cmds\"
7449 func_len " $test_cmds"
7450 len0=$func_len_result
7451 len=$len0
Lev Walkin8e8b5482004-06-17 23:42:48 +00007452 for obj in $save_oldobjs
7453 do
Lev Walkin4da95cf2010-10-16 02:46:32 -07007454 func_len " $obj"
7455 func_arith $len + $func_len_result
7456 len=$func_arith_result
7457 func_append objlist " $obj"
7458 if test "$len" -lt "$max_cmd_len"; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00007459 :
7460 else
7461 # the above command should be used before it gets too long
7462 oldobjs=$objlist
7463 if test "$obj" = "$last_oldobj" ; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07007464 RANLIB=$save_RANLIB
Lev Walkin8e8b5482004-06-17 23:42:48 +00007465 fi
7466 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
7467 eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
7468 objlist=
Lev Walkin4da95cf2010-10-16 02:46:32 -07007469 len=$len0
Lev Walkin8e8b5482004-06-17 23:42:48 +00007470 fi
7471 done
7472 RANLIB=$save_RANLIB
7473 oldobjs=$objlist
7474 if test "X$oldobjs" = "X" ; then
7475 eval cmds=\"\$concat_cmds\"
7476 else
7477 eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
7478 fi
7479 fi
Lev Walkinf15320b2004-06-03 03:38:44 +00007480 fi
Lev Walkin4da95cf2010-10-16 02:46:32 -07007481 func_execute_cmds "$cmds" 'exit $?'
Lev Walkinf15320b2004-06-03 03:38:44 +00007482 done
7483
Lev Walkin4da95cf2010-10-16 02:46:32 -07007484 test -n "$generated" && \
7485 func_show_eval "${RM}r$generated"
Lev Walkinf15320b2004-06-03 03:38:44 +00007486
7487 # Now create the libtool archive.
Lev Walkin8e8b5482004-06-17 23:42:48 +00007488 case $output in
Lev Walkinf15320b2004-06-03 03:38:44 +00007489 *.la)
7490 old_library=
Lev Walkin8e8b5482004-06-17 23:42:48 +00007491 test "$build_old_libs" = yes && old_library="$libname.$libext"
Lev Walkin4da95cf2010-10-16 02:46:32 -07007492 func_verbose "creating $output"
Lev Walkinf15320b2004-06-03 03:38:44 +00007493
Lev Walkin8e8b5482004-06-17 23:42:48 +00007494 # Preserve any variables that may affect compiler behavior
7495 for var in $variables_saved_for_relink; do
7496 if eval test -z \"\${$var+set}\"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07007497 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
Lev Walkin8e8b5482004-06-17 23:42:48 +00007498 elif eval var_value=\$$var; test -z "$var_value"; then
7499 relink_command="$var=; export $var; $relink_command"
7500 else
Lev Walkin4da95cf2010-10-16 02:46:32 -07007501 func_quote_for_eval "$var_value"
7502 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
Lev Walkin8e8b5482004-06-17 23:42:48 +00007503 fi
7504 done
7505 # Quote the link command for shipping.
7506 relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
Lev Walkine7c4b962010-11-09 03:10:36 -08007507 relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
Lev Walkin8e8b5482004-06-17 23:42:48 +00007508 if test "$hardcode_automatic" = yes ; then
7509 relink_command=
Lev Walkinf15320b2004-06-03 03:38:44 +00007510 fi
7511
7512 # Only create the output if not a dry run.
Lev Walkin4da95cf2010-10-16 02:46:32 -07007513 $opt_dry_run || {
Lev Walkinf15320b2004-06-03 03:38:44 +00007514 for installed in no yes; do
7515 if test "$installed" = yes; then
7516 if test -z "$install_libdir"; then
7517 break
7518 fi
7519 output="$output_objdir/$outputname"i
Lev Walkin8e8b5482004-06-17 23:42:48 +00007520 # Replace all uninstalled libtool libraries with the installed ones
7521 newdependency_libs=
7522 for deplib in $dependency_libs; do
7523 case $deplib in
7524 *.la)
Lev Walkin4da95cf2010-10-16 02:46:32 -07007525 func_basename "$deplib"
7526 name="$func_basename_result"
Lev Walkin8e8b5482004-06-17 23:42:48 +00007527 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
Lev Walkin4da95cf2010-10-16 02:46:32 -07007528 test -z "$libdir" && \
7529 func_fatal_error "\`$deplib' is not a valid libtool archive"
Lev Walkine7c4b962010-11-09 03:10:36 -08007530 newdependency_libs="$newdependency_libs $libdir/$name"
Lev Walkin8e8b5482004-06-17 23:42:48 +00007531 ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08007532 *) newdependency_libs="$newdependency_libs $deplib" ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00007533 esac
7534 done
7535 dependency_libs="$newdependency_libs"
7536 newdlfiles=
Lev Walkin4da95cf2010-10-16 02:46:32 -07007537
Lev Walkin8e8b5482004-06-17 23:42:48 +00007538 for lib in $dlfiles; do
Lev Walkin4da95cf2010-10-16 02:46:32 -07007539 case $lib in
7540 *.la)
7541 func_basename "$lib"
7542 name="$func_basename_result"
7543 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
7544 test -z "$libdir" && \
7545 func_fatal_error "\`$lib' is not a valid libtool archive"
Lev Walkine7c4b962010-11-09 03:10:36 -08007546 newdlfiles="$newdlfiles $libdir/$name"
Lev Walkin4da95cf2010-10-16 02:46:32 -07007547 ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08007548 *) newdlfiles="$newdlfiles $lib" ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07007549 esac
Lev Walkin8e8b5482004-06-17 23:42:48 +00007550 done
7551 dlfiles="$newdlfiles"
7552 newdlprefiles=
7553 for lib in $dlprefiles; do
Lev Walkin4da95cf2010-10-16 02:46:32 -07007554 case $lib in
7555 *.la)
7556 # Only pass preopened files to the pseudo-archive (for
7557 # eventual linking with the app. that links it) if we
7558 # didn't already link the preopened objects directly into
7559 # the library:
7560 func_basename "$lib"
7561 name="$func_basename_result"
7562 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
7563 test -z "$libdir" && \
7564 func_fatal_error "\`$lib' is not a valid libtool archive"
Lev Walkine7c4b962010-11-09 03:10:36 -08007565 newdlprefiles="$newdlprefiles $libdir/$name"
Lev Walkin4da95cf2010-10-16 02:46:32 -07007566 ;;
7567 esac
Lev Walkin8e8b5482004-06-17 23:42:48 +00007568 done
7569 dlprefiles="$newdlprefiles"
7570 else
7571 newdlfiles=
7572 for lib in $dlfiles; do
7573 case $lib in
7574 [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
7575 *) abs=`pwd`"/$lib" ;;
7576 esac
Lev Walkine7c4b962010-11-09 03:10:36 -08007577 newdlfiles="$newdlfiles $abs"
Lev Walkin8e8b5482004-06-17 23:42:48 +00007578 done
7579 dlfiles="$newdlfiles"
7580 newdlprefiles=
7581 for lib in $dlprefiles; do
7582 case $lib in
7583 [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
7584 *) abs=`pwd`"/$lib" ;;
7585 esac
Lev Walkine7c4b962010-11-09 03:10:36 -08007586 newdlprefiles="$newdlprefiles $abs"
Lev Walkin8e8b5482004-06-17 23:42:48 +00007587 done
7588 dlprefiles="$newdlprefiles"
Lev Walkinf15320b2004-06-03 03:38:44 +00007589 fi
Lev Walkin4da95cf2010-10-16 02:46:32 -07007590 $RM $output
Lev Walkin8e8b5482004-06-17 23:42:48 +00007591 # place dlname in correct position for cygwin
7592 tdlname=$dlname
7593 case $host,$output,$installed,$module,$dlname in
Lev Walkine7c4b962010-11-09 03:10:36 -08007594 *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00007595 esac
Lev Walkin4da95cf2010-10-16 02:46:32 -07007596 $ECHO > $output "\
Lev Walkinf15320b2004-06-03 03:38:44 +00007597# $outputname - a libtool library file
Lev Walkin4da95cf2010-10-16 02:46:32 -07007598# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
Lev Walkinf15320b2004-06-03 03:38:44 +00007599#
7600# Please DO NOT delete this file!
7601# It is necessary for linking the library.
7602
7603# The name that we can dlopen(3).
Lev Walkin8e8b5482004-06-17 23:42:48 +00007604dlname='$tdlname'
Lev Walkinf15320b2004-06-03 03:38:44 +00007605
7606# Names of this library.
7607library_names='$library_names'
7608
7609# The name of the static archive.
7610old_library='$old_library'
7611
Lev Walkin4da95cf2010-10-16 02:46:32 -07007612# Linker flags that can not go in dependency_libs.
7613inherited_linker_flags='$new_inherited_linker_flags'
7614
Lev Walkinf15320b2004-06-03 03:38:44 +00007615# Libraries that this one depends upon.
7616dependency_libs='$dependency_libs'
7617
Lev Walkin4da95cf2010-10-16 02:46:32 -07007618# Names of additional weak libraries provided by this library
7619weak_library_names='$weak_libs'
7620
Lev Walkinf15320b2004-06-03 03:38:44 +00007621# Version information for $libname.
7622current=$current
7623age=$age
7624revision=$revision
7625
7626# Is this an already installed library?
7627installed=$installed
7628
Lev Walkin8e8b5482004-06-17 23:42:48 +00007629# Should we warn about portability when linking against -modules?
7630shouldnotlink=$module
7631
7632# Files to dlopen/dlpreopen
7633dlopen='$dlfiles'
7634dlpreopen='$dlprefiles'
7635
Lev Walkinf15320b2004-06-03 03:38:44 +00007636# Directory that this library needs to be installed in:
Lev Walkin8e8b5482004-06-17 23:42:48 +00007637libdir='$install_libdir'"
7638 if test "$installed" = no && test "$need_relink" = yes; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07007639 $ECHO >> $output "\
Lev Walkin8e8b5482004-06-17 23:42:48 +00007640relink_command=\"$relink_command\""
7641 fi
Lev Walkinf15320b2004-06-03 03:38:44 +00007642 done
Lev Walkin4da95cf2010-10-16 02:46:32 -07007643 }
Lev Walkinf15320b2004-06-03 03:38:44 +00007644
7645 # Do a symbolic link so that the libtool archive can be found in
7646 # LD_LIBRARY_PATH before the program is installed.
Lev Walkin4da95cf2010-10-16 02:46:32 -07007647 func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
Lev Walkinf15320b2004-06-03 03:38:44 +00007648 ;;
7649 esac
Lev Walkin8e8b5482004-06-17 23:42:48 +00007650 exit $EXIT_SUCCESS
Lev Walkin4da95cf2010-10-16 02:46:32 -07007651}
Lev Walkinf15320b2004-06-03 03:38:44 +00007652
Lev Walkine7c4b962010-11-09 03:10:36 -08007653{ test "$mode" = link || test "$mode" = relink; } &&
Lev Walkin4da95cf2010-10-16 02:46:32 -07007654 func_mode_link ${1+"$@"}
Lev Walkinf15320b2004-06-03 03:38:44 +00007655
Lev Walkinf15320b2004-06-03 03:38:44 +00007656
Lev Walkin4da95cf2010-10-16 02:46:32 -07007657# func_mode_uninstall arg...
7658func_mode_uninstall ()
7659{
7660 $opt_debug
7661 RM="$nonopt"
Lev Walkinf15320b2004-06-03 03:38:44 +00007662 files=
Lev Walkin8e8b5482004-06-17 23:42:48 +00007663 rmforce=
7664 exit_status=0
7665
7666 # This variable tells wrapper scripts just to set variables rather
7667 # than running their programs.
7668 libtool_install_magic="$magic"
Lev Walkinf15320b2004-06-03 03:38:44 +00007669
7670 for arg
7671 do
Lev Walkin8e8b5482004-06-17 23:42:48 +00007672 case $arg in
Lev Walkine7c4b962010-11-09 03:10:36 -08007673 -f) RM="$RM $arg"; rmforce=yes ;;
7674 -*) RM="$RM $arg" ;;
7675 *) files="$files $arg" ;;
Lev Walkinf15320b2004-06-03 03:38:44 +00007676 esac
7677 done
7678
Lev Walkin4da95cf2010-10-16 02:46:32 -07007679 test -z "$RM" && \
7680 func_fatal_help "you must specify an RM program"
Lev Walkinf15320b2004-06-03 03:38:44 +00007681
Lev Walkin8e8b5482004-06-17 23:42:48 +00007682 rmdirs=
7683
Lev Walkine7c4b962010-11-09 03:10:36 -08007684 origobjdir="$objdir"
Lev Walkinf15320b2004-06-03 03:38:44 +00007685 for file in $files; do
Lev Walkin4da95cf2010-10-16 02:46:32 -07007686 func_dirname "$file" "" "."
7687 dir="$func_dirname_result"
7688 if test "X$dir" = X.; then
Lev Walkine7c4b962010-11-09 03:10:36 -08007689 objdir="$origobjdir"
Lev Walkin8e8b5482004-06-17 23:42:48 +00007690 else
Lev Walkine7c4b962010-11-09 03:10:36 -08007691 objdir="$dir/$origobjdir"
Lev Walkin8e8b5482004-06-17 23:42:48 +00007692 fi
Lev Walkin4da95cf2010-10-16 02:46:32 -07007693 func_basename "$file"
7694 name="$func_basename_result"
Lev Walkine7c4b962010-11-09 03:10:36 -08007695 test "$mode" = uninstall && objdir="$dir"
Lev Walkin8e8b5482004-06-17 23:42:48 +00007696
Lev Walkine7c4b962010-11-09 03:10:36 -08007697 # Remember objdir for removal later, being careful to avoid duplicates
7698 if test "$mode" = clean; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00007699 case " $rmdirs " in
Lev Walkine7c4b962010-11-09 03:10:36 -08007700 *" $objdir "*) ;;
7701 *) rmdirs="$rmdirs $objdir" ;;
Lev Walkin8e8b5482004-06-17 23:42:48 +00007702 esac
7703 fi
7704
7705 # Don't error if the file doesn't exist and rm -f was used.
Lev Walkin4da95cf2010-10-16 02:46:32 -07007706 if { test -L "$file"; } >/dev/null 2>&1 ||
7707 { test -h "$file"; } >/dev/null 2>&1 ||
7708 test -f "$file"; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00007709 :
7710 elif test -d "$file"; then
7711 exit_status=1
7712 continue
7713 elif test "$rmforce" = yes; then
7714 continue
7715 fi
Lev Walkinf15320b2004-06-03 03:38:44 +00007716
7717 rmfiles="$file"
7718
Lev Walkin8e8b5482004-06-17 23:42:48 +00007719 case $name in
Lev Walkinf15320b2004-06-03 03:38:44 +00007720 *.la)
7721 # Possibly a libtool archive, so verify it.
Lev Walkin4da95cf2010-10-16 02:46:32 -07007722 if func_lalib_p "$file"; then
7723 func_source $dir/$name
Lev Walkinf15320b2004-06-03 03:38:44 +00007724
7725 # Delete the libtool libraries and symlinks.
7726 for n in $library_names; do
Lev Walkine7c4b962010-11-09 03:10:36 -08007727 rmfiles="$rmfiles $objdir/$n"
Lev Walkinf15320b2004-06-03 03:38:44 +00007728 done
Lev Walkine7c4b962010-11-09 03:10:36 -08007729 test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
Lev Walkinf15320b2004-06-03 03:38:44 +00007730
Lev Walkine7c4b962010-11-09 03:10:36 -08007731 case "$mode" in
Lev Walkin4da95cf2010-10-16 02:46:32 -07007732 clean)
Lev Walkine7c4b962010-11-09 03:10:36 -08007733 case " $library_names " in
7734 # " " in the beginning catches empty $dlname
Lev Walkin4da95cf2010-10-16 02:46:32 -07007735 *" $dlname "*) ;;
Lev Walkine7c4b962010-11-09 03:10:36 -08007736 *) rmfiles="$rmfiles $objdir/$dlname" ;;
Lev Walkin4da95cf2010-10-16 02:46:32 -07007737 esac
Lev Walkine7c4b962010-11-09 03:10:36 -08007738 test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
Lev Walkin4da95cf2010-10-16 02:46:32 -07007739 ;;
7740 uninstall)
Lev Walkin8e8b5482004-06-17 23:42:48 +00007741 if test -n "$library_names"; then
7742 # Do each command in the postuninstall commands.
Lev Walkin4da95cf2010-10-16 02:46:32 -07007743 func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
Lev Walkin8e8b5482004-06-17 23:42:48 +00007744 fi
Lev Walkinf15320b2004-06-03 03:38:44 +00007745
Lev Walkin8e8b5482004-06-17 23:42:48 +00007746 if test -n "$old_library"; then
7747 # Do each command in the old_postuninstall commands.
Lev Walkin4da95cf2010-10-16 02:46:32 -07007748 func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
Lev Walkin8e8b5482004-06-17 23:42:48 +00007749 fi
7750 # FIXME: should reinstall the best remaining shared library.
Lev Walkin4da95cf2010-10-16 02:46:32 -07007751 ;;
7752 esac
Lev Walkinf15320b2004-06-03 03:38:44 +00007753 fi
7754 ;;
7755
7756 *.lo)
Lev Walkin8e8b5482004-06-17 23:42:48 +00007757 # Possibly a libtool object, so verify it.
Lev Walkin4da95cf2010-10-16 02:46:32 -07007758 if func_lalib_p "$file"; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00007759
7760 # Read the .lo file
Lev Walkin4da95cf2010-10-16 02:46:32 -07007761 func_source $dir/$name
Lev Walkin8e8b5482004-06-17 23:42:48 +00007762
7763 # Add PIC object to the list of files to remove.
Lev Walkin4da95cf2010-10-16 02:46:32 -07007764 if test -n "$pic_object" &&
7765 test "$pic_object" != none; then
Lev Walkine7c4b962010-11-09 03:10:36 -08007766 rmfiles="$rmfiles $dir/$pic_object"
Lev Walkin8e8b5482004-06-17 23:42:48 +00007767 fi
7768
7769 # Add non-PIC object to the list of files to remove.
Lev Walkin4da95cf2010-10-16 02:46:32 -07007770 if test -n "$non_pic_object" &&
7771 test "$non_pic_object" != none; then
Lev Walkine7c4b962010-11-09 03:10:36 -08007772 rmfiles="$rmfiles $dir/$non_pic_object"
Lev Walkin8e8b5482004-06-17 23:42:48 +00007773 fi
Lev Walkinf15320b2004-06-03 03:38:44 +00007774 fi
Lev Walkinf15320b2004-06-03 03:38:44 +00007775 ;;
7776
7777 *)
Lev Walkine7c4b962010-11-09 03:10:36 -08007778 if test "$mode" = clean ; then
Lev Walkin8e8b5482004-06-17 23:42:48 +00007779 noexename=$name
7780 case $file in
7781 *.exe)
Lev Walkin4da95cf2010-10-16 02:46:32 -07007782 func_stripname '' '.exe' "$file"
7783 file=$func_stripname_result
7784 func_stripname '' '.exe' "$name"
7785 noexename=$func_stripname_result
Lev Walkin8e8b5482004-06-17 23:42:48 +00007786 # $file with .exe has already been added to rmfiles,
7787 # add $file without .exe
Lev Walkine7c4b962010-11-09 03:10:36 -08007788 rmfiles="$rmfiles $file"
Lev Walkin8e8b5482004-06-17 23:42:48 +00007789 ;;
7790 esac
7791 # Do a test to see if this is a libtool program.
Lev Walkin4da95cf2010-10-16 02:46:32 -07007792 if func_ltwrapper_p "$file"; then
7793 if func_ltwrapper_executable_p "$file"; then
7794 func_ltwrapper_scriptname "$file"
7795 relink_command=
7796 func_source $func_ltwrapper_scriptname_result
Lev Walkine7c4b962010-11-09 03:10:36 -08007797 rmfiles="$rmfiles $func_ltwrapper_scriptname_result"
Lev Walkin4da95cf2010-10-16 02:46:32 -07007798 else
7799 relink_command=
7800 func_source $dir/$noexename
7801 fi
Lev Walkin8e8b5482004-06-17 23:42:48 +00007802
7803 # note $name still contains .exe if it was in $file originally
7804 # as does the version of $file that was added into $rmfiles
Lev Walkine7c4b962010-11-09 03:10:36 -08007805 rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
Lev Walkin8e8b5482004-06-17 23:42:48 +00007806 if test "$fast_install" = yes && test -n "$relink_command"; then
Lev Walkine7c4b962010-11-09 03:10:36 -08007807 rmfiles="$rmfiles $objdir/lt-$name"
Lev Walkin8e8b5482004-06-17 23:42:48 +00007808 fi
7809 if test "X$noexename" != "X$name" ; then
Lev Walkine7c4b962010-11-09 03:10:36 -08007810 rmfiles="$rmfiles $objdir/lt-${noexename}.c"
Lev Walkin8e8b5482004-06-17 23:42:48 +00007811 fi
7812 fi
7813 fi
Lev Walkinf15320b2004-06-03 03:38:44 +00007814 ;;
7815 esac
Lev Walkin4da95cf2010-10-16 02:46:32 -07007816 func_show_eval "$RM $rmfiles" 'exit_status=1'
Lev Walkinf15320b2004-06-03 03:38:44 +00007817 done
Lev Walkine7c4b962010-11-09 03:10:36 -08007818 objdir="$origobjdir"
Lev Walkin8e8b5482004-06-17 23:42:48 +00007819
7820 # Try to remove the ${objdir}s in the directories where we deleted files
7821 for dir in $rmdirs; do
7822 if test -d "$dir"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07007823 func_show_eval "rmdir $dir >/dev/null 2>&1"
Lev Walkin8e8b5482004-06-17 23:42:48 +00007824 fi
7825 done
7826
7827 exit $exit_status
Lev Walkin4da95cf2010-10-16 02:46:32 -07007828}
Lev Walkinf15320b2004-06-03 03:38:44 +00007829
Lev Walkine7c4b962010-11-09 03:10:36 -08007830{ test "$mode" = uninstall || test "$mode" = clean; } &&
Lev Walkin4da95cf2010-10-16 02:46:32 -07007831 func_mode_uninstall ${1+"$@"}
Lev Walkinf15320b2004-06-03 03:38:44 +00007832
Lev Walkine7c4b962010-11-09 03:10:36 -08007833test -z "$mode" && {
Lev Walkin4da95cf2010-10-16 02:46:32 -07007834 help="$generic_help"
7835 func_fatal_help "you must specify a MODE"
7836}
7837
7838test -z "$exec_cmd" && \
Lev Walkine7c4b962010-11-09 03:10:36 -08007839 func_fatal_help "invalid operation mode \`$mode'"
Lev Walkinf15320b2004-06-03 03:38:44 +00007840
Lev Walkin8e8b5482004-06-17 23:42:48 +00007841if test -n "$exec_cmd"; then
Lev Walkin4da95cf2010-10-16 02:46:32 -07007842 eval exec "$exec_cmd"
Lev Walkin8e8b5482004-06-17 23:42:48 +00007843 exit $EXIT_FAILURE
7844fi
7845
Lev Walkin4da95cf2010-10-16 02:46:32 -07007846exit $exit_status
Lev Walkinf15320b2004-06-03 03:38:44 +00007847
Lev Walkin8e8b5482004-06-17 23:42:48 +00007848
7849# The TAGs below are defined such that we never get into a situation
7850# in which we disable both kinds of libraries. Given conflicting
7851# choices, we go for a static library, that is the most portable,
7852# since we can't tell whether shared libraries were disabled because
7853# the user asked for that or because the platform doesn't support
7854# them. This is particularly important on AIX, because we don't
7855# support having both static and shared libraries enabled at the same
7856# time on that platform, so we default to a shared-only configuration.
7857# If a disable-shared tag is given, we'll fallback to a static-only
7858# configuration. But we'll never go from static-only to shared-only.
7859
7860# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
7861build_libtool_libs=no
7862build_old_libs=yes
7863# ### END LIBTOOL TAG CONFIG: disable-shared
7864
7865# ### BEGIN LIBTOOL TAG CONFIG: disable-static
Lev Walkin4da95cf2010-10-16 02:46:32 -07007866build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
Lev Walkin8e8b5482004-06-17 23:42:48 +00007867# ### END LIBTOOL TAG CONFIG: disable-static
Lev Walkinf15320b2004-06-03 03:38:44 +00007868
7869# Local Variables:
7870# mode:shell-script
7871# sh-indentation:2
7872# End:
Lev Walkin4da95cf2010-10-16 02:46:32 -07007873# vi:sw=2
7874