kumquat-buildroot/package/python/python.mk
Thomas Petazzoni e3418f69cf python: convert to autotargets, bump to 2.7.1, many improvements
This commit does a number of changes and improvements to the Python
interpreter package :

 * It converts the .mk file to the AUTOTARGETS infrastructure. Even
   though Python uses only autoconf and not automake, the AUTOTARGETS
   is a fairly good fit for the Python interpreter, so we make use of
   it.

 * It bumps the version to 2.7.1. As this is a minor release compared
   to 2.7, there are no particular changes needed because of this
   bump. All changes done to the package are cleanups and improvements
   unrelated to the version bump.

 * It uses the system libffi. Until now, Python was building its own
   libffi (a library used by interprets to build code that makes
   function call at runtime). Using the Python internal libffi was not
   working as Python was not passing the appropriate arguments down to
   libffi ./configure script. And it sounded better to use a
   system-wide libffi, that could potentially be used by other
   packages as well. This libffi is needed for the ctypes Python
   module.

 * Remove all "depends on BR2_PACKAGE_PYTHON" by moving all
   Python-related options under a "if BR2_PACKAGE_PYTHON ... endif"
   condition.

 * Make the installation of pre-compiled Python modules (.pyc) the
   default, since they are smaller and do not need to be compiled on
   the target. It is still possible to install uncompiled modules, or
   both the uncompiled and pre-compiled versions.

 * The options to select the set of Python modules to compile has been
   moved to a submenu.

 * The codecscjk (Japanese, Korean and Chinese codecs) module is no
   longer enabled by default.

 * The commented options for gdbm and nis in Python have been
   removed. Those were not supported, so let's get rid of unused code.

 * The option for the tkinker module in Python has been removed, since
   we don't have a package for Tk in Buildroot.

 * Options for the bzip2, sqlite and zlib modules have been added,
   since those modules have external dependencies.

 * The set of patches has been completely reworked and extended, with
   more fine-grained patches and newer functionalities. The patches
   are split in two categories:

    - Patches that make various modifications to the Python build
      system to support cross-compilation or make some minor
      modifications. Those patches are numbered from 0 to 100.

    - Patches that add configuration options to the Python build
      system in order to enable/disable the compilation of Python
      extensions or modules (test modules, pydoc, lib2to3, sqlite, tk,
      curses, expat, codecs-cjk, nis, unicodedata, database modules,
      ssl, bzip2, zlib). These patches are numbered from 100 to 200.

   All features of the previous four patches are preserved, but they
   are organized differently and the patches have been renamed. This
   makes it difficult to see the differences from the existing
   patches.

 * The host Python interpreter is now installed in $(HOST_DIR), since
   it is used to build third party Python modules.

 * The BR2_PACKAGE_PYTHON_DEV option is removed since
   BR2_HAVE_DEVFILES already does the necessary work.

 * The "make -i install" workaround introduced by Maxime Ripard is no
   longer needed. It was caused by the compilation of the tests that
   required the unicodedata module (which wasn't built in the host
   Python interpreter). Since we no longer compile the Python tests,
   the problem doesn't exist anymore and we can avoid this "-i"
   option.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2011-01-25 08:59:57 +01:00

149 lines
3.5 KiB
Makefile

#############################################################
#
# python
#
#############################################################
PYTHON_VERSION_MAJOR = 2.7
PYTHON_VERSION = $(PYTHON_VERSION_MAJOR).1
PYTHON_SOURCE = Python-$(PYTHON_VERSION).tar.bz2
PYTHON_SITE = http://python.org/ftp/python/$(PYTHON_VERSION)
# Python needs itself and a "pgen" program to build itself, both being
# provided in the Python sources. So in order to cross-compile Python,
# we need to build a host Python first. This host Python is also
# installed in $(HOST_DIR), as it is needed when cross-compiling
# third-party Python modules.
HOST_PYTHON_CONF_OPT += \
--without-cxx-main \
--disable-sqlite3 \
--disable-tk \
--with-expat=none \
--disable-curses \
--disable-codecs-cjk \
--disable-nis \
--disable-unicodedata \
--disable-dbm \
--disable-gdbm \
--disable-bsddb \
--disable-test-modules \
--disable-bz2 \
--disable-zlib \
--disable-ssl
HOST_PYTHON_MAKE_ENV = \
PYTHON_MODULES_INCLUDE=$(HOST_DIR)/usr/include \
PYTHON_MODULES_LIB="$(HOST_DIR)/lib $(HOST_DIR)/usr/lib"
HOST_PYTHON_AUTORECONF = YES
PYTHON_DEPENDENCIES = host-python libffi
PYTHON_INSTALL_STAGING = YES
ifeq ($(BR2_PACKAGE_PYTHON_READLINE),y)
PYTHON_DEPENDENCIES += readline
endif
ifeq ($(BR2_PACKAGE_PYTHON_CURSES),y)
PYTHON_DEPENDENCIES += ncurses
else
PYTHON_CONF_OPT += --disable-curses
endif
ifeq ($(BR2_PACKAGE_PYTHON_PYEXPAT),y)
PYTHON_DEPENDENCIES += expat
PYTHON_CONF_OPT += --with-expat=system
else
PYTHON_CONF_OPT += --with-expat=none
endif
ifeq ($(BR2_PACKAGE_PYTHON_BSDDB),y)
PYTHON_DEPENDENCIES += berkeleydb
else
PYTHON_CONF_OPT += --disable-bsddb
endif
ifeq ($(BR2_PACKAGE_PYTHON_SQLITE),y)
PYTHON_DEPENDENCIES += sqlite
else
PYTHON_CONF_OPT += --disable-sqlite3
endif
ifeq ($(BR2_PACKAGE_PYTHON_SSL),y)
PYTHON_DEPENDENCIES += openssl
else
PYTHON_CONF_OPT += --disable-ssl
endif
ifneq ($(BR2_PACKAGE_PYTHON_CODECSCJK),y)
PYTHON_CONF_OPT += --disable-codecs-cjk
endif
ifneq ($(BR2_PACKAGE_PYTHON_UNICODEDATA),y)
PYTHON_CONF_OPT += --disable-unicodedata
endif
ifeq ($(BR2_PACKAGE_PYTHON_BZIP2),y)
PYTHON_DEPENDENCIES += bzip2
else
PYTHON_CONF_OPT += --disable-bz2
endif
ifeq ($(BR2_PACKAGE_PYTHON_ZLIB),y)
PYTHON_DEPENDENCIES += zlib
else
PYTHON_CONF_OPT += --disable-zlib
endif
PYTHON_CONF_ENV += \
PYTHON_FOR_BUILD=$(HOST_PYTHON_DIR)/python \
PGEN_FOR_BUILD=$(HOST_PYTHON_DIR)/Parser/pgen \
ac_cv_have_long_long_format=yes
PYTHON_CONF_OPT += \
--without-cxx-main \
--without-doc-strings \
--with-system-ffi \
--disable-pydoc \
--disable-test-modules \
--disable-lib2to3 \
--disable-gdbm \
--disable-tk \
--disable-nis \
--disable-dbm
PYTHON_MAKE_ENV = \
PYTHON_MODULES_INCLUDE=$(STAGING_DIR)/usr/include \
PYTHON_MODULES_LIB="$(STAGING_DIR)/lib $(STAGING_DIR)/usr/lib"
#
# Development files removal
#
define PYTHON_REMOVE_DEVFILES
rm -f $(TARGET_DIR)/usr/bin/python$(PYTHON_VERSION_MAJOR)-config
rm -f $(TARGET_DIR)/usr/bin/python-config
endef
ifneq ($(BR2_HAVE_DEVFILES),y)
PYTHON_POST_INSTALL_TARGET_HOOKS += PYTHON_REMOVE_DEVFILES
endif
#
# Remove useless files. In the config/ directory, only the Makefile
# and the pyconfig.h files are needed at runtime.
#
define PYTHON_REMOVE_USELESS_FILES
for i in `find $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/config/ \
-type f -not -name pyconfig.h -a -not -name Makefile` ; do \
rm -f $$i ; \
done
endef
PYTHON_POST_INSTALL_TARGET_HOOKS += PYTHON_REMOVE_USELESS_FILES
PYTHON_AUTORECONF = YES
$(eval $(call AUTOTARGETS,package,python))
$(eval $(call AUTOTARGETS,package,python,host))