python3.mk 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. #############################################################
  2. #
  3. # python3
  4. #
  5. #############################################################
  6. PYTHON3_VERSION_MAJOR = 3.3
  7. PYTHON3_VERSION = $(PYTHON3_VERSION_MAJOR).0
  8. PYTHON3_SOURCE = Python-$(PYTHON3_VERSION).tar.bz2
  9. PYTHON3_SITE = http://python.org/ftp/python/$(PYTHON3_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_PYTHON3_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_PYTHON3_MAKE_ENV = \
  31. PYTHON_MODULES_INCLUDE=$(HOST_DIR)/usr/include \
  32. PYTHON_MODULES_LIB="$(HOST_DIR)/lib $(HOST_DIR)/usr/lib"
  33. HOST_PYTHON3_AUTORECONF = YES
  34. define HOST_PYTHON3_CONFIGURE_CMDS
  35. (cd $(@D) && rm -rf config.cache; \
  36. $(HOST_CONFIGURE_OPTS) \
  37. CFLAGS="$(HOST_CFLAGS)" \
  38. LDFLAGS="$(HOST_LDFLAGS)" \
  39. $(HOST_PYTHON3_CONF_ENV) \
  40. ./configure \
  41. --prefix="$(HOST_DIR)/usr" \
  42. --sysconfdir="$(HOST_DIR)/etc" \
  43. $(HOST_PYTHON3_CONF_OPT) \
  44. )
  45. endef
  46. PYTHON3_DEPENDENCIES = host-python3 libffi
  47. HOST_PYTHON3_DEPENDENCIES = host-expat host-zlib
  48. PYTHON3_INSTALL_STAGING = YES
  49. ifeq ($(BR2_PACKAGE_PYTHON3_READLINE),y)
  50. PYTHON3_DEPENDENCIES += readline
  51. endif
  52. ifeq ($(BR2_PACKAGE_PYTHON3_CURSES),y)
  53. PYTHON3_DEPENDENCIES += ncurses
  54. endif
  55. ifeq ($(BR2_PACKAGE_PYTHON3_PYEXPAT),y)
  56. PYTHON3_DEPENDENCIES += expat
  57. PYTHON3_CONF_OPT += --with-expat=system
  58. else
  59. PYTHON3_CONF_OPT += --with-expat=none
  60. endif
  61. ifeq ($(BR2_PACKAGE_PYTHON3_PYC_ONLY),y)
  62. PYTHON3_CONF_OPT += --enable-old-stdlib-cache
  63. endif
  64. ifeq ($(BR2_PACKAGE_PYTHON3_SQLITE),y)
  65. PYTHON3_DEPENDENCIES += sqlite
  66. endif
  67. ifeq ($(BR2_PACKAGE_PYTHON3_SSL),y)
  68. PYTHON_DEPENDENCIES += openssl
  69. endif
  70. ifeq ($(BR2_PACKAGE_PYTHON3_BZIP2),y)
  71. PYTHON_DEPENDENCIES += bzip2
  72. endif
  73. ifeq ($(BR2_PACKAGE_PYTHON3_ZLIB),y)
  74. PYTHON3_DEPENDENCIES += zlib
  75. endif
  76. PYTHON3_CONF_ENV += \
  77. _PROJECT_BASE=$(PYTHON3_DIR) \
  78. _PYTHON_HOST_PLATFORM=$(BR2_HOSTARCH) \
  79. PYTHON_FOR_BUILD=$(HOST_PYTHON3_DIR)/python \
  80. PGEN_FOR_BUILD=$(HOST_PYTHON3_DIR)/Parser/pgen \
  81. ac_cv_have_long_long_format=yes \
  82. ac_cv_file__dev_ptmx=yes \
  83. ac_cv_file__dev_ptc=yes \
  84. PYTHON3_CONF_OPT += \
  85. --without-cxx-main \
  86. --with-system-ffi \
  87. --disable-pydoc \
  88. --disable-test-modules \
  89. --disable-lib2to3 \
  90. --disable-gdbm \
  91. --disable-tk \
  92. --disable-nis \
  93. --disable-dbm
  94. PYTHON3_MAKE_ENV = \
  95. _PROJECT_BASE=$(PYTHON3_DIR) \
  96. _PYTHON_HOST_PLATFORM=$(BR2_HOSTARCH) \
  97. PYTHON_MODULES_INCLUDE=$(STAGING_DIR)/usr/include \
  98. PYTHON_MODULES_LIB="$(STAGING_DIR)/lib $(STAGING_DIR)/usr/lib"
  99. # python distutils adds -L$LIBDIR when linking binary extensions, causing
  100. # trouble for cross compilation
  101. define PYTHON3_FIXUP_LIBDIR
  102. $(SED) 's|^LIBDIR=.*|LIBDIR= $(STAGING_DIR)/usr/lib|' \
  103. $(STAGING_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/config-3.3m/Makefile
  104. endef
  105. PYTHON3_POST_INSTALL_STAGING_HOOKS += PYTHON3_FIXUP_LIBDIR
  106. #
  107. # Development files removal
  108. #
  109. define PYTHON3_REMOVE_DEVFILES
  110. rm -f $(TARGET_DIR)/usr/bin/python$(PYTHON3_VERSION_MAJOR)-config
  111. rm -f $(TARGET_DIR)/usr/bin/python3-config
  112. endef
  113. ifneq ($(BR2_HAVE_DEVFILES),y)
  114. PYTHON3_POST_INSTALL_TARGET_HOOKS += PYTHON3_REMOVE_DEVFILES
  115. endif
  116. #
  117. # Remove useless files. In the config/ directory, only the Makefile
  118. # and the pyconfig.h files are needed at runtime.
  119. #
  120. define PYTHON3_REMOVE_USELESS_FILES
  121. for i in `find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/config-3.3m/ \
  122. -type f -not -name pyconfig.h -a -not -name Makefile` ; do \
  123. rm -f $$i ; \
  124. done
  125. endef
  126. PYTHON3_POST_INSTALL_TARGET_HOOKS += PYTHON3_REMOVE_USELESS_FILES
  127. PYTHON3_AUTORECONF = YES
  128. define PYTHON3_INSTALL_SYMLINK
  129. ln -fs python3 $(TARGET_DIR)/usr/bin/python
  130. endef
  131. ifneq ($(BR2_PACKAGE_PYTHON),y)
  132. PYTHON3_POST_INSTALL_TARGET_HOOKS += PYTHON3_INSTALL_SYMLINK
  133. endif
  134. ifeq ($(BR2_PACKAGE_PYTHON3_PY_ONLY),y)
  135. define PYTHON3_REMOVE_MODULES_FILES
  136. for i in `find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR) \
  137. -name __pycache__` ; do \
  138. rm -rf $$i ; \
  139. done
  140. endef
  141. endif
  142. ifeq ($(BR2_PACKAGE_PYTHON3_PYC_ONLY),y)
  143. define PYTHON3_REMOVE_MODULES_FILES
  144. for i in `find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR) \
  145. -name *.py` ; do \
  146. rm -f $$i ; \
  147. done
  148. endef
  149. endif
  150. PYTHON3_POST_INSTALL_TARGET_HOOKS += PYTHON3_REMOVE_MODULES_FILES
  151. $(eval $(autotools-package))
  152. $(eval $(host-autotools-package))