python.mk 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. PYTHON_INSTALL_STAGING = YES
  46. ifeq ($(BR2_PACKAGE_PYTHON_READLINE),y)
  47. PYTHON_DEPENDENCIES += readline
  48. endif
  49. ifeq ($(BR2_PACKAGE_PYTHON_CURSES),y)
  50. PYTHON_DEPENDENCIES += ncurses
  51. else
  52. PYTHON_CONF_OPT += --disable-curses
  53. endif
  54. ifeq ($(BR2_PACKAGE_PYTHON_PYEXPAT),y)
  55. PYTHON_DEPENDENCIES += expat
  56. PYTHON_CONF_OPT += --with-expat=system
  57. else
  58. PYTHON_CONF_OPT += --with-expat=none
  59. endif
  60. ifeq ($(BR2_PACKAGE_PYTHON_BSDDB),y)
  61. PYTHON_DEPENDENCIES += berkeleydb
  62. else
  63. PYTHON_CONF_OPT += --disable-bsddb
  64. endif
  65. ifeq ($(BR2_PACKAGE_PYTHON_SQLITE),y)
  66. PYTHON_DEPENDENCIES += sqlite
  67. else
  68. PYTHON_CONF_OPT += --disable-sqlite3
  69. endif
  70. ifeq ($(BR2_PACKAGE_PYTHON_SSL),y)
  71. PYTHON_DEPENDENCIES += openssl
  72. else
  73. PYTHON_CONF_OPT += --disable-ssl
  74. endif
  75. ifneq ($(BR2_PACKAGE_PYTHON_CODECSCJK),y)
  76. PYTHON_CONF_OPT += --disable-codecs-cjk
  77. endif
  78. ifneq ($(BR2_PACKAGE_PYTHON_UNICODEDATA),y)
  79. PYTHON_CONF_OPT += --disable-unicodedata
  80. endif
  81. ifeq ($(BR2_PACKAGE_PYTHON_BZIP2),y)
  82. PYTHON_DEPENDENCIES += bzip2
  83. else
  84. PYTHON_CONF_OPT += --disable-bz2
  85. endif
  86. ifeq ($(BR2_PACKAGE_PYTHON_ZLIB),y)
  87. PYTHON_DEPENDENCIES += zlib
  88. else
  89. PYTHON_CONF_OPT += --disable-zlib
  90. endif
  91. ifeq ($(BR2_PACKAGE_PYTHON_HASHLIB),y)
  92. PYTHON_DEPENDENCIES += openssl
  93. endif
  94. PYTHON_CONF_ENV += \
  95. PYTHON_FOR_BUILD=$(HOST_PYTHON_DIR)/python \
  96. PGEN_FOR_BUILD=$(HOST_PYTHON_DIR)/Parser/pgen \
  97. ac_cv_have_long_long_format=yes
  98. PYTHON_CONF_OPT += \
  99. --without-cxx-main \
  100. --without-doc-strings \
  101. --with-system-ffi \
  102. --disable-pydoc \
  103. --disable-test-modules \
  104. --disable-lib2to3 \
  105. --disable-gdbm \
  106. --disable-tk \
  107. --disable-nis \
  108. --disable-dbm
  109. PYTHON_MAKE_ENV = \
  110. PYTHON_MODULES_INCLUDE=$(STAGING_DIR)/usr/include \
  111. PYTHON_MODULES_LIB="$(STAGING_DIR)/lib $(STAGING_DIR)/usr/lib"
  112. # python distutils adds -L$LIBDIR when linking binary extensions, causing
  113. # trouble for cross compilation
  114. define PYTHON_FIXUP_LIBDIR
  115. $(SED) 's|^LIBDIR=.*|LIBDIR= $(STAGING_DIR)/usr/lib|' \
  116. $(STAGING_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/config/Makefile
  117. endef
  118. PYTHON_POST_INSTALL_STAGING_HOOKS += PYTHON_FIXUP_LIBDIR
  119. #
  120. # Remove useless files. In the config/ directory, only the Makefile
  121. # and the pyconfig.h files are needed at runtime.
  122. #
  123. # idle & smtpd.py have bad shebangs and are mostly samples
  124. #
  125. define PYTHON_REMOVE_USELESS_FILES
  126. rm -f $(TARGET_DIR)/usr/bin/idle
  127. rm -f $(TARGET_DIR)/usr/bin/python$(PYTHON_VERSION_MAJOR)-config
  128. rm -f $(TARGET_DIR)/usr/bin/python2-config
  129. rm -f $(TARGET_DIR)/usr/bin/python-config
  130. rm -f $(TARGET_DIR)/usr/bin/smtpd.py
  131. for i in `find $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/config/ \
  132. -type f -not -name pyconfig.h -a -not -name Makefile` ; do \
  133. rm -f $$i ; \
  134. done
  135. endef
  136. PYTHON_POST_INSTALL_TARGET_HOOKS += PYTHON_REMOVE_USELESS_FILES
  137. PYTHON_AUTORECONF = YES
  138. $(eval $(autotools-package))
  139. $(eval $(host-autotools-package))