--- Makefile.in.orig	2013-07-15 14:21:05.208308731 +0400
+++ Makefile.in	2013-07-15 14:24:56.873283315 +0400
@@ -65,11 +65,19 @@
 
 # Create apr-config script suitable for the install tree
 apr-config.out: $(APR_CONFIG)
-	sed 's,^\(location=\).*$$,\1installed,' < $(APR_CONFIG) > $@
+	sed -e 's,^\(location=\).*$$,\1installed,' \
+	    -e '/^CC=/s,/.*/,,' \
+	    -e '/^CPP=/s,/.*/,,' \
+	    -e '/^APR_SOURCE_DIR=/s,/.*",/usr/apr",' \
+	    -e '/^APR_BUILD_DIR=/s,/.*",/usr/apr",' \
+	    < $(APR_CONFIG) > $@
 
 # Create apr_rules.mk suitable for the install tree
 build/apr_rules.out: build/apr_rules.mk
-	sed -e 's,^\(apr_build.*=\).*$$,\1$(installbuilddir),' -e 's,^\(top_build.*=\).*$$,\1$(installbuilddir),' < build/apr_rules.mk > $@
+	sed -e 's,^\(apr_build.*=\).*$$,\1$(installbuilddir),' -e 's,^\(top_build.*=\).*$$,\1$(installbuilddir),' \
+            -e '/^CC=/s,/.*/,,' \
+	    -e '/^MKDEP            = /s,/.*/,,' \
+	    < build/apr_rules.mk > $@
 
 install: $(TARGETS)
 	$(APR_MKDIR) $(DESTDIR)$(libdir) $(DESTDIR)$(bindir) $(DESTDIR)$(installbuilddir) \
@@ -82,7 +90,13 @@
 	$(INSTALL_DATA) apr.exp $(DESTDIR)$(libdir)/apr.exp
 	$(INSTALL_DATA) apr.pc $(DESTDIR)$(libdir)/pkgconfig/$(APR_PCFILE)
 	for f in libtool shlibtool; do \
-	    if test -f $${f}; then $(INSTALL) -m 755 $${f} $(DESTDIR)$(installbuilddir); fi; \
+	    if test -f $${f}; then \
+		sed -e '/^LTCC=/s,/.*/,,' \
+		    -e '/^CC=/s,/.*/,,' \
+		    < $${f} > $${f}.out; \
+		$(INSTALL) -m 755 $${f}.out $(DESTDIR)$(installbuilddir)/$${f}; \
+		rm $${f}.out; \
+	    fi; \
 	done
 	$(INSTALL) -m 755 $(top_srcdir)/build/mkdir.sh $(DESTDIR)$(installbuilddir)
 	for f in make_exports.awk make_var_export.awk; do \