Upstream-Status: Inappropriate [embedded specific]

# The proper prefix is inside our staging area.
# Signed-Off: Michael 'Mickey' Lauer <mickey@vanille-media.de>
# Signed-off-by: Phil Blundell <philb@gnu.org>
# Signed-off-by: Khem Raj <raj.khem@gmail.com>

Index: Python-3.3.2/Lib/distutils/sysconfig.py
===================================================================
--- Python-3.3.2.orig/Lib/distutils/sysconfig.py	2013-07-30 00:00:52.769749805 -0700
+++ Python-3.3.2/Lib/distutils/sysconfig.py	2013-07-30 00:16:22.545767248 -0700
@@ -16,10 +16,11 @@
 from .errors import DistutilsPlatformError
 
 # These are needed in a couple of spots, so just compute them once.
-PREFIX = os.path.normpath(sys.prefix)
-EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
-BASE_PREFIX = os.path.normpath(sys.base_prefix)
-BASE_EXEC_PREFIX = os.path.normpath(sys.base_exec_prefix)
+PREFIX = os.path.normpath(sys.prefix).replace( os.getenv("BUILD_SYS"), os.getenv("HOST_SYS") )
+EXEC_PREFIX = os.path.normpath(sys.exec_prefix).replace( os.getenv("BUILD_SYS"), os.getenv("HOST_SYS") )
+BASE_PREFIX = os.path.normpath(sys.base_prefix).replace( os.getenv("BUILD_SYS"), os.getenv("HOST_SYS") )
+BASE_EXEC_PREFIX= os.path.normpath(sys.base_exec_prefix).replace( os.getenv("BUILD_SYS"), os.getenv("HOST_SYS") )
+
 
 # Path to the base directory of the project. On Windows the binary may
 # live in project/PCBuild9.  If we're dealing with an x64 Windows build,
@@ -93,7 +94,9 @@
     If 'prefix' is supplied, use it instead of sys.base_prefix or
     sys.base_exec_prefix -- i.e., ignore 'plat_specific'.
     """
-    if prefix is None:
+    if prefix is None and os.environ['STAGING_INCDIR'] != "":
+        prefix = os.environ['STAGING_INCDIR'].rstrip('include')
+    elif prefix is None:
         prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX
     if os.name == "posix":
         if python_build:
@@ -136,6 +139,12 @@
     If 'prefix' is supplied, use it instead of sys.base_prefix or
     sys.base_exec_prefix -- i.e., ignore 'plat_specific'.
     """
+    if prefix is None and os.environ['STAGING_LIBDIR'] != "":
+        lib_basename = os.environ['STAGING_LIBDIR'].split('/')[-1]
+        prefix = os.environ['STAGING_LIBDIR'].rstrip(lib_basename)
+    else:
+        lib_basename = sys.lib
+
     if prefix is None:
         if standard_lib:
             prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX
@@ -144,7 +153,7 @@
 
     if os.name == "posix":
         libpython = os.path.join(prefix,
-                                 "lib", "python" + get_python_version())
+                                 lib_basename, "python" + get_python_version())
         if standard_lib:
             return libpython
         else:
@@ -249,7 +258,7 @@
     else:
         # The name of the config.h file changed in 2.2
         config_h = 'pyconfig.h'
-    return os.path.join(inc_dir, config_h)
+    return os.path.join(inc_dir, config_h).replace( os.getenv("BUILD_SYS"), os.getenv("HOST_SYS") )
 
 
 def get_makefile_filename():
@@ -258,7 +267,7 @@
         return os.path.join(_sys_home or project_base, "Makefile")
     lib_dir = get_python_lib(plat_specific=0, standard_lib=1)
     config_file = 'config-{}{}'.format(get_python_version(), build_flags)
-    return os.path.join(lib_dir, config_file, 'Makefile')
+    return os.path.join(lib_dir, config_file, 'Makefile').replace( os.getenv("BUILD_SYS"), os.getenv("HOST_SYS") )
 
 
 def parse_config_h(fp, g=None):
