diff -ru readline-6.2/Makefile.in readline-6.2-patched/Makefile.in
--- readline-6.2/Makefile.in	2010-10-11 17:53:52.000000000 +0200
+++ readline-6.2-patched/Makefile.in	2012-06-14 22:35:58.000000000 +0200
@@ -83,7 +83,7 @@
 # For libraries which include headers from other libraries.
 INCLUDES = -I. -I$(srcdir)
 
-XCCFLAGS = $(DEFS) $(LOCAL_DEFS) $(CPPFLAGS) $(INCLUDES)
+XCCFLAGS = $(DEFS) $(LOCAL_DEFS) $(INCLUDES) $(CPPFLAGS)
 CCFLAGS = $(XCCFLAGS) $(LOCAL_CFLAGS) $(CFLAGS)
 
 # could add -Werror here
@@ -225,10 +225,8 @@
 maybe-uninstall-headers: uninstall-headers
 
 install-static: installdirs $(STATIC_LIBS) install-headers install-doc install-examples
-	-$(MV) $(DESTDIR)$(libdir)/libreadline.a $(DESTDIR)$(libdir)/libreadline.old
 	$(INSTALL_DATA) libreadline.a $(DESTDIR)$(libdir)/libreadline.a
 	-test -n "$(RANLIB)" && $(RANLIB) $(DESTDIR)$(libdir)/libreadline.a
-	-$(MV) $(DESTDIR)$(libdir)/libhistory.a $(DESTDIR)$(libdir)/libhistory.old
 	$(INSTALL_DATA) libhistory.a $(DESTDIR)$(libdir)/libhistory.a
 	-test -n "$(RANLIB)" && $(RANLIB) $(DESTDIR)$(libdir)/libhistory.a
 
diff -ru readline-6.2/doc/Makefile.in readline-6.2-patched/doc/Makefile.in
--- readline-6.2/doc/Makefile.in	2009-12-23 16:42:59.000000000 +0100
+++ readline-6.2-patched/doc/Makefile.in	2012-06-14 22:36:31.000000000 +0200
@@ -215,14 +215,6 @@
 	else \
 		${INSTALL_DATA} $(srcdir)/history.info $(DESTDIR)$(infodir)/history.info; \
 	fi
-	-if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \
-		install-info --dir-file=$(DESTDIR)$(infodir)/dir \
-			$(DESTDIR)$(infodir)/readline.info ; \
-		install-info --dir-file=$(DESTDIR)$(infodir)/dir \
-			$(DESTDIR)$(infodir)/history.info ; \
-		install-info --dir-file=$(DESTDIR)$(infodir)/dir \
-			$(DESTDIR)$(infodir)/rluserman.info ; \
-	else true; fi
 	-${INSTALL_DATA} $(srcdir)/readline.3 $(DESTDIR)$(man3dir)/readline$(man3ext)
 	-${INSTALL_DATA} $(srcdir)/history.3 $(DESTDIR)$(man3dir)/history$(man3ext)
 	-if test -n "${htmldir}" ; then \
diff -ru readline-6.2/examples/Makefile.in readline-6.2-patched/examples/Makefile.in
--- readline-6.2/examples/Makefile.in	2010-12-28 21:55:32.000000000 +0100
+++ readline-6.2-patched/examples/Makefile.in	2012-06-14 22:35:12.000000000 +0200
@@ -53,7 +53,7 @@
 
 INCLUDES = -I$(srcdir) -I$(top_srcdir) -I..
 
-CCFLAGS  = $(DEFS) $(LOCAL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(CFLAGS)
+CCFLAGS  = $(DEFS) $(LOCAL_CFLAGS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
 LDFLAGS = -g -L.. @LDFLAGS@
 
 PURIFY = @PURIFY@
diff -ru readline-6.2/shlib/Makefile.in readline-6.2-patched/shlib/Makefile.in
--- readline-6.2/shlib/Makefile.in	2010-12-28 21:56:21.000000000 +0100
+++ readline-6.2-patched/shlib/Makefile.in	2012-06-14 22:34:55.000000000 +0200
@@ -107,7 +107,7 @@
 # For libraries which include headers from other libraries.
 INCLUDES = -I. -I.. -I$(topdir)
 
-CCFLAGS = $(DEFS) $(LOCAL_DEFS) $(CPPFLAGS) $(INCLUDES) $(LOCAL_CFLAGS) $(CFLAGS)
+CCFLAGS = $(DEFS) $(LOCAL_DEFS) $(INCLUDES) $(CPPFLAGS) $(LOCAL_CFLAGS) $(CFLAGS)
 
 .SUFFIXES:	.so
 
diff -ru readline-6.2/support/shobj-conf readline-6.2-patched/support/shobj-conf
--- readline-6.2/support/shobj-conf	2012-06-14 23:02:19.000000000 +0200
+++ readline-6.2-patched/support/shobj-conf	2012-06-18 14:37:26.000000000 +0200
@@ -169,7 +169,7 @@
 	SHLIB_LIBSUFF='dylib'
 
 	SHOBJ_LDFLAGS='-dynamiclib -dynamic -undefined dynamic_lookup -arch_only `/usr/bin/arch`'
-	SHLIB_XLDFLAGS='-dynamiclib -arch_only `/usr/bin/arch` -install_name $(libdir)/$@ -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v'
+	SHLIB_XLDFLAGS='-dynamiclib -arch_only `/usr/bin/arch` -install_name $(libdir)/`echo $@ | sed "s:\\(.*\\.[0-9]\\)\\.[0-9]:\\1:"` -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v'
 
 	SHLIB_LIBS='-lncurses'	# see if -lcurses works on MacOS X 10.1 
 	;;
@@ -187,7 +187,7 @@
 
 	case "${host_os}" in
 	darwin[789]*|darwin1[012]*)	SHOBJ_LDFLAGS=''
-			SHLIB_XLDFLAGS='-dynamiclib -arch_only `/usr/bin/arch` -install_name $(libdir)/$@ -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v'
+			SHLIB_XLDFLAGS='-dynamiclib -arch_only `/usr/bin/arch` -install_name $(libdir)/`echo $@ | sed "s:\\(.*\\.[0-9]\\)\\.[0-9]:\\1:"` -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v'
 			;;
 	*)		SHOBJ_LDFLAGS='-dynamic'
 			SHLIB_XLDFLAGS='-arch_only `/usr/bin/arch` -install_name $(libdir)/$@ -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v'
