python.mk 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. #############################################################
  2. #
  3. # python
  4. #
  5. #############################################################
  6. PYTHON_VERSION_MAJOR = 2.7
  7. PYTHON_VERSION = $(PYTHON_VERSION_MAJOR).3
  8. PYTHON_SOURCE = Python-$(PYTHON_VERSION).tar.bz2
  9. PYTHON_SITE = http://python.org/ftp/python/$(PYTHON_VERSION)
  10. PYTHON_LICENSE = Python software foundation license v2, others
  11. PYTHON_LICENSE_FILES = LICENSE
  12. # Python needs itself and a "pgen" program to build itself, both being
  13. # provided in the Python sources. So in order to cross-compile Python,
  14. # we need to build a host Python first. This host Python is also
  15. # installed in $(HOST_DIR), as it is needed when cross-compiling
  16. # third-party Python modules.
  17. HOST_PYTHON_CONF_OPT += \
  18. --enable-static \
  19. --without-cxx-main \
  20. --disable-sqlite3 \
  21. --disable-tk \
  22. --with-expat=system \
  23. --disable-curses \
  24. --disable-codecs-cjk \
  25. --disable-nis \
  26. --disable-unicodedata \
  27. --disable-dbm \
  28. --disable-gdbm \
  29. --disable-bsddb \
  30. --disable-test-modules \
  31. --disable-bz2 \
  32. --disable-ssl
  33. HOST_PYTHON_MAKE_ENV = \
  34. PYTHON_MODULES_INCLUDE=$(HOST_DIR)/usr/include \
  35. PYTHON_MODULES_LIB="$(HOST_DIR)/lib $(HOST_DIR)/usr/lib"
  36. HOST_PYTHON_AUTORECONF = YES
  37. # Building host python in parallel sometimes triggers a "Bus error"
  38. # during the execution of "./python setup.py build" in the
  39. # installation step. It is probably due to the installation of a
  40. # shared library taking place in parallel to the execution of
  41. # ./python, causing spurious Bus error. Building host-python with
  42. # MAKE1 has shown to workaround the problem.
  43. HOST_PYTHON_MAKE = $(MAKE1)
  44. PYTHON_DEPENDENCIES = host-python libffi
  45. HOST_PYTHON_DEPENDENCIES = host-expat host-zlib
  46. PYTHON_INSTALL_STAGING = YES
  47. ifeq ($(BR2_PACKAGE_PYTHON_READLINE),y)
  48. PYTHON_DEPENDENCIES += readline
  49. endif
  50. ifeq ($(BR2_PACKAGE_PYTHON_CURSES),y)
  51. PYTHON_DEPENDENCIES += ncurses
  52. else
  53. PYTHON_CONF_OPT += --disable-curses
  54. endif
  55. ifeq ($(BR2_PACKAGE_PYTHON_PYEXPAT),y)
  56. PYTHON_DEPENDENCIES += expat
  57. PYTHON_CONF_OPT += --with-expat=system
  58. else
  59. PYTHON_CONF_OPT += --with-expat=none
  60. endif
  61. ifeq ($(BR2_PACKAGE_PYTHON_BSDDB),y)
  62. PYTHON_DEPENDENCIES += berkeleydb
  63. else
  64. PYTHON_CONF_OPT += --disable-bsddb
  65. endif
  66. ifeq ($(BR2_PACKAGE_PYTHON_SQLITE),y)
  67. PYTHON_DEPENDENCIES += sqlite
  68. else
  69. PYTHON_CONF_OPT += --disable-sqlite3
  70. endif
  71. ifeq ($(BR2_PACKAGE_PYTHON_SSL),y)
  72. PYTHON_DEPENDENCIES += openssl
  73. else
  74. PYTHON_CONF_OPT += --disable-ssl
  75. endif
  76. ifneq ($(BR2_PACKAGE_PYTHON_CODECSCJK),y)
  77. PYTHON_CONF_OPT += --disable-codecs-cjk
  78. endif
  79. ifneq ($(BR2_PACKAGE_PYTHON_UNICODEDATA),y)
  80. PYTHON_CONF_OPT += --disable-unicodedata
  81. endif
  82. ifeq ($(BR2_PACKAGE_PYTHON_BZIP2),y)
  83. PYTHON_DEPENDENCIES += bzip2
  84. else
  85. PYTHON_CONF_OPT += --disable-bz2
  86. endif
  87. ifeq ($(BR2_PACKAGE_PYTHON_ZLIB),y)
  88. PYTHON_DEPENDENCIES += zlib
  89. else
  90. PYTHON_CONF_OPT += --disable-zlib
  91. endif
  92. PYTHON_CONF_ENV += \
  93. PYTHON_FOR_BUILD=$(HOST_PYTHON_DIR)/python \
  94. PGEN_FOR_BUILD=$(HOST_PYTHON_DIR)/Parser/pgen \
  95. ac_cv_have_long_long_format=yes
  96. PYTHON_CONF_OPT += \
  97. --without-cxx-main \
  98. --without-doc-strings \
  99. --with-system-ffi \
  100. --disable-pydoc \
  101. --disable-test-modules \
  102. --disable-lib2to3 \
  103. --disable-gdbm \
  104. --disable-tk \
  105. --disable-nis \
  106. --disable-dbm
  107. PYTHON_MAKE_ENV = \
  108. PYTHON_MODULES_INCLUDE=$(STAGING_DIR)/usr/include \
  109. PYTHON_MODULES_LIB="$(STAGING_DIR)/lib $(STAGING_DIR)/usr/lib"
  110. # python distutils adds -L$LIBDIR when linking binary extensions, causing
  111. # trouble for cross compilation
  112. define PYTHON_FIXUP_LIBDIR
  113. $(SED) 's|^LIBDIR=.*|LIBDIR= $(STAGING_DIR)/usr/lib|' \
  114. $(STAGING_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/config/Makefile
  115. endef
  116. PYTHON_POST_INSTALL_STAGING_HOOKS += PYTHON_FIXUP_LIBDIR
  117. #
  118. # Development files removal
  119. #
  120. define PYTHON_REMOVE_DEVFILES
  121. rm -f $(TARGET_DIR)/usr/bin/python$(PYTHON_VERSION_MAJOR)-config
  122. rm -f $(TARGET_DIR)/usr/bin/python-config
  123. endef
  124. ifneq ($(BR2_HAVE_DEVFILES),y)
  125. PYTHON_POST_INSTALL_TARGET_HOOKS += PYTHON_REMOVE_DEVFILES
  126. endif
  127. #
  128. # Remove useless files. In the config/ directory, only the Makefile
  129. # and the pyconfig.h files are needed at runtime.
  130. #
  131. define PYTHON_REMOVE_USELESS_FILES
  132. for i in `find $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/config/ \
  133. -type f -not -name pyconfig.h -a -not -name Makefile` ; do \
  134. rm -f $$i ; \
  135. done
  136. endef
  137. PYTHON_POST_INSTALL_TARGET_HOOKS += PYTHON_REMOVE_USELESS_FILES
  138. PYTHON_AUTORECONF = YES
  139. $(eval $(autotools-package))
  140. $(eval $(host-autotools-package))