version 1.1, 2012/02/21 22:57:49
|
version 1.1.1.3, 2021/03/17 13:38:46
|
Line 2
|
Line 2
|
# Output a system dependent linker command for putting a relocatable library |
# Output a system dependent linker command for putting a relocatable library |
# search path into an executable. |
# search path into an executable. |
# |
# |
# Copyright 2003 Free Software Foundation, Inc. | # Copyright 2003-2019 Free Software Foundation, Inc. |
# Written by Bruno Haible <bruno@clisp.org>, 2003. |
# Written by Bruno Haible <bruno@clisp.org>, 2003. |
# |
# |
# This program is free software: you can redistribute it and/or modify |
# This program is free software: you can redistribute it and/or modify |
Line 16
|
Line 16
|
# GNU General Public License for more details. |
# GNU General Public License for more details. |
# |
# |
# You should have received a copy of the GNU General Public License |
# You should have received a copy of the GNU General Public License |
# along with this program. If not, see <http://www.gnu.org/licenses/>. | # along with this program. If not, see <https://www.gnu.org/licenses/>. |
# |
# |
# As a special exception to the GNU General Public License, if you |
# As a special exception to the GNU General Public License, if you |
# distribute this file as part of a program that contains a |
# distribute this file as part of a program that contains a |
Line 53 case "$installdir" in
|
Line 53 case "$installdir" in
|
;; |
;; |
esac |
esac |
|
|
|
origin_token= |
case "$host_os" in |
case "$host_os" in |
linux*) # Supported since Linux 2.1 and glibc 2.1. | linux* | gnu* | kfreebsd* | \ |
rpath= | freebsd* | dragonfly* | \ |
save_IFS="$IFS"; IFS=":" | netbsd* | \ |
for dir in $library_path_value; do | openbsd* | \ |
IFS="$save_IFS" | solaris* | \ |
case "$dir" in | haiku*) |
/*) | origin_token='$ORIGIN' |
# Make dir relative to installdir. (Works only if dir is absolute.) | |
idir="$installdir" | |
while true; do | |
dfirst=`echo "$dir" | sed -n -e 's,^//*\([^/]*\).*$,/\1,p'` | |
ifirst=`echo "$idir" | sed -n -e 's,^//*\([^/]*\).*$,/\1,p'` | |
if test -z "$dfirst" || test -z "$ifirst"; then | |
break | |
fi | |
if test "$dfirst" != "$ifirst"; then | |
break | |
fi | |
dir=`echo "$dir" | sed -e 's,^//*[^/]*,,'` | |
idir=`echo "$idir" | sed -e 's,^//*[^/]*,,'` | |
done | |
dir="\$ORIGIN"`echo "$idir" | sed -e 's,//*[^/]*,/..,g'`"$dir" | |
# Add dir to rpath. | |
rpath="${rpath}${rpath:+ }$dir" | |
;; | |
*) | |
if test -n "$dir"; then | |
echo "libdir is not absolute: $dir" 1>&2 | |
fi | |
;; | |
esac | |
done | |
IFS="$save_IFS" | |
# Output it. | |
if test -n "$rpath"; then | |
echo "-Wl,-rpath,$rpath" | |
fi | |
;; |
;; |
*) | darwin*) |
echo "relocation via rpath not supported on this system: $host" 1>&2 | origin_token='@loader_path' |
exit 1 | |
;; |
;; |
esac |
esac |
|
if test -n "$origin_token"; then |
|
rpath= |
|
save_IFS="$IFS"; IFS=":" |
|
for dir in $library_path_value; do |
|
IFS="$save_IFS" |
|
case "$dir" in |
|
/*) |
|
# Make dir relative to installdir. (Works only if dir is absolute.) |
|
idir="$installdir" |
|
while true; do |
|
dfirst=`echo "$dir" | sed -n -e 's,^//*\([^/]*\).*$,/\1,p'` |
|
ifirst=`echo "$idir" | sed -n -e 's,^//*\([^/]*\).*$,/\1,p'` |
|
if test -z "$dfirst" || test -z "$ifirst"; then |
|
break |
|
fi |
|
if test "$dfirst" != "$ifirst"; then |
|
break |
|
fi |
|
dir=`echo "$dir" | sed -e 's,^//*[^/]*,,'` |
|
idir=`echo "$idir" | sed -e 's,^//*[^/]*,,'` |
|
done |
|
dir="$origin_token"`echo "$idir" | sed -e 's,//*[^/]*,/..,g'`"$dir" |
|
# Add dir to rpath. |
|
rpath="${rpath}${rpath:+ }$dir" |
|
;; |
|
*) |
|
if test -n "$dir"; then |
|
echo "libdir is not absolute: $dir" 1>&2 |
|
fi |
|
;; |
|
esac |
|
done |
|
IFS="$save_IFS" |
|
# Output it. |
|
if test -n "$rpath"; then |
|
case "$host_os" in |
|
# At least some versions of FreeBSD, DragonFly, and OpenBSD need the |
|
# linker option "-z origin". See <https://lekensteyn.nl/rpath.html>. |
|
freebsd* | dragonfly* | openbsd*) |
|
echo "-Wl,-z,origin -Wl,-rpath,$rpath" ;; |
|
*) |
|
echo "-Wl,-rpath,$rpath" ;; |
|
esac |
|
fi |
|
else |
|
echo "relocation via rpath not supported on this system: $host" 1>&2 |
|
exit 1 |
|
fi |
|
|
exit 0 |
exit 0 |