python.mk 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. #############################################################
  2. #
  3. # python
  4. #
  5. #############################################################
  6. PYTHON_VERSION_MAJOR = 2.7
  7. PYTHON_VERSION = $(PYTHON_VERSION_MAJOR).2
  8. PYTHON_SOURCE = Python-$(PYTHON_VERSION).tar.bz2
  9. PYTHON_SITE = http://python.org/ftp/python/$(PYTHON_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_PYTHON_CONF_OPT += \
  16. --without-cxx-main \
  17. --disable-sqlite3 \
  18. --disable-tk \
  19. --with-expat=system \
  20. --disable-curses \
  21. --disable-codecs-cjk \
  22. --disable-nis \
  23. --disable-unicodedata \
  24. --disable-dbm \
  25. --disable-gdbm \
  26. --disable-bsddb \
  27. --disable-test-modules \
  28. --disable-bz2 \
  29. --disable-ssl
  30. HOST_PYTHON_MAKE_ENV = \
  31. PYTHON_MODULES_INCLUDE=$(HOST_DIR)/usr/include \
  32. PYTHON_MODULES_LIB="$(HOST_DIR)/lib $(HOST_DIR)/usr/lib"
  33. HOST_PYTHON_AUTORECONF = YES
  34. define HOST_PYTHON_CONFIGURE_CMDS
  35. (cd $(@D) && rm -rf config.cache; \
  36. $(HOST_CONFIGURE_OPTS) \
  37. CFLAGS="$(HOST_CFLAGS)" \
  38. LDFLAGS="$(HOST_LDFLAGS)" \
  39. $(HOST_PYTHON_CONF_ENV) \
  40. ./configure \
  41. --prefix="$(HOST_DIR)/usr" \
  42. --sysconfdir="$(HOST_DIR)/etc" \
  43. $(HOST_PYTHON_CONF_OPT) \
  44. )
  45. endef
  46. PYTHON_DEPENDENCIES = host-python libffi
  47. HOST_PYTHON_DEPENDENCIES = host-expat host-zlib
  48. PYTHON_INSTALL_STAGING = YES
  49. ifeq ($(BR2_PACKAGE_PYTHON_READLINE),y)
  50. PYTHON_DEPENDENCIES += readline
  51. endif
  52. ifeq ($(BR2_PACKAGE_PYTHON_CURSES),y)
  53. PYTHON_DEPENDENCIES += ncurses
  54. else
  55. PYTHON_CONF_OPT += --disable-curses
  56. endif
  57. ifeq ($(BR2_PACKAGE_PYTHON_PYEXPAT),y)
  58. PYTHON_DEPENDENCIES += expat
  59. PYTHON_CONF_OPT += --with-expat=system
  60. else
  61. PYTHON_CONF_OPT += --with-expat=none
  62. endif
  63. ifeq ($(BR2_PACKAGE_PYTHON_BSDDB),y)
  64. PYTHON_DEPENDENCIES += berkeleydb
  65. else
  66. PYTHON_CONF_OPT += --disable-bsddb
  67. endif
  68. ifeq ($(BR2_PACKAGE_PYTHON_SQLITE),y)
  69. PYTHON_DEPENDENCIES += sqlite
  70. else
  71. PYTHON_CONF_OPT += --disable-sqlite3
  72. endif
  73. ifeq ($(BR2_PACKAGE_PYTHON_SSL),y)
  74. PYTHON_DEPENDENCIES += openssl
  75. else
  76. PYTHON_CONF_OPT += --disable-ssl
  77. endif
  78. ifneq ($(BR2_PACKAGE_PYTHON_CODECSCJK),y)
  79. PYTHON_CONF_OPT += --disable-codecs-cjk
  80. endif
  81. ifneq ($(BR2_PACKAGE_PYTHON_UNICODEDATA),y)
  82. PYTHON_CONF_OPT += --disable-unicodedata
  83. endif
  84. ifeq ($(BR2_PACKAGE_PYTHON_BZIP2),y)
  85. PYTHON_DEPENDENCIES += bzip2
  86. else
  87. PYTHON_CONF_OPT += --disable-bz2
  88. endif
  89. ifeq ($(BR2_PACKAGE_PYTHON_ZLIB),y)
  90. PYTHON_DEPENDENCIES += zlib
  91. else
  92. PYTHON_CONF_OPT += --disable-zlib
  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. #
  113. # Development files removal
  114. #
  115. define PYTHON_REMOVE_DEVFILES
  116. rm -f $(TARGET_DIR)/usr/bin/python$(PYTHON_VERSION_MAJOR)-config
  117. rm -f $(TARGET_DIR)/usr/bin/python-config
  118. endef
  119. ifneq ($(BR2_HAVE_DEVFILES),y)
  120. PYTHON_POST_INSTALL_TARGET_HOOKS += PYTHON_REMOVE_DEVFILES
  121. endif
  122. #
  123. # Remove useless files. In the config/ directory, only the Makefile
  124. # and the pyconfig.h files are needed at runtime.
  125. #
  126. define PYTHON_REMOVE_USELESS_FILES
  127. for i in `find $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/config/ \
  128. -type f -not -name pyconfig.h -a -not -name Makefile` ; do \
  129. rm -f $$i ; \
  130. done
  131. endef
  132. PYTHON_POST_INSTALL_TARGET_HOOKS += PYTHON_REMOVE_USELESS_FILES
  133. PYTHON_AUTORECONF = YES
  134. $(eval $(call AUTOTARGETS))
  135. $(eval $(call AUTOTARGETS,host))