python.mk 4.3 KB

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