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.

88 lines
2.6 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:=3.4
  8. PYTHON3_VERSION_MICRO:=1
  9. PYTHON3_DIR:=$(STAGING_DIR)/usr
  10. PYTHON3_BIN_DIR:=$(PYTHON3_DIR)/bin
  11. PYTHON3_INC_DIR:=$(PYTHON3_DIR)/include/python$(PYTHON3_VERSION)
  12. PYTHON3_LIB_DIR:=$(PYTHON3_DIR)/lib/python$(PYTHON3_VERSION)
  13. PYTHON3_PKG_DIR:=/usr/lib/python$(PYTHON3_VERSION)/site-packages
  14. PYTHON3:=python$(PYTHON3_VERSION)
  15. HOST_PYTHON3_BIN:=$(STAGING_DIR_HOST)/bin/python3
  16. define HostPython3
  17. ( export PYTHONPATH="$(PYTHON3_LIB_DIR):$(STAGING_DIR)/$(PYTHON3_PKG_DIR)"; \
  18. export PYTHONOPTIMIZE=""; \
  19. export PYTHONDONTWRITEBYTECODE=1; \
  20. $(1) \
  21. $(HOST_PYTHON3_BIN) $(2); \
  22. )
  23. endef
  24. define Py3Package
  25. $(call shexport,Py3Package/$(1)/filespec)
  26. define Package/$(1)/install
  27. find $(PKG_INSTALL_DIR) -name "*\.pyc" -o -name "*\.pyo" | xargs rm -f
  28. @echo "$$$$$$$$$$(call shvar,PyPackage/$(1)/filespec)" | ( \
  29. IFS='|'; \
  30. while read fop fspec fperm; do \
  31. if [ "$$$$$$$$fop" = "+" ]; then \
  32. if [ ! -e "$(PKG_INSTALL_DIR)$$$$$$$$fspec" ]; then \
  33. echo "File not found '$(PKG_INSTALL_DIR)$$$$$$$$fspec'"; \
  34. exit 1; \
  35. fi; \
  36. dpath=`dirname "$$$$$$$$fspec"`; \
  37. if [ -n "$$$$$$$$fperm" ]; then \
  38. dperm="-m$$$$$$$$fperm"; \
  39. else \
  40. dperm=`stat -c "%a" $(PKG_INSTALL_DIR)$$$$$$$$dpath`; \
  41. fi; \
  42. mkdir -p $$$$$$$$$dperm $$(1)$$$$$$$$dpath; \
  43. echo "copying: '$$$$$$$$fspec'"; \
  44. cp -fpR $(PKG_INSTALL_DIR)$$$$$$$$fspec $$(1)$$$$$$$$dpath/; \
  45. if [ -n "$$$$$$$$fperm" ]; then \
  46. chmod -R $$$$$$$$fperm $$(1)$$$$$$$$fspec; \
  47. fi; \
  48. elif [ "$$$$$$$$fop" = "-" ]; then \
  49. echo "removing: '$$$$$$$$fspec'"; \
  50. rm -fR $$(1)$$$$$$$$fspec; \
  51. elif [ "$$$$$$$$fop" = "=" ]; then \
  52. echo "setting permissions: '$$$$$$$$fperm' on '$$$$$$$$fspec'"; \
  53. chmod -R $$$$$$$$fperm $$(1)$$$$$$$$fspec; \
  54. fi; \
  55. done; \
  56. )
  57. $(call Py3Package/$(1)/install,$$(1))
  58. endef
  59. endef
  60. # $(1) => build subdir
  61. # $(2) => additional arguments to setup.py
  62. # $(3) => additional variables
  63. define Build/Compile/Py3Mod
  64. $(call HostPython3, \
  65. cd $(PKG_BUILD_DIR)/$(strip $(1)); \
  66. CC="$(TARGET_CC)" \
  67. CCSHARED="$(TARGET_CC) $(FPIC)" \
  68. LD="$(TARGET_CC)" \
  69. LDSHARED="$(TARGET_CC) -shared" \
  70. CFLAGS="$(TARGET_CFLAGS)" \
  71. CPPFLAGS="$(TARGET_CPPFLAGS) -I$(PYTHON3_INC_DIR)" \
  72. LDFLAGS="$(TARGET_LDFLAGS) -lpython$(PYTHON3_VERSION)" \
  73. _PYTHON_HOST_PLATFORM="linux-$(ARCH)" \
  74. $(3) \
  75. , \
  76. ./setup.py $(2) \
  77. )
  78. find $(PKG_INSTALL_DIR) -name "*\.pyc" -o -name "*\.pyo" | xargs rm -f
  79. endef