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 [-b bin-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 [-b bin-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 -b) shift; BINDIR="$1" ; shift ;;
27 -i) shift; INSTALLPROG="$1" ; shift ;;
28 -D) echo=echo ; shift ;;
29 -U) uninstall=true ; shift ;;
30 -*) echo "$USAGE" >&2 ; exit 2;;
35 # set install target name
38 if [ -z "$LIBNAME" ]; then
50 if [ -z "$uninstall" ]; then
51 ${echo} $RM ${INSTALLDIR}/${LIBNAME}.${OLDSUFF}
52 if [ -f "$INSTALLDIR/$LIBNAME" ]; then
53 ${echo} $MV $INSTALLDIR/$LIBNAME ${INSTALLDIR}/${LIBNAME}.${OLDSUFF}
59 if [ -z "$uninstall" ] ; then
60 ${echo} eval ${INSTALLPROG} $LIBNAME ${INSTALLDIR}/${LIBNAME}
62 ${echo} ${RM} ${INSTALLDIR}/${LIBNAME}
65 # post-install/uninstall
67 # HP-UX and Darwin/MacOS X require that a shared library have execute permission
68 # Linux does, too, and ldd warns about it
69 # Cygwin installs both a dll (which must go in $BINDIR) and an implicit
70 # link library (in $libdir)
72 hpux*|darwin*|macosx*|linux*)
73 if [ -z "$uninstall" ]; then
74 chmod 555 ${INSTALLDIR}/${LIBNAME}
77 IMPLIBNAME=`echo ${LIBNAME} \
78 | sed -e 's,^cyg,lib,' -e 's,[0-9]*.dll$,.dll.a,'`
79 if [ -z "$uninstall" ]; then
80 ${echo} $RM ${BINDIR}/${LIBNAME}.${OLDSUFF}
81 if [ -f "$BINDIR/$LIBNAME" ]; then
82 ${echo} $MV $BINDIR/$LIBNAME $BINDIR/$LIBNAME.$OLDSUFF
84 ${echo} $MV ${INSTALLDIR}/${LIBNAME} ${BINDIR}/${LIBNAME}
85 ${echo} chmod a+x ${BINDIR}/${LIBNAME}
86 ${echo} eval ${INSTALLPROG} ${LIBNAME}.a \
87 ${INSTALLDIR}/${IMPLIBNAME}
89 ${echo} ${RM} ${BINDIR}/${LIBNAME}
90 ${echo} ${RM} ${INSTALLDIR}/${IMPLIBNAME}
97 *.*.[0-9].[0-9]) # libname.so.M.N
98 LINK2=`echo $LIBNAME | sed 's:\(.*\..*\.[0-9]\)\.[0-9]:\1:'` # libname.so.M
99 LINK1=`echo $LIBNAME | sed 's:\(.*\..*\)\.[0-9]\.[0-9]:\1:'` # libname.so
101 *.*.[0-9]) # libname.so.M
102 LINK1=`echo $LIBNAME | sed 's:\(.*\..*\)\.[0-9]:\1:'` # libname.so
105 LINK1=`echo $LIBNAME | sed 's:\(.*\)\.[0-9]:\1:'` # libname
107 *.[0-9].[0-9].dylib) # libname.M.N.dylib
108 LINK2=`echo $LIBNAME | sed 's:\(.*\.[0-9]\)\.[0-9]:\1:'` # libname.M.dylib
109 LINK1=`echo $LIBNAME | sed 's:\(.*\)\.[0-9]\.[0-9]:\1:'` # libname.dylib
112 INSTALL_LINK1='${echo} cd $INSTALLDIR && ${echo} ${LN} $LIBNAME $LINK1'
113 INSTALL_LINK2='${echo} cd $INSTALLDIR && ${echo} ${LN} $LIBNAME $LINK2'
116 # Create symlinks to the installed library. This section is incomplete.
120 # libname.so.M -> libname.so.M.N
121 ${echo} ${RM} ${INSTALLDIR}/$LINK2
122 if [ -z "$uninstall" ]; then
126 # libname.so -> libname.so.M
127 ${echo} ${RM} ${INSTALLDIR}/$LINK1
128 if [ -z "$uninstall" ]; then
129 ${echo} cd $INSTALLDIR && ${echo} ${LN} $LINK2 $LINK1
133 bsdi4*|*gnu*|darwin*|macosx*|k*bsd*-gnu)
134 # libname.so.M -> libname.so.M.N
135 ${echo} ${RM} ${INSTALLDIR}/$LINK2
136 if [ -z "$uninstall" ]; then
140 # libname.so -> libname.so.M.N
141 ${echo} ${RM} ${INSTALLDIR}/$LINK1
142 if [ -z "$uninstall" ]; then
147 solaris2*|aix4.[2-9]*|osf*|irix[56]*|sysv[45]*|dgux*)
148 # libname.so -> libname.so.M
149 ${echo} ${RM} ${INSTALLDIR}/$LINK1
150 if [ -z "$uninstall" ]; then
156 # FreeBSD 3.x and above can have either a.out or ELF shared libraries
157 freebsd[3-9]*|freebsdelf[3-9]*|freebsdaout[3-9]*)
158 if [ -x /usr/bin/objformat ] && [ "`/usr/bin/objformat`" = "elf" ]; then
159 # libname.so -> libname.so.M
160 ${echo} ${RM} ${INSTALLDIR}/$LINK1
161 if [ -z "$uninstall" ]; then
165 # libname.so.M -> libname.so.M.N
166 ${echo} ${RM} ${INSTALLDIR}/$LINK2
167 if [ -z "$uninstall" ]; then
171 # libname.so -> libname.so.M.N
172 ${echo} ${RM} ${INSTALLDIR}/$LINK1
173 if [ -z "$uninstall" ]; then
180 # libname.sl -> libname.M
181 ${echo} ${RM} ${INSTALLDIR}/$LINK1.sl
182 if [ -z "$uninstall" ]; then
188 # Links to .dlls don't work. Hence shobj-conf used DLLVERSION.dll
189 # instead of so.SHLIB_MAJOR.SHLIB_MINOR. The postinstall above
190 # took care of everything else.