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.

251 lines
7.4 KiB

  1. #
  2. # Copyright (C) 2006-2015 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:=2
  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:=7d092d1bba6e17f0d9bd21b49e441dd5
  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
  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-light
  54. $(call Package/python3/Default)
  55. TITLE:=Python $(PYTHON_VERSION) light installation
  56. DEPENDS:=+python3-base +libffi +libbz2
  57. endef
  58. define Package/python3-light/description
  59. This package is essentially the python3-base package plus
  60. a few of the rarely used (and big) libraries stripped out
  61. into separate packages.
  62. endef
  63. # Define newline here, since it's not defined in OpenWRT
  64. define newline
  65. endef
  66. PYTHON3_LIB_FILES_DEL:=
  67. PYTHON3_PACKAGES:=
  68. PYTHON3_SO_SUFFIX:=cpython-34.so
  69. define Py3BasePackage
  70. PYTHON3_PACKAGES+=$(1)
  71. PYTHON3_LIB_FILES_DEL+=$(2)
  72. define Py3Package/$(1)/filespec
  73. $(subst $(space),$(newline),$(foreach lib_file,$(2),+|$(lib_file)))
  74. endef
  75. endef
  76. include ./files/python3-package-*.mk
  77. define Package/python3
  78. $(call Package/python3/Default)
  79. DEPENDS:=+python3-light $(foreach package,$(PYTHON3_PACKAGES),+$(package))
  80. endef
  81. define Package/python3/description
  82. This package contains the (almost) full Python install.
  83. It's python3-light + all other packages.
  84. endef
  85. MAKE_FLAGS+=\
  86. CROSS_COMPILE=yes \
  87. LD="$(TARGET_CC)" \
  88. PGEN=pgen3
  89. EXTRA_CFLAGS+= \
  90. -DNDEBUG -fno-inline
  91. EXTRA_LDFLAGS+= \
  92. -L$(PKG_BUILD_DIR)
  93. ENABLE_IPV6:=
  94. ifeq ($(CONFIG_IPV6),y)
  95. ENABLE_IPV6 += --enable-ipv6
  96. endif
  97. CONFIGURE_ARGS+= \
  98. --sysconfdir=/etc \
  99. --enable-shared \
  100. --without-cxx-main \
  101. --with-threads \
  102. --with-system-ffi="$(STAGING_DIR)/usr" \
  103. --without-pymalloc \
  104. --without-ensurepip \
  105. $(ENABLE_IPV6) \
  106. CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
  107. OPT="$(TARGET_CFLAGS)"
  108. define Build/Prepare
  109. $(call Build/Prepare/Default)
  110. $(CP) ./files/config.site $(PKG_BUILD_DIR)/config.site
  111. endef
  112. define Build/InstallDev
  113. $(INSTALL_DIR) $(STAGING_DIR)/mk/
  114. $(INSTALL_DIR) $(1)/usr/include/ $(1)/usr/lib/
  115. $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/
  116. $(INSTALL_DATA) ./files/python3-package.mk $(STAGING_DIR)/mk/
  117. $(CP) \
  118. $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \
  119. $(1)/usr/include/
  120. $(CP) \
  121. $(STAGING_DIR_HOST)/lib/python$(PYTHON_VERSION) \
  122. $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* \
  123. $(1)/usr/lib/
  124. $(CP) \
  125. $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config-$(PYTHON_VERSION) \
  126. $(1)/usr/lib/python$(PYTHON_VERSION)/
  127. endef
  128. PYTHON3_BASE_LIB_FILES:= \
  129. /usr/lib/python$(PYTHON_VERSION)/encodings \
  130. /usr/lib/python$(PYTHON_VERSION)/_collections_abc.py \
  131. /usr/lib/python$(PYTHON_VERSION)/_sitebuiltins.py \
  132. /usr/lib/python$(PYTHON_VERSION)/_sysconfigdata.py \
  133. /usr/lib/python$(PYTHON_VERSION)/_weakrefset.py \
  134. /usr/lib/python$(PYTHON_VERSION)/abc.py \
  135. /usr/lib/python$(PYTHON_VERSION)/codecs.py \
  136. /usr/lib/python$(PYTHON_VERSION)/genericpath.py \
  137. /usr/lib/python$(PYTHON_VERSION)/io.py \
  138. /usr/lib/python$(PYTHON_VERSION)/os.py \
  139. /usr/lib/python$(PYTHON_VERSION)/posixpath.py \
  140. /usr/lib/python$(PYTHON_VERSION)/site.py \
  141. /usr/lib/python$(PYTHON_VERSION)/sysconfig.py \
  142. /usr/lib/python$(PYTHON_VERSION)/stat.py
  143. PYTHON3_LIB_FILES_DEL+=$(PYTHON3_BASE_LIB_FILES)
  144. define Py3Package/python3-base/filespec
  145. +|/usr/bin/python$(PYTHON_VERSION)
  146. $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON3_BASE_LIB_FILES),+|$(lib_file)))
  147. endef
  148. define Py3Package/python3-light/filespec
  149. +|/usr/lib/python$(PYTHON_VERSION)
  150. -|/usr/lib/python$(PYTHON_VERSION)/config-$(PYTHON_VERSION)
  151. -|/usr/lib/python$(PYTHON_VERSION)/distutils/cygwinccompiler.py
  152. -|/usr/lib/python$(PYTHON_VERSION)/distutils/command/wininst*
  153. -|/usr/lib/python$(PYTHON_VERSION)/ensurepip
  154. -|/usr/lib/python$(PYTHON_VERSION)/idlelib
  155. -|/usr/lib/python$(PYTHON_VERSION)/lib2to3
  156. -|/usr/lib/python$(PYTHON_VERSION)/tkinter
  157. -|/usr/lib/python$(PYTHON_VERSION)/turtledemo
  158. -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_test*.so
  159. -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/readline*.so
  160. -|/usr/lib/python$(PYTHON_VERSION)/pdb.doc
  161. -|/usr/lib/python$(PYTHON_VERSION)/test
  162. -|/usr/lib/python$(PYTHON_VERSION)/webbrowser.py
  163. -|/usr/lib/python$(PYTHON_VERSION)/*/test
  164. -|/usr/lib/python$(PYTHON_VERSION)/*/tests
  165. -|/usr/lib/python$(PYTHON_VERSION)/_osx_support.py
  166. $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON3_LIB_FILES_DEL),-|$(lib_file)))
  167. endef
  168. define Py3Package/python3-base/install
  169. # Adding the lib-dynload folder (even just empty) suppresses 2 warnings when starting Python
  170. $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/lib-dynload/
  171. $(INSTALL_DIR) $(1)/usr/bin
  172. $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python3
  173. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* $(1)/usr/lib/
  174. endef
  175. define Py3Package/python3/filespec
  176. -|$(PYTHON3_PKG_DIR)
  177. endef
  178. HOST_CFLAGS+= \
  179. -I/usr/include/ncursesw \
  180. -I/usr/include/ncurses
  181. HOST_CONFIGURE_ARGS+= \
  182. --without-cxx-main \
  183. --without-pymalloc \
  184. --with-threads \
  185. --prefix=$(STAGING_DIR_HOST) \
  186. --with-ensurepip=upgrade \
  187. CONFIG_SITE= \
  188. CFLAGS="$(HOST_CFLAGS)"
  189. define Host/Compile
  190. +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) python Parser/pgen
  191. +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) sharedmods
  192. endef
  193. define Host/Install
  194. $(INSTALL_DIR) $(STAGING_DIR_HOST)/bin/
  195. $(MAKE) -C $(HOST_BUILD_DIR) install
  196. $(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(STAGING_DIR_HOST)/bin/pgen3
  197. endef
  198. $(eval $(call HostBuild))
  199. $(foreach package, $(PYTHON3_PACKAGES), \
  200. $(eval $(call Py3Package,$(package))) \
  201. $(eval $(call BuildPackage,$(package))) \
  202. )
  203. $(eval $(call Py3Package,python3-base))
  204. $(eval $(call Py3Package,python3-light))
  205. $(eval $(call Py3Package,python3))
  206. $(eval $(call BuildPackage,python3-base))
  207. $(eval $(call BuildPackage,python3-light))
  208. $(eval $(call BuildPackage,python3))