No Description

Makefile 7.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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/python3-package.mk
  10. PYTHON_VERSION:=$(PYTHON3_VERSION)
  11. PYTHON_VERSION_MICRO:=$(PYTHON3_VERSION_MICRO)
  12. PKG_NAME:=python3
  13. PKG_RELEASE:=2
  14. PKG_VERSION:=$(PYTHON_VERSION).$(PYTHON_VERSION_MICRO)
  15. PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz
  16. PKG_SOURCE_URL:=http://www.python.org/ftp/python/$(PKG_VERSION)
  17. PKG_MD5SUM:=7d092d1bba6e17f0d9bd21b49e441dd5
  18. PKG_LICENSE:=PSF
  19. 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
  20. PKG_INSTALL:=1
  21. PKG_BUILD_PARALLEL:=1
  22. HOST_BUILD_PARALLEL:=1
  23. PKG_BUILD_DIR:=$(BUILD_DIR)/Python-$(PKG_VERSION)
  24. HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/Python-$(PKG_VERSION)
  25. PKG_BUILD_DEPENDS:=python3/host
  26. include $(INCLUDE_DIR)/host-build.mk
  27. include $(INCLUDE_DIR)/package.mk
  28. define Package/python3/Default
  29. SUBMENU:=Python
  30. SECTION:=lang
  31. CATEGORY:=Languages
  32. TITLE:=Python $(PYTHON_VERSION) programming language
  33. URL:=http://www.python.org/
  34. MAINTAINER:=Alexandru Ardelean <ardeleanalex@gmail.com>
  35. endef
  36. define Package/python3/Default/description
  37. Python is a dynamic object-oriented programming language that can be used
  38. for many kinds of software development. It offers strong support for
  39. integration with other languages and tools, comes with extensive standard
  40. libraries, and can be learned in a few days. Many Python programmers
  41. report substantial productivity gains and feel the language encourages
  42. the development of higher quality, more maintainable code.
  43. endef
  44. define Package/python3-base
  45. $(call Package/python3/Default)
  46. TITLE:=Python $(PYTHON_VERSION) interpreter
  47. DEPENDS:=+libpthread +zlib
  48. endef
  49. define Package/python3-base/description
  50. This package contains only the interpreter and the bare minimum
  51. for the interpreter to start.
  52. endef
  53. define Package/python3-light
  54. $(call Package/python3/Default)
  55. TITLE:=Python $(PYTHON_VERSION) light installation
  56. DEPENDS:=+python3-base +libffi +libbz2
  57. endef
  58. define Package/python3-light/description
  59. This package is essentially the python3-base package plus
  60. a few of the rarely used (and big) libraries stripped out
  61. into separate packages.
  62. endef
  63. # Define newline here, since it's not defined in OpenWRT
  64. define newline
  65. endef
  66. PYTHON3_LIB_FILES_DEL:=
  67. PYTHON3_PACKAGES:=
  68. PYTHON3_SO_SUFFIX:=cpython-34.so
  69. define Py3BasePackage
  70. PYTHON3_PACKAGES+=$(1)
  71. PYTHON3_LIB_FILES_DEL+=$(2)
  72. define Py3Package/$(1)/filespec
  73. $(subst $(space),$(newline),$(foreach lib_file,$(2),+|$(lib_file)))
  74. endef
  75. endef
  76. include ./files/python3-package-*.mk
  77. define Package/python3
  78. $(call Package/python3/Default)
  79. DEPENDS:=+python3-light $(foreach package,$(PYTHON3_PACKAGES),+$(package))
  80. endef
  81. define Package/python3/description
  82. This package contains the (almost) full Python install.
  83. It's python3-light + all other packages.
  84. endef
  85. MAKE_FLAGS+=\
  86. CROSS_COMPILE=yes \
  87. LD="$(TARGET_CC)" \
  88. PGEN=pgen3
  89. ifeq ($(ARCH),i386)
  90. MAKE_FLAGS+=PYTHON_DECIMAL_WITH_MACHINE=ansi32
  91. endif
  92. EXTRA_CFLAGS+= \
  93. -DNDEBUG -fno-inline
  94. EXTRA_LDFLAGS+= \
  95. -L$(PKG_BUILD_DIR)
  96. ENABLE_IPV6:=
  97. ifeq ($(CONFIG_IPV6),y)
  98. ENABLE_IPV6 += --enable-ipv6
  99. endif
  100. CONFIGURE_ARGS+= \
  101. --sysconfdir=/etc \
  102. --enable-shared \
  103. --without-cxx-main \
  104. --with-threads \
  105. --with-system-ffi="$(STAGING_DIR)/usr" \
  106. --without-pymalloc \
  107. --without-ensurepip \
  108. $(ENABLE_IPV6) \
  109. CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
  110. OPT="$(TARGET_CFLAGS)"
  111. define Build/Prepare
  112. $(call Build/Prepare/Default)
  113. $(CP) ./files/config.site $(PKG_BUILD_DIR)/config.site
  114. endef
  115. define Build/InstallDev
  116. $(INSTALL_DIR) $(STAGING_DIR)/mk/
  117. $(INSTALL_DIR) $(1)/usr/include/ $(1)/usr/lib/
  118. $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/
  119. $(INSTALL_DATA) ./files/python3-package.mk $(STAGING_DIR)/mk/
  120. $(CP) \
  121. $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \
  122. $(1)/usr/include/
  123. $(CP) \
  124. $(STAGING_DIR_HOST)/lib/python$(PYTHON_VERSION) \
  125. $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* \
  126. $(1)/usr/lib/
  127. $(CP) \
  128. $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config-$(PYTHON_VERSION) \
  129. $(1)/usr/lib/python$(PYTHON_VERSION)/
  130. endef
  131. PYTHON3_BASE_LIB_FILES:= \
  132. /usr/lib/python$(PYTHON_VERSION)/encodings \
  133. /usr/lib/python$(PYTHON_VERSION)/_collections_abc.py \
  134. /usr/lib/python$(PYTHON_VERSION)/_sitebuiltins.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)/codecs.py \
  139. /usr/lib/python$(PYTHON_VERSION)/genericpath.py \
  140. /usr/lib/python$(PYTHON_VERSION)/io.py \
  141. /usr/lib/python$(PYTHON_VERSION)/os.py \
  142. /usr/lib/python$(PYTHON_VERSION)/posixpath.py \
  143. /usr/lib/python$(PYTHON_VERSION)/site.py \
  144. /usr/lib/python$(PYTHON_VERSION)/sysconfig.py \
  145. /usr/lib/python$(PYTHON_VERSION)/stat.py
  146. PYTHON3_LIB_FILES_DEL+=$(PYTHON3_BASE_LIB_FILES)
  147. define Py3Package/python3-base/filespec
  148. +|/usr/bin/python$(PYTHON_VERSION)
  149. $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON3_BASE_LIB_FILES),+|$(lib_file)))
  150. endef
  151. define Py3Package/python3-light/filespec
  152. +|/usr/lib/python$(PYTHON_VERSION)
  153. -|/usr/lib/python$(PYTHON_VERSION)/config-$(PYTHON_VERSION)
  154. -|/usr/lib/python$(PYTHON_VERSION)/distutils/cygwinccompiler.py
  155. -|/usr/lib/python$(PYTHON_VERSION)/distutils/command/wininst*
  156. -|/usr/lib/python$(PYTHON_VERSION)/ensurepip
  157. -|/usr/lib/python$(PYTHON_VERSION)/idlelib
  158. -|/usr/lib/python$(PYTHON_VERSION)/lib2to3
  159. -|/usr/lib/python$(PYTHON_VERSION)/tkinter
  160. -|/usr/lib/python$(PYTHON_VERSION)/turtledemo
  161. -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_test*.so
  162. -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/readline*.so
  163. -|/usr/lib/python$(PYTHON_VERSION)/pdb.doc
  164. -|/usr/lib/python$(PYTHON_VERSION)/test
  165. -|/usr/lib/python$(PYTHON_VERSION)/webbrowser.py
  166. -|/usr/lib/python$(PYTHON_VERSION)/*/test
  167. -|/usr/lib/python$(PYTHON_VERSION)/*/tests
  168. -|/usr/lib/python$(PYTHON_VERSION)/_osx_support.py
  169. $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON3_LIB_FILES_DEL),-|$(lib_file)))
  170. endef
  171. define Py3Package/python3-base/install
  172. # Adding the lib-dynload folder (even just empty) suppresses 2 warnings when starting Python
  173. $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/lib-dynload/
  174. $(INSTALL_DIR) $(1)/usr/bin
  175. $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python3
  176. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* $(1)/usr/lib/
  177. endef
  178. define Py3Package/python3/filespec
  179. -|$(PYTHON3_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. --prefix=$(STAGING_DIR_HOST) \
  189. --with-ensurepip=upgrade \
  190. CONFIG_SITE= \
  191. CFLAGS="$(HOST_CFLAGS)"
  192. define Host/Compile
  193. +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) python Parser/pgen
  194. +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) sharedmods
  195. endef
  196. define Host/Install
  197. $(INSTALL_DIR) $(STAGING_DIR_HOST)/bin/
  198. $(MAKE) -C $(HOST_BUILD_DIR) install
  199. $(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(STAGING_DIR_HOST)/bin/pgen3
  200. endef
  201. $(eval $(call HostBuild))
  202. $(foreach package, $(PYTHON3_PACKAGES), \
  203. $(eval $(call Py3Package,$(package))) \
  204. $(eval $(call BuildPackage,$(package))) \
  205. )
  206. $(eval $(call Py3Package,python3-base))
  207. $(eval $(call Py3Package,python3-light))
  208. $(eval $(call Py3Package,python3))
  209. $(eval $(call BuildPackage,python3-base))
  210. $(eval $(call BuildPackage,python3-light))
  211. $(eval $(call BuildPackage,python3))