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.

198 lines
6.2 KiB

  1. #
  2. # Copyright (C) 2006-2014 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:=1
  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:=6cafc183b4106476dd73d5738d7f616a
  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
  45. $(call Package/python3/Default)
  46. DEPENDS:=+libpthread +zlib +libffi
  47. endef
  48. define Package/python3/description
  49. $(call Package/python3/Default/description)
  50. .
  51. This package contains only the interpreter and the bare minimum for the interpreter to start.
  52. endef
  53. MAKE_FLAGS:=\
  54. $(TARGET_CONFIGURE_OPTS) \
  55. DESTDIR="$(PKG_INSTALL_DIR)" \
  56. CROSS_COMPILE=yes \
  57. CFLAGS="$(TARGET_CFLAGS) -DNDEBUG -fno-inline" \
  58. LDFLAGS="$(TARGET_LDFLAGS) -L$(PKG_BUILD_DIR)" \
  59. LD="$(TARGET_CC)"
  60. ENABLE_IPV6:=
  61. ifeq ($(CONFIG_IPV6),y)
  62. ENABLE_IPV6 += --enable-ipv6
  63. endif
  64. #=======================================================================
  65. # Notes: adding these so that I don't forget, and can track why stuff
  66. # was did as was did
  67. # - Arguments below were moved to ./files/config.site file, and disabled
  68. # ac_cv_have_chflags=no \
  69. # ac_cv_have_lchflags=no \
  70. # ac_cv_py_format_size_t=no \
  71. # ac_cv_have_long_long_format=yes \
  72. # ac_cv_buggy_getaddrinfo=no \
  73. # - --without-ensurepip added, because the build wants to ensure that
  74. # it works; that's a good idea, but for now, it requires special
  75. # setup, and we can do that later
  76. # - --without-pymalloc added, becase in Python 3, modules are suffixed
  77. # with m; e.g. so some paths are python3.4m instead of python3.4
  78. # all this is detailed here:
  79. # http://legacy.python.org/dev/peps/pep-3149/
  80. #=======================================================================
  81. define Build/Configure
  82. -$(MAKE) -C $(PKG_BUILD_DIR) distclean
  83. (cd $(PKG_BUILD_DIR); autoreconf --force --install || exit 0)
  84. $(CP) ./files/config.site $(PKG_BUILD_DIR)
  85. $(call Build/Configure/Default, \
  86. --sysconfdir=/etc \
  87. --enable-shared \
  88. --without-cxx-main \
  89. --with-threads \
  90. --with-system-ffi="$(STAGING_DIR)/usr" \
  91. --without-ensurepip \
  92. --without-pymalloc \
  93. $(ENABLE_IPV6) \
  94. CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
  95. OPT="$(TARGET_CFLAGS)" \
  96. )
  97. endef
  98. define Build/InstallDev
  99. $(INSTALL_DIR) $(2)/bin $(1)/usr/bin $(1)/usr/include $(1)/usr/lib
  100. $(INSTALL_DIR) $(STAGING_DIR)/mk/
  101. $(INSTALL_DATA) ./files/python3-package.mk $(STAGING_DIR)/mk/
  102. $(CP) \
  103. $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \
  104. $(1)/usr/include/
  105. $(CP) \
  106. $(STAGING_DIR_HOST)/lib/python$(PYTHON_VERSION) \
  107. $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* \
  108. $(1)/usr/lib/
  109. $(CP) \
  110. $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config-$(PYTHON_VERSION) \
  111. $(1)/usr/lib/python$(PYTHON_VERSION)/
  112. $(CP) \
  113. $(STAGING_DIR_HOST)/bin/python$(PYTHON_VERSION)-config \
  114. $(2)/bin/
  115. $(SED) 's,^#!.*,#!/usr/bin/env python$(PYTHON_VERSION),g' $(2)/bin/python$(PYTHON_VERSION)-config
  116. endef
  117. define Py3Package/python3/filespec
  118. +|/usr/bin/python$(PYTHON_VERSION)
  119. +|/usr/lib/python$(PYTHON_VERSION)/encodings
  120. +|/usr/lib/python$(PYTHON_VERSION)/_collections_abc.py
  121. +|/usr/lib/python$(PYTHON_VERSION)/_sitebuiltins.py
  122. +|/usr/lib/python$(PYTHON_VERSION)/_sysconfigdata.py
  123. +|/usr/lib/python$(PYTHON_VERSION)/_weakrefset.py
  124. +|/usr/lib/python$(PYTHON_VERSION)/abc.py
  125. +|/usr/lib/python$(PYTHON_VERSION)/codecs.py
  126. +|/usr/lib/python$(PYTHON_VERSION)/genericpath.py
  127. +|/usr/lib/python$(PYTHON_VERSION)/io.py
  128. +|/usr/lib/python$(PYTHON_VERSION)/os.py
  129. +|/usr/lib/python$(PYTHON_VERSION)/posixpath.py
  130. +|/usr/lib/python$(PYTHON_VERSION)/site.py
  131. +|/usr/lib/python$(PYTHON_VERSION)/sysconfig.py
  132. +|/usr/lib/python$(PYTHON_VERSION)/stat.py
  133. endef
  134. define Py3Package/python3/install
  135. # Adding the lib-dynload folder (even just empty) suppresses 2 warnings when starting Python
  136. $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/lib-dynload/
  137. $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python3
  138. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* $(1)/usr/lib/
  139. endef
  140. define Host/Configure
  141. -$(MAKE) -C $(HOST_BUILD_DIR) distclean
  142. (cd $(HOST_BUILD_DIR); autoreconf --force --install || exit 0)
  143. (cd $(HOST_BUILD_DIR); \
  144. rm -rf config.cache; \
  145. CONFIG_SITE= \
  146. OPT="$(HOST_CFLAGS)" \
  147. ./configure \
  148. --without-cxx-main \
  149. --without-ensurepip \
  150. --without-pymalloc \
  151. --with-threads \
  152. --prefix=$(STAGING_DIR_HOST); \
  153. )
  154. endef
  155. define Host/Compile
  156. +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
  157. python Parser/pgen
  158. +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
  159. sharedmods
  160. endef
  161. define Host/Install
  162. $(INSTALL_DIR) $(STAGING_DIR_HOST)/bin/
  163. $(MAKE) -C $(HOST_BUILD_DIR) \
  164. install
  165. $(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(STAGING_DIR_HOST)/bin/
  166. endef
  167. $(eval $(call HostBuild))
  168. $(eval $(call Py3Package,python3))
  169. $(eval $(call BuildPackage,python3))