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. PYTHON_VERSION=3.4
  8. PYTHON_VERSION_MICRO=1
  9. PYTHON_DIR:=$(STAGING_DIR)/usr
  10. PYTHON_BIN_DIR:=$(PYTHON_DIR)/bin
  11. PYTHON_INC_DIR:=$(PYTHON_DIR)/include/python$(PYTHON_VERSION)
  12. PYTHON_LIB_DIR:=$(PYTHON_DIR)/lib/python$(PYTHON_VERSION)
  13. PYTHON_PKG_DIR:=/usr/lib/python$(PYTHON_VERSION)/site-packages
  14. PYTHON:=python$(PYTHON_VERSION)
  15. HOST_PYTHON_BIN:=$(STAGING_DIR)/usr/bin/hostpython
  16. define HostPython
  17. ( export PYTHONPATH="$(PYTHON_LIB_DIR):$(STAGING_DIR)/$(PYTHON_PKG_DIR)"; \
  18. export PYTHONOPTIMIZE=""; \
  19. export PYTHONDONTWRITEBYTECODE=1; \
  20. $(1) \
  21. $(HOST_PYTHON_BIN) $(2); \
  22. )
  23. endef
  24. define PyPackage
  25. $(call shexport,PyPackage/$(1)/filespec)
  26. define Package/$(1)/install
  27. @$(SH_FUNC) getvar $$(call shvar,PyPackage/$(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 PyPackage/$(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/PyMod
  59. $(call HostPython, \
  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