python.mk 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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.xz
  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. # Building host python in parallel sometimes triggers a "Bus error"
  37. # during the execution of "./python setup.py build" in the
  38. # installation step. It is probably due to the installation of a
  39. # shared library taking place in parallel to the execution of
  40. # ./python, causing spurious Bus error. Building host-python with
  41. # MAKE1 has shown to workaround the problem.
  42. HOST_PYTHON_MAKE = $(MAKE1)
  43. PYTHON_DEPENDENCIES = host-python libffi
  44. HOST_PYTHON_DEPENDENCIES = host-expat host-zlib
  45. define HOST_PYTHON_INSTALL_PGEN
  46. $(INSTALL) -m0755 -D $(@D)/Parser/pgen $(HOST_DIR)/usr/bin/python-pgen
  47. endef
  48. HOST_PYTHON_POST_INSTALL_HOOKS += HOST_PYTHON_INSTALL_PGEN
  49. PYTHON_INSTALL_STAGING = YES
  50. ifeq ($(BR2_PACKAGE_PYTHON_READLINE),y)
  51. PYTHON_DEPENDENCIES += readline
  52. endif
  53. ifeq ($(BR2_PACKAGE_PYTHON_CURSES),y)
  54. PYTHON_DEPENDENCIES += ncurses
  55. else
  56. PYTHON_CONF_OPT += --disable-curses
  57. endif
  58. ifeq ($(BR2_PACKAGE_PYTHON_PYEXPAT),y)
  59. PYTHON_DEPENDENCIES += expat
  60. PYTHON_CONF_OPT += --with-expat=system
  61. else
  62. PYTHON_CONF_OPT += --with-expat=none
  63. endif
  64. ifeq ($(BR2_PACKAGE_PYTHON_BSDDB),y)
  65. PYTHON_DEPENDENCIES += berkeleydb
  66. else
  67. PYTHON_CONF_OPT += --disable-bsddb
  68. endif
  69. ifeq ($(BR2_PACKAGE_PYTHON_SQLITE),y)
  70. PYTHON_DEPENDENCIES += sqlite
  71. else
  72. PYTHON_CONF_OPT += --disable-sqlite3
  73. endif
  74. ifeq ($(BR2_PACKAGE_PYTHON_SSL),y)
  75. PYTHON_DEPENDENCIES += openssl
  76. else
  77. PYTHON_CONF_OPT += --disable-ssl
  78. endif
  79. ifneq ($(BR2_PACKAGE_PYTHON_CODECSCJK),y)
  80. PYTHON_CONF_OPT += --disable-codecs-cjk
  81. endif
  82. ifneq ($(BR2_PACKAGE_PYTHON_UNICODEDATA),y)
  83. PYTHON_CONF_OPT += --disable-unicodedata
  84. endif
  85. # Default is UCS2 w/o a conf opt
  86. ifeq ($(BR2_PACKAGE_PYTHON_UCS4),y)
  87. PYTHON_CONF_OPT += --enable-unicode=ucs4
  88. endif
  89. ifeq ($(BR2_PACKAGE_PYTHON_BZIP2),y)
  90. PYTHON_DEPENDENCIES += bzip2
  91. else
  92. PYTHON_CONF_OPT += --disable-bz2
  93. endif
  94. ifeq ($(BR2_PACKAGE_PYTHON_ZLIB),y)
  95. PYTHON_DEPENDENCIES += zlib
  96. else
  97. PYTHON_CONF_OPT += --disable-zlib
  98. endif
  99. ifeq ($(BR2_PACKAGE_PYTHON_HASHLIB),y)
  100. PYTHON_DEPENDENCIES += openssl
  101. endif
  102. PYTHON_CONF_ENV += \
  103. PYTHON_FOR_BUILD=$(HOST_DIR)/usr/bin/python \
  104. PGEN_FOR_BUILD=$(HOST_DIR)/usr/bin/python-pgen \
  105. ac_cv_have_long_long_format=yes
  106. PYTHON_MAKE_ENV += \
  107. _python_sysroot=$(STAGING_DIR) \
  108. PYTHON_MODULES_INCLUDE=$(STAGING_DIR)/usr/include \
  109. PYTHON_MODULES_LIB="$(STAGING_DIR)/lib $(STAGING_DIR)/usr/lib"
  110. PYTHON_CONF_OPT += \
  111. --without-cxx-main \
  112. --without-doc-strings \
  113. --with-system-ffi \
  114. --disable-pydoc \
  115. --disable-test-modules \
  116. --disable-lib2to3 \
  117. --disable-gdbm \
  118. --disable-tk \
  119. --disable-nis \
  120. --disable-dbm
  121. #
  122. # Remove useless files. In the config/ directory, only the Makefile
  123. # and the pyconfig.h files are needed at runtime.
  124. #
  125. # idle & smtpd.py have bad shebangs and are mostly samples
  126. #
  127. define PYTHON_REMOVE_USELESS_FILES
  128. rm -f $(TARGET_DIR)/usr/bin/idle
  129. rm -f $(TARGET_DIR)/usr/bin/python$(PYTHON_VERSION_MAJOR)-config
  130. rm -f $(TARGET_DIR)/usr/bin/python2-config
  131. rm -f $(TARGET_DIR)/usr/bin/python-config
  132. rm -f $(TARGET_DIR)/usr/bin/smtpd.py
  133. for i in `find $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/config/ \
  134. -type f -not -name pyconfig.h -a -not -name Makefile` ; do \
  135. rm -f $$i ; \
  136. done
  137. endef
  138. PYTHON_POST_INSTALL_TARGET_HOOKS += PYTHON_REMOVE_USELESS_FILES
  139. PYTHON_AUTORECONF = YES
  140. # Provided to other packages
  141. PYTHON_PATH = $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/site-packages/
  142. $(eval $(autotools-package))
  143. $(eval $(host-autotools-package))