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)
11 # Compatibility fallback for older OpenWrt and LEDE versions
12 ifeq ($(STAGING_DIR_HOSTPKG
),)
13 $(warning STAGING_DIR_HOSTPKG is unset
- falling back to
$$(STAGING_DIR
)/host
)
14 STAGING_DIR_HOSTPKG
:= $(STAGING_DIR
)/host
17 HOST_PYTHON_DIR
:=$(STAGING_DIR_HOSTPKG
)
18 HOST_PYTHON_INC_DIR
:=$(HOST_PYTHON_DIR
)/include/python
$(PYTHON_VERSION
)
19 HOST_PYTHON_LIB_DIR
:=$(HOST_PYTHON_DIR
)/lib
/python
$(PYTHON_VERSION
)
21 HOST_PYTHON_PKG_DIR
:=/lib
/python
$(PYTHON_VERSION
)/site-packages
23 HOST_PYTHON_BIN
:=$(HOST_PYTHON_DIR
)/bin
/python
$(PYTHON_VERSION
)
25 HOST_PYTHONPATH
:=$(HOST_PYTHON_LIB_DIR
):$(STAGING_DIR_HOSTPKG
)/$(HOST_PYTHON_PKG_DIR
)
28 if
[ "$(strip $(3))" == "HOST" ]; then \
29 export PYTHONPATH
="$(HOST_PYTHONPATH)"; \
30 export PYTHONDONTWRITEBYTECODE
=0; \
32 export PYTHONPATH
="$(PYTHONPATH)"; \
33 export PYTHONDONTWRITEBYTECODE
=1; \
34 export _python_sysroot
="$(STAGING_DIR)"; \
35 export _python_prefix
="/usr"; \
36 export _python_exec_prefix
="/usr"; \
38 export PYTHONOPTIMIZE
=""; \
40 $(HOST_PYTHON_BIN
) $(2);
43 # $(1) => commands to execute before running pythons script
44 # $(2) => python script and its arguments
45 # $(3) => additional variables
46 define Build
/Compile
/HostPyRunHost
50 CCSHARED
="$(HOSTCC) $(HOST_FPIC)" \
53 LDSHARED
="$(HOSTCC) -shared" \
54 CFLAGS
="$(HOST_CFLAGS)" \
55 CPPFLAGS
="$(HOST_CPPFLAGS) -I$(HOST_PYTHON_INC_DIR)" \
56 LDFLAGS
="$(HOST_LDFLAGS) -lpython$(PYTHON_VERSION) -Wl$(comma)-rpath=$(STAGING_DIR_HOSTPKG)/lib" \
57 _PYTHON_HOST_PLATFORM
=linux2 \
67 # $(1) => build subdir
68 # $(2) => additional arguments to setup.py
69 # $(3) => additional variables
70 define Build
/Compile
/HostPyMod
71 $(call Build
/Compile
/HostPyRunHost
, \
72 cd
$(HOST_BUILD_DIR
)/$(strip $(1)), \
77 endif # __python_host_mk_inc