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.

250 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/python-package.mk
  10. PKG_NAME:=python
  11. PKG_VERSION:=$(PYTHON_VERSION).$(PYTHON_VERSION_MICRO)
  12. PKG_RELEASE:=6
  13. PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz
  14. PKG_SOURCE_URL:=http://www.python.org/ftp/python/$(PKG_VERSION)
  15. PKG_MD5SUM:=c685ef0b8e9f27b5e3db5db12b268ac6
  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
  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:=http://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. # Define newline here, since it's not defined in OpenWRT
  63. define newline
  64. endef
  65. PYTHON_LIB_FILES_DEL:=
  66. PYTHON_PACKAGES:=
  67. define PyBasePackage
  68. PYTHON_PACKAGES+=$(1)
  69. PYTHON_LIB_FILES_DEL+=$(2)
  70. define PyPackage/$(1)/filespec
  71. $(subst $(space),$(newline),$(foreach lib_file,$(2),+|$(lib_file)))
  72. endef
  73. endef
  74. include ./files/python-package-*.mk
  75. define Package/python
  76. $(call Package/python/Default)
  77. DEPENDS:=+python-light $(foreach package,$(PYTHON_PACKAGES),+$(package))
  78. endef
  79. define Package/python/description
  80. This package contains the (almost) full Python install.
  81. It's python-light + all other packages.
  82. endef
  83. MAKE_FLAGS+=\
  84. CROSS_COMPILE=yes \
  85. LD="$(TARGET_CC)" \
  86. PGEN=pgen2
  87. EXTRA_CFLAGS+= \
  88. -DNDEBUG -fno-inline
  89. EXTRA_LDFLAGS+= \
  90. -L$(PKG_BUILD_DIR)
  91. ENABLE_IPV6:=
  92. ifeq ($(CONFIG_IPV6),y)
  93. ENABLE_IPV6 += --enable-ipv6
  94. endif
  95. CONFIGURE_ARGS+= \
  96. --sysconfdir=/etc \
  97. --enable-shared \
  98. --without-cxx-main \
  99. --with-threads \
  100. --with-system-ffi="$(STAGING_DIR)/usr" \
  101. --without-pymalloc \
  102. $(ENABLE_IPV6) \
  103. CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
  104. OPT="$(TARGET_CFLAGS)"
  105. define Build/Prepare
  106. $(call Build/Prepare/Default)
  107. $(CP) ./files/config.site $(PKG_BUILD_DIR)/config.site
  108. endef
  109. define Build/InstallDev
  110. $(INSTALL_DIR) $(STAGING_DIR)/mk/
  111. $(INSTALL_DIR) $(1)/usr/include/ $(1)/usr/lib/ $(1)/usr/lib/pkgconfig
  112. $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/
  113. $(INSTALL_DATA) ./files/python-package.mk $(STAGING_DIR)/mk/
  114. $(CP) \
  115. $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \
  116. $(1)/usr/include/
  117. $(CP) \
  118. $(STAGING_DIR_HOST)/lib/python$(PYTHON_VERSION) \
  119. $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* \
  120. $(1)/usr/lib/
  121. $(CP) \
  122. $(STAGING_DIR_HOST)/lib/pkgconfig/python.pc \
  123. $(STAGING_DIR_HOST)/lib/pkgconfig/python2.pc \
  124. $(STAGING_DIR_HOST)/lib/pkgconfig/python-$(PYTHON_VERSION).pc \
  125. $(1)/usr/lib/pkgconfig
  126. $(CP) \
  127. $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config \
  128. $(1)/usr/lib/python$(PYTHON_VERSION)/
  129. endef
  130. PYTHON_BASE_LIB_FILES:= \
  131. /usr/lib/python$(PYTHON_VERSION)/_abcoll.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)/copy_reg.py \
  136. /usr/lib/python$(PYTHON_VERSION)/genericpath.py \
  137. /usr/lib/python$(PYTHON_VERSION)/linecache.py \
  138. /usr/lib/python$(PYTHON_VERSION)/posixpath.py \
  139. /usr/lib/python$(PYTHON_VERSION)/os.py \
  140. /usr/lib/python$(PYTHON_VERSION)/re.py \
  141. /usr/lib/python$(PYTHON_VERSION)/site.py \
  142. /usr/lib/python$(PYTHON_VERSION)/sre_compile.py \
  143. /usr/lib/python$(PYTHON_VERSION)/sre_constants.py \
  144. /usr/lib/python$(PYTHON_VERSION)/sre_parse.py \
  145. /usr/lib/python$(PYTHON_VERSION)/sysconfig.py \
  146. /usr/lib/python$(PYTHON_VERSION)/stat.py \
  147. /usr/lib/python$(PYTHON_VERSION)/traceback.py \
  148. /usr/lib/python$(PYTHON_VERSION)/types.py \
  149. /usr/lib/python$(PYTHON_VERSION)/UserDict.py \
  150. /usr/lib/python$(PYTHON_VERSION)/warnings.py
  151. PYTHON_LIB_FILES_DEL+=$(PYTHON_BASE_LIB_FILES)
  152. define PyPackage/python-base/filespec
  153. +|/usr/bin/python$(PYTHON_VERSION)
  154. $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON_BASE_LIB_FILES),+|$(lib_file)))
  155. endef
  156. define PyPackage/python-light/filespec
  157. +|/usr/lib/python$(PYTHON_VERSION)
  158. -|/usr/lib/python$(PYTHON_VERSION)/config
  159. -|/usr/lib/python$(PYTHON_VERSION)/distutils/cygwinccompiler.py
  160. -|/usr/lib/python$(PYTHON_VERSION)/distutils/command/wininst*
  161. -|/usr/lib/python$(PYTHON_VERSION)/ensurepip
  162. -|/usr/lib/python$(PYTHON_VERSION)/idlelib
  163. -|/usr/lib/python$(PYTHON_VERSION)/lib2to3
  164. -|/usr/lib/python$(PYTHON_VERSION)/lib-tk
  165. -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_testcapi.so
  166. -|/usr/lib/python$(PYTHON_VERSION)/pdb.doc
  167. -|/usr/lib/python$(PYTHON_VERSION)/test
  168. -|/usr/lib/python$(PYTHON_VERSION)/webbrowser.py
  169. -|/usr/lib/python$(PYTHON_VERSION)/*/test
  170. -|/usr/lib/python$(PYTHON_VERSION)/*/tests
  171. -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/readline.so
  172. $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON_LIB_FILES_DEL),-|$(lib_file)))
  173. endef
  174. define PyPackage/python-base/install
  175. $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python
  176. $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python2
  177. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* $(1)/usr/lib/
  178. endef
  179. define PyPackage/python/filespec
  180. -|$(PYTHON_PKG_DIR)
  181. endef
  182. HOST_CFLAGS+= \
  183. -I/usr/include/ncursesw \
  184. -I/usr/include/ncurses
  185. HOST_CONFIGURE_ARGS+= \
  186. --without-cxx-main \
  187. --without-pymalloc \
  188. --with-threads \
  189. --with-system-expat=$(STAGING_DIR_HOST) \
  190. --prefix=$(STAGING_DIR_HOST) \
  191. --with-ensurepip=upgrade \
  192. CONFIG_SITE= \
  193. CFLAGS="$(HOST_CFLAGS)"
  194. define Host/Install
  195. $(INSTALL_DIR) $(STAGING_DIR_HOST)/bin/
  196. $(MAKE) -C $(HOST_BUILD_DIR) install
  197. $(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(STAGING_DIR_HOST)/bin/pgen2
  198. endef
  199. $(eval $(call HostBuild))
  200. $(foreach package, $(PYTHON_PACKAGES), \
  201. $(eval $(call PyPackage,$(package))) \
  202. $(eval $(call BuildPackage,$(package))) \
  203. )
  204. $(eval $(call PyPackage,python-base))
  205. $(eval $(call PyPackage,python-light))
  206. $(eval $(call PyPackage,python))
  207. $(eval $(call BuildPackage,python-base))
  208. $(eval $(call BuildPackage,python-light))
  209. $(eval $(call BuildPackage,python))