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
:=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 HOST_PYTHON_LIB_DIR
:=$(STAGING_DIR_HOST
)/usr
/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 # These configure args are needed in detection of path to Python header files
28 _python_sysroot
="$(STAGING_DIR)" \
29 _python_prefix
="/usr" \
30 _python_exec_prefix
="/usr"
33 # This is required in addition to PKG_USE_MIPS16:=0 because otherwise MIPS16
34 # flags are inherited from the Python base package (via sysconfig module)
35 ifdef CONFIG_USE_MIPS16
36 TARGET_CFLAGS
+= -mno-mips16
-mno-interlink-mips16
41 # Add default PyPackage filespec none defined
42 ifndef PyPackage
/$(1)/filespec
43 define PyPackage
/$(1)/filespec
48 $(call shexport
,PyPackage
/$(1)/filespec
)
50 define Package
/$(1)/install
51 find
$(PKG_INSTALL_DIR
) -name
"*\.pyc" -o
-name
"*\.pyo" | xargs
rm -f
52 @echo
"$$$$$$$$$$(call shvar,PyPackage/$(1)/filespec)" |
( \
54 while read fop fspec fperm
; do \
55 fop
=`echo "$$$$$$$$fop" | tr -d ' \t\n'`; \
56 if
[ "$$$$$$$$fop" = "+" ]; then \
57 if
[ ! -e
"$(PKG_INSTALL_DIR)$$$$$$$$fspec" ]; then \
58 echo
"File not found '$(PKG_INSTALL_DIR)$$$$$$$$fspec'"; \
61 dpath
=`dirname "$$$$$$$$fspec"`; \
62 if
[ -n
"$$$$$$$$fperm" ]; then \
63 dperm
="-m$$$$$$$$fperm"; \
65 dperm
=`stat -c "%a" $(PKG_INSTALL_DIR)$$$$$$$$dpath`; \
67 mkdir
-p
$$$$$$$$$dperm $$(1)$$$$$$$$dpath; \
68 echo
"copying: '$$$$$$$$fspec'"; \
69 cp
-fpR
$(PKG_INSTALL_DIR
)$$$$$$$$fspec $$(1)$$$$$$$$dpath/; \
70 if
[ -n
"$$$$$$$$fperm" ]; then \
71 chmod
-R
$$$$$$$$fperm $$(1)$$$$$$$$fspec; \
73 elif
[ "$$$$$$$$fop" = "-" ]; then \
74 echo
"removing: '$$$$$$$$fspec'"; \
75 rm -fR
$$(1)$$$$$$$$fspec; \
76 elif
[ "$$$$$$$$fop" = "=" ]; then \
77 echo
"setting permissions: '$$$$$$$$fperm' on '$$$$$$$$fspec'"; \
78 chmod
-R
$$$$$$$$fperm $$(1)$$$$$$$$fspec; \
82 $(call PyPackage
/$(1)/install,$$(1))
86 $(call include_mk
, python-host.mk
)
88 # $(1) => build subdir
89 # $(2) => additional arguments to setup.py
90 # $(3) => additional variables
91 define Build
/Compile
/PyMod
92 $(INSTALL_DIR
) $(PKG_INSTALL_DIR
)/$(PYTHON_PKG_DIR
)
94 cd
$(PKG_BUILD_DIR
)/$(strip $(1)); \
96 CCSHARED
="$(TARGET_CC) $(FPIC)" \
99 LDSHARED
="$(TARGET_CC) -shared" \
100 CFLAGS
="$(TARGET_CFLAGS)" \
101 CPPFLAGS
="$(TARGET_CPPFLAGS) -I$(PYTHON_INC_DIR)" \
102 LDFLAGS
="$(TARGET_LDFLAGS) -lpython$(PYTHON_VERSION)" \
103 _PYTHON_HOST_PLATFORM
=linux2 \
104 __PYVENV_LAUNCHER__
="/usr/bin/$(PYTHON)" \
109 find
$(PKG_INSTALL_DIR
) -name
"*\.pyc" -o
-name
"*\.pyo" | xargs
rm -f
114 $$(call Build
/Compile
/PyMod
,,install --prefix=/usr
--root
=$(PKG_INSTALL_DIR
))
117 define Package
/$(PKG_NAME
)/install
118 $(INSTALL_DIR
) $$(1)$(PYTHON_PKG_DIR
) $$(1)/usr
/bin
119 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
120 find
$(PKG_INSTALL_DIR
)$(PYTHON_PKG_DIR
) -mindepth
1 -maxdepth
1 \
( -type f
-o
-type d \
) -exec
$(CP
) \
{\
} $$(1)$(PYTHON_PKG_DIR
)/ \
;
123 define Build
/InstallDev
124 $(INSTALL_DIR
) $$(1)/usr
/bin
$$(1)$(PYTHON_PKG_DIR
)
125 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
126 find
$(PKG_INSTALL_DIR
)$(PYTHON_PKG_DIR
) -mindepth
1 -maxdepth
1 \
( -type f
-o
-type d \
) -exec
$(CP
) \
{\
} $$(1)$(PYTHON_PKG_DIR
)/ \
;