1 ################################################################################
5 ################################################################################
7 PYTHON3_VERSION_MAJOR
= 3.5
8 PYTHON3_VERSION
= $(PYTHON3_VERSION_MAJOR
).2
9 PYTHON3_SOURCE
= Python-
$(PYTHON3_VERSION
).
tar.xz
10 PYTHON3_SITE
= http
://python.org
/ftp
/python
/$(PYTHON3_VERSION
)
11 PYTHON3_LICENSE
= Python software foundation license v2
, others
12 PYTHON3_LICENSE_FILES
= LICENSE
14 # Python itself doesn't use libtool, but it includes the source code
15 # of libffi, which uses libtool. Unfortunately, it uses a beta version
16 # of libtool for which we don't have a matching patch. However, this
17 # is not a problem, because we don't use the libffi copy included in
18 # the Python sources, but instead use an external libffi library.
19 PYTHON3_LIBTOOL_PATCH
= NO
21 # Python needs itself and a "pgen" program to build itself, both being
22 # provided in the Python sources. So in order to cross-compile Python,
23 # we need to build a host Python first. This host Python is also
24 # installed in $(HOST_DIR), as it is needed when cross-compiling
25 # third-party Python modules.
27 HOST_PYTHON3_CONF_OPTS
+= \
34 --disable-codecs-cjk \
36 --enable-unicodedata \
37 --disable-test-modules \
39 --disable-ossaudiodev \
42 # Make sure that LD_LIBRARY_PATH overrides -rpath.
43 # This is needed because libpython may be installed at the same time that
45 # Make python believe we don't have 'hg', so that it doesn't try to
46 # communicate over the network during the build.
47 HOST_PYTHON3_CONF_ENV
+= \
48 LDFLAGS
="$(HOST_LDFLAGS) -Wl,--enable-new-dtags" \
49 ac_cv_prog_HAS_HG
=/bin
/false
51 PYTHON3_DEPENDENCIES
= host-python3 libffi
53 HOST_PYTHON3_DEPENDENCIES
= host-expat host-zlib
55 PYTHON3_INSTALL_STAGING
= YES
57 ifeq ($(BR2_PACKAGE_PYTHON3_READLINE
),y
)
58 PYTHON3_DEPENDENCIES
+= readline
61 ifeq ($(BR2_PACKAGE_PYTHON3_CURSES
),y
)
62 PYTHON3_DEPENDENCIES
+= ncurses
64 PYTHON3_CONF_OPTS
+= --disable-curses
67 ifeq ($(BR2_PACKAGE_PYTHON3_DECIMAL
),y
)
68 PYTHON3_DEPENDENCIES
+= mpdecimal
69 PYTHON3_CONF_OPTS
+= --with-libmpdec
=system
71 PYTHON3_CONF_OPTS
+= --with-libmpdec
=none
74 ifeq ($(BR2_PACKAGE_PYTHON3_PYEXPAT
),y
)
75 PYTHON3_DEPENDENCIES
+= expat
76 PYTHON3_CONF_OPTS
+= --with-expat
=system
78 PYTHON3_CONF_OPTS
+= --with-expat
=none
81 ifeq ($(BR2_PACKAGE_PYTHON3_PYC_ONLY
),y
)
82 PYTHON3_CONF_OPTS
+= --enable-old-stdlib-cache
85 ifeq ($(BR2_PACKAGE_PYTHON3_SQLITE
),y
)
86 PYTHON3_DEPENDENCIES
+= sqlite
88 PYTHON3_CONF_OPTS
+= --disable-sqlite3
91 ifeq ($(BR2_PACKAGE_PYTHON3_SSL
),y
)
92 PYTHON3_DEPENDENCIES
+= openssl
95 ifneq ($(BR2_PACKAGE_PYTHON3_CODECSCJK
),y
)
96 PYTHON3_CONF_OPTS
+= --disable-codecs-cjk
99 ifneq ($(BR2_PACKAGE_PYTHON3_UNICODEDATA
),y
)
100 PYTHON3_CONF_OPTS
+= --disable-unicodedata
103 ifeq ($(BR2_PACKAGE_PYTHON3_BZIP2
),y
)
104 PYTHON3_DEPENDENCIES
+= bzip2
107 ifeq ($(BR2_PACKAGE_PYTHON3_XZ
),y
)
108 PYTHON3_DEPENDENCIES
+= xz
111 ifeq ($(BR2_PACKAGE_PYTHON3_ZLIB
),y
)
112 PYTHON3_DEPENDENCIES
+= zlib
115 ifeq ($(BR2_PACKAGE_PYTHON3_OSSAUDIODEV
),y
)
116 PYTHON3_CONF_OPTS
+= --enable-ossaudiodev
118 PYTHON3_CONF_OPTS
+= --disable-ossaudiodev
121 # Make python believe we don't have 'hg', so that it doesn't try to
122 # communicate over the network during the build.
123 PYTHON3_CONF_ENV
+= \
124 ac_cv_have_long_long_format
=yes \
125 ac_cv_file__dev_ptmx
=yes \
126 ac_cv_file__dev_ptc
=yes \
127 ac_cv_working_tzset
=yes \
128 ac_cv_prog_HAS_HG
=/bin
/false
130 # GCC is always compliant with IEEE754
131 ifeq ($(BR2_ENDIAN
),"LITTLE")
132 PYTHON3_CONF_ENV
+= ac_cv_little_endian_double
=yes
134 PYTHON3_CONF_ENV
+= ac_cv_big_endian_double
=yes
137 # uClibc is known to have a broken wcsftime() implementation, so tell
138 # Python 3 to fall back to strftime() instead.
139 ifeq ($(BR2_TOOLCHAIN_USES_UCLIBC
),y
)
140 PYTHON3_CONF_ENV
+= ac_cv_func_wcsftime
=no
143 PYTHON3_CONF_OPTS
+= \
144 --without-ensurepip \
148 --disable-test-modules \
155 # Python builds two tools to generate code: 'pgen' and
156 # '_freeze_importlib'. Unfortunately, for the target Python, they are
157 # built for the target, while we need to run them at build time. So
158 # when installing host-python, we copy them to
159 # $(HOST_DIR)/usr/bin. And then, when building the target python
160 # package, we tell the configure script where they are located.
161 define HOST_PYTHON3_INSTALL_TOOLS
162 cp
$(@D
)/Parser
/pgen
$(HOST_DIR
)/usr
/bin
/python-pgen
163 cp
$(@D
)/Programs
/_freeze_importlib
$(HOST_DIR
)/usr
/bin
/python-freeze-importlib
165 HOST_PYTHON3_POST_INSTALL_HOOKS
+= HOST_PYTHON3_INSTALL_TOOLS
167 PYTHON3_CONF_ENV
+= \
168 PGEN_FOR_BUILD
=$(HOST_DIR
)/usr
/bin
/python-pgen \
169 FREEZE_IMPORTLIB_FOR_BUILD
=$(HOST_DIR
)/usr
/bin
/python-freeze-importlib
172 # Remove useless files. In the config/ directory, only the Makefile
173 # and the pyconfig.h files are needed at runtime.
175 define PYTHON3_REMOVE_USELESS_FILES
176 rm -f
$(TARGET_DIR
)/usr
/bin
/python
$(PYTHON3_VERSION_MAJOR
)-config
177 rm -f
$(TARGET_DIR
)/usr
/bin
/python
$(PYTHON3_VERSION_MAJOR
)m-config
178 rm -f
$(TARGET_DIR
)/usr
/bin
/python3-config
179 rm -f
$(TARGET_DIR
)/usr
/bin
/smtpd.py
.3
180 for i in
`find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/config-$(PYTHON3_VERSION_MAJOR)m/ \
181 -type f -not -name pyconfig.h -a -not -name Makefile` ; do \
184 rm -rf
$(TARGET_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION_MAJOR
)/__pycache__
/
185 rm -rf
$(TARGET_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION_MAJOR
)/lib-dynload
/sysconfigdata
/__pycache__
186 rm -rf
$(TARGET_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION_MAJOR
)/collections
/__pycache__
187 rm -rf
$(TARGET_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION_MAJOR
)/importlib
/__pycache__
190 PYTHON3_POST_INSTALL_TARGET_HOOKS
+= PYTHON3_REMOVE_USELESS_FILES
193 # Make sure libpython gets stripped out on target
195 define PYTHON3_ENSURE_LIBPYTHON_STRIPPED
196 chmod u
+w
$(TARGET_DIR
)/usr
/lib
/libpython
$(PYTHON3_VERSION_MAJOR
)*.so
199 PYTHON3_POST_INSTALL_TARGET_HOOKS
+= PYTHON3_ENSURE_LIBPYTHON_STRIPPED
201 PYTHON3_AUTORECONF
= YES
203 define PYTHON3_INSTALL_SYMLINK
204 ln
-fs python3
$(TARGET_DIR
)/usr
/bin
/python
207 ifneq ($(BR2_PACKAGE_PYTHON
),y
)
208 PYTHON3_POST_INSTALL_TARGET_HOOKS
+= PYTHON3_INSTALL_SYMLINK
211 # Some packages may have build scripts requiring python3, whatever is the
212 # python version chosen for the target.
213 # Only install the python symlink in the host tree if python3 is enabled
215 ifeq ($(BR2_PACKAGE_PYTHON3
),y
)
216 define HOST_PYTHON3_INSTALL_SYMLINK
217 ln
-fs python3
$(HOST_DIR
)/usr
/bin
/python
218 ln
-fs python3-config
$(HOST_DIR
)/usr
/bin
/python-config
221 HOST_PYTHON3_POST_INSTALL_HOOKS
+= HOST_PYTHON3_INSTALL_SYMLINK
224 # Provided to other packages
225 PYTHON3_PATH
= $(TARGET_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION_MAJOR
)/sysconfigdata
/:$(TARGET_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION_MAJOR
)/site-packages
/
227 $(eval
$(autotools-package
))
228 $(eval
$(host-autotools-package
))
230 define PYTHON3_CREATE_PYC_FILES
231 PYTHONPATH
="$(PYTHON3_PATH)" \
232 $(HOST_DIR
)/usr
/bin
/python
$(PYTHON3_VERSION_MAJOR
) \
233 support
/scripts
/pycompile.py \
234 $(TARGET_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION_MAJOR
)
237 ifeq ($(BR2_PACKAGE_PYTHON3_PYC_ONLY
)$(BR2_PACKAGE_PYTHON3_PY_PYC
),y
)
238 PYTHON3_TARGET_FINALIZE_HOOKS
+= PYTHON3_CREATE_PYC_FILES
241 ifeq ($(BR2_PACKAGE_PYTHON3_PYC_ONLY
),y
)
242 define PYTHON3_REMOVE_PY_FILES
243 find
$(TARGET_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION_MAJOR
) -name
'*.py' -print0 | \
244 xargs
-0 --no-run-if-empty
rm -f
246 PYTHON3_TARGET_FINALIZE_HOOKS
+= PYTHON3_REMOVE_PY_FILES
249 # Normally, *.pyc files should not have been compiled, but just in
250 # case, we make sure we remove all of them.
251 ifeq ($(BR2_PACKAGE_PYTHON3_PY_ONLY
),y
)
252 define PYTHON3_REMOVE_PYC_FILES
253 find
$(TARGET_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION_MAJOR
) -name
'*.pyc' -print0 | \
254 xargs
-0 --no-run-if-empty
rm -f
256 PYTHON3_TARGET_FINALIZE_HOOKS
+= PYTHON3_REMOVE_PYC_FILES
259 # In all cases, we don't want to keep the optimized .opt-1.pyc and
260 # .opt-2.pyc files, since they can't work without their non-optimized
262 define PYTHON3_REMOVE_OPTIMIZED_PYC_FILES
263 find
$(TARGET_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION_MAJOR
) -name
'*.opt-1.pyc' -print0
-o
-name
'*.opt-2.pyc' -print0 | \
264 xargs
-0 --no-run-if-empty
rm -f
266 PYTHON3_TARGET_FINALIZE_HOOKS
+= PYTHON3_REMOVE_OPTIMIZED_PYC_FILES