2 # Copyright (C) 2006-2016 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
:=11
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 PYTHONPATH
:=$(PYTHON_LIB_DIR
):$(STAGING_DIR
)/$(PYTHON_PKG_DIR
):$(PKG_INSTALL_DIR
)/$(PYTHON_PKG_DIR
)
22 # These configure args are needed in detection of path to Python header files
25 _python_sysroot
="$(STAGING_DIR)" \
26 _python_prefix
="/usr" \
27 _python_exec_prefix
="/usr"
30 # This is required in addition to PKG_USE_MIPS16:=0 because otherwise MIPS16
31 # flags are inherited from the Python base package (via sysconfig module)
32 ifdef CONFIG_USE_MIPS16
33 TARGET_CFLAGS
+= -mno-mips16
-mno-interlink-mips16
38 # Add default PyPackage filespec none defined
39 ifndef PyPackage
/$(1)/filespec
40 define PyPackage
/$(1)/filespec
45 $(call shexport
,PyPackage
/$(1)/filespec
)
47 define Package
/$(1)/install
48 find
$(PKG_INSTALL_DIR
) -name
"*\.pyc" -o
-name
"*\.pyo" | xargs
rm -f
49 @echo
"$$$$$$$$$$(call shvar,PyPackage/$(1)/filespec)" |
( \
51 while read fop fspec fperm
; do \
52 fop
=`echo "$$$$$$$$fop" | tr -d ' \t\n'`; \
53 if
[ "$$$$$$$$fop" = "+" ]; then \
54 if
[ ! -e
"$(PKG_INSTALL_DIR)$$$$$$$$fspec" ]; then \
55 echo
"File not found '$(PKG_INSTALL_DIR)$$$$$$$$fspec'"; \
58 dpath
=`dirname "$$$$$$$$fspec"`; \
59 if
[ -n
"$$$$$$$$fperm" ]; then \
60 dperm
="-m$$$$$$$$fperm"; \
62 dperm
=`stat -c "%a" $(PKG_INSTALL_DIR)$$$$$$$$dpath`; \
64 mkdir
-p
$$$$$$$$$dperm $$(1)$$$$$$$$dpath; \
65 echo
"copying: '$$$$$$$$fspec'"; \
66 cp
-fpR
$(PKG_INSTALL_DIR
)$$$$$$$$fspec $$(1)$$$$$$$$dpath/; \
67 if
[ -n
"$$$$$$$$fperm" ]; then \
68 chmod
-R
$$$$$$$$fperm $$(1)$$$$$$$$fspec; \
70 elif
[ "$$$$$$$$fop" = "-" ]; then \
71 echo
"removing: '$$$$$$$$fspec'"; \
72 rm -fR
$$(1)$$$$$$$$fspec; \
73 elif
[ "$$$$$$$$fop" = "=" ]; then \
74 echo
"setting permissions: '$$$$$$$$fperm' on '$$$$$$$$fspec'"; \
75 chmod
-R
$$$$$$$$fperm $$(1)$$$$$$$$fspec; \
79 $(call PyPackage
/$(1)/install,$$(1))
83 $(call include_mk
, python-host.mk
)
85 # $(1) => build subdir
86 # $(2) => additional arguments to setup.py
87 # $(3) => additional variables
88 define Build
/Compile
/PyMod
89 $(INSTALL_DIR
) $(PKG_INSTALL_DIR
)/$(PYTHON_PKG_DIR
)
91 cd
$(PKG_BUILD_DIR
)/$(strip $(1)); \
93 CCSHARED
="$(TARGET_CC) $(FPIC)" \
96 LDSHARED
="$(TARGET_CC) -shared" \
97 CFLAGS
="$(TARGET_CFLAGS)" \
98 CPPFLAGS
="$(TARGET_CPPFLAGS) -I$(PYTHON_INC_DIR)" \
99 LDFLAGS
="$(TARGET_LDFLAGS) -lpython$(PYTHON_VERSION)" \
100 _PYTHON_HOST_PLATFORM
=linux2 \
101 __PYVENV_LAUNCHER__
="/usr/bin/$(PYTHON)" \
106 find
$(PKG_INSTALL_DIR
) -name
"*\.pyc" -o
-name
"*\.pyo" | xargs
rm -f
111 $$(call Build
/Compile
/PyMod
,,install --prefix=/usr
--root
=$(PKG_INSTALL_DIR
))
114 define Package
/$(PKG_NAME
)/install
115 $(INSTALL_DIR
) $$(1)$(PYTHON_PKG_DIR
) $$(1)/usr
/bin
116 if
[ -d
$(PKG_INSTALL_DIR
)/usr
/bin
]; then find
$(PKG_INSTALL_DIR
)/usr
/bin
-mindepth
1 -maxdepth
1 -type f
-exec
$(CP
) \
{\
} $$(1)/usr
/bin
/ \
; ; fi
117 find
$(PKG_INSTALL_DIR
)$(PYTHON_PKG_DIR
) -mindepth
1 -maxdepth
1 \
( -type f
-o
-type d \
) -exec
$(CP
) \
{\
} $$(1)$(PYTHON_PKG_DIR
)/ \
;
120 define Build
/InstallDev
121 $(INSTALL_DIR
) $$(1)/usr
/bin
$$(1)$(PYTHON_PKG_DIR
)
122 if
[ -d
$(PKG_INSTALL_DIR
)/usr
/bin
]; then find
$(PKG_INSTALL_DIR
)/usr
/bin
-mindepth
1 -maxdepth
1 -type f
-exec
$(CP
) \
{\
} $$(1)/usr
/bin
/ \
; ; fi
123 find
$(PKG_INSTALL_DIR
)$(PYTHON_PKG_DIR
) -mindepth
1 -maxdepth
1 \
( -type f
-o
-type d \
) -exec
$(CP
) \
{\
} $$(1)$(PYTHON_PKG_DIR
)/ \
;