2 # Copyright (C) 2007-2015 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
8 PYTHON3_VERSION_MAJOR
:=3
9 PYTHON3_VERSION_MINOR
:=5
10 PYTHON3_VERSION_MICRO
:=0
12 PYTHON3_VERSION
:=$(PYTHON3_VERSION_MAJOR
).
$(PYTHON3_VERSION_MINOR
)
14 PYTHON3_DIR
:=$(STAGING_DIR
)/usr
15 PYTHON3_BIN_DIR
:=$(PYTHON3_DIR
)/bin
16 PYTHON3_INC_DIR
:=$(PYTHON3_DIR
)/include/python
$(PYTHON3_VERSION
)
17 PYTHON3_LIB_DIR
:=$(PYTHON3_DIR
)/lib
/python
$(PYTHON3_VERSION
)
19 PYTHON3_PKG_DIR
:=/usr
/lib
/python
$(PYTHON3_VERSION
)/site-packages
21 PYTHON3
:=python
$(PYTHON3_VERSION
)
23 HOST_PYTHON3_LIB_DIR
:=$(STAGING_DIR
)/host
/lib
/python
$(PYTHON3_VERSION
)
24 HOST_PYTHON3_BIN
:=$(STAGING_DIR
)/host
/bin
/python3
26 PYTHON3PATH
:=$(PYTHON3_LIB_DIR
):$(STAGING_DIR
)/$(PYTHON3_PKG_DIR
):$(PKG_INSTALL_DIR
)/$(PYTHON3_PKG_DIR
)
28 ( export PYTHONPATH
="$(PYTHON3PATH)"; \
29 export PYTHONOPTIMIZE
=""; \
30 export PYTHONDONTWRITEBYTECODE
=1; \
31 export _python_sysroot
="$(STAGING_DIR)"; \
32 export _python_prefix
="/usr"; \
33 export _python_exec_prefix
="/usr"; \
35 $(HOST_PYTHON3_BIN
) $(2); \
39 # These configure args are needed in detection of path to Python header files
42 _python_sysroot
="$(STAGING_DIR)" \
43 _python_prefix
="/usr" \
44 _python_exec_prefix
="/usr"
47 # This is required in addition to PKG_USE_MIPS16:=0 because otherwise MIPS16
48 # flags are inherited from the Python base package (via sysconfig module)
49 ifdef CONFIG_USE_MIPS16
50 TARGET_CFLAGS
+= -mno-mips16
-mno-interlink-mips16
55 # Add default PyPackage filespec none defined
56 ifndef Py3Package
/$(1)/filespec
57 define Py3Package
/$(1)/filespec
62 $(call shexport
,Py3Package
/$(1)/filespec
)
64 define Package
/$(1)/install
65 find
$(PKG_INSTALL_DIR
) -name
"*\.pyc" -o
-name
"*\.pyo" | xargs
rm -f
66 @echo
"$$$$$$$$$$(call shvar,Py3Package/$(1)/filespec)" |
( \
68 while read fop fspec fperm
; do \
69 fop
=`echo "$$$$$$$$fop" | tr -d ' \t\n'`; \
70 if
[ "$$$$$$$$fop" = "+" ]; then \
71 if
[ ! -e
"$(PKG_INSTALL_DIR)$$$$$$$$fspec" ]; then \
72 echo
"File not found '$(PKG_INSTALL_DIR)$$$$$$$$fspec'"; \
75 dpath
=`dirname "$$$$$$$$fspec"`; \
76 if
[ -n
"$$$$$$$$fperm" ]; then \
77 dperm
="-m$$$$$$$$fperm"; \
79 dperm
=`stat -c "%a" $(PKG_INSTALL_DIR)$$$$$$$$dpath`; \
81 mkdir
-p
$$$$$$$$$dperm $$(1)$$$$$$$$dpath; \
82 echo
"copying: '$$$$$$$$fspec'"; \
83 cp
-fpR
$(PKG_INSTALL_DIR
)$$$$$$$$fspec $$(1)$$$$$$$$dpath/; \
84 if
[ -n
"$$$$$$$$fperm" ]; then \
85 chmod
-R
$$$$$$$$fperm $$(1)$$$$$$$$fspec; \
87 elif
[ "$$$$$$$$fop" = "-" ]; then \
88 echo
"removing: '$$$$$$$$fspec'"; \
89 rm -fR
$$(1)$$$$$$$$fspec; \
90 elif
[ "$$$$$$$$fop" = "=" ]; then \
91 echo
"setting permissions: '$$$$$$$$fperm' on '$$$$$$$$fspec'"; \
92 chmod
-R
$$$$$$$$fperm $$(1)$$$$$$$$fspec; \
96 $(call Py3Package
/$(1)/install,$$(1))
100 # $(1) => build subdir
101 # $(2) => additional arguments to setup.py
102 # $(3) => additional variables
103 define Build
/Compile
/Py3Mod
104 $(INSTALL_DIR
) $(PKG_INSTALL_DIR
)/$(PYTHON3_PKG_DIR
)
105 $(call HostPython3
, \
106 cd
$(PKG_BUILD_DIR
)/$(strip $(1)); \
108 CCSHARED
="$(TARGET_CC) $(FPIC)" \
110 LDSHARED
="$(TARGET_CC) -shared" \
111 CFLAGS
="$(TARGET_CFLAGS)" \
112 CPPFLAGS
="$(TARGET_CPPFLAGS) -I$(PYTHON3_INC_DIR)" \
113 LDFLAGS
="$(TARGET_LDFLAGS) -lpython$(PYTHON3_VERSION)" \
114 _PYTHON_HOST_PLATFORM
=linux2 \
115 __PYVENV_LAUNCHER__
="/usr/bin/$(PYTHON3)" \
120 find
$(PKG_INSTALL_DIR
) -name
"*\.pyc" -o
-name
"*\.pyo" | xargs
rm -f