python-2.7-015-distutils-cross-compilation-support.patch 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. Add some cross-compilation fixes to distutils
  2. Inspired by work done by Marc Kleine-Budde <mkl@pengutronix.de> in
  3. PTXdist.
  4. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  5. ---
  6. Lib/distutils/sysconfig.py | 7 ++++---
  7. 1 files changed, 4 insertions(+), 3 deletions(-)
  8. Index: Python-2.7.2/Lib/distutils/sysconfig.py
  9. ===================================================================
  10. --- Python-2.7.2.orig/Lib/distutils/sysconfig.py
  11. +++ Python-2.7.2/Lib/distutils/sysconfig.py
  12. @@ -19,13 +19,22 @@
  13. from distutils.errors import DistutilsPlatformError
  14. # These are needed in a couple of spots, so just compute them once.
  15. -PREFIX = os.path.normpath(sys.prefix)
  16. -EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
  17. +EXECUTABLE_DIRNAME = os.path.dirname(os.path.realpath(sys.executable))
  18. +if os.environ.get('CROSS_COMPILING') == 'yes':
  19. + _sysroot=os.environ.get('_python_sysroot')
  20. + PREFIX = os.path.normpath(_sysroot + os.environ.get('_python_prefix'))
  21. + EXEC_PREFIX = os.path.normpath(_sysroot + os.environ.get('_python_exec_prefix'))
  22. + if '_python_srcdir' in os.environ:
  23. + EXECUTABLE_DIRNAME = os.path.normpath(os.environ['_python_srcdir'])
  24. +else:
  25. + PREFIX = os.path.normpath(sys.prefix)
  26. + EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
  27. +
  28. # Path to the base directory of the project. On Windows the binary may
  29. # live in project/PCBuild9. If we're dealing with an x64 Windows build,
  30. # it'll live in project/PCbuild/amd64.
  31. -project_base = os.path.dirname(os.path.abspath(sys.executable))
  32. +project_base = EXECUTABLE_DIRNAME
  33. if os.name == "nt" and "pcbuild" in project_base[-8:].lower():
  34. project_base = os.path.abspath(os.path.join(project_base, os.path.pardir))
  35. # PC/VS7.1
  36. @@ -74,7 +83,7 @@
  37. if os.name == "posix":
  38. if python_build:
  39. - buildir = os.path.dirname(sys.executable)
  40. + buildir = EXECUTABLE_DIRNAME
  41. if plat_specific:
  42. # python.h is located in the buildir
  43. inc_dir = buildir
  44. @@ -206,7 +215,7 @@
  45. def get_makefile_filename():
  46. """Return full pathname of installed Makefile from the Python build."""
  47. if python_build:
  48. - return os.path.join(os.path.dirname(sys.executable), "Makefile")
  49. + return os.path.join(EXECUTABLE_DIRNAME, "Makefile")
  50. lib_dir = get_python_lib(plat_specific=1, standard_lib=1)
  51. return os.path.join(lib_dir, "config", "Makefile")
  52. Index: Python-2.7.2/configure.in
  53. ===================================================================
  54. --- Python-2.7.2.orig/configure.in
  55. +++ Python-2.7.2/configure.in
  56. @@ -4328,6 +4328,21 @@
  57. CROSS_COMPILING=$cross_compiling
  58. AC_SUBST(CROSS_COMPILING)
  59. +#
  60. +# Cross compiling
  61. +#
  62. +# special RUNSHARED
  63. +if test "$cross_compiling" = "yes"; then
  64. + RUNSHARED="\
  65. + CROSS_COMPILING=yes \
  66. + _python_cross_host=${ac_cv_host} \
  67. + _python_sysroot=\"\$(sysroot)\" \
  68. + _python_srcdir=\"\$(srcdir)\" \
  69. + _python_prefix=\"\$(prefix)\" \
  70. + _python_exec_prefix=\"\$(exec_prefix)\""
  71. +fi
  72. +
  73. +
  74. # generate output files
  75. AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
  76. AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])