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.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 expat/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) \
  114. ./files/python-package.mk \
  115. ./files/python-host.mk \
  116. $(STAGING_DIR)/mk/
  117. $(CP) \
  118. $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \
  119. $(1)/usr/include/
  120. $(CP) \
  121. $(STAGING_DIR_HOST)/lib/python$(PYTHON_VERSION) \
  122. $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* \
  123. $(1)/usr/lib/
  124. $(CP) \
  125. $(STAGING_DIR_HOST)/lib/pkgconfig/python.pc \
  126. $(STAGING_DIR_HOST)/lib/pkgconfig/python2.pc \
  127. $(STAGING_DIR_HOST)/lib/pkgconfig/python-$(PYTHON_VERSION).pc \
  128. $(1)/usr/lib/pkgconfig
  129. $(CP) \
  130. $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config \
  131. $(1)/usr/lib/python$(PYTHON_VERSION)/
  132. endef
  133. PYTHON_BASE_LIB_FILES:= \
  134. /usr/lib/python$(PYTHON_VERSION)/_abcoll.py \
  135. /usr/lib/python$(PYTHON_VERSION)/_sysconfigdata.py \
  136. /usr/lib/python$(PYTHON_VERSION)/_weakrefset.py \
  137. /usr/lib/python$(PYTHON_VERSION)/abc.py \
  138. /usr/lib/python$(PYTHON_VERSION)/copy_reg.py \
  139. /usr/lib/python$(PYTHON_VERSION)/genericpath.py \
  140. /usr/lib/python$(PYTHON_VERSION)/linecache.py \
  141. /usr/lib/python$(PYTHON_VERSION)/posixpath.py \
  142. /usr/lib/python$(PYTHON_VERSION)/os.py \
  143. /usr/lib/python$(PYTHON_VERSION)/re.py \
  144. /usr/lib/python$(PYTHON_VERSION)/site.py \
  145. /usr/lib/python$(PYTHON_VERSION)/sre_compile.py \
  146. /usr/lib/python$(PYTHON_VERSION)/sre_constants.py \
  147. /usr/lib/python$(PYTHON_VERSION)/sre_parse.py \
  148. /usr/lib/python$(PYTHON_VERSION)/sysconfig.py \
  149. /usr/lib/python$(PYTHON_VERSION)/stat.py \
  150. /usr/lib/python$(PYTHON_VERSION)/traceback.py \
  151. /usr/lib/python$(PYTHON_VERSION)/types.py \
  152. /usr/lib/python$(PYTHON_VERSION)/UserDict.py \
  153. /usr/lib/python$(PYTHON_VERSION)/warnings.py
  154. PYTHON_LIB_FILES_DEL+=$(PYTHON_BASE_LIB_FILES)
  155. define PyPackage/python-base/filespec
  156. +|/usr/bin/python$(PYTHON_VERSION)
  157. $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON_BASE_LIB_FILES),+|$(lib_file)))
  158. endef
  159. define PyPackage/python-light/filespec
  160. +|/usr/lib/python$(PYTHON_VERSION)
  161. -|/usr/lib/python$(PYTHON_VERSION)/config
  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)/lib2to3
  167. -|/usr/lib/python$(PYTHON_VERSION)/lib-tk
  168. -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_testcapi.so
  169. -|/usr/lib/python$(PYTHON_VERSION)/pdb.doc
  170. -|/usr/lib/python$(PYTHON_VERSION)/test
  171. -|/usr/lib/python$(PYTHON_VERSION)/webbrowser.py
  172. -|/usr/lib/python$(PYTHON_VERSION)/*/test
  173. -|/usr/lib/python$(PYTHON_VERSION)/*/tests
  174. -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/readline.so
  175. $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON_LIB_FILES_DEL),-|$(lib_file)))
  176. endef
  177. define PyPackage/python-base/install
  178. $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python
  179. $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python2
  180. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* $(1)/usr/lib/
  181. endef
  182. define PyPackage/python/filespec
  183. -|$(PYTHON_PKG_DIR)
  184. endef
  185. HOST_CFLAGS+= \
  186. -I/usr/include/ncursesw \
  187. -I/usr/include/ncurses
  188. HOST_CONFIGURE_ARGS+= \
  189. --without-cxx-main \
  190. --without-pymalloc \
  191. --with-threads \
  192. --with-system-expat=$(STAGING_DIR_HOST) \
  193. --prefix=$(STAGING_DIR_HOST) \
  194. --with-ensurepip=upgrade \
  195. CONFIG_SITE= \
  196. CFLAGS="$(HOST_CFLAGS)"
  197. define Host/Install
  198. $(INSTALL_DIR) $(STAGING_DIR_HOST)/bin/
  199. $(MAKE) -C $(HOST_BUILD_DIR) install
  200. $(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(STAGING_DIR_HOST)/bin/pgen2
  201. endef
  202. $(eval $(call HostBuild))
  203. $(foreach package, $(PYTHON_PACKAGES), \
  204. $(eval $(call PyPackage,$(package))) \
  205. $(eval $(call BuildPackage,$(package))) \
  206. )
  207. $(eval $(call PyPackage,python-base))
  208. $(eval $(call PyPackage,python-light))
  209. $(eval $(call PyPackage,python))
  210. $(eval $(call BuildPackage,python-base))
  211. $(eval $(call BuildPackage,python-light))
  212. $(eval $(call BuildPackage,python))