1 ################################################################################
5 ################################################################################
7 PYTHON_VERSION_MAJOR
= 2.7
8 PYTHON_VERSION
= $(PYTHON_VERSION_MAJOR
).13
9 PYTHON_SOURCE
= Python-
$(PYTHON_VERSION
).
tar.xz
10 PYTHON_SITE
= http
://python.org
/ftp
/python
/$(PYTHON_VERSION
)
11 PYTHON_LICENSE
= Python software foundation license v2
, others
12 PYTHON_LICENSE_FILES
= LICENSE
13 PYTHON_LIBTOOL_PATCH
= NO
15 # Python needs itself to be built, so in order to cross-compile
16 # Python, we need to build a host Python first. This host Python is
17 # also installed in $(HOST_DIR), as it is needed when cross-compiling
18 # third-party Python modules.
20 HOST_PYTHON_CONF_OPTS
+= \
27 --disable-codecs-cjk \
29 --enable-unicodedata \
33 --disable-test-modules \
36 --disable-ossaudiodev \
39 # Make sure that LD_LIBRARY_PATH overrides -rpath.
40 # This is needed because libpython may be installed at the same time that
42 # Make python believe we don't have 'hg' and 'svn', so that it doesn't
43 # try to communicate over the network during the build.
44 HOST_PYTHON_CONF_ENV
+= \
45 LDFLAGS
="$(HOST_LDFLAGS) -Wl,--enable-new-dtags" \
46 ac_cv_prog_HAS_HG
=/bin
/false \
47 ac_cv_prog_SVNVERSION
=/bin
/false
49 # Building host python in parallel sometimes triggers a "Bus error"
50 # during the execution of "./python setup.py build" in the
51 # installation step. It is probably due to the installation of a
52 # shared library taking place in parallel to the execution of
53 # ./python, causing spurious Bus error. Building host-python with
54 # MAKE1 has shown to workaround the problem.
55 HOST_PYTHON_MAKE
= $(MAKE1
)
57 PYTHON_DEPENDENCIES
= host-python libffi
59 HOST_PYTHON_DEPENDENCIES
= host-expat host-zlib
61 PYTHON_INSTALL_STAGING
= YES
63 ifeq ($(BR2_PACKAGE_PYTHON_READLINE
),y
)
64 PYTHON_DEPENDENCIES
+= readline
67 ifeq ($(BR2_PACKAGE_PYTHON_CURSES
),y
)
68 PYTHON_DEPENDENCIES
+= ncurses
70 PYTHON_CONF_OPTS
+= --disable-curses
73 ifeq ($(BR2_PACKAGE_PYTHON_PYEXPAT
),y
)
74 PYTHON_DEPENDENCIES
+= expat
75 PYTHON_CONF_OPTS
+= --with-expat
=system
77 PYTHON_CONF_OPTS
+= --with-expat
=none
80 ifeq ($(BR2_PACKAGE_PYTHON_BSDDB
),y
)
81 PYTHON_DEPENDENCIES
+= berkeleydb
83 PYTHON_CONF_OPTS
+= --disable-bsddb
86 ifeq ($(BR2_PACKAGE_PYTHON_SQLITE
),y
)
87 PYTHON_DEPENDENCIES
+= sqlite
89 PYTHON_CONF_OPTS
+= --disable-sqlite3
92 ifeq ($(BR2_PACKAGE_PYTHON_SSL
),y
)
93 PYTHON_DEPENDENCIES
+= openssl
95 PYTHON_CONF_OPTS
+= --disable-ssl
98 ifneq ($(BR2_PACKAGE_PYTHON_CODECSCJK
),y
)
99 PYTHON_CONF_OPTS
+= --disable-codecs-cjk
102 ifneq ($(BR2_PACKAGE_PYTHON_UNICODEDATA
),y
)
103 PYTHON_CONF_OPTS
+= --disable-unicodedata
106 # Default is UCS2 w/o a conf opt
107 ifeq ($(BR2_PACKAGE_PYTHON_UCS4
),y
)
108 PYTHON_CONF_OPTS
+= --enable-unicode
=ucs4
111 ifeq ($(BR2_PACKAGE_PYTHON_BZIP2
),y
)
112 PYTHON_DEPENDENCIES
+= bzip2
114 PYTHON_CONF_OPTS
+= --disable-bz2
117 ifeq ($(BR2_PACKAGE_PYTHON_ZLIB
),y
)
118 PYTHON_DEPENDENCIES
+= zlib
120 PYTHON_CONF_OPTS
+= --disable-zlib
123 ifeq ($(BR2_PACKAGE_PYTHON_HASHLIB
),y
)
124 PYTHON_DEPENDENCIES
+= openssl
127 ifeq ($(BR2_PACKAGE_PYTHON_OSSAUDIODEV
),y
)
128 PYTHON_CONF_OPTS
+= --enable-ossaudiodev
130 PYTHON_CONF_OPTS
+= --disable-ossaudiodev
133 # Make python believe we don't have 'hg' and 'svn', so that it doesn't
134 # try to communicate over the network during the build.
136 ac_cv_have_long_long_format
=yes \
137 ac_cv_file__dev_ptmx
=yes \
138 ac_cv_file__dev_ptc
=yes \
139 ac_cv_working_tzset
=yes \
140 ac_cv_prog_HAS_HG
=/bin
/false \
141 ac_cv_prog_SVNVERSION
=/bin
/false
143 # GCC is always compliant with IEEE754
144 ifeq ($(BR2_ENDIAN
),"LITTLE")
145 PYTHON_CONF_ENV
+= ac_cv_little_endian_double
=yes
147 PYTHON_CONF_ENV
+= ac_cv_big_endian_double
=yes
150 PYTHON_CONF_OPTS
+= \
152 --without-doc-strings \
155 --disable-test-modules \
161 --disable-pyo-build \
164 # This is needed to make sure the Python build process doesn't try to
165 # regenerate those files with the pgen program. Otherwise, it builds
166 # pgen for the target, and tries to run it on the host.
168 define PYTHON_TOUCH_GRAMMAR_FILES
169 touch
$(@D
)/Include
/graminit.h
$(@D
)/Python
/graminit.c
172 PYTHON_POST_PATCH_HOOKS
+= PYTHON_TOUCH_GRAMMAR_FILES
175 # Remove useless files. In the config/ directory, only the Makefile
176 # and the pyconfig.h files are needed at runtime.
178 # idle & smtpd.py have bad shebangs and are mostly samples
180 define PYTHON_REMOVE_USELESS_FILES
181 rm -f
$(TARGET_DIR
)/usr
/bin
/python
$(PYTHON_VERSION_MAJOR
)-config
182 rm -f
$(TARGET_DIR
)/usr
/bin
/python2-config
183 rm -f
$(TARGET_DIR
)/usr
/bin
/python-config
184 rm -f
$(TARGET_DIR
)/usr
/bin
/smtpd.py
185 for i in
`find $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/config/ \
186 -type f -not -name pyconfig.h -a -not -name Makefile` ; do \
191 PYTHON_POST_INSTALL_TARGET_HOOKS
+= PYTHON_REMOVE_USELESS_FILES
194 # Make sure libpython gets stripped out on target
196 define PYTHON_ENSURE_LIBPYTHON_STRIPPED
197 chmod u
+w
$(TARGET_DIR
)/usr
/lib
/libpython
$(PYTHON_VERSION_MAJOR
)*.so
200 PYTHON_POST_INSTALL_TARGET_HOOKS
+= PYTHON_ENSURE_LIBPYTHON_STRIPPED
202 # Always install the python symlink in the target tree
203 define PYTHON_INSTALL_TARGET_PYTHON_SYMLINK
204 ln
-sf python2
$(TARGET_DIR
)/usr
/bin
/python
207 PYTHON_POST_INSTALL_TARGET_HOOKS
+= PYTHON_INSTALL_TARGET_PYTHON_SYMLINK
209 # Always install the python-config symlink in the staging tree
210 define PYTHON_INSTALL_STAGING_PYTHON_CONFIG_SYMLINK
211 ln
-sf python2-config
$(STAGING_DIR
)/usr
/bin
/python-config
214 PYTHON_POST_INSTALL_STAGING_HOOKS
+= PYTHON_INSTALL_STAGING_PYTHON_CONFIG_SYMLINK
216 PYTHON_AUTORECONF
= YES
218 # Some packages may have build scripts requiring python2.
219 # Only install the python symlink in the host tree if python3 is not enabled
220 # for the target, otherwise the default python program may be missing.
221 ifneq ($(BR2_PACKAGE_PYTHON3
),y
)
222 define HOST_PYTHON_INSTALL_PYTHON_SYMLINK
223 ln
-sf python2
$(HOST_DIR
)/usr
/bin
/python
224 ln
-sf python2-config
$(HOST_DIR
)/usr
/bin
/python-config
227 HOST_PYTHON_POST_INSTALL_HOOKS
+= HOST_PYTHON_INSTALL_PYTHON_SYMLINK
230 # Provided to other packages
231 PYTHON_PATH
= $(TARGET_DIR
)/usr
/lib
/python
$(PYTHON_VERSION_MAJOR
)/sysconfigdata
/:$(TARGET_DIR
)/usr
/lib
/python
$(PYTHON_VERSION_MAJOR
)/site-packages
/
233 $(eval
$(autotools-package
))
234 $(eval
$(host-autotools-package
))
236 define PYTHON_CREATE_PYC_FILES
237 PYTHONPATH
="$(PYTHON_PATH)" \
238 $(HOST_DIR
)/usr
/bin
/python
$(PYTHON_VERSION_MAJOR
) \
239 support
/scripts
/pycompile.py \
240 $(TARGET_DIR
)/usr
/lib
/python
$(PYTHON_VERSION_MAJOR
)
243 ifeq ($(BR2_PACKAGE_PYTHON_PYC_ONLY
)$(BR2_PACKAGE_PYTHON_PY_PYC
),y
)
244 PYTHON_TARGET_FINALIZE_HOOKS
+= PYTHON_CREATE_PYC_FILES
247 ifeq ($(BR2_PACKAGE_PYTHON_PYC_ONLY
),y
)
248 define PYTHON_REMOVE_PY_FILES
249 find
$(TARGET_DIR
)/usr
/lib
/python
$(PYTHON_VERSION_MAJOR
) -name
'*.py' -print0 | \
250 xargs
-0 --no-run-if-empty
rm -f
252 PYTHON_TARGET_FINALIZE_HOOKS
+= PYTHON_REMOVE_PY_FILES
255 # Normally, *.pyc files should not have been compiled, but just in
256 # case, we make sure we remove all of them.
257 ifeq ($(BR2_PACKAGE_PYTHON_PY_ONLY
),y
)
258 define PYTHON_REMOVE_PYC_FILES
259 find
$(TARGET_DIR
)/usr
/lib
/python
$(PYTHON_VERSION_MAJOR
) -name
'*.pyc' -print0 | \
260 xargs
-0 --no-run-if-empty
rm -f
262 PYTHON_TARGET_FINALIZE_HOOKS
+= PYTHON_REMOVE_PYC_FILES
265 # In all cases, we don't want to keep the optimized .pyo files
266 define PYTHON_REMOVE_PYO_FILES
267 find
$(TARGET_DIR
)/usr
/lib
/python
$(PYTHON_VERSION_MAJOR
) -name
'*.pyo' -print0 | \
268 xargs
-0 --no-run-if-empty
rm -f
270 PYTHON_TARGET_FINALIZE_HOOKS
+= PYTHON_REMOVE_PYO_FILES