freebsd-dev/contrib/libreadline/support/shlib-install

197 lines
4.7 KiB
Plaintext
Raw Normal View History

1999-05-28 01:59:23 +00:00
#! /bin/sh
#
# shlib-install - install a shared library and do any necessary host-specific
# post-installation configuration (like ldconfig)
#
2006-03-27 22:47:12 +00:00
# usage: shlib-install [-D] -O host_os -d installation-dir [-b bin-dir] -i install-prog [-U] library
1999-05-28 01:59:23 +00:00
#
# Chet Ramey
# chet@po.cwru.edu
#
# defaults
#
INSTALLDIR=/usr/local/lib
LDCONFIG=ldconfig
PROGNAME=`basename $0`
2006-03-27 22:47:12 +00:00
USAGE="$PROGNAME [-D] -O host_os -d installation-dir [-b bin-dir] -i install-prog [-U] library"
1999-05-28 01:59:23 +00:00
# process options
while [ $# -gt 0 ]; do
case "$1" in
-O) shift; host_os="$1"; shift ;;
-d) shift; INSTALLDIR="$1"; shift ;;
2006-03-27 22:47:12 +00:00
-b) shift; BINDIR="$1" ; shift ;;
1999-05-28 01:59:23 +00:00
-i) shift; INSTALLPROG="$1" ; shift ;;
-D) echo=echo ; shift ;;
-U) uninstall=true ; shift ;;
-*) echo "$USAGE" >&2 ; exit 2;;
*) break ;;
esac
done
# set install target name
LIBNAME="$1"
if [ -z "$LIBNAME" ]; then
echo "$USAGE" >&2
exit 2
fi
OLDSUFF=old
MV=mv
RM="rm -f"
LN="ln -s"
# pre-install
if [ -z "$uninstall" ]; then
${echo} $RM ${INSTALLDIR}/${LIBNAME}.${OLDSUFF}
if [ -f "$INSTALLDIR/$LIBNAME" ]; then
2000-03-19 21:18:09 +00:00
${echo} $MV $INSTALLDIR/$LIBNAME ${INSTALLDIR}/${LIBNAME}.${OLDSUFF}
1999-05-28 01:59:23 +00:00
fi
fi
# install/uninstall
if [ -z "$uninstall" ] ; then
${echo} eval ${INSTALLPROG} $LIBNAME ${INSTALLDIR}/${LIBNAME}
else
${echo} ${RM} ${INSTALLDIR}/${LIBNAME}
fi
# post-install/uninstall
2003-08-31 17:55:46 +00:00
# HP-UX and Darwin/MacOS X require that a shared library have execute permission
2006-12-31 09:06:30 +00:00
# Linux does, too, and ldd warns about it
2006-03-27 22:47:12 +00:00
# Cygwin installs both a dll (which must go in $BINDIR) and an implicit
# link library (in $libdir)
2000-03-19 21:18:09 +00:00
case "$host_os" in
2006-12-31 09:06:30 +00:00
hpux*|darwin*|macosx*|linux*)
2003-08-31 17:55:46 +00:00
if [ -z "$uninstall" ]; then
2001-04-11 02:33:07 +00:00
chmod 555 ${INSTALLDIR}/${LIBNAME}
2000-03-19 21:18:09 +00:00
fi ;;
2006-03-27 22:47:12 +00:00
cygwin*)
IMPLIBNAME=`echo ${LIBNAME} \
| sed -e 's,^cyg,lib,' -e 's,[0-9]*.dll$,.dll.a,'`
if [ -z "$uninstall" ]; then
${echo} $RM ${BINDIR}/${LIBNAME}.${OLDSUFF}
if [ -f "$BINDIR/$LIBNAME" ]; then
${echo} $MV $BINDIR/$LIBNAME $BINDIR/$LIBNAME.$OLDSUFF
fi
${echo} $MV ${INSTALLDIR}/${LIBNAME} ${BINDIR}/${LIBNAME}
${echo} chmod a+x ${BINDIR}/${LIBNAME}
${echo} eval ${INSTALLPROG} ${LIBNAME}.a \
${INSTALLDIR}/${IMPLIBNAME}
else
${echo} ${RM} ${BINDIR}/${LIBNAME}
${echo} ${RM} ${INSTALLDIR}/${IMPLIBNAME}
fi ;;
2000-03-19 21:18:09 +00:00
*) ;;
esac
1999-05-28 01:59:23 +00:00
case "$LIBNAME" in
*.*.[0-9].[0-9]) # libname.so.M.N
LINK2=`echo $LIBNAME | sed 's:\(.*\..*\.[0-9]\)\.[0-9]:\1:'` # libname.so.M
LINK1=`echo $LIBNAME | sed 's:\(.*\..*\)\.[0-9]\.[0-9]:\1:'` # libname.so
;;
*.*.[0-9]) # libname.so.M
LINK1=`echo $LIBNAME | sed 's:\(.*\..*\)\.[0-9]:\1:'` # libname.so
;;
2000-03-19 21:18:09 +00:00
*.[0-9]) # libname.M
LINK1=`echo $LIBNAME | sed 's:\(.*\)\.[0-9]:\1:'` # libname
;;
2003-08-31 17:55:46 +00:00
*.[0-9].[0-9].dylib) # libname.M.N.dylib
LINK2=`echo $LIBNAME | sed 's:\(.*\.[0-9]\)\.[0-9]:\1:'` # libname.M.dylib
LINK1=`echo $LIBNAME | sed 's:\(.*\)\.[0-9]\.[0-9]:\1:'` # libname.dylib
1999-05-28 01:59:23 +00:00
esac
2004-10-18 07:02:42 +00:00
INSTALL_LINK1='${echo} cd $INSTALLDIR && ${echo} ${LN} $LIBNAME $LINK1'
INSTALL_LINK2='${echo} cd $INSTALLDIR && ${echo} ${LN} $LIBNAME $LINK2'
2001-04-11 02:33:07 +00:00
1999-05-28 01:59:23 +00:00
#
# Create symlinks to the installed library. This section is incomplete.
#
case "$host_os" in
2004-10-18 07:02:42 +00:00
*linux*)
1999-05-28 01:59:23 +00:00
# libname.so.M -> libname.so.M.N
${echo} ${RM} ${INSTALLDIR}/$LINK2
if [ -z "$uninstall" ]; then
2004-10-18 07:02:42 +00:00
eval $INSTALL_LINK2
fi
# libname.so -> libname.so.M
${echo} ${RM} ${INSTALLDIR}/$LINK1
if [ -z "$uninstall" ]; then
${echo} cd $INSTALLDIR && ${echo} ${LN} $LINK2 $LINK1
fi
;;
bsdi4*|*gnu*|darwin*|macosx*|k*bsd*-gnu)
# libname.so.M -> libname.so.M.N
${echo} ${RM} ${INSTALLDIR}/$LINK2
if [ -z "$uninstall" ]; then
eval $INSTALL_LINK2
1999-05-28 01:59:23 +00:00
fi
# libname.so -> libname.so.M.N
${echo} ${RM} ${INSTALLDIR}/$LINK1
if [ -z "$uninstall" ]; then
2004-10-18 07:02:42 +00:00
eval $INSTALL_LINK1
1999-05-28 01:59:23 +00:00
fi
;;
2003-08-31 17:55:46 +00:00
solaris2*|aix4.[2-9]*|osf*|irix[56]*|sysv[45]*|dgux*)
1999-05-28 01:59:23 +00:00
# libname.so -> libname.so.M
${echo} ${RM} ${INSTALLDIR}/$LINK1
if [ -z "$uninstall" ]; then
2004-10-18 07:02:42 +00:00
eval $INSTALL_LINK1
1999-05-28 01:59:23 +00:00
fi
;;
2000-03-19 21:18:09 +00:00
2003-08-31 17:55:46 +00:00
# FreeBSD 3.x and above can have either a.out or ELF shared libraries
freebsd[3-9]*|freebsdelf[3-9]*|freebsdaout[3-9]*)
2000-03-19 21:18:09 +00:00
if [ -x /usr/bin/objformat ] && [ "`/usr/bin/objformat`" = "elf" ]; then
# libname.so -> libname.so.M
${echo} ${RM} ${INSTALLDIR}/$LINK1
if [ -z "$uninstall" ]; then
2004-10-18 07:02:42 +00:00
eval $INSTALL_LINK1
2000-03-19 21:18:09 +00:00
fi
else
# libname.so.M -> libname.so.M.N
${echo} ${RM} ${INSTALLDIR}/$LINK2
if [ -z "$uninstall" ]; then
2004-10-18 07:02:42 +00:00
eval $INSTALL_LINK2
2000-03-19 21:18:09 +00:00
fi
# libname.so -> libname.so.M.N
${echo} ${RM} ${INSTALLDIR}/$LINK1
if [ -z "$uninstall" ]; then
2004-10-18 07:02:42 +00:00
eval $INSTALL_LINK1
2000-03-19 21:18:09 +00:00
fi
fi
;;
hpux1*)
# libname.sl -> libname.M
${echo} ${RM} ${INSTALLDIR}/$LINK1.sl
if [ -z "$uninstall" ]; then
2004-10-18 07:02:42 +00:00
eval $INSTALL_LINK1
2000-03-19 21:18:09 +00:00
fi
;;
2006-03-27 22:47:12 +00:00
cygwin*)
# Links to .dlls don't work. Hence shobj-conf used DLLVERSION.dll
# instead of so.SHLIB_MAJOR.SHLIB_MINOR. The postinstall above
# took care of everything else.
;;
1999-05-28 01:59:23 +00:00
*) ;;
esac
exit 0