Mercurial > gnulib
annotate build-aux/libtool-reloc @ 40246:c34f677e6117 default tip master
_Noreturn: GCC 4.7 does not support [[noreturn]] in C++11 mode
* lib/_Noreturn.h, m4/gnulib-common.m4: Don't use [[noreturn]] before
GCC 4.8.
author | Akim Demaille <akim.demaille@gmail.com> |
---|---|
date | Sun, 17 Mar 2019 19:27:20 +0100 |
parents | 770a5696761e |
children |
rev | line source |
---|---|
40206
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
1 #!/bin/sh |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
2 # libtool-reloc - libtool wrapper with support for relocatable programs |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3 # Copyright (C) 2019 Free Software Foundation, Inc. |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
4 # Written by Bruno Haible <bruno@clisp.org>, 2019. |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
5 # |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
6 # This program is free software: you can redistribute it and/or modify |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
7 # it under the terms of the GNU General Public License as published by |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
8 # the Free Software Foundation; either version 3 of the License, or |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
9 # (at your option) any later version. |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
10 # |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
11 # This program is distributed in the hope that it will be useful, |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
14 # GNU General Public License for more details. |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
15 # |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
16 # You should have received a copy of the GNU General Public License |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
17 # along with this program. If not, see <https://www.gnu.org/licenses/>. |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
18 |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
19 # Usage: libtool-reloc libtool LIBTOOL_ARGUMENTS |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
20 |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
21 # Outputs a command and runs it. |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
22 func_verbose () |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
23 { |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
24 # Make it easy to copy&paste the printed command into a shell in most cases, |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
25 # by escaping '\\', '"', and '$'. This is not perfect, just good enough. |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
26 echo "$@" | sed -e 's/\([\\"$]\)/\\\1/g' |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
27 "$@" |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
28 } |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
29 |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
30 # Determine the mode from the arguments. |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
31 mode= |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
32 for arg |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
33 do |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
34 case "$arg" in |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
35 --mode=link) mode=link ;; |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
36 esac |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
37 done |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
38 |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
39 if test "$mode" = link; then |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
40 # Determine the target from the arguments. |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
41 target= |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
42 next_is_target=false |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
43 for arg |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
44 do |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
45 if $next_is_target; then |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
46 target="$arg" |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
47 next_is_target=false |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
48 else |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
49 case "$arg" in |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
50 -o) next_is_target=true ;; |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
51 *) next_is_target=false ;; |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
52 esac |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
53 fi |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
54 done |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
55 case "$target" in |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
56 *.la) |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
57 # When creating a library: |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
58 # 1. Add a '-Wl,-rpath,@loader_path' option. |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
59 # (A '-R @loader_path' option does not work: libtool produces |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
60 # an error "error: only absolute run-paths are allowed".) |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
61 # (Also note that 'install_name_tool -add_rpath @loader_path ...' |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
62 # does not work on Mac OS X 10.5.) |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
63 # This is done through the RELOCATABLE_LDFLAGS macro. |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
64 # 2. After creating the library, run |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
65 # install_name_tool -id @rpath/$dlname $target_dir/.libs/$dlname |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
66 # (This is easier than to modify the libtool script to emit a different |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
67 # install_name. Also, an option '-Wl,-install_name,@rpath/$dlname' does |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
68 # not work since libtool emits another option '-Wl,-install_name,...' |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
69 # after it. |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
70 "$@" && { |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
71 dlname_assignment=`grep '^dlname=' "$target"` |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
72 dlname= |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
73 eval "$dlname_assignment" |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
74 # Nothing to do when --disable-shared was specified. |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
75 if test -n "$dlname"; then |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
76 target_dir=`dirname "$target"` |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
77 if test -f "$target_dir/.libs/$dlname"; then |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
78 func_verbose install_name_tool -id "@rpath/$dlname" "$target_dir/.libs/$dlname" |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
79 fi |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
80 fi |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
81 } |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
82 ;; |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
83 *) |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
84 "$@" |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
85 ;; |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
86 esac |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
87 else |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
88 "$@" |
770a5696761e
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
89 fi |