Mercurial > hg > octave-nkf > gnulib-hg
annotate build-aux/reloc-ldflags @ 17764:2e1bf0ada123
autoupdate
author | Karl Berry <karl@freefriends.org> |
---|---|
date | Fri, 26 Sep 2014 09:07:05 -0700 |
parents | 344018b6e5d7 |
children | ab58d4870664 |
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 # |
17587 | 5 # Copyright 2003-2014 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 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8265
diff
changeset
|
19 # along with this program. If not, see <http://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 |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
56 case "$host_os" in |
16809
c73f5acae6b1
relocatable-prog: Enable ELF ORIGIN trick also on GNU/kFreeBSD.
Bruno Haible <bruno@clisp.org>
parents:
16690
diff
changeset
|
57 linux* | kfreebsd*) |
8265
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
58 rpath= |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
59 save_IFS="$IFS"; IFS=":" |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
60 for dir in $library_path_value; do |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
61 IFS="$save_IFS" |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
62 case "$dir" in |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
63 /*) |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
64 # Make dir relative to installdir. (Works only if dir is absolute.) |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
65 idir="$installdir" |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
66 while true; do |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
67 dfirst=`echo "$dir" | sed -n -e 's,^//*\([^/]*\).*$,/\1,p'` |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
68 ifirst=`echo "$idir" | sed -n -e 's,^//*\([^/]*\).*$,/\1,p'` |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
69 if test -z "$dfirst" || test -z "$ifirst"; then |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
70 break |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
71 fi |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
72 if test "$dfirst" != "$ifirst"; then |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
73 break |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
74 fi |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
75 dir=`echo "$dir" | sed -e 's,^//*[^/]*,,'` |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
76 idir=`echo "$idir" | sed -e 's,^//*[^/]*,,'` |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
77 done |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
78 dir="\$ORIGIN"`echo "$idir" | sed -e 's,//*[^/]*,/..,g'`"$dir" |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
79 # Add dir to rpath. |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
80 rpath="${rpath}${rpath:+ }$dir" |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
81 ;; |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
82 *) |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
83 if test -n "$dir"; then |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
84 echo "libdir is not absolute: $dir" 1>&2 |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
85 fi |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
86 ;; |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
87 esac |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
88 done |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
89 IFS="$save_IFS" |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
90 # Output it. |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
91 if test -n "$rpath"; then |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
92 echo "-Wl,-rpath,$rpath" |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
93 fi |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
94 ;; |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
95 *) |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
96 echo "relocation via rpath not supported on this system: $host" 1>&2 |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
97 exit 1 |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
98 ;; |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
99 esac |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
100 |
20006894dae4
Infrastructure for relocatable installation, from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
101 exit 0 |