python.mk 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. #############################################################
  2. #
  3. # python
  4. #
  5. #############################################################
  6. PYTHON_VERSION_MAJOR = 2.7
  7. PYTHON_VERSION = $(PYTHON_VERSION_MAJOR).1
  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-zlib \
  30. --disable-ssl
  31. HOST_PYTHON_MAKE_ENV = \
  32. PYTHON_MODULES_INCLUDE=$(HOST_DIR)/usr/include \
  33. PYTHON_MODULES_LIB="$(HOST_DIR)/lib $(HOST_DIR)/usr/lib"
  34. HOST_PYTHON_AUTORECONF = YES
  35. define HOST_PYTHON_CONFIGURE_CMDS
  36. (cd $(@D) && rm -rf config.cache; \
  37. $(HOST_CONFIGURE_OPTS) \
  38. CFLAGS="$(HOST_CFLAGS)" \
  39. LDFLAGS="$(HOST_LDFLAGS)" \
  40. $(HOST_PYTHON_CONF_ENV) \
  41. ./configure \
  42. --prefix="$(HOST_DIR)/usr" \
  43. --sysconfdir="$(HOST_DIR)/etc" \
  44. $(HOST_PYTHON_CONF_OPT) \
  45. )
  46. endef
  47. PYTHON_DEPENDENCIES = host-python libffi
  48. HOST_PYTHON_DEPENDENCIES = host-expat
  49. PYTHON_INSTALL_STAGING = YES
  50. ifeq ($(BR2_PACKAGE_PYTHON_READLINE),y)
  51. PYTHON_DEPENDENCIES += readline
  52. endif
  53. ifeq ($(BR2_PACKAGE_PYTHON_CURSES),y)
  54. PYTHON_DEPENDENCIES += ncurses
  55. else
  56. PYTHON_CONF_OPT += --disable-curses
  57. endif
  58. ifeq ($(BR2_PACKAGE_PYTHON_PYEXPAT),y)
  59. PYTHON_DEPENDENCIES += expat
  60. PYTHON_CONF_OPT += --with-expat=system
  61. else
  62. PYTHON_CONF_OPT += --with-expat=none
  63. endif
  64. ifeq ($(BR2_PACKAGE_PYTHON_BSDDB),y)
  65. PYTHON_DEPENDENCIES += berkeleydb
  66. else
  67. PYTHON_CONF_OPT += --disable-bsddb
  68. endif
  69. ifeq ($(BR2_PACKAGE_PYTHON_SQLITE),y)
  70. PYTHON_DEPENDENCIES += sqlite
  71. else
  72. PYTHON_CONF_OPT += --disable-sqlite3
  73. endif
  74. ifeq ($(BR2_PACKAGE_PYTHON_SSL),y)
  75. PYTHON_DEPENDENCIES += openssl
  76. else
  77. PYTHON_CONF_OPT += --disable-ssl
  78. endif
  79. ifneq ($(BR2_PACKAGE_PYTHON_CODECSCJK),y)
  80. PYTHON_CONF_OPT += --disable-codecs-cjk
  81. endif
  82. ifneq ($(BR2_PACKAGE_PYTHON_UNICODEDATA),y)
  83. PYTHON_CONF_OPT += --disable-unicodedata
  84. endif
  85. ifeq ($(BR2_PACKAGE_PYTHON_BZIP2),y)
  86. PYTHON_DEPENDENCIES += bzip2
  87. else
  88. PYTHON_CONF_OPT += --disable-bz2
  89. endif
  90. ifeq ($(BR2_PACKAGE_PYTHON_ZLIB),y)
  91. PYTHON_DEPENDENCIES += zlib
  92. else
  93. PYTHON_CONF_OPT += --disable-zlib
  94. endif
  95. PYTHON_CONF_ENV += \
  96. PYTHON_FOR_BUILD=$(HOST_PYTHON_DIR)/python \
  97. PGEN_FOR_BUILD=$(HOST_PYTHON_DIR)/Parser/pgen \
  98. ac_cv_have_long_long_format=yes
  99. PYTHON_CONF_OPT += \
  100. --without-cxx-main \
  101. --without-doc-strings \
  102. --with-system-ffi \
  103. --disable-pydoc \
  104. --disable-test-modules \
  105. --disable-lib2to3 \
  106. --disable-gdbm \
  107. --disable-tk \
  108. --disable-nis \
  109. --disable-dbm
  110. PYTHON_MAKE_ENV = \
  111. PYTHON_MODULES_INCLUDE=$(STAGING_DIR)/usr/include \
  112. PYTHON_MODULES_LIB="$(STAGING_DIR)/lib $(STAGING_DIR)/usr/lib"
  113. #
  114. # Development files removal
  115. #
  116. define PYTHON_REMOVE_DEVFILES
  117. rm -f $(TARGET_DIR)/usr/bin/python$(PYTHON_VERSION_MAJOR)-config
  118. rm -f $(TARGET_DIR)/usr/bin/python-config
  119. endef
  120. ifneq ($(BR2_HAVE_DEVFILES),y)
  121. PYTHON_POST_INSTALL_TARGET_HOOKS += PYTHON_REMOVE_DEVFILES
  122. endif
  123. #
  124. # Remove useless files. In the config/ directory, only the Makefile
  125. # and the pyconfig.h files are needed at runtime.
  126. #
  127. define PYTHON_REMOVE_USELESS_FILES
  128. for i in `find $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/config/ \
  129. -type f -not -name pyconfig.h -a -not -name Makefile` ; do \
  130. rm -f $$i ; \
  131. done
  132. endef
  133. PYTHON_POST_INSTALL_TARGET_HOOKS += PYTHON_REMOVE_USELESS_FILES
  134. PYTHON_AUTORECONF = YES
  135. $(eval $(call AUTOTARGETS,package,python))
  136. $(eval $(call AUTOTARGETS,package,python,host))