1 ################################################################################
5 ################################################################################
7 PYTHON_VERSION_MAJOR
= 2.7
8 PYTHON_VERSION
= $(PYTHON_VERSION_MAJOR
).9
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 HOST_PYTHON_CONF_ENV
+= \
43 LDFLAGS
="$(HOST_LDFLAGS) -Wl,--enable-new-dtags"
45 # Building host python in parallel sometimes triggers a "Bus error"
46 # during the execution of "./python setup.py build" in the
47 # installation step. It is probably due to the installation of a
48 # shared library taking place in parallel to the execution of
49 # ./python, causing spurious Bus error. Building host-python with
50 # MAKE1 has shown to workaround the problem.
51 HOST_PYTHON_MAKE
= $(MAKE1
)
53 PYTHON_DEPENDENCIES
= host-python libffi
55 HOST_PYTHON_DEPENDENCIES
= host-expat host-zlib
57 PYTHON_INSTALL_STAGING
= YES
59 ifeq ($(BR2_PACKAGE_PYTHON_READLINE
),y
)
60 PYTHON_DEPENDENCIES
+= readline
63 ifeq ($(BR2_PACKAGE_PYTHON_CURSES
),y
)
64 PYTHON_DEPENDENCIES
+= ncurses
66 PYTHON_CONF_OPTS
+= --disable-curses
69 ifeq ($(BR2_PACKAGE_PYTHON_PYEXPAT
),y
)
70 PYTHON_DEPENDENCIES
+= expat
71 PYTHON_CONF_OPTS
+= --with-expat
=system
73 PYTHON_CONF_OPTS
+= --with-expat
=none
76 ifeq ($(BR2_PACKAGE_PYTHON_BSDDB
),y
)
77 PYTHON_DEPENDENCIES
+= berkeleydb
79 PYTHON_CONF_OPTS
+= --disable-bsddb
82 ifeq ($(BR2_PACKAGE_PYTHON_SQLITE
),y
)
83 PYTHON_DEPENDENCIES
+= sqlite
85 PYTHON_CONF_OPTS
+= --disable-sqlite3
88 ifeq ($(BR2_PACKAGE_PYTHON_SSL
),y
)
89 PYTHON_DEPENDENCIES
+= openssl
91 PYTHON_CONF_OPTS
+= --disable-ssl
94 ifneq ($(BR2_PACKAGE_PYTHON_CODECSCJK
),y
)
95 PYTHON_CONF_OPTS
+= --disable-codecs-cjk
98 ifneq ($(BR2_PACKAGE_PYTHON_UNICODEDATA
),y
)
99 PYTHON_CONF_OPTS
+= --disable-unicodedata
102 # Default is UCS2 w/o a conf opt
103 ifeq ($(BR2_PACKAGE_PYTHON_UCS4
),y
)
104 PYTHON_CONF_OPTS
+= --enable-unicode
=ucs4
107 ifeq ($(BR2_PACKAGE_PYTHON_BZIP2
),y
)
108 PYTHON_DEPENDENCIES
+= bzip2
110 PYTHON_CONF_OPTS
+= --disable-bz2
113 ifeq ($(BR2_PACKAGE_PYTHON_ZLIB
),y
)
114 PYTHON_DEPENDENCIES
+= zlib
116 PYTHON_CONF_OPTS
+= --disable-zlib
119 ifeq ($(BR2_PACKAGE_PYTHON_HASHLIB
),y
)
120 PYTHON_DEPENDENCIES
+= openssl
123 ifeq ($(BR2_PACKAGE_PYTHON_OSSAUDIODEV
),y
)
124 PYTHON_CONF_OPTS
+= --enable-ossaudiodev
126 PYTHON_CONF_OPTS
+= --disable-ossaudiodev
130 ac_cv_have_long_long_format
=yes \
131 ac_cv_file__dev_ptmx
=yes \
132 ac_cv_file__dev_ptc
=yes \
133 ac_cv_working_tzset
=yes
135 PYTHON_CONF_OPTS
+= \
137 --without-doc-strings \
140 --disable-test-modules \
148 # This is needed to make sure the Python build process doesn't try to
149 # regenerate those files with the pgen program. Otherwise, it builds
150 # pgen for the target, and tries to run it on the host.
152 define PYTHON_TOUCH_GRAMMAR_FILES
153 touch
$(@D
)/Include
/graminit.h
$(@D
)/Python
/graminit.c
156 PYTHON_POST_PATCH_HOOKS
+= PYTHON_TOUCH_GRAMMAR_FILES
159 # Remove useless files. In the config/ directory, only the Makefile
160 # and the pyconfig.h files are needed at runtime.
162 # idle & smtpd.py have bad shebangs and are mostly samples
164 define PYTHON_REMOVE_USELESS_FILES
165 rm -f
$(TARGET_DIR
)/usr
/bin
/python
$(PYTHON_VERSION_MAJOR
)-config
166 rm -f
$(TARGET_DIR
)/usr
/bin
/python2-config
167 rm -f
$(TARGET_DIR
)/usr
/bin
/python-config
168 rm -f
$(TARGET_DIR
)/usr
/bin
/smtpd.py
169 for i in
`find $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/config/ \
170 -type f -not -name pyconfig.h -a -not -name Makefile` ; do \
175 PYTHON_POST_INSTALL_TARGET_HOOKS
+= PYTHON_REMOVE_USELESS_FILES
178 # Make sure libpython gets stripped out on target
180 define PYTHON_ENSURE_LIBPYTHON_STRIPPED
181 chmod u
+w
$(TARGET_DIR
)/usr
/lib
/libpython
$(PYTHON_VERSION_MAJOR
)*.so
184 PYTHON_POST_INSTALL_TARGET_HOOKS
+= PYTHON_ENSURE_LIBPYTHON_STRIPPED
186 # Always install the python symlink in the target tree
187 define PYTHON_INSTALL_TARGET_PYTHON_SYMLINK
188 ln
-sf python2
$(TARGET_DIR
)/usr
/bin
/python
191 PYTHON_POST_INSTALL_TARGET_HOOKS
+= PYTHON_INSTALL_TARGET_PYTHON_SYMLINK
193 # Always install the python-config symlink in the staging tree
194 define PYTHON_INSTALL_STAGING_PYTHON_CONFIG_SYMLINK
195 ln
-sf python2-config
$(STAGING_DIR
)/usr
/bin
/python-config
198 PYTHON_POST_INSTALL_STAGING_HOOKS
+= PYTHON_INSTALL_STAGING_PYTHON_CONFIG_SYMLINK
200 PYTHON_AUTORECONF
= YES
202 # Some packages may have build scripts requiring python2.
203 # Only install the python symlink in the host tree if python3 is not enabled
204 # for the target, otherwise the default python program may be missing.
205 ifneq ($(BR2_PACKAGE_PYTHON3
),y
)
206 define HOST_PYTHON_INSTALL_PYTHON_SYMLINK
207 ln
-sf python2
$(HOST_DIR
)/usr
/bin
/python
208 ln
-sf python2-config
$(HOST_DIR
)/usr
/bin
/python-config
211 HOST_PYTHON_POST_INSTALL_HOOKS
+= HOST_PYTHON_INSTALL_PYTHON_SYMLINK
214 # Provided to other packages
215 PYTHON_PATH
= $(TARGET_DIR
)/usr
/lib
/python
$(PYTHON_VERSION_MAJOR
)/sysconfigdata
/:$(TARGET_DIR
)/usr
/lib
/python
$(PYTHON_VERSION_MAJOR
)/site-packages
/
217 $(eval
$(autotools-package
))
218 $(eval
$(host-autotools-package
))
220 ifeq ($(BR2_PACKAGE_PYTHON_PYC_ONLY
),y
)
221 define PYTHON_FINALIZE_TARGET
222 find
$(TARGET_DIR
)/usr
/lib
/python
$(PYTHON_VERSION_MAJOR
) -name
'*.py' -print0 | xargs
-0 rm -f
226 ifeq ($(BR2_PACKAGE_PYTHON_PY_ONLY
),y
)
227 define PYTHON_FINALIZE_TARGET
228 find
$(TARGET_DIR
)/usr
/lib
/python
$(PYTHON_VERSION_MAJOR
) -name
'*.pyc' -print0 | xargs
-0 rm -f
232 TARGET_FINALIZE_HOOKS
+= PYTHON_FINALIZE_TARGET