2 # Copyright (C) 2006-2015 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
9 PYTHON_VERSION_MICRO
:=10
11 PYTHON_DIR
:=$(STAGING_DIR
)/usr
12 PYTHON_BIN_DIR
:=$(PYTHON_DIR
)/bin
13 PYTHON_INC_DIR
:=$(PYTHON_DIR
)/include/python
$(PYTHON_VERSION
)
14 PYTHON_LIB_DIR
:=$(PYTHON_DIR
)/lib
/python
$(PYTHON_VERSION
)
16 PYTHON_PKG_DIR
:=/usr
/lib
/python
$(PYTHON_VERSION
)/site-packages
18 PYTHON
:=python
$(PYTHON_VERSION
)
20 HOST_PYTHON_LIB_DIR
:=$(STAGING_DIR_HOST
)/lib
/python
$(PYTHON_VERSION
)
21 HOST_PYTHON_BIN
:=$(STAGING_DIR_HOST
)/bin
/python2
23 PYTHONPATH
:=$(PYTHON_LIB_DIR
):$(STAGING_DIR
)/$(PYTHON_PKG_DIR
):$(PKG_INSTALL_DIR
)/$(PYTHON_PKG_DIR
)
25 ( export PYTHONPATH
="$(PYTHONPATH)"; \
26 export PYTHONOPTIMIZE
=""; \
27 export PYTHONDONTWRITEBYTECODE
=1; \
28 export _python_sysroot
="$(STAGING_DIR)"; \
29 export _python_prefix
="/usr"; \
30 export _python_exec_prefix
="/usr"; \
32 $(HOST_PYTHON_BIN
) $(2); \
36 # These configure args are needed in detection of path to Python header files
39 _python_sysroot
="$(STAGING_DIR)" \
40 _python_prefix
="/usr" \
41 _python_exec_prefix
="/usr"
44 # This is required in addition to PKG_USE_MIPS16:=0 because otherwise MIPS16
45 # flags are inherited from the Python base package (via sysconfig module)
46 ifdef CONFIG_USE_MIPS16
47 TARGET_CFLAGS
+= -mno-mips16
-mno-interlink-mips16
52 # Add default PyPackage filespec none defined
53 ifndef PyPackage
/$(1)/filespec
54 define PyPackage
/$(1)/filespec
59 $(call shexport
,PyPackage
/$(1)/filespec
)
61 define Package
/$(1)/install
62 find
$(PKG_INSTALL_DIR
) -name
"*\.pyc" -o
-name
"*\.pyo" | xargs
rm -f
63 @echo
"$$$$$$$$$$(call shvar,PyPackage/$(1)/filespec)" |
( \
65 while read fop fspec fperm
; do \
66 fop
=`echo "$$$$$$$$fop" | tr -d ' \t\n'`; \
67 if
[ "$$$$$$$$fop" = "+" ]; then \
68 if
[ ! -e
"$(PKG_INSTALL_DIR)$$$$$$$$fspec" ]; then \
69 echo
"File not found '$(PKG_INSTALL_DIR)$$$$$$$$fspec'"; \
72 dpath
=`dirname "$$$$$$$$fspec"`; \
73 if
[ -n
"$$$$$$$$fperm" ]; then \
74 dperm
="-m$$$$$$$$fperm"; \
76 dperm
=`stat -c "%a" $(PKG_INSTALL_DIR)$$$$$$$$dpath`; \
78 mkdir
-p
$$$$$$$$$dperm $$(1)$$$$$$$$dpath; \
79 echo
"copying: '$$$$$$$$fspec'"; \
80 cp
-fpR
$(PKG_INSTALL_DIR
)$$$$$$$$fspec $$(1)$$$$$$$$dpath/; \
81 if
[ -n
"$$$$$$$$fperm" ]; then \
82 chmod
-R
$$$$$$$$fperm $$(1)$$$$$$$$fspec; \
84 elif
[ "$$$$$$$$fop" = "-" ]; then \
85 echo
"removing: '$$$$$$$$fspec'"; \
86 rm -fR
$$(1)$$$$$$$$fspec; \
87 elif
[ "$$$$$$$$fop" = "=" ]; then \
88 echo
"setting permissions: '$$$$$$$$fperm' on '$$$$$$$$fspec'"; \
89 chmod
-R
$$$$$$$$fperm $$(1)$$$$$$$$fspec; \
93 $(call PyPackage
/$(1)/install,$$(1))
97 # $(1) => build subdir
98 # $(2) => additional arguments to setup.py
99 # $(3) => additional variables
100 define Build
/Compile
/PyMod
101 $(INSTALL_DIR
) $(PKG_INSTALL_DIR
)/$(PYTHON_PKG_DIR
)
103 cd
$(PKG_BUILD_DIR
)/$(strip $(1)); \
105 CCSHARED
="$(TARGET_CC) $(FPIC)" \
106 CXX
="$(TARGET_CXX)" \
108 LDSHARED
="$(TARGET_CC) -shared" \
109 CFLAGS
="$(TARGET_CFLAGS)" \
110 CPPFLAGS
="$(TARGET_CPPFLAGS) -I$(PYTHON_INC_DIR)" \
111 LDFLAGS
="$(TARGET_LDFLAGS) -lpython$(PYTHON_VERSION)" \
112 _PYTHON_HOST_PLATFORM
=linux2 \
113 __PYVENV_LAUNCHER__
="/usr/bin/$(PYTHON)" \
118 find
$(PKG_INSTALL_DIR
) -name
"*\.pyc" -o
-name
"*\.pyo" | xargs
rm -f