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.
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.
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.
18 linker="@SHLIB_LINKER@"
19 suffix="@SHLIB_SUFFIX@"
20 sysname="@AFS_SYSNAME@"
28 while [ -z "$done" ] && [ $# -gt 0 ] ; do
64 echo 'Usage: shlib-build [-i] -l <lib> -M <major> -m <minor> -- ...' >&2
69 if [ -z "$library" ] ; then
70 echo 'Usage: shlib-build [-i] -l <lib> -M <major> -m <minor> -- ...' >&2
74 # Print out what we're doing while we do it for debugging.
76 if [ -z "$filename" ] ; then
77 if [ -z "$major" ] ; then
78 filename="$library.$suffix"
81 filename="$library.$suffix.$major.$minor"
82 soname="$library.$suffix.$major"
87 if [ -f "$srcdir/$library.map" ] ; then
88 cat $srcdir/$library.map | \
89 awk '/local:/ {inglobal=0};
90 inglobal { sub(/;/,""); print };
91 /global:/ { inglobal=1};' \
93 export="-bE:$library.exp"
95 echo "$linker $export -o $filename $*"
96 $linker $export -o "$filename" "$@"
99 if [ -f "$srcdir/$library.map" ] ; then
100 if [ -z "$ignore" ] ; then
101 export="-Wl,-M$srcdir/$library.map"
103 # add "= EXTERN" to every symbol, so we don't get errors about
105 cat "$srcdir/$library.map" | \
106 sed -e 's/\([a-zA-Z_]\);$/\1 = EXTERN;/' > "$library.real.map"
107 export="-Wl,-M$library.real.map"
110 if [ -z "$soname" ] ; then
111 echo "$linker $export -o $filename $*"
112 $linker $export -o "$filename" "$@"
114 echo "$linker $export -h $soname -o $filename $*"
115 $linker $export -h "$soname" -o "$filename" "$@"
119 if [ -f "$srcdir/$library.map" ] ; then
120 export="-Wl,--version-script=$srcdir/$library.map"
122 if [ -z "$soname" ] ; then
123 echo "$linker $export -o $filename $*"
124 $linker $export -o "$filename" "$@"
126 echo "$linker $export -Wl,-h,$soname -o $filename $*"
127 $linker $export -Wl,-h,"$soname" -o "$filename" "$@"
131 if [ -f "$srcdir/$library.hp" ] ; then
132 export="-c $srcdir/$library.hp"
134 echo "$linker $export -o $filename $*"
135 $linker $export -o "$filename" "$@"
138 if [ -f "$srcdir/$library.map" ] ; then
139 # For 10.4 and later, the Mac exports list is a list of symbols,
140 # prefixed with an '_'
141 cat $srcdir/$library.map | \
142 awk '/local:/ {inglobal=0};
144 inglobal { sub(/;/,""); sub(/[\t ]+/,"_"); print };
145 /global:/ { inglobal=1};' \
147 export="-Wl,-exported_symbols_list,$library.exp"
148 if [ ! -z "$ignore" ] ; then
149 export="$export,-flat_namespace,-undefined,suppress"
152 echo "$linker $export -o $filename $*"
153 $linker $export -o "$filename" "$@"
156 echo "$linker -o $filename $*"
157 $linker -o "$filename" "$@"