annotate build-aux/reloc-ldflags @ 40206:770a5696761e

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.
author Bruno Haible <bruno@clisp.org>
date Mon, 04 Mar 2019 17:25:09 +0100
parents ef116535bf1a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8265
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 #! /bin/sh
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2 # Output a system dependent linker command for putting a relocatable library
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3 # search path into an executable.
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 #
40057
b06060465f09 maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents: 19484
diff changeset
5 # Copyright 2003-2019 Free Software Foundation, Inc.
8265
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 # Written by Bruno Haible <bruno@clisp.org>, 2003.
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 #
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 8265
diff changeset
8 # This program is free software: you can redistribute it and/or modify
8265
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 # it under the terms of the GNU General Public License as published by
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 8265
diff changeset
10 # the Free Software Foundation; either version 3 of the License, or
8265
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 # (at your option) any later version.
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 #
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 8265
diff changeset
13 # This program is distributed in the hope that it will be useful,
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 8265
diff changeset
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 8265
diff changeset
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 8265
diff changeset
16 # GNU General Public License for more details.
8265
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 #
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18 # You should have received a copy of the GNU General Public License
19190
9759915b2aca all: prefer https: URLs
Paul Eggert <eggert@cs.ucla.edu>
parents: 18626
diff changeset
19 # along with this program. If not, see <https://www.gnu.org/licenses/>.
8265
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20 #
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 # As a special exception to the GNU General Public License, if you
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 # distribute this file as part of a program that contains a
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 # configuration script generated by Autoconf, you may include it under
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 # the same distribution terms that you use for the rest of that program.
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 #
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 # The first argument passed to this file is the canonical host specification,
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 # or
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 # The environment variable LD should be set by the caller.
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 #
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 # The second argument is a colon separated list of directories that contain
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 # the libraries at installation time.
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 #
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 # The third argument is the directory into which the executable is going to be
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 # installed.
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 host="$1"
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39 host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 library_path_value=$2
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 installdir=$3
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 # Verify that installdir is absolute.
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 case "$installdir" in
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 /*) ;;
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 *)
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 echo "installdir is not absolute: $installdir" 1>&2
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 exit 1
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 ;;
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 esac
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55
40206
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
56 origin_token=
8265
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 case "$host_os" in
40190
ef116535bf1a relocatable-prog: Use $ORIGIN trick on more platforms.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
58 linux* | gnu* | kfreebsd* | \
ef116535bf1a relocatable-prog: Use $ORIGIN trick on more platforms.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
59 freebsd* | dragonfly* | \
ef116535bf1a relocatable-prog: Use $ORIGIN trick on more platforms.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
60 netbsd* | \
ef116535bf1a relocatable-prog: Use $ORIGIN trick on more platforms.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
61 openbsd* | \
ef116535bf1a relocatable-prog: Use $ORIGIN trick on more platforms.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
62 solaris* | \
ef116535bf1a relocatable-prog: Use $ORIGIN trick on more platforms.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
63 haiku*)
40206
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
64 origin_token='$ORIGIN'
8265
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65 ;;
40206
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
66 darwin*)
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
67 origin_token='@loader_path'
8265
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
68 ;;
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
69 esac
40206
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
70 if test -n "$origin_token"; then
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
71 rpath=
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
72 save_IFS="$IFS"; IFS=":"
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
73 for dir in $library_path_value; do
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
74 IFS="$save_IFS"
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
75 case "$dir" in
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
76 /*)
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
77 # Make dir relative to installdir. (Works only if dir is absolute.)
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
78 idir="$installdir"
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
79 while true; do
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
80 dfirst=`echo "$dir" | sed -n -e 's,^//*\([^/]*\).*$,/\1,p'`
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
81 ifirst=`echo "$idir" | sed -n -e 's,^//*\([^/]*\).*$,/\1,p'`
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
82 if test -z "$dfirst" || test -z "$ifirst"; then
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
83 break
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
84 fi
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
85 if test "$dfirst" != "$ifirst"; then
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
86 break
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
87 fi
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
88 dir=`echo "$dir" | sed -e 's,^//*[^/]*,,'`
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
89 idir=`echo "$idir" | sed -e 's,^//*[^/]*,,'`
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
90 done
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
91 dir="$origin_token"`echo "$idir" | sed -e 's,//*[^/]*,/..,g'`"$dir"
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
92 # Add dir to rpath.
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
93 rpath="${rpath}${rpath:+ }$dir"
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
94 ;;
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
95 *)
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
96 if test -n "$dir"; then
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
97 echo "libdir is not absolute: $dir" 1>&2
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
98 fi
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
99 ;;
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
100 esac
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
101 done
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
102 IFS="$save_IFS"
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
103 # Output it.
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
104 if test -n "$rpath"; then
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
105 case "$host_os" in
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
106 # At least some versions of FreeBSD, DragonFly, and OpenBSD need the
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
107 # linker option "-z origin". See <https://lekensteyn.nl/rpath.html>.
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
108 freebsd* | dragonfly* | openbsd*)
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
109 echo "-Wl,-z,origin -Wl,-rpath,$rpath" ;;
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
110 *)
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
111 echo "-Wl,-rpath,$rpath" ;;
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
112 esac
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
113 fi
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
114 else
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
115 echo "relocation via rpath not supported on this system: $host" 1>&2
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
116 exit 1
770a5696761e relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents: 40190
diff changeset
117 fi
8265
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
118
20006894dae4 Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
119 exit 0