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.

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