ed0ef4159916c2870e4a9e2f2883efb5bbfd6947
[feed/packages.git] / lang / python / files / python-host.mk
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
8 HOST_PYTHON_INC_DIR:=$(STAGING_DIR_HOST)/include/python$(PYTHON_VERSION)
9
10 HOST_PYTHON_PKG_DIR:=/lib/python$(PYTHON_VERSION)/site-packages
11
12 HOST_PYTHONPATH:=$(HOST_PYTHON_LIB_DIR):$(STAGING_DIR_HOST)/$(HOST_PYTHON_PKG_DIR)
13 define HostHostPython
14 ( export PYTHONPATH="$(HOST_PYTHONPATH)"; \
15 export PYTHONOPTIMIZE=""; \
16 export PYTHONDONTWRITEBYTECODE=1; \
17 export _python_sysroot="$(STAGING_DIR_HOST)"; \
18 export _python_prefix=""; \
19 export _python_exec_prefix=""; \
20 $(1) \
21 $(HOST_PYTHON_BIN) $(2); \
22 )
23 endef
24
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="" \
30 _python_exec_prefix=""
31
32 # $(1) => build subdir
33 # $(2) => additional arguments to setup.py
34 # $(3) => additional variables
35 define Build/Compile/HostPyMod
36 $(call HostHostPython, \
37 cd $(HOST_BUILD_DIR)/$(strip $(1)); \
38 CC="$(HOSTCC)" \
39 CCSHARED="$(HOSTCC) $(HOST_FPIC)" \
40 CXX="$(HOSTCXX)" \
41 LD="$(HOSTCC)" \
42 LDSHARED="$(HOSTCC) -shared" \
43 CFLAGS="$(HOST_CFLAGS)" \
44 CPPFLAGS="$(HOST_CPPFLAGS) -I$(HOST_PYTHON_INC_DIR)" \
45 LDFLAGS="$(HOST_LDFLAGS) -lpython$(PYTHON_VERSION)" \
46 _PYTHON_HOST_PLATFORM=linux2 \
47 __PYVENV_LAUNCHER__="/usr/bin/$(PYTHON)" \
48 $(3) \
49 , \
50 ./setup.py $(2) \
51 )
52 endef
53