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