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.

56 lines
1.5 KiB

  1. #
  2. # Copyright (C) 2015-2016 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. HOST_PYTHON_DIR:=$(STAGING_DIR)/host
  8. HOST_PYTHON_INC_DIR:=$(HOST_PYTHON_DIR)/include/python$(PYTHON_VERSION)
  9. HOST_PYTHON_LIB_DIR:=$(HOST_PYTHON_DIR)/lib/python$(PYTHON_VERSION)
  10. HOST_PYTHON_PKG_DIR:=/lib/python$(PYTHON_VERSION)/site-packages
  11. HOST_PYTHON_BIN:=$(HOST_PYTHON_DIR)/bin/python$(PYTHON_VERSION)
  12. HOST_PYTHONPATH:=$(HOST_PYTHON_LIB_DIR):$(STAGING_DIR)/host/$(HOST_PYTHON_PKG_DIR)
  13. define HostPython
  14. if [ "$(strip $(3))" == "HOST" ]; then \
  15. export PYTHONPATH="$(HOST_PYTHONPATH)"; \
  16. export PYTHONDONTWRITEBYTECODE=0; \
  17. else \
  18. export PYTHONPATH="$(PYTHONPATH)"; \
  19. export PYTHONDONTWRITEBYTECODE=1; \
  20. export _python_sysroot="$(STAGING_DIR)"; \
  21. export _python_prefix="/usr"; \
  22. export _python_exec_prefix="/usr"; \
  23. fi; \
  24. export PYTHONOPTIMIZE=""; \
  25. $(1) \
  26. $(HOST_PYTHON_BIN) $(2);
  27. endef
  28. # $(1) => build subdir
  29. # $(2) => additional arguments to setup.py
  30. # $(3) => additional variables
  31. define Build/Compile/HostPyMod
  32. $(call HostPython, \
  33. cd $(HOST_BUILD_DIR)/$(strip $(1)); \
  34. CC="$(HOSTCC)" \
  35. CCSHARED="$(HOSTCC) $(HOST_FPIC)" \
  36. CXX="$(HOSTCXX)" \
  37. LD="$(HOSTCC)" \
  38. LDSHARED="$(HOSTCC) -shared" \
  39. CFLAGS="$(HOST_CFLAGS)" \
  40. CPPFLAGS="$(HOST_CPPFLAGS) -I$(HOST_PYTHON_INC_DIR)" \
  41. LDFLAGS="$(HOST_LDFLAGS) -lpython$(PYTHON_VERSION) -Wl$(comma)-rpath=$(STAGING_DIR)/host/lib" \
  42. _PYTHON_HOST_PLATFORM=linux2 \
  43. $(3) \
  44. , \
  45. ./setup.py $(2) \
  46. , \
  47. HOST \
  48. )
  49. endef