Import of readline 4.3.
[deliverable/binutils-gdb.git] / readline / support / shlib-install
1 #! /bin/sh
2 #
3 # shlib-install - install a shared library and do any necessary host-specific
4 # post-installation configuration (like ldconfig)
5 #
6 # usage: shlib-install [-D] -O host_os -d installation-dir -i install-prog [-U] library
7 #
8 # Chet Ramey
9 # chet@po.cwru.edu
10
11 #
12 # defaults
13 #
14 INSTALLDIR=/usr/local/lib
15 LDCONFIG=ldconfig
16
17 PROGNAME=`basename $0`
18 USAGE="$PROGNAME [-D] -O host_os -d installation-dir -i install-prog [-U] library"
19
20 # process options
21
22 while [ $# -gt 0 ]; do
23 case "$1" in
24 -O) shift; host_os="$1"; shift ;;
25 -d) shift; INSTALLDIR="$1"; shift ;;
26 -i) shift; INSTALLPROG="$1" ; shift ;;
27 -D) echo=echo ; shift ;;
28 -U) uninstall=true ; shift ;;
29 -*) echo "$USAGE" >&2 ; exit 2;;
30 *) break ;;
31 esac
32 done
33
34 # set install target name
35 LIBNAME="$1"
36
37 if [ -z "$LIBNAME" ]; then
38 echo "$USAGE" >&2
39 exit 2
40 fi
41
42 OLDSUFF=old
43 MV=mv
44 RM="rm -f"
45 LN="ln -s"
46
47 # pre-install
48
49 if [ -z "$uninstall" ]; then
50 ${echo} $RM ${INSTALLDIR}/${LIBNAME}.${OLDSUFF}
51 if [ -f "$INSTALLDIR/$LIBNAME" ]; then
52 ${echo} $MV $INSTALLDIR/$LIBNAME ${INSTALLDIR}/${LIBNAME}.${OLDSUFF}
53 fi
54 fi
55
56 # install/uninstall
57
58 if [ -z "$uninstall" ] ; then
59 ${echo} eval ${INSTALLPROG} $LIBNAME ${INSTALLDIR}/${LIBNAME}
60 else
61 ${echo} ${RM} ${INSTALLDIR}/${LIBNAME}
62 fi
63
64 # post-install/uninstall
65
66 # HP-UX and Darwin/MacOS X require that a shared library have execute permission
67 case "$host_os" in
68 hpux*|darwin*|macosx*)
69 if [ -z "$uninstall" ]; then
70 chmod 555 ${INSTALLDIR}/${LIBNAME}
71 fi ;;
72 *) ;;
73 esac
74
75 case "$LIBNAME" in
76 *.*.[0-9].[0-9]) # libname.so.M.N
77 LINK2=`echo $LIBNAME | sed 's:\(.*\..*\.[0-9]\)\.[0-9]:\1:'` # libname.so.M
78 LINK1=`echo $LIBNAME | sed 's:\(.*\..*\)\.[0-9]\.[0-9]:\1:'` # libname.so
79 ;;
80 *.*.[0-9]) # libname.so.M
81 LINK1=`echo $LIBNAME | sed 's:\(.*\..*\)\.[0-9]:\1:'` # libname.so
82 ;;
83 *.[0-9]) # libname.M
84 LINK1=`echo $LIBNAME | sed 's:\(.*\)\.[0-9]:\1:'` # libname
85 ;;
86 *.[0-9].[0-9].dylib) # libname.M.N.dylib
87 LINK2=`echo $LIBNAME | sed 's:\(.*\.[0-9]\)\.[0-9]:\1:'` # libname.M.dylib
88 LINK1=`echo $LIBNAME | sed 's:\(.*\)\.[0-9]\.[0-9]:\1:'` # libname.dylib
89 esac
90
91 INSTALL_LINK1='cd $INSTALLDIR ; ln -s $LIBNAME $LINK1'
92 INSTALL_LINK2='cd $INSTALLDIR ; ln -s $LIBNAME $LINK2'
93
94 #
95 # Create symlinks to the installed library. This section is incomplete.
96 #
97 case "$host_os" in
98 *linux*|bsdi4*|*gnu*|darwin*|macosx*)
99 # libname.so.M -> libname.so.M.N
100 ${echo} ${RM} ${INSTALLDIR}/$LINK2
101 if [ -z "$uninstall" ]; then
102 ${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK2
103 fi
104
105 # libname.so -> libname.so.M.N
106 ${echo} ${RM} ${INSTALLDIR}/$LINK1
107 if [ -z "$uninstall" ]; then
108 ${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK1
109 fi
110 ;;
111
112 solaris2*|aix4.[2-9]*|osf*|irix[56]*|sysv[45]*|dgux*)
113 # libname.so -> libname.so.M
114 ${echo} ${RM} ${INSTALLDIR}/$LINK1
115 if [ -z "$uninstall" ]; then
116 ${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK1
117 fi
118 ;;
119
120
121 # FreeBSD 3.x and above can have either a.out or ELF shared libraries
122 freebsd[3-9]*|freebsdelf[3-9]*|freebsdaout[3-9]*)
123 if [ -x /usr/bin/objformat ] && [ "`/usr/bin/objformat`" = "elf" ]; then
124 # libname.so -> libname.so.M
125 ${echo} ${RM} ${INSTALLDIR}/$LINK1
126 if [ -z "$uninstall" ]; then
127 ${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK1
128 fi
129 else
130 # libname.so.M -> libname.so.M.N
131 ${echo} ${RM} ${INSTALLDIR}/$LINK2
132 if [ -z "$uninstall" ]; then
133 ${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK2
134 fi
135
136 # libname.so -> libname.so.M.N
137 ${echo} ${RM} ${INSTALLDIR}/$LINK1
138 if [ -z "$uninstall" ]; then
139 ${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK1
140 fi
141 fi
142 ;;
143
144 hpux1*)
145 # libname.sl -> libname.M
146 ${echo} ${RM} ${INSTALLDIR}/$LINK1.sl
147 if [ -z "$uninstall" ]; then
148 # ${echo} ln -s $LIBNAME ${INSTALLDIR}/${LINK1}.sl
149 ${echo} ln -s $LIBNAME ${INSTALLDIR}/${LINK1}
150 fi
151 ;;
152
153 *) ;;
154 esac
155
156 exit 0
This page took 0.033041 seconds and 4 git commands to generate.