3 # shlib-install - install a shared library and do any necessary host-specific
4 # post-installation configuration (like ldconfig)
6 # usage: shlib-install [-D] -O host_os -d installation-dir -i install-prog [-U] library
14 INSTALLDIR=/usr/local/lib
17 PROGNAME=`basename $0`
18 USAGE="$PROGNAME [-D] -O host_os -d installation-dir -i install-prog [-U] library"
22 while [ $# -gt 0 ]; do
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;;
34 # set install target name
37 if [ -z "$LIBNAME" ]; then
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}
58 if [ -z "$uninstall" ] ; then
59 ${echo} eval ${INSTALLPROG} $LIBNAME ${INSTALLDIR}/${LIBNAME}
61 ${echo} ${RM} ${INSTALLDIR}/${LIBNAME}
64 # post-install/uninstall
66 # HP-UX requires that a shared library have execute permission
68 hpux*) if [ -z "$uninstall" ]; then
69 chmod 755 ${INSTALLDIR}/${LIBNAME}
75 *.*.[0-9].[0-9]) # libname.so.M.N
76 LINK2=`echo $LIBNAME | sed 's:\(.*\..*\.[0-9]\)\.[0-9]:\1:'` # libname.so.M
77 LINK1=`echo $LIBNAME | sed 's:\(.*\..*\)\.[0-9]\.[0-9]:\1:'` # libname.so
79 *.*.[0-9]) # libname.so.M
80 LINK1=`echo $LIBNAME | sed 's:\(.*\..*\)\.[0-9]:\1:'` # libname.so
83 LINK1=`echo $LIBNAME | sed 's:\(.*\)\.[0-9]:\1:'` # libname
88 # Create symlinks to the installed library. This section is incomplete.
92 # libname.so.M -> libname.so.M.N
93 ${echo} ${RM} ${INSTALLDIR}/$LINK2
94 if [ -z "$uninstall" ]; then
95 ${echo} ln -s $INSTALLDIR/$LIBNAME ${INSTALLDIR}/$LINK2
98 # libname.so -> libname.so.M.N
99 ${echo} ${RM} ${INSTALLDIR}/$LINK1
100 if [ -z "$uninstall" ]; then
101 ${echo} ln -s $INSTALLDIR/$LIBNAME ${INSTALLDIR}/$LINK1
105 solaris2*|aix4.[2-9]*|osf*|irix[56]*)
106 # libname.so -> libname.so.M
107 ${echo} ${RM} ${INSTALLDIR}/$LINK1
108 if [ -z "$uninstall" ]; then
109 ${echo} ln -s $INSTALLDIR/$LIBNAME ${INSTALLDIR}/$LINK1
114 # FreeBSD 3.x can have either a.out or ELF shared libraries
116 if [ -x /usr/bin/objformat ] && [ "`/usr/bin/objformat`" = "elf" ]; then
117 # libname.so -> libname.so.M
118 ${echo} ${RM} ${INSTALLDIR}/$LINK1
119 if [ -z "$uninstall" ]; then
120 ${echo} ln -s $INSTALLDIR/$LIBNAME ${INSTALLDIR}/$LINK1
123 # libname.so.M -> libname.so.M.N
124 ${echo} ${RM} ${INSTALLDIR}/$LINK2
125 if [ -z "$uninstall" ]; then
126 ${echo} ln -s $INSTALLDIR/$LIBNAME ${INSTALLDIR}/$LINK2
129 # libname.so -> libname.so.M.N
130 ${echo} ${RM} ${INSTALLDIR}/$LINK1
131 if [ -z "$uninstall" ]; then
132 ${echo} ln -s $INSTALLDIR/$LIBNAME ${INSTALLDIR}/$LINK1
138 # libname.sl -> libname.M
139 ${echo} ${RM} ${INSTALLDIR}/$LINK1.sl
140 if [ -z "$uninstall" ]; then
141 ${echo} ln -s $INSTALLDIR/$LIBNAME ${INSTALLDIR}/${LINK1}.sl