File: libtool-reloc

package info (click to toggle)
gettext 0.23.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 168,104 kB
  • sloc: ansic: 532,579; sh: 68,252; perl: 28,011; makefile: 9,066; lisp: 3,184; yacc: 1,055; java: 615; cs: 589; cpp: 397; objc: 343; sed: 79; tcl: 63; xml: 40; pascal: 11; php: 7; awk: 7
file content (148 lines) | stat: -rwxr-xr-x 4,341 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/bin/sh
# libtool-reloc - libtool wrapper with support for relocatable programs
# Copyright (C) 2019-2024 Free Software Foundation, Inc.
# Written by Bruno Haible <bruno@clisp.org>, 2019.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

# func_usage
# outputs to stdout the --help usage message.
func_usage ()
{
  echo "\
Usage: libtool-reloc [OPTION]... libtool LIBTOOL_ARGUMENTS

Invokes GNU libtool, with support for relocatable programs.

Options:
      --help           print this help and exit
      --version        print version information and exit

Send patches and bug reports to <bug-gnulib@gnu.org>."
}

# func_version
# outputs to stdout the --version message.
func_version ()
{
  echo "libtool-reloc (GNU gnulib, module relocatable-prog)"
  echo "Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law."
  echo
  printf 'Written by %s.\n' "Bruno Haible"
}

# func_fatal_error message
# outputs to stderr a fatal error message, and terminates the program.
func_fatal_error ()
{
  echo "libtool-reloc: *** $1" 1>&2
  echo "libtool-reloc: *** Stop." 1>&2
  exit 1
}

# Outputs a command and runs it.
func_verbose ()
{
  # Make it easy to copy&paste the printed command into a shell in most cases,
  # by escaping '\\', '"', and '$'. This is not perfect, just good enough.
  echo "$@" | sed -e 's/\([\\"$]\)/\\\1/g'
  "$@"
}

# Command-line option processing.
while test $# -gt 0; do
  case "$1" in
    --help | --hel | --he | --h )
      func_usage
      exit 0 ;;
   --version | --versio | --versi | --vers | --ver | --ve | --v )
      func_version
      exit 0 ;;
    -- )      # Stop option processing
      shift; break ;;
    -* )
      func_fatal_error "unrecognized option: $1"
      ;;
    * )
      break ;;
  esac
done

if test $# -lt 1; then
  func_fatal_error "too few arguments"
fi

# Determine the mode from the arguments.
mode=
for arg
do
  case "$arg" in
    --mode=link) mode=link ;;
  esac
done

if test "$mode" = link; then
  # Determine the target from the arguments.
  target=
  next_is_target=false
  for arg
  do
    if $next_is_target; then
      target="$arg"
      next_is_target=false
    else
      case "$arg" in
        -o) next_is_target=true ;;
        *) next_is_target=false ;;
      esac
    fi
  done
  case "$target" in
    *.la)
      # When creating a library:
      # 1. Add a '-Wl,-rpath,@loader_path' option.
      #    (A '-R @loader_path' option does not work: libtool produces
      #    an error "error: only absolute run-paths are allowed".)
      #    (Also note that 'install_name_tool -add_rpath @loader_path ...'
      #    does not work on Mac OS X 10.5.)
      #    This is done through the RELOCATABLE_LDFLAGS macro.
      # 2. After creating the library, run
      #    install_name_tool -id @rpath/$dlname $target_dir/.libs/$dlname
      #    (This is easier than to modify the libtool script to emit a different
      #    install_name. Also, an option '-Wl,-install_name,@rpath/$dlname' does
      #    not work since libtool emits another option '-Wl,-install_name,...'
      #    after it.
      "$@" && {
        dlname_assignment=`grep '^dlname=' "$target"`
        dlname=
        eval "$dlname_assignment"
        # Nothing to do when --disable-shared was specified.
        if test -n "$dlname"; then
          target_dir=`dirname "$target"`
          if test -f "$target_dir/.libs/$dlname"; then
            func_verbose install_name_tool -id "@rpath/$dlname" "$target_dir/.libs/$dlname"
          fi
        fi
      }
      ;;
    *)
      "$@"
      ;;
  esac
else
  "$@"
fi