You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

199 lines
6.2 KiB

  1. #
  2. # Copyright (C) 2006-2014 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. include $(TOPDIR)/rules.mk
  8. # The file included below defines PYTHON_VERSION
  9. -include $(if $(DUMP),,./files/python-package.mk)
  10. PKG_NAME:=python3
  11. PKG_RELEASE:=1
  12. PKG_VERSION:=$(PYTHON_VERSION).$(PYTHON_VERSION_MICRO)
  13. PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz
  14. PKG_SOURCE_URL:=http://www.python.org/ftp/python/$(PKG_VERSION)
  15. PKG_MD5SUM:=6cafc183b4106476dd73d5738d7f616a
  16. PKG_LICENSE:=PSF
  17. PKG_LICENSE_FILES:=LICENSE Modules/_ctypes/libffi_msvc/LICENSE Modules/_ctypes/darwin/LICENSE Modules/_ctypes/libffi/LICENSE Modules/_ctypes/libffi_osx/LICENSE Tools/pybench/LICENSE
  18. PKG_INSTALL:=1
  19. PKG_BUILD_PARALLEL:=1
  20. HOST_BUILD_PARALLEL:=1
  21. PKG_BUILD_DIR:=$(BUILD_DIR)/Python-$(PKG_VERSION)
  22. HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/Python-$(PKG_VERSION)
  23. PKG_BUILD_DEPENDS:=python3/host
  24. include $(INCLUDE_DIR)/host-build.mk
  25. include $(INCLUDE_DIR)/package.mk
  26. define Package/python3/Default
  27. SUBMENU:=Python
  28. SECTION:=lang
  29. CATEGORY:=Languages
  30. TITLE:=Python $(PYTHON_VERSION) programming language
  31. URL:=http://www.python.org/
  32. MAINTAINER:=Alexandru Ardelean <ardeleanalex@gmail.com>
  33. endef
  34. define Package/python3/Default/description
  35. Python is a dynamic object-oriented programming language that can be used
  36. for many kinds of software development. It offers strong support for
  37. integration with other languages and tools, comes with extensive standard
  38. libraries, and can be learned in a few days. Many Python programmers
  39. report substantial productivity gains and feel the language encourages
  40. the development of higher quality, more maintainable code.
  41. endef
  42. define Package/python3
  43. $(call Package/python3/Default)
  44. DEPENDS:=+libpthread +zlib +libffi
  45. endef
  46. define Package/python3/description
  47. $(call Package/python3/Default/description)
  48. .
  49. This package contains only the interpreter and the bare minimum for the interpreter to start.
  50. endef
  51. MAKE_FLAGS:=\
  52. $(TARGET_CONFIGURE_OPTS) \
  53. DESTDIR="$(PKG_INSTALL_DIR)" \
  54. CROSS_COMPILE=yes \
  55. CFLAGS="$(TARGET_CFLAGS) -DNDEBUG -fno-inline" \
  56. LDFLAGS="$(TARGET_LDFLAGS)" \
  57. LD="$(TARGET_CC)"
  58. ENABLE_IPV6:=
  59. ifeq ($(CONFIG_IPV6),y)
  60. ENABLE_IPV6 += --enable-ipv6
  61. endif
  62. #=======================================================================
  63. # Notes: adding these so that I don't forget, and can track why stuff
  64. # was did as was did
  65. # - Arguments below were moved to ./files/config.site file, and disabled
  66. # ac_cv_have_chflags=no \
  67. # ac_cv_have_lchflags=no \
  68. # ac_cv_py_format_size_t=no \
  69. # ac_cv_have_long_long_format=yes \
  70. # ac_cv_buggy_getaddrinfo=no \
  71. # - --without-ensurepip added, because the build wants to ensure that
  72. # it works; that's a good idea, but for now, it requires special
  73. # setup, and we can do that later
  74. # - --without-pymalloc added, becase in Python 3, modules are suffixed
  75. # with m; e.g. so some paths are python3.4m instead of python3.4
  76. # all this is detailed here:
  77. # http://legacy.python.org/dev/peps/pep-3149/
  78. #=======================================================================
  79. define Build/Configure
  80. -$(MAKE) -C $(PKG_BUILD_DIR) distclean
  81. (cd $(PKG_BUILD_DIR); autoreconf --force --install || exit 0)
  82. # The python executable needs to stay in the rootdir since its location will
  83. # be used to compute the path of the config files.
  84. $(CP) ./files/config.site $(PKG_BUILD_DIR)
  85. $(call Build/Configure/Default, \
  86. --sysconfdir=/etc \
  87. --disable-shared \
  88. --without-cxx-main \
  89. --with-threads \
  90. --with-system-ffi="$(STAGING_DIR)/usr" \
  91. --without-ensurepip \
  92. --without-pymalloc \
  93. $(ENABLE_IPV6) \
  94. CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
  95. OPT="$(TARGET_CFLAGS)" \
  96. )
  97. endef
  98. define Build/InstallDev
  99. $(INSTALL_DIR) $(2)/bin $(1)/usr/bin $(1)/usr/include $(1)/usr/lib
  100. $(INSTALL_DIR) $(STAGING_DIR)/mk/
  101. $(INSTALL_DATA) ./files/python-package.mk $(STAGING_DIR)/mk/
  102. $(CP) \
  103. $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \
  104. $(1)/usr/include/
  105. $(CP) \
  106. $(STAGING_DIR_HOST)/lib/python$(PYTHON_VERSION) \
  107. $(PKG_BUILD_DIR)/libpython$(PYTHON_VERSION).a \
  108. $(1)/usr/lib/
  109. $(CP) \
  110. $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config-$(PYTHON_VERSION) \
  111. $(1)/usr/lib/python$(PYTHON_VERSION)/
  112. $(CP) \
  113. $(STAGING_DIR_HOST)/bin/python$(PYTHON_VERSION)-config \
  114. $(2)/bin/
  115. $(SED) 's,^#!.*,#!/usr/bin/env python$(PYTHON_VERSION),g' $(2)/bin/python$(PYTHON_VERSION)-config
  116. (cd $(2)/bin; \
  117. ln -sf python$(PYTHON_VERSION)-config python-config;)
  118. endef
  119. define PyPackage/python3/filespec
  120. +|/usr/bin/python$(PYTHON_VERSION)
  121. +|/usr/lib/python$(PYTHON_VERSION)/encodings
  122. +|/usr/lib/python$(PYTHON_VERSION)/_collections_abc.py
  123. +|/usr/lib/python$(PYTHON_VERSION)/_sitebuiltins.py
  124. +|/usr/lib/python$(PYTHON_VERSION)/_sysconfigdata.py
  125. +|/usr/lib/python$(PYTHON_VERSION)/_weakrefset.py
  126. +|/usr/lib/python$(PYTHON_VERSION)/abc.py
  127. +|/usr/lib/python$(PYTHON_VERSION)/codecs.py
  128. +|/usr/lib/python$(PYTHON_VERSION)/genericpath.py
  129. +|/usr/lib/python$(PYTHON_VERSION)/io.py
  130. +|/usr/lib/python$(PYTHON_VERSION)/os.py
  131. +|/usr/lib/python$(PYTHON_VERSION)/posixpath.py
  132. +|/usr/lib/python$(PYTHON_VERSION)/site.py
  133. +|/usr/lib/python$(PYTHON_VERSION)/sysconfig.py
  134. +|/usr/lib/python$(PYTHON_VERSION)/stat.py
  135. endef
  136. define PyPackage/python3/install
  137. # Adding the lib-dynload folder (even just empty) suppresses 2 warnings when starting Python
  138. $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/lib-dynload/
  139. ln -sf python$(PYTHON_VERSION) $(1)/usr/bin/python
  140. endef
  141. define Host/Configure
  142. -$(MAKE) -C $(HOST_BUILD_DIR) distclean
  143. (cd $(HOST_BUILD_DIR); autoreconf --force --install || exit 0)
  144. (cd $(HOST_BUILD_DIR); \
  145. rm -rf config.cache; \
  146. CONFIG_SITE= \
  147. OPT="$(HOST_CFLAGS)" \
  148. ./configure \
  149. --without-cxx-main \
  150. --without-ensurepip \
  151. --without-pymalloc \
  152. --with-threads \
  153. --prefix=$(STAGING_DIR_HOST); \
  154. )
  155. endef
  156. define Host/Compile
  157. +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
  158. python Parser/pgen
  159. +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
  160. sharedmods
  161. endef
  162. define Host/Install
  163. $(INSTALL_DIR) $(STAGING_DIR_HOST)/bin/
  164. $(MAKE) -C $(HOST_BUILD_DIR) \
  165. install
  166. $(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(STAGING_DIR_HOST)/bin/
  167. endef
  168. $(eval $(call HostBuild))
  169. $(eval $(call PyPackage,python3))
  170. $(eval $(call BuildPackage,python3))