]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - readline/support/shlib-install
This commit was generated by cvs2svn to track changes on a CVS vendor
[thirdparty/binutils-gdb.git] / readline / support / shlib-install
CommitLineData
c862e87b
JM
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#
14INSTALLDIR=/usr/local/lib
15LDCONFIG=ldconfig
16
17PROGNAME=`basename $0`
18USAGE="$PROGNAME [-D] -O host_os -d installation-dir -i install-prog [-U] library"
19
20# process options
21
22while [ $# -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
32done
33
34# set install target name
35LIBNAME="$1"
36
37if [ -z "$LIBNAME" ]; then
38 echo "$USAGE" >&2
39 exit 2
40fi
41
42OLDSUFF=old
43MV=mv
44RM="rm -f"
45LN="ln -s"
46
47# pre-install
48
49if [ -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
54fi
55
56# install/uninstall
57
58if [ -z "$uninstall" ] ; then
59 ${echo} eval ${INSTALLPROG} $LIBNAME ${INSTALLDIR}/${LIBNAME}
60else
61 ${echo} ${RM} ${INSTALLDIR}/${LIBNAME}
62fi
63
64# post-install/uninstall
65
66case "$LIBNAME" in
67*.*.[0-9].[0-9]) # libname.so.M.N
68 LINK2=`echo $LIBNAME | sed 's:\(.*\..*\.[0-9]\)\.[0-9]:\1:'` # libname.so.M
69 LINK1=`echo $LIBNAME | sed 's:\(.*\..*\)\.[0-9]\.[0-9]:\1:'` # libname.so
70 ;;
71*.*.[0-9]) # libname.so.M
72 LINK1=`echo $LIBNAME | sed 's:\(.*\..*\)\.[0-9]:\1:'` # libname.so
73 ;;
74esac
75
76#
77# Create symlinks to the installed library. This section is incomplete.
78#
79case "$host_os" in
80*linux*|bsdi4*)
81 # libname.so.M -> libname.so.M.N
82 ${echo} ${RM} ${INSTALLDIR}/$LINK2
83 if [ -z "$uninstall" ]; then
84 ${echo} ln -s $INSTALLDIR/$LIBNAME ${INSTALLDIR}/$LINK2
85 fi
86
87 # libname.so -> libname.so.M.N
88 ${echo} ${RM} ${INSTALLDIR}/$LINK1
89 if [ -z "$uninstall" ]; then
90 ${echo} ln -s $INSTALLDIR/$LIBNAME ${INSTALLDIR}/$LINK1
91 fi
92 ;;
93
94solaris2*|aix4.[2-9]*|hpux1*)
95 # libname.so -> libname.so.M
96 ${echo} ${RM} ${INSTALLDIR}/$LINK1
97 if [ -z "$uninstall" ]; then
98 ${echo} ln -s $INSTALLDIR/$LIBNAME ${INSTALLDIR}/$LINK1
99 fi
100 ;;
101
102*) ;;
103esac
104
105exit 0