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.

253 lines
7.5 KiB

  1. #
  2. # Copyright (C) 2006-2016 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. # For PYTHON_VERSION
  9. include ./files/python-version.mk
  10. PKG_NAME:=python
  11. PKG_VERSION:=$(PYTHON_VERSION).$(PYTHON_VERSION_MICRO)
  12. PKG_RELEASE:=2
  13. PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz
  14. PKG_SOURCE_URL:=https://www.python.org/ftp/python/$(PKG_VERSION)
  15. PKG_MD5SUM:=57dffcee9cee8bb2ab5f82af1d8e9a69
  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. # This file provides the necsessary host build variables
  19. include ./files/python-host.mk
  20. # For PyPackage
  21. include ./files/python-package.mk
  22. PKG_INSTALL:=1
  23. PKG_BUILD_PARALLEL:=1
  24. HOST_BUILD_PARALLEL:=1
  25. PKG_BUILD_DIR:=$(BUILD_DIR)/Python-$(PKG_VERSION)
  26. HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/Python-$(PKG_VERSION)
  27. PKG_BUILD_DEPENDS:=python/host
  28. HOST_BUILD_DEPENDS:=bzip2/host expat/host libffi/host
  29. include $(INCLUDE_DIR)/host-build.mk
  30. include $(INCLUDE_DIR)/package.mk
  31. define Package/python/Default
  32. SUBMENU:=Python
  33. SECTION:=lang
  34. CATEGORY:=Languages
  35. TITLE:=Python $(PYTHON_VERSION) programming language
  36. URL:=https://www.python.org/
  37. MAINTAINER:=Alexandru Ardelean <ardeleanalex@gmail.com>
  38. endef
  39. define Package/python/Default/description
  40. Python is a dynamic object-oriented programming language that can be used
  41. for many kinds of software development. It offers strong support for
  42. integration with other languages and tools, comes with extensive standard
  43. libraries, and can be learned in a few days. Many Python programmers
  44. report substantial productivity gains and feel the language encourages
  45. the development of higher quality, more maintainable code.
  46. endef
  47. define Package/python-base
  48. $(call Package/python/Default)
  49. TITLE:=Python $(PYTHON_VERSION) interpreter
  50. DEPENDS:=+libpthread +zlib
  51. endef
  52. define Package/python-base/description
  53. This package contains only the interpreter and the bare minimum
  54. for the interpreter to start.
  55. endef
  56. define Package/python-light
  57. $(call Package/python/Default)
  58. TITLE:=Python $(PYTHON_VERSION) light installation
  59. DEPENDS:=+python-base +libffi +libbz2
  60. endef
  61. define Package/python-light/description
  62. This package is essentially the python-base package plus
  63. a few of the rarely used (and big) libraries stripped out
  64. into separate packages.
  65. endef
  66. PYTHON_LIB_FILES_DEL:=
  67. PYTHON_PACKAGES:=
  68. PYTHON_PACKAGES_DEPENDS:=
  69. define PyBasePackage
  70. PYTHON_PACKAGES+=$(1)
  71. ifeq ($(3),)
  72. PYTHON_PACKAGES_DEPENDS+=$(1)
  73. endif
  74. PYTHON_LIB_FILES_DEL+=$(2)
  75. define PyPackage/$(1)/filespec
  76. $(subst $(space),$(newline),$(foreach lib_file,$(2),+|$(lib_file)))
  77. endef
  78. endef
  79. include ./files/python-package-*.mk
  80. define Package/python
  81. $(call Package/python/Default)
  82. DEPENDS:=+python-light $(foreach package,$(PYTHON_PACKAGES_DEPENDS),+$(package))
  83. endef
  84. define Package/python/description
  85. This package contains the (almost) full Python install.
  86. It's python-light + all other packages.
  87. endef
  88. MAKE_FLAGS+=\
  89. CROSS_COMPILE=yes \
  90. LD="$(TARGET_CC)" \
  91. PGEN=pgen2
  92. EXTRA_CFLAGS+= \
  93. -DNDEBUG -fno-inline
  94. EXTRA_LDFLAGS+= \
  95. -L$(PKG_BUILD_DIR)
  96. ENABLE_IPV6:=
  97. ifeq ($(CONFIG_IPV6),y)
  98. ENABLE_IPV6 += --enable-ipv6
  99. endif
  100. CONFIGURE_ARGS+= \
  101. --sysconfdir=/etc \
  102. --enable-shared \
  103. --without-cxx-main \
  104. --with-threads \
  105. --with-system-ffi="$(STAGING_DIR)/usr" \
  106. --without-pymalloc \
  107. $(ENABLE_IPV6) \
  108. CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
  109. OPT="$(TARGET_CFLAGS)"
  110. define Build/Prepare
  111. $(call Build/Prepare/Default)
  112. $(CP) ./files/config.site $(PKG_BUILD_DIR)/config.site
  113. endef
  114. define Build/InstallDev
  115. $(INSTALL_DIR) $(STAGING_DIR)/mk/
  116. $(INSTALL_DIR) $(1)/usr/include/ $(1)/usr/lib/ $(1)/usr/lib/pkgconfig
  117. $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/
  118. $(INSTALL_DATA) \
  119. ./files/python-package.mk \
  120. ./files/python-host.mk \
  121. ./files/python-version.mk \
  122. $(STAGING_DIR)/mk/
  123. $(CP) \
  124. $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \
  125. $(1)/usr/include/
  126. $(CP) \
  127. $(HOST_PYTHON_LIB_DIR) \
  128. $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* \
  129. $(1)/usr/lib/
  130. $(CP) \
  131. $(HOST_PYTHON_DIR)/lib/pkgconfig/python.pc \
  132. $(HOST_PYTHON_DIR)/lib/pkgconfig/python2.pc \
  133. $(HOST_PYTHON_DIR)/lib/pkgconfig/python-$(PYTHON_VERSION).pc \
  134. $(1)/usr/lib/pkgconfig
  135. $(CP) \
  136. $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config \
  137. $(1)/usr/lib/python$(PYTHON_VERSION)/
  138. endef
  139. PYTHON_BASE_LIB_FILES:= \
  140. /usr/lib/python$(PYTHON_VERSION)/_abcoll.py \
  141. /usr/lib/python$(PYTHON_VERSION)/_sysconfigdata.py \
  142. /usr/lib/python$(PYTHON_VERSION)/_weakrefset.py \
  143. /usr/lib/python$(PYTHON_VERSION)/abc.py \
  144. /usr/lib/python$(PYTHON_VERSION)/copy_reg.py \
  145. /usr/lib/python$(PYTHON_VERSION)/genericpath.py \
  146. /usr/lib/python$(PYTHON_VERSION)/linecache.py \
  147. /usr/lib/python$(PYTHON_VERSION)/posixpath.py \
  148. /usr/lib/python$(PYTHON_VERSION)/os.py \
  149. /usr/lib/python$(PYTHON_VERSION)/re.py \
  150. /usr/lib/python$(PYTHON_VERSION)/site.py \
  151. /usr/lib/python$(PYTHON_VERSION)/sre_compile.py \
  152. /usr/lib/python$(PYTHON_VERSION)/sre_constants.py \
  153. /usr/lib/python$(PYTHON_VERSION)/sre_parse.py \
  154. /usr/lib/python$(PYTHON_VERSION)/sysconfig.py \
  155. /usr/lib/python$(PYTHON_VERSION)/stat.py \
  156. /usr/lib/python$(PYTHON_VERSION)/traceback.py \
  157. /usr/lib/python$(PYTHON_VERSION)/types.py \
  158. /usr/lib/python$(PYTHON_VERSION)/UserDict.py \
  159. /usr/lib/python$(PYTHON_VERSION)/warnings.py
  160. PYTHON_LIB_FILES_DEL+=$(PYTHON_BASE_LIB_FILES)
  161. define PyPackage/python-base/filespec
  162. +|/usr/bin/python$(PYTHON_VERSION)
  163. $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON_BASE_LIB_FILES),+|$(lib_file)))
  164. endef
  165. define PyPackage/python-light/filespec
  166. +|/usr/lib/python$(PYTHON_VERSION)
  167. -|/usr/lib/python$(PYTHON_VERSION)/distutils/cygwinccompiler.py
  168. -|/usr/lib/python$(PYTHON_VERSION)/distutils/command/wininst*
  169. -|/usr/lib/python$(PYTHON_VERSION)/ensurepip
  170. -|/usr/lib/python$(PYTHON_VERSION)/idlelib
  171. -|/usr/lib/python$(PYTHON_VERSION)/lib-tk
  172. -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_testcapi.so
  173. -|/usr/lib/python$(PYTHON_VERSION)/pdb.doc
  174. -|/usr/lib/python$(PYTHON_VERSION)/test
  175. -|/usr/lib/python$(PYTHON_VERSION)/webbrowser.py
  176. -|/usr/lib/python$(PYTHON_VERSION)/*/test
  177. -|/usr/lib/python$(PYTHON_VERSION)/*/tests
  178. -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/readline.so
  179. $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON_LIB_FILES_DEL),-|$(lib_file)))
  180. endef
  181. define PyPackage/python-base/install
  182. $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python
  183. $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python2
  184. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* $(1)/usr/lib/
  185. endef
  186. define PyPackage/python/filespec
  187. -|$(PYTHON_PKG_DIR)
  188. endef
  189. HOST_CONFIGURE_ARGS+= \
  190. --without-cxx-main \
  191. --without-pymalloc \
  192. --with-threads \
  193. --prefix=$(HOST_PYTHON_DIR) \
  194. --exec-prefix=$(HOST_PYTHON_DIR) \
  195. --with-system-expat=$(STAGING_DIR_HOSTPKG) \
  196. --with-system-ffi=$(STAGING_DIR_HOSTPKG) \
  197. CONFIG_SITE= \
  198. CFLAGS="$(HOST_CFLAGS)"
  199. define Host/Install
  200. $(MAKE) -C $(HOST_BUILD_DIR) install
  201. $(INSTALL_DIR) $(HOST_PYTHON_DIR)/bin/
  202. $(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(HOST_PYTHON_DIR)/bin/pgen2
  203. endef
  204. $(eval $(call HostBuild))
  205. $(foreach package, $(PYTHON_PACKAGES), \
  206. $(eval $(call PyPackage,$(package))) \
  207. $(eval $(call BuildPackage,$(package))) \
  208. )
  209. $(eval $(call PyPackage,python-base))
  210. $(eval $(call PyPackage,python-light))
  211. $(eval $(call PyPackage,python))
  212. $(eval $(call BuildPackage,python-base))
  213. $(eval $(call BuildPackage,python-light))
  214. $(eval $(call BuildPackage,python))