Commit | Line | Data |
---|---|---|
805e021f CE |
1 | #!/bin/sh |
2 | # | |
3 | # Builds a shared library, incorporating the random portability work that we | |
4 | # have to do. Gets the basic information from Autoconf and knows how to find | |
5 | # the appropriate system-specific map or version file and set library SONAMEs. | |
6 | # | |
7 | # This is not libtool. If it appears to be in danger of evolving into | |
8 | # libtool, please shoot it and start over, possibly by rewriting AFS in Ada. | |
9 | ||
10 | # We take the following regular arguments: -d <srcdir>, -f <filename>, -l | |
11 | # <library>, -M <major>, and -m <minor>. If -f is given, it overrides -l and | |
12 | # specifies the complete filename of the shared library to build. We then | |
13 | # expect a -- option indicating the end of our arguments and the rest of the | |
14 | # arguments are passed along verbatim to the linker. | |
15 | ||
16 | set -e | |
17 | ||
18 | linker="@SHLIB_LINKER@" | |
19 | suffix="@SHLIB_SUFFIX@" | |
20 | sysname="@AFS_SYSNAME@" | |
21 | ||
22 | library= | |
23 | major= | |
24 | minor= | |
25 | unused= | |
26 | srcdir=. | |
27 | plain= | |
28 | done= | |
29 | while [ -z "$done" ] && [ $# -gt 0 ] ; do | |
30 | case "$1" in | |
31 | -d) | |
32 | shift | |
33 | srcdir="$1" | |
34 | shift | |
35 | ;; | |
36 | -f) | |
37 | shift | |
38 | filename="$1" | |
39 | shift | |
40 | ;; | |
41 | -l) | |
42 | shift | |
43 | library="$1" | |
44 | shift | |
45 | ;; | |
46 | -M) | |
47 | shift | |
48 | major="$1" | |
49 | shift | |
50 | ;; | |
51 | -m) | |
52 | shift | |
53 | minor="$1" | |
54 | shift | |
55 | ;; | |
56 | -i) | |
57 | ignore=yes | |
58 | shift | |
59 | ;; | |
60 | -p) | |
61 | plain=yes | |
62 | shift | |
63 | ;; | |
64 | --) | |
65 | shift | |
66 | done=yes | |
67 | ;; | |
68 | *) | |
69 | echo 'Usage: shlib-build (-p -f <file> | [-i] -l <lib> -M <major> -m <minor>) -- ...' >&2 | |
70 | exit 1 | |
71 | ;; | |
72 | esac | |
73 | done | |
74 | if [ -z "$library" ] && [ -z "$plain" ] || \ | |
75 | [ -z "$filename" ] && [ "x$plain" != "x" ] ; then | |
76 | echo 'Usage: shlib-build (-p -f <file> | [-i] -l <lib> -M <major> -m <minor>) -- ...' >&2 | |
77 | exit 1 | |
78 | fi | |
79 | ||
80 | # Print out what we're doing while we do it for debugging. | |
81 | export= | |
82 | if [ -z "$filename" ] ; then | |
83 | if [ -z "$major" ] ; then | |
84 | filename="$library.$suffix" | |
85 | soname= | |
86 | else | |
87 | filename="$library.$suffix.$major.$minor" | |
88 | soname="$library.$suffix.$major" | |
89 | fi | |
90 | fi | |
91 | case $sysname in | |
92 | rs_aix*) | |
93 | if [ -z "$plain" ] && [ -f "$srcdir/$library.map" ] ; then | |
94 | cat $srcdir/$library.map | \ | |
95 | awk '/local:/ {inglobal=0}; | |
96 | inglobal { sub(/;/,""); print }; | |
97 | /global:/ { inglobal=1};' \ | |
98 | > $library.exp | |
99 | export="-bE:$library.exp" | |
100 | fi | |
101 | echo "$linker $export -o $filename $*" | |
102 | $linker $export -o "$filename" "$@" | |
103 | ;; | |
104 | sun*_5*) | |
105 | if [ -z "$plain" ] && [ -f "$srcdir/$library.map" ] ; then | |
106 | if [ -z "$ignore" ] ; then | |
107 | export="-Wl,-M$srcdir/$library.map" | |
108 | else | |
109 | # add "= EXTERN" to every symbol, so we don't get errors about | |
110 | # undefined symbols | |
111 | cat "$srcdir/$library.map" | \ | |
112 | sed -e 's/\([a-zA-Z_]\);$/\1 = EXTERN;/' > "$library.real.map" | |
113 | export="-Wl,-M$library.real.map" | |
114 | fi | |
115 | fi | |
116 | if [ -z "$soname" ] ; then | |
117 | echo "$linker $export -o $filename $*" | |
118 | $linker $export -o "$filename" "$@" | |
119 | else | |
120 | echo "$linker $export -h $soname -o $filename $*" | |
121 | $linker $export -h "$soname" -o "$filename" "$@" | |
122 | fi | |
123 | ;; | |
124 | *_linux*) | |
125 | if [ -z "$plain" ] && [ -f "$srcdir/$library.map" ] ; then | |
126 | export="-Wl,--version-script=$srcdir/$library.map" | |
127 | fi | |
128 | if [ -z "$soname" ] ; then | |
129 | echo "$linker $export -o $filename $*" | |
130 | $linker $export -o "$filename" "$@" | |
131 | else | |
132 | echo "$linker $export -Wl,-h,$soname -o $filename $*" | |
133 | $linker $export -Wl,-h,"$soname" -o "$filename" "$@" | |
134 | fi | |
135 | ;; | |
136 | hp_ux*) | |
137 | if [ -z "$plain" ] && [ -f "$srcdir/$library.hp" ] ; then | |
138 | export="-c $srcdir/$library.hp" | |
139 | fi | |
140 | echo "$linker $export -o $filename $*" | |
141 | $linker $export -o "$filename" "$@" | |
142 | ;; | |
143 | *darwin*) | |
144 | if [ -z "$plain" ] && [ -f "$srcdir/$library.map" ] ; then | |
145 | # For 10.4 and later, the Mac exports list is a list of symbols, | |
146 | # prefixed with an '_' | |
147 | cat $srcdir/$library.map | \ | |
148 | awk '/local:/ {inglobal=0}; | |
149 | /^[\t ]+#/ {next}; | |
150 | inglobal { sub(/;/,""); sub(/[\t ]+/,"_"); print }; | |
151 | /global:/ { inglobal=1};' \ | |
152 | > $library.exp | |
153 | export="-Wl,-exported_symbols_list,$library.exp" | |
154 | if [ ! -z "$ignore" ] ; then | |
155 | export="$export,-undefined,dynamic_lookup" | |
156 | fi | |
157 | fi | |
158 | echo "$linker $export -o $filename $*" | |
159 | $linker $export -o "$filename" "$@" | |
160 | ;; | |
161 | *) | |
162 | echo "$linker -o $filename $*" | |
163 | $linker -o "$filename" "$@" | |
164 | ;; | |
165 | esac |