Debian Codegraph @

src/makeverslink.in

raw
1 #!/bin/sh
2 # Helper script to create a symlink to sharedlib,
3 # like libgauche-0.9.so -> libgauche-0.9.so.0.1
4 # Assumes $TARGETLIB and $DESTDIR is set by the caller.
5
6 # In some occasions, TARGETLIB contains a path like
7 # '@executable_path/../Frameworks/Gauche.framework'.
8 # We don't need to create links in such case.
9
10 # NB: In 0.9.x series, we create a link libgauche.so -> libgauche-0.9.so
11 # for the backward comatibility. This feature should be removed on 1.0
12 # release.
13
14 set -e
15
16 case "$TARGETLIB" in
17 "@*")
18 exit 0;;
19 "")
20 echo "TAGRETLIB must be set"
21 exit 1;;
22 esac
23
24 mode=create
25 case "$1" in
26 -d )
27 mode=delete
28 shift;;
29 -* )
30 mode=help
31 shift;;
32 esac
33
34 if test \( $# != 1 \) -o $mode = "help"; then
35 echo "Usage: makeverslink [-d] LIBGAUCHE"
36 echo "LIBGAUCHE is the name of Gauche DSO, e.g. libgauche-0.9.so"
37 echo "Environment variable TARGETLIB and DESTDIR must be set"
38 echo "If -d option is given, remove links instead of creating"
39 exit 0
40 fi
41
42
43 LIBGAUCHE=$1
44
45 MICRO_VERSION=@GAUCHE_MICRO_VERSION@
46
47 LIB_VVV=$LIBGAUCHE.0.$MICRO_VERSION
48 LIB_V=$LIBGAUCHE.0
49 LIB_COMPAT=libgauche.so
50
51 cd "$DESTDIR$TARGETLIB"
52 case "$mode" in
53 create)
54 # avoid re-running mkverslink.
55 if test -f $LIB_VVV -a -L $LIBGAUCHE; then exit; fi
56 rm -f $LIB_VVV
57 mv $LIBGAUCHE $LIB_VVV
58 ln -s $LIB_VVV $LIBGAUCHE
59 rm -f $LIB_V
60 ln -s $LIB_VVV $LIB_V
61
62 if [ -f $LIB_COMPAT ]; then
63 rm -f $LIB_COMPAT
64 ln -s $LIBGAUCHE $LIB_COMPAT
65 fi
66 if [ -f $LIB_COMPAT.0 ]; then
67 rm -f $LIB_COMPAT.0
68 ln -s $LIB_V $LIB_COMPAT.0
69 fi
70 if [ -f $LIB_COMPAT.0.9.0 ]; then
71 rm -f $LIB_COMPAT.0.9.0
72 ln -s $LIB_VVV $LIB_COMPAT.0.9.0
73 fi
74 ;;
75 delete)
76 rm -f $LIB_VVV $LIB_V $LIBGAUCHE $LIB_COMPAT $LIB_COMPAT.0 $LIB_COMPAT.0.9.0
77 ;;
78 esac