memcached: bump version to 1.4.36
[buildroot-gz.git] / package / python / python.mk
blob17875761888ff2a5ad911f03c1c5becd26416532
1 ################################################################################
3 # python
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 += \
21 --enable-static \
22 --without-cxx-main \
23 --disable-sqlite3 \
24 --disable-tk \
25 --with-expat=system \
26 --disable-curses \
27 --disable-codecs-cjk \
28 --disable-nis \
29 --enable-unicodedata \
30 --disable-dbm \
31 --disable-gdbm \
32 --disable-bsddb \
33 --disable-test-modules \
34 --disable-bz2 \
35 --disable-ssl \
36 --disable-ossaudiodev \
37 --disable-pyo-build
39 # Make sure that LD_LIBRARY_PATH overrides -rpath.
40 # This is needed because libpython may be installed at the same time that
41 # python is called.
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_GETTEXT),y)
64 PYTHON_DEPENDENCIES += gettext
65 endif
67 ifeq ($(BR2_PACKAGE_PYTHON_READLINE),y)
68 PYTHON_DEPENDENCIES += readline
69 else
70 PYTHON_CONF_OPTS += --disable-readline
71 endif
73 ifeq ($(BR2_PACKAGE_PYTHON_CURSES),y)
74 PYTHON_DEPENDENCIES += ncurses
75 else
76 PYTHON_CONF_OPTS += --disable-curses
77 endif
79 ifeq ($(BR2_PACKAGE_PYTHON_PYEXPAT),y)
80 PYTHON_DEPENDENCIES += expat
81 PYTHON_CONF_OPTS += --with-expat=system
82 else
83 PYTHON_CONF_OPTS += --with-expat=none
84 endif
86 ifeq ($(BR2_PACKAGE_PYTHON_BSDDB),y)
87 PYTHON_DEPENDENCIES += berkeleydb
88 else
89 PYTHON_CONF_OPTS += --disable-bsddb
90 endif
92 ifeq ($(BR2_PACKAGE_PYTHON_SQLITE),y)
93 PYTHON_DEPENDENCIES += sqlite
94 else
95 PYTHON_CONF_OPTS += --disable-sqlite3
96 endif
98 ifeq ($(BR2_PACKAGE_PYTHON_SSL),y)
99 PYTHON_DEPENDENCIES += openssl
100 else
101 PYTHON_CONF_OPTS += --disable-ssl
102 endif
104 ifneq ($(BR2_PACKAGE_PYTHON_CODECSCJK),y)
105 PYTHON_CONF_OPTS += --disable-codecs-cjk
106 endif
108 ifneq ($(BR2_PACKAGE_PYTHON_UNICODEDATA),y)
109 PYTHON_CONF_OPTS += --disable-unicodedata
110 endif
112 # Default is UCS2 w/o a conf opt
113 ifeq ($(BR2_PACKAGE_PYTHON_UCS4),y)
114 # host-python must have the same UCS2/4 configuration as the target
115 # python
116 HOST_PYTHON_CONF_OPTS += --enable-unicode=ucs4
117 PYTHON_CONF_OPTS += --enable-unicode=ucs4
118 endif
120 ifeq ($(BR2_PACKAGE_PYTHON_BZIP2),y)
121 PYTHON_DEPENDENCIES += bzip2
122 else
123 PYTHON_CONF_OPTS += --disable-bz2
124 endif
126 ifeq ($(BR2_PACKAGE_PYTHON_ZLIB),y)
127 PYTHON_DEPENDENCIES += zlib
128 else
129 PYTHON_CONF_OPTS += --disable-zlib
130 endif
132 ifeq ($(BR2_PACKAGE_PYTHON_HASHLIB),y)
133 PYTHON_DEPENDENCIES += openssl
134 else
135 PYTHON_CONF_OPTS += --disable-hashlib
136 endif
138 ifeq ($(BR2_PACKAGE_PYTHON_OSSAUDIODEV),y)
139 PYTHON_CONF_OPTS += --enable-ossaudiodev
140 else
141 PYTHON_CONF_OPTS += --disable-ossaudiodev
142 endif
144 # Make python believe we don't have 'hg' and 'svn', so that it doesn't
145 # try to communicate over the network during the build.
146 PYTHON_CONF_ENV += \
147 ac_cv_have_long_long_format=yes \
148 ac_cv_file__dev_ptmx=yes \
149 ac_cv_file__dev_ptc=yes \
150 ac_cv_working_tzset=yes \
151 ac_cv_prog_HAS_HG=/bin/false \
152 ac_cv_prog_SVNVERSION=/bin/false
154 # GCC is always compliant with IEEE754
155 ifeq ($(BR2_ENDIAN),"LITTLE")
156 PYTHON_CONF_ENV += ac_cv_little_endian_double=yes
157 else
158 PYTHON_CONF_ENV += ac_cv_big_endian_double=yes
159 endif
161 PYTHON_CONF_OPTS += \
162 --without-cxx-main \
163 --without-doc-strings \
164 --with-system-ffi \
165 --disable-pydoc \
166 --disable-test-modules \
167 --disable-lib2to3 \
168 --disable-gdbm \
169 --disable-tk \
170 --disable-nis \
171 --disable-dbm \
172 --disable-pyo-build \
173 --disable-pyc-build
175 # This is needed to make sure the Python build process doesn't try to
176 # regenerate those files with the pgen program. Otherwise, it builds
177 # pgen for the target, and tries to run it on the host.
179 define PYTHON_TOUCH_GRAMMAR_FILES
180 touch $(@D)/Include/graminit.h $(@D)/Python/graminit.c
181 endef
183 PYTHON_POST_PATCH_HOOKS += PYTHON_TOUCH_GRAMMAR_FILES
186 # Remove useless files. In the config/ directory, only the Makefile
187 # and the pyconfig.h files are needed at runtime.
189 # idle & smtpd.py have bad shebangs and are mostly samples
191 define PYTHON_REMOVE_USELESS_FILES
192 rm -f $(TARGET_DIR)/usr/bin/python$(PYTHON_VERSION_MAJOR)-config
193 rm -f $(TARGET_DIR)/usr/bin/python2-config
194 rm -f $(TARGET_DIR)/usr/bin/python-config
195 rm -f $(TARGET_DIR)/usr/bin/smtpd.py
196 for i in `find $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/config/ \
197 -type f -not -name pyconfig.h -a -not -name Makefile` ; do \
198 rm -f $$i ; \
199 done
200 endef
202 PYTHON_POST_INSTALL_TARGET_HOOKS += PYTHON_REMOVE_USELESS_FILES
205 # Make sure libpython gets stripped out on target
207 define PYTHON_ENSURE_LIBPYTHON_STRIPPED
208 chmod u+w $(TARGET_DIR)/usr/lib/libpython$(PYTHON_VERSION_MAJOR)*.so
209 endef
211 PYTHON_POST_INSTALL_TARGET_HOOKS += PYTHON_ENSURE_LIBPYTHON_STRIPPED
213 # Always install the python symlink in the target tree
214 define PYTHON_INSTALL_TARGET_PYTHON_SYMLINK
215 ln -sf python2 $(TARGET_DIR)/usr/bin/python
216 endef
218 PYTHON_POST_INSTALL_TARGET_HOOKS += PYTHON_INSTALL_TARGET_PYTHON_SYMLINK
220 # Always install the python-config symlink in the staging tree
221 define PYTHON_INSTALL_STAGING_PYTHON_CONFIG_SYMLINK
222 ln -sf python2-config $(STAGING_DIR)/usr/bin/python-config
223 endef
225 PYTHON_POST_INSTALL_STAGING_HOOKS += PYTHON_INSTALL_STAGING_PYTHON_CONFIG_SYMLINK
227 PYTHON_AUTORECONF = YES
229 # Some packages may have build scripts requiring python2.
230 # Only install the python symlink in the host tree if python3 is not enabled
231 # for the target, otherwise the default python program may be missing.
232 ifneq ($(BR2_PACKAGE_PYTHON3),y)
233 define HOST_PYTHON_INSTALL_PYTHON_SYMLINK
234 ln -sf python2 $(HOST_DIR)/usr/bin/python
235 ln -sf python2-config $(HOST_DIR)/usr/bin/python-config
236 endef
238 HOST_PYTHON_POST_INSTALL_HOOKS += HOST_PYTHON_INSTALL_PYTHON_SYMLINK
239 endif
241 # Provided to other packages
242 PYTHON_PATH = $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/sysconfigdata/:$(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/site-packages/
244 $(eval $(autotools-package))
245 $(eval $(host-autotools-package))
247 ifeq ($(BR2_REPRODUCIBLE),y)
248 define PYTHON_FIX_TIME
249 find $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR) -name '*.py' -print0 | \
250 xargs -0 --no-run-if-empty touch -d @$(SOURCE_DATE_EPOCH)
251 endef
252 endif
254 define PYTHON_CREATE_PYC_FILES
255 $(PYTHON_FIX_TIME)
256 PYTHONPATH="$(PYTHON_PATH)" \
257 $(HOST_DIR)/usr/bin/python$(PYTHON_VERSION_MAJOR) \
258 support/scripts/pycompile.py $(if $(BR2_REPRODUCIBLE),--force) \
259 $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)
260 endef
262 ifeq ($(BR2_PACKAGE_PYTHON_PYC_ONLY)$(BR2_PACKAGE_PYTHON_PY_PYC),y)
263 PYTHON_TARGET_FINALIZE_HOOKS += PYTHON_CREATE_PYC_FILES
264 endif
266 ifeq ($(BR2_PACKAGE_PYTHON_PYC_ONLY),y)
267 define PYTHON_REMOVE_PY_FILES
268 find $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR) -name '*.py' -print0 | \
269 xargs -0 --no-run-if-empty rm -f
270 endef
271 PYTHON_TARGET_FINALIZE_HOOKS += PYTHON_REMOVE_PY_FILES
272 endif
274 # Normally, *.pyc files should not have been compiled, but just in
275 # case, we make sure we remove all of them.
276 ifeq ($(BR2_PACKAGE_PYTHON_PY_ONLY),y)
277 define PYTHON_REMOVE_PYC_FILES
278 find $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR) -name '*.pyc' -print0 | \
279 xargs -0 --no-run-if-empty rm -f
280 endef
281 PYTHON_TARGET_FINALIZE_HOOKS += PYTHON_REMOVE_PYC_FILES
282 endif
284 # In all cases, we don't want to keep the optimized .pyo files
285 define PYTHON_REMOVE_PYO_FILES
286 find $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR) -name '*.pyo' -print0 | \
287 xargs -0 --no-run-if-empty rm -f
288 endef
289 PYTHON_TARGET_FINALIZE_HOOKS += PYTHON_REMOVE_PYO_FILES