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.

112 lines
3.3 KiB

  1. #
  2. # Copyright (C) 2007-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. PYTHON3_VERSION_MAJOR:=3
  8. PYTHON3_VERSION_MINOR:=5
  9. PYTHON3_VERSION_MICRO:=0
  10. PYTHON3_VERSION:=$(PYTHON3_VERSION_MAJOR).$(PYTHON3_VERSION_MINOR)
  11. PYTHON3_DIR:=$(STAGING_DIR)/usr
  12. PYTHON3_BIN_DIR:=$(PYTHON3_DIR)/bin
  13. PYTHON3_INC_DIR:=$(PYTHON3_DIR)/include/python$(PYTHON3_VERSION)
  14. PYTHON3_LIB_DIR:=$(PYTHON3_DIR)/lib/python$(PYTHON3_VERSION)
  15. PYTHON3_PKG_DIR:=/usr/lib/python$(PYTHON3_VERSION)/site-packages
  16. PYTHON3:=python$(PYTHON3_VERSION)
  17. HOST_PYTHON3_LIB_DIR:=$(STAGING_DIR_HOST)/lib/python$(PYTHON3_VERSION)
  18. HOST_PYTHON3_BIN:=$(STAGING_DIR_HOST)/bin/python3
  19. PYTHON3PATH:=$(PYTHON3_LIB_DIR):$(STAGING_DIR)/$(PYTHON3_PKG_DIR):$(PKG_INSTALL_DIR)/$(PYTHON3_PKG_DIR)
  20. define HostPython3
  21. ( export PYTHONPATH="$(PYTHON3PATH)"; \
  22. export PYTHONOPTIMIZE=""; \
  23. export PYTHONDONTWRITEBYTECODE=1; \
  24. $(1) \
  25. $(HOST_PYTHON3_BIN) $(2); \
  26. )
  27. endef
  28. PKG_USE_MIPS16:=0
  29. # This is required in addition to PKG_USE_MIPS16:=0 because otherwise MIPS16
  30. # flags are inherited from the Python base package (via sysconfig module)
  31. ifdef CONFIG_USE_MIPS16
  32. TARGET_CFLAGS += -mno-mips16 -mno-interlink-mips16
  33. endif
  34. define Py3Package
  35. # Add default PyPackage filespec none defined
  36. ifndef Py3Package/$(1)/filespec
  37. define Py3Package/$(1)/filespec
  38. +|$(PYTHON3_PKG_DIR)
  39. endef
  40. endif
  41. $(call shexport,Py3Package/$(1)/filespec)
  42. define Package/$(1)/install
  43. find $(PKG_INSTALL_DIR) -name "*\.pyc" -o -name "*\.pyo" | xargs rm -f
  44. @echo "$$$$$$$$$$(call shvar,Py3Package/$(1)/filespec)" | ( \
  45. IFS='|'; \
  46. while read fop fspec fperm; do \
  47. fop=`echo "$$$$$$$$fop" | tr -d ' \t\n'`; \
  48. if [ "$$$$$$$$fop" = "+" ]; then \
  49. if [ ! -e "$(PKG_INSTALL_DIR)$$$$$$$$fspec" ]; then \
  50. echo "File not found '$(PKG_INSTALL_DIR)$$$$$$$$fspec'"; \
  51. exit 1; \
  52. fi; \
  53. dpath=`dirname "$$$$$$$$fspec"`; \
  54. if [ -n "$$$$$$$$fperm" ]; then \
  55. dperm="-m$$$$$$$$fperm"; \
  56. else \
  57. dperm=`stat -c "%a" $(PKG_INSTALL_DIR)$$$$$$$$dpath`; \
  58. fi; \
  59. mkdir -p $$$$$$$$$dperm $$(1)$$$$$$$$dpath; \
  60. echo "copying: '$$$$$$$$fspec'"; \
  61. cp -fpR $(PKG_INSTALL_DIR)$$$$$$$$fspec $$(1)$$$$$$$$dpath/; \
  62. if [ -n "$$$$$$$$fperm" ]; then \
  63. chmod -R $$$$$$$$fperm $$(1)$$$$$$$$fspec; \
  64. fi; \
  65. elif [ "$$$$$$$$fop" = "-" ]; then \
  66. echo "removing: '$$$$$$$$fspec'"; \
  67. rm -fR $$(1)$$$$$$$$fspec; \
  68. elif [ "$$$$$$$$fop" = "=" ]; then \
  69. echo "setting permissions: '$$$$$$$$fperm' on '$$$$$$$$fspec'"; \
  70. chmod -R $$$$$$$$fperm $$(1)$$$$$$$$fspec; \
  71. fi; \
  72. done; \
  73. )
  74. $(call Py3Package/$(1)/install,$$(1))
  75. endef
  76. endef
  77. # $(1) => build subdir
  78. # $(2) => additional arguments to setup.py
  79. # $(3) => additional variables
  80. define Build/Compile/Py3Mod
  81. $(INSTALL_DIR) $(PKG_INSTALL_DIR)/$(PYTHON3_PKG_DIR)
  82. $(call HostPython3, \
  83. cd $(PKG_BUILD_DIR)/$(strip $(1)); \
  84. CC="$(TARGET_CC)" \
  85. CCSHARED="$(TARGET_CC) $(FPIC)" \
  86. LD="$(TARGET_CC)" \
  87. LDSHARED="$(TARGET_CC) -shared" \
  88. CFLAGS="$(TARGET_CFLAGS)" \
  89. CPPFLAGS="$(TARGET_CPPFLAGS) -I$(PYTHON3_INC_DIR)" \
  90. LDFLAGS="$(TARGET_LDFLAGS) -lpython$(PYTHON3_VERSION)" \
  91. _PYTHON_HOST_PLATFORM=linux2 \
  92. __PYVENV_LAUNCHER__="/usr/bin/$(PYTHON3)" \
  93. $(3) \
  94. , \
  95. ./setup.py $(2) \
  96. )
  97. find $(PKG_INSTALL_DIR) -name "*\.pyc" -o -name "*\.pyo" | xargs rm -f
  98. endef