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@"
29 while [ -z "$done" ] && [ $# -gt 0 ] ; do
69 echo 'Usage: shlib-build (-p -f <file> | [-i] -l <lib> -M <major> -m <minor>) -- ...' >&2
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
80 # Print out what we're doing while we do it for debugging.
82 if [ -z "$filename" ] ; then
83 if [ -z "$major" ] ; then
84 filename
="$library.$suffix"
87 filename
="$library.$suffix.$major.$minor"
88 soname
="$library.$suffix.$major"
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};' \
99 export="-bE:$library.exp"
101 echo "$linker $export -o $filename $*"
102 $linker $export -o "$filename" "$@"
105 if [ -z "$plain" ] && [ -f "$srcdir/$library.map" ] ; then
106 if [ -z "$ignore" ] ; then
107 export="-Wl,-M$srcdir/$library.map"
109 # add "= EXTERN" to every symbol, so we don't get errors about
111 cat "$srcdir/$library.map" | \
112 sed -e 's/\([a-zA-Z_]\);$/\1 = EXTERN;/' > "$library.real.map"
113 export="-Wl,-M$library.real.map"
116 if [ -z "$soname" ] ; then
117 echo "$linker $export -o $filename $*"
118 $linker $export -o "$filename" "$@"
120 echo "$linker $export -h $soname -o $filename $*"
121 $linker $export -h "$soname" -o "$filename" "$@"
125 if [ -z "$plain" ] && [ -f "$srcdir/$library.map" ] ; then
126 export="-Wl,--version-script=$srcdir/$library.map"
128 if [ -z "$soname" ] ; then
129 echo "$linker $export -o $filename $*"
130 $linker $export -o "$filename" "$@"
132 echo "$linker $export -Wl,-h,$soname -o $filename $*"
133 $linker $export -Wl,-h,"$soname" -o "$filename" "$@"
137 if [ -z "$plain" ] && [ -f "$srcdir/$library.hp" ] ; then
138 export="-c $srcdir/$library.hp"
140 echo "$linker $export -o $filename $*"
141 $linker $export -o "$filename" "$@"
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};
150 inglobal { sub(/;/,""); sub(/[\t ]+/,"_"); print };
151 /global:/ { inglobal=1};' \
153 export="-Wl,-exported_symbols_list,$library.exp"
154 if [ ! -z "$ignore" ] ; then
155 export="$export,-undefined,dynamic_lookup"
158 echo "$linker $export -o $filename $*"
159 $linker $export -o "$filename" "$@"
162 echo "$linker -o $filename $*"
163 $linker -o "$filename" "$@"