Add to git.
[makeplus.git] / link_dynamic.sh
1 #!/bin/sh
2 #
3 # This is make+. Make+ is a set of scripts which enhance GNU make and
4 # let ou build RPMs, and other packages types with just one control
5 # file. Read more at http://www.annexia.org/freeware/makeplus/
6 #
7 # The original author is Richard W.M. Jones <rich@annexia.org>.
8 #
9 # This software has been explicitly placed in the PUBLIC DOMAIN.  You
10 # do not need any sort of license or agreement to use or copy this
11 # software. You may also copyright this software yourself, and/or
12 # relicense it under any terms you want, at any time and at no cost.
13 # This allows you (among other things) to include this software with
14 # other packages so that the user does not need to download and
15 # install make+ separately.
16
17 set -e
18
19 # Find the name of the linker -soname option.
20 # XXX This is wrong: during the configure stage we should work out
21 # which Solaris linker we are using (gcc has it as a hard-coded path)
22 # and choose the appropriate option.
23 soname_opt=-soname
24 if [ `uname` = "SunOS" ]; then
25     soname_opt=-h
26 fi
27
28 library="$1"; shift
29
30 soname="$library.$VERSION_MAJOR"
31 filename="$library.$VERSION_MAJOR.$VERSION_MINOR"
32
33 base_soname=`basename "$soname"`
34 base_filename=`basename "$filename"`
35
36 gcc -shared -Wl,$soname_opt,"$base_soname" -o "$filename" "$@"
37 rm -f "$soname" "$library"
38 ln -s "$base_filename" "$soname"
39 ln -s "$base_soname" "$library"