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 # Compatibility fallback for older OpenWrt and LEDE versions
15 ifeq ($(STAGING_DIR_HOSTPKG
),)
16 $(warning STAGING_DIR_HOSTPKG is unset
- falling back to
$$(STAGING_DIR
)/host
)
17 STAGING_DIR_HOSTPKG
:= $(STAGING_DIR
)/host
20 HOST_PYTHON3_DIR
:=$(STAGING_DIR_HOSTPKG
)
21 HOST_PYTHON3_INC_DIR
:=$(HOST_PYTHON3_DIR
)/include/python
$(PYTHON3_VERSION
)
22 HOST_PYTHON3_LIB_DIR
:=$(HOST_PYTHON3_DIR
)/lib
/python
$(PYTHON3_VERSION
)
24 HOST_PYTHON3_PKG_DIR
:=$(HOST_PYTHON3_DIR
)/lib
/python
$(PYTHON3_VERSION
)/site-packages
26 HOST_PYTHON3_BIN
:=$(HOST_PYTHON3_DIR
)/bin
/python
$(PYTHON3_VERSION
)
28 HOST_PYTHON3PATH
:=$(HOST_PYTHON3_LIB_DIR
):$(HOST_PYTHON3_PKG_DIR
)
31 if
[ "$(strip $(3))" == "HOST" ]; then \
32 export PYTHONPATH
="$(HOST_PYTHON3PATH)"; \
33 export PYTHONDONTWRITEBYTECODE
=0; \
35 export PYTHONPATH
="$(PYTHON3PATH)"; \
36 export PYTHONDONTWRITEBYTECODE
=1; \
37 export _python_sysroot
="$(STAGING_DIR)"; \
38 export _python_prefix
="/usr"; \
39 export _python_exec_prefix
="/usr"; \
41 export PYTHONOPTIMIZE
=""; \
43 $(HOST_PYTHON3_BIN
) $(2);
46 # $(1) => commands to execute before running pythons script
47 # $(2) => python script and its arguments
48 # $(3) => additional variables
49 define Build
/Compile
/HostPy3RunHost
53 CCSHARED
="$(HOSTCC) $(HOST_FPIC)" \
56 LDSHARED
="$(HOSTCC) -shared" \
57 CFLAGS
="$(HOST_CFLAGS)" \
58 CPPFLAGS
="$(HOST_CPPFLAGS) -I$(HOST_PYTHON3_INC_DIR)" \
59 LDFLAGS
="$(HOST_LDFLAGS) -lpython$(PYTHON3_VERSION) -Wl$(comma)-rpath=$(STAGING_DIR_HOSTPKG)/lib" \
60 _PYTHON_HOST_PLATFORM
=linux2 \
70 # $(1) => build subdir
71 # $(2) => additional arguments to setup.py
72 # $(3) => additional variables
73 define Build
/Compile
/HostPy3Mod
74 $(call Build
/Compile
/HostPy3RunHost
, \
75 cd
$(HOST_BUILD_DIR
)/$(strip $(1)), \
80 define HostPy3
/Compile
/Default
81 $(call Build
/Compile
/HostPy3Mod
,,\
82 install --root
="$(HOST_BUILD_PREFIX)" --prefix="" \
83 --single-version-externally-managed \
87 ifeq ($(BUILD_VARIANT
),python3
)
89 $(call HostPy3
/Compile
/Default
)
96 endif # __python3_host_mk_inc