--- /dev/null
+setup.py: do not add invalid header locations
+
+This piece of code incorrectly adds /usr/include to
+self.compiler.include_dirs, and results in the following invalid
+compilation line:
+
+/home/thomas/projets/buildroot/output/host/usr/bin/arm-none-linux-gnueabi-gcc -fPIC \
+ -fno-strict-aliasing -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 \
+ -pipe -Os -DNDEBUG -g -O3 -Wall -Wstrict-prototypes \
+ -I/usr/include -I. -IInclude -I./Include \
+ -I/home/thomas/projets/buildroot/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/include \
+ -I/home/thomas/projets/buildroot/output/build/python-2.7.6/Include \
+ -I/home/thomas/projets/buildroot/output/build/python-2.7.6 \
+ -c /home/thomas/projets/buildroot/output/build/python-2.7.6/Modules/mathmodule.c \
+ -o build/temp.linux2-arm-2.7/home/thomas/projets/buildroot/output/build/python-2.7.6/Modules/mathmodule.o
+cc1: warning: include location "/usr/include" is unsafe for cross-compilation [-Wpoison-system-directories]
+[...]
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+Index: b/setup.py
+===================================================================
+--- a/setup.py
++++ b/setup.py
+@@ -480,7 +480,7 @@
+ for directory in reversed(options.dirs):
+ add_dir_to_list(dir_list, directory)
+
+- if os.path.normpath(sys.prefix) != '/usr' \
++ if False and os.path.normpath(sys.prefix) != '/usr' \
+ and not sysconfig.get_config_var('PYTHONFRAMEWORK'):
+ # OSX note: Don't add LIBDIR and INCLUDEDIR to building a framework
+ # (PYTHONFRAMEWORK is set) to avoid # linking problems when
--- /dev/null
+Fix get_python_inc() for cross-compilation
+
+When we are cross compiling, doing os.path.dirname(sys.executable) to
+get the build directory is incorrect, because we're executing the host
+Python to build things for the target. Instead, we should use the
+project_base variable.
+
+This fixes cross-compilation, which was adding incorrect header paths
+pointing to the location where the host Python was built:
+
+/home/thomas/projets/buildroot/output/host/usr/bin/arm-none-linux-gnueabi-gcc -fPIC -fno-strict-aliasing \
+ -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -pipe -Os -DNDEBUG -g -O3 -Wall -Wstrict-prototypes \
+ -I/usr/include -I. -IInclude -I./Include -I/home/thomas/projets/buildroot/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/include \
+ -I/home/thomas/projets/buildroot/output/host/usr/bin/Include -I/home/thomas/projets/buildroot/output/host/usr/bin \
+ -c /home/thomas/projets/buildroot/output/build/python-2.7.6/Modules/_struct.c \
+ -o build/temp.linux2-arm-2.7/home/thomas/projets/buildroot/output/build/python-2.7.6/Modules/_struct.o
+
+This patch allows to fix the
+/home/thomas/projets/buildroot/output/host/usr/bin/Include and
+/home/thomas/projets/buildroot/output/host/usr/bin paths that are
+incorrectly added to the header paths.
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+Index: b/Lib/distutils/sysconfig.py
+===================================================================
+--- a/Lib/distutils/sysconfig.py
++++ b/Lib/distutils/sysconfig.py
+@@ -79,7 +79,7 @@
+
+ if os.name == "posix":
+ if python_build:
+- buildir = os.path.dirname(sys.executable)
++ buildir = project_base
+ if plat_specific:
+ # python.h is located in the buildir
+ inc_dir = buildir
--- /dev/null
+Change the install location of _sysconfigdata.py
+
+The _sysconfigdata.py module contains definitions that are needed when
+building Python modules. In cross-compilation mode, when building
+Python extensions for the target, we need to use the _sysconfigdata.py
+of the target Python while executing the host Python.
+
+However until now, the _sysconfigdata.py module was installed in
+build/lib.<arch>-<version> directory, together with a number of
+architecture-specific shared objects, which cannot be used with the
+host Python.
+
+To solve this problem, this patch moves _sysconfigdata.py to a
+separate location, build/sysconfigdata.<arch>-<version>/, and only
+this directory gets added to the PYTHONPATH of the host Python
+interpreter when building Python modules for the target.
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+
+Index: b/Makefile.pre.in
+===================================================================
+--- a/Makefile.pre.in
++++ b/Makefile.pre.in
+@@ -462,6 +462,9 @@
+ rm -f ./pybuilddir.txt ; \
+ exit 1 ; \
+ fi
++ echo `cat pybuilddir.txt`/sysconfigdata > pysysconfigdatadir.txt
++ mkdir -p `cat pysysconfigdatadir.txt`
++ cp `cat pybuilddir.txt`/_sysconfigdata.py `cat pysysconfigdatadir.txt`
+
+ # Build the shared modules
+ # Under GNU make, MAKEFLAGS are sorted and normalized; the 's' for
+@@ -1002,7 +1005,7 @@
+ else true; \
+ fi; \
+ done
+- @for i in $(srcdir)/Lib/*.py `cat pybuilddir.txt`/_sysconfigdata.py $(srcdir)/Lib/*.doc $(srcdir)/Lib/*.egg-info ; \
++ @for i in $(srcdir)/Lib/*.py $(srcdir)/Lib/*.doc $(srcdir)/Lib/*.egg-info ; \
+ do \
+ if test -x $$i; then \
+ $(INSTALL_SCRIPT) $$i $(DESTDIR)$(LIBDEST); \
+@@ -1012,6 +1015,11 @@
+ echo $(INSTALL_DATA) $$i $(LIBDEST); \
+ fi; \
+ done
++ $(INSTALL_DATA) `cat pysysconfigdatadir.txt`/_sysconfigdata.py \
++ $(DESTDIR)$(LIBDEST)
++ mkdir -p $(DESTDIR)$(LIBDEST)/sysconfigdata
++ $(INSTALL_DATA) `cat pysysconfigdatadir.txt`/_sysconfigdata.py \
++ $(DESTDIR)$(LIBDEST)/sysconfigdata
+ @for d in $(LIBSUBDIRS); \
+ do \
+ a=$(srcdir)/Lib/$$d; \
+@@ -1337,7 +1345,7 @@
+ Modules/Setup Modules/Setup.local Modules/Setup.config \
+ Modules/ld_so_aix Modules/python.exp Misc/python.pc
+ -rm -f python*-gdb.py
+- -rm -f pybuilddir.txt
++ -rm -f pybuilddir.txt pysysconfigdatadir.txt
+ find $(srcdir)/[a-zA-Z]* '(' -name '*.fdc' -o -name '*~' \
+ -o -name '[@,#]*' -o -name '*.old' \
+ -o -name '*.orig' -o -name '*.rej' \
+Index: b/configure.ac
+===================================================================
+--- a/configure.ac
++++ b/configure.ac
+@@ -33,7 +33,7 @@
+ AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found])
+ fi
+ AC_MSG_RESULT($interp)
+- PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp
++ PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pysysconfigdatadir.txt && echo $(abs_builddir)/`cat pysysconfigdatadir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp
+ fi
+ elif test "$cross_compiling" = maybe; then
+ AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH])
--- /dev/null
+Index: b/Makefile.pre.in
+===================================================================
+--- a/Makefile.pre.in
++++ b/Makefile.pre.in
+@@ -1050,24 +1050,32 @@
+ $(INSTALL_DATA) $(srcdir)/Modules/xxmodule.c \
+ $(DESTDIR)$(LIBDEST)/distutils/tests ; \
+ fi
++ifeq (@PYC_BUILD@,yes)
+ PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+ $(PYTHON_FOR_BUILD) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
+ -d $(LIBDEST) -f \
+ -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
+ $(DESTDIR)$(LIBDEST)
++endif
++ifeq (@PYO_BUILD@,yes)
+ PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+ $(PYTHON_FOR_BUILD) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
+ -d $(LIBDEST) -f \
+ -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
+ $(DESTDIR)$(LIBDEST)
++endif
++ifeq (@PYC_BUILD@,yes)
+ -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+ $(PYTHON_FOR_BUILD) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
+ -d $(LIBDEST)/site-packages -f \
+ -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
++endif
++ifeq (@PYO_BUILD@,yes)
+ -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+ $(PYTHON_FOR_BUILD) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
+ -d $(LIBDEST)/site-packages -f \
+ -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
++endif
+ -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+ $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt
+ -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+Index: b/configure.ac
+===================================================================
+--- a/configure.ac
++++ b/configure.ac
+@@ -736,6 +736,17 @@
+ ;;
+ esac
+
++AC_SUBST(PYC_BUILD)
++
++AC_ARG_ENABLE(pyc-build,
++ AS_HELP_STRING([--disable-pyc-build], [disable build of pyc files]),
++ [ PYC_BUILD="${enableval}" ], [ PYC_BUILD=yes ])
++
++AC_SUBST(PYO_BUILD)
++
++AC_ARG_ENABLE(pyo-build,
++ AS_HELP_STRING([--disable-pyo-build], [disable build of pyo files]),
++ [ PYO_BUILD="${enableval}" ], [ PYO_BUILD=yes ])
+
+ AC_SUBST(LIBRARY)
+ AC_MSG_CHECKING(LIBRARY)
--- /dev/null
+Index: b/configure.ac
+===================================================================
+--- a/configure.ac
++++ b/configure.ac
+@@ -3346,7 +3346,7 @@
+
+ AC_MSG_RESULT($ac_cv_buggy_getaddrinfo)
+
+-if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
++if test $have_getaddrinfo = no || test "$cross_compiling" != "yes" -a "$ac_cv_buggy_getaddrinfo" = yes
+ then
+ if test $ipv6 = yes
+ then
--- /dev/null
+Index: b/Makefile.pre.in
+===================================================================
+--- a/Makefile.pre.in
++++ b/Makefile.pre.in
+@@ -156,6 +156,8 @@
+ # configure script arguments
+ CONFIG_ARGS= @CONFIG_ARGS@
+
++# disabled extensions
++DISABLED_EXTENSIONS= @DISABLED_EXTENSIONS@
+
+ # Subdirectories with code
+ SRCDIRS= @SRCDIRS@
+@@ -477,6 +479,7 @@
+ esac; \
+ $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
+ _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
++ DISABLED_EXTENSIONS="$(DISABLED_EXTENSIONS)" \
+ $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
+
+ # Build static library
+@@ -1191,7 +1194,8 @@
+ # Install the dynamically loadable modules
+ # This goes into $(exec_prefix)
+ sharedinstall: sharedmods
+- $(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \
++ $(RUNSHARED) DISABLED_EXTENSIONS="$(DISABLED_EXTENSIONS)" \
++ $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \
+ --prefix=$(prefix) \
+ --install-scripts=$(BINDIR) \
+ --install-platlib=$(DESTSHARED) \
+Index: b/configure.ac
+===================================================================
+--- a/configure.ac
++++ b/configure.ac
+@@ -2284,6 +2284,8 @@
+
+ AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
+
++AC_SUBST(DISABLED_EXTENSIONS)
++
+ # Check for use of the system expat library
+ AC_MSG_CHECKING(for --with-system-expat)
+ AC_ARG_WITH(system_expat,
+Index: b/setup.py
+===================================================================
+--- a/setup.py
++++ b/setup.py
+@@ -33,7 +33,10 @@
+ COMPILED_WITH_PYDEBUG = ('--with-pydebug' in sysconfig.get_config_var("CONFIG_ARGS"))
+
+ # This global variable is used to hold the list of modules to be disabled.
+-disabled_module_list = []
++try:
++ disabled_module_list = sysconfig.get_config_var("DISABLED_EXTENSIONS").split(" ")
++except KeyError:
++ disabled_module_list = list()
+
+ def add_dir_to_list(dirlist, dir):
+ """Add the directory 'dir' to the list 'dirlist' (at the front) if
--- /dev/null
+Adjust library/header paths for cross-compilation
+
+When cross-compiling third-party extensions, the get_python_inc() or
+get_python_lib() can be called, to return the path to headers or
+libraries. However, they use the sys.prefix of the host Python, which
+returns incorrect paths when cross-compiling (paths pointing to host
+headers and libraries).
+
+In order to fix this, we introduce the _python_sysroot, _python_prefix
+and _python_exec_prefix variables, that allow to override these
+values, and get correct header/library paths when cross-compiling
+third-party Python modules.
+
+The _python_sysroot variable is also used to prefix the LIBDIR value
+taken from the sysconfigdata module.
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+
+Index: b/Lib/distutils/sysconfig.py
+===================================================================
+--- a/Lib/distutils/sysconfig.py
++++ b/Lib/distutils/sysconfig.py
+@@ -19,8 +19,13 @@
+ from distutils.errors import DistutilsPlatformError
+
+ # These are needed in a couple of spots, so just compute them once.
+-PREFIX = os.path.normpath(sys.prefix)
+-EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
++if "_python_sysroot" in os.environ:
++ _sysroot=os.environ.get('_python_sysroot')
++ PREFIX = os.path.normpath(_sysroot + os.environ.get('_python_prefix'))
++ EXEC_PREFIX = os.path.normpath(_sysroot + os.environ.get('_python_exec_prefix'))
++else:
++ PREFIX = os.path.normpath(sys.prefix)
++ EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
+
+ # Path to the base directory of the project. On Windows the binary may
+ # live in project/PCBuild9. If we're dealing with an x64 Windows build,
+Index: b/Lib/distutils/command/build_ext.py
+===================================================================
+--- a/Lib/distutils/command/build_ext.py
++++ b/Lib/distutils/command/build_ext.py
+@@ -237,7 +237,10 @@
+ if (sysconfig.get_config_var('Py_ENABLE_SHARED')):
+ if not sysconfig.python_build:
+ # building third party extensions
+- self.library_dirs.append(sysconfig.get_config_var('LIBDIR'))
++ libdir = sysconfig.get_config_var('LIBDIR')
++ if "_python_sysroot" in os.environ:
++ libdir = os.environ.get("_python_sysroot") + libdir
++ self.library_dirs.append(libdir)
+ else:
+ # building python standard extensions
+ self.library_dirs.append('.')
--- /dev/null
+Don't look in /usr/lib/termcap for libraries
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+
+
+Index: b/setup.py
+===================================================================
+--- a/setup.py
++++ b/setup.py
+@@ -764,12 +764,9 @@
+ pass # Issue 7384: Already linked against curses or tinfo.
+ elif curses_library:
+ readline_libs.append(curses_library)
+- elif self.compiler.find_library_file(lib_dirs +
+- ['/usr/lib/termcap'],
+- 'termcap'):
++ elif self.compiler.find_library_file(lib_dirs, 'termcap'):
+ readline_libs.append('termcap')
+ exts.append( Extension('readline', ['readline.c'],
+- library_dirs=['/usr/lib/termcap'],
+ extra_link_args=readline_extra_link_args,
+ libraries=readline_libs) )
+ else:
--- /dev/null
+Add a backport of http://bugs.python.org/issue16235 so we can use
+python-config for cross builds.
+This basically replaces the python version of python-config with a pure-shell
+version that's already preprocessed when installed and doesn't depend
+on the sysconfig import that usually leads to bad data/results.
+
+Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
+
+Index: b/configure.ac
+===================================================================
+--- a/configure.ac
++++ b/configure.ac
+@@ -882,6 +882,7 @@
+
+ # Other platforms follow
+ if test $enable_shared = "yes"; then
++ PY_ENABLE_SHARED=1
+ AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
+ case $ac_sys_system in
+ BeOS*)
+@@ -942,6 +943,7 @@
+
+ esac
+ else # shared is disabled
++ PY_ENABLE_SHARED=0
+ case $ac_sys_system in
+ CYGWIN*)
+ BLDLIBRARY='$(LIBRARY)'
+@@ -1918,6 +1920,9 @@
+ AC_SUBST(BLDSHARED)
+ AC_SUBST(CCSHARED)
+ AC_SUBST(LINKFORSHARED)
++AC_SUBST(PY_ENABLE_SHARED)
++LIBPL="${prefix}/lib/python${VERSION}/config"
++AC_SUBST(LIBPL)
+ # SO is the extension of shared libraries `(including the dot!)
+ # -- usually .so, .sl on HP-UX, .dll on Cygwin
+ AC_MSG_CHECKING(SO)
+@@ -4581,7 +4586,7 @@
+ AC_SUBST(ENSUREPIP)
+
+ # generate output files
+-AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
++AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc Misc/python-config.sh)
+ AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
+ AC_OUTPUT
+
+Index: b/Makefile.pre.in
+===================================================================
+--- a/Makefile.pre.in
++++ b/Makefile.pre.in
+@@ -166,7 +166,7 @@
+ SUBDIRSTOO= Include Lib Misc Demo
+
+ # Files and directories to be distributed
+-CONFIGFILES= configure configure.ac acconfig.h pyconfig.h.in Makefile.pre.in
++CONFIGFILES= configure configure.ac acconfig.h pyconfig.h.in Makefile.pre.in Misc/python-config.sh
+ DISTFILES= README ChangeLog $(CONFIGFILES)
+ DISTDIRS= $(SUBDIRS) $(SUBDIRSTOO) Ext-dummy
+ DIST= $(DISTFILES) $(DISTDIRS)
+@@ -410,7 +410,7 @@
+
+ # Default target
+ all: build_all
+-build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks
++build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks python-config
+
+ # Compile a binary with gcc profile guided optimization.
+ profile-opt:
+@@ -1101,10 +1101,12 @@
+ fi; \
+ cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen
+
+-python-config: $(srcdir)/Misc/python-config.in
++python-config: $(srcdir)/Misc/python-config.in Misc/python-config.sh
+ # Substitution happens here, as the completely-expanded BINDIR
+ # is not available in configure
+- sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config
++ sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config.py
++ # Replace makefile compat. variable references with shell script compat. ones; $(VAR) -> ${VAR}
++ sed -e 's,\$$(\([A-Za-z0-9_]*\)),\$$\{\1\},g' Misc/python-config.sh >python-config
+
+ # Install the include files
+ INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)
+@@ -1163,7 +1165,7 @@
+ $(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup
+ $(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh
+ $(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(VERSION)-config
+- rm python-config
++ $(INSTALL_SCRIPT) python-config.py $(DESTDIR)$(LIBPL)/python-config.py
+ @if [ -s Modules/python.exp -a \
+ "`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \
+ echo; echo "Installing support files for building shared extension modules on AIX:"; \
+@@ -1345,6 +1347,7 @@
+ config.cache config.log pyconfig.h Modules/config.c
+ -rm -rf build platform
+ -rm -rf $(PYTHONFRAMEWORKDIR)
++ -rm -f python-config.py python-config
+
+ # Make things extra clean, before making a distribution:
+ # remove all generated files, even Makefile[.pre]
+Index: b/Misc/python-config.sh.in
+===================================================================
+--- /dev/null
++++ b/Misc/python-config.sh.in
+@@ -0,0 +1,102 @@
++#!/bin/sh
++
++exit_with_usage ()
++{
++ echo "Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--configdir"
++ exit $1
++}
++
++if [ "$1" = "" ] ; then
++ exit_with_usage 1
++fi
++
++# Returns the actual prefix where this script was installed to.
++installed_prefix ()
++{
++ RESULT=$(dirname $(cd $(dirname "$1") && pwd -P))
++ if which readlink >/dev/null 2>&1 ; then
++ RESULT=$(readlink -f "$RESULT")
++ fi
++ echo $RESULT
++}
++
++prefix_build="@prefix@"
++prefix_real=$(installed_prefix "$0")
++
++# Use sed to fix paths from their built to locations to their installed to locations.
++prefix=$(echo "$prefix_build" | sed "s#$prefix_build#$prefix_real#")
++exec_prefix_build="@exec_prefix@"
++exec_prefix=$(echo "$exec_prefix_build" | sed "s#$exec_prefix_build#$prefix_real#")
++includedir=$(echo "@includedir@")
++libdir=$(echo "@libdir@" | sed "s#$prefix_build#$prefix_real#")
++CFLAGS=$(echo "@CFLAGS@" | sed "s#$prefix_build#$prefix_real#")
++VERSION="@VERSION@"
++LIBM="@LIBM@"
++LIBC="@LIBC@"
++SYSLIBS="$LIBM $LIBC"
++LIBS="@LIBS@ $SYSLIBS -lpython${VERSION}"
++BASECFLAGS="@BASECFLAGS@"
++LDLIBRARY="@LDLIBRARY@"
++LINKFORSHARED="@LINKFORSHARED@"
++OPT="@OPT@"
++PY_ENABLE_SHARED="@PY_ENABLE_SHARED@"
++LDVERSION="@LDVERSION@"
++LIBDEST=${prefix}/lib/python${VERSION}
++LIBPL=$(echo "@LIBPL@" | sed "s#$prefix_build#$prefix_real#")
++SO="@SO@"
++PYTHONFRAMEWORK="@PYTHONFRAMEWORK@"
++INCDIR="-I$includedir/python${VERSION}"
++PLATINCDIR="-I$includedir/python${VERSION}"
++
++# Scan for --help or unknown argument.
++for ARG in $*
++do
++ case $ARG in
++ --help)
++ exit_with_usage 0
++ ;;
++ --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--abiflags|--configdir)
++ ;;
++ *)
++ exit_with_usage 1
++ ;;
++esac
++done
++
++for ARG in "$@"
++do
++ case "$ARG" in
++ --prefix)
++ echo "$prefix"
++ ;;
++ --exec-prefix)
++ echo "$exec_prefix"
++ ;;
++ --includes)
++ echo "$INCDIR $PLATINCDIR"
++ ;;
++ --cflags)
++ echo "$INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT"
++ ;;
++ --libs)
++ echo "$LIBS"
++ ;;
++ --ldflags)
++ LINKFORSHAREDUSED=
++ if [ -z "$PYTHONFRAMEWORK" ] ; then
++ LINKFORSHAREDUSED=$LINKFORSHARED
++ fi
++ LIBPLUSED=
++ if [ "$PY_ENABLE_SHARED" = "0" ] ; then
++ LIBPLUSED="-L$LIBPL"
++ fi
++ echo "$LIBPLUSED -L$libdir $LIBS $LINKFORSHAREDUSED"
++ ;;
++ --extension-suffix)
++ echo "$SO"
++ ;;
++ --configdir)
++ echo "$LIBPL"
++ ;;
++esac
++done
--- /dev/null
+Remove the python symlink install rules.
+
+The python symlink installation will be handled by Buildroot itself, because
+Buildroot needs to control to what python interpreter (python2 or python3) the
+python symlink points to.
+
+Signed-off-by: Samuel Martin <s.martin49@gmail.com>
+
+Index: b/Makefile.pre.in
+===================================================================
+--- a/Makefile.pre.in
++++ b/Makefile.pre.in
+@@ -890,17 +890,10 @@
+ # $(PYTHON) -> python2 -> python$(VERSION))
+ # Also create equivalent chains for other installed files
+ bininstall: altbininstall
+- -if test -f $(DESTDIR)$(BINDIR)/$(PYTHON) -o -h $(DESTDIR)$(BINDIR)/$(PYTHON); \
+- then rm -f $(DESTDIR)$(BINDIR)/$(PYTHON); \
+- else true; \
+- fi
+- (cd $(DESTDIR)$(BINDIR); $(LN) -s python2$(EXE) $(PYTHON))
+ -rm -f $(DESTDIR)$(BINDIR)/python2$(EXE)
+ (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)$(EXE) python2$(EXE))
+ -rm -f $(DESTDIR)$(BINDIR)/python2-config
+ (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-config python2-config)
+- -rm -f $(DESTDIR)$(BINDIR)/python-config
+- (cd $(DESTDIR)$(BINDIR); $(LN) -s python2-config python-config)
+ -test -d $(DESTDIR)$(LIBPC) || $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(LIBPC)
+ -rm -f $(DESTDIR)$(LIBPC)/python2.pc
+ (cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION).pc python2.pc)
--- /dev/null
+python: do not rely only on LIBRARY_PATH for old compilers
+
+The cross-compilation improvements integrated in Python rely on the
+compiler exposing a line starting with LIBRARY_PATH when called with
+-E -v. This is used by Python setup.py to find the installation
+locations of libraries.
+
+However, this LIBRARY_PATH line is not shown by very old compilers,
+such as the gcc 4.2.x compiler used on the AVR32 architecture. This
+causes libraries installed in the sysroot, such as libffi, to not be
+detected by the setup.py script.
+
+To fix this problem, this patch adds addtional logic to setup.py,
+which consists in deriving the library paths from the sysroot
+location, if no LIBRARY_PATH field was found.
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+
+Index: b/setup.py
+===================================================================
+--- a/setup.py
++++ b/setup.py
+@@ -418,6 +418,7 @@
+ in_incdirs = False
+ inc_dirs = []
+ lib_dirs = []
++ compiler_has_library_path = False
+ try:
+ if ret >> 8 == 0:
+ with open(tmpfile) as fp:
+@@ -429,6 +430,7 @@
+ elif line.startswith("End of search list"):
+ in_incdirs = False
+ elif is_gcc and line.startswith("LIBRARY_PATH"):
++ compiler_has_library_path = True
+ for d in line.strip().split("=")[1].split(":"):
+ d = os.path.normpath(d)
+ if '/gcc/' not in d:
+@@ -440,6 +442,15 @@
+ finally:
+ os.unlink(tmpfile)
+
++ if not compiler_has_library_path:
++ ret = os.system("%s -print-file-name=libc.a | sed -r -e 's:(usr/)?lib(32|64)?/([^/]*/)?libc\.a::' >%s" % (gcc, tmpfile))
++ with open(tmpfile) as fp:
++ line = fp.readline().strip()
++ add_dir_to_list(self.compiler.library_dirs,
++ os.path.join(line, "usr", "lib"))
++ add_dir_to_list(self.compiler.library_dirs,
++ os.path.join(line, "lib"))
++
+ def detect_modules(self):
+ # Ensure that /usr/local is always used
+ if not cross_compiling:
--- /dev/null
+Don't add multiarch paths
+
+The add_multiarch_paths() function leads, in certain build
+environments, to the addition of host header paths to the CFLAGS,
+which is not appropriate for cross-compilation. This patch fixes that
+by simply removing the call to add_multiarch_paths() when we're
+cross-compiling.
+
+Investigation done by David <buildroot-2014@inbox.com>.
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+
+Index: b/setup.py
+===================================================================
+--- a/setup.py
++++ b/setup.py
+@@ -456,9 +456,9 @@
+ if not cross_compiling:
+ add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
+ add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
++ self.add_multiarch_paths()
+ if cross_compiling:
+ self.add_gcc_paths()
+- self.add_multiarch_paths()
+
+ # Add paths specified in the environment variables LDFLAGS and
+ # CPPFLAGS for header and library files.
--- /dev/null
+Abort on failed module build
+
+When building a Python module fails, the setup.py script currently
+doesn't exit with an error, and simply continues. This is not a really
+nice behavior, so this patch changes setup.py to abort with an error,
+so that the build issue is clearly noticeable.
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+
+Index: b/setup.py
+===================================================================
+--- a/setup.py
++++ b/setup.py
+@@ -283,6 +283,7 @@
+ print "Failed to build these modules:"
+ print_three_column(failed)
+ print
++ sys.exit(1)
+
+ def build_extension(self, ext):
+
--- /dev/null
+sqlite3: fix build when threads are not used/available
+
+When threads are not used/available, a function in the sqlite3 extension
+ends up with a label at the end:
+
+ void _pysqlite_final_callback(sqlite3_context* context)
+ {
+ PyObject* function_result;
+ PyObject** aggregate_instance;
+ int ok;
+
+ #ifdef WITH_THREAD
+ PyGILState_STATE threadstate;
+
+ threadstate = PyGILState_Ensure();
+ #endif
+
+ aggregate_instance = (PyObject**)sqlite3_aggregate_context(context, sizeof(PyObject*));
+ if (!*aggregate_instance) {
+ goto error;
+ }
+
+ [......]
+
+ error:
+ #ifdef WITH_THREAD
+ PyGILState_Release(threadstate);
+ #endif
+ }
+
+This is not valid, and gcc complains.
+
+Fix that by adding a dummy statement after the label, so that the label
+is never the last statement of the function.
+
+Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
+
+Index: b/Modules/_sqlite/connection.c
+===================================================================
+--- a/Modules/_sqlite/connection.c
++++ b/Modules/_sqlite/connection.c
+@@ -786,6 +786,7 @@
+ #ifdef WITH_THREAD
+ PyGILState_Release(threadstate);
+ #endif
++ ; /* Make gcc happy: a label can't be at the end of a function */
+ }
+
+ static void _pysqlite_drop_unused_statement_references(pysqlite_Connection* self)
--- /dev/null
+Serial ioctl() workaround
+
+The ioctls.h of some architectures (notably xtensa) references structs from
+linux/serial.h. Make sure to include this header as well.
+
+Also, undef TIOCTTYGSTRUCT that require reference to internal kernel tty_struct,
+but isn't actually referenced in modern kernels.
+
+Signed-off-by: Baruch Siach <baruch@tkos.co.il>
+---
+Index: b/Modules/termios.c
+===================================================================
+--- a/Modules/termios.c
++++ b/Modules/termios.c
+@@ -16,7 +16,9 @@
+ * so this needs to be included first on that platform. */
+ #include <termio.h>
+ #endif
++#include <linux/serial.h>
+ #include <sys/ioctl.h>
++#undef TIOCTTYGSTRUCT
+
+ /* HP-UX requires that this be included to pick up MDCD, MCTS, MDSR,
+ * MDTR, MRI, and MRTS (appearantly used internally by some things
--- /dev/null
+Do not adjust the shebang of Python scripts for cross-compilation
+
+The copy_scripts() method in distutils copies the scripts listed in
+the setup file and adjusts the first line to refer to the current
+Python interpreter. When cross-compiling, this means that the adjusted
+shebang refers to the host Python interpreter.
+
+This patch modifies copy_scripts() to preserve the shebang when
+cross-compilation is detected.
+
+Signed-off-by: Christophe Vu-Brugier <cvubrugier@fastmail.fm>
+
+Index: b/Lib/distutils/command/build_scripts.py
+===================================================================
+--- a/Lib/distutils/command/build_scripts.py
++++ b/Lib/distutils/command/build_scripts.py
+@@ -89,7 +89,7 @@
+ adjust = 1
+ post_interp = match.group(1) or ''
+
+- if adjust:
++ if adjust and not '_python_sysroot' in os.environ:
+ log.info("copying and adjusting %s -> %s", script,
+ self.build_dir)
+ if not self.dry_run:
--- /dev/null
+Add an option to disable installation of test modules
+
+The Python standard distribution comes with many test modules, that
+are not necessarly useful on embedded targets.
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+Signed-off-by: Samuel Martin <s.martin49@gmail.com>
+
+---
+ Makefile.pre.in | 40 +++++++++++++++++++++++++++-------------
+ configure.in | 6 ++++++
+ 2 files changed, 33 insertions(+), 13 deletions(-)
+
+Index: b/Makefile.pre.in
+===================================================================
+--- a/Makefile.pre.in
++++ b/Makefile.pre.in
+@@ -960,27 +960,43 @@
+ plat-mac/lib-scriptpackages/SystemEvents \
+ plat-mac/lib-scriptpackages/Terminal
+ PLATMACPATH=:plat-mac:plat-mac/lib-scriptpackages
+-LIBSUBDIRS= lib-tk lib-tk/test lib-tk/test/test_tkinter \
+- lib-tk/test/test_ttk site-packages test test/audiodata test/capath \
+- test/data test/cjkencodings test/decimaltestdata test/xmltestdata \
+- test/imghdrdata \
+- test/subprocessdata \
+- test/tracedmodules \
++LIBSUBDIRS= lib-tk site-packages \
+ encodings compiler hotshot \
+- email email/mime email/test email/test/data \
++ email email/mime \
+ ensurepip ensurepip/_bundled \
+- json json/tests \
+- sqlite3 sqlite3/test \
+- logging bsddb bsddb/test csv importlib wsgiref \
+- lib2to3 lib2to3/fixes lib2to3/pgen2 lib2to3/tests \
+- lib2to3/tests/data lib2to3/tests/data/fixers lib2to3/tests/data/fixers/myfixes \
+- ctypes ctypes/test ctypes/macholib \
+- idlelib idlelib/Icons idlelib/idle_test \
+- distutils distutils/command distutils/tests $(XMLLIBSUBDIRS) \
++ json \
++ sqlite3 \
++ logging bsddb csv importlib wsgiref \
++ lib2to3 lib2to3/fixes lib2to3/pgen2 \
++ ctypes ctypes/macholib \
++ idlelib idlelib/Icons \
++ distutils distutils/command $(XMLLIBSUBDIRS) \
+ multiprocessing multiprocessing/dummy \
+- unittest unittest/test \
++ unittest \
+ lib-old \
+ curses pydoc_data $(MACHDEPS)
++
++TESTSUBDIRS = lib-tk/test lib-tk/test/test_tkinter \
++ lib-tk/test/test_ttk test test/audiodata test/capath test/data \
++ test/cjkencodings test/decimaltestdata test/xmltestdata \
++ test/imghdrdata \
++ test/subprocessdata \
++ test/tracedmodules \
++ email/test email/test/data \
++ json/tests \
++ sqlite3/test \
++ bsddb/test \
++ lib2to3/tests \
++ lib2to3/tests/data lib2to3/tests/data/fixers lib2to3/tests/data/fixers/myfixes \
++ ctypes/test \
++ idlelib/idle_test \
++ distutils/tests \
++ unittest/test
++
++ifeq (@TEST_MODULES@,yes)
++LIBSUBDIRS += $(TESTSUBDIRS)
++endif
++
+ libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
+ @for i in $(SCRIPTDIR) $(LIBDEST); \
+ do \
+Index: b/configure.ac
+===================================================================
+--- a/configure.ac
++++ b/configure.ac
+@@ -2628,6 +2628,12 @@
+ fi
+
+
++AC_SUBST(TEST_MODULES)
++
++AC_ARG_ENABLE(test-modules,
++ AS_HELP_STRING([--disable-test-modules], [disable test modules]),
++ [ TEST_MODULES="${enableval}" ], [ TEST_MODULES=yes ])
++
+ # Check for enable-ipv6
+ AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
+ AC_MSG_CHECKING([if --enable-ipv6 is specified])
--- /dev/null
+Add an option to disable pydoc
+
+It removes 0.5 MB of data from the target plus the pydoc script
+itself.
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+Signed-off-by: Samuel Martin <s.martin49@gmail.com>
+
+---
+ Makefile.pre.in | 6 +++++-
+ configure.in | 5 +++++
+ setup.py | 10 +++++++---
+ 3 files changed, 17 insertions(+), 4 deletions(-)
+
+Index: b/Makefile.pre.in
+===================================================================
+--- a/Makefile.pre.in
++++ b/Makefile.pre.in
+@@ -974,7 +974,7 @@
+ multiprocessing multiprocessing/dummy \
+ unittest \
+ lib-old \
+- curses pydoc_data $(MACHDEPS)
++ curses $(MACHDEPS)
+
+ TESTSUBDIRS = lib-tk/test lib-tk/test/test_tkinter \
+ lib-tk/test/test_ttk test test/audiodata test/capath test/data \
+@@ -997,6 +997,10 @@
+ LIBSUBDIRS += $(TESTSUBDIRS)
+ endif
+
++ifeq (@PYDOC@,yes)
++LIBSUBDIRS += pydoc_data
++endif
++
+ libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
+ @for i in $(SCRIPTDIR) $(LIBDEST); \
+ do \
+Index: b/configure.ac
+===================================================================
+--- a/configure.ac
++++ b/configure.ac
+@@ -2627,6 +2627,11 @@
+ AC_CHECK_FUNCS(pthread_atfork)
+ fi
+
++AC_SUBST(PYDOC)
++
++AC_ARG_ENABLE(pydoc,
++ AS_HELP_STRING([--disable-pydoc], [disable pydoc]),
++ [ PYDOC="${enableval}" ], [ PYDOC=yes ])
+
+ AC_SUBST(TEST_MODULES)
+
+Index: b/setup.py
+===================================================================
+--- a/setup.py
++++ b/setup.py
+@@ -2222,6 +2222,12 @@
+ # turn off warnings when deprecated modules are imported
+ import warnings
+ warnings.filterwarnings("ignore",category=DeprecationWarning)
++
++ scripts = ['Tools/scripts/idle', 'Tools/scripts/2to3',
++ 'Lib/smtpd.py']
++ if not '--disable-pydoc' in sysconfig.get_config_var("CONFIG_ARGS"):
++ scripts += [ 'Tools/scripts/pydoc' ]
++
+ setup(# PyPI Metadata (PEP 301)
+ name = "Python",
+ version = sys.version.split()[0],
+@@ -2242,9 +2248,7 @@
+ ext_modules=[Extension('_struct', ['_struct.c'])],
+
+ # Scripts to install
+- scripts = ['Tools/scripts/pydoc', 'Tools/scripts/idle',
+- 'Tools/scripts/2to3',
+- 'Lib/smtpd.py']
++ scripts = scripts,
+ )
+
+ # --install-platlib
--- /dev/null
+Add an option to disable lib2to3
+
+lib2to3 is a library to convert Python 2.x code to Python 3.x. As
+such, it is probably not very useful on embedded system targets.
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+Signed-off-by: Samuel Martin <s.martin49@gmail.com>
+
+---
+ Makefile.pre.in | 24 +++++++++++++++++-------
+ configure.in | 6 ++++++
+ setup.py | 5 +++--
+ 3 files changed, 26 insertions(+), 9 deletions(-)
+
+Index: b/Makefile.pre.in
+===================================================================
+--- a/Makefile.pre.in
++++ b/Makefile.pre.in
+@@ -967,7 +967,6 @@
+ json \
+ sqlite3 \
+ logging bsddb csv importlib wsgiref \
+- lib2to3 lib2to3/fixes lib2to3/pgen2 \
+ ctypes ctypes/macholib \
+ idlelib idlelib/Icons \
+ distutils distutils/command $(XMLLIBSUBDIRS) \
+@@ -986,8 +985,6 @@
+ json/tests \
+ sqlite3/test \
+ bsddb/test \
+- lib2to3/tests \
+- lib2to3/tests/data lib2to3/tests/data/fixers lib2to3/tests/data/fixers/myfixes \
+ ctypes/test \
+ idlelib/idle_test \
+ distutils/tests \
+@@ -1001,6 +998,14 @@
+ LIBSUBDIRS += pydoc_data
+ endif
+
++ifeq (@LIB2TO3@,yes)
++LIBSUBDIRS += lib2to3 lib2to3/fixes lib2to3/pgen2
++TESTSUBDIRS += lib2to3/tests \
++ lib2to3/tests/data \
++ lib2to3/tests/data/fixers \
++ lib2to3/tests/data/fixers/myfixes
++endif
++
+ libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
+ @for i in $(SCRIPTDIR) $(LIBDEST); \
+ do \
+Index: b/configure.ac
+===================================================================
+--- a/configure.ac
++++ b/configure.ac
+@@ -2639,6 +2639,12 @@
+ AS_HELP_STRING([--disable-test-modules], [disable test modules]),
+ [ TEST_MODULES="${enableval}" ], [ TEST_MODULES=yes ])
+
++AC_SUBST(LIB2TO3)
++
++AC_ARG_ENABLE(lib2to3,
++ AS_HELP_STRING([--disable-lib2to3], [disable lib2to3]),
++ [ LIB2TO3="${enableval}" ], [ LIB2TO3=yes ])
++
+ # Check for enable-ipv6
+ AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
+ AC_MSG_CHECKING([if --enable-ipv6 is specified])
+Index: b/setup.py
+===================================================================
+--- a/setup.py
++++ b/setup.py
+@@ -2223,10 +2223,11 @@
+ import warnings
+ warnings.filterwarnings("ignore",category=DeprecationWarning)
+
+- scripts = ['Tools/scripts/idle', 'Tools/scripts/2to3',
+- 'Lib/smtpd.py']
++ scripts = ['Tools/scripts/idle', 'Lib/smtpd.py']
+ if not '--disable-pydoc' in sysconfig.get_config_var("CONFIG_ARGS"):
+ scripts += [ 'Tools/scripts/pydoc' ]
++ if not '--disable-lib2to3' in sysconfig.get_config_var("CONFIG_ARGS"):
++ scripts += [ 'Tools/scripts/2to3' ]
+
+ setup(# PyPI Metadata (PEP 301)
+ name = "Python",
--- /dev/null
+Add option to disable the sqlite3 module
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+Signed-off-by: Samuel Martin <s.martin49@gmail.com>
+
+---
+ Makefile.pre.in | 24 +++++++++++++++++-------
+ configure.in | 9 +++++++++
+ 2 file changed, 9 insertions(+)
+
+Index: b/configure.ac
+===================================================================
+--- a/configure.ac
++++ b/configure.ac
+@@ -2627,6 +2627,15 @@
+ AC_CHECK_FUNCS(pthread_atfork)
+ fi
+
++AC_SUBST(SQLITE3)
++AC_ARG_ENABLE(sqlite3,
++ AS_HELP_STRING([--disable-sqlite3], [disable sqlite3]),
++ [ SQLITE3="${enableval}" ], [ SQLITE3=yes ])
++
++if test "$SQLITE3" = "no" ; then
++ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} _sqlite3"
++fi
++
+ AC_SUBST(PYDOC)
+
+ AC_ARG_ENABLE(pydoc,
+Index: b/Makefile.pre.in
+===================================================================
+--- a/Makefile.pre.in
++++ b/Makefile.pre.in
+@@ -965,7 +965,6 @@
+ email email/mime \
+ ensurepip ensurepip/_bundled \
+ json \
+- sqlite3 \
+ logging bsddb csv importlib wsgiref \
+ ctypes ctypes/macholib \
+ idlelib idlelib/Icons \
+@@ -983,7 +982,6 @@
+ test/tracedmodules \
+ email/test email/test/data \
+ json/tests \
+- sqlite3/test \
+ bsddb/test \
+ ctypes/test \
+ idlelib/idle_test \
+@@ -1006,6 +1004,11 @@
+ lib2to3/tests/data/fixers/myfixes
+ endif
+
++ifeq (@SQLITE3@,yes)
++LIBSUBDIRS += sqlite3
++TESTSUBDIRS += sqlite3/test
++endif
++
+ libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
+ @for i in $(SCRIPTDIR) $(LIBDEST); \
+ do \
--- /dev/null
+Add an option to disable the tk module
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+Signed-off-by: Samuel Martin <s.martin49@gmail.com>
+
+---
+ Makefile.pre.in | 14 ++++++++++----
+ configure.in | 9 +++++++++
+ 2 files changed, 19 insertions(+), 4 deletions(-)
+
+Index: b/Makefile.pre.in
+===================================================================
+--- a/Makefile.pre.in
++++ b/Makefile.pre.in
+@@ -960,7 +960,7 @@
+ plat-mac/lib-scriptpackages/SystemEvents \
+ plat-mac/lib-scriptpackages/Terminal
+ PLATMACPATH=:plat-mac:plat-mac/lib-scriptpackages
+-LIBSUBDIRS= lib-tk site-packages \
++LIBSUBDIRS= site-packages \
+ encodings compiler hotshot \
+ email email/mime \
+ ensurepip ensurepip/_bundled \
+@@ -974,8 +974,7 @@
+ lib-old \
+ curses $(MACHDEPS)
+
+-TESTSUBDIRS = lib-tk/test lib-tk/test/test_tkinter \
+- lib-tk/test/test_ttk test test/audiodata test/capath test/data \
++TESTSUBDIRS = test test/audiodata test/capath test/data \
+ test/cjkencodings test/decimaltestdata test/xmltestdata \
+ test/imghdrdata \
+ test/subprocessdata \
+@@ -1009,6 +1008,12 @@
+ TESTSUBDIRS += sqlite3/test
+ endif
+
++ifeq (@TK@,yes)
++LIBSUBDIRS += lib-tk
++TESTSUBDIRS += lib-tk/test lib-tk/test/test_tkinter \
++ lib-tk/test/test_ttk
++endif
++
+ libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
+ @for i in $(SCRIPTDIR) $(LIBDEST); \
+ do \
+Index: b/configure.ac
+===================================================================
+--- a/configure.ac
++++ b/configure.ac
+@@ -2636,6 +2636,15 @@
+ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} _sqlite3"
+ fi
+
++AC_SUBST(TK)
++AC_ARG_ENABLE(tk,
++ AS_HELP_STRING([--disable-tk], [disable tk]),
++ [ TK="${enableval}" ], [ TK=yes ])
++
++if test "$TK" = "no"; then
++ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} _tkinter"
++fi
++
+ AC_SUBST(PYDOC)
+
+ AC_ARG_ENABLE(pydoc,
--- /dev/null
+Add an option to disable the curses module
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+Signed-off-by: Samuel Martin <s.martin49@gmail.com>
+
+---
+ Makefile.pre.in | 6 +++++-
+ configure.in | 9 +++++++++
+ 2 files changed, 14 insertions(+), 1 deletion(-)
+
+Index: b/Makefile.pre.in
+===================================================================
+--- a/Makefile.pre.in
++++ b/Makefile.pre.in
+@@ -972,7 +972,7 @@
+ multiprocessing multiprocessing/dummy \
+ unittest \
+ lib-old \
+- curses $(MACHDEPS)
++ $(MACHDEPS)
+
+ TESTSUBDIRS = test test/audiodata test/capath test/data \
+ test/cjkencodings test/decimaltestdata test/xmltestdata \
+@@ -1014,6 +1014,10 @@
+ lib-tk/test/test_ttk
+ endif
+
++ifeq (@CURSES@,yes)
++LIBSUBDIRS += curses
++endif
++
+ libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
+ @for i in $(SCRIPTDIR) $(LIBDEST); \
+ do \
+Index: b/configure.ac
+===================================================================
+--- a/configure.ac
++++ b/configure.ac
+@@ -2645,6 +2645,15 @@
+ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} _tkinter"
+ fi
+
++AC_SUBST(CURSES)
++AC_ARG_ENABLE(curses,
++ AS_HELP_STRING([--disable-curses], [disable curses]),
++ [ CURSES="${enableval}" ], [ CURSES=yes ])
++
++if test "$CURSES" = "no"; then
++ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} _curses _curses_panel"
++fi
++
+ AC_SUBST(PYDOC)
+
+ AC_ARG_ENABLE(pydoc,
--- /dev/null
+Add an option to disable expat
+
+This patch replaces the existing --with-system-expat option with a
+--with-expat={system,builtin,none} option, which allows to tell Python
+whether we want to use the system expat (already installed), the expat
+builtin the Python sources, or no expat at all (which disables the
+installation of XML modules).
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+Signed-off-by: Samuel Martin <s.martin49@gmail.com>
+
+---
+ Makefile.pre.in | 6 +++++-
+ configure.in | 18 +++++++++++++-----
+ setup.py | 2 +-
+ 3 files changed, 19 insertions(+), 7 deletions(-)
+
+Index: b/Makefile.pre.in
+===================================================================
+--- a/Makefile.pre.in
++++ b/Makefile.pre.in
+@@ -968,7 +968,7 @@
+ logging bsddb csv importlib wsgiref \
+ ctypes ctypes/macholib \
+ idlelib idlelib/Icons \
+- distutils distutils/command $(XMLLIBSUBDIRS) \
++ distutils distutils/command \
+ multiprocessing multiprocessing/dummy \
+ unittest \
+ lib-old \
+@@ -1018,6 +1018,10 @@
+ LIBSUBDIRS += curses
+ endif
+
++ifeq (@EXPAT@,yes)
++LIBSUBDIRS += $(XMLLIBSUBDIRS)
++endif
++
+ libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
+ @for i in $(SCRIPTDIR) $(LIBDEST); \
+ do \
+Index: b/configure.ac
+===================================================================
+--- a/configure.ac
++++ b/configure.ac
+@@ -2292,13 +2292,21 @@
+ AC_SUBST(DISABLED_EXTENSIONS)
+
+ # Check for use of the system expat library
+-AC_MSG_CHECKING(for --with-system-expat)
+-AC_ARG_WITH(system_expat,
+- AS_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library]),
++AC_MSG_CHECKING(for --with-expat)
++AC_ARG_WITH(expat,
++ AS_HELP_STRING([--with-expat], [select which expat version to use: system, builtin, none]),
+ [],
+- [with_system_expat="no"])
++ [with_expat="builtin"])
+
+-AC_MSG_RESULT($with_system_expat)
++AC_MSG_RESULT($with_expat)
++
++if test "$with_expat" != "none"; then
++ EXPAT=yes
++else
++ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} pyexpat"
++ EXPAT=no
++fi
++AC_SUBST(EXPAT)
+
+ # Check for use of the system libffi library
+ AC_MSG_CHECKING(for --with-system-ffi)
+Index: b/setup.py
+===================================================================
+--- a/setup.py
++++ b/setup.py
+@@ -1474,7 +1474,7 @@
+ #
+ # More information on Expat can be found at www.libexpat.org.
+ #
+- if '--with-system-expat' in sysconfig.get_config_var("CONFIG_ARGS"):
++ if '--with-expat=system' in sysconfig.get_config_var("CONFIG_ARGS"):
+ expat_inc = []
+ define_macros = []
+ expat_lib = ['expat']
--- /dev/null
+Add an option to disable CJK codecs
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+
+---
+ configure.in | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+Index: b/configure.ac
+===================================================================
+--- a/configure.ac
++++ b/configure.ac
+@@ -2644,6 +2644,12 @@
+ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} _sqlite3"
+ fi
+
++AC_ARG_ENABLE(codecs-cjk,
++ AS_HELP_STRING([--disable-codecs-cjk], [disable CJK codecs]),
++ [ if test "$enableval" = "no"; then
++ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} _codecs_kr _codecs_jp _codecs_cn _codecs_tw _codecs_hk"
++ fi])
++
+ AC_SUBST(TK)
+ AC_ARG_ENABLE(tk,
+ AS_HELP_STRING([--disable-tk], [disable tk]),
--- /dev/null
+Add an option to disable NIS
+
+NIS is not necessarily available in uClibc, so we need an option to
+not compile support for it.
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+
+---
+ configure.in | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+Index: b/configure.ac
+===================================================================
+--- a/configure.ac
++++ b/configure.ac
+@@ -2650,6 +2650,12 @@
+ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} _codecs_kr _codecs_jp _codecs_cn _codecs_tw _codecs_hk"
+ fi])
+
++AC_ARG_ENABLE(nis,
++ AS_HELP_STRING([--disable-nis], [disable NIS]),
++ [ if test "$enableval" = "no"; then
++ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} nis"
++ fi])
++
+ AC_SUBST(TK)
+ AC_ARG_ENABLE(tk,
+ AS_HELP_STRING([--disable-tk], [disable tk]),
--- /dev/null
+Add an option to disable unicodedata
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+
+---
+ configure.in | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+Index: b/configure.ac
+===================================================================
+--- a/configure.ac
++++ b/configure.ac
+@@ -2656,6 +2656,12 @@
+ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} nis"
+ fi])
+
++AC_ARG_ENABLE(unicodedata,
++ AS_HELP_STRING([--disable-unicodedata], [disable unicodedata]),
++ [ if test "$enableval" = "no"; then
++ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} unicodedata"
++ fi])
++
+ AC_SUBST(TK)
+ AC_ARG_ENABLE(tk,
+ AS_HELP_STRING([--disable-tk], [disable tk]),
--- /dev/null
+Add an option to disable bsddb
+
+bsddb has an external dependency on Berkeley DB. Since we want to be
+able to build Python without it, this patch adds an option to disable
+the build/installation of this Python module.
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+Signed-off-by: Samuel Martin <s.martin49@gmail.com>
+
+---
+ Makefile.pre.in | 10 ++++++++--
+ configure.in | 22 ++++++++++++++++++++++
+ 2 files changed, 30 insertions(+), 2 deletions(-)
+
+Index: b/Makefile.pre.in
+===================================================================
+--- a/Makefile.pre.in
++++ b/Makefile.pre.in
+@@ -965,7 +965,7 @@
+ email email/mime \
+ ensurepip ensurepip/_bundled \
+ json \
+- logging bsddb csv importlib wsgiref \
++ logging csv importlib wsgiref \
+ ctypes ctypes/macholib \
+ idlelib idlelib/Icons \
+ distutils distutils/command \
+@@ -981,7 +981,6 @@
+ test/tracedmodules \
+ email/test email/test/data \
+ json/tests \
+- bsddb/test \
+ ctypes/test \
+ idlelib/idle_test \
+ distutils/tests \
+@@ -1022,6 +1021,11 @@
+ LIBSUBDIRS += $(XMLLIBSUBDIRS)
+ endif
+
++ifeq (@BSDDB@,yes)
++LIBSUBDIRS += bsddb
++TESTSUBDIRS += bsddb/test
++endif
++
+ libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
+ @for i in $(SCRIPTDIR) $(LIBDEST); \
+ do \
+Index: b/configure.ac
+===================================================================
+--- a/configure.ac
++++ b/configure.ac
+@@ -2656,6 +2656,28 @@
+ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} nis"
+ fi])
+
++AC_ARG_ENABLE(dbm,
++ AS_HELP_STRING([--disable-dbm], [disable DBM]),
++ [ if test "$enableval" = "no"; then
++ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} dbm"
++ fi])
++
++AC_ARG_ENABLE(gdbm,
++ AS_HELP_STRING([--disable-gdbm], [disable GDBM]),
++ [ if test "$enableval" = "no"; then
++ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} gdbm"
++ fi])
++
++AC_SUBST(BSDDB)
++AC_ARG_ENABLE(bsddb,
++ AS_HELP_STRING([--disable-bsddb], [disable BerkeyleyDB]),
++ [ if test "$enableval" = "no"; then
++ BSDDB=no
++ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} _bsddb"
++ else
++ BSDDB=yes
++ fi], [ BSDDB=yes ])
++
+ AC_ARG_ENABLE(unicodedata,
+ AS_HELP_STRING([--disable-unicodedata], [disable unicodedata]),
+ [ if test "$enableval" = "no"; then
--- /dev/null
+Add an option to disable the ssl module
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+
+---
+ configure.in | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+Index: b/configure.ac
+===================================================================
+--- a/configure.ac
++++ b/configure.ac
+@@ -2656,6 +2656,12 @@
+ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} nis"
+ fi])
+
++AC_ARG_ENABLE(ssl,
++ AS_HELP_STRING([--disable-ssl], [disable SSL]),
++ [ if test "$enableval" = "no"; then
++ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} ssl"
++ fi])
++
+ AC_ARG_ENABLE(dbm,
+ AS_HELP_STRING([--disable-dbm], [disable DBM]),
+ [ if test "$enableval" = "no"; then
--- /dev/null
+Add an option to disable the bz2 module
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+---
+ configure.in | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+Index: b/configure.ac
+===================================================================
+--- a/configure.ac
++++ b/configure.ac
+@@ -2662,6 +2662,12 @@
+ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} ssl"
+ fi])
+
++AC_ARG_ENABLE(bz2,
++ AS_HELP_STRING([--disable-bz2], [disable BZIP2]),
++ [ if test "$enableval" = "no"; then
++ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} bz2"
++ fi])
++
+ AC_ARG_ENABLE(dbm,
+ AS_HELP_STRING([--disable-dbm], [disable DBM]),
+ [ if test "$enableval" = "no"; then
--- /dev/null
+Add an option to disable the zlib module
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+---
+ configure.in | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+Index: b/configure.ac
+===================================================================
+--- a/configure.ac
++++ b/configure.ac
+@@ -2668,6 +2668,12 @@
+ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} bz2"
+ fi])
+
++AC_ARG_ENABLE(zlib,
++ AS_HELP_STRING([--disable-zlib], [disable ZLIB]),
++ [ if test "$enableval" = "no"; then
++ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} zlib"
++ fi])
++
+ AC_ARG_ENABLE(dbm,
+ AS_HELP_STRING([--disable-dbm], [disable DBM]),
+ [ if test "$enableval" = "no"; then
--- /dev/null
+Do not install the idle editor
+
+IDLE is the Python IDE built with the tkinter GUI toolkit. Since it's
+highly unlikely to ever be useful in an embedded Linux system
+generated by Buildroot, this patch simply disables the installation of
+idle and the related Python modules. It saves 800 KB-900 KB of
+installed .pyc files.
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+
+Index: b/Makefile.pre.in
+===================================================================
+--- a/Makefile.pre.in
++++ b/Makefile.pre.in
+@@ -967,7 +967,6 @@
+ json \
+ logging csv importlib wsgiref \
+ ctypes ctypes/macholib \
+- idlelib idlelib/Icons \
+ distutils distutils/command \
+ multiprocessing multiprocessing/dummy \
+ unittest \
+@@ -982,7 +981,6 @@
+ email/test email/test/data \
+ json/tests \
+ ctypes/test \
+- idlelib/idle_test \
+ distutils/tests \
+ unittest/test
+
+Index: b/setup.py
+===================================================================
+--- a/setup.py
++++ b/setup.py
+@@ -2223,7 +2223,7 @@
+ import warnings
+ warnings.filterwarnings("ignore",category=DeprecationWarning)
+
+- scripts = ['Tools/scripts/idle', 'Lib/smtpd.py']
++ scripts = ['Lib/smtpd.py']
+ if not '--disable-pydoc' in sysconfig.get_config_var("CONFIG_ARGS"):
+ scripts += [ 'Tools/scripts/pydoc' ]
+ if not '--disable-lib2to3' in sysconfig.get_config_var("CONFIG_ARGS"):
+++ /dev/null
-setup.py: do not add invalid header locations
-
-This piece of code incorrectly adds /usr/include to
-self.compiler.include_dirs, and results in the following invalid
-compilation line:
-
-/home/thomas/projets/buildroot/output/host/usr/bin/arm-none-linux-gnueabi-gcc -fPIC \
- -fno-strict-aliasing -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 \
- -pipe -Os -DNDEBUG -g -O3 -Wall -Wstrict-prototypes \
- -I/usr/include -I. -IInclude -I./Include \
- -I/home/thomas/projets/buildroot/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/include \
- -I/home/thomas/projets/buildroot/output/build/python-2.7.6/Include \
- -I/home/thomas/projets/buildroot/output/build/python-2.7.6 \
- -c /home/thomas/projets/buildroot/output/build/python-2.7.6/Modules/mathmodule.c \
- -o build/temp.linux2-arm-2.7/home/thomas/projets/buildroot/output/build/python-2.7.6/Modules/mathmodule.o
-cc1: warning: include location "/usr/include" is unsafe for cross-compilation [-Wpoison-system-directories]
-[...]
-
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-Index: b/setup.py
-===================================================================
---- a/setup.py
-+++ b/setup.py
-@@ -480,7 +480,7 @@
- for directory in reversed(options.dirs):
- add_dir_to_list(dir_list, directory)
-
-- if os.path.normpath(sys.prefix) != '/usr' \
-+ if False and os.path.normpath(sys.prefix) != '/usr' \
- and not sysconfig.get_config_var('PYTHONFRAMEWORK'):
- # OSX note: Don't add LIBDIR and INCLUDEDIR to building a framework
- # (PYTHONFRAMEWORK is set) to avoid # linking problems when
+++ /dev/null
-Fix get_python_inc() for cross-compilation
-
-When we are cross compiling, doing os.path.dirname(sys.executable) to
-get the build directory is incorrect, because we're executing the host
-Python to build things for the target. Instead, we should use the
-project_base variable.
-
-This fixes cross-compilation, which was adding incorrect header paths
-pointing to the location where the host Python was built:
-
-/home/thomas/projets/buildroot/output/host/usr/bin/arm-none-linux-gnueabi-gcc -fPIC -fno-strict-aliasing \
- -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -pipe -Os -DNDEBUG -g -O3 -Wall -Wstrict-prototypes \
- -I/usr/include -I. -IInclude -I./Include -I/home/thomas/projets/buildroot/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/include \
- -I/home/thomas/projets/buildroot/output/host/usr/bin/Include -I/home/thomas/projets/buildroot/output/host/usr/bin \
- -c /home/thomas/projets/buildroot/output/build/python-2.7.6/Modules/_struct.c \
- -o build/temp.linux2-arm-2.7/home/thomas/projets/buildroot/output/build/python-2.7.6/Modules/_struct.o
-
-This patch allows to fix the
-/home/thomas/projets/buildroot/output/host/usr/bin/Include and
-/home/thomas/projets/buildroot/output/host/usr/bin paths that are
-incorrectly added to the header paths.
-
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-Index: b/Lib/distutils/sysconfig.py
-===================================================================
---- a/Lib/distutils/sysconfig.py
-+++ b/Lib/distutils/sysconfig.py
-@@ -79,7 +79,7 @@
-
- if os.name == "posix":
- if python_build:
-- buildir = os.path.dirname(sys.executable)
-+ buildir = project_base
- if plat_specific:
- # python.h is located in the buildir
- inc_dir = buildir
+++ /dev/null
-Change the install location of _sysconfigdata.py
-
-The _sysconfigdata.py module contains definitions that are needed when
-building Python modules. In cross-compilation mode, when building
-Python extensions for the target, we need to use the _sysconfigdata.py
-of the target Python while executing the host Python.
-
-However until now, the _sysconfigdata.py module was installed in
-build/lib.<arch>-<version> directory, together with a number of
-architecture-specific shared objects, which cannot be used with the
-host Python.
-
-To solve this problem, this patch moves _sysconfigdata.py to a
-separate location, build/sysconfigdata.<arch>-<version>/, and only
-this directory gets added to the PYTHONPATH of the host Python
-interpreter when building Python modules for the target.
-
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-
-Index: b/Makefile.pre.in
-===================================================================
---- a/Makefile.pre.in
-+++ b/Makefile.pre.in
-@@ -462,6 +462,9 @@
- rm -f ./pybuilddir.txt ; \
- exit 1 ; \
- fi
-+ echo `cat pybuilddir.txt`/sysconfigdata > pysysconfigdatadir.txt
-+ mkdir -p `cat pysysconfigdatadir.txt`
-+ cp `cat pybuilddir.txt`/_sysconfigdata.py `cat pysysconfigdatadir.txt`
-
- # Build the shared modules
- # Under GNU make, MAKEFLAGS are sorted and normalized; the 's' for
-@@ -1002,7 +1005,7 @@
- else true; \
- fi; \
- done
-- @for i in $(srcdir)/Lib/*.py `cat pybuilddir.txt`/_sysconfigdata.py $(srcdir)/Lib/*.doc $(srcdir)/Lib/*.egg-info ; \
-+ @for i in $(srcdir)/Lib/*.py $(srcdir)/Lib/*.doc $(srcdir)/Lib/*.egg-info ; \
- do \
- if test -x $$i; then \
- $(INSTALL_SCRIPT) $$i $(DESTDIR)$(LIBDEST); \
-@@ -1012,6 +1015,11 @@
- echo $(INSTALL_DATA) $$i $(LIBDEST); \
- fi; \
- done
-+ $(INSTALL_DATA) `cat pysysconfigdatadir.txt`/_sysconfigdata.py \
-+ $(DESTDIR)$(LIBDEST)
-+ mkdir -p $(DESTDIR)$(LIBDEST)/sysconfigdata
-+ $(INSTALL_DATA) `cat pysysconfigdatadir.txt`/_sysconfigdata.py \
-+ $(DESTDIR)$(LIBDEST)/sysconfigdata
- @for d in $(LIBSUBDIRS); \
- do \
- a=$(srcdir)/Lib/$$d; \
-@@ -1337,7 +1345,7 @@
- Modules/Setup Modules/Setup.local Modules/Setup.config \
- Modules/ld_so_aix Modules/python.exp Misc/python.pc
- -rm -f python*-gdb.py
-- -rm -f pybuilddir.txt
-+ -rm -f pybuilddir.txt pysysconfigdatadir.txt
- find $(srcdir)/[a-zA-Z]* '(' -name '*.fdc' -o -name '*~' \
- -o -name '[@,#]*' -o -name '*.old' \
- -o -name '*.orig' -o -name '*.rej' \
-Index: b/configure.ac
-===================================================================
---- a/configure.ac
-+++ b/configure.ac
-@@ -33,7 +33,7 @@
- AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found])
- fi
- AC_MSG_RESULT($interp)
-- PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp
-+ PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pysysconfigdatadir.txt && echo $(abs_builddir)/`cat pysysconfigdatadir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp
- fi
- elif test "$cross_compiling" = maybe; then
- AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH])
+++ /dev/null
-Index: b/Makefile.pre.in
-===================================================================
---- a/Makefile.pre.in
-+++ b/Makefile.pre.in
-@@ -1050,24 +1050,32 @@
- $(INSTALL_DATA) $(srcdir)/Modules/xxmodule.c \
- $(DESTDIR)$(LIBDEST)/distutils/tests ; \
- fi
-+ifeq (@PYC_BUILD@,yes)
- PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- $(PYTHON_FOR_BUILD) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
- -d $(LIBDEST) -f \
- -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
- $(DESTDIR)$(LIBDEST)
-+endif
-+ifeq (@PYO_BUILD@,yes)
- PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- $(PYTHON_FOR_BUILD) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
- -d $(LIBDEST) -f \
- -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
- $(DESTDIR)$(LIBDEST)
-+endif
-+ifeq (@PYC_BUILD@,yes)
- -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- $(PYTHON_FOR_BUILD) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
- -d $(LIBDEST)/site-packages -f \
- -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
-+endif
-+ifeq (@PYO_BUILD@,yes)
- -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- $(PYTHON_FOR_BUILD) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
- -d $(LIBDEST)/site-packages -f \
- -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
-+endif
- -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
- $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt
- -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
-Index: b/configure.ac
-===================================================================
---- a/configure.ac
-+++ b/configure.ac
-@@ -736,6 +736,17 @@
- ;;
- esac
-
-+AC_SUBST(PYC_BUILD)
-+
-+AC_ARG_ENABLE(pyc-build,
-+ AS_HELP_STRING([--disable-pyc-build], [disable build of pyc files]),
-+ [ PYC_BUILD="${enableval}" ], [ PYC_BUILD=yes ])
-+
-+AC_SUBST(PYO_BUILD)
-+
-+AC_ARG_ENABLE(pyo-build,
-+ AS_HELP_STRING([--disable-pyo-build], [disable build of pyo files]),
-+ [ PYO_BUILD="${enableval}" ], [ PYO_BUILD=yes ])
-
- AC_SUBST(LIBRARY)
- AC_MSG_CHECKING(LIBRARY)
+++ /dev/null
-Index: b/configure.ac
-===================================================================
---- a/configure.ac
-+++ b/configure.ac
-@@ -3346,7 +3346,7 @@
-
- AC_MSG_RESULT($ac_cv_buggy_getaddrinfo)
-
--if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
-+if test $have_getaddrinfo = no || test "$cross_compiling" != "yes" -a "$ac_cv_buggy_getaddrinfo" = yes
- then
- if test $ipv6 = yes
- then
+++ /dev/null
-Index: b/Makefile.pre.in
-===================================================================
---- a/Makefile.pre.in
-+++ b/Makefile.pre.in
-@@ -156,6 +156,8 @@
- # configure script arguments
- CONFIG_ARGS= @CONFIG_ARGS@
-
-+# disabled extensions
-+DISABLED_EXTENSIONS= @DISABLED_EXTENSIONS@
-
- # Subdirectories with code
- SRCDIRS= @SRCDIRS@
-@@ -477,6 +479,7 @@
- esac; \
- $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
- _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
-+ DISABLED_EXTENSIONS="$(DISABLED_EXTENSIONS)" \
- $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
-
- # Build static library
-@@ -1191,7 +1194,8 @@
- # Install the dynamically loadable modules
- # This goes into $(exec_prefix)
- sharedinstall: sharedmods
-- $(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \
-+ $(RUNSHARED) DISABLED_EXTENSIONS="$(DISABLED_EXTENSIONS)" \
-+ $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \
- --prefix=$(prefix) \
- --install-scripts=$(BINDIR) \
- --install-platlib=$(DESTSHARED) \
-Index: b/configure.ac
-===================================================================
---- a/configure.ac
-+++ b/configure.ac
-@@ -2284,6 +2284,8 @@
-
- AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
-
-+AC_SUBST(DISABLED_EXTENSIONS)
-+
- # Check for use of the system expat library
- AC_MSG_CHECKING(for --with-system-expat)
- AC_ARG_WITH(system_expat,
-Index: b/setup.py
-===================================================================
---- a/setup.py
-+++ b/setup.py
-@@ -33,7 +33,10 @@
- COMPILED_WITH_PYDEBUG = ('--with-pydebug' in sysconfig.get_config_var("CONFIG_ARGS"))
-
- # This global variable is used to hold the list of modules to be disabled.
--disabled_module_list = []
-+try:
-+ disabled_module_list = sysconfig.get_config_var("DISABLED_EXTENSIONS").split(" ")
-+except KeyError:
-+ disabled_module_list = list()
-
- def add_dir_to_list(dirlist, dir):
- """Add the directory 'dir' to the list 'dirlist' (at the front) if
+++ /dev/null
-Adjust library/header paths for cross-compilation
-
-When cross-compiling third-party extensions, the get_python_inc() or
-get_python_lib() can be called, to return the path to headers or
-libraries. However, they use the sys.prefix of the host Python, which
-returns incorrect paths when cross-compiling (paths pointing to host
-headers and libraries).
-
-In order to fix this, we introduce the _python_sysroot, _python_prefix
-and _python_exec_prefix variables, that allow to override these
-values, and get correct header/library paths when cross-compiling
-third-party Python modules.
-
-The _python_sysroot variable is also used to prefix the LIBDIR value
-taken from the sysconfigdata module.
-
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-
-Index: b/Lib/distutils/sysconfig.py
-===================================================================
---- a/Lib/distutils/sysconfig.py
-+++ b/Lib/distutils/sysconfig.py
-@@ -19,8 +19,13 @@
- from distutils.errors import DistutilsPlatformError
-
- # These are needed in a couple of spots, so just compute them once.
--PREFIX = os.path.normpath(sys.prefix)
--EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
-+if "_python_sysroot" in os.environ:
-+ _sysroot=os.environ.get('_python_sysroot')
-+ PREFIX = os.path.normpath(_sysroot + os.environ.get('_python_prefix'))
-+ EXEC_PREFIX = os.path.normpath(_sysroot + os.environ.get('_python_exec_prefix'))
-+else:
-+ PREFIX = os.path.normpath(sys.prefix)
-+ EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
-
- # Path to the base directory of the project. On Windows the binary may
- # live in project/PCBuild9. If we're dealing with an x64 Windows build,
-Index: b/Lib/distutils/command/build_ext.py
-===================================================================
---- a/Lib/distutils/command/build_ext.py
-+++ b/Lib/distutils/command/build_ext.py
-@@ -237,7 +237,10 @@
- if (sysconfig.get_config_var('Py_ENABLE_SHARED')):
- if not sysconfig.python_build:
- # building third party extensions
-- self.library_dirs.append(sysconfig.get_config_var('LIBDIR'))
-+ libdir = sysconfig.get_config_var('LIBDIR')
-+ if "_python_sysroot" in os.environ:
-+ libdir = os.environ.get("_python_sysroot") + libdir
-+ self.library_dirs.append(libdir)
- else:
- # building python standard extensions
- self.library_dirs.append('.')
+++ /dev/null
-Don't look in /usr/lib/termcap for libraries
-
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-
-
-Index: b/setup.py
-===================================================================
---- a/setup.py
-+++ b/setup.py
-@@ -764,12 +764,9 @@
- pass # Issue 7384: Already linked against curses or tinfo.
- elif curses_library:
- readline_libs.append(curses_library)
-- elif self.compiler.find_library_file(lib_dirs +
-- ['/usr/lib/termcap'],
-- 'termcap'):
-+ elif self.compiler.find_library_file(lib_dirs, 'termcap'):
- readline_libs.append('termcap')
- exts.append( Extension('readline', ['readline.c'],
-- library_dirs=['/usr/lib/termcap'],
- extra_link_args=readline_extra_link_args,
- libraries=readline_libs) )
- else:
+++ /dev/null
-Add a backport of http://bugs.python.org/issue16235 so we can use
-python-config for cross builds.
-This basically replaces the python version of python-config with a pure-shell
-version that's already preprocessed when installed and doesn't depend
-on the sysconfig import that usually leads to bad data/results.
-
-Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
-
-Index: b/configure.ac
-===================================================================
---- a/configure.ac
-+++ b/configure.ac
-@@ -882,6 +882,7 @@
-
- # Other platforms follow
- if test $enable_shared = "yes"; then
-+ PY_ENABLE_SHARED=1
- AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
- case $ac_sys_system in
- BeOS*)
-@@ -942,6 +943,7 @@
-
- esac
- else # shared is disabled
-+ PY_ENABLE_SHARED=0
- case $ac_sys_system in
- CYGWIN*)
- BLDLIBRARY='$(LIBRARY)'
-@@ -1918,6 +1920,9 @@
- AC_SUBST(BLDSHARED)
- AC_SUBST(CCSHARED)
- AC_SUBST(LINKFORSHARED)
-+AC_SUBST(PY_ENABLE_SHARED)
-+LIBPL="${prefix}/lib/python${VERSION}/config"
-+AC_SUBST(LIBPL)
- # SO is the extension of shared libraries `(including the dot!)
- # -- usually .so, .sl on HP-UX, .dll on Cygwin
- AC_MSG_CHECKING(SO)
-@@ -4581,7 +4586,7 @@
- AC_SUBST(ENSUREPIP)
-
- # generate output files
--AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
-+AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc Misc/python-config.sh)
- AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
- AC_OUTPUT
-
-Index: b/Makefile.pre.in
-===================================================================
---- a/Makefile.pre.in
-+++ b/Makefile.pre.in
-@@ -166,7 +166,7 @@
- SUBDIRSTOO= Include Lib Misc Demo
-
- # Files and directories to be distributed
--CONFIGFILES= configure configure.ac acconfig.h pyconfig.h.in Makefile.pre.in
-+CONFIGFILES= configure configure.ac acconfig.h pyconfig.h.in Makefile.pre.in Misc/python-config.sh
- DISTFILES= README ChangeLog $(CONFIGFILES)
- DISTDIRS= $(SUBDIRS) $(SUBDIRSTOO) Ext-dummy
- DIST= $(DISTFILES) $(DISTDIRS)
-@@ -410,7 +410,7 @@
-
- # Default target
- all: build_all
--build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks
-+build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks python-config
-
- # Compile a binary with gcc profile guided optimization.
- profile-opt:
-@@ -1101,10 +1101,12 @@
- fi; \
- cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen
-
--python-config: $(srcdir)/Misc/python-config.in
-+python-config: $(srcdir)/Misc/python-config.in Misc/python-config.sh
- # Substitution happens here, as the completely-expanded BINDIR
- # is not available in configure
-- sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config
-+ sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config.py
-+ # Replace makefile compat. variable references with shell script compat. ones; $(VAR) -> ${VAR}
-+ sed -e 's,\$$(\([A-Za-z0-9_]*\)),\$$\{\1\},g' Misc/python-config.sh >python-config
-
- # Install the include files
- INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)
-@@ -1163,7 +1165,7 @@
- $(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup
- $(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh
- $(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(VERSION)-config
-- rm python-config
-+ $(INSTALL_SCRIPT) python-config.py $(DESTDIR)$(LIBPL)/python-config.py
- @if [ -s Modules/python.exp -a \
- "`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \
- echo; echo "Installing support files for building shared extension modules on AIX:"; \
-@@ -1345,6 +1347,7 @@
- config.cache config.log pyconfig.h Modules/config.c
- -rm -rf build platform
- -rm -rf $(PYTHONFRAMEWORKDIR)
-+ -rm -f python-config.py python-config
-
- # Make things extra clean, before making a distribution:
- # remove all generated files, even Makefile[.pre]
-Index: b/Misc/python-config.sh.in
-===================================================================
---- /dev/null
-+++ b/Misc/python-config.sh.in
-@@ -0,0 +1,102 @@
-+#!/bin/sh
-+
-+exit_with_usage ()
-+{
-+ echo "Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--configdir"
-+ exit $1
-+}
-+
-+if [ "$1" = "" ] ; then
-+ exit_with_usage 1
-+fi
-+
-+# Returns the actual prefix where this script was installed to.
-+installed_prefix ()
-+{
-+ RESULT=$(dirname $(cd $(dirname "$1") && pwd -P))
-+ if which readlink >/dev/null 2>&1 ; then
-+ RESULT=$(readlink -f "$RESULT")
-+ fi
-+ echo $RESULT
-+}
-+
-+prefix_build="@prefix@"
-+prefix_real=$(installed_prefix "$0")
-+
-+# Use sed to fix paths from their built to locations to their installed to locations.
-+prefix=$(echo "$prefix_build" | sed "s#$prefix_build#$prefix_real#")
-+exec_prefix_build="@exec_prefix@"
-+exec_prefix=$(echo "$exec_prefix_build" | sed "s#$exec_prefix_build#$prefix_real#")
-+includedir=$(echo "@includedir@")
-+libdir=$(echo "@libdir@" | sed "s#$prefix_build#$prefix_real#")
-+CFLAGS=$(echo "@CFLAGS@" | sed "s#$prefix_build#$prefix_real#")
-+VERSION="@VERSION@"
-+LIBM="@LIBM@"
-+LIBC="@LIBC@"
-+SYSLIBS="$LIBM $LIBC"
-+LIBS="@LIBS@ $SYSLIBS -lpython${VERSION}"
-+BASECFLAGS="@BASECFLAGS@"
-+LDLIBRARY="@LDLIBRARY@"
-+LINKFORSHARED="@LINKFORSHARED@"
-+OPT="@OPT@"
-+PY_ENABLE_SHARED="@PY_ENABLE_SHARED@"
-+LDVERSION="@LDVERSION@"
-+LIBDEST=${prefix}/lib/python${VERSION}
-+LIBPL=$(echo "@LIBPL@" | sed "s#$prefix_build#$prefix_real#")
-+SO="@SO@"
-+PYTHONFRAMEWORK="@PYTHONFRAMEWORK@"
-+INCDIR="-I$includedir/python${VERSION}"
-+PLATINCDIR="-I$includedir/python${VERSION}"
-+
-+# Scan for --help or unknown argument.
-+for ARG in $*
-+do
-+ case $ARG in
-+ --help)
-+ exit_with_usage 0
-+ ;;
-+ --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--abiflags|--configdir)
-+ ;;
-+ *)
-+ exit_with_usage 1
-+ ;;
-+esac
-+done
-+
-+for ARG in "$@"
-+do
-+ case "$ARG" in
-+ --prefix)
-+ echo "$prefix"
-+ ;;
-+ --exec-prefix)
-+ echo "$exec_prefix"
-+ ;;
-+ --includes)
-+ echo "$INCDIR $PLATINCDIR"
-+ ;;
-+ --cflags)
-+ echo "$INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT"
-+ ;;
-+ --libs)
-+ echo "$LIBS"
-+ ;;
-+ --ldflags)
-+ LINKFORSHAREDUSED=
-+ if [ -z "$PYTHONFRAMEWORK" ] ; then
-+ LINKFORSHAREDUSED=$LINKFORSHARED
-+ fi
-+ LIBPLUSED=
-+ if [ "$PY_ENABLE_SHARED" = "0" ] ; then
-+ LIBPLUSED="-L$LIBPL"
-+ fi
-+ echo "$LIBPLUSED -L$libdir $LIBS $LINKFORSHAREDUSED"
-+ ;;
-+ --extension-suffix)
-+ echo "$SO"
-+ ;;
-+ --configdir)
-+ echo "$LIBPL"
-+ ;;
-+esac
-+done
+++ /dev/null
-Remove the python symlink install rules.
-
-The python symlink installation will be handled by Buildroot itself, because
-Buildroot needs to control to what python interpreter (python2 or python3) the
-python symlink points to.
-
-Signed-off-by: Samuel Martin <s.martin49@gmail.com>
-
-Index: b/Makefile.pre.in
-===================================================================
---- a/Makefile.pre.in
-+++ b/Makefile.pre.in
-@@ -890,17 +890,10 @@
- # $(PYTHON) -> python2 -> python$(VERSION))
- # Also create equivalent chains for other installed files
- bininstall: altbininstall
-- -if test -f $(DESTDIR)$(BINDIR)/$(PYTHON) -o -h $(DESTDIR)$(BINDIR)/$(PYTHON); \
-- then rm -f $(DESTDIR)$(BINDIR)/$(PYTHON); \
-- else true; \
-- fi
-- (cd $(DESTDIR)$(BINDIR); $(LN) -s python2$(EXE) $(PYTHON))
- -rm -f $(DESTDIR)$(BINDIR)/python2$(EXE)
- (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)$(EXE) python2$(EXE))
- -rm -f $(DESTDIR)$(BINDIR)/python2-config
- (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-config python2-config)
-- -rm -f $(DESTDIR)$(BINDIR)/python-config
-- (cd $(DESTDIR)$(BINDIR); $(LN) -s python2-config python-config)
- -test -d $(DESTDIR)$(LIBPC) || $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(LIBPC)
- -rm -f $(DESTDIR)$(LIBPC)/python2.pc
- (cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION).pc python2.pc)
+++ /dev/null
-python: do not rely only on LIBRARY_PATH for old compilers
-
-The cross-compilation improvements integrated in Python rely on the
-compiler exposing a line starting with LIBRARY_PATH when called with
--E -v. This is used by Python setup.py to find the installation
-locations of libraries.
-
-However, this LIBRARY_PATH line is not shown by very old compilers,
-such as the gcc 4.2.x compiler used on the AVR32 architecture. This
-causes libraries installed in the sysroot, such as libffi, to not be
-detected by the setup.py script.
-
-To fix this problem, this patch adds addtional logic to setup.py,
-which consists in deriving the library paths from the sysroot
-location, if no LIBRARY_PATH field was found.
-
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-
-Index: b/setup.py
-===================================================================
---- a/setup.py
-+++ b/setup.py
-@@ -418,6 +418,7 @@
- in_incdirs = False
- inc_dirs = []
- lib_dirs = []
-+ compiler_has_library_path = False
- try:
- if ret >> 8 == 0:
- with open(tmpfile) as fp:
-@@ -429,6 +430,7 @@
- elif line.startswith("End of search list"):
- in_incdirs = False
- elif is_gcc and line.startswith("LIBRARY_PATH"):
-+ compiler_has_library_path = True
- for d in line.strip().split("=")[1].split(":"):
- d = os.path.normpath(d)
- if '/gcc/' not in d:
-@@ -440,6 +442,15 @@
- finally:
- os.unlink(tmpfile)
-
-+ if not compiler_has_library_path:
-+ ret = os.system("%s -print-file-name=libc.a | sed -r -e 's:(usr/)?lib(32|64)?/([^/]*/)?libc\.a::' >%s" % (gcc, tmpfile))
-+ with open(tmpfile) as fp:
-+ line = fp.readline().strip()
-+ add_dir_to_list(self.compiler.library_dirs,
-+ os.path.join(line, "usr", "lib"))
-+ add_dir_to_list(self.compiler.library_dirs,
-+ os.path.join(line, "lib"))
-+
- def detect_modules(self):
- # Ensure that /usr/local is always used
- if not cross_compiling:
+++ /dev/null
-Don't add multiarch paths
-
-The add_multiarch_paths() function leads, in certain build
-environments, to the addition of host header paths to the CFLAGS,
-which is not appropriate for cross-compilation. This patch fixes that
-by simply removing the call to add_multiarch_paths() when we're
-cross-compiling.
-
-Investigation done by David <buildroot-2014@inbox.com>.
-
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-
-Index: b/setup.py
-===================================================================
---- a/setup.py
-+++ b/setup.py
-@@ -456,9 +456,9 @@
- if not cross_compiling:
- add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
- add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
-+ self.add_multiarch_paths()
- if cross_compiling:
- self.add_gcc_paths()
-- self.add_multiarch_paths()
-
- # Add paths specified in the environment variables LDFLAGS and
- # CPPFLAGS for header and library files.
+++ /dev/null
-Abort on failed module build
-
-When building a Python module fails, the setup.py script currently
-doesn't exit with an error, and simply continues. This is not a really
-nice behavior, so this patch changes setup.py to abort with an error,
-so that the build issue is clearly noticeable.
-
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-
-Index: b/setup.py
-===================================================================
---- a/setup.py
-+++ b/setup.py
-@@ -283,6 +283,7 @@
- print "Failed to build these modules:"
- print_three_column(failed)
- print
-+ sys.exit(1)
-
- def build_extension(self, ext):
-
+++ /dev/null
-sqlite3: fix build when threads are not used/available
-
-When threads are not used/available, a function in the sqlite3 extension
-ends up with a label at the end:
-
- void _pysqlite_final_callback(sqlite3_context* context)
- {
- PyObject* function_result;
- PyObject** aggregate_instance;
- int ok;
-
- #ifdef WITH_THREAD
- PyGILState_STATE threadstate;
-
- threadstate = PyGILState_Ensure();
- #endif
-
- aggregate_instance = (PyObject**)sqlite3_aggregate_context(context, sizeof(PyObject*));
- if (!*aggregate_instance) {
- goto error;
- }
-
- [......]
-
- error:
- #ifdef WITH_THREAD
- PyGILState_Release(threadstate);
- #endif
- }
-
-This is not valid, and gcc complains.
-
-Fix that by adding a dummy statement after the label, so that the label
-is never the last statement of the function.
-
-Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
-
-Index: b/Modules/_sqlite/connection.c
-===================================================================
---- a/Modules/_sqlite/connection.c
-+++ b/Modules/_sqlite/connection.c
-@@ -786,6 +786,7 @@
- #ifdef WITH_THREAD
- PyGILState_Release(threadstate);
- #endif
-+ ; /* Make gcc happy: a label can't be at the end of a function */
- }
-
- static void _pysqlite_drop_unused_statement_references(pysqlite_Connection* self)
+++ /dev/null
-Serial ioctl() workaround
-
-The ioctls.h of some architectures (notably xtensa) references structs from
-linux/serial.h. Make sure to include this header as well.
-
-Also, undef TIOCTTYGSTRUCT that require reference to internal kernel tty_struct,
-but isn't actually referenced in modern kernels.
-
-Signed-off-by: Baruch Siach <baruch@tkos.co.il>
----
-Index: b/Modules/termios.c
-===================================================================
---- a/Modules/termios.c
-+++ b/Modules/termios.c
-@@ -16,7 +16,9 @@
- * so this needs to be included first on that platform. */
- #include <termio.h>
- #endif
-+#include <linux/serial.h>
- #include <sys/ioctl.h>
-+#undef TIOCTTYGSTRUCT
-
- /* HP-UX requires that this be included to pick up MDCD, MCTS, MDSR,
- * MDTR, MRI, and MRTS (appearantly used internally by some things
+++ /dev/null
-Do not adjust the shebang of Python scripts for cross-compilation
-
-The copy_scripts() method in distutils copies the scripts listed in
-the setup file and adjusts the first line to refer to the current
-Python interpreter. When cross-compiling, this means that the adjusted
-shebang refers to the host Python interpreter.
-
-This patch modifies copy_scripts() to preserve the shebang when
-cross-compilation is detected.
-
-Signed-off-by: Christophe Vu-Brugier <cvubrugier@fastmail.fm>
-
-Index: b/Lib/distutils/command/build_scripts.py
-===================================================================
---- a/Lib/distutils/command/build_scripts.py
-+++ b/Lib/distutils/command/build_scripts.py
-@@ -89,7 +89,7 @@
- adjust = 1
- post_interp = match.group(1) or ''
-
-- if adjust:
-+ if adjust and not '_python_sysroot' in os.environ:
- log.info("copying and adjusting %s -> %s", script,
- self.build_dir)
- if not self.dry_run:
+++ /dev/null
-Add an option to disable installation of test modules
-
-The Python standard distribution comes with many test modules, that
-are not necessarly useful on embedded targets.
-
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-Signed-off-by: Samuel Martin <s.martin49@gmail.com>
-
----
- Makefile.pre.in | 40 +++++++++++++++++++++++++++-------------
- configure.in | 6 ++++++
- 2 files changed, 33 insertions(+), 13 deletions(-)
-
-Index: b/Makefile.pre.in
-===================================================================
---- a/Makefile.pre.in
-+++ b/Makefile.pre.in
-@@ -960,27 +960,43 @@
- plat-mac/lib-scriptpackages/SystemEvents \
- plat-mac/lib-scriptpackages/Terminal
- PLATMACPATH=:plat-mac:plat-mac/lib-scriptpackages
--LIBSUBDIRS= lib-tk lib-tk/test lib-tk/test/test_tkinter \
-- lib-tk/test/test_ttk site-packages test test/audiodata test/capath \
-- test/data test/cjkencodings test/decimaltestdata test/xmltestdata \
-- test/imghdrdata \
-- test/subprocessdata \
-- test/tracedmodules \
-+LIBSUBDIRS= lib-tk site-packages \
- encodings compiler hotshot \
-- email email/mime email/test email/test/data \
-+ email email/mime \
- ensurepip ensurepip/_bundled \
-- json json/tests \
-- sqlite3 sqlite3/test \
-- logging bsddb bsddb/test csv importlib wsgiref \
-- lib2to3 lib2to3/fixes lib2to3/pgen2 lib2to3/tests \
-- lib2to3/tests/data lib2to3/tests/data/fixers lib2to3/tests/data/fixers/myfixes \
-- ctypes ctypes/test ctypes/macholib \
-- idlelib idlelib/Icons idlelib/idle_test \
-- distutils distutils/command distutils/tests $(XMLLIBSUBDIRS) \
-+ json \
-+ sqlite3 \
-+ logging bsddb csv importlib wsgiref \
-+ lib2to3 lib2to3/fixes lib2to3/pgen2 \
-+ ctypes ctypes/macholib \
-+ idlelib idlelib/Icons \
-+ distutils distutils/command $(XMLLIBSUBDIRS) \
- multiprocessing multiprocessing/dummy \
-- unittest unittest/test \
-+ unittest \
- lib-old \
- curses pydoc_data $(MACHDEPS)
-+
-+TESTSUBDIRS = lib-tk/test lib-tk/test/test_tkinter \
-+ lib-tk/test/test_ttk test test/audiodata test/capath test/data \
-+ test/cjkencodings test/decimaltestdata test/xmltestdata \
-+ test/imghdrdata \
-+ test/subprocessdata \
-+ test/tracedmodules \
-+ email/test email/test/data \
-+ json/tests \
-+ sqlite3/test \
-+ bsddb/test \
-+ lib2to3/tests \
-+ lib2to3/tests/data lib2to3/tests/data/fixers lib2to3/tests/data/fixers/myfixes \
-+ ctypes/test \
-+ idlelib/idle_test \
-+ distutils/tests \
-+ unittest/test
-+
-+ifeq (@TEST_MODULES@,yes)
-+LIBSUBDIRS += $(TESTSUBDIRS)
-+endif
-+
- libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
- @for i in $(SCRIPTDIR) $(LIBDEST); \
- do \
-Index: b/configure.ac
-===================================================================
---- a/configure.ac
-+++ b/configure.ac
-@@ -2628,6 +2628,12 @@
- fi
-
-
-+AC_SUBST(TEST_MODULES)
-+
-+AC_ARG_ENABLE(test-modules,
-+ AS_HELP_STRING([--disable-test-modules], [disable test modules]),
-+ [ TEST_MODULES="${enableval}" ], [ TEST_MODULES=yes ])
-+
- # Check for enable-ipv6
- AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
- AC_MSG_CHECKING([if --enable-ipv6 is specified])
+++ /dev/null
-Add an option to disable pydoc
-
-It removes 0.5 MB of data from the target plus the pydoc script
-itself.
-
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-Signed-off-by: Samuel Martin <s.martin49@gmail.com>
-
----
- Makefile.pre.in | 6 +++++-
- configure.in | 5 +++++
- setup.py | 10 +++++++---
- 3 files changed, 17 insertions(+), 4 deletions(-)
-
-Index: b/Makefile.pre.in
-===================================================================
---- a/Makefile.pre.in
-+++ b/Makefile.pre.in
-@@ -974,7 +974,7 @@
- multiprocessing multiprocessing/dummy \
- unittest \
- lib-old \
-- curses pydoc_data $(MACHDEPS)
-+ curses $(MACHDEPS)
-
- TESTSUBDIRS = lib-tk/test lib-tk/test/test_tkinter \
- lib-tk/test/test_ttk test test/audiodata test/capath test/data \
-@@ -997,6 +997,10 @@
- LIBSUBDIRS += $(TESTSUBDIRS)
- endif
-
-+ifeq (@PYDOC@,yes)
-+LIBSUBDIRS += pydoc_data
-+endif
-+
- libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
- @for i in $(SCRIPTDIR) $(LIBDEST); \
- do \
-Index: b/configure.ac
-===================================================================
---- a/configure.ac
-+++ b/configure.ac
-@@ -2627,6 +2627,11 @@
- AC_CHECK_FUNCS(pthread_atfork)
- fi
-
-+AC_SUBST(PYDOC)
-+
-+AC_ARG_ENABLE(pydoc,
-+ AS_HELP_STRING([--disable-pydoc], [disable pydoc]),
-+ [ PYDOC="${enableval}" ], [ PYDOC=yes ])
-
- AC_SUBST(TEST_MODULES)
-
-Index: b/setup.py
-===================================================================
---- a/setup.py
-+++ b/setup.py
-@@ -2222,6 +2222,12 @@
- # turn off warnings when deprecated modules are imported
- import warnings
- warnings.filterwarnings("ignore",category=DeprecationWarning)
-+
-+ scripts = ['Tools/scripts/idle', 'Tools/scripts/2to3',
-+ 'Lib/smtpd.py']
-+ if not '--disable-pydoc' in sysconfig.get_config_var("CONFIG_ARGS"):
-+ scripts += [ 'Tools/scripts/pydoc' ]
-+
- setup(# PyPI Metadata (PEP 301)
- name = "Python",
- version = sys.version.split()[0],
-@@ -2242,9 +2248,7 @@
- ext_modules=[Extension('_struct', ['_struct.c'])],
-
- # Scripts to install
-- scripts = ['Tools/scripts/pydoc', 'Tools/scripts/idle',
-- 'Tools/scripts/2to3',
-- 'Lib/smtpd.py']
-+ scripts = scripts,
- )
-
- # --install-platlib
+++ /dev/null
-Add an option to disable lib2to3
-
-lib2to3 is a library to convert Python 2.x code to Python 3.x. As
-such, it is probably not very useful on embedded system targets.
-
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-Signed-off-by: Samuel Martin <s.martin49@gmail.com>
-
----
- Makefile.pre.in | 24 +++++++++++++++++-------
- configure.in | 6 ++++++
- setup.py | 5 +++--
- 3 files changed, 26 insertions(+), 9 deletions(-)
-
-Index: b/Makefile.pre.in
-===================================================================
---- a/Makefile.pre.in
-+++ b/Makefile.pre.in
-@@ -967,7 +967,6 @@
- json \
- sqlite3 \
- logging bsddb csv importlib wsgiref \
-- lib2to3 lib2to3/fixes lib2to3/pgen2 \
- ctypes ctypes/macholib \
- idlelib idlelib/Icons \
- distutils distutils/command $(XMLLIBSUBDIRS) \
-@@ -986,8 +985,6 @@
- json/tests \
- sqlite3/test \
- bsddb/test \
-- lib2to3/tests \
-- lib2to3/tests/data lib2to3/tests/data/fixers lib2to3/tests/data/fixers/myfixes \
- ctypes/test \
- idlelib/idle_test \
- distutils/tests \
-@@ -1001,6 +998,14 @@
- LIBSUBDIRS += pydoc_data
- endif
-
-+ifeq (@LIB2TO3@,yes)
-+LIBSUBDIRS += lib2to3 lib2to3/fixes lib2to3/pgen2
-+TESTSUBDIRS += lib2to3/tests \
-+ lib2to3/tests/data \
-+ lib2to3/tests/data/fixers \
-+ lib2to3/tests/data/fixers/myfixes
-+endif
-+
- libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
- @for i in $(SCRIPTDIR) $(LIBDEST); \
- do \
-Index: b/configure.ac
-===================================================================
---- a/configure.ac
-+++ b/configure.ac
-@@ -2639,6 +2639,12 @@
- AS_HELP_STRING([--disable-test-modules], [disable test modules]),
- [ TEST_MODULES="${enableval}" ], [ TEST_MODULES=yes ])
-
-+AC_SUBST(LIB2TO3)
-+
-+AC_ARG_ENABLE(lib2to3,
-+ AS_HELP_STRING([--disable-lib2to3], [disable lib2to3]),
-+ [ LIB2TO3="${enableval}" ], [ LIB2TO3=yes ])
-+
- # Check for enable-ipv6
- AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
- AC_MSG_CHECKING([if --enable-ipv6 is specified])
-Index: b/setup.py
-===================================================================
---- a/setup.py
-+++ b/setup.py
-@@ -2223,10 +2223,11 @@
- import warnings
- warnings.filterwarnings("ignore",category=DeprecationWarning)
-
-- scripts = ['Tools/scripts/idle', 'Tools/scripts/2to3',
-- 'Lib/smtpd.py']
-+ scripts = ['Tools/scripts/idle', 'Lib/smtpd.py']
- if not '--disable-pydoc' in sysconfig.get_config_var("CONFIG_ARGS"):
- scripts += [ 'Tools/scripts/pydoc' ]
-+ if not '--disable-lib2to3' in sysconfig.get_config_var("CONFIG_ARGS"):
-+ scripts += [ 'Tools/scripts/2to3' ]
-
- setup(# PyPI Metadata (PEP 301)
- name = "Python",
+++ /dev/null
-Add option to disable the sqlite3 module
-
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-Signed-off-by: Samuel Martin <s.martin49@gmail.com>
-
----
- Makefile.pre.in | 24 +++++++++++++++++-------
- configure.in | 9 +++++++++
- 2 file changed, 9 insertions(+)
-
-Index: b/configure.ac
-===================================================================
---- a/configure.ac
-+++ b/configure.ac
-@@ -2627,6 +2627,15 @@
- AC_CHECK_FUNCS(pthread_atfork)
- fi
-
-+AC_SUBST(SQLITE3)
-+AC_ARG_ENABLE(sqlite3,
-+ AS_HELP_STRING([--disable-sqlite3], [disable sqlite3]),
-+ [ SQLITE3="${enableval}" ], [ SQLITE3=yes ])
-+
-+if test "$SQLITE3" = "no" ; then
-+ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} _sqlite3"
-+fi
-+
- AC_SUBST(PYDOC)
-
- AC_ARG_ENABLE(pydoc,
-Index: b/Makefile.pre.in
-===================================================================
---- a/Makefile.pre.in
-+++ b/Makefile.pre.in
-@@ -965,7 +965,6 @@
- email email/mime \
- ensurepip ensurepip/_bundled \
- json \
-- sqlite3 \
- logging bsddb csv importlib wsgiref \
- ctypes ctypes/macholib \
- idlelib idlelib/Icons \
-@@ -983,7 +982,6 @@
- test/tracedmodules \
- email/test email/test/data \
- json/tests \
-- sqlite3/test \
- bsddb/test \
- ctypes/test \
- idlelib/idle_test \
-@@ -1006,6 +1004,11 @@
- lib2to3/tests/data/fixers/myfixes
- endif
-
-+ifeq (@SQLITE3@,yes)
-+LIBSUBDIRS += sqlite3
-+TESTSUBDIRS += sqlite3/test
-+endif
-+
- libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
- @for i in $(SCRIPTDIR) $(LIBDEST); \
- do \
+++ /dev/null
-Add an option to disable the tk module
-
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-Signed-off-by: Samuel Martin <s.martin49@gmail.com>
-
----
- Makefile.pre.in | 14 ++++++++++----
- configure.in | 9 +++++++++
- 2 files changed, 19 insertions(+), 4 deletions(-)
-
-Index: b/Makefile.pre.in
-===================================================================
---- a/Makefile.pre.in
-+++ b/Makefile.pre.in
-@@ -960,7 +960,7 @@
- plat-mac/lib-scriptpackages/SystemEvents \
- plat-mac/lib-scriptpackages/Terminal
- PLATMACPATH=:plat-mac:plat-mac/lib-scriptpackages
--LIBSUBDIRS= lib-tk site-packages \
-+LIBSUBDIRS= site-packages \
- encodings compiler hotshot \
- email email/mime \
- ensurepip ensurepip/_bundled \
-@@ -974,8 +974,7 @@
- lib-old \
- curses $(MACHDEPS)
-
--TESTSUBDIRS = lib-tk/test lib-tk/test/test_tkinter \
-- lib-tk/test/test_ttk test test/audiodata test/capath test/data \
-+TESTSUBDIRS = test test/audiodata test/capath test/data \
- test/cjkencodings test/decimaltestdata test/xmltestdata \
- test/imghdrdata \
- test/subprocessdata \
-@@ -1009,6 +1008,12 @@
- TESTSUBDIRS += sqlite3/test
- endif
-
-+ifeq (@TK@,yes)
-+LIBSUBDIRS += lib-tk
-+TESTSUBDIRS += lib-tk/test lib-tk/test/test_tkinter \
-+ lib-tk/test/test_ttk
-+endif
-+
- libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
- @for i in $(SCRIPTDIR) $(LIBDEST); \
- do \
-Index: b/configure.ac
-===================================================================
---- a/configure.ac
-+++ b/configure.ac
-@@ -2636,6 +2636,15 @@
- DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} _sqlite3"
- fi
-
-+AC_SUBST(TK)
-+AC_ARG_ENABLE(tk,
-+ AS_HELP_STRING([--disable-tk], [disable tk]),
-+ [ TK="${enableval}" ], [ TK=yes ])
-+
-+if test "$TK" = "no"; then
-+ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} _tkinter"
-+fi
-+
- AC_SUBST(PYDOC)
-
- AC_ARG_ENABLE(pydoc,
+++ /dev/null
-Add an option to disable the curses module
-
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-Signed-off-by: Samuel Martin <s.martin49@gmail.com>
-
----
- Makefile.pre.in | 6 +++++-
- configure.in | 9 +++++++++
- 2 files changed, 14 insertions(+), 1 deletion(-)
-
-Index: b/Makefile.pre.in
-===================================================================
---- a/Makefile.pre.in
-+++ b/Makefile.pre.in
-@@ -972,7 +972,7 @@
- multiprocessing multiprocessing/dummy \
- unittest \
- lib-old \
-- curses $(MACHDEPS)
-+ $(MACHDEPS)
-
- TESTSUBDIRS = test test/audiodata test/capath test/data \
- test/cjkencodings test/decimaltestdata test/xmltestdata \
-@@ -1014,6 +1014,10 @@
- lib-tk/test/test_ttk
- endif
-
-+ifeq (@CURSES@,yes)
-+LIBSUBDIRS += curses
-+endif
-+
- libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
- @for i in $(SCRIPTDIR) $(LIBDEST); \
- do \
-Index: b/configure.ac
-===================================================================
---- a/configure.ac
-+++ b/configure.ac
-@@ -2645,6 +2645,15 @@
- DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} _tkinter"
- fi
-
-+AC_SUBST(CURSES)
-+AC_ARG_ENABLE(curses,
-+ AS_HELP_STRING([--disable-curses], [disable curses]),
-+ [ CURSES="${enableval}" ], [ CURSES=yes ])
-+
-+if test "$CURSES" = "no"; then
-+ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} _curses _curses_panel"
-+fi
-+
- AC_SUBST(PYDOC)
-
- AC_ARG_ENABLE(pydoc,
+++ /dev/null
-Add an option to disable expat
-
-This patch replaces the existing --with-system-expat option with a
---with-expat={system,builtin,none} option, which allows to tell Python
-whether we want to use the system expat (already installed), the expat
-builtin the Python sources, or no expat at all (which disables the
-installation of XML modules).
-
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-Signed-off-by: Samuel Martin <s.martin49@gmail.com>
-
----
- Makefile.pre.in | 6 +++++-
- configure.in | 18 +++++++++++++-----
- setup.py | 2 +-
- 3 files changed, 19 insertions(+), 7 deletions(-)
-
-Index: b/Makefile.pre.in
-===================================================================
---- a/Makefile.pre.in
-+++ b/Makefile.pre.in
-@@ -968,7 +968,7 @@
- logging bsddb csv importlib wsgiref \
- ctypes ctypes/macholib \
- idlelib idlelib/Icons \
-- distutils distutils/command $(XMLLIBSUBDIRS) \
-+ distutils distutils/command \
- multiprocessing multiprocessing/dummy \
- unittest \
- lib-old \
-@@ -1018,6 +1018,10 @@
- LIBSUBDIRS += curses
- endif
-
-+ifeq (@EXPAT@,yes)
-+LIBSUBDIRS += $(XMLLIBSUBDIRS)
-+endif
-+
- libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
- @for i in $(SCRIPTDIR) $(LIBDEST); \
- do \
-Index: b/configure.ac
-===================================================================
---- a/configure.ac
-+++ b/configure.ac
-@@ -2292,13 +2292,21 @@
- AC_SUBST(DISABLED_EXTENSIONS)
-
- # Check for use of the system expat library
--AC_MSG_CHECKING(for --with-system-expat)
--AC_ARG_WITH(system_expat,
-- AS_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library]),
-+AC_MSG_CHECKING(for --with-expat)
-+AC_ARG_WITH(expat,
-+ AS_HELP_STRING([--with-expat], [select which expat version to use: system, builtin, none]),
- [],
-- [with_system_expat="no"])
-+ [with_expat="builtin"])
-
--AC_MSG_RESULT($with_system_expat)
-+AC_MSG_RESULT($with_expat)
-+
-+if test "$with_expat" != "none"; then
-+ EXPAT=yes
-+else
-+ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} pyexpat"
-+ EXPAT=no
-+fi
-+AC_SUBST(EXPAT)
-
- # Check for use of the system libffi library
- AC_MSG_CHECKING(for --with-system-ffi)
-Index: b/setup.py
-===================================================================
---- a/setup.py
-+++ b/setup.py
-@@ -1474,7 +1474,7 @@
- #
- # More information on Expat can be found at www.libexpat.org.
- #
-- if '--with-system-expat' in sysconfig.get_config_var("CONFIG_ARGS"):
-+ if '--with-expat=system' in sysconfig.get_config_var("CONFIG_ARGS"):
- expat_inc = []
- define_macros = []
- expat_lib = ['expat']
+++ /dev/null
-Add an option to disable CJK codecs
-
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-
----
- configure.in | 6 ++++++
- 1 file changed, 6 insertions(+)
-
-Index: b/configure.ac
-===================================================================
---- a/configure.ac
-+++ b/configure.ac
-@@ -2644,6 +2644,12 @@
- DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} _sqlite3"
- fi
-
-+AC_ARG_ENABLE(codecs-cjk,
-+ AS_HELP_STRING([--disable-codecs-cjk], [disable CJK codecs]),
-+ [ if test "$enableval" = "no"; then
-+ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} _codecs_kr _codecs_jp _codecs_cn _codecs_tw _codecs_hk"
-+ fi])
-+
- AC_SUBST(TK)
- AC_ARG_ENABLE(tk,
- AS_HELP_STRING([--disable-tk], [disable tk]),
+++ /dev/null
-Add an option to disable NIS
-
-NIS is not necessarily available in uClibc, so we need an option to
-not compile support for it.
-
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-
----
- configure.in | 6 ++++++
- 1 file changed, 6 insertions(+)
-
-Index: b/configure.ac
-===================================================================
---- a/configure.ac
-+++ b/configure.ac
-@@ -2650,6 +2650,12 @@
- DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} _codecs_kr _codecs_jp _codecs_cn _codecs_tw _codecs_hk"
- fi])
-
-+AC_ARG_ENABLE(nis,
-+ AS_HELP_STRING([--disable-nis], [disable NIS]),
-+ [ if test "$enableval" = "no"; then
-+ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} nis"
-+ fi])
-+
- AC_SUBST(TK)
- AC_ARG_ENABLE(tk,
- AS_HELP_STRING([--disable-tk], [disable tk]),
+++ /dev/null
-Add an option to disable unicodedata
-
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-
----
- configure.in | 6 ++++++
- 1 file changed, 6 insertions(+)
-
-Index: b/configure.ac
-===================================================================
---- a/configure.ac
-+++ b/configure.ac
-@@ -2656,6 +2656,12 @@
- DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} nis"
- fi])
-
-+AC_ARG_ENABLE(unicodedata,
-+ AS_HELP_STRING([--disable-unicodedata], [disable unicodedata]),
-+ [ if test "$enableval" = "no"; then
-+ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} unicodedata"
-+ fi])
-+
- AC_SUBST(TK)
- AC_ARG_ENABLE(tk,
- AS_HELP_STRING([--disable-tk], [disable tk]),
+++ /dev/null
-Add an option to disable bsddb
-
-bsddb has an external dependency on Berkeley DB. Since we want to be
-able to build Python without it, this patch adds an option to disable
-the build/installation of this Python module.
-
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-Signed-off-by: Samuel Martin <s.martin49@gmail.com>
-
----
- Makefile.pre.in | 10 ++++++++--
- configure.in | 22 ++++++++++++++++++++++
- 2 files changed, 30 insertions(+), 2 deletions(-)
-
-Index: b/Makefile.pre.in
-===================================================================
---- a/Makefile.pre.in
-+++ b/Makefile.pre.in
-@@ -965,7 +965,7 @@
- email email/mime \
- ensurepip ensurepip/_bundled \
- json \
-- logging bsddb csv importlib wsgiref \
-+ logging csv importlib wsgiref \
- ctypes ctypes/macholib \
- idlelib idlelib/Icons \
- distutils distutils/command \
-@@ -981,7 +981,6 @@
- test/tracedmodules \
- email/test email/test/data \
- json/tests \
-- bsddb/test \
- ctypes/test \
- idlelib/idle_test \
- distutils/tests \
-@@ -1022,6 +1021,11 @@
- LIBSUBDIRS += $(XMLLIBSUBDIRS)
- endif
-
-+ifeq (@BSDDB@,yes)
-+LIBSUBDIRS += bsddb
-+TESTSUBDIRS += bsddb/test
-+endif
-+
- libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
- @for i in $(SCRIPTDIR) $(LIBDEST); \
- do \
-Index: b/configure.ac
-===================================================================
---- a/configure.ac
-+++ b/configure.ac
-@@ -2656,6 +2656,28 @@
- DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} nis"
- fi])
-
-+AC_ARG_ENABLE(dbm,
-+ AS_HELP_STRING([--disable-dbm], [disable DBM]),
-+ [ if test "$enableval" = "no"; then
-+ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} dbm"
-+ fi])
-+
-+AC_ARG_ENABLE(gdbm,
-+ AS_HELP_STRING([--disable-gdbm], [disable GDBM]),
-+ [ if test "$enableval" = "no"; then
-+ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} gdbm"
-+ fi])
-+
-+AC_SUBST(BSDDB)
-+AC_ARG_ENABLE(bsddb,
-+ AS_HELP_STRING([--disable-bsddb], [disable BerkeyleyDB]),
-+ [ if test "$enableval" = "no"; then
-+ BSDDB=no
-+ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} _bsddb"
-+ else
-+ BSDDB=yes
-+ fi], [ BSDDB=yes ])
-+
- AC_ARG_ENABLE(unicodedata,
- AS_HELP_STRING([--disable-unicodedata], [disable unicodedata]),
- [ if test "$enableval" = "no"; then
+++ /dev/null
-Add an option to disable the ssl module
-
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-
----
- configure.in | 6 ++++++
- 1 file changed, 6 insertions(+)
-
-Index: b/configure.ac
-===================================================================
---- a/configure.ac
-+++ b/configure.ac
-@@ -2656,6 +2656,12 @@
- DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} nis"
- fi])
-
-+AC_ARG_ENABLE(ssl,
-+ AS_HELP_STRING([--disable-ssl], [disable SSL]),
-+ [ if test "$enableval" = "no"; then
-+ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} ssl"
-+ fi])
-+
- AC_ARG_ENABLE(dbm,
- AS_HELP_STRING([--disable-dbm], [disable DBM]),
- [ if test "$enableval" = "no"; then
+++ /dev/null
-Add an option to disable the bz2 module
-
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
----
- configure.in | 6 ++++++
- 1 file changed, 6 insertions(+)
-
-Index: b/configure.ac
-===================================================================
---- a/configure.ac
-+++ b/configure.ac
-@@ -2662,6 +2662,12 @@
- DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} ssl"
- fi])
-
-+AC_ARG_ENABLE(bz2,
-+ AS_HELP_STRING([--disable-bz2], [disable BZIP2]),
-+ [ if test "$enableval" = "no"; then
-+ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} bz2"
-+ fi])
-+
- AC_ARG_ENABLE(dbm,
- AS_HELP_STRING([--disable-dbm], [disable DBM]),
- [ if test "$enableval" = "no"; then
+++ /dev/null
-Add an option to disable the zlib module
-
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
----
- configure.in | 6 ++++++
- 1 file changed, 6 insertions(+)
-
-Index: b/configure.ac
-===================================================================
---- a/configure.ac
-+++ b/configure.ac
-@@ -2668,6 +2668,12 @@
- DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} bz2"
- fi])
-
-+AC_ARG_ENABLE(zlib,
-+ AS_HELP_STRING([--disable-zlib], [disable ZLIB]),
-+ [ if test "$enableval" = "no"; then
-+ DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} zlib"
-+ fi])
-+
- AC_ARG_ENABLE(dbm,
- AS_HELP_STRING([--disable-dbm], [disable DBM]),
- [ if test "$enableval" = "no"; then
+++ /dev/null
-Do not install the idle editor
-
-IDLE is the Python IDE built with the tkinter GUI toolkit. Since it's
-highly unlikely to ever be useful in an embedded Linux system
-generated by Buildroot, this patch simply disables the installation of
-idle and the related Python modules. It saves 800 KB-900 KB of
-installed .pyc files.
-
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-
-Index: b/Makefile.pre.in
-===================================================================
---- a/Makefile.pre.in
-+++ b/Makefile.pre.in
-@@ -967,7 +967,6 @@
- json \
- logging csv importlib wsgiref \
- ctypes ctypes/macholib \
-- idlelib idlelib/Icons \
- distutils distutils/command \
- multiprocessing multiprocessing/dummy \
- unittest \
-@@ -982,7 +981,6 @@
- email/test email/test/data \
- json/tests \
- ctypes/test \
-- idlelib/idle_test \
- distutils/tests \
- unittest/test
-
-Index: b/setup.py
-===================================================================
---- a/setup.py
-+++ b/setup.py
-@@ -2223,7 +2223,7 @@
- import warnings
- warnings.filterwarnings("ignore",category=DeprecationWarning)
-
-- scripts = ['Tools/scripts/idle', 'Lib/smtpd.py']
-+ scripts = ['Lib/smtpd.py']
- if not '--disable-pydoc' in sysconfig.get_config_var("CONFIG_ARGS"):
- scripts += [ 'Tools/scripts/pydoc' ]
- if not '--disable-lib2to3' in sysconfig.get_config_var("CONFIG_ARGS"):