2 # Copyright (C) 2015-2016 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
8 ifneq ($(__python_host_mk_inc
),1)
12 $(call include_mk
, python-version.mk
)
14 HOST_PYTHON_DIR
:=$(STAGING_DIR_HOSTPKG
)
15 HOST_PYTHON_INC_DIR
:=$(HOST_PYTHON_DIR
)/include/python
$(PYTHON_VERSION
)
16 HOST_PYTHON_LIB_DIR
:=$(HOST_PYTHON_DIR
)/lib
/python
$(PYTHON_VERSION
)
18 HOST_PYTHON_PKG_DIR
:=$(HOST_PYTHON_DIR
)/lib
/python
$(PYTHON_VERSION
)/site-packages
20 HOST_PYTHON_BIN
:=$(HOST_PYTHON_DIR
)/bin
/python
$(PYTHON_VERSION
)
22 HOST_PYTHONPATH
:=$(HOST_PYTHON_LIB_DIR
):$(HOST_PYTHON_PKG_DIR
)
25 if
[ "$(strip $(3))" == "HOST" ]; then \
26 export PYTHONPATH
="$(HOST_PYTHONPATH)"; \
27 export PYTHONDONTWRITEBYTECODE
=0; \
29 export PYTHONPATH
="$(PYTHONPATH)"; \
30 export PYTHONDONTWRITEBYTECODE
=1; \
31 export _python_sysroot
="$(STAGING_DIR)"; \
32 export _python_prefix
="/usr"; \
33 export _python_exec_prefix
="/usr"; \
35 export PYTHONOPTIMIZE
=""; \
37 $(HOST_PYTHON_BIN
) $(2);
40 # $(1) => commands to execute before running pythons script
41 # $(2) => python script and its arguments
42 # $(3) => additional variables
43 define Build
/Compile
/HostPyRunHost
47 CCSHARED
="$(HOSTCC) $(HOST_FPIC)" \
50 LDSHARED
="$(HOSTCC) -shared" \
51 CFLAGS
="$(HOST_CFLAGS)" \
52 CPPFLAGS
="$(HOST_CPPFLAGS) -I$(HOST_PYTHON_INC_DIR)" \
53 LDFLAGS
="$(HOST_LDFLAGS) -lpython$(PYTHON_VERSION) -Wl$(comma)-rpath=$(STAGING_DIR_HOSTPKG)/lib" \
54 _PYTHON_HOST_PLATFORM
=linux2 \
64 # $(1) => build subdir
65 # $(2) => additional arguments to setup.py
66 # $(3) => additional variables
67 define Build
/Compile
/HostPyMod
68 $(call Build
/Compile
/HostPyRunHost
, \
69 cd
$(HOST_BUILD_DIR
)/$(strip $(1)), \
74 define HostPy
/Compile
/Default
75 $(call Build
/Compile
/HostPyMod
,,\
76 install --root
="$(STAGING_DIR_HOSTPKG)" --prefix="" \
77 --single-version-externally-managed \
81 endif # __python_host_mk_inc