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
60 PYTHON3_CONF_OPTS
+= --disable-readline
63 ifeq ($(BR2_PACKAGE_PYTHON3_CURSES
),y
)
64 PYTHON3_DEPENDENCIES
+= ncurses
66 PYTHON3_CONF_OPTS
+= --disable-curses
69 ifeq ($(BR2_PACKAGE_PYTHON3_DECIMAL
),y
)
70 PYTHON3_DEPENDENCIES
+= mpdecimal
71 PYTHON3_CONF_OPTS
+= --with-libmpdec
=system
73 PYTHON3_CONF_OPTS
+= --with-libmpdec
=none
76 ifeq ($(BR2_PACKAGE_PYTHON3_PYEXPAT
),y
)
77 PYTHON3_DEPENDENCIES
+= expat
78 PYTHON3_CONF_OPTS
+= --with-expat
=system
80 PYTHON3_CONF_OPTS
+= --with-expat
=none
83 ifeq ($(BR2_PACKAGE_PYTHON3_PYC_ONLY
),y
)
84 PYTHON3_CONF_OPTS
+= --enable-old-stdlib-cache
87 ifeq ($(BR2_PACKAGE_PYTHON3_SQLITE
),y
)
88 PYTHON3_DEPENDENCIES
+= sqlite
90 PYTHON3_CONF_OPTS
+= --disable-sqlite3
93 ifeq ($(BR2_PACKAGE_PYTHON3_SSL
),y
)
94 PYTHON3_DEPENDENCIES
+= openssl
96 PYTHON3_CONF_OPTS
+= --disable-openssl
99 ifneq ($(BR2_PACKAGE_PYTHON3_CODECSCJK
),y
)
100 PYTHON3_CONF_OPTS
+= --disable-codecs-cjk
103 ifneq ($(BR2_PACKAGE_PYTHON3_UNICODEDATA
),y
)
104 PYTHON3_CONF_OPTS
+= --disable-unicodedata
107 ifeq ($(BR2_PACKAGE_PYTHON3_BZIP2
),y
)
108 PYTHON3_DEPENDENCIES
+= bzip2
110 PYTHON3_CONF_OPTS
+= --disable-bzip2
113 ifeq ($(BR2_PACKAGE_PYTHON3_XZ
),y
)
114 PYTHON3_DEPENDENCIES
+= xz
116 PYTHON3_CONF_OPTS
+= --disable-xz
119 ifeq ($(BR2_PACKAGE_PYTHON3_ZLIB
),y
)
120 PYTHON3_DEPENDENCIES
+= zlib
122 PYTHON3_CONF_OPTS
+= --disable-zlib
125 ifeq ($(BR2_PACKAGE_PYTHON3_OSSAUDIODEV
),y
)
126 PYTHON3_CONF_OPTS
+= --enable-ossaudiodev
128 PYTHON3_CONF_OPTS
+= --disable-ossaudiodev
131 # Make python believe we don't have 'hg', so that it doesn't try to
132 # communicate over the network during the build.
133 PYTHON3_CONF_ENV
+= \
134 ac_cv_have_long_long_format
=yes \
135 ac_cv_file__dev_ptmx
=yes \
136 ac_cv_file__dev_ptc
=yes \
137 ac_cv_working_tzset
=yes \
138 ac_cv_prog_HAS_HG
=/bin
/false
140 # GCC is always compliant with IEEE754
141 ifeq ($(BR2_ENDIAN
),"LITTLE")
142 PYTHON3_CONF_ENV
+= ac_cv_little_endian_double
=yes
144 PYTHON3_CONF_ENV
+= ac_cv_big_endian_double
=yes
147 # uClibc is known to have a broken wcsftime() implementation, so tell
148 # Python 3 to fall back to strftime() instead.
149 ifeq ($(BR2_TOOLCHAIN_USES_UCLIBC
),y
)
150 PYTHON3_CONF_ENV
+= ac_cv_func_wcsftime
=no
153 PYTHON3_CONF_OPTS
+= \
154 --without-ensurepip \
158 --disable-test-modules \
165 # Python builds two tools to generate code: 'pgen' and
166 # '_freeze_importlib'. Unfortunately, for the target Python, they are
167 # built for the target, while we need to run them at build time. So
168 # when installing host-python, we copy them to
169 # $(HOST_DIR)/usr/bin. And then, when building the target python
170 # package, we tell the configure script where they are located.
171 define HOST_PYTHON3_INSTALL_TOOLS
172 cp
$(@D
)/Parser
/pgen
$(HOST_DIR
)/usr
/bin
/python-pgen
173 cp
$(@D
)/Programs
/_freeze_importlib
$(HOST_DIR
)/usr
/bin
/python-freeze-importlib
175 HOST_PYTHON3_POST_INSTALL_HOOKS
+= HOST_PYTHON3_INSTALL_TOOLS
177 PYTHON3_CONF_ENV
+= \
178 PGEN_FOR_BUILD
=$(HOST_DIR
)/usr
/bin
/python-pgen \
179 FREEZE_IMPORTLIB_FOR_BUILD
=$(HOST_DIR
)/usr
/bin
/python-freeze-importlib
182 # Remove useless files. In the config/ directory, only the Makefile
183 # and the pyconfig.h files are needed at runtime.
185 define PYTHON3_REMOVE_USELESS_FILES
186 rm -f
$(TARGET_DIR
)/usr
/bin
/python
$(PYTHON3_VERSION_MAJOR
)-config
187 rm -f
$(TARGET_DIR
)/usr
/bin
/python
$(PYTHON3_VERSION_MAJOR
)m-config
188 rm -f
$(TARGET_DIR
)/usr
/bin
/python3-config
189 rm -f
$(TARGET_DIR
)/usr
/bin
/smtpd.py
.3
190 for i in
`find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/config-$(PYTHON3_VERSION_MAJOR)m/ \
191 -type f -not -name pyconfig.h -a -not -name Makefile` ; do \
194 rm -rf
$(TARGET_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION_MAJOR
)/__pycache__
/
195 rm -rf
$(TARGET_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION_MAJOR
)/lib-dynload
/sysconfigdata
/__pycache__
196 rm -rf
$(TARGET_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION_MAJOR
)/collections
/__pycache__
197 rm -rf
$(TARGET_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION_MAJOR
)/importlib
/__pycache__
200 PYTHON3_POST_INSTALL_TARGET_HOOKS
+= PYTHON3_REMOVE_USELESS_FILES
203 # Make sure libpython gets stripped out on target
205 define PYTHON3_ENSURE_LIBPYTHON_STRIPPED
206 chmod u
+w
$(TARGET_DIR
)/usr
/lib
/libpython
$(PYTHON3_VERSION_MAJOR
)*.so
209 PYTHON3_POST_INSTALL_TARGET_HOOKS
+= PYTHON3_ENSURE_LIBPYTHON_STRIPPED
211 PYTHON3_AUTORECONF
= YES
213 define PYTHON3_INSTALL_SYMLINK
214 ln
-fs python3
$(TARGET_DIR
)/usr
/bin
/python
217 ifneq ($(BR2_PACKAGE_PYTHON
),y
)
218 PYTHON3_POST_INSTALL_TARGET_HOOKS
+= PYTHON3_INSTALL_SYMLINK
221 # Some packages may have build scripts requiring python3, whatever is the
222 # python version chosen for the target.
223 # Only install the python symlink in the host tree if python3 is enabled
225 ifeq ($(BR2_PACKAGE_PYTHON3
),y
)
226 define HOST_PYTHON3_INSTALL_SYMLINK
227 ln
-fs python3
$(HOST_DIR
)/usr
/bin
/python
228 ln
-fs python3-config
$(HOST_DIR
)/usr
/bin
/python-config
231 HOST_PYTHON3_POST_INSTALL_HOOKS
+= HOST_PYTHON3_INSTALL_SYMLINK
234 # Provided to other packages
235 PYTHON3_PATH
= $(TARGET_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION_MAJOR
)/sysconfigdata
/:$(TARGET_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION_MAJOR
)/site-packages
/
237 $(eval
$(autotools-package
))
238 $(eval
$(host-autotools-package
))
240 define PYTHON3_CREATE_PYC_FILES
241 PYTHONPATH
="$(PYTHON3_PATH)" \
242 $(HOST_DIR
)/usr
/bin
/python
$(PYTHON3_VERSION_MAJOR
) \
243 support
/scripts
/pycompile.py \
244 $(TARGET_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION_MAJOR
)
247 ifeq ($(BR2_PACKAGE_PYTHON3_PYC_ONLY
)$(BR2_PACKAGE_PYTHON3_PY_PYC
),y
)
248 PYTHON3_TARGET_FINALIZE_HOOKS
+= PYTHON3_CREATE_PYC_FILES
251 ifeq ($(BR2_PACKAGE_PYTHON3_PYC_ONLY
),y
)
252 define PYTHON3_REMOVE_PY_FILES
253 find
$(TARGET_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION_MAJOR
) -name
'*.py' -print0 | \
254 xargs
-0 --no-run-if-empty
rm -f
256 PYTHON3_TARGET_FINALIZE_HOOKS
+= PYTHON3_REMOVE_PY_FILES
259 # Normally, *.pyc files should not have been compiled, but just in
260 # case, we make sure we remove all of them.
261 ifeq ($(BR2_PACKAGE_PYTHON3_PY_ONLY
),y
)
262 define PYTHON3_REMOVE_PYC_FILES
263 find
$(TARGET_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION_MAJOR
) -name
'*.pyc' -print0 | \
264 xargs
-0 --no-run-if-empty
rm -f
266 PYTHON3_TARGET_FINALIZE_HOOKS
+= PYTHON3_REMOVE_PYC_FILES
269 # In all cases, we don't want to keep the optimized .opt-1.pyc and
270 # .opt-2.pyc files, since they can't work without their non-optimized
272 define PYTHON3_REMOVE_OPTIMIZED_PYC_FILES
273 find
$(TARGET_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION_MAJOR
) -name
'*.opt-1.pyc' -print0
-o
-name
'*.opt-2.pyc' -print0 | \
274 xargs
-0 --no-run-if-empty
rm -f
276 PYTHON3_TARGET_FINALIZE_HOOKS
+= PYTHON3_REMOVE_OPTIMIZED_PYC_FILES