File readline-5.1-destdir.patch of Package libreadline5

Index: shlib/Makefile.in
===================================================================
--- shlib/Makefile.in.orig
+++ shlib/Makefile.in
@@ -57,6 +57,7 @@ bindir = @bindir@
 libdir = @libdir@
 datadir = @datadir@
 localedir = $(datadir)/locale
+linkagedir = $(libdir)
 
 # Support an alternate destination root directory for package building
 DESTDIR =
@@ -181,13 +182,13 @@ installdirs: $(topdir)/support/mkdirs
 	-$(SHELL) $(topdir)/support/mkdirs $(DESTDIR)$(libdir)
 
 install: installdirs $(SHLIB_STATUS)
-	$(SHELL) $(topdir)/support/shlib-install -O $(host_os) -d $(DESTDIR)$(libdir) -b $(DESTDIR)$(bindir) -i "$(INSTALL_DATA)" $(SHARED_HISTORY)
-	$(SHELL) $(topdir)/support/shlib-install -O $(host_os) -d $(DESTDIR)$(libdir) -b $(DESTDIR)$(bindir) -i "$(INSTALL_DATA)" $(SHARED_READLINE)
+	$(SHELL) $(topdir)/support/shlib-install -O $(host_os) -dd $(DESTDIR) -d $(libdir) -l $(linkagedir) -b $(bindir) -i "$(INSTALL_DATA)" $(SHARED_HISTORY)
+	$(SHELL) $(topdir)/support/shlib-install -O $(host_os) -dd $(DESTDIR) -d $(libdir) -l $(linkagedir) -b $(bindir) -i "$(INSTALL_DATA)" $(SHARED_READLINE)
 	@echo install: you may need to run ldconfig
 
 uninstall:
-	$(SHELL) $(topdir)/support/shlib-install -O $(host_os) -d $(DESTDIR)$(libdir) -b $(DESTDIR)$(bindir) -U $(SHARED_HISTORY)
-	$(SHELL) $(topdir)/support/shlib-install -O $(host_os) -d $(DESTDIR)$(libdir) -b $(DESTDIR)$(bindir) -U $(SHARED_READLINE)
+	$(SHELL) $(topdir)/support/shlib-install -O $(host_os) -dd $(DESTDIR) -d $(libdir) -l $(linkagedir) -b $(bindir) -U $(SHARED_HISTORY)
+	$(SHELL) $(topdir)/support/shlib-install -O $(host_os) -dd $(DESTDIR) -d $(libdir) -l $(linkagedir) -b $(bindir) -U $(SHARED_READLINE)
 	@echo uninstall: you may need to run ldconfig
 
 clean mostlyclean:	force
Index: support/shlib-install
===================================================================
--- support/shlib-install.orig
+++ support/shlib-install
@@ -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 [-b bin-dir] -i install-prog [-U] library
+# usage: shlib-install [-D] -O host_os -d installation-dir [-l linkage-dir] [-b bin-dir] -i install-prog [-U] library
 #
 # Chet Ramey
 # chet@po.cwru.edu
@@ -12,10 +12,12 @@
 # defaults
 #
 INSTALLDIR=/usr/local/lib
+LINKAGEDIR=
 LDCONFIG=ldconfig
+DESTDIR=
 
 PROGNAME=`basename $0`
-USAGE="$PROGNAME [-D] -O host_os -d installation-dir [-b bin-dir] -i install-prog [-U] library"
+USAGE="$PROGNAME [-D] -O host_os -d installation-dir [-l linkage-dir] [-b bin-dir] -i install-prog [-U] library"
 
 # process options
 
@@ -23,14 +25,19 @@ while [ $# -gt 0 ]; do
 	case "$1" in
 	-O)	shift; host_os="$1"; shift ;;
 	-d)	shift; INSTALLDIR="$1"; shift ;;
+	-dd)	shift; DESTDIR=$1; shift ;;
 	-b)	shift; BINDIR="$1" ; shift ;;
 	-i)	shift; INSTALLPROG="$1" ; shift ;;
+	-l)	shift; LINKAGEDIR="$1" ; shift ;;
 	-D)	echo=echo ; shift ;;
 	-U)	uninstall=true ; shift ;;
 	-*)	echo "$USAGE" >&2 ; exit 2;;
 	*)	break ;;
 	esac
 done
+if [ -z "$LINKAGEDIR" ]; then
+	LINKAGEDIR="$INSTALLDIR"
+fi
 
 # set install target name
 LIBNAME="$1"
@@ -48,18 +55,18 @@ LN="ln -s"
 # pre-install
 
 if [ -z "$uninstall" ]; then
-	${echo} $RM ${INSTALLDIR}/${LIBNAME}.${OLDSUFF}
-	if [ -f "$INSTALLDIR/$LIBNAME" ]; then
-		${echo} $MV $INSTALLDIR/$LIBNAME ${INSTALLDIR}/${LIBNAME}.${OLDSUFF}
+	${echo} $RM ${DESTDIR}${INSTALLDIR}/${LIBNAME}.${OLDSUFF}
+	if [ -f "${DESTDIR}$INSTALLDIR/$LIBNAME" ]; then
+		${echo} $MV ${DESTDIR}$INSTALLDIR/$LIBNAME ${DESTDIR}${INSTALLDIR}/${LIBNAME}.${OLDSUFF}
 	fi
 fi
 
 # install/uninstall
 
 if [ -z "$uninstall" ] ; then
-	${echo} eval ${INSTALLPROG} $LIBNAME ${INSTALLDIR}/${LIBNAME}
+	${echo} eval ${INSTALLPROG} $LIBNAME ${DESTDIR}${INSTALLDIR}/${LIBNAME}
 else
-	${echo} ${RM} ${INSTALLDIR}/${LIBNAME}
+	${echo} ${RM} ${DESTDIR}${INSTALLDIR}/${LIBNAME}
 fi
 
 # post-install/uninstall
@@ -71,7 +78,7 @@ fi
 case "$host_os" in
 hpux*|darwin*|macosx*|linux*)
 	if [ -z "$uninstall" ]; then
-		chmod 555 ${INSTALLDIR}/${LIBNAME}
+		chmod 555 ${DESTDIR}${INSTALLDIR}/${LIBNAME}
 	fi ;;
 cygwin*)
 	IMPLIBNAME=`echo ${LIBNAME} \
@@ -109,8 +116,8 @@ case "$LIBNAME" in
 	LINK1=`echo $LIBNAME | sed 's:\(.*\)\.[0-9]\.[0-9]:\1:'`	# libname.dylib
 esac
 
-INSTALL_LINK1='${echo} cd $INSTALLDIR && ${echo} ${LN} $LIBNAME $LINK1'
-INSTALL_LINK2='${echo} cd $INSTALLDIR && ${echo} ${LN} $LIBNAME $LINK2'
+INSTALL_LINK1='${echo} cd ${DESTDIR}$INSTALLDIR && ${echo} ${LN} $LIBNAME $LINK1'
+INSTALL_LINK2='${echo} cd ${DESTDIR}$INSTALLDIR && ${echo} ${LN} $LIBNAME $LINK2'
 
 #
 # Create symlinks to the installed library.  This section is incomplete.
@@ -118,27 +125,27 @@ INSTALL_LINK2='${echo} cd $INSTALLDIR &&
 case "$host_os" in
 *linux*)
 	# libname.so.M -> libname.so.M.N
-	${echo} ${RM} ${INSTALLDIR}/$LINK2
+	${echo} ${RM} ${DESTDIR}${INSTALLDIR}/$LINK2
 	if [ -z "$uninstall" ]; then
 		eval $INSTALL_LINK2
 	fi
 
 	# libname.so -> libname.so.M
-	${echo} ${RM} ${INSTALLDIR}/$LINK1
+	${echo} ${RM} ${DESTDIR}${LINKAGEDIR}/$LINK1
 	if [ -z "$uninstall" ]; then
-		${echo} cd $INSTALLDIR && ${echo} ${LN} $LINK2 $LINK1
+		${echo} ln -s ${INSTALLDIR}/$LIBNAME ${DESTDIR}${LINKAGEDIR}/$LINK1
 	fi
 	;;
 
 bsdi4*|*gnu*|darwin*|macosx*|k*bsd*-gnu)
 	# libname.so.M -> libname.so.M.N
-	${echo} ${RM} ${INSTALLDIR}/$LINK2
+	${echo} ${RM} ${DESTDIR}${INSTALLDIR}/$LINK2
 	if [ -z "$uninstall" ]; then
 		eval $INSTALL_LINK2
 	fi
 
 	# libname.so -> libname.so.M.N
-	${echo} ${RM} ${INSTALLDIR}/$LINK1
+	${echo} ${RM} ${DESTDIR}${INSTALLDIR}/$LINK1
 	if [ -z "$uninstall" ]; then
 		eval $INSTALL_LINK1
 	fi
@@ -146,7 +153,7 @@ bsdi4*|*gnu*|darwin*|macosx*|k*bsd*-gnu)
 
 solaris2*|aix4.[2-9]*|osf*|irix[56]*|sysv[45]*|dgux*)
 	# libname.so -> libname.so.M
-	${echo} ${RM} ${INSTALLDIR}/$LINK1
+	${echo} ${RM} ${DESTDIR}${INSTALLDIR}/$LINK1
 	if [ -z "$uninstall" ]; then
 		eval $INSTALL_LINK1
 	fi
@@ -157,19 +164,19 @@ solaris2*|aix4.[2-9]*|osf*|irix[56]*|sys
 freebsd[3-9]*|freebsdelf[3-9]*|freebsdaout[3-9]*)
 	if [ -x /usr/bin/objformat ] && [ "`/usr/bin/objformat`" = "elf" ]; then
 		# libname.so -> libname.so.M
-		${echo} ${RM} ${INSTALLDIR}/$LINK1
+		${echo} ${RM} ${DESTDIR}${INSTALLDIR}/$LINK1
 		if [ -z "$uninstall" ]; then
 			eval $INSTALL_LINK1
 		fi
 	else
 		# libname.so.M -> libname.so.M.N
-		${echo} ${RM} ${INSTALLDIR}/$LINK2
+		${echo} ${RM} ${DESTDIR}${INSTALLDIR}/$LINK2
 		if [ -z "$uninstall" ]; then
 			eval $INSTALL_LINK2
 		fi
 
 		# libname.so -> libname.so.M.N
-		${echo} ${RM} ${INSTALLDIR}/$LINK1
+		${echo} ${RM} ${DESTDIR}${INSTALLDIR}/$LINK1
 		if [ -z "$uninstall" ]; then
 			eval $INSTALL_LINK1
 		fi
@@ -178,7 +185,7 @@ freebsd[3-9]*|freebsdelf[3-9]*|freebsdao
 
 hpux1*)
 	# libname.sl -> libname.M
-	${echo} ${RM} ${INSTALLDIR}/$LINK1.sl
+	${echo} ${RM} ${DESTDIR}${INSTALLDIR}/$LINK1.sl
 	if [ -z "$uninstall" ]; then
 		eval $INSTALL_LINK1
 	fi