python.mk 4.0 KB

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