1 ################################################################################
5 ################################################################################
7 PYTHON3_VERSION_MAJOR = 3.4
8 PYTHON3_VERSION = $(PYTHON3_VERSION_MAJOR).3
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 HOST_PYTHON3_CONF_ENV += \
46 LDFLAGS="$(HOST_LDFLAGS) -Wl,--enable-new-dtags"
48 PYTHON3_DEPENDENCIES = host-python3 libffi
50 HOST_PYTHON3_DEPENDENCIES = host-expat host-zlib
52 PYTHON3_INSTALL_STAGING = YES
54 ifeq ($(BR2_PACKAGE_PYTHON3_READLINE),y)
55 PYTHON3_DEPENDENCIES += readline
58 ifeq ($(BR2_PACKAGE_PYTHON3_CURSES),y)
59 PYTHON3_DEPENDENCIES += ncurses
61 PYTHON3_CONF_OPTS += --disable-curses
64 ifeq ($(BR2_PACKAGE_PYTHON3_DECIMAL),y)
65 PYTHON3_DEPENDENCIES += mpdecimal
66 PYTHON3_CONF_OPTS += --with-libmpdec=system
68 PYTHON3_CONF_OPTS += --with-libmpdec=none
71 ifeq ($(BR2_PACKAGE_PYTHON3_PYEXPAT),y)
72 PYTHON3_DEPENDENCIES += expat
73 PYTHON3_CONF_OPTS += --with-expat=system
75 PYTHON3_CONF_OPTS += --with-expat=none
78 ifeq ($(BR2_PACKAGE_PYTHON3_PYC_ONLY),y)
79 PYTHON3_CONF_OPTS += --enable-old-stdlib-cache
82 ifeq ($(BR2_PACKAGE_PYTHON3_PY_ONLY),y)
83 PYTHON3_CONF_OPTS += --disable-pyc-build
86 ifeq ($(BR2_PACKAGE_PYTHON3_SQLITE),y)
87 PYTHON3_DEPENDENCIES += sqlite
89 PYTHON3_CONF_OPTS += --disable-sqlite3
92 ifeq ($(BR2_PACKAGE_PYTHON3_SSL),y)
93 PYTHON3_DEPENDENCIES += openssl
96 ifneq ($(BR2_PACKAGE_PYTHON3_CODECSCJK),y)
97 PYTHON3_CONF_OPTS += --disable-codecs-cjk
100 ifneq ($(BR2_PACKAGE_PYTHON3_UNICODEDATA),y)
101 PYTHON3_CONF_OPTS += --disable-unicodedata
104 ifeq ($(BR2_PACKAGE_PYTHON3_BZIP2),y)
105 PYTHON3_DEPENDENCIES += bzip2
108 ifeq ($(BR2_PACKAGE_PYTHON3_ZLIB),y)
109 PYTHON3_DEPENDENCIES += zlib
112 ifeq ($(BR2_PACKAGE_PYTHON3_OSSAUDIODEV),y)
113 PYTHON3_CONF_OPTS += --enable-ossaudiodev
115 PYTHON3_CONF_OPTS += --disable-ossaudiodev
118 PYTHON3_CONF_ENV += \
119 ac_cv_have_long_long_format=yes \
120 ac_cv_file__dev_ptmx=yes \
121 ac_cv_file__dev_ptc=yes \
122 ac_cv_working_tzset=yes
124 # uClibc is known to have a broken wcsftime() implementation, so tell
125 # Python 3 to fall back to strftime() instead.
126 ifeq ($(BR2_TOOLCHAIN_USES_UCLIBC),y)
127 PYTHON3_CONF_ENV += ac_cv_func_wcsftime=no
130 PYTHON3_CONF_OPTS += \
131 --without-ensurepip \
135 --disable-test-modules \
142 # This is needed to make sure the Python build process doesn't try to
143 # regenerate those files with the pgen program. Otherwise, it builds
144 # pgen for the target, and tries to run it on the host.
146 define PYTHON3_TOUCH_GRAMMAR_FILES
147 touch $(@D)/Include/graminit.h $(@D)/Python/graminit.c
150 PYTHON3_POST_PATCH_HOOKS += PYTHON3_TOUCH_GRAMMAR_FILES
153 # Remove useless files. In the config/ directory, only the Makefile
154 # and the pyconfig.h files are needed at runtime.
156 define PYTHON3_REMOVE_USELESS_FILES
157 rm -f $(TARGET_DIR)/usr/bin/python$(PYTHON3_VERSION_MAJOR)-config
158 rm -f $(TARGET_DIR)/usr/bin/python$(PYTHON3_VERSION_MAJOR)m-config
159 rm -f $(TARGET_DIR)/usr/bin/python3-config
160 rm -f $(TARGET_DIR)/usr/bin/smtpd.py.3
161 for i in `find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/config-$(PYTHON3_VERSION_MAJOR)m/ \
162 -type f -not -name pyconfig.h -a -not -name Makefile` ; do \
165 rm -rf $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/__pycache__/
166 rm -rf $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/lib-dynload/sysconfigdata/__pycache__
167 rm -rf $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/collections/__pycache__
168 rm -rf $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/importlib/__pycache__
171 PYTHON3_POST_INSTALL_TARGET_HOOKS += PYTHON3_REMOVE_USELESS_FILES
174 # Make sure libpython gets stripped out on target
176 define PYTHON3_ENSURE_LIBPYTHON_STRIPPED
177 chmod u+w $(TARGET_DIR)/usr/lib/libpython$(PYTHON3_VERSION_MAJOR)*.so
180 PYTHON3_POST_INSTALL_TARGET_HOOKS += PYTHON3_ENSURE_LIBPYTHON_STRIPPED
182 PYTHON3_AUTORECONF = YES
184 define PYTHON3_INSTALL_SYMLINK
185 ln -fs python3 $(TARGET_DIR)/usr/bin/python
188 ifneq ($(BR2_PACKAGE_PYTHON),y)
189 PYTHON3_POST_INSTALL_TARGET_HOOKS += PYTHON3_INSTALL_SYMLINK
192 # Some packages may have build scripts requiring python3, whatever is the
193 # python version chosen for the target.
194 # Only install the python symlink in the host tree if python3 is enabled
196 ifeq ($(BR2_PACKAGE_PYTHON3),y)
197 define HOST_PYTHON3_INSTALL_SYMLINK
198 ln -fs python3 $(HOST_DIR)/usr/bin/python
199 ln -fs python3-config $(HOST_DIR)/usr/bin/python-config
202 HOST_PYTHON3_POST_INSTALL_HOOKS += HOST_PYTHON3_INSTALL_SYMLINK
205 # Provided to other packages
206 PYTHON3_PATH = $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/sysconfigdata/:$(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/site-packages/
208 $(eval $(autotools-package))
209 $(eval $(host-autotools-package))
211 ifeq ($(BR2_PACKAGE_PYTHON3_PYC_ONLY),y)
212 define PYTHON3_FINALIZE_TARGET
213 find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR) -name '*.py' -print0 | xargs -0 rm -f
217 ifeq ($(BR2_PACKAGE_PYTHON3_PY_ONLY),y)
218 define PYTHON3_FINALIZE_TARGET
219 find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR) -name '*.pyc' -print0 | xargs -0 rm -f
223 TARGET_FINALIZE_HOOKS += PYTHON3_FINALIZE_TARGET