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.

196 lines
5.9 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 ./files/python3-package.mk
  10. PYTHON_VERSION:=$(PYTHON3_VERSION)
  11. PYTHON_VERSION_MICRO:=$(PYTHON3_VERSION_MICRO)
  12. PKG_NAME:=python3
  13. PKG_RELEASE:=1
  14. PKG_VERSION:=$(PYTHON_VERSION).$(PYTHON_VERSION_MICRO)
  15. PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz
  16. PKG_SOURCE_URL:=http://www.python.org/ftp/python/$(PKG_VERSION)
  17. PKG_MD5SUM:=36fc7327c02c6f12fa24fc9ba78039e3
  18. PKG_LICENSE:=PSF
  19. 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
  20. PKG_INSTALL:=1
  21. PKG_BUILD_PARALLEL:=1
  22. HOST_BUILD_PARALLEL:=1
  23. PKG_BUILD_DIR:=$(BUILD_DIR)/Python-$(PKG_VERSION)
  24. HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/Python-$(PKG_VERSION)
  25. PKG_BUILD_DEPENDS:=python3/host
  26. include $(INCLUDE_DIR)/host-build.mk
  27. include $(INCLUDE_DIR)/package.mk
  28. define Package/python3/Default
  29. SUBMENU:=Python
  30. SECTION:=lang
  31. CATEGORY:=Languages
  32. TITLE:=Python $(PYTHON_VERSION) programming language
  33. URL:=http://www.python.org/
  34. MAINTAINER:=Alexandru Ardelean <ardeleanalex@gmail.com>
  35. endef
  36. define Package/python3/Default/description
  37. Python is a dynamic object-oriented programming language that can be used
  38. for many kinds of software development. It offers strong support for
  39. integration with other languages and tools, comes with extensive standard
  40. libraries, and can be learned in a few days. Many Python programmers
  41. report substantial productivity gains and feel the language encourages
  42. the development of higher quality, more maintainable code.
  43. endef
  44. define Package/python3-base
  45. $(call Package/python3/Default)
  46. TITLE:=Python $(PYTHON_VERSION) interpreter
  47. DEPENDS:=+libpthread +zlib +libffi +libopenssl
  48. endef
  49. define Package/python3-base/description
  50. This package contains only the interpreter and the bare minimum
  51. for the interpreter to start.
  52. endef
  53. define Package/python3
  54. $(call Package/python3/Default)
  55. DEPENDS:=+python3-base +libncursesw +libbz2 +libgdbm +libsqlite3 +libdb47
  56. endef
  57. define Package/python3/description
  58. This package contains the (almost) full Python install.
  59. endef
  60. MAKE_FLAGS+=\
  61. CROSS_COMPILE=yes \
  62. LD="$(TARGET_CC)" \
  63. PGEN=pgen3
  64. EXTRA_CFLAGS+= \
  65. -DNDEBUG -fno-inline
  66. EXTRA_LDFLAGS+= \
  67. -L$(PKG_BUILD_DIR)
  68. ENABLE_IPV6:=
  69. ifeq ($(CONFIG_IPV6),y)
  70. ENABLE_IPV6 += --enable-ipv6
  71. endif
  72. CONFIGURE_ARGS+= \
  73. --sysconfdir=/etc \
  74. --enable-shared \
  75. --without-cxx-main \
  76. --with-threads \
  77. --with-system-ffi="$(STAGING_DIR)/usr" \
  78. --without-pymalloc \
  79. --without-ensurepip \
  80. $(ENABLE_IPV6) \
  81. CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
  82. OPT="$(TARGET_CFLAGS)"
  83. define Build/Prepare
  84. $(call Build/Prepare/Default)
  85. $(CP) ./files/config.site $(PKG_BUILD_DIR)/config.site
  86. endef
  87. define Build/InstallDev
  88. $(INSTALL_DIR) $(STAGING_DIR)/mk/
  89. $(INSTALL_DIR) $(1)/usr/include/ $(1)/usr/lib/
  90. $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/
  91. $(INSTALL_DATA) ./files/python3-package.mk $(STAGING_DIR)/mk/
  92. $(CP) \
  93. $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \
  94. $(1)/usr/include/
  95. $(CP) \
  96. $(STAGING_DIR_HOST)/lib/python$(PYTHON_VERSION) \
  97. $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* \
  98. $(1)/usr/lib/
  99. $(CP) \
  100. $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config-$(PYTHON_VERSION) \
  101. $(1)/usr/lib/python$(PYTHON_VERSION)/
  102. endef
  103. define Py3Package/python3-base/filespec
  104. +|/usr/bin/python$(PYTHON_VERSION)
  105. +|/usr/lib/python$(PYTHON_VERSION)/encodings
  106. +|/usr/lib/python$(PYTHON_VERSION)/_collections_abc.py
  107. +|/usr/lib/python$(PYTHON_VERSION)/_sitebuiltins.py
  108. +|/usr/lib/python$(PYTHON_VERSION)/_sysconfigdata.py
  109. +|/usr/lib/python$(PYTHON_VERSION)/_weakrefset.py
  110. +|/usr/lib/python$(PYTHON_VERSION)/abc.py
  111. +|/usr/lib/python$(PYTHON_VERSION)/codecs.py
  112. +|/usr/lib/python$(PYTHON_VERSION)/genericpath.py
  113. +|/usr/lib/python$(PYTHON_VERSION)/io.py
  114. +|/usr/lib/python$(PYTHON_VERSION)/os.py
  115. +|/usr/lib/python$(PYTHON_VERSION)/posixpath.py
  116. +|/usr/lib/python$(PYTHON_VERSION)/site.py
  117. +|/usr/lib/python$(PYTHON_VERSION)/sysconfig.py
  118. +|/usr/lib/python$(PYTHON_VERSION)/stat.py
  119. endef
  120. define Py3Package/python3/filespec
  121. +|/usr/lib/python$(PYTHON_VERSION)
  122. -|/usr/lib/python$(PYTHON_VERSION)/config-$(PYTHON_VERSION)
  123. -|/usr/lib/python$(PYTHON_VERSION)/distutils/cygwinccompiler.py
  124. -|/usr/lib/python$(PYTHON_VERSION)/distutils/command/wininst*
  125. -|/usr/lib/python$(PYTHON_VERSION)/idlelib
  126. -|/usr/lib/python$(PYTHON_VERSION)/lib2to3
  127. -|/usr/lib/python$(PYTHON_VERSION)/tkinter
  128. -|/usr/lib/python$(PYTHON_VERSION)/turtledemo
  129. -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_test*.so
  130. -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/readline*.so
  131. -|/usr/lib/python$(PYTHON_VERSION)/pdb.doc
  132. -|/usr/lib/python$(PYTHON_VERSION)/test
  133. -|/usr/lib/python$(PYTHON_VERSION)/webbrowser.py
  134. -|/usr/lib/python$(PYTHON_VERSION)/*/test
  135. -|/usr/lib/python$(PYTHON_VERSION)/*/tests
  136. endef
  137. define Py3Package/python3-base/install
  138. # Adding the lib-dynload folder (even just empty) suppresses 2 warnings when starting Python
  139. $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/lib-dynload/
  140. $(INSTALL_DIR) $(1)/usr/bin
  141. $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python3
  142. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* $(1)/usr/lib/
  143. endef
  144. HOST_CONFIGURE_ARGS+= \
  145. --without-cxx-main \
  146. --without-pymalloc \
  147. --with-threads \
  148. --prefix=$(STAGING_DIR_HOST) \
  149. --with-ensurepip=upgrade \
  150. CONFIG_SITE= \
  151. OPT="$(HOST_CFLAGS)"
  152. define Host/Compile
  153. +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) python Parser/pgen
  154. +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) sharedmods
  155. endef
  156. define Host/Install
  157. $(INSTALL_DIR) $(STAGING_DIR_HOST)/bin/
  158. $(MAKE) -C $(HOST_BUILD_DIR) install
  159. $(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(STAGING_DIR_HOST)/bin/pgen3
  160. endef
  161. $(eval $(call HostBuild))
  162. $(eval $(call Py3Package,python3-base))
  163. $(eval $(call Py3Package,python3))
  164. $(eval $(call BuildPackage,python3-base))
  165. $(eval $(call BuildPackage,python3))