python3.mk 4.6 KB

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