Annotation of embedaddon/readline/support/shlib-install, revision 1.1.1.2

1.1       misho       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 [-V host_vendor] -d installation-dir [-b bin-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 [-V host_vendor] -d installation-dir [-b bin-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:        -V)     shift; host_vendor="$1"; shift ;;
                     26:        -d)     shift; INSTALLDIR="$1"; shift ;;
                     27:        -b)     shift; BINDIR="$1" ; shift ;;
                     28:        -i)     shift; INSTALLPROG="$1" ; shift ;;
                     29:        -D)     echo=echo ; shift ;;
                     30:        -U)     uninstall=true ; shift ;;
                     31:        -*)     echo "$USAGE" >&2 ; exit 2;;
                     32:        *)      break ;;
                     33:        esac
                     34: done
                     35: 
                     36: # set install target name
                     37: LIBNAME="$1"
                     38: 
                     39: if [ -z "$LIBNAME" ]; then
                     40:        echo "$USAGE" >&2
                     41:        exit 2
                     42: fi
                     43: 
                     44: OLDSUFF=old
                     45: MV=mv
                     46: RM="rm -f"
                     47: LN="ln -s"
                     48: 
                     49: # pre-install
                     50: 
                     51: if [ -z "$uninstall" ]; then
                     52:        ${echo} $RM ${INSTALLDIR}/${LIBNAME}.${OLDSUFF}
                     53:        if [ -f "$INSTALLDIR/$LIBNAME" ]; then
                     54:                ${echo} $MV $INSTALLDIR/$LIBNAME ${INSTALLDIR}/${LIBNAME}.${OLDSUFF}
                     55:        fi
                     56: fi
                     57: 
                     58: # install/uninstall
                     59: 
                     60: if [ -z "$uninstall" ] ; then
                     61:        ${echo} eval ${INSTALLPROG} $LIBNAME ${INSTALLDIR}/${LIBNAME}
                     62: else
                     63:        ${echo} ${RM} ${INSTALLDIR}/${LIBNAME}
                     64: fi
                     65: 
                     66: # post-install/uninstall
                     67: 
                     68: # HP-UX and Darwin/MacOS X require that a shared library have execute permission
                     69: # Linux does, too, and ldd warns about it.  Solaris doesn't seem to mind,
                     70: # but ldd still warns about it.
                     71: # Cygwin installs both a dll (which must go in $BINDIR) and an implicit
                     72: # link library (in $libdir)
                     73: case "$host_os" in
                     74: hpux*|darwin*|macosx*|linux*|solaris2*)
                     75:        if [ -z "$uninstall" ]; then
                     76:                chmod 555 ${INSTALLDIR}/${LIBNAME}
                     77:        fi ;;
                     78: cygwin*|mingw*)
                     79:        IMPLIBNAME=`echo ${LIBNAME} \
                     80:                | sed -e 's,^cyg,lib,' -e 's,[0-9]*.dll$,.dll.a,'`
                     81:        if [ -z "$uninstall" ]; then
                     82:                ${echo} $RM ${BINDIR}/${LIBNAME}.${OLDSUFF}
                     83:                if [ -f "$BINDIR/$LIBNAME" ]; then
                     84:                        ${echo} $MV $BINDIR/$LIBNAME $BINDIR/$LIBNAME.$OLDSUFF
                     85:                fi
                     86:                ${echo} $MV ${INSTALLDIR}/${LIBNAME} ${BINDIR}/${LIBNAME}
                     87:                ${echo} chmod a+x ${BINDIR}/${LIBNAME}
                     88:                ${echo} eval ${INSTALLPROG} ${LIBNAME}.a \
                     89:                        ${INSTALLDIR}/${IMPLIBNAME}
                     90:        else
                     91:                ${echo} ${RM} ${BINDIR}/${LIBNAME}
                     92:                ${echo} ${RM} ${INSTALLDIR}/${IMPLIBNAME}
                     93:        fi ;;
                     94: 
                     95: *)     ;;
                     96: esac
                     97: 
                     98: case "$LIBNAME" in
                     99: *.*.[0-9].[0-9])       # libname.so.M.N
                    100:        LINK2=`echo $LIBNAME | sed 's:\(.*\..*\.[0-9]\)\.[0-9]:\1:'`    # libname.so.M
                    101:        LINK1=`echo $LIBNAME | sed 's:\(.*\..*\)\.[0-9]\.[0-9]:\1:'`    # libname.so
                    102:        ;;
                    103: *.*.[0-9])             # libname.so.M
                    104:        LINK1=`echo $LIBNAME | sed 's:\(.*\..*\)\.[0-9]:\1:'`           # libname.so
                    105:        ;;
                    106: *.[0-9])               # libname.M
                    107:        LINK1=`echo $LIBNAME | sed 's:\(.*\)\.[0-9]:\1:'`               # libname
                    108:        ;;
                    109: *.[0-9].[0-9].dylib)   # libname.M.N.dylib
                    110:        LINK2=`echo $LIBNAME | sed 's:\(.*\.[0-9]\)\.[0-9]:\1:'`        # libname.M.dylib
                    111:        LINK1=`echo $LIBNAME | sed 's:\(.*\)\.[0-9]\.[0-9]:\1:'`        # libname.dylib
                    112: esac
                    113: 
                    114: INSTALL_LINK1='${echo} cd $INSTALLDIR && ${echo} ${LN} $LIBNAME $LINK1'
                    115: INSTALL_LINK2='${echo} cd $INSTALLDIR && ${echo} ${LN} $LIBNAME $LINK2'
                    116: 
                    117: #
                    118: # Create symlinks to the installed library.  This section is incomplete.
                    119: #
                    120: case "$host_os-$host_vendor" in
                    121: *linux*|freebsd*-gentoo)
                    122:        # libname.so.M -> libname.so.M.N
                    123:        ${echo} ${RM} ${INSTALLDIR}/$LINK2
                    124:        if [ -z "$uninstall" ]; then
                    125:                eval $INSTALL_LINK2
                    126:        fi
                    127: 
                    128:        # libname.so -> libname.so.M
                    129:        ${echo} ${RM} ${INSTALLDIR}/$LINK1
                    130:        if [ -z "$uninstall" ]; then
                    131:                ${echo} cd $INSTALLDIR && ${echo} ${LN} $LINK2 $LINK1
                    132:        fi
                    133:        ;;
                    134: 
                    135: bsdi4*|*gnu*|darwin*|macosx*|netbsd*|mirbsd*)
                    136:        # libname.so.M -> libname.so.M.N
                    137:        ${echo} ${RM} ${INSTALLDIR}/$LINK2
                    138:        if [ -z "$uninstall" ]; then
                    139:                eval $INSTALL_LINK2
                    140:        fi
                    141: 
                    142:        # libname.so -> libname.so.M.N
                    143:        ${echo} ${RM} ${INSTALLDIR}/$LINK1
                    144:        if [ -z "$uninstall" ]; then
                    145:                eval $INSTALL_LINK1
                    146:        fi
                    147:        ;;
                    148: 
                    149: solaris2*|aix4.[2-9]*|aix[5-9]*|osf*|irix[56]*|sysv[45]*|dgux*|interix*)
                    150:        # libname.so -> libname.so.M
                    151:        ${echo} ${RM} ${INSTALLDIR}/$LINK1
                    152:        if [ -z "$uninstall" ]; then
                    153:                eval $INSTALL_LINK1
                    154:        fi
                    155:        ;;
                    156: 
                    157: 
                    158: # FreeBSD 3.x and above can have either a.out or ELF shared libraries
1.1.1.2 ! misho     159: freebsd3.*|freebsdaout*)
1.1       misho     160:        if [ -x /usr/bin/objformat ] && [ "`/usr/bin/objformat`" = "elf" ]; then
                    161:                # libname.so -> libname.so.M
                    162:                ${echo} ${RM} ${INSTALLDIR}/$LINK1
                    163:                if [ -z "$uninstall" ]; then
                    164:                        eval $INSTALL_LINK1
                    165:                fi
                    166:        else
                    167:                # libname.so.M -> libname.so.M.N
                    168:                ${echo} ${RM} ${INSTALLDIR}/$LINK2
                    169:                if [ -z "$uninstall" ]; then
                    170:                        eval $INSTALL_LINK2
                    171:                fi
                    172: 
                    173:                # libname.so -> libname.so.M.N
                    174:                ${echo} ${RM} ${INSTALLDIR}/$LINK1
                    175:                if [ -z "$uninstall" ]; then
                    176:                        eval $INSTALL_LINK1
                    177:                fi
                    178:        fi
                    179:        ;;
                    180: 
                    181: freebsd[4-9]*|freebsd1[0-9]*|freebsdelf*|dragonfly*)
                    182:        # libname.so -> libname.so.M
                    183:        ${echo} ${RM} ${INSTALLDIR}/$LINK1
                    184:        if [ -z "$uninstall" ]; then
                    185:                eval $INSTALL_LINK1
                    186:        fi
                    187:        ;;
                    188:        
                    189: hpux1*)
                    190:        # libname.sl -> libname.M
                    191:        ${echo} ${RM} ${INSTALLDIR}/$LINK1.sl
                    192:        if [ -z "$uninstall" ]; then
                    193:                eval $INSTALL_LINK1
                    194:        fi
                    195:        ;;
                    196: 
                    197: cygwin*|mingw*)
                    198:        # Links to .dlls don't work.  Hence shobj-conf used DLLVERSION.dll
                    199:        # instead of so.SHLIB_MAJOR.SHLIB_MINOR.  The postinstall above
                    200:        # took care of everything else.
                    201:        ;;
                    202: 
                    203: *)     ;;
                    204: esac
                    205: 
                    206: exit 0

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>