python3.mk 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. ################################################################################
  2. #
  3. # python3
  4. #
  5. ################################################################################
  6. PYTHON3_VERSION_MAJOR = 3.4
  7. PYTHON3_VERSION = $(PYTHON3_VERSION_MAJOR).0
  8. PYTHON3_SOURCE = Python-$(PYTHON3_VERSION).tar.xz
  9. PYTHON3_SITE = http://python.org/ftp/python/$(PYTHON3_VERSION)
  10. # Python needs itself and a "pgen" program to build itself, both being
  11. # provided in the Python sources. So in order to cross-compile Python,
  12. # we need to build a host Python first. This host Python is also
  13. # installed in $(HOST_DIR), as it is needed when cross-compiling
  14. # third-party Python modules.
  15. HOST_PYTHON3_CONF_OPT += \
  16. --without-ensurepip \
  17. --without-cxx-main \
  18. --disable-sqlite3 \
  19. --disable-tk \
  20. --with-expat=system \
  21. --disable-curses \
  22. --disable-codecs-cjk \
  23. --disable-nis \
  24. --enable-unicodedata \
  25. --disable-test-modules \
  26. --disable-idle3 \
  27. --disable-pyo-build
  28. # Make sure that LD_LIBRARY_PATH overrides -rpath.
  29. # This is needed because libpython may be installed at the same time that
  30. # python is called.
  31. HOST_PYTHON3_CONF_ENV += \
  32. LDFLAGS="$(HOST_LDFLAGS) -Wl,--enable-new-dtags"
  33. PYTHON3_DEPENDENCIES = host-python3 libffi
  34. HOST_PYTHON3_DEPENDENCIES = host-expat host-zlib
  35. PYTHON3_INSTALL_STAGING = YES
  36. ifeq ($(BR2_PACKAGE_PYTHON3_READLINE),y)
  37. PYTHON3_DEPENDENCIES += readline
  38. endif
  39. ifeq ($(BR2_PACKAGE_PYTHON3_CURSES),y)
  40. PYTHON3_DEPENDENCIES += ncurses
  41. else
  42. PYTHON3_CONF_OPT += --disable-curses
  43. endif
  44. ifeq ($(BR2_PACKAGE_PYTHON3_PYEXPAT),y)
  45. PYTHON3_DEPENDENCIES += expat
  46. PYTHON3_CONF_OPT += --with-expat=system
  47. else
  48. PYTHON3_CONF_OPT += --with-expat=none
  49. endif
  50. ifeq ($(BR2_PACKAGE_PYTHON3_PYC_ONLY),y)
  51. PYTHON3_CONF_OPT += --enable-old-stdlib-cache
  52. endif
  53. ifeq ($(BR2_PACKAGE_PYTHON3_PY_ONLY),y)
  54. PYTHON3_CONF_OPT += --disable-pyc-build
  55. endif
  56. ifeq ($(BR2_PACKAGE_PYTHON3_SQLITE),y)
  57. PYTHON3_DEPENDENCIES += sqlite
  58. else
  59. PYTHON3_CONF_OPT += --disable-sqlite3
  60. endif
  61. ifeq ($(BR2_PACKAGE_PYTHON3_SSL),y)
  62. PYTHON3_DEPENDENCIES += openssl
  63. endif
  64. ifneq ($(BR2_PACKAGE_PYTHON3_CODECSCJK),y)
  65. PYTHON3_CONF_OPT += --disable-codecs-cjk
  66. endif
  67. ifneq ($(BR2_PACKAGE_PYTHON3_UNICODEDATA),y)
  68. PYTHON3_CONF_OPT += --disable-unicodedata
  69. endif
  70. ifeq ($(BR2_PACKAGE_PYTHON3_BZIP2),y)
  71. PYTHON3_DEPENDENCIES += bzip2
  72. endif
  73. ifeq ($(BR2_PACKAGE_PYTHON3_ZLIB),y)
  74. PYTHON3_DEPENDENCIES += zlib
  75. endif
  76. PYTHON3_CONF_ENV += \
  77. ac_cv_have_long_long_format=yes \
  78. ac_cv_file__dev_ptmx=yes \
  79. ac_cv_file__dev_ptc=yes \
  80. PYTHON3_CONF_OPT += \
  81. --without-ensurepip \
  82. --without-cxx-main \
  83. --with-system-ffi \
  84. --disable-pydoc \
  85. --disable-test-modules \
  86. --disable-lib2to3 \
  87. --disable-tk \
  88. --disable-nis \
  89. --disable-idle3 \
  90. --disable-pyo-build
  91. # This is needed to make sure the Python build process doesn't try to
  92. # regenerate those files with the pgen program. Otherwise, it builds
  93. # pgen for the target, and tries to run it on the host.
  94. define PYTHON3_TOUCH_GRAMMAR_FILES
  95. touch $(@D)/Include/graminit.h $(@D)/Python/graminit.c
  96. endef
  97. PYTHON3_POST_PATCH_HOOKS += PYTHON3_TOUCH_GRAMMAR_FILES
  98. #
  99. # Remove useless files. In the config/ directory, only the Makefile
  100. # and the pyconfig.h files are needed at runtime.
  101. #
  102. define PYTHON3_REMOVE_USELESS_FILES
  103. rm -f $(TARGET_DIR)/usr/bin/python$(PYTHON3_VERSION_MAJOR)-config
  104. rm -f $(TARGET_DIR)/usr/bin/python$(PYTHON3_VERSION_MAJOR)m-config
  105. rm -f $(TARGET_DIR)/usr/bin/python3-config
  106. rm -f $(TARGET_DIR)/usr/bin/smtpd.py.3
  107. for i in `find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/config-$(PYTHON3_VERSION_MAJOR)m/ \
  108. -type f -not -name pyconfig.h -a -not -name Makefile` ; do \
  109. rm -f $$i ; \
  110. done
  111. endef
  112. PYTHON3_POST_INSTALL_TARGET_HOOKS += PYTHON3_REMOVE_USELESS_FILES
  113. #
  114. # Make sure libpython gets stripped out on target
  115. #
  116. define PYTHON3_ENSURE_LIBPYTHON_STRIPPED
  117. chmod u+w $(TARGET_DIR)/usr/lib/libpython$(PYTHON3_VERSION_MAJOR)*.so
  118. endef
  119. PYTHON3_POST_INSTALL_TARGET_HOOKS += PYTHON3_ENSURE_LIBPYTHON_STRIPPED
  120. PYTHON3_AUTORECONF = YES
  121. define PYTHON3_INSTALL_SYMLINK
  122. ln -fs python3 $(TARGET_DIR)/usr/bin/python
  123. endef
  124. ifneq ($(BR2_PACKAGE_PYTHON),y)
  125. PYTHON3_POST_INSTALL_TARGET_HOOKS += PYTHON3_INSTALL_SYMLINK
  126. endif
  127. define HOST_PYTHON3_INSTALL_SYMLINK
  128. ln -fs python3 $(HOST_DIR)/usr/bin/python
  129. endef
  130. HOST_PYTHON3_POST_INSTALL_HOOKS += HOST_PYTHON3_INSTALL_SYMLINK
  131. # Provided to other packages
  132. PYTHON3_PATH = $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/sysconfigdata/:$(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/site-packages/
  133. $(eval $(autotools-package))
  134. $(eval $(host-autotools-package))