2 # Copyright (C) 2007-2016 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
8 # For HOST_BUILD_PREFIX
9 include $(INCLUDE_DIR
)/host-build.mk
11 PYTHON3_VERSION_MAJOR
:=3
12 PYTHON3_VERSION_MINOR
:=5
13 PYTHON3_VERSION_MICRO
:=2
15 PYTHON3_VERSION
:=$(PYTHON3_VERSION_MAJOR
).
$(PYTHON3_VERSION_MINOR
)
17 PYTHON3_DIR
:=$(STAGING_DIR
)/usr
18 PYTHON3_BIN_DIR
:=$(PYTHON3_DIR
)/bin
19 PYTHON3_INC_DIR
:=$(PYTHON3_DIR
)/include/python
$(PYTHON3_VERSION
)
20 PYTHON3_LIB_DIR
:=$(PYTHON3_DIR
)/lib
/python
$(PYTHON3_VERSION
)
22 PYTHON3_PKG_DIR
:=/usr
/lib
/python
$(PYTHON3_VERSION
)/site-packages
24 PYTHON3
:=python
$(PYTHON3_VERSION
)
26 HOST_PYTHON3_LIB_DIR
:=$(HOST_BUILD_PREFIX
)/lib
/python
$(PYTHON3_VERSION
)
27 HOST_PYTHON3_BIN
:=$(HOST_BUILD_PREFIX
)/bin
/python3
29 PYTHON3PATH
:=$(PYTHON3_LIB_DIR
):$(STAGING_DIR
)/$(PYTHON3_PKG_DIR
):$(PKG_INSTALL_DIR
)/$(PYTHON3_PKG_DIR
)
31 ( export PYTHONPATH
="$(PYTHON3PATH)"; \
32 export PYTHONOPTIMIZE
=""; \
33 export PYTHONDONTWRITEBYTECODE
=1; \
34 export _python_sysroot
="$(STAGING_DIR)"; \
35 export _python_prefix
="/usr"; \
36 export _python_exec_prefix
="/usr"; \
38 $(HOST_PYTHON3_BIN
) $(2); \
42 # These configure args are needed in detection of path to Python header files
45 _python_sysroot
="$(STAGING_DIR)" \
46 _python_prefix
="/usr" \
47 _python_exec_prefix
="/usr"
50 # This is required in addition to PKG_USE_MIPS16:=0 because otherwise MIPS16
51 # flags are inherited from the Python base package (via sysconfig module)
52 ifdef CONFIG_USE_MIPS16
53 TARGET_CFLAGS
+= -mno-mips16
-mno-interlink-mips16
58 # Add default PyPackage filespec none defined
59 ifndef Py3Package
/$(1)/filespec
60 define Py3Package
/$(1)/filespec
65 $(call shexport
,Py3Package
/$(1)/filespec
)
67 define Package
/$(1)/install
68 find
$(PKG_INSTALL_DIR
) -name
"*\.pyc" -o
-name
"*\.pyo" -o
-name
"*\.exe" | xargs
rm -f
69 @echo
"$$$$$$$$$$(call shvar,Py3Package/$(1)/filespec)" |
( \
71 while read fop fspec fperm
; do \
72 fop
=`echo "$$$$$$$$fop" | tr -d ' \t\n'`; \
73 if
[ "$$$$$$$$fop" = "+" ]; then \
74 if
[ ! -e
"$(PKG_INSTALL_DIR)$$$$$$$$fspec" ]; then \
75 echo
"File not found '$(PKG_INSTALL_DIR)$$$$$$$$fspec'"; \
78 dpath
=`dirname "$$$$$$$$fspec"`; \
79 if
[ -n
"$$$$$$$$fperm" ]; then \
80 dperm
="-m$$$$$$$$fperm"; \
82 dperm
=`stat -c "%a" $(PKG_INSTALL_DIR)$$$$$$$$dpath`; \
84 mkdir
-p
$$$$$$$$$dperm $$(1)$$$$$$$$dpath; \
85 echo
"copying: '$$$$$$$$fspec'"; \
86 cp
-fpR
$(PKG_INSTALL_DIR
)$$$$$$$$fspec $$(1)$$$$$$$$dpath/; \
87 if
[ -n
"$$$$$$$$fperm" ]; then \
88 chmod
-R
$$$$$$$$fperm $$(1)$$$$$$$$fspec; \
90 elif
[ "$$$$$$$$fop" = "-" ]; then \
91 echo
"removing: '$$$$$$$$fspec'"; \
92 rm -fR
$$(1)$$$$$$$$fspec; \
93 elif
[ "$$$$$$$$fop" = "=" ]; then \
94 echo
"setting permissions: '$$$$$$$$fperm' on '$$$$$$$$fspec'"; \
95 chmod
-R
$$$$$$$$fperm $$(1)$$$$$$$$fspec; \
99 $(call Py3Package
/$(1)/install,$$(1))
103 # $(1) => build subdir
104 # $(2) => additional arguments to setup.py
105 # $(3) => additional variables
106 define Build
/Compile
/Py3Mod
107 $(INSTALL_DIR
) $(PKG_INSTALL_DIR
)/$(PYTHON3_PKG_DIR
)
108 $(call HostPython3
, \
109 cd
$(PKG_BUILD_DIR
)/$(strip $(1)); \
111 CCSHARED
="$(TARGET_CC) $(FPIC)" \
113 LDSHARED
="$(TARGET_CC) -shared" \
114 CFLAGS
="$(TARGET_CFLAGS)" \
115 CPPFLAGS
="$(TARGET_CPPFLAGS) -I$(PYTHON3_INC_DIR)" \
116 LDFLAGS
="$(TARGET_LDFLAGS) -lpython$(PYTHON3_VERSION)" \
117 _PYTHON_HOST_PLATFORM
=linux2 \
118 __PYVENV_LAUNCHER__
="/usr/bin/$(PYTHON3)" \
123 find
$(PKG_INSTALL_DIR
) -name
"*\.pyc" -o
-name
"*\.pyo" -o
-name
"*\.exe" | xargs
rm -f