2 # Copyright (C) 2017 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
8 ifneq ($(__python3_host_mk_inc
),1)
9 __python3_host_mk_inc
=1
12 $(call include_mk
, python3-version.mk
)
14 HOST_PYTHON3_DIR
:=$(STAGING_DIR_HOSTPKG
)
15 HOST_PYTHON3_INC_DIR
:=$(HOST_PYTHON3_DIR
)/include/python
$(PYTHON3_VERSION
)
16 HOST_PYTHON3_LIB_DIR
:=$(HOST_PYTHON3_DIR
)/lib
/python
$(PYTHON3_VERSION
)
18 HOST_PYTHON3_PKG_DIR
:=$(HOST_PYTHON3_DIR
)/lib
/python
$(PYTHON3_VERSION
)/site-packages
20 HOST_PYTHON3_BIN
:=$(HOST_PYTHON3_DIR
)/bin
/python
$(PYTHON3_VERSION
)
22 HOST_PYTHON3PATH
:=$(HOST_PYTHON3_LIB_DIR
):$(HOST_PYTHON3_PKG_DIR
)
25 if
[ "$(strip $(3))" == "HOST" ]; then \
26 export PYTHONPATH
="$(HOST_PYTHON3PATH)"; \
27 export PYTHONDONTWRITEBYTECODE
=0; \
29 export PYTHONPATH
="$(PYTHON3PATH)"; \
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_PYTHON3_BIN
) $(2);
40 define host_python3_settings
43 CCSHARED
="$(HOSTCC) $(HOST_FPIC)" \
46 LDSHARED
="$(HOSTCC) -shared" \
47 CFLAGS
="$(HOST_CFLAGS)" \
48 CPPFLAGS
="$(HOST_CPPFLAGS) -I$(HOST_PYTHON3_INC_DIR)" \
49 LDFLAGS
="$(HOST_LDFLAGS) -lpython$(PYTHON3_VERSION) -Wl$(comma)-rpath=$(STAGING_DIR_HOSTPKG)/lib" \
50 _PYTHON_HOST_PLATFORM
=linux2
53 # $(1) => commands to execute before running pythons script
54 # $(2) => python script and its arguments
55 # $(3) => additional variables
56 define Build
/Compile
/HostPy3RunHost
59 $(call host_python3_settings
) \
68 # Note: I shamelessly copied this from Yousong's logic (from python-packages);
69 HOST_PYTHON3_PIP
:=$(STAGING_DIR_HOSTPKG
)/bin
/pip
$(PYTHON3_VERSION
)
70 define host_python3_pip_install
71 $(call host_python3_settings
) \
72 $(HOST_PYTHON3_PIP
) install \
79 define host_python3_pip_install_host
80 $(call host_python3_pip_install
,$(STAGING_DIR_HOSTPKG
),"",$(1))
83 # $(1) => build subdir
84 # $(2) => additional arguments to setup.py
85 # $(3) => additional variables
86 define Build
/Compile
/HostPy3Mod
87 $(call Build
/Compile
/HostPy3RunHost
, \
88 cd
$(HOST_BUILD_DIR
)/$(strip $(1)), \
93 endif # __python3_host_mk_inc