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.

59 lines
1.6 KiB

  1. #
  2. # Copyright (C) 2015 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_INC_DIR:=$(STAGING_DIR)/host/usr/include/python$(PYTHON_VERSION)
  8. HOST_PYTHON_PKG_DIR:=/usr/lib/python$(PYTHON_VERSION)/site-packages
  9. HOST_PYTHONPATH:=$(HOST_PYTHON_LIB_DIR):$(STAGING_DIR)/host/$(HOST_PYTHON_PKG_DIR)
  10. define HostPython
  11. if [ "$(strip $(3))" == "HOST" ]; then \
  12. export PYTHONPATH="$(HOST_PYTHONPATH)"; \
  13. export _python_sysroot="$(STAGING_DIR)/host"; \
  14. else \
  15. export PYTHONPATH="$(PYTHONPATH)"; \
  16. export _python_sysroot="$(STAGING_DIR)"; \
  17. fi; \
  18. export PYTHONOPTIMIZE=""; \
  19. export PYTHONDONTWRITEBYTECODE=1; \
  20. export _python_prefix="/usr"; \
  21. export _python_exec_prefix="/usr"; \
  22. $(1) \
  23. $(HOST_PYTHON_BIN) $(2);
  24. endef
  25. # These configure args are needed in detection of path to Python header files
  26. # using autotools.
  27. HOST_CONFIGURE_ARGS += \
  28. _python_sysroot="$(STAGING_DIR)/host" \
  29. _python_prefix="/usr" \
  30. _python_exec_prefix="/usr"
  31. # $(1) => build subdir
  32. # $(2) => additional arguments to setup.py
  33. # $(3) => additional variables
  34. define Build/Compile/HostPyMod
  35. $(call HostPython, \
  36. cd $(HOST_BUILD_DIR)/$(strip $(1)); \
  37. CC="$(HOSTCC)" \
  38. CCSHARED="$(HOSTCC) $(HOST_FPIC)" \
  39. CXX="$(HOSTCXX)" \
  40. LD="$(HOSTCC)" \
  41. LDSHARED="$(HOSTCC) -shared" \
  42. CFLAGS="$(HOST_CFLAGS)" \
  43. CPPFLAGS="$(HOST_CPPFLAGS) -I$(HOST_PYTHON_INC_DIR)" \
  44. LDFLAGS="$(HOST_LDFLAGS) -lpython$(PYTHON_VERSION)" \
  45. _PYTHON_HOST_PLATFORM=linux2 \
  46. __PYVENV_LAUNCHER__="/usr/bin/$(PYTHON)" \
  47. $(3) \
  48. , \
  49. ./setup.py $(2) \
  50. , \
  51. HOST \
  52. )
  53. endef