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.

78 lines
2.1 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. @$(SH_FUNC) getvar $$(call shvar,Py3Package/$(1)/filespec) | ( \
  28. IFS='|'; \
  29. while read fop fspec fperm; do \
  30. if [ "$$$$$$$$fop" = "+" ]; then \
  31. dpath=`dirname "$$$$$$$$fspec"`; \
  32. if [ -n "$$$$$$$$fperm" ]; then \
  33. dperm="-m$$$$$$$$fperm"; \
  34. else \
  35. dperm=`stat -c "%a" $(PKG_INSTALL_DIR)$$$$$$$$dpath`; \
  36. fi; \
  37. mkdir -p $$$$$$$$$dperm $$(1)$$$$$$$$dpath; \
  38. echo "copying: '$$$$$$$$fspec'"; \
  39. cp -fpR $(PKG_INSTALL_DIR)$$$$$$$$fspec $$(1)$$$$$$$$dpath/; \
  40. if [ -n "$$$$$$$$fperm" ]; then \
  41. chmod -R $$$$$$$$fperm $$(1)$$$$$$$$fspec; \
  42. fi; \
  43. elif [ "$$$$$$$$fop" = "-" ]; then \
  44. echo "removing: '$$$$$$$$fspec'"; \
  45. rm -fR $$(1)$$$$$$$$fspec; \
  46. elif [ "$$$$$$$$fop" = "=" ]; then \
  47. echo "setting permissions: '$$$$$$$$fperm' on '$$$$$$$$fspec'"; \
  48. chmod -R $$$$$$$$fperm $$(1)$$$$$$$$fspec; \
  49. fi; \
  50. done; \
  51. )
  52. $(call Py3Package/$(1)/install,$$(1))
  53. endef
  54. endef
  55. # $(1) => build subdir
  56. # $(2) => additional arguments to setup.py
  57. # $(3) => additional variables
  58. define Build/Compile/Py3Mod
  59. $(call HostPython3, \
  60. cd $(PKG_BUILD_DIR)/$(strip $(1)); \
  61. CFLAGS="$(TARGET_CFLAGS)" \
  62. CPPFLAGS="$(TARGET_CPPFLAGS)" \
  63. LDFLAGS="$(TARGET_LDFLAGS)" \
  64. $(3) \
  65. , \
  66. ./setup.py $(2) \
  67. )
  68. find $(PKG_INSTALL_DIR) -name "*\.pyc" -o -name "*\.pyo" | xargs rm -f
  69. endef