diff build-aux/reloc-ldflags @ 40190:ef116535bf1a

relocatable-prog: Use $ORIGIN trick on more platforms. * m4/relocatable.m4 (gl_RELOCATABLE_BODY): Use $ORIGIN trick also on FreeBSD >= 7.3, DragonFly >= 3.0, NetBSD >= 8.0, OpenBSD >= 5.4, Solaris >= 10, Haiku. But don't use it on Android. * build-aux/reloc-ldflags: Allow the use of the $ORIGIN trick also on Hurd, FreeBSD, DragonFly, NetBSD, OpenBSD, Solaris, Haiku.
author Bruno Haible <bruno@clisp.org>
date Wed, 20 Feb 2019 02:39:52 +0100
parents b06060465f09
children 770a5696761e
line wrap: on
line diff
--- a/build-aux/reloc-ldflags	Tue Feb 19 21:42:54 2019 +0100
+++ b/build-aux/reloc-ldflags	Wed Feb 20 02:39:52 2019 +0100
@@ -54,7 +54,12 @@
 esac
 
 case "$host_os" in
-  linux* | kfreebsd*)
+  linux* | gnu* | kfreebsd* | \
+  freebsd* | dragonfly* | \
+  netbsd* | \
+  openbsd* | \
+  solaris* | \
+  haiku*)
     rpath=
     save_IFS="$IFS"; IFS=":"
     for dir in $library_path_value; do
@@ -89,7 +94,14 @@
     IFS="$save_IFS"
     # Output it.
     if test -n "$rpath"; then
-      echo "-Wl,-rpath,$rpath"
+      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
     ;;
   *)