python: unify HostPython and HostHostPython functions
[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:=/usr/lib/python$(PYTHON_VERSION)/site-packages
11
12 HOST_PYTHONPATH:=$(HOST_PYTHON_LIB_DIR):$(STAGING_DIR_HOST)/$(HOST_PYTHON_PKG_DIR)
13 define HostPython
14 ifeq ($(3),)
15 $(3):=$(PYTHONPATH)
16 endif
17 ( export PYTHONPATH="$(3)"; \
18 export PYTHONOPTIMIZE=""; \
19 export PYTHONDONTWRITEBYTECODE=1; \
20 export _python_sysroot="$(STAGING_DIR_HOST)"; \
21 export _python_prefix=""; \
22 export _python_exec_prefix=""; \
23 $(1) \
24 $(HOST_PYTHON_BIN) $(2); \
25 )
26 endef
27
28 # These configure args are needed in detection of path to Python header files
29 # using autotools.
30 HOST_CONFIGURE_ARGS += \
31 _python_sysroot="$(STAGING_DIR_HOST)/usr" \
32 _python_prefix="/usr" \
33 _python_exec_prefix="/usr"
34
35 # $(1) => build subdir
36 # $(2) => additional arguments to setup.py
37 # $(3) => additional variables
38 define Build/Compile/HostPyMod
39 $(call HostPython, \
40 cd $(HOST_BUILD_DIR)/$(strip $(1)); \
41 CC="$(HOSTCC)" \
42 CCSHARED="$(HOSTCC) $(HOST_FPIC)" \
43 CXX="$(HOSTCXX)" \
44 LD="$(HOSTCC)" \
45 LDSHARED="$(HOSTCC) -shared" \
46 CFLAGS="$(HOST_CFLAGS)" \
47 CPPFLAGS="$(HOST_CPPFLAGS) -I$(HOST_PYTHON_INC_DIR)" \
48 LDFLAGS="$(HOST_LDFLAGS) -lpython$(PYTHON_VERSION)" \
49 _PYTHON_HOST_PLATFORM=linux2 \
50 __PYVENV_LAUNCHER__="/usr/bin/$(PYTHON)" \
51 $(3) \
52 , \
53 ./setup.py $(2) \
54 , \
55 $(HOST_PYTHONPATH) \
56 )
57 endef
58