OSDN Git Service

Readline 5.1 import for HEAD.
[pf3gnuchains/pf3gnuchains4x.git] / readline / support / shlib-install
index 654cfa9..2cd252a 100755 (executable)
@@ -3,7 +3,7 @@
 # shlib-install - install a shared library and do any necessary host-specific
 #                post-installation configuration (like ldconfig)
 #
-# usage: shlib-install [-D] -O host_os -d installation-dir -i install-prog [-U] library
+# usage: shlib-install [-D] -O host_os -d installation-dir [-b bin-dir] -i install-prog [-U] library
 #
 # Chet Ramey
 # chet@po.cwru.edu
@@ -15,7 +15,7 @@ INSTALLDIR=/usr/local/lib
 LDCONFIG=ldconfig
 
 PROGNAME=`basename $0`
-USAGE="$PROGNAME [-D] -O host_os -d installation-dir -i install-prog [-U] library"
+USAGE="$PROGNAME [-D] -O host_os -d installation-dir [-b bin-dir] -i install-prog [-U] library"
 
 # process options
 
@@ -23,6 +23,7 @@ while [ $# -gt 0 ]; do
        case "$1" in
        -O)     shift; host_os="$1"; shift ;;
        -d)     shift; INSTALLDIR="$1"; shift ;;
+       -b)     shift; BINDIR="$1" ; shift ;;
        -i)     shift; INSTALLPROG="$1" ; shift ;;
        -D)     echo=echo ; shift ;;
        -U)     uninstall=true ; shift ;;
@@ -64,11 +65,30 @@ fi
 # post-install/uninstall
 
 # HP-UX and Darwin/MacOS X require that a shared library have execute permission
+# Cygwin installs both a dll (which must go in $BINDIR) and an implicit
+# link library (in $libdir)
 case "$host_os" in
 hpux*|darwin*|macosx*)
        if [ -z "$uninstall" ]; then
                chmod 555 ${INSTALLDIR}/${LIBNAME}
        fi ;;
+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 ;;
+
 *)     ;;
 esac
 
@@ -88,24 +108,38 @@ case "$LIBNAME" in
        LINK1=`echo $LIBNAME | sed 's:\(.*\)\.[0-9]\.[0-9]:\1:'`        # libname.dylib
 esac
 
-INSTALL_LINK1='cd $INSTALLDIR ; ln -s $LIBNAME $LINK1'
-INSTALL_LINK2='cd $INSTALLDIR ; ln -s $LIBNAME $LINK2'
+INSTALL_LINK1='${echo} cd $INSTALLDIR && ${echo} ${LN} $LIBNAME $LINK1'
+INSTALL_LINK2='${echo} cd $INSTALLDIR && ${echo} ${LN} $LIBNAME $LINK2'
 
 #
 # Create symlinks to the installed library.  This section is incomplete.
 #
 case "$host_os" in
-*linux*|bsdi4*|*gnu*|darwin*|macosx*)
+*linux*)
+       # libname.so.M -> libname.so.M.N
+       ${echo} ${RM} ${INSTALLDIR}/$LINK2
+       if [ -z "$uninstall" ]; then
+               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
-               ${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK2
+               eval $INSTALL_LINK2
        fi
 
        # libname.so -> libname.so.M.N
        ${echo} ${RM} ${INSTALLDIR}/$LINK1
        if [ -z "$uninstall" ]; then
-               ${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK1
+               eval $INSTALL_LINK1
        fi
        ;;
 
@@ -113,7 +147,7 @@ solaris2*|aix4.[2-9]*|osf*|irix[56]*|sysv[45]*|dgux*)
        # libname.so -> libname.so.M
        ${echo} ${RM} ${INSTALLDIR}/$LINK1
        if [ -z "$uninstall" ]; then
-               ${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK1
+               eval $INSTALL_LINK1
        fi
        ;;
 
@@ -124,19 +158,19 @@ freebsd[3-9]*|freebsdelf[3-9]*|freebsdaout[3-9]*)
                # libname.so -> libname.so.M
                ${echo} ${RM} ${INSTALLDIR}/$LINK1
                if [ -z "$uninstall" ]; then
-                       ${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK1
+                       eval $INSTALL_LINK1
                fi
        else
                # libname.so.M -> libname.so.M.N
                ${echo} ${RM} ${INSTALLDIR}/$LINK2
                if [ -z "$uninstall" ]; then
-                       ${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK2
+                       eval $INSTALL_LINK2
                fi
 
                # libname.so -> libname.so.M.N
                ${echo} ${RM} ${INSTALLDIR}/$LINK1
                if [ -z "$uninstall" ]; then
-                       ${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK1
+                       eval $INSTALL_LINK1
                fi
        fi
        ;;
@@ -145,11 +179,16 @@ hpux1*)
        # libname.sl -> libname.M
        ${echo} ${RM} ${INSTALLDIR}/$LINK1.sl
        if [ -z "$uninstall" ]; then
-#              ${echo} ln -s $LIBNAME ${INSTALLDIR}/${LINK1}.sl
-               ${echo} ln -s $LIBNAME ${INSTALLDIR}/${LINK1}
+               eval $INSTALL_LINK1
        fi
        ;;
 
+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.
+       ;;
+
 *)     ;;
 esac