summaryrefslogtreecommitdiff
path: root/build-aux/reloc-ldflags
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2019-03-04 17:25:09 +0100
committerBruno Haible <bruno@clisp.org>2019-03-04 17:28:15 +0100
commitb204bbfc779359c1de8895fe163673c3cf56d01b (patch)
tree0ef90885f310c60660d4635e6494891f887e9a11 /build-aux/reloc-ldflags
parentd355f90561200e05b46488a045f5ac12ad7b5669 (diff)
downloadgnulib-b204bbfc779359c1de8895fe163673c3cf56d01b.tar.gz
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
This approach supports relocatable installation of shared libraries which depend on other shared libraries from the same package. * m4/relocatable.m4 (gl_RELOCATABLE_BODY): Determine use_macos_tools. If use_macos_tools is true, use reloc-ldflags and set LIBTOOL to be a wrapper around the original LIBTOOL. * build-aux/reloc-ldflags: Add support for Mac OS X, which uses the token '@loader_path' instead of '$ORIGIN'. * build-aux/libtool-reloc: New file. * modules/relocatable-prog (Files): Add it. * doc/relocatable-maint.texi (Supporting Relocation): Update to match the recent changes. Document the need to set the *_LDFLAGS of libraries. RELOCATABLE_LIBRARY_PATH and RELOCATABLE_CONFIG_H_DIR should be set in Makefile.am, not in configure.ac.
Diffstat (limited to 'build-aux/reloc-ldflags')
-rwxr-xr-xbuild-aux/reloc-ldflags98
1 files changed, 52 insertions, 46 deletions
diff --git a/build-aux/reloc-ldflags b/build-aux/reloc-ldflags
index 3aed3308dc..625fef249f 100755
--- a/build-aux/reloc-ldflags
+++ b/build-aux/reloc-ldflags
@@ -53,6 +53,7 @@ case "$installdir" in
;;
esac
+origin_token=
case "$host_os" in
linux* | gnu* | kfreebsd* | \
freebsd* | dragonfly* | \
@@ -60,54 +61,59 @@ case "$host_os" in
openbsd* | \
solaris* | \
haiku*)
- 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"`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
+ origin_token='$ORIGIN'
;;
- *)
- echo "relocation via rpath not supported on this system: $host" 1>&2
- exit 1
+ darwin*)
+ origin_token='@loader_path'
;;
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