aboutsummaryrefslogtreecommitdiff
path: root/ltmain.sh
diff options
context:
space:
mode:
Diffstat (limited to 'ltmain.sh')
-rw-r--r--ltmain.sh269
1 files changed, 213 insertions, 56 deletions
diff --git a/ltmain.sh b/ltmain.sh
index 2393e14..4fd5fa7 100644
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -55,8 +55,8 @@ modename="$progname"
# Constants.
PROGRAM=ltmain.sh
PACKAGE=libtool
-VERSION=1.4
-TIMESTAMP=" (1.920 2001/04/24 23:26:18)"
+VERSION=1.4.1
+TIMESTAMP=" (1.922.2.34 2001/09/03 01:22:13)"
default_mode=
help="Try \`$progname --help' for more information."
@@ -174,6 +174,8 @@ do
--mode) prevopt="--mode" prev=mode ;;
--mode=*) mode="$optarg" ;;
+ --preserve-dup-deps) duplicate_deps="yes" ;;
+
--quiet | --silent)
show=:
;;
@@ -202,6 +204,11 @@ if test -n "$prevopt"; then
exit 1
fi
+# If this variable is set in any of the actions, the command in it
+# will be execed at the end. This prevents here-documents from being
+# left over by shells.
+exec_cmd=
+
if test -z "$show_help"; then
# Infer the operation mode.
@@ -615,6 +622,10 @@ compiler."
# Now arrange that obj and lo_libobj become the same file
$show "(cd $xdir && $LN_S $baseobj $libobj)"
if $run eval '(cd $xdir && $LN_S $baseobj $libobj)'; then
+ # Unlock the critical section if it was locked
+ if test "$need_locks" != no; then
+ $run $rm "$lockfile"
+ fi
exit 0
else
error=$?
@@ -745,6 +756,7 @@ compiler."
linker_flags=
dllsearchpath=
lib_search_path=`pwd`
+ inst_prefix_dir=
avoid_version=no
dlfiles=
@@ -875,6 +887,11 @@ compiler."
prev=
continue
;;
+ inst_prefix)
+ inst_prefix_dir="$arg"
+ prev=
+ continue
+ ;;
release)
release="-$arg"
prev=
@@ -976,6 +993,11 @@ compiler."
continue
;;
+ -inst-prefix-dir)
+ prev=inst_prefix
+ continue
+ ;;
+
# The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
# so, if we see these flags be careful not to treat them like -L
-L[A-Z][A-Z]*:*)
@@ -1031,6 +1053,18 @@ compiler."
# These systems don't actually have a C library (as such)
test "X$arg" = "X-lc" && continue
;;
+ *-*-openbsd*)
+ # Do not include libc due to us having libc/libc_r.
+ test "X$arg" = "X-lc" && continue
+ ;;
+ esac
+ fi
+ if test "X$arg" = "X-lc_r"; then
+ case $host in
+ *-*-openbsd*)
+ # Do not include libc_r directly, use -pthread flag.
+ continue
+ ;;
esac
fi
deplibs="$deplibs $arg"
@@ -1307,11 +1341,32 @@ compiler."
# Find all interdependent deplibs by searching for libraries
# that are linked more than once (e.g. -la -lb -la)
for deplib in $deplibs; do
- case "$libs " in
- *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
- esac
+ if test "X$duplicate_deps" = "Xyes" ; then
+ case "$libs " in
+ *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+ esac
+ fi
libs="$libs $deplib"
done
+
+ if test "$linkmode" = lib; then
+ libs="$predeps $libs $compiler_lib_search_path $postdeps"
+
+ # Compute libraries that are listed more than once in $predeps
+ # $postdeps and mark them as special (i.e., whose duplicates are
+ # not to be eliminated).
+ pre_post_deps=
+ if test "X$duplicate_deps" = "Xyes" ; then
+ for pre_post_dep in $predeps $postdeps; do
+ case "$pre_post_deps " in
+ *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
+ esac
+ pre_post_deps="$pre_post_deps $pre_post_dep"
+ done
+ fi
+ pre_post_deps=
+ fi
+
deplibs=
newdependency_libs=
newlib_search_path=
@@ -1532,9 +1587,11 @@ compiler."
tmp_libs=
for deplib in $dependency_libs; do
deplibs="$deplib $deplibs"
- case "$tmp_libs " in
- *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
- esac
+ if test "X$duplicate_deps" = "Xyes" ; then
+ case "$tmp_libs " in
+ *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+ esac
+ fi
tmp_libs="$tmp_libs $deplib"
done
elif test "$linkmode" != prog && test "$linkmode" != lib; then
@@ -1657,9 +1714,11 @@ compiler."
# or/and link against static libraries
newdependency_libs="$deplib $newdependency_libs"
fi
- case "$tmp_libs " in
- *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
- esac
+ if test "X$duplicate_deps" = "Xyes" ; then
+ case "$tmp_libs " in
+ *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+ esac
+ fi
tmp_libs="$tmp_libs $deplib"
done # for deplib
continue
@@ -1851,7 +1910,16 @@ compiler."
if test "$hardcode_direct" = yes; then
add="$libdir/$linklib"
elif test "$hardcode_minus_L" = yes; then
- add_dir="-L$libdir"
+ # Try looking first in the location we're being installed to.
+ add_dir=
+ if test -n "$inst_prefix_dir"; then
+ case "$libdir" in
+ [\\/]*)
+ add_dir="-L$inst_prefix_dir$libdir"
+ ;;
+ esac
+ fi
+ add_dir="$add_dir -L$libdir"
add="-l$name"
elif test "$hardcode_shlibpath_var" = yes; then
case :$finalize_shlibpath: in
@@ -1861,7 +1929,16 @@ compiler."
add="-l$name"
else
# We cannot seem to hardcode it, guess we'll fake it.
- add_dir="-L$libdir"
+ # Try looking first in the location we're being installed to.
+ add_dir=
+ if test -n "$inst_prefix_dir"; then
+ case "$libdir" in
+ [\\/]*)
+ add_dir="-L$inst_prefix_dir$libdir"
+ ;;
+ esac
+ fi
+ add_dir="$add_dir -L$libdir"
add="-l$name"
fi
@@ -1911,17 +1988,17 @@ compiler."
echo "*** Therefore, libtool will create a static module, that should work "
echo "*** as long as the dlopening application is linked with the -dlopen flag."
if test -z "$global_symbol_pipe"; then
- echo
- echo "*** However, this would only work if libtool was able to extract symbol"
- echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
- echo "*** not find such a program. So, this module is probably useless."
- echo "*** \`nm' from GNU binutils and a full rebuild may help."
+ echo
+ echo "*** However, this would only work if libtool was able to extract symbol"
+ echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+ echo "*** not find such a program. So, this module is probably useless."
+ echo "*** \`nm' from GNU binutils and a full rebuild may help."
fi
if test "$build_old_libs" = no; then
- build_libtool_libs=module
- build_old_libs=yes
+ build_libtool_libs=module
+ build_old_libs=yes
else
- build_libtool_libs=no
+ build_libtool_libs=no
fi
fi
else
@@ -1958,9 +2035,11 @@ compiler."
tmp_libs=
for deplib in $dependency_libs; do
newdependency_libs="$deplib $newdependency_libs"
- case "$tmp_libs " in
- *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
- esac
+ if test "X$duplicate_deps" = "Xyes" ; then
+ case "$tmp_libs " in
+ *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+ esac
+ fi
tmp_libs="$tmp_libs $deplib"
done
@@ -2191,7 +2270,7 @@ compiler."
# Check that each of the things are valid numbers.
case $current in
- 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
+ [0-9]*) ;;
*)
$echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2
$echo "$modename: \`$vinfo' is not valid version information" 1>&2
@@ -2200,7 +2279,7 @@ compiler."
esac
case $revision in
- 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
+ [0-9]*) ;;
*)
$echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2
$echo "$modename: \`$vinfo' is not valid version information" 1>&2
@@ -2209,7 +2288,7 @@ compiler."
esac
case $age in
- 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
+ [0-9]*) ;;
*)
$echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2
$echo "$modename: \`$vinfo' is not valid version information" 1>&2
@@ -2312,6 +2391,16 @@ compiler."
if test -z "$vinfo" && test -n "$release"; then
major=
verstring="0.0"
+ case $version_type in
+ darwin)
+ # we can't check for "0.0" in archive_cmds due to quoting
+ # problems, so we reset it completely
+ verstring=""
+ ;;
+ *)
+ verstring="0.0"
+ ;;
+ esac
if test "$need_version" = no; then
versuffix=
else
@@ -2408,6 +2497,9 @@ compiler."
*-*-netbsd*)
# Don't link with libc until the a.out ld.so is fixed.
;;
+ *-*-openbsd*)
+ # Do not include libc due to us having libc/libc_r.
+ ;;
*)
# Add libc to deplibs on all other systems if necessary.
if test "$build_libtool_need_lc" = "yes"; then
@@ -3287,27 +3379,25 @@ extern \"C\" {
#undef lt_preloaded_symbols
#if defined (__STDC__) && __STDC__
-# define lt_ptr_t void *
+# define lt_ptr void *
#else
-# define lt_ptr_t char *
+# define lt_ptr char *
# define const
#endif
/* The mapping between symbol names and symbols. */
const struct {
const char *name;
- lt_ptr_t address;
+ lt_ptr address;
}
lt_preloaded_symbols[] =
{\
"
- sed -n -e 's/^: \([^ ]*\) $/ {\"\1\", (lt_ptr_t) 0},/p' \
- -e 's/^. \([^ ]*\) \([^ ]*\)$/ {"\2", (lt_ptr_t) \&\2},/p' \
- < "$nlist" >> "$output_objdir/$dlsyms"
+ eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
$echo >> "$output_objdir/$dlsyms" "\
- {0, (lt_ptr_t) 0}
+ {0, (lt_ptr) 0}
};
/* This works around a problem in FreeBSD linker */
@@ -3618,8 +3708,9 @@ else
# relink executable if necessary
if test -n \"\$relink_command\"; then
- if (eval \$relink_command); then :
+ if relink_command_output=\`eval \$relink_command 2>&1\`; then :
else
+ $echo \"\$relink_command_output\" >&2
$rm \"\$progdir/\$file\"
exit 1
fi
@@ -3823,7 +3914,7 @@ fi\
fi
done
# Quote the link command for shipping.
- relink_command="cd `pwd`; $SHELL $0 --mode=relink $libtool_args"
+ relink_command="cd `pwd`; $SHELL $0 --mode=relink $libtool_args @inst_prefix_dir@"
relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
# Only create the output if not a dry run.
@@ -3845,9 +3936,46 @@ fi\
$echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
exit 1
fi
- newdependency_libs="$newdependency_libs $libdir/$name"
+ # We do not want portage's install root ($D) present. Check only for
+ # this if the .la is being installed.
+ if test "$installed" = yes && test "$D"; then
+ eval mynewdependency_lib="`echo "$libdir/$name" |sed -e "s:$D::g" -e 's://:/:g'`"
+ else
+ mynewdependency_lib="$libdir/$name"
+ fi
+ # Do not add duplicates
+ if test "$mynewdependency_lib"; then
+ if test -z "`echo $newdependency_libs |grep -e "$mynewdependency_lib"`"; then
+ newdependency_libs="$newdependency_libs $mynewdependency_lib"
+ fi
+ fi
+ ;;
+ *)
+ if test "$installed" = yes; then
+ # Rather use S=WORKDIR if our version of portage supports it.
+ # This is because some ebuild (gcc) do not use $S as buildroot.
+ if test "$PWORKDIR"; then
+ S="$PWORKDIR"
+ fi
+ # We do not want portage's build root ($S) present.
+ if test -n "`echo $deplib |grep -e "$S"`" && test "$S"; then
+ mynewdependency_lib=""
+ # We do not want portage's install root ($D) present.
+ elif test -n "`echo $deplib |grep -e "$D"`" && test "$D"; then
+ eval mynewdependency_lib="`echo "$deplib" |sed -e "s:$D::g" -e 's://:/:g'`"
+ else
+ mynewdependency_lib="$deplib"
+ fi
+ else
+ mynewdependency_lib="$deplib"
+ fi
+ # Do not add duplicates
+ if test "$mynewdependency_lib"; then
+ if test -z "`echo $newdependency_libs |grep -e "$mynewdependency_lib"`"; then
+ newdependency_libs="$newdependency_libs $mynewdependency_lib"
+ fi
+ fi
;;
- *) newdependency_libs="$newdependency_libs $deplib" ;;
esac
done
dependency_libs="$newdependency_libs"
@@ -3880,6 +4008,10 @@ fi\
case $host,$output,$installed,$module,$dlname in
*cygwin*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
esac
+ # Do not add duplicates
+ if test "$installed" = yes && test "$D"; then
+ install_libdir="`echo "$install_libdir" |sed -e "s:$D::g" -e 's://:/:g'`"
+ fi
$echo > $output "\
# $outputname - a libtool library file
# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
@@ -4124,12 +4256,30 @@ relink_command=\"$relink_command\""
dir="$dir$objdir"
if test -n "$relink_command"; then
+ # Determine the prefix the user has applied to our future dir.
+ inst_prefix_dir=`$echo "$destdir" | sed "s%$libdir\$%%"`
+
+ # Don't allow the user to place us outside of our expected
+ # location b/c this prevents finding dependent libraries that
+ # are installed to the same prefix.
+ if test "$inst_prefix_dir" = "$destdir"; then
+ $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
+ exit 1
+ fi
+
+ if test -n "$inst_prefix_dir"; then
+ # Stick the inst_prefix_dir data into the link command.
+ relink_command=`$echo "$relink_command" | sed "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
+ else
+ relink_command=`$echo "$relink_command" | sed "s%@inst_prefix_dir@%%"`
+ fi
+
$echo "$modename: warning: relinking \`$file'" 1>&2
$show "$relink_command"
if $run eval "$relink_command"; then :
else
$echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
- continue
+ exit 1
fi
fi
@@ -4284,7 +4434,11 @@ relink_command=\"$relink_command\""
if test "$finalize" = yes && test -z "$run"; then
tmpdir="/tmp"
test -n "$TMPDIR" && tmpdir="$TMPDIR"
- tmpdir="$tmpdir/libtool-$$"
+ tmpdir=`mktemp -d $tmpdir/libtool-XXXXXX 2> /dev/null`
+ if test $? = 0 ; then :
+ else
+ tmpdir="$tmpdir/libtool-$$"
+ fi
if $mkdir -p "$tmpdir" && chmod 700 "$tmpdir"; then :
else
$echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2
@@ -4368,11 +4522,10 @@ relink_command=\"$relink_command\""
if test -n "$current_libdirs"; then
# Maybe just do a dry run.
test -n "$run" && current_libdirs=" -n$current_libdirs"
- exec $SHELL $0 --finish$current_libdirs
- exit 1
+ exec_cmd='$SHELL $0 --finish$current_libdirs'
+ else
+ exit 0
fi
-
- exit 0
;;
# libtool finish mode
@@ -4575,11 +4728,8 @@ relink_command=\"$relink_command\""
LANG="$save_LANG"; export LANG
fi
- # Now actually exec the command.
- eval "exec \$cmd$args"
-
- $echo "$modename: cannot exec \$cmd$args"
- exit 1
+ # Now prepare to actually exec the command.
+ exec_cmd='"$cmd"$args'
else
# Display what would be done.
if test -n "$shlibpath_var"; then
@@ -4641,14 +4791,14 @@ relink_command=\"$relink_command\""
# Don't error if the file doesn't exist and rm -f was used.
if (test -L "$file") >/dev/null 2>&1 \
- || (test -h "$file") >/dev/null 2>&1 \
+ || (test -h "$file") >/dev/null 2>&1 \
|| test -f "$file"; then
- :
+ :
elif test -d "$file"; then
- exit_status=1
+ exit_status=1
continue
elif test "$rmforce" = yes; then
- continue
+ continue
fi
rmfiles="$file"
@@ -4744,11 +4894,18 @@ relink_command=\"$relink_command\""
;;
esac
- $echo "$modename: invalid operation mode \`$mode'" 1>&2
- $echo "$generic_help" 1>&2
- exit 1
+ if test -z "$exec_cmd"; then
+ $echo "$modename: invalid operation mode \`$mode'" 1>&2
+ $echo "$generic_help" 1>&2
+ exit 1
+ fi
fi # test -z "$show_help"
+if test -n "$exec_cmd"; then
+ eval exec $exec_cmd
+ exit 1
+fi
+
# We need to display help for each of the modes.
case $mode in
"") $echo \