python3.mk 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. ################################################################################
  2. #
  3. # python3
  4. #
  5. ################################################################################
  6. PYTHON3_VERSION_MAJOR = 3.4
  7. PYTHON3_VERSION = $(PYTHON3_VERSION_MAJOR).1
  8. PYTHON3_SOURCE = Python-$(PYTHON3_VERSION).tar.xz
  9. PYTHON3_SITE = http://python.org/ftp/python/$(PYTHON3_VERSION)
  10. PYTHON3_LICENSE = Python software foundation license v2, others
  11. PYTHON3_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_PYTHON3_CONF_OPTS += \
  18. --without-ensurepip \
  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. --enable-unicodedata \
  27. --disable-test-modules \
  28. --disable-idle3 \
  29. --disable-pyo-build
  30. # Make sure that LD_LIBRARY_PATH overrides -rpath.
  31. # This is needed because libpython may be installed at the same time that
  32. # python is called.
  33. HOST_PYTHON3_CONF_ENV += \
  34. LDFLAGS="$(HOST_LDFLAGS) -Wl,--enable-new-dtags"
  35. PYTHON3_DEPENDENCIES = host-python3 libffi
  36. HOST_PYTHON3_DEPENDENCIES = host-expat host-zlib
  37. PYTHON3_INSTALL_STAGING = YES
  38. ifeq ($(BR2_PACKAGE_PYTHON3_READLINE),y)
  39. PYTHON3_DEPENDENCIES += readline
  40. endif
  41. ifeq ($(BR2_PACKAGE_PYTHON3_CURSES),y)
  42. PYTHON3_DEPENDENCIES += ncurses
  43. else
  44. PYTHON3_CONF_OPTS += --disable-curses
  45. endif
  46. ifeq ($(BR2_PACKAGE_PYTHON3_DECIMAL),y)
  47. PYTHON3_DEPENDENCIES += mpdecimal
  48. PYTHON3_CONF_OPTS += --with-libmpdec=system
  49. else
  50. PYTHON3_CONF_OPTS += --with-libmpdec=none
  51. endif
  52. ifeq ($(BR2_PACKAGE_PYTHON3_PYEXPAT),y)
  53. PYTHON3_DEPENDENCIES += expat
  54. PYTHON3_CONF_OPTS += --with-expat=system
  55. else
  56. PYTHON3_CONF_OPTS += --with-expat=none
  57. endif
  58. ifeq ($(BR2_PACKAGE_PYTHON3_PYC_ONLY),y)
  59. PYTHON3_CONF_OPTS += --enable-old-stdlib-cache
  60. endif
  61. ifeq ($(BR2_PACKAGE_PYTHON3_PY_ONLY),y)
  62. PYTHON3_CONF_OPTS += --disable-pyc-build
  63. endif
  64. ifeq ($(BR2_PACKAGE_PYTHON3_SQLITE),y)
  65. PYTHON3_DEPENDENCIES += sqlite
  66. else
  67. PYTHON3_CONF_OPTS += --disable-sqlite3
  68. endif
  69. ifeq ($(BR2_PACKAGE_PYTHON3_SSL),y)
  70. PYTHON3_DEPENDENCIES += openssl
  71. endif
  72. ifneq ($(BR2_PACKAGE_PYTHON3_CODECSCJK),y)
  73. PYTHON3_CONF_OPTS += --disable-codecs-cjk
  74. endif
  75. ifneq ($(BR2_PACKAGE_PYTHON3_UNICODEDATA),y)
  76. PYTHON3_CONF_OPTS += --disable-unicodedata
  77. endif
  78. ifeq ($(BR2_PACKAGE_PYTHON3_BZIP2),y)
  79. PYTHON3_DEPENDENCIES += bzip2
  80. endif
  81. ifeq ($(BR2_PACKAGE_PYTHON3_ZLIB),y)
  82. PYTHON3_DEPENDENCIES += zlib
  83. endif
  84. PYTHON3_CONF_ENV += \
  85. ac_cv_have_long_long_format=yes \
  86. ac_cv_file__dev_ptmx=yes \
  87. ac_cv_file__dev_ptc=yes \
  88. ac_cv_working_tzset=yes
  89. PYTHON3_CONF_OPTS += \
  90. --without-ensurepip \
  91. --without-cxx-main \
  92. --with-system-ffi \
  93. --disable-pydoc \
  94. --disable-test-modules \
  95. --disable-lib2to3 \
  96. --disable-tk \
  97. --disable-nis \
  98. --disable-idle3 \
  99. --disable-pyo-build
  100. # This is needed to make sure the Python build process doesn't try to
  101. # regenerate those files with the pgen program. Otherwise, it builds
  102. # pgen for the target, and tries to run it on the host.
  103. define PYTHON3_TOUCH_GRAMMAR_FILES
  104. touch $(@D)/Include/graminit.h $(@D)/Python/graminit.c
  105. endef
  106. PYTHON3_POST_PATCH_HOOKS += PYTHON3_TOUCH_GRAMMAR_FILES
  107. #
  108. # Remove useless files. In the config/ directory, only the Makefile
  109. # and the pyconfig.h files are needed at runtime.
  110. #
  111. define PYTHON3_REMOVE_USELESS_FILES
  112. rm -f $(TARGET_DIR)/usr/bin/python$(PYTHON3_VERSION_MAJOR)-config
  113. rm -f $(TARGET_DIR)/usr/bin/python$(PYTHON3_VERSION_MAJOR)m-config
  114. rm -f $(TARGET_DIR)/usr/bin/python3-config
  115. rm -f $(TARGET_DIR)/usr/bin/smtpd.py.3
  116. for i in `find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/config-$(PYTHON3_VERSION_MAJOR)m/ \
  117. -type f -not -name pyconfig.h -a -not -name Makefile` ; do \
  118. rm -f $$i ; \
  119. done
  120. rm -rf $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/__pycache__/
  121. rm -rf $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/lib-dynload/sysconfigdata/__pycache__
  122. rm -rf $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/collections/__pycache__
  123. rm -rf $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/importlib/__pycache__
  124. endef
  125. PYTHON3_POST_INSTALL_TARGET_HOOKS += PYTHON3_REMOVE_USELESS_FILES
  126. #
  127. # Make sure libpython gets stripped out on target
  128. #
  129. define PYTHON3_ENSURE_LIBPYTHON_STRIPPED
  130. chmod u+w $(TARGET_DIR)/usr/lib/libpython$(PYTHON3_VERSION_MAJOR)*.so
  131. endef
  132. PYTHON3_POST_INSTALL_TARGET_HOOKS += PYTHON3_ENSURE_LIBPYTHON_STRIPPED
  133. PYTHON3_AUTORECONF = YES
  134. define PYTHON3_INSTALL_SYMLINK
  135. ln -fs python3 $(TARGET_DIR)/usr/bin/python
  136. endef
  137. ifneq ($(BR2_PACKAGE_PYTHON),y)
  138. PYTHON3_POST_INSTALL_TARGET_HOOKS += PYTHON3_INSTALL_SYMLINK
  139. endif
  140. # Some packages may have build scripts requiring python3, whatever is the
  141. # python version chosen for the target.
  142. # Only install the python symlink in the host tree if python3 is enabled
  143. # for the target.
  144. ifeq ($(BR2_PACKAGE_PYTHON3),y)
  145. define HOST_PYTHON3_INSTALL_SYMLINK
  146. ln -fs python3 $(HOST_DIR)/usr/bin/python
  147. ln -fs python3-config $(HOST_DIR)/usr/bin/python-config
  148. endef
  149. HOST_PYTHON3_POST_INSTALL_HOOKS += HOST_PYTHON3_INSTALL_SYMLINK
  150. endif
  151. # Provided to other packages
  152. PYTHON3_PATH = $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/sysconfigdata/:$(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/site-packages/
  153. $(eval $(autotools-package))
  154. $(eval $(host-autotools-package))
  155. ifeq ($(BR2_PACKAGE_PYTHON3_PYC_ONLY),y)
  156. define PYTHON3_FINALIZE_TARGET
  157. find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR) -name '*.py' -print0 | xargs -0 rm -f
  158. endef
  159. endif
  160. ifeq ($(BR2_PACKAGE_PYTHON3_PY_ONLY),y)
  161. define PYTHON3_FINALIZE_TARGET
  162. find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR) -name '*.pyc' -print0 | xargs -0 rm -f
  163. endef
  164. endif
  165. TARGET_FINALIZE_HOOKS += PYTHON3_FINALIZE_TARGET