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.

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