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.

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