Fix broken path rewriting in python-config.sh.

python-config.sh was running the same sed invocation on a string
multiple times, resulting in paths like
/usr/local/google/usr/local/google/tmp/... being generated.

Change-Id: I321c51b44268ad62c38aa45ea5a94746f2de0c06
diff --git a/Python-2.7.5/Misc/python-config.sh.in b/Python-2.7.5/Misc/python-config.sh.in
index 7f8dfaa..9cffaca 100644
--- a/Python-2.7.5/Misc/python-config.sh.in
+++ b/Python-2.7.5/Misc/python-config.sh.in
@@ -34,13 +34,23 @@
 prefix_build="@prefix@"
 prefix_real=$(installed_prefix "$0")
 
-# Use sed to fix paths from their built to locations to their installed to locations.
-prefix=$(echo "$prefix_build" | sed "s#$prefix_build#$prefix_real#")
 exec_prefix_build="@exec_prefix@"
-exec_prefix=$(echo "$exec_prefix_build" | sed "s#$exec_prefix_build#$prefix_real#")
-includedir=$(echo "@includedir@" | sed "s#$prefix_build#$prefix_real#")
-libdir=$(echo "@libdir@" | sed "s#$prefix_build#$prefix_real#")
-CFLAGS=$(echo "@CFLAGS@" | sed "s#$prefix_build#$prefix_real#")
+exec_prefix_real="$prefix_real"
+
+# Use sed to fix paths from their built to locations to their installed to locations.
+
+# The @includedir@ and @libdir@ macros can be '$prefix/include' and the like, so we
+# need to avoid replacing the prefix multiple times.
+prefix="$prefix_build"
+exec_prefix="$exec_prefix_build"
+
+includedir=$(echo "@includedir@" | sed "s#^$prefix_build#$prefix_real#")
+libdir=$(echo "@libdir@" | sed "s#^$prefix_build#$prefix_real#")
+
+prefix="$prefix_real"
+exec_prefix="$exec_prefix_real"
+
+CFLAGS="@CFLAGS@"
 VERSION="@VERSION@"
 LIBM="@LIBM@"
 LIBC="@LIBC@"