]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blobdiff - package/python/python.mk
Globally replace $(HOST_DIR)/usr/bin with $(HOST_DIR)/bin
[coffee/buildroot.git] / package / python / python.mk
index 819d32b9d64c236770a7d5d1bf920a43748ba80d..30c55b7704aa3828e4d9df8c9277a8b619c16668 100644 (file)
@@ -5,10 +5,10 @@
 ################################################################################
 
 PYTHON_VERSION_MAJOR = 2.7
-PYTHON_VERSION = $(PYTHON_VERSION_MAJOR).11
+PYTHON_VERSION = $(PYTHON_VERSION_MAJOR).13
 PYTHON_SOURCE = Python-$(PYTHON_VERSION).tar.xz
 PYTHON_SITE = http://python.org/ftp/python/$(PYTHON_VERSION)
-PYTHON_LICENSE = Python software foundation license v2, others
+PYTHON_LICENSE = Python-2.0, others
 PYTHON_LICENSE_FILES = LICENSE
 PYTHON_LIBTOOL_PATCH = NO
 
@@ -17,30 +17,34 @@ PYTHON_LIBTOOL_PATCH = NO
 # also installed in $(HOST_DIR), as it is needed when cross-compiling
 # third-party Python modules.
 
-HOST_PYTHON_CONF_OPTS +=       \
-       --enable-static         \
-       --without-cxx-main      \
-       --disable-sqlite3       \
-       --disable-tk            \
-       --with-expat=system     \
-       --disable-curses        \
-       --disable-codecs-cjk    \
-       --disable-nis           \
-       --enable-unicodedata    \
-       --disable-dbm           \
-       --disable-gdbm          \
-       --disable-bsddb         \
-       --disable-test-modules  \
-       --disable-bz2           \
-       --disable-ssl           \
-       --disable-ossaudiodev   \
+HOST_PYTHON_CONF_OPTS += \
+       --enable-static \
+       --without-cxx-main \
+       --disable-sqlite3 \
+       --disable-tk \
+       --with-expat=system \
+       --disable-curses \
+       --disable-codecs-cjk \
+       --disable-nis \
+       --enable-unicodedata \
+       --disable-dbm \
+       --disable-gdbm \
+       --disable-bsddb \
+       --disable-test-modules \
+       --disable-bz2 \
+       --disable-ssl \
+       --disable-ossaudiodev \
        --disable-pyo-build
 
 # Make sure that LD_LIBRARY_PATH overrides -rpath.
 # This is needed because libpython may be installed at the same time that
 # python is called.
+# Make python believe we don't have 'hg' and 'svn', so that it doesn't
+# try to communicate over the network during the build.
 HOST_PYTHON_CONF_ENV += \
-       LDFLAGS="$(HOST_LDFLAGS) -Wl,--enable-new-dtags"
+       LDFLAGS="$(HOST_LDFLAGS) -Wl,--enable-new-dtags" \
+       ac_cv_prog_HAS_HG=/bin/false \
+       ac_cv_prog_SVNVERSION=/bin/false
 
 # Building host python in parallel sometimes triggers a "Bus error"
 # during the execution of "./python setup.py build" in the
@@ -50,7 +54,7 @@ HOST_PYTHON_CONF_ENV += \
 # MAKE1 has shown to workaround the problem.
 HOST_PYTHON_MAKE = $(MAKE1)
 
-PYTHON_DEPENDENCIES = host-python libffi
+PYTHON_DEPENDENCIES = host-python libffi $(TARGET_NLS_DEPENDENCIES)
 
 HOST_PYTHON_DEPENDENCIES = host-expat host-zlib
 
@@ -58,6 +62,8 @@ PYTHON_INSTALL_STAGING = YES
 
 ifeq ($(BR2_PACKAGE_PYTHON_READLINE),y)
 PYTHON_DEPENDENCIES += readline
+else
+PYTHON_CONF_OPTS += --disable-readline
 endif
 
 ifeq ($(BR2_PACKAGE_PYTHON_CURSES),y)
@@ -101,6 +107,9 @@ endif
 
 # Default is UCS2 w/o a conf opt
 ifeq ($(BR2_PACKAGE_PYTHON_UCS4),y)
+# host-python must have the same UCS2/4 configuration as the target
+# python
+HOST_PYTHON_CONF_OPTS += --enable-unicode=ucs4
 PYTHON_CONF_OPTS += --enable-unicode=ucs4
 endif
 
@@ -118,6 +127,8 @@ endif
 
 ifeq ($(BR2_PACKAGE_PYTHON_HASHLIB),y)
 PYTHON_DEPENDENCIES += openssl
+else
+PYTHON_CONF_OPTS += --disable-hashlib
 endif
 
 ifeq ($(BR2_PACKAGE_PYTHON_OSSAUDIODEV),y)
@@ -126,24 +137,36 @@ else
 PYTHON_CONF_OPTS += --disable-ossaudiodev
 endif
 
+# Make python believe we don't have 'hg' and 'svn', so that it doesn't
+# try to communicate over the network during the build.
 PYTHON_CONF_ENV += \
        ac_cv_have_long_long_format=yes \
        ac_cv_file__dev_ptmx=yes \
        ac_cv_file__dev_ptc=yes \
-       ac_cv_working_tzset=yes
+       ac_cv_working_tzset=yes \
+       ac_cv_prog_HAS_HG=/bin/false \
+       ac_cv_prog_SVNVERSION=/bin/false
+
+# GCC is always compliant with IEEE754
+ifeq ($(BR2_ENDIAN),"LITTLE")
+PYTHON_CONF_ENV += ac_cv_little_endian_double=yes
+else
+PYTHON_CONF_ENV += ac_cv_big_endian_double=yes
+endif
 
 PYTHON_CONF_OPTS += \
-       --without-cxx-main      \
-       --without-doc-strings   \
-       --with-system-ffi       \
-       --disable-pydoc         \
-       --disable-test-modules  \
-       --disable-lib2to3       \
-       --disable-gdbm          \
-       --disable-tk            \
-       --disable-nis           \
-       --disable-dbm           \
-       --disable-pyo-build
+       --without-cxx-main \
+       --without-doc-strings \
+       --with-system-ffi \
+       --disable-pydoc \
+       --disable-test-modules \
+       --disable-lib2to3 \
+       --disable-gdbm \
+       --disable-tk \
+       --disable-nis \
+       --disable-dbm \
+       --disable-pyo-build \
+       --disable-pyc-build
 
 # This is needed to make sure the Python build process doesn't try to
 # regenerate those files with the pgen program. Otherwise, it builds
@@ -204,8 +227,8 @@ PYTHON_AUTORECONF = YES
 # for the target, otherwise the default python program may be missing.
 ifneq ($(BR2_PACKAGE_PYTHON3),y)
 define HOST_PYTHON_INSTALL_PYTHON_SYMLINK
-       ln -sf python2 $(HOST_DIR)/usr/bin/python
-       ln -sf python2-config $(HOST_DIR)/usr/bin/python-config
+       ln -sf python2 $(HOST_DIR)/bin/python
+       ln -sf python2-config $(HOST_DIR)/bin/python-config
 endef
 
 HOST_PYTHON_POST_INSTALL_HOOKS += HOST_PYTHON_INSTALL_PYTHON_SYMLINK
@@ -217,16 +240,47 @@ PYTHON_PATH = $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/sysconfigdata/
 $(eval $(autotools-package))
 $(eval $(host-autotools-package))
 
+ifeq ($(BR2_REPRODUCIBLE),y)
+define PYTHON_FIX_TIME
+       find $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR) -name '*.py' -print0 | \
+               xargs -0 --no-run-if-empty touch -d @$(SOURCE_DATE_EPOCH)
+endef
+endif
+
+define PYTHON_CREATE_PYC_FILES
+       $(PYTHON_FIX_TIME)
+       PYTHONPATH="$(PYTHON_PATH)" \
+       cd $(TARGET_DIR) && $(HOST_DIR)/bin/python$(PYTHON_VERSION_MAJOR) \
+               $(TOPDIR)/support/scripts/pycompile.py \
+               $(if $(BR2_REPRODUCIBLE),--force) \
+               usr/lib/python$(PYTHON_VERSION_MAJOR)
+endef
+
+ifeq ($(BR2_PACKAGE_PYTHON_PYC_ONLY)$(BR2_PACKAGE_PYTHON_PY_PYC),y)
+PYTHON_TARGET_FINALIZE_HOOKS += PYTHON_CREATE_PYC_FILES
+endif
+
 ifeq ($(BR2_PACKAGE_PYTHON_PYC_ONLY),y)
 define PYTHON_REMOVE_PY_FILES
-       find $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR) -name '*.py' -print0 | xargs -0 rm -f
+       find $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR) -name '*.py' -print0 | \
+               xargs -0 --no-run-if-empty rm -f
 endef
-TARGET_FINALIZE_HOOKS += PYTHON_REMOVE_PY_FILES
+PYTHON_TARGET_FINALIZE_HOOKS += PYTHON_REMOVE_PY_FILES
 endif
 
+# Normally, *.pyc files should not have been compiled, but just in
+# case, we make sure we remove all of them.
 ifeq ($(BR2_PACKAGE_PYTHON_PY_ONLY),y)
 define PYTHON_REMOVE_PYC_FILES
-       find $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR) -name '*.pyc' -print0 | xargs -0 rm -f
+       find $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR) -name '*.pyc' -print0 | \
+               xargs -0 --no-run-if-empty rm -f
 endef
-TARGET_FINALIZE_HOOKS += PYTHON_REMOVE_PYC_FILES
+PYTHON_TARGET_FINALIZE_HOOKS += PYTHON_REMOVE_PYC_FILES
 endif
+
+# In all cases, we don't want to keep the optimized .pyo files
+define PYTHON_REMOVE_PYO_FILES
+       find $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR) -name '*.pyo' -print0 | \
+               xargs -0 --no-run-if-empty rm -f
+endef
+PYTHON_TARGET_FINALIZE_HOOKS += PYTHON_REMOVE_PYO_FILES