Merge "Push out python local patches to toolchain/python.git"
diff --git a/build/tools/build-host-python.sh b/build/tools/build-host-python.sh
index 08738ff..cf6aa6b 100755
--- a/build/tools/build-host-python.sh
+++ b/build/tools/build-host-python.sh
@@ -53,7 +53,7 @@
 TOOLCHAIN_SRC_DIR=
 register_var_option "--toolchain-src-dir=<path>" TOOLCHAIN_SRC_DIR "Select toolchain source directory"
 
-PYTHON_VERSION=2.7.3
+PYTHON_VERSION=$DEFAULT_PYTHON_VERSION
 register_var_option "--python-version=<version>" PYTHON_VERSION "Select Python version."
 
 NDK_DIR=$ANDROID_NDK_ROOT
diff --git a/build/tools/dev-defaults.sh b/build/tools/dev-defaults.sh
index ea3099f..5b6c0e3 100644
--- a/build/tools/dev-defaults.sh
+++ b/build/tools/dev-defaults.sh
@@ -40,6 +40,7 @@
 DEFAULT_MPC_VERSION=1.0.1
 DEFAULT_CLOOG_VERSION=0.17.0
 DEFAULT_PPL_VERSION=1.0
+DEFAULT_PYTHON_VERSION=2.7.3
 
 # Default platform to build target binaries against.
 DEFAULT_PLATFORM=android-9
diff --git a/build/tools/download-toolchain-sources.sh b/build/tools/download-toolchain-sources.sh
index 6e77e3a..ef14b5a 100755
--- a/build/tools/download-toolchain-sources.sh
+++ b/build/tools/download-toolchain-sources.sh
@@ -194,6 +194,7 @@
 toolchain_clone binutils
 toolchain_clone gcc
 toolchain_clone gdb
+toolchain_clone python
 toolchain_clone clang
 toolchain_clone llvm
 
@@ -207,6 +208,7 @@
 toolchain_checkout "" $BRANCH binutils binutils-2.19 binutils-2.21 binutils-2.22
 toolchain_checkout "" $BRANCH gcc gcc-4.4.3 gcc-4.6 gcc-4.7
 toolchain_checkout "" $BRANCH gdb gdb-6.6 gdb-7.3.x
+toolchain_checkout "" $BRANCH python Python-2.7.3
 
 for LLVM_VERSION in $LLVM_VERSION_LIST; do
     LLVM_VERSION_NO_DOT=$(echo $LLVM_VERSION | sed -e 's!\.!!g')
@@ -228,11 +230,6 @@
         find . -name "configure" -exec touch {} \; )
 done
 
-PYVERSION=2.7.3
-PYVERSION_FOLDER=$(echo ${PYVERSION} | sed 's/\([0-9\.]*\).*/\1/')
-dump "Downloading http://www.python.org/ftp/python/${PYVERSION_FOLDER}/Python-${PYVERSION}.tar.bz2"
-(mkdir -p $TMPDIR/python && cd $TMPDIR/python && run curl -S -O http://www.python.org/ftp/python/${PYVERSION_FOLDER}/Python-${PYVERSION}.tar.bz2 && tar -xjf Python-${PYVERSION}.tar.bz2)
-
 # Patch the toolchain sources
 if [ "$OPTION_NO_PATCHES" != "yes" ]; then
     PATCHES_DIR="$PROGDIR/toolchain-patches"
diff --git a/build/tools/toolchain-patches/python/Python-2.7.3/0000-CROSS.patch b/build/tools/toolchain-patches/python/Python-2.7.3/0000-CROSS.patch
deleted file mode 100644
index e4a84ee..0000000
--- a/build/tools/toolchain-patches/python/Python-2.7.3/0000-CROSS.patch
+++ /dev/null
@@ -1,4614 +0,0 @@
-diff -urN a/config.guess b/config.guess
---- a/config.guess	1970-01-01 01:00:00.000000000 +0100
-+++ b/config.guess	2012-06-25 19:39:10.609815624 +0100
-@@ -0,0 +1,1530 @@
-+#! /bin/sh
-+# Attempt to guess a canonical system name.
-+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
-+#   2011, 2012 Free Software Foundation, Inc.
-+
-+timestamp='2012-02-10'
-+
-+# This file is free software; you can redistribute it and/or modify it
-+# under the terms of the GNU General Public License as published by
-+# the Free Software Foundation; either version 2 of the License, or
-+# (at your option) any later version.
-+#
-+# This program is distributed in the hope that it will be useful, but
-+# WITHOUT ANY WARRANTY; without even the implied warranty of
-+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-+# General Public License for more details.
-+#
-+# You should have received a copy of the GNU General Public License
-+# along with this program; if not, see <http://www.gnu.org/licenses/>.
-+#
-+# As a special exception to the GNU General Public License, if you
-+# distribute this file as part of a program that contains a
-+# configuration script generated by Autoconf, you may include it under
-+# the same distribution terms that you use for the rest of that program.
-+
-+
-+# Originally written by Per Bothner.  Please send patches (context
-+# diff format) to <config-patches@gnu.org> and include a ChangeLog
-+# entry.
-+#
-+# This script attempts to guess a canonical system name similar to
-+# config.sub.  If it succeeds, it prints the system name on stdout, and
-+# exits with 0.  Otherwise, it exits with 1.
-+#
-+# You can get the latest version of this script from:
-+# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
-+
-+me=`echo "$0" | sed -e 's,.*/,,'`
-+
-+usage="\
-+Usage: $0 [OPTION]
-+
-+Output the configuration name of the system \`$me' is run on.
-+
-+Operation modes:
-+  -h, --help         print this help, then exit
-+  -t, --time-stamp   print date of last modification, then exit
-+  -v, --version      print version number, then exit
-+
-+Report bugs and patches to <config-patches@gnu.org>."
-+
-+version="\
-+GNU config.guess ($timestamp)
-+
-+Originally written by Per Bothner.
-+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
-+Free Software Foundation, Inc.
-+
-+This is free software; see the source for copying conditions.  There is NO
-+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
-+
-+help="
-+Try \`$me --help' for more information."
-+
-+# Parse command line
-+while test $# -gt 0 ; do
-+  case $1 in
-+    --time-stamp | --time* | -t )
-+       echo "$timestamp" ; exit ;;
-+    --version | -v )
-+       echo "$version" ; exit ;;
-+    --help | --h* | -h )
-+       echo "$usage"; exit ;;
-+    -- )     # Stop option processing
-+       shift; break ;;
-+    - )	# Use stdin as input.
-+       break ;;
-+    -* )
-+       echo "$me: invalid option $1$help" >&2
-+       exit 1 ;;
-+    * )
-+       break ;;
-+  esac
-+done
-+
-+if test $# != 0; then
-+  echo "$me: too many arguments$help" >&2
-+  exit 1
-+fi
-+
-+trap 'exit 1' 1 2 15
-+
-+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
-+# compiler to aid in system detection is discouraged as it requires
-+# temporary files to be created and, as you can see below, it is a
-+# headache to deal with in a portable fashion.
-+
-+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
-+# use `HOST_CC' if defined, but it is deprecated.
-+
-+# Portable tmp directory creation inspired by the Autoconf team.
-+
-+set_cc_for_build='
-+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
-+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
-+: ${TMPDIR=/tmp} ;
-+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
-+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
-+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
-+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
-+dummy=$tmp/dummy ;
-+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
-+case $CC_FOR_BUILD,$HOST_CC,$CC in
-+ ,,)    echo "int x;" > $dummy.c ;
-+	for c in cc gcc c89 c99 ; do
-+	  if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
-+	     CC_FOR_BUILD="$c"; break ;
-+	  fi ;
-+	done ;
-+	if test x"$CC_FOR_BUILD" = x ; then
-+	  CC_FOR_BUILD=no_compiler_found ;
-+	fi
-+	;;
-+ ,,*)   CC_FOR_BUILD=$CC ;;
-+ ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
-+esac ; set_cc_for_build= ;'
-+
-+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
-+# (ghazi@noc.rutgers.edu 1994-08-24)
-+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
-+	PATH=$PATH:/.attbin ; export PATH
-+fi
-+
-+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
-+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
-+UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
-+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
-+
-+# Note: order is significant - the case branches are not exclusive.
-+
-+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
-+    *:NetBSD:*:*)
-+	# NetBSD (nbsd) targets should (where applicable) match one or
-+	# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
-+	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
-+	# switched to ELF, *-*-netbsd* would select the old
-+	# object file format.  This provides both forward
-+	# compatibility and a consistent mechanism for selecting the
-+	# object file format.
-+	#
-+	# Note: NetBSD doesn't particularly care about the vendor
-+	# portion of the name.  We always set it to "unknown".
-+	sysctl="sysctl -n hw.machine_arch"
-+	UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
-+	    /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
-+	case "${UNAME_MACHINE_ARCH}" in
-+	    armeb) machine=armeb-unknown ;;
-+	    arm*) machine=arm-unknown ;;
-+	    sh3el) machine=shl-unknown ;;
-+	    sh3eb) machine=sh-unknown ;;
-+	    sh5el) machine=sh5le-unknown ;;
-+	    *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
-+	esac
-+	# The Operating System including object format, if it has switched
-+	# to ELF recently, or will in the future.
-+	case "${UNAME_MACHINE_ARCH}" in
-+	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)
-+		eval $set_cc_for_build
-+		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
-+			| grep -q __ELF__
-+		then
-+		    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
-+		    # Return netbsd for either.  FIX?
-+		    os=netbsd
-+		else
-+		    os=netbsdelf
-+		fi
-+		;;
-+	    *)
-+		os=netbsd
-+		;;
-+	esac
-+	# The OS release
-+	# Debian GNU/NetBSD machines have a different userland, and
-+	# thus, need a distinct triplet. However, they do not need
-+	# kernel version information, so it can be replaced with a
-+	# suitable tag, in the style of linux-gnu.
-+	case "${UNAME_VERSION}" in
-+	    Debian*)
-+		release='-gnu'
-+		;;
-+	    *)
-+		release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
-+		;;
-+	esac
-+	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
-+	# contains redundant information, the shorter form:
-+	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
-+	echo "${machine}-${os}${release}"
-+	exit ;;
-+    *:OpenBSD:*:*)
-+	UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
-+	echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
-+	exit ;;
-+    *:ekkoBSD:*:*)
-+	echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
-+	exit ;;
-+    *:SolidBSD:*:*)
-+	echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
-+	exit ;;
-+    macppc:MirBSD:*:*)
-+	echo powerpc-unknown-mirbsd${UNAME_RELEASE}
-+	exit ;;
-+    *:MirBSD:*:*)
-+	echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
-+	exit ;;
-+    alpha:OSF1:*:*)
-+	case $UNAME_RELEASE in
-+	*4.0)
-+		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
-+		;;
-+	*5.*)
-+		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
-+		;;
-+	esac
-+	# According to Compaq, /usr/sbin/psrinfo has been available on
-+	# OSF/1 and Tru64 systems produced since 1995.  I hope that
-+	# covers most systems running today.  This code pipes the CPU
-+	# types through head -n 1, so we only detect the type of CPU 0.
-+	ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
-+	case "$ALPHA_CPU_TYPE" in
-+	    "EV4 (21064)")
-+		UNAME_MACHINE="alpha" ;;
-+	    "EV4.5 (21064)")
-+		UNAME_MACHINE="alpha" ;;
-+	    "LCA4 (21066/21068)")
-+		UNAME_MACHINE="alpha" ;;
-+	    "EV5 (21164)")
-+		UNAME_MACHINE="alphaev5" ;;
-+	    "EV5.6 (21164A)")
-+		UNAME_MACHINE="alphaev56" ;;
-+	    "EV5.6 (21164PC)")
-+		UNAME_MACHINE="alphapca56" ;;
-+	    "EV5.7 (21164PC)")
-+		UNAME_MACHINE="alphapca57" ;;
-+	    "EV6 (21264)")
-+		UNAME_MACHINE="alphaev6" ;;
-+	    "EV6.7 (21264A)")
-+		UNAME_MACHINE="alphaev67" ;;
-+	    "EV6.8CB (21264C)")
-+		UNAME_MACHINE="alphaev68" ;;
-+	    "EV6.8AL (21264B)")
-+		UNAME_MACHINE="alphaev68" ;;
-+	    "EV6.8CX (21264D)")
-+		UNAME_MACHINE="alphaev68" ;;
-+	    "EV6.9A (21264/EV69A)")
-+		UNAME_MACHINE="alphaev69" ;;
-+	    "EV7 (21364)")
-+		UNAME_MACHINE="alphaev7" ;;
-+	    "EV7.9 (21364A)")
-+		UNAME_MACHINE="alphaev79" ;;
-+	esac
-+	# A Pn.n version is a patched version.
-+	# A Vn.n version is a released version.
-+	# A Tn.n version is a released field test version.
-+	# A Xn.n version is an unreleased experimental baselevel.
-+	# 1.2 uses "1.2" for uname -r.
-+	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
-+	# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
-+	exitcode=$?
-+	trap '' 0
-+	exit $exitcode ;;
-+    Alpha\ *:Windows_NT*:*)
-+	# How do we know it's Interix rather than the generic POSIX subsystem?
-+	# Should we change UNAME_MACHINE based on the output of uname instead
-+	# of the specific Alpha model?
-+	echo alpha-pc-interix
-+	exit ;;
-+    21064:Windows_NT:50:3)
-+	echo alpha-dec-winnt3.5
-+	exit ;;
-+    Amiga*:UNIX_System_V:4.0:*)
-+	echo m68k-unknown-sysv4
-+	exit ;;
-+    *:[Aa]miga[Oo][Ss]:*:*)
-+	echo ${UNAME_MACHINE}-unknown-amigaos
-+	exit ;;
-+    *:[Mm]orph[Oo][Ss]:*:*)
-+	echo ${UNAME_MACHINE}-unknown-morphos
-+	exit ;;
-+    *:OS/390:*:*)
-+	echo i370-ibm-openedition
-+	exit ;;
-+    *:z/VM:*:*)
-+	echo s390-ibm-zvmoe
-+	exit ;;
-+    *:OS400:*:*)
-+	echo powerpc-ibm-os400
-+	exit ;;
-+    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
-+	echo arm-acorn-riscix${UNAME_RELEASE}
-+	exit ;;
-+    arm:riscos:*:*|arm:RISCOS:*:*)
-+	echo arm-unknown-riscos
-+	exit ;;
-+    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
-+	echo hppa1.1-hitachi-hiuxmpp
-+	exit ;;
-+    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
-+	# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
-+	if test "`(/bin/universe) 2>/dev/null`" = att ; then
-+		echo pyramid-pyramid-sysv3
-+	else
-+		echo pyramid-pyramid-bsd
-+	fi
-+	exit ;;
-+    NILE*:*:*:dcosx)
-+	echo pyramid-pyramid-svr4
-+	exit ;;
-+    DRS?6000:unix:4.0:6*)
-+	echo sparc-icl-nx6
-+	exit ;;
-+    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
-+	case `/usr/bin/uname -p` in
-+	    sparc) echo sparc-icl-nx7; exit ;;
-+	esac ;;
-+    s390x:SunOS:*:*)
-+	echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-+	exit ;;
-+    sun4H:SunOS:5.*:*)
-+	echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-+	exit ;;
-+    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
-+	echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-+	exit ;;
-+    i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
-+	echo i386-pc-auroraux${UNAME_RELEASE}
-+	exit ;;
-+    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
-+	eval $set_cc_for_build
-+	SUN_ARCH="i386"
-+	# If there is a compiler, see if it is configured for 64-bit objects.
-+	# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
-+	# This test works for both compilers.
-+	if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
-+	    if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
-+		(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
-+		grep IS_64BIT_ARCH >/dev/null
-+	    then
-+		SUN_ARCH="x86_64"
-+	    fi
-+	fi
-+	echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-+	exit ;;
-+    sun4*:SunOS:6*:*)
-+	# According to config.sub, this is the proper way to canonicalize
-+	# SunOS6.  Hard to guess exactly what SunOS6 will be like, but
-+	# it's likely to be more like Solaris than SunOS4.
-+	echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-+	exit ;;
-+    sun4*:SunOS:*:*)
-+	case "`/usr/bin/arch -k`" in
-+	    Series*|S4*)
-+		UNAME_RELEASE=`uname -v`
-+		;;
-+	esac
-+	# Japanese Language versions have a version number like `4.1.3-JL'.
-+	echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
-+	exit ;;
-+    sun3*:SunOS:*:*)
-+	echo m68k-sun-sunos${UNAME_RELEASE}
-+	exit ;;
-+    sun*:*:4.2BSD:*)
-+	UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
-+	test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
-+	case "`/bin/arch`" in
-+	    sun3)
-+		echo m68k-sun-sunos${UNAME_RELEASE}
-+		;;
-+	    sun4)
-+		echo sparc-sun-sunos${UNAME_RELEASE}
-+		;;
-+	esac
-+	exit ;;
-+    aushp:SunOS:*:*)
-+	echo sparc-auspex-sunos${UNAME_RELEASE}
-+	exit ;;
-+    # The situation for MiNT is a little confusing.  The machine name
-+    # can be virtually everything (everything which is not
-+    # "atarist" or "atariste" at least should have a processor
-+    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
-+    # to the lowercase version "mint" (or "freemint").  Finally
-+    # the system name "TOS" denotes a system which is actually not
-+    # MiNT.  But MiNT is downward compatible to TOS, so this should
-+    # be no problem.
-+    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
-+	echo m68k-atari-mint${UNAME_RELEASE}
-+	exit ;;
-+    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
-+	echo m68k-atari-mint${UNAME_RELEASE}
-+	exit ;;
-+    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
-+	echo m68k-atari-mint${UNAME_RELEASE}
-+	exit ;;
-+    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
-+	echo m68k-milan-mint${UNAME_RELEASE}
-+	exit ;;
-+    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
-+	echo m68k-hades-mint${UNAME_RELEASE}
-+	exit ;;
-+    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
-+	echo m68k-unknown-mint${UNAME_RELEASE}
-+	exit ;;
-+    m68k:machten:*:*)
-+	echo m68k-apple-machten${UNAME_RELEASE}
-+	exit ;;
-+    powerpc:machten:*:*)
-+	echo powerpc-apple-machten${UNAME_RELEASE}
-+	exit ;;
-+    RISC*:Mach:*:*)
-+	echo mips-dec-mach_bsd4.3
-+	exit ;;
-+    RISC*:ULTRIX:*:*)
-+	echo mips-dec-ultrix${UNAME_RELEASE}
-+	exit ;;
-+    VAX*:ULTRIX*:*:*)
-+	echo vax-dec-ultrix${UNAME_RELEASE}
-+	exit ;;
-+    2020:CLIX:*:* | 2430:CLIX:*:*)
-+	echo clipper-intergraph-clix${UNAME_RELEASE}
-+	exit ;;
-+    mips:*:*:UMIPS | mips:*:*:RISCos)
-+	eval $set_cc_for_build
-+	sed 's/^	//' << EOF >$dummy.c
-+#ifdef __cplusplus
-+#include <stdio.h>  /* for printf() prototype */
-+	int main (int argc, char *argv[]) {
-+#else
-+	int main (argc, argv) int argc; char *argv[]; {
-+#endif
-+	#if defined (host_mips) && defined (MIPSEB)
-+	#if defined (SYSTYPE_SYSV)
-+	  printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
-+	#endif
-+	#if defined (SYSTYPE_SVR4)
-+	  printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
-+	#endif
-+	#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
-+	  printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
-+	#endif
-+	#endif
-+	  exit (-1);
-+	}
-+EOF
-+	$CC_FOR_BUILD -o $dummy $dummy.c &&
-+	  dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
-+	  SYSTEM_NAME=`$dummy $dummyarg` &&
-+	    { echo "$SYSTEM_NAME"; exit; }
-+	echo mips-mips-riscos${UNAME_RELEASE}
-+	exit ;;
-+    Motorola:PowerMAX_OS:*:*)
-+	echo powerpc-motorola-powermax
-+	exit ;;
-+    Motorola:*:4.3:PL8-*)
-+	echo powerpc-harris-powermax
-+	exit ;;
-+    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
-+	echo powerpc-harris-powermax
-+	exit ;;
-+    Night_Hawk:Power_UNIX:*:*)
-+	echo powerpc-harris-powerunix
-+	exit ;;
-+    m88k:CX/UX:7*:*)
-+	echo m88k-harris-cxux7
-+	exit ;;
-+    m88k:*:4*:R4*)
-+	echo m88k-motorola-sysv4
-+	exit ;;
-+    m88k:*:3*:R3*)
-+	echo m88k-motorola-sysv3
-+	exit ;;
-+    AViiON:dgux:*:*)
-+	# DG/UX returns AViiON for all architectures
-+	UNAME_PROCESSOR=`/usr/bin/uname -p`
-+	if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
-+	then
-+	    if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
-+	       [ ${TARGET_BINARY_INTERFACE}x = x ]
-+	    then
-+		echo m88k-dg-dgux${UNAME_RELEASE}
-+	    else
-+		echo m88k-dg-dguxbcs${UNAME_RELEASE}
-+	    fi
-+	else
-+	    echo i586-dg-dgux${UNAME_RELEASE}
-+	fi
-+	exit ;;
-+    M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
-+	echo m88k-dolphin-sysv3
-+	exit ;;
-+    M88*:*:R3*:*)
-+	# Delta 88k system running SVR3
-+	echo m88k-motorola-sysv3
-+	exit ;;
-+    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
-+	echo m88k-tektronix-sysv3
-+	exit ;;
-+    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
-+	echo m68k-tektronix-bsd
-+	exit ;;
-+    *:IRIX*:*:*)
-+	echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
-+	exit ;;
-+    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
-+	echo romp-ibm-aix     # uname -m gives an 8 hex-code CPU id
-+	exit ;;               # Note that: echo "'`uname -s`'" gives 'AIX '
-+    i*86:AIX:*:*)
-+	echo i386-ibm-aix
-+	exit ;;
-+    ia64:AIX:*:*)
-+	if [ -x /usr/bin/oslevel ] ; then
-+		IBM_REV=`/usr/bin/oslevel`
-+	else
-+		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
-+	fi
-+	echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
-+	exit ;;
-+    *:AIX:2:3)
-+	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
-+		eval $set_cc_for_build
-+		sed 's/^		//' << EOF >$dummy.c
-+		#include <sys/systemcfg.h>
-+
-+		main()
-+			{
-+			if (!__power_pc())
-+				exit(1);
-+			puts("powerpc-ibm-aix3.2.5");
-+			exit(0);
-+			}
-+EOF
-+		if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
-+		then
-+			echo "$SYSTEM_NAME"
-+		else
-+			echo rs6000-ibm-aix3.2.5
-+		fi
-+	elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
-+		echo rs6000-ibm-aix3.2.4
-+	else
-+		echo rs6000-ibm-aix3.2
-+	fi
-+	exit ;;
-+    *:AIX:*:[4567])
-+	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
-+	if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
-+		IBM_ARCH=rs6000
-+	else
-+		IBM_ARCH=powerpc
-+	fi
-+	if [ -x /usr/bin/oslevel ] ; then
-+		IBM_REV=`/usr/bin/oslevel`
-+	else
-+		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
-+	fi
-+	echo ${IBM_ARCH}-ibm-aix${IBM_REV}
-+	exit ;;
-+    *:AIX:*:*)
-+	echo rs6000-ibm-aix
-+	exit ;;
-+    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
-+	echo romp-ibm-bsd4.4
-+	exit ;;
-+    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
-+	echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
-+	exit ;;                             # report: romp-ibm BSD 4.3
-+    *:BOSX:*:*)
-+	echo rs6000-bull-bosx
-+	exit ;;
-+    DPX/2?00:B.O.S.:*:*)
-+	echo m68k-bull-sysv3
-+	exit ;;
-+    9000/[34]??:4.3bsd:1.*:*)
-+	echo m68k-hp-bsd
-+	exit ;;
-+    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
-+	echo m68k-hp-bsd4.4
-+	exit ;;
-+    9000/[34678]??:HP-UX:*:*)
-+	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
-+	case "${UNAME_MACHINE}" in
-+	    9000/31? )            HP_ARCH=m68000 ;;
-+	    9000/[34]?? )         HP_ARCH=m68k ;;
-+	    9000/[678][0-9][0-9])
-+		if [ -x /usr/bin/getconf ]; then
-+		    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
-+		    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
-+		    case "${sc_cpu_version}" in
-+		      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
-+		      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
-+		      532)                      # CPU_PA_RISC2_0
-+			case "${sc_kernel_bits}" in
-+			  32) HP_ARCH="hppa2.0n" ;;
-+			  64) HP_ARCH="hppa2.0w" ;;
-+			  '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
-+			esac ;;
-+		    esac
-+		fi
-+		if [ "${HP_ARCH}" = "" ]; then
-+		    eval $set_cc_for_build
-+		    sed 's/^		//' << EOF >$dummy.c
-+
-+		#define _HPUX_SOURCE
-+		#include <stdlib.h>
-+		#include <unistd.h>
-+
-+		int main ()
-+		{
-+		#if defined(_SC_KERNEL_BITS)
-+		    long bits = sysconf(_SC_KERNEL_BITS);
-+		#endif
-+		    long cpu  = sysconf (_SC_CPU_VERSION);
-+
-+		    switch (cpu)
-+			{
-+			case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
-+			case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
-+			case CPU_PA_RISC2_0:
-+		#if defined(_SC_KERNEL_BITS)
-+			    switch (bits)
-+				{
-+				case 64: puts ("hppa2.0w"); break;
-+				case 32: puts ("hppa2.0n"); break;
-+				default: puts ("hppa2.0"); break;
-+				} break;
-+		#else  /* !defined(_SC_KERNEL_BITS) */
-+			    puts ("hppa2.0"); break;
-+		#endif
-+			default: puts ("hppa1.0"); break;
-+			}
-+		    exit (0);
-+		}
-+EOF
-+		    (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
-+		    test -z "$HP_ARCH" && HP_ARCH=hppa
-+		fi ;;
-+	esac
-+	if [ ${HP_ARCH} = "hppa2.0w" ]
-+	then
-+	    eval $set_cc_for_build
-+
-+	    # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
-+	    # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
-+	    # generating 64-bit code.  GNU and HP use different nomenclature:
-+	    #
-+	    # $ CC_FOR_BUILD=cc ./config.guess
-+	    # => hppa2.0w-hp-hpux11.23
-+	    # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
-+	    # => hppa64-hp-hpux11.23
-+
-+	    if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
-+		grep -q __LP64__
-+	    then
-+		HP_ARCH="hppa2.0w"
-+	    else
-+		HP_ARCH="hppa64"
-+	    fi
-+	fi
-+	echo ${HP_ARCH}-hp-hpux${HPUX_REV}
-+	exit ;;
-+    ia64:HP-UX:*:*)
-+	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
-+	echo ia64-hp-hpux${HPUX_REV}
-+	exit ;;
-+    3050*:HI-UX:*:*)
-+	eval $set_cc_for_build
-+	sed 's/^	//' << EOF >$dummy.c
-+	#include <unistd.h>
-+	int
-+	main ()
-+	{
-+	  long cpu = sysconf (_SC_CPU_VERSION);
-+	  /* The order matters, because CPU_IS_HP_MC68K erroneously returns
-+	     true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
-+	     results, however.  */
-+	  if (CPU_IS_PA_RISC (cpu))
-+	    {
-+	      switch (cpu)
-+		{
-+		  case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
-+		  case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
-+		  case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
-+		  default: puts ("hppa-hitachi-hiuxwe2"); break;
-+		}
-+	    }
-+	  else if (CPU_IS_HP_MC68K (cpu))
-+	    puts ("m68k-hitachi-hiuxwe2");
-+	  else puts ("unknown-hitachi-hiuxwe2");
-+	  exit (0);
-+	}
-+EOF
-+	$CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
-+		{ echo "$SYSTEM_NAME"; exit; }
-+	echo unknown-hitachi-hiuxwe2
-+	exit ;;
-+    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
-+	echo hppa1.1-hp-bsd
-+	exit ;;
-+    9000/8??:4.3bsd:*:*)
-+	echo hppa1.0-hp-bsd
-+	exit ;;
-+    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
-+	echo hppa1.0-hp-mpeix
-+	exit ;;
-+    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
-+	echo hppa1.1-hp-osf
-+	exit ;;
-+    hp8??:OSF1:*:*)
-+	echo hppa1.0-hp-osf
-+	exit ;;
-+    i*86:OSF1:*:*)
-+	if [ -x /usr/sbin/sysversion ] ; then
-+	    echo ${UNAME_MACHINE}-unknown-osf1mk
-+	else
-+	    echo ${UNAME_MACHINE}-unknown-osf1
-+	fi
-+	exit ;;
-+    parisc*:Lites*:*:*)
-+	echo hppa1.1-hp-lites
-+	exit ;;
-+    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
-+	echo c1-convex-bsd
-+	exit ;;
-+    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
-+	if getsysinfo -f scalar_acc
-+	then echo c32-convex-bsd
-+	else echo c2-convex-bsd
-+	fi
-+	exit ;;
-+    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
-+	echo c34-convex-bsd
-+	exit ;;
-+    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
-+	echo c38-convex-bsd
-+	exit ;;
-+    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
-+	echo c4-convex-bsd
-+	exit ;;
-+    CRAY*Y-MP:*:*:*)
-+	echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-+	exit ;;
-+    CRAY*[A-Z]90:*:*:*)
-+	echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
-+	| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
-+	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
-+	      -e 's/\.[^.]*$/.X/'
-+	exit ;;
-+    CRAY*TS:*:*:*)
-+	echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-+	exit ;;
-+    CRAY*T3E:*:*:*)
-+	echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-+	exit ;;
-+    CRAY*SV1:*:*:*)
-+	echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-+	exit ;;
-+    *:UNICOS/mp:*:*)
-+	echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-+	exit ;;
-+    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
-+	FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
-+	FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
-+	FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
-+	echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
-+	exit ;;
-+    5000:UNIX_System_V:4.*:*)
-+	FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
-+	FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
-+	echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
-+	exit ;;
-+    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
-+	echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
-+	exit ;;
-+    sparc*:BSD/OS:*:*)
-+	echo sparc-unknown-bsdi${UNAME_RELEASE}
-+	exit ;;
-+    *:BSD/OS:*:*)
-+	echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
-+	exit ;;
-+    *:FreeBSD:*:*)
-+	UNAME_PROCESSOR=`/usr/bin/uname -p`
-+	case ${UNAME_PROCESSOR} in
-+	    amd64)
-+		echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
-+	    *)
-+		echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
-+	esac
-+	exit ;;
-+    i*:CYGWIN*:*)
-+	echo ${UNAME_MACHINE}-pc-cygwin
-+	exit ;;
-+    *:MINGW*:*)
-+	echo ${UNAME_MACHINE}-pc-mingw32
-+	exit ;;
-+    i*:MSYS*:*)
-+	echo ${UNAME_MACHINE}-pc-msys
-+	exit ;;
-+    i*:windows32*:*)
-+	# uname -m includes "-pc" on this system.
-+	echo ${UNAME_MACHINE}-mingw32
-+	exit ;;
-+    i*:PW*:*)
-+	echo ${UNAME_MACHINE}-pc-pw32
-+	exit ;;
-+    *:Interix*:*)
-+	case ${UNAME_MACHINE} in
-+	    x86)
-+		echo i586-pc-interix${UNAME_RELEASE}
-+		exit ;;
-+	    authenticamd | genuineintel | EM64T)
-+		echo x86_64-unknown-interix${UNAME_RELEASE}
-+		exit ;;
-+	    IA64)
-+		echo ia64-unknown-interix${UNAME_RELEASE}
-+		exit ;;
-+	esac ;;
-+    [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
-+	echo i${UNAME_MACHINE}-pc-mks
-+	exit ;;
-+    8664:Windows_NT:*)
-+	echo x86_64-pc-mks
-+	exit ;;
-+    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
-+	# How do we know it's Interix rather than the generic POSIX subsystem?
-+	# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
-+	# UNAME_MACHINE based on the output of uname instead of i386?
-+	echo i586-pc-interix
-+	exit ;;
-+    i*:UWIN*:*)
-+	echo ${UNAME_MACHINE}-pc-uwin
-+	exit ;;
-+    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
-+	echo x86_64-unknown-cygwin
-+	exit ;;
-+    p*:CYGWIN*:*)
-+	echo powerpcle-unknown-cygwin
-+	exit ;;
-+    prep*:SunOS:5.*:*)
-+	echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-+	exit ;;
-+    *:GNU:*:*)
-+	# the GNU system
-+	echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
-+	exit ;;
-+    *:GNU/*:*:*)
-+	# other systems with GNU libc and userland
-+	echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
-+	exit ;;
-+    i*86:Minix:*:*)
-+	echo ${UNAME_MACHINE}-pc-minix
-+	exit ;;
-+    aarch64:Linux:*:*)
-+	echo ${UNAME_MACHINE}-unknown-linux-gnu
-+	exit ;;
-+    aarch64_be:Linux:*:*)
-+	UNAME_MACHINE=aarch64_be
-+	echo ${UNAME_MACHINE}-unknown-linux-gnu
-+	exit ;;
-+    alpha:Linux:*:*)
-+	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
-+	  EV5)   UNAME_MACHINE=alphaev5 ;;
-+	  EV56)  UNAME_MACHINE=alphaev56 ;;
-+	  PCA56) UNAME_MACHINE=alphapca56 ;;
-+	  PCA57) UNAME_MACHINE=alphapca56 ;;
-+	  EV6)   UNAME_MACHINE=alphaev6 ;;
-+	  EV67)  UNAME_MACHINE=alphaev67 ;;
-+	  EV68*) UNAME_MACHINE=alphaev68 ;;
-+	esac
-+	objdump --private-headers /bin/sh | grep -q ld.so.1
-+	if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
-+	echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
-+	exit ;;
-+    arm*:Linux:*:*)
-+	eval $set_cc_for_build
-+	if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
-+	    | grep -q __ARM_EABI__
-+	then
-+	    echo ${UNAME_MACHINE}-unknown-linux-gnu
-+	else
-+	    if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
-+		| grep -q __ARM_PCS_VFP
-+	    then
-+		echo ${UNAME_MACHINE}-unknown-linux-gnueabi
-+	    else
-+		echo ${UNAME_MACHINE}-unknown-linux-gnueabihf
-+	    fi
-+	fi
-+	exit ;;
-+    avr32*:Linux:*:*)
-+	echo ${UNAME_MACHINE}-unknown-linux-gnu
-+	exit ;;
-+    cris:Linux:*:*)
-+	echo ${UNAME_MACHINE}-axis-linux-gnu
-+	exit ;;
-+    crisv32:Linux:*:*)
-+	echo ${UNAME_MACHINE}-axis-linux-gnu
-+	exit ;;
-+    frv:Linux:*:*)
-+	echo ${UNAME_MACHINE}-unknown-linux-gnu
-+	exit ;;
-+    hexagon:Linux:*:*)
-+	echo ${UNAME_MACHINE}-unknown-linux-gnu
-+	exit ;;
-+    i*86:Linux:*:*)
-+	LIBC=gnu
-+	eval $set_cc_for_build
-+	sed 's/^	//' << EOF >$dummy.c
-+	#ifdef __dietlibc__
-+	LIBC=dietlibc
-+	#endif
-+EOF
-+	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
-+	echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
-+	exit ;;
-+    ia64:Linux:*:*)
-+	echo ${UNAME_MACHINE}-unknown-linux-gnu
-+	exit ;;
-+    m32r*:Linux:*:*)
-+	echo ${UNAME_MACHINE}-unknown-linux-gnu
-+	exit ;;
-+    m68*:Linux:*:*)
-+	echo ${UNAME_MACHINE}-unknown-linux-gnu
-+	exit ;;
-+    mips:Linux:*:* | mips64:Linux:*:*)
-+	eval $set_cc_for_build
-+	sed 's/^	//' << EOF >$dummy.c
-+	#undef CPU
-+	#undef ${UNAME_MACHINE}
-+	#undef ${UNAME_MACHINE}el
-+	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
-+	CPU=${UNAME_MACHINE}el
-+	#else
-+	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
-+	CPU=${UNAME_MACHINE}
-+	#else
-+	CPU=
-+	#endif
-+	#endif
-+EOF
-+	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
-+	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
-+	;;
-+    or32:Linux:*:*)
-+	echo ${UNAME_MACHINE}-unknown-linux-gnu
-+	exit ;;
-+    padre:Linux:*:*)
-+	echo sparc-unknown-linux-gnu
-+	exit ;;
-+    parisc64:Linux:*:* | hppa64:Linux:*:*)
-+	echo hppa64-unknown-linux-gnu
-+	exit ;;
-+    parisc:Linux:*:* | hppa:Linux:*:*)
-+	# Look for CPU level
-+	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
-+	  PA7*) echo hppa1.1-unknown-linux-gnu ;;
-+	  PA8*) echo hppa2.0-unknown-linux-gnu ;;
-+	  *)    echo hppa-unknown-linux-gnu ;;
-+	esac
-+	exit ;;
-+    ppc64:Linux:*:*)
-+	echo powerpc64-unknown-linux-gnu
-+	exit ;;
-+    ppc:Linux:*:*)
-+	echo powerpc-unknown-linux-gnu
-+	exit ;;
-+    s390:Linux:*:* | s390x:Linux:*:*)
-+	echo ${UNAME_MACHINE}-ibm-linux
-+	exit ;;
-+    sh64*:Linux:*:*)
-+	echo ${UNAME_MACHINE}-unknown-linux-gnu
-+	exit ;;
-+    sh*:Linux:*:*)
-+	echo ${UNAME_MACHINE}-unknown-linux-gnu
-+	exit ;;
-+    sparc:Linux:*:* | sparc64:Linux:*:*)
-+	echo ${UNAME_MACHINE}-unknown-linux-gnu
-+	exit ;;
-+    tile*:Linux:*:*)
-+	echo ${UNAME_MACHINE}-unknown-linux-gnu
-+	exit ;;
-+    vax:Linux:*:*)
-+	echo ${UNAME_MACHINE}-dec-linux-gnu
-+	exit ;;
-+    x86_64:Linux:*:*)
-+	echo ${UNAME_MACHINE}-unknown-linux-gnu
-+	exit ;;
-+    xtensa*:Linux:*:*)
-+	echo ${UNAME_MACHINE}-unknown-linux-gnu
-+	exit ;;
-+    i*86:DYNIX/ptx:4*:*)
-+	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
-+	# earlier versions are messed up and put the nodename in both
-+	# sysname and nodename.
-+	echo i386-sequent-sysv4
-+	exit ;;
-+    i*86:UNIX_SV:4.2MP:2.*)
-+	# Unixware is an offshoot of SVR4, but it has its own version
-+	# number series starting with 2...
-+	# I am not positive that other SVR4 systems won't match this,
-+	# I just have to hope.  -- rms.
-+	# Use sysv4.2uw... so that sysv4* matches it.
-+	echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
-+	exit ;;
-+    i*86:OS/2:*:*)
-+	# If we were able to find `uname', then EMX Unix compatibility
-+	# is probably installed.
-+	echo ${UNAME_MACHINE}-pc-os2-emx
-+	exit ;;
-+    i*86:XTS-300:*:STOP)
-+	echo ${UNAME_MACHINE}-unknown-stop
-+	exit ;;
-+    i*86:atheos:*:*)
-+	echo ${UNAME_MACHINE}-unknown-atheos
-+	exit ;;
-+    i*86:syllable:*:*)
-+	echo ${UNAME_MACHINE}-pc-syllable
-+	exit ;;
-+    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
-+	echo i386-unknown-lynxos${UNAME_RELEASE}
-+	exit ;;
-+    i*86:*DOS:*:*)
-+	echo ${UNAME_MACHINE}-pc-msdosdjgpp
-+	exit ;;
-+    i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
-+	UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
-+	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
-+		echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
-+	else
-+		echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
-+	fi
-+	exit ;;
-+    i*86:*:5:[678]*)
-+	# UnixWare 7.x, OpenUNIX and OpenServer 6.
-+	case `/bin/uname -X | grep "^Machine"` in
-+	    *486*)	     UNAME_MACHINE=i486 ;;
-+	    *Pentium)	     UNAME_MACHINE=i586 ;;
-+	    *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
-+	esac
-+	echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
-+	exit ;;
-+    i*86:*:3.2:*)
-+	if test -f /usr/options/cb.name; then
-+		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
-+		echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
-+	elif /bin/uname -X 2>/dev/null >/dev/null ; then
-+		UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
-+		(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
-+		(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
-+			&& UNAME_MACHINE=i586
-+		(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
-+			&& UNAME_MACHINE=i686
-+		(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
-+			&& UNAME_MACHINE=i686
-+		echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
-+	else
-+		echo ${UNAME_MACHINE}-pc-sysv32
-+	fi
-+	exit ;;
-+    pc:*:*:*)
-+	# Left here for compatibility:
-+	# uname -m prints for DJGPP always 'pc', but it prints nothing about
-+	# the processor, so we play safe by assuming i586.
-+	# Note: whatever this is, it MUST be the same as what config.sub
-+	# prints for the "djgpp" host, or else GDB configury will decide that
-+	# this is a cross-build.
-+	echo i586-pc-msdosdjgpp
-+	exit ;;
-+    Intel:Mach:3*:*)
-+	echo i386-pc-mach3
-+	exit ;;
-+    paragon:*:*:*)
-+	echo i860-intel-osf1
-+	exit ;;
-+    i860:*:4.*:*) # i860-SVR4
-+	if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
-+	  echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
-+	else # Add other i860-SVR4 vendors below as they are discovered.
-+	  echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
-+	fi
-+	exit ;;
-+    mini*:CTIX:SYS*5:*)
-+	# "miniframe"
-+	echo m68010-convergent-sysv
-+	exit ;;
-+    mc68k:UNIX:SYSTEM5:3.51m)
-+	echo m68k-convergent-sysv
-+	exit ;;
-+    M680?0:D-NIX:5.3:*)
-+	echo m68k-diab-dnix
-+	exit ;;
-+    M68*:*:R3V[5678]*:*)
-+	test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
-+    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
-+	OS_REL=''
-+	test -r /etc/.relid \
-+	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
-+	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
-+	  && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
-+	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
-+	  && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
-+    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
-+	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
-+	  && { echo i486-ncr-sysv4; exit; } ;;
-+    NCR*:*:4.2:* | MPRAS*:*:4.2:*)
-+	OS_REL='.3'
-+	test -r /etc/.relid \
-+	    && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
-+	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
-+	    && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
-+	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
-+	    && { echo i586-ncr-sysv4.3${OS_REL}; exit; }
-+	/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
-+	    && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
-+    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
-+	echo m68k-unknown-lynxos${UNAME_RELEASE}
-+	exit ;;
-+    mc68030:UNIX_System_V:4.*:*)
-+	echo m68k-atari-sysv4
-+	exit ;;
-+    TSUNAMI:LynxOS:2.*:*)
-+	echo sparc-unknown-lynxos${UNAME_RELEASE}
-+	exit ;;
-+    rs6000:LynxOS:2.*:*)
-+	echo rs6000-unknown-lynxos${UNAME_RELEASE}
-+	exit ;;
-+    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
-+	echo powerpc-unknown-lynxos${UNAME_RELEASE}
-+	exit ;;
-+    SM[BE]S:UNIX_SV:*:*)
-+	echo mips-dde-sysv${UNAME_RELEASE}
-+	exit ;;
-+    RM*:ReliantUNIX-*:*:*)
-+	echo mips-sni-sysv4
-+	exit ;;
-+    RM*:SINIX-*:*:*)
-+	echo mips-sni-sysv4
-+	exit ;;
-+    *:SINIX-*:*:*)
-+	if uname -p 2>/dev/null >/dev/null ; then
-+		UNAME_MACHINE=`(uname -p) 2>/dev/null`
-+		echo ${UNAME_MACHINE}-sni-sysv4
-+	else
-+		echo ns32k-sni-sysv
-+	fi
-+	exit ;;
-+    PENTIUM:*:4.0*:*)	# Unisys `ClearPath HMP IX 4000' SVR4/MP effort
-+			# says <Richard.M.Bartel@ccMail.Census.GOV>
-+	echo i586-unisys-sysv4
-+	exit ;;
-+    *:UNIX_System_V:4*:FTX*)
-+	# From Gerald Hewes <hewes@openmarket.com>.
-+	# How about differentiating between stratus architectures? -djm
-+	echo hppa1.1-stratus-sysv4
-+	exit ;;
-+    *:*:*:FTX*)
-+	# From seanf@swdc.stratus.com.
-+	echo i860-stratus-sysv4
-+	exit ;;
-+    i*86:VOS:*:*)
-+	# From Paul.Green@stratus.com.
-+	echo ${UNAME_MACHINE}-stratus-vos
-+	exit ;;
-+    *:VOS:*:*)
-+	# From Paul.Green@stratus.com.
-+	echo hppa1.1-stratus-vos
-+	exit ;;
-+    mc68*:A/UX:*:*)
-+	echo m68k-apple-aux${UNAME_RELEASE}
-+	exit ;;
-+    news*:NEWS-OS:6*:*)
-+	echo mips-sony-newsos6
-+	exit ;;
-+    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
-+	if [ -d /usr/nec ]; then
-+		echo mips-nec-sysv${UNAME_RELEASE}
-+	else
-+		echo mips-unknown-sysv${UNAME_RELEASE}
-+	fi
-+	exit ;;
-+    BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
-+	echo powerpc-be-beos
-+	exit ;;
-+    BeMac:BeOS:*:*)	# BeOS running on Mac or Mac clone, PPC only.
-+	echo powerpc-apple-beos
-+	exit ;;
-+    BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
-+	echo i586-pc-beos
-+	exit ;;
-+    BePC:Haiku:*:*)	# Haiku running on Intel PC compatible.
-+	echo i586-pc-haiku
-+	exit ;;
-+    SX-4:SUPER-UX:*:*)
-+	echo sx4-nec-superux${UNAME_RELEASE}
-+	exit ;;
-+    SX-5:SUPER-UX:*:*)
-+	echo sx5-nec-superux${UNAME_RELEASE}
-+	exit ;;
-+    SX-6:SUPER-UX:*:*)
-+	echo sx6-nec-superux${UNAME_RELEASE}
-+	exit ;;
-+    SX-7:SUPER-UX:*:*)
-+	echo sx7-nec-superux${UNAME_RELEASE}
-+	exit ;;
-+    SX-8:SUPER-UX:*:*)
-+	echo sx8-nec-superux${UNAME_RELEASE}
-+	exit ;;
-+    SX-8R:SUPER-UX:*:*)
-+	echo sx8r-nec-superux${UNAME_RELEASE}
-+	exit ;;
-+    Power*:Rhapsody:*:*)
-+	echo powerpc-apple-rhapsody${UNAME_RELEASE}
-+	exit ;;
-+    *:Rhapsody:*:*)
-+	echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
-+	exit ;;
-+    *:Darwin:*:*)
-+	UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
-+	case $UNAME_PROCESSOR in
-+	    i386)
-+		eval $set_cc_for_build
-+		if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
-+		  if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
-+		      (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
-+		      grep IS_64BIT_ARCH >/dev/null
-+		  then
-+		      UNAME_PROCESSOR="x86_64"
-+		  fi
-+		fi ;;
-+	    unknown) UNAME_PROCESSOR=powerpc ;;
-+	esac
-+	echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
-+	exit ;;
-+    *:procnto*:*:* | *:QNX:[0123456789]*:*)
-+	UNAME_PROCESSOR=`uname -p`
-+	if test "$UNAME_PROCESSOR" = "x86"; then
-+		UNAME_PROCESSOR=i386
-+		UNAME_MACHINE=pc
-+	fi
-+	echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
-+	exit ;;
-+    *:QNX:*:4*)
-+	echo i386-pc-qnx
-+	exit ;;
-+    NEO-?:NONSTOP_KERNEL:*:*)
-+	echo neo-tandem-nsk${UNAME_RELEASE}
-+	exit ;;
-+    NSE-?:NONSTOP_KERNEL:*:*)
-+	echo nse-tandem-nsk${UNAME_RELEASE}
-+	exit ;;
-+    NSR-?:NONSTOP_KERNEL:*:*)
-+	echo nsr-tandem-nsk${UNAME_RELEASE}
-+	exit ;;
-+    *:NonStop-UX:*:*)
-+	echo mips-compaq-nonstopux
-+	exit ;;
-+    BS2000:POSIX*:*:*)
-+	echo bs2000-siemens-sysv
-+	exit ;;
-+    DS/*:UNIX_System_V:*:*)
-+	echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
-+	exit ;;
-+    *:Plan9:*:*)
-+	# "uname -m" is not consistent, so use $cputype instead. 386
-+	# is converted to i386 for consistency with other x86
-+	# operating systems.
-+	if test "$cputype" = "386"; then
-+	    UNAME_MACHINE=i386
-+	else
-+	    UNAME_MACHINE="$cputype"
-+	fi
-+	echo ${UNAME_MACHINE}-unknown-plan9
-+	exit ;;
-+    *:TOPS-10:*:*)
-+	echo pdp10-unknown-tops10
-+	exit ;;
-+    *:TENEX:*:*)
-+	echo pdp10-unknown-tenex
-+	exit ;;
-+    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
-+	echo pdp10-dec-tops20
-+	exit ;;
-+    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
-+	echo pdp10-xkl-tops20
-+	exit ;;
-+    *:TOPS-20:*:*)
-+	echo pdp10-unknown-tops20
-+	exit ;;
-+    *:ITS:*:*)
-+	echo pdp10-unknown-its
-+	exit ;;
-+    SEI:*:*:SEIUX)
-+	echo mips-sei-seiux${UNAME_RELEASE}
-+	exit ;;
-+    *:DragonFly:*:*)
-+	echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
-+	exit ;;
-+    *:*VMS:*:*)
-+	UNAME_MACHINE=`(uname -p) 2>/dev/null`
-+	case "${UNAME_MACHINE}" in
-+	    A*) echo alpha-dec-vms ; exit ;;
-+	    I*) echo ia64-dec-vms ; exit ;;
-+	    V*) echo vax-dec-vms ; exit ;;
-+	esac ;;
-+    *:XENIX:*:SysV)
-+	echo i386-pc-xenix
-+	exit ;;
-+    i*86:skyos:*:*)
-+	echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
-+	exit ;;
-+    i*86:rdos:*:*)
-+	echo ${UNAME_MACHINE}-pc-rdos
-+	exit ;;
-+    i*86:AROS:*:*)
-+	echo ${UNAME_MACHINE}-pc-aros
-+	exit ;;
-+    x86_64:VMkernel:*:*)
-+	echo ${UNAME_MACHINE}-unknown-esx
-+	exit ;;
-+esac
-+
-+#echo '(No uname command or uname output not recognized.)' 1>&2
-+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
-+
-+eval $set_cc_for_build
-+cat >$dummy.c <<EOF
-+#ifdef _SEQUENT_
-+# include <sys/types.h>
-+# include <sys/utsname.h>
-+#endif
-+main ()
-+{
-+#if defined (sony)
-+#if defined (MIPSEB)
-+  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
-+     I don't know....  */
-+  printf ("mips-sony-bsd\n"); exit (0);
-+#else
-+#include <sys/param.h>
-+  printf ("m68k-sony-newsos%s\n",
-+#ifdef NEWSOS4
-+	"4"
-+#else
-+	""
-+#endif
-+	); exit (0);
-+#endif
-+#endif
-+
-+#if defined (__arm) && defined (__acorn) && defined (__unix)
-+  printf ("arm-acorn-riscix\n"); exit (0);
-+#endif
-+
-+#if defined (hp300) && !defined (hpux)
-+  printf ("m68k-hp-bsd\n"); exit (0);
-+#endif
-+
-+#if defined (NeXT)
-+#if !defined (__ARCHITECTURE__)
-+#define __ARCHITECTURE__ "m68k"
-+#endif
-+  int version;
-+  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
-+  if (version < 4)
-+    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
-+  else
-+    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
-+  exit (0);
-+#endif
-+
-+#if defined (MULTIMAX) || defined (n16)
-+#if defined (UMAXV)
-+  printf ("ns32k-encore-sysv\n"); exit (0);
-+#else
-+#if defined (CMU)
-+  printf ("ns32k-encore-mach\n"); exit (0);
-+#else
-+  printf ("ns32k-encore-bsd\n"); exit (0);
-+#endif
-+#endif
-+#endif
-+
-+#if defined (__386BSD__)
-+  printf ("i386-pc-bsd\n"); exit (0);
-+#endif
-+
-+#if defined (sequent)
-+#if defined (i386)
-+  printf ("i386-sequent-dynix\n"); exit (0);
-+#endif
-+#if defined (ns32000)
-+  printf ("ns32k-sequent-dynix\n"); exit (0);
-+#endif
-+#endif
-+
-+#if defined (_SEQUENT_)
-+    struct utsname un;
-+
-+    uname(&un);
-+
-+    if (strncmp(un.version, "V2", 2) == 0) {
-+	printf ("i386-sequent-ptx2\n"); exit (0);
-+    }
-+    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
-+	printf ("i386-sequent-ptx1\n"); exit (0);
-+    }
-+    printf ("i386-sequent-ptx\n"); exit (0);
-+
-+#endif
-+
-+#if defined (vax)
-+# if !defined (ultrix)
-+#  include <sys/param.h>
-+#  if defined (BSD)
-+#   if BSD == 43
-+      printf ("vax-dec-bsd4.3\n"); exit (0);
-+#   else
-+#    if BSD == 199006
-+      printf ("vax-dec-bsd4.3reno\n"); exit (0);
-+#    else
-+      printf ("vax-dec-bsd\n"); exit (0);
-+#    endif
-+#   endif
-+#  else
-+    printf ("vax-dec-bsd\n"); exit (0);
-+#  endif
-+# else
-+    printf ("vax-dec-ultrix\n"); exit (0);
-+# endif
-+#endif
-+
-+#if defined (alliant) && defined (i860)
-+  printf ("i860-alliant-bsd\n"); exit (0);
-+#endif
-+
-+  exit (1);
-+}
-+EOF
-+
-+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
-+	{ echo "$SYSTEM_NAME"; exit; }
-+
-+# Apollos put the system type in the environment.
-+
-+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
-+
-+# Convex versions that predate uname can use getsysinfo(1)
-+
-+if [ -x /usr/convex/getsysinfo ]
-+then
-+    case `getsysinfo -f cpu_type` in
-+    c1*)
-+	echo c1-convex-bsd
-+	exit ;;
-+    c2*)
-+	if getsysinfo -f scalar_acc
-+	then echo c32-convex-bsd
-+	else echo c2-convex-bsd
-+	fi
-+	exit ;;
-+    c34*)
-+	echo c34-convex-bsd
-+	exit ;;
-+    c38*)
-+	echo c38-convex-bsd
-+	exit ;;
-+    c4*)
-+	echo c4-convex-bsd
-+	exit ;;
-+    esac
-+fi
-+
-+cat >&2 <<EOF
-+$0: unable to guess system type
-+
-+This script, last modified $timestamp, has failed to recognize
-+the operating system you are using. It is advised that you
-+download the most up to date version of the config scripts from
-+
-+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
-+and
-+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
-+
-+If the version you run ($0) is already up to date, please
-+send the following data and any information you think might be
-+pertinent to <config-patches@gnu.org> in order to provide the needed
-+information to handle your system.
-+
-+config.guess timestamp = $timestamp
-+
-+uname -m = `(uname -m) 2>/dev/null || echo unknown`
-+uname -r = `(uname -r) 2>/dev/null || echo unknown`
-+uname -s = `(uname -s) 2>/dev/null || echo unknown`
-+uname -v = `(uname -v) 2>/dev/null || echo unknown`
-+
-+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
-+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
-+
-+hostinfo               = `(hostinfo) 2>/dev/null`
-+/bin/universe          = `(/bin/universe) 2>/dev/null`
-+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
-+/bin/arch              = `(/bin/arch) 2>/dev/null`
-+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
-+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
-+
-+UNAME_MACHINE = ${UNAME_MACHINE}
-+UNAME_RELEASE = ${UNAME_RELEASE}
-+UNAME_SYSTEM  = ${UNAME_SYSTEM}
-+UNAME_VERSION = ${UNAME_VERSION}
-+EOF
-+
-+exit 1
-+
-+# Local variables:
-+# eval: (add-hook 'write-file-hooks 'time-stamp)
-+# time-stamp-start: "timestamp='"
-+# time-stamp-format: "%:y-%02m-%02d"
-+# time-stamp-end: "'"
-+# End:
-diff -urN a/config.sub b/config.sub
---- a/config.sub	1970-01-01 01:00:00.000000000 +0100
-+++ b/config.sub	2012-06-25 19:39:10.609815624 +0100
-@@ -0,0 +1,1773 @@
-+#! /bin/sh
-+# Configuration validation subroutine script.
-+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
-+#   2011, 2012 Free Software Foundation, Inc.
-+
-+timestamp='2012-02-10'
-+
-+# This file is (in principle) common to ALL GNU software.
-+# The presence of a machine in this file suggests that SOME GNU software
-+# can handle that machine.  It does not imply ALL GNU software can.
-+#
-+# This file is free software; you can redistribute it and/or modify
-+# it under the terms of the GNU General Public License as published by
-+# the Free Software Foundation; either version 2 of the License, or
-+# (at your option) any later version.
-+#
-+# This program is distributed in the hope that it will be useful,
-+# but WITHOUT ANY WARRANTY; without even the implied warranty of
-+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-+# GNU General Public License for more details.
-+#
-+# You should have received a copy of the GNU General Public License
-+# along with this program; if not, see <http://www.gnu.org/licenses/>.
-+#
-+# As a special exception to the GNU General Public License, if you
-+# distribute this file as part of a program that contains a
-+# configuration script generated by Autoconf, you may include it under
-+# the same distribution terms that you use for the rest of that program.
-+
-+
-+# Please send patches to <config-patches@gnu.org>.  Submit a context
-+# diff and a properly formatted GNU ChangeLog entry.
-+#
-+# Configuration subroutine to validate and canonicalize a configuration type.
-+# Supply the specified configuration type as an argument.
-+# If it is invalid, we print an error message on stderr and exit with code 1.
-+# Otherwise, we print the canonical config type on stdout and succeed.
-+
-+# You can get the latest version of this script from:
-+# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
-+
-+# This file is supposed to be the same for all GNU packages
-+# and recognize all the CPU types, system types and aliases
-+# that are meaningful with *any* GNU software.
-+# Each package is responsible for reporting which valid configurations
-+# it does not support.  The user should be able to distinguish
-+# a failure to support a valid configuration from a meaningless
-+# configuration.
-+
-+# The goal of this file is to map all the various variations of a given
-+# machine specification into a single specification in the form:
-+#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
-+# or in some cases, the newer four-part form:
-+#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
-+# It is wrong to echo any other type of specification.
-+
-+me=`echo "$0" | sed -e 's,.*/,,'`
-+
-+usage="\
-+Usage: $0 [OPTION] CPU-MFR-OPSYS
-+       $0 [OPTION] ALIAS
-+
-+Canonicalize a configuration name.
-+
-+Operation modes:
-+  -h, --help         print this help, then exit
-+  -t, --time-stamp   print date of last modification, then exit
-+  -v, --version      print version number, then exit
-+
-+Report bugs and patches to <config-patches@gnu.org>."
-+
-+version="\
-+GNU config.sub ($timestamp)
-+
-+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
-+Free Software Foundation, Inc.
-+
-+This is free software; see the source for copying conditions.  There is NO
-+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
-+
-+help="
-+Try \`$me --help' for more information."
-+
-+# Parse command line
-+while test $# -gt 0 ; do
-+  case $1 in
-+    --time-stamp | --time* | -t )
-+       echo "$timestamp" ; exit ;;
-+    --version | -v )
-+       echo "$version" ; exit ;;
-+    --help | --h* | -h )
-+       echo "$usage"; exit ;;
-+    -- )     # Stop option processing
-+       shift; break ;;
-+    - )	# Use stdin as input.
-+       break ;;
-+    -* )
-+       echo "$me: invalid option $1$help"
-+       exit 1 ;;
-+
-+    *local*)
-+       # First pass through any local machine types.
-+       echo $1
-+       exit ;;
-+
-+    * )
-+       break ;;
-+  esac
-+done
-+
-+case $# in
-+ 0) echo "$me: missing argument$help" >&2
-+    exit 1;;
-+ 1) ;;
-+ *) echo "$me: too many arguments$help" >&2
-+    exit 1;;
-+esac
-+
-+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
-+# Here we must recognize all the valid KERNEL-OS combinations.
-+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
-+case $maybe_os in
-+  nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
-+  linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
-+  knetbsd*-gnu* | netbsd*-gnu* | \
-+  kopensolaris*-gnu* | \
-+  storm-chaos* | os2-emx* | rtmk-nova*)
-+    os=-$maybe_os
-+    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
-+    ;;
-+  android-linux)
-+    os=-linux-android
-+    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
-+    ;;
-+  *)
-+    basic_machine=`echo $1 | sed 's/-[^-]*$//'`
-+    if [ $basic_machine != $1 ]
-+    then os=`echo $1 | sed 's/.*-/-/'`
-+    else os=; fi
-+    ;;
-+esac
-+
-+### Let's recognize common machines as not being operating systems so
-+### that things like config.sub decstation-3100 work.  We also
-+### recognize some manufacturers as not being operating systems, so we
-+### can provide default operating systems below.
-+case $os in
-+	-sun*os*)
-+		# Prevent following clause from handling this invalid input.
-+		;;
-+	-dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
-+	-att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
-+	-unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
-+	-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-+	-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-+	-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-+	-apple | -axis | -knuth | -cray | -microblaze)
-+		os=
-+		basic_machine=$1
-+		;;
-+	-bluegene*)
-+		os=-cnk
-+		;;
-+	-sim | -cisco | -oki | -wec | -winbond)
-+		os=
-+		basic_machine=$1
-+		;;
-+	-scout)
-+		;;
-+	-wrs)
-+		os=-vxworks
-+		basic_machine=$1
-+		;;
-+	-chorusos*)
-+		os=-chorusos
-+		basic_machine=$1
-+		;;
-+	-chorusrdb)
-+		os=-chorusrdb
-+		basic_machine=$1
-+		;;
-+	-hiux*)
-+		os=-hiuxwe2
-+		;;
-+	-sco6)
-+		os=-sco5v6
-+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-+		;;
-+	-sco5)
-+		os=-sco3.2v5
-+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-+		;;
-+	-sco4)
-+		os=-sco3.2v4
-+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-+		;;
-+	-sco3.2.[4-9]*)
-+		os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
-+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-+		;;
-+	-sco3.2v[4-9]*)
-+		# Don't forget version if it is 3.2v4 or newer.
-+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-+		;;
-+	-sco5v6*)
-+		# Don't forget version if it is 3.2v4 or newer.
-+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-+		;;
-+	-sco*)
-+		os=-sco3.2v2
-+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-+		;;
-+	-udk*)
-+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-+		;;
-+	-isc)
-+		os=-isc2.2
-+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-+		;;
-+	-clix*)
-+		basic_machine=clipper-intergraph
-+		;;
-+	-isc*)
-+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-+		;;
-+	-lynx*)
-+		os=-lynxos
-+		;;
-+	-ptx*)
-+		basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
-+		;;
-+	-windowsnt*)
-+		os=`echo $os | sed -e 's/windowsnt/winnt/'`
-+		;;
-+	-psos*)
-+		os=-psos
-+		;;
-+	-mint | -mint[0-9]*)
-+		basic_machine=m68k-atari
-+		os=-mint
-+		;;
-+esac
-+
-+# Decode aliases for certain CPU-COMPANY combinations.
-+case $basic_machine in
-+	# Recognize the basic CPU types without company name.
-+	# Some are omitted here because they have special meanings below.
-+	1750a | 580 \
-+	| a29k \
-+	| aarch64 | aarch64_be \
-+	| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
-+	| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
-+	| am33_2.0 \
-+	| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
-+        | be32 | be64 \
-+	| bfin \
-+	| c4x | clipper \
-+	| d10v | d30v | dlx | dsp16xx \
-+	| epiphany \
-+	| fido | fr30 | frv \
-+	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
-+	| hexagon \
-+	| i370 | i860 | i960 | ia64 \
-+	| ip2k | iq2000 \
-+	| le32 | le64 \
-+	| lm32 \
-+	| m32c | m32r | m32rle | m68000 | m68k | m88k \
-+	| maxq | mb | microblaze | mcore | mep | metag \
-+	| mips | mipsbe | mipseb | mipsel | mipsle \
-+	| mips16 \
-+	| mips64 | mips64el \
-+	| mips64octeon | mips64octeonel \
-+	| mips64orion | mips64orionel \
-+	| mips64r5900 | mips64r5900el \
-+	| mips64vr | mips64vrel \
-+	| mips64vr4100 | mips64vr4100el \
-+	| mips64vr4300 | mips64vr4300el \
-+	| mips64vr5000 | mips64vr5000el \
-+	| mips64vr5900 | mips64vr5900el \
-+	| mipsisa32 | mipsisa32el \
-+	| mipsisa32r2 | mipsisa32r2el \
-+	| mipsisa64 | mipsisa64el \
-+	| mipsisa64r2 | mipsisa64r2el \
-+	| mipsisa64sb1 | mipsisa64sb1el \
-+	| mipsisa64sr71k | mipsisa64sr71kel \
-+	| mipstx39 | mipstx39el \
-+	| mn10200 | mn10300 \
-+	| moxie \
-+	| mt \
-+	| msp430 \
-+	| nds32 | nds32le | nds32be \
-+	| nios | nios2 \
-+	| ns16k | ns32k \
-+	| open8 \
-+	| or32 \
-+	| pdp10 | pdp11 | pj | pjl \
-+	| powerpc | powerpc64 | powerpc64le | powerpcle \
-+	| pyramid \
-+	| rl78 | rx \
-+	| score \
-+	| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
-+	| sh64 | sh64le \
-+	| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
-+	| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
-+	| spu \
-+	| tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
-+	| ubicom32 \
-+	| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
-+	| we32k \
-+	| x86 | xc16x | xstormy16 | xtensa \
-+	| z8k | z80)
-+		basic_machine=$basic_machine-unknown
-+		;;
-+	c54x)
-+		basic_machine=tic54x-unknown
-+		;;
-+	c55x)
-+		basic_machine=tic55x-unknown
-+		;;
-+	c6x)
-+		basic_machine=tic6x-unknown
-+		;;
-+	m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
-+		basic_machine=$basic_machine-unknown
-+		os=-none
-+		;;
-+	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
-+		;;
-+	ms1)
-+		basic_machine=mt-unknown
-+		;;
-+
-+	strongarm | thumb | xscale)
-+		basic_machine=arm-unknown
-+		;;
-+	xgate)
-+		basic_machine=$basic_machine-unknown
-+		os=-none
-+		;;
-+	xscaleeb)
-+		basic_machine=armeb-unknown
-+		;;
-+
-+	xscaleel)
-+		basic_machine=armel-unknown
-+		;;
-+
-+	# We use `pc' rather than `unknown'
-+	# because (1) that's what they normally are, and
-+	# (2) the word "unknown" tends to confuse beginning users.
-+	i*86 | x86_64)
-+	  basic_machine=$basic_machine-pc
-+	  ;;
-+	# Object if more than one company name word.
-+	*-*-*)
-+		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
-+		exit 1
-+		;;
-+	# Recognize the basic CPU types with company name.
-+	580-* \
-+	| a29k-* \
-+	| aarch64-* | aarch64_be-* \
-+	| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
-+	| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
-+	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
-+	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
-+	| avr-* | avr32-* \
-+	| be32-* | be64-* \
-+	| bfin-* | bs2000-* \
-+	| c[123]* | c30-* | [cjt]90-* | c4x-* \
-+	| clipper-* | craynv-* | cydra-* \
-+	| d10v-* | d30v-* | dlx-* \
-+	| elxsi-* \
-+	| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
-+	| h8300-* | h8500-* \
-+	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
-+	| hexagon-* \
-+	| i*86-* | i860-* | i960-* | ia64-* \
-+	| ip2k-* | iq2000-* \
-+	| le32-* | le64-* \
-+	| lm32-* \
-+	| m32c-* | m32r-* | m32rle-* \
-+	| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
-+	| m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \
-+	| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
-+	| mips16-* \
-+	| mips64-* | mips64el-* \
-+	| mips64octeon-* | mips64octeonel-* \
-+	| mips64orion-* | mips64orionel-* \
-+	| mips64r5900-* | mips64r5900el-* \
-+	| mips64vr-* | mips64vrel-* \
-+	| mips64vr4100-* | mips64vr4100el-* \
-+	| mips64vr4300-* | mips64vr4300el-* \
-+	| mips64vr5000-* | mips64vr5000el-* \
-+	| mips64vr5900-* | mips64vr5900el-* \
-+	| mipsisa32-* | mipsisa32el-* \
-+	| mipsisa32r2-* | mipsisa32r2el-* \
-+	| mipsisa64-* | mipsisa64el-* \
-+	| mipsisa64r2-* | mipsisa64r2el-* \
-+	| mipsisa64sb1-* | mipsisa64sb1el-* \
-+	| mipsisa64sr71k-* | mipsisa64sr71kel-* \
-+	| mipstx39-* | mipstx39el-* \
-+	| mmix-* \
-+	| mt-* \
-+	| msp430-* \
-+	| nds32-* | nds32le-* | nds32be-* \
-+	| nios-* | nios2-* \
-+	| none-* | np1-* | ns16k-* | ns32k-* \
-+	| open8-* \
-+	| orion-* \
-+	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
-+	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
-+	| pyramid-* \
-+	| rl78-* | romp-* | rs6000-* | rx-* \
-+	| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
-+	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
-+	| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
-+	| sparclite-* \
-+	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
-+	| tahoe-* \
-+	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
-+	| tile*-* \
-+	| tron-* \
-+	| ubicom32-* \
-+	| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
-+	| vax-* \
-+	| we32k-* \
-+	| x86-* | x86_64-* | xc16x-* | xps100-* \
-+	| xstormy16-* | xtensa*-* \
-+	| ymp-* \
-+	| z8k-* | z80-*)
-+		;;
-+	# Recognize the basic CPU types without company name, with glob match.
-+	xtensa*)
-+		basic_machine=$basic_machine-unknown
-+		;;
-+	# Recognize the various machine names and aliases which stand
-+	# for a CPU type and a company and sometimes even an OS.
-+	386bsd)
-+		basic_machine=i386-unknown
-+		os=-bsd
-+		;;
-+	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
-+		basic_machine=m68000-att
-+		;;
-+	3b*)
-+		basic_machine=we32k-att
-+		;;
-+	a29khif)
-+		basic_machine=a29k-amd
-+		os=-udi
-+		;;
-+	abacus)
-+		basic_machine=abacus-unknown
-+		;;
-+	adobe68k)
-+		basic_machine=m68010-adobe
-+		os=-scout
-+		;;
-+	alliant | fx80)
-+		basic_machine=fx80-alliant
-+		;;
-+	altos | altos3068)
-+		basic_machine=m68k-altos
-+		;;
-+	am29k)
-+		basic_machine=a29k-none
-+		os=-bsd
-+		;;
-+	amd64)
-+		basic_machine=x86_64-pc
-+		;;
-+	amd64-*)
-+		basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
-+		;;
-+	amdahl)
-+		basic_machine=580-amdahl
-+		os=-sysv
-+		;;
-+	amiga | amiga-*)
-+		basic_machine=m68k-unknown
-+		;;
-+	amigaos | amigados)
-+		basic_machine=m68k-unknown
-+		os=-amigaos
-+		;;
-+	amigaunix | amix)
-+		basic_machine=m68k-unknown
-+		os=-sysv4
-+		;;
-+	apollo68)
-+		basic_machine=m68k-apollo
-+		os=-sysv
-+		;;
-+	apollo68bsd)
-+		basic_machine=m68k-apollo
-+		os=-bsd
-+		;;
-+	aros)
-+		basic_machine=i386-pc
-+		os=-aros
-+		;;
-+	aux)
-+		basic_machine=m68k-apple
-+		os=-aux
-+		;;
-+	balance)
-+		basic_machine=ns32k-sequent
-+		os=-dynix
-+		;;
-+	blackfin)
-+		basic_machine=bfin-unknown
-+		os=-linux
-+		;;
-+	blackfin-*)
-+		basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
-+		os=-linux
-+		;;
-+	bluegene*)
-+		basic_machine=powerpc-ibm
-+		os=-cnk
-+		;;
-+	c54x-*)
-+		basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
-+		;;
-+	c55x-*)
-+		basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
-+		;;
-+	c6x-*)
-+		basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
-+		;;
-+	c90)
-+		basic_machine=c90-cray
-+		os=-unicos
-+		;;
-+	cegcc)
-+		basic_machine=arm-unknown
-+		os=-cegcc
-+		;;
-+	convex-c1)
-+		basic_machine=c1-convex
-+		os=-bsd
-+		;;
-+	convex-c2)
-+		basic_machine=c2-convex
-+		os=-bsd
-+		;;
-+	convex-c32)
-+		basic_machine=c32-convex
-+		os=-bsd
-+		;;
-+	convex-c34)
-+		basic_machine=c34-convex
-+		os=-bsd
-+		;;
-+	convex-c38)
-+		basic_machine=c38-convex
-+		os=-bsd
-+		;;
-+	cray | j90)
-+		basic_machine=j90-cray
-+		os=-unicos
-+		;;
-+	craynv)
-+		basic_machine=craynv-cray
-+		os=-unicosmp
-+		;;
-+	cr16 | cr16-*)
-+		basic_machine=cr16-unknown
-+		os=-elf
-+		;;
-+	crds | unos)
-+		basic_machine=m68k-crds
-+		;;
-+	crisv32 | crisv32-* | etraxfs*)
-+		basic_machine=crisv32-axis
-+		;;
-+	cris | cris-* | etrax*)
-+		basic_machine=cris-axis
-+		;;
-+	crx)
-+		basic_machine=crx-unknown
-+		os=-elf
-+		;;
-+	da30 | da30-*)
-+		basic_machine=m68k-da30
-+		;;
-+	decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
-+		basic_machine=mips-dec
-+		;;
-+	decsystem10* | dec10*)
-+		basic_machine=pdp10-dec
-+		os=-tops10
-+		;;
-+	decsystem20* | dec20*)
-+		basic_machine=pdp10-dec
-+		os=-tops20
-+		;;
-+	delta | 3300 | motorola-3300 | motorola-delta \
-+	      | 3300-motorola | delta-motorola)
-+		basic_machine=m68k-motorola
-+		;;
-+	delta88)
-+		basic_machine=m88k-motorola
-+		os=-sysv3
-+		;;
-+	dicos)
-+		basic_machine=i686-pc
-+		os=-dicos
-+		;;
-+	djgpp)
-+		basic_machine=i586-pc
-+		os=-msdosdjgpp
-+		;;
-+	dpx20 | dpx20-*)
-+		basic_machine=rs6000-bull
-+		os=-bosx
-+		;;
-+	dpx2* | dpx2*-bull)
-+		basic_machine=m68k-bull
-+		os=-sysv3
-+		;;
-+	ebmon29k)
-+		basic_machine=a29k-amd
-+		os=-ebmon
-+		;;
-+	elxsi)
-+		basic_machine=elxsi-elxsi
-+		os=-bsd
-+		;;
-+	encore | umax | mmax)
-+		basic_machine=ns32k-encore
-+		;;
-+	es1800 | OSE68k | ose68k | ose | OSE)
-+		basic_machine=m68k-ericsson
-+		os=-ose
-+		;;
-+	fx2800)
-+		basic_machine=i860-alliant
-+		;;
-+	genix)
-+		basic_machine=ns32k-ns
-+		;;
-+	gmicro)
-+		basic_machine=tron-gmicro
-+		os=-sysv
-+		;;
-+	go32)
-+		basic_machine=i386-pc
-+		os=-go32
-+		;;
-+	h3050r* | hiux*)
-+		basic_machine=hppa1.1-hitachi
-+		os=-hiuxwe2
-+		;;
-+	h8300hms)
-+		basic_machine=h8300-hitachi
-+		os=-hms
-+		;;
-+	h8300xray)
-+		basic_machine=h8300-hitachi
-+		os=-xray
-+		;;
-+	h8500hms)
-+		basic_machine=h8500-hitachi
-+		os=-hms
-+		;;
-+	harris)
-+		basic_machine=m88k-harris
-+		os=-sysv3
-+		;;
-+	hp300-*)
-+		basic_machine=m68k-hp
-+		;;
-+	hp300bsd)
-+		basic_machine=m68k-hp
-+		os=-bsd
-+		;;
-+	hp300hpux)
-+		basic_machine=m68k-hp
-+		os=-hpux
-+		;;
-+	hp3k9[0-9][0-9] | hp9[0-9][0-9])
-+		basic_machine=hppa1.0-hp
-+		;;
-+	hp9k2[0-9][0-9] | hp9k31[0-9])
-+		basic_machine=m68000-hp
-+		;;
-+	hp9k3[2-9][0-9])
-+		basic_machine=m68k-hp
-+		;;
-+	hp9k6[0-9][0-9] | hp6[0-9][0-9])
-+		basic_machine=hppa1.0-hp
-+		;;
-+	hp9k7[0-79][0-9] | hp7[0-79][0-9])
-+		basic_machine=hppa1.1-hp
-+		;;
-+	hp9k78[0-9] | hp78[0-9])
-+		# FIXME: really hppa2.0-hp
-+		basic_machine=hppa1.1-hp
-+		;;
-+	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
-+		# FIXME: really hppa2.0-hp
-+		basic_machine=hppa1.1-hp
-+		;;
-+	hp9k8[0-9][13679] | hp8[0-9][13679])
-+		basic_machine=hppa1.1-hp
-+		;;
-+	hp9k8[0-9][0-9] | hp8[0-9][0-9])
-+		basic_machine=hppa1.0-hp
-+		;;
-+	hppa-next)
-+		os=-nextstep3
-+		;;
-+	hppaosf)
-+		basic_machine=hppa1.1-hp
-+		os=-osf
-+		;;
-+	hppro)
-+		basic_machine=hppa1.1-hp
-+		os=-proelf
-+		;;
-+	i370-ibm* | ibm*)
-+		basic_machine=i370-ibm
-+		;;
-+	i*86v32)
-+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
-+		os=-sysv32
-+		;;
-+	i*86v4*)
-+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
-+		os=-sysv4
-+		;;
-+	i*86v)
-+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
-+		os=-sysv
-+		;;
-+	i*86sol2)
-+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
-+		os=-solaris2
-+		;;
-+	i386mach)
-+		basic_machine=i386-mach
-+		os=-mach
-+		;;
-+	i386-vsta | vsta)
-+		basic_machine=i386-unknown
-+		os=-vsta
-+		;;
-+	iris | iris4d)
-+		basic_machine=mips-sgi
-+		case $os in
-+		    -irix*)
-+			;;
-+		    *)
-+			os=-irix4
-+			;;
-+		esac
-+		;;
-+	isi68 | isi)
-+		basic_machine=m68k-isi
-+		os=-sysv
-+		;;
-+	m68knommu)
-+		basic_machine=m68k-unknown
-+		os=-linux
-+		;;
-+	m68knommu-*)
-+		basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
-+		os=-linux
-+		;;
-+	m88k-omron*)
-+		basic_machine=m88k-omron
-+		;;
-+	magnum | m3230)
-+		basic_machine=mips-mips
-+		os=-sysv
-+		;;
-+	merlin)
-+		basic_machine=ns32k-utek
-+		os=-sysv
-+		;;
-+	microblaze)
-+		basic_machine=microblaze-xilinx
-+		;;
-+	mingw32)
-+		basic_machine=i386-pc
-+		os=-mingw32
-+		;;
-+	mingw32ce)
-+		basic_machine=arm-unknown
-+		os=-mingw32ce
-+		;;
-+	miniframe)
-+		basic_machine=m68000-convergent
-+		;;
-+	*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
-+		basic_machine=m68k-atari
-+		os=-mint
-+		;;
-+	mips3*-*)
-+		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
-+		;;
-+	mips3*)
-+		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
-+		;;
-+	monitor)
-+		basic_machine=m68k-rom68k
-+		os=-coff
-+		;;
-+	morphos)
-+		basic_machine=powerpc-unknown
-+		os=-morphos
-+		;;
-+	msdos)
-+		basic_machine=i386-pc
-+		os=-msdos
-+		;;
-+	ms1-*)
-+		basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
-+		;;
-+	msys)
-+		basic_machine=i386-pc
-+		os=-msys
-+		;;
-+	mvs)
-+		basic_machine=i370-ibm
-+		os=-mvs
-+		;;
-+	nacl)
-+		basic_machine=le32-unknown
-+		os=-nacl
-+		;;
-+	ncr3000)
-+		basic_machine=i486-ncr
-+		os=-sysv4
-+		;;
-+	netbsd386)
-+		basic_machine=i386-unknown
-+		os=-netbsd
-+		;;
-+	netwinder)
-+		basic_machine=armv4l-rebel
-+		os=-linux
-+		;;
-+	news | news700 | news800 | news900)
-+		basic_machine=m68k-sony
-+		os=-newsos
-+		;;
-+	news1000)
-+		basic_machine=m68030-sony
-+		os=-newsos
-+		;;
-+	news-3600 | risc-news)
-+		basic_machine=mips-sony
-+		os=-newsos
-+		;;
-+	necv70)
-+		basic_machine=v70-nec
-+		os=-sysv
-+		;;
-+	next | m*-next )
-+		basic_machine=m68k-next
-+		case $os in
-+		    -nextstep* )
-+			;;
-+		    -ns2*)
-+		      os=-nextstep2
-+			;;
-+		    *)
-+		      os=-nextstep3
-+			;;
-+		esac
-+		;;
-+	nh3000)
-+		basic_machine=m68k-harris
-+		os=-cxux
-+		;;
-+	nh[45]000)
-+		basic_machine=m88k-harris
-+		os=-cxux
-+		;;
-+	nindy960)
-+		basic_machine=i960-intel
-+		os=-nindy
-+		;;
-+	mon960)
-+		basic_machine=i960-intel
-+		os=-mon960
-+		;;
-+	nonstopux)
-+		basic_machine=mips-compaq
-+		os=-nonstopux
-+		;;
-+	np1)
-+		basic_machine=np1-gould
-+		;;
-+	neo-tandem)
-+		basic_machine=neo-tandem
-+		;;
-+	nse-tandem)
-+		basic_machine=nse-tandem
-+		;;
-+	nsr-tandem)
-+		basic_machine=nsr-tandem
-+		;;
-+	op50n-* | op60c-*)
-+		basic_machine=hppa1.1-oki
-+		os=-proelf
-+		;;
-+	openrisc | openrisc-*)
-+		basic_machine=or32-unknown
-+		;;
-+	os400)
-+		basic_machine=powerpc-ibm
-+		os=-os400
-+		;;
-+	OSE68000 | ose68000)
-+		basic_machine=m68000-ericsson
-+		os=-ose
-+		;;
-+	os68k)
-+		basic_machine=m68k-none
-+		os=-os68k
-+		;;
-+	pa-hitachi)
-+		basic_machine=hppa1.1-hitachi
-+		os=-hiuxwe2
-+		;;
-+	paragon)
-+		basic_machine=i860-intel
-+		os=-osf
-+		;;
-+	parisc)
-+		basic_machine=hppa-unknown
-+		os=-linux
-+		;;
-+	parisc-*)
-+		basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
-+		os=-linux
-+		;;
-+	pbd)
-+		basic_machine=sparc-tti
-+		;;
-+	pbb)
-+		basic_machine=m68k-tti
-+		;;
-+	pc532 | pc532-*)
-+		basic_machine=ns32k-pc532
-+		;;
-+	pc98)
-+		basic_machine=i386-pc
-+		;;
-+	pc98-*)
-+		basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
-+		;;
-+	pentium | p5 | k5 | k6 | nexgen | viac3)
-+		basic_machine=i586-pc
-+		;;
-+	pentiumpro | p6 | 6x86 | athlon | athlon_*)
-+		basic_machine=i686-pc
-+		;;
-+	pentiumii | pentium2 | pentiumiii | pentium3)
-+		basic_machine=i686-pc
-+		;;
-+	pentium4)
-+		basic_machine=i786-pc
-+		;;
-+	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
-+		basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
-+		;;
-+	pentiumpro-* | p6-* | 6x86-* | athlon-*)
-+		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
-+		;;
-+	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
-+		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
-+		;;
-+	pentium4-*)
-+		basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
-+		;;
-+	pn)
-+		basic_machine=pn-gould
-+		;;
-+	power)	basic_machine=power-ibm
-+		;;
-+	ppc | ppcbe)	basic_machine=powerpc-unknown
-+		;;
-+	ppc-* | ppcbe-*)
-+		basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
-+		;;
-+	ppcle | powerpclittle | ppc-le | powerpc-little)
-+		basic_machine=powerpcle-unknown
-+		;;
-+	ppcle-* | powerpclittle-*)
-+		basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
-+		;;
-+	ppc64)	basic_machine=powerpc64-unknown
-+		;;
-+	ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
-+		;;
-+	ppc64le | powerpc64little | ppc64-le | powerpc64-little)
-+		basic_machine=powerpc64le-unknown
-+		;;
-+	ppc64le-* | powerpc64little-*)
-+		basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
-+		;;
-+	ps2)
-+		basic_machine=i386-ibm
-+		;;
-+	pw32)
-+		basic_machine=i586-unknown
-+		os=-pw32
-+		;;
-+	rdos)
-+		basic_machine=i386-pc
-+		os=-rdos
-+		;;
-+	rom68k)
-+		basic_machine=m68k-rom68k
-+		os=-coff
-+		;;
-+	rm[46]00)
-+		basic_machine=mips-siemens
-+		;;
-+	rtpc | rtpc-*)
-+		basic_machine=romp-ibm
-+		;;
-+	s390 | s390-*)
-+		basic_machine=s390-ibm
-+		;;
-+	s390x | s390x-*)
-+		basic_machine=s390x-ibm
-+		;;
-+	sa29200)
-+		basic_machine=a29k-amd
-+		os=-udi
-+		;;
-+	sb1)
-+		basic_machine=mipsisa64sb1-unknown
-+		;;
-+	sb1el)
-+		basic_machine=mipsisa64sb1el-unknown
-+		;;
-+	sde)
-+		basic_machine=mipsisa32-sde
-+		os=-elf
-+		;;
-+	sei)
-+		basic_machine=mips-sei
-+		os=-seiux
-+		;;
-+	sequent)
-+		basic_machine=i386-sequent
-+		;;
-+	sh)
-+		basic_machine=sh-hitachi
-+		os=-hms
-+		;;
-+	sh5el)
-+		basic_machine=sh5le-unknown
-+		;;
-+	sh64)
-+		basic_machine=sh64-unknown
-+		;;
-+	sparclite-wrs | simso-wrs)
-+		basic_machine=sparclite-wrs
-+		os=-vxworks
-+		;;
-+	sps7)
-+		basic_machine=m68k-bull
-+		os=-sysv2
-+		;;
-+	spur)
-+		basic_machine=spur-unknown
-+		;;
-+	st2000)
-+		basic_machine=m68k-tandem
-+		;;
-+	stratus)
-+		basic_machine=i860-stratus
-+		os=-sysv4
-+		;;
-+	strongarm-* | thumb-*)
-+		basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
-+		;;
-+	sun2)
-+		basic_machine=m68000-sun
-+		;;
-+	sun2os3)
-+		basic_machine=m68000-sun
-+		os=-sunos3
-+		;;
-+	sun2os4)
-+		basic_machine=m68000-sun
-+		os=-sunos4
-+		;;
-+	sun3os3)
-+		basic_machine=m68k-sun
-+		os=-sunos3
-+		;;
-+	sun3os4)
-+		basic_machine=m68k-sun
-+		os=-sunos4
-+		;;
-+	sun4os3)
-+		basic_machine=sparc-sun
-+		os=-sunos3
-+		;;
-+	sun4os4)
-+		basic_machine=sparc-sun
-+		os=-sunos4
-+		;;
-+	sun4sol2)
-+		basic_machine=sparc-sun
-+		os=-solaris2
-+		;;
-+	sun3 | sun3-*)
-+		basic_machine=m68k-sun
-+		;;
-+	sun4)
-+		basic_machine=sparc-sun
-+		;;
-+	sun386 | sun386i | roadrunner)
-+		basic_machine=i386-sun
-+		;;
-+	sv1)
-+		basic_machine=sv1-cray
-+		os=-unicos
-+		;;
-+	symmetry)
-+		basic_machine=i386-sequent
-+		os=-dynix
-+		;;
-+	t3e)
-+		basic_machine=alphaev5-cray
-+		os=-unicos
-+		;;
-+	t90)
-+		basic_machine=t90-cray
-+		os=-unicos
-+		;;
-+	tile*)
-+		basic_machine=$basic_machine-unknown
-+		os=-linux-gnu
-+		;;
-+	tx39)
-+		basic_machine=mipstx39-unknown
-+		;;
-+	tx39el)
-+		basic_machine=mipstx39el-unknown
-+		;;
-+	toad1)
-+		basic_machine=pdp10-xkl
-+		os=-tops20
-+		;;
-+	tower | tower-32)
-+		basic_machine=m68k-ncr
-+		;;
-+	tpf)
-+		basic_machine=s390x-ibm
-+		os=-tpf
-+		;;
-+	udi29k)
-+		basic_machine=a29k-amd
-+		os=-udi
-+		;;
-+	ultra3)
-+		basic_machine=a29k-nyu
-+		os=-sym1
-+		;;
-+	v810 | necv810)
-+		basic_machine=v810-nec
-+		os=-none
-+		;;
-+	vaxv)
-+		basic_machine=vax-dec
-+		os=-sysv
-+		;;
-+	vms)
-+		basic_machine=vax-dec
-+		os=-vms
-+		;;
-+	vpp*|vx|vx-*)
-+		basic_machine=f301-fujitsu
-+		;;
-+	vxworks960)
-+		basic_machine=i960-wrs
-+		os=-vxworks
-+		;;
-+	vxworks68)
-+		basic_machine=m68k-wrs
-+		os=-vxworks
-+		;;
-+	vxworks29k)
-+		basic_machine=a29k-wrs
-+		os=-vxworks
-+		;;
-+	w65*)
-+		basic_machine=w65-wdc
-+		os=-none
-+		;;
-+	w89k-*)
-+		basic_machine=hppa1.1-winbond
-+		os=-proelf
-+		;;
-+	xbox)
-+		basic_machine=i686-pc
-+		os=-mingw32
-+		;;
-+	xps | xps100)
-+		basic_machine=xps100-honeywell
-+		;;
-+	xscale-* | xscalee[bl]-*)
-+		basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
-+		;;
-+	ymp)
-+		basic_machine=ymp-cray
-+		os=-unicos
-+		;;
-+	z8k-*-coff)
-+		basic_machine=z8k-unknown
-+		os=-sim
-+		;;
-+	z80-*-coff)
-+		basic_machine=z80-unknown
-+		os=-sim
-+		;;
-+	none)
-+		basic_machine=none-none
-+		os=-none
-+		;;
-+
-+# Here we handle the default manufacturer of certain CPU types.  It is in
-+# some cases the only manufacturer, in others, it is the most popular.
-+	w89k)
-+		basic_machine=hppa1.1-winbond
-+		;;
-+	op50n)
-+		basic_machine=hppa1.1-oki
-+		;;
-+	op60c)
-+		basic_machine=hppa1.1-oki
-+		;;
-+	romp)
-+		basic_machine=romp-ibm
-+		;;
-+	mmix)
-+		basic_machine=mmix-knuth
-+		;;
-+	rs6000)
-+		basic_machine=rs6000-ibm
-+		;;
-+	vax)
-+		basic_machine=vax-dec
-+		;;
-+	pdp10)
-+		# there are many clones, so DEC is not a safe bet
-+		basic_machine=pdp10-unknown
-+		;;
-+	pdp11)
-+		basic_machine=pdp11-dec
-+		;;
-+	we32k)
-+		basic_machine=we32k-att
-+		;;
-+	sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
-+		basic_machine=sh-unknown
-+		;;
-+	sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
-+		basic_machine=sparc-sun
-+		;;
-+	cydra)
-+		basic_machine=cydra-cydrome
-+		;;
-+	orion)
-+		basic_machine=orion-highlevel
-+		;;
-+	orion105)
-+		basic_machine=clipper-highlevel
-+		;;
-+	mac | mpw | mac-mpw)
-+		basic_machine=m68k-apple
-+		;;
-+	pmac | pmac-mpw)
-+		basic_machine=powerpc-apple
-+		;;
-+	*-unknown)
-+		# Make sure to match an already-canonicalized machine name.
-+		;;
-+	*)
-+		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
-+		exit 1
-+		;;
-+esac
-+
-+# Here we canonicalize certain aliases for manufacturers.
-+case $basic_machine in
-+	*-digital*)
-+		basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
-+		;;
-+	*-commodore*)
-+		basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
-+		;;
-+	*)
-+		;;
-+esac
-+
-+# Decode manufacturer-specific aliases for certain operating systems.
-+
-+if [ x"$os" != x"" ]
-+then
-+case $os in
-+	# First match some system type aliases
-+	# that might get confused with valid system types.
-+	# -solaris* is a basic system type, with this one exception.
-+	-auroraux)
-+		os=-auroraux
-+		;;
-+	-solaris1 | -solaris1.*)
-+		os=`echo $os | sed -e 's|solaris1|sunos4|'`
-+		;;
-+	-solaris)
-+		os=-solaris2
-+		;;
-+	-svr4*)
-+		os=-sysv4
-+		;;
-+	-unixware*)
-+		os=-sysv4.2uw
-+		;;
-+	-gnu/linux*)
-+		os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
-+		;;
-+	# First accept the basic system types.
-+	# The portable systems comes first.
-+	# Each alternative MUST END IN A *, to match a version number.
-+	# -sysv* is not here because it comes later, after sysvr4.
-+	-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
-+	      | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
-+	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
-+	      | -sym* | -kopensolaris* \
-+	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
-+	      | -aos* | -aros* \
-+	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
-+	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
-+	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
-+	      | -openbsd* | -solidbsd* \
-+	      | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
-+	      | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
-+	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
-+	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
-+	      | -chorusos* | -chorusrdb* | -cegcc* \
-+	      | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
-+	      | -mingw32* | -linux-gnu* | -linux-android* \
-+	      | -linux-newlib* | -linux-uclibc* \
-+	      | -uxpv* | -beos* | -mpeix* | -udk* \
-+	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
-+	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
-+	      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
-+	      | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
-+	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
-+	      | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
-+	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
-+	# Remember, each alternative MUST END IN *, to match a version number.
-+		;;
-+	-qnx*)
-+		case $basic_machine in
-+		    x86-* | i*86-*)
-+			;;
-+		    *)
-+			os=-nto$os
-+			;;
-+		esac
-+		;;
-+	-nto-qnx*)
-+		;;
-+	-nto*)
-+		os=`echo $os | sed -e 's|nto|nto-qnx|'`
-+		;;
-+	-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
-+	      | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
-+	      | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
-+		;;
-+	-mac*)
-+		os=`echo $os | sed -e 's|mac|macos|'`
-+		;;
-+	-linux-dietlibc)
-+		os=-linux-dietlibc
-+		;;
-+	-linux*)
-+		os=`echo $os | sed -e 's|linux|linux-gnu|'`
-+		;;
-+	-sunos5*)
-+		os=`echo $os | sed -e 's|sunos5|solaris2|'`
-+		;;
-+	-sunos6*)
-+		os=`echo $os | sed -e 's|sunos6|solaris3|'`
-+		;;
-+	-opened*)
-+		os=-openedition
-+		;;
-+	-os400*)
-+		os=-os400
-+		;;
-+	-wince*)
-+		os=-wince
-+		;;
-+	-osfrose*)
-+		os=-osfrose
-+		;;
-+	-osf*)
-+		os=-osf
-+		;;
-+	-utek*)
-+		os=-bsd
-+		;;
-+	-dynix*)
-+		os=-bsd
-+		;;
-+	-acis*)
-+		os=-aos
-+		;;
-+	-atheos*)
-+		os=-atheos
-+		;;
-+	-syllable*)
-+		os=-syllable
-+		;;
-+	-386bsd)
-+		os=-bsd
-+		;;
-+	-ctix* | -uts*)
-+		os=-sysv
-+		;;
-+	-nova*)
-+		os=-rtmk-nova
-+		;;
-+	-ns2 )
-+		os=-nextstep2
-+		;;
-+	-nsk*)
-+		os=-nsk
-+		;;
-+	# Preserve the version number of sinix5.
-+	-sinix5.*)
-+		os=`echo $os | sed -e 's|sinix|sysv|'`
-+		;;
-+	-sinix*)
-+		os=-sysv4
-+		;;
-+	-tpf*)
-+		os=-tpf
-+		;;
-+	-triton*)
-+		os=-sysv3
-+		;;
-+	-oss*)
-+		os=-sysv3
-+		;;
-+	-svr4)
-+		os=-sysv4
-+		;;
-+	-svr3)
-+		os=-sysv3
-+		;;
-+	-sysvr4)
-+		os=-sysv4
-+		;;
-+	# This must come after -sysvr4.
-+	-sysv*)
-+		;;
-+	-ose*)
-+		os=-ose
-+		;;
-+	-es1800*)
-+		os=-ose
-+		;;
-+	-xenix)
-+		os=-xenix
-+		;;
-+	-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
-+		os=-mint
-+		;;
-+	-aros*)
-+		os=-aros
-+		;;
-+	-kaos*)
-+		os=-kaos
-+		;;
-+	-zvmoe)
-+		os=-zvmoe
-+		;;
-+	-dicos*)
-+		os=-dicos
-+		;;
-+	-nacl*)
-+		;;
-+	-none)
-+		;;
-+	*)
-+		# Get rid of the `-' at the beginning of $os.
-+		os=`echo $os | sed 's/[^-]*-//'`
-+		echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
-+		exit 1
-+		;;
-+esac
-+else
-+
-+# Here we handle the default operating systems that come with various machines.
-+# The value should be what the vendor currently ships out the door with their
-+# machine or put another way, the most popular os provided with the machine.
-+
-+# Note that if you're going to try to match "-MANUFACTURER" here (say,
-+# "-sun"), then you have to tell the case statement up towards the top
-+# that MANUFACTURER isn't an operating system.  Otherwise, code above
-+# will signal an error saying that MANUFACTURER isn't an operating
-+# system, and we'll never get to this point.
-+
-+case $basic_machine in
-+	score-*)
-+		os=-elf
-+		;;
-+	spu-*)
-+		os=-elf
-+		;;
-+	*-acorn)
-+		os=-riscix1.2
-+		;;
-+	arm*-rebel)
-+		os=-linux
-+		;;
-+	arm*-semi)
-+		os=-aout
-+		;;
-+	c4x-* | tic4x-*)
-+		os=-coff
-+		;;
-+	tic54x-*)
-+		os=-coff
-+		;;
-+	tic55x-*)
-+		os=-coff
-+		;;
-+	tic6x-*)
-+		os=-coff
-+		;;
-+	# This must come before the *-dec entry.
-+	pdp10-*)
-+		os=-tops20
-+		;;
-+	pdp11-*)
-+		os=-none
-+		;;
-+	*-dec | vax-*)
-+		os=-ultrix4.2
-+		;;
-+	m68*-apollo)
-+		os=-domain
-+		;;
-+	i386-sun)
-+		os=-sunos4.0.2
-+		;;
-+	m68000-sun)
-+		os=-sunos3
-+		;;
-+	m68*-cisco)
-+		os=-aout
-+		;;
-+	mep-*)
-+		os=-elf
-+		;;
-+	mips*-cisco)
-+		os=-elf
-+		;;
-+	mips*-*)
-+		os=-elf
-+		;;
-+	or32-*)
-+		os=-coff
-+		;;
-+	*-tti)	# must be before sparc entry or we get the wrong os.
-+		os=-sysv3
-+		;;
-+	sparc-* | *-sun)
-+		os=-sunos4.1.1
-+		;;
-+	*-be)
-+		os=-beos
-+		;;
-+	*-haiku)
-+		os=-haiku
-+		;;
-+	*-ibm)
-+		os=-aix
-+		;;
-+	*-knuth)
-+		os=-mmixware
-+		;;
-+	*-wec)
-+		os=-proelf
-+		;;
-+	*-winbond)
-+		os=-proelf
-+		;;
-+	*-oki)
-+		os=-proelf
-+		;;
-+	*-hp)
-+		os=-hpux
-+		;;
-+	*-hitachi)
-+		os=-hiux
-+		;;
-+	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
-+		os=-sysv
-+		;;
-+	*-cbm)
-+		os=-amigaos
-+		;;
-+	*-dg)
-+		os=-dgux
-+		;;
-+	*-dolphin)
-+		os=-sysv3
-+		;;
-+	m68k-ccur)
-+		os=-rtu
-+		;;
-+	m88k-omron*)
-+		os=-luna
-+		;;
-+	*-next )
-+		os=-nextstep
-+		;;
-+	*-sequent)
-+		os=-ptx
-+		;;
-+	*-crds)
-+		os=-unos
-+		;;
-+	*-ns)
-+		os=-genix
-+		;;
-+	i370-*)
-+		os=-mvs
-+		;;
-+	*-next)
-+		os=-nextstep3
-+		;;
-+	*-gould)
-+		os=-sysv
-+		;;
-+	*-highlevel)
-+		os=-bsd
-+		;;
-+	*-encore)
-+		os=-bsd
-+		;;
-+	*-sgi)
-+		os=-irix
-+		;;
-+	*-siemens)
-+		os=-sysv4
-+		;;
-+	*-masscomp)
-+		os=-rtu
-+		;;
-+	f30[01]-fujitsu | f700-fujitsu)
-+		os=-uxpv
-+		;;
-+	*-rom68k)
-+		os=-coff
-+		;;
-+	*-*bug)
-+		os=-coff
-+		;;
-+	*-apple)
-+		os=-macos
-+		;;
-+	*-atari*)
-+		os=-mint
-+		;;
-+	*)
-+		os=-none
-+		;;
-+esac
-+fi
-+
-+# Here we handle the case where we know the os, and the CPU type, but not the
-+# manufacturer.  We pick the logical manufacturer.
-+vendor=unknown
-+case $basic_machine in
-+	*-unknown)
-+		case $os in
-+			-riscix*)
-+				vendor=acorn
-+				;;
-+			-sunos*)
-+				vendor=sun
-+				;;
-+			-cnk*|-aix*)
-+				vendor=ibm
-+				;;
-+			-beos*)
-+				vendor=be
-+				;;
-+			-hpux*)
-+				vendor=hp
-+				;;
-+			-mpeix*)
-+				vendor=hp
-+				;;
-+			-hiux*)
-+				vendor=hitachi
-+				;;
-+			-unos*)
-+				vendor=crds
-+				;;
-+			-dgux*)
-+				vendor=dg
-+				;;
-+			-luna*)
-+				vendor=omron
-+				;;
-+			-genix*)
-+				vendor=ns
-+				;;
-+			-mvs* | -opened*)
-+				vendor=ibm
-+				;;
-+			-os400*)
-+				vendor=ibm
-+				;;
-+			-ptx*)
-+				vendor=sequent
-+				;;
-+			-tpf*)
-+				vendor=ibm
-+				;;
-+			-vxsim* | -vxworks* | -windiss*)
-+				vendor=wrs
-+				;;
-+			-aux*)
-+				vendor=apple
-+				;;
-+			-hms*)
-+				vendor=hitachi
-+				;;
-+			-mpw* | -macos*)
-+				vendor=apple
-+				;;
-+			-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
-+				vendor=atari
-+				;;
-+			-vos*)
-+				vendor=stratus
-+				;;
-+		esac
-+		basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
-+		;;
-+esac
-+
-+echo $basic_machine$os
-+exit
-+
-+# Local variables:
-+# eval: (add-hook 'write-file-hooks 'time-stamp)
-+# time-stamp-start: "timestamp='"
-+# time-stamp-format: "%:y-%02m-%02d"
-+# time-stamp-end: "'"
-+# End:
-diff -urN a/configure.in b/configure.in
---- a/configure.in	2012-04-10 00:07:36.000000000 +0100
-+++ b/configure.in	2012-06-25 19:39:10.610815313 +0100
-@@ -11,6 +11,7 @@
- AC_INIT(python, PYTHON_VERSION, http://bugs.python.org/)
- AC_CONFIG_SRCDIR([Include/object.h])
- AC_CONFIG_HEADER(pyconfig.h)
-+AC_CANONICAL_HOST
- 
- dnl Ensure that if prefix is specified, it does not end in a slash. If
- dnl it does, we get path names containing '//' which is both ugly and
-@@ -42,6 +43,46 @@
- rm confdefs.h
- mv confdefs.h.new confdefs.h
- 
-+dnl makefile conditional (for future use)
-+if test "x$cross_compiling" = xyes; then
-+  CROSS_ON=''
-+  CROSS_OFF='#'
-+else
-+  CROSS_ON='#'
-+  CROSS_OFF=''
-+fi
-+AC_SUBST(CROSS_ON)
-+AC_SUBST(CROSS_OFF)
-+
-+AC_PROG_LN_S
-+if test "x$cross_compiling" = xyes; then
-+  AC_MSG_WARN([cross-compilation is incomplete])
-+
-+  dnl In cross-compilation environment we need python from
-+  dnl the build system (for future use)
-+  AC_PATH_PROG(SYSPYTHON, python, [none],
-+    [$PATH:/usr/local/bin]
-+  )
-+  if test "x$SYSPYTHON" = xnone; then
-+    AC_MSG_ERROR([python program is required in cross-compilation environment])
-+  fi
-+  SYSPYOSNAME=`${SYSPYTHON} -c "import os; print os.name"`
-+  case $SYSPYOSNAME in
-+  posix)
-+    dnl On posix distutils read variables from installed makefile.
-+    dnl We will do some hacks based on distutils internals to overcome
-+    dnl this limitation:
-+    dnl - we link system python in build directory so that it will
-+    dnl   read generated file.
-+    dnl As result from sysconfig.get_config_vars we will get our
-+    dnl setting (for the host system) like SO, CFLAGS, CPPFLAGS,
-+    dnl LDFLAGS instead those for the build system.
-+    rm -f syspython
-+    ${LN_S} ${SYSPYTHON} syspython
-+    SYSPYTHON=./syspython
-+  esac
-+fi
-+
- AC_SUBST(VERSION)
- VERSION=PYTHON_VERSION
- 
-@@ -275,8 +316,35 @@
- ##                           [Use (OpenStep|Rhapsody) dynamic linker]))
- ##
- # Set name for machine-dependent library files
-+dnl Now configure script support cross-compilation and detection of host
-+dnl system based on value of $ac_sys_system and/or $ac_sys_release
-+dnl has to be avoided. It is superseded by "host triplet"(cpu-verdor-os).
-+dnl FIXME: replace all cases based on $ac_sys_system and/or $ac_sys_release
-+dnl with case based on $host ("host triplet") or $host_os.
-+dnl Also cases with MACHDEP may be replaces by $host or $host_os. Note
-+dnl script may not set this variable if cross compiling.
-+
-+dnl Next two variables are intended to be passed through makefile to other
-+dnl scripts. As example setup.py check for CPU(machine) and OS(platform).
-+HOST_CPU=$host_cpu
-+AC_SUBST(HOST_CPU)
-+HOST_OS=$host_os
-+AC_SUBST(HOST_OS)
-+
- AC_SUBST(MACHDEP)
-+if test "x$cross_compiling" = xyes; then
-+AC_MSG_WARN([
-+  May be value of MACHDEP isn't correct if cross-compiling.
-+  You may tweak configure script for you host system: $host])
-+fi
- AC_MSG_CHECKING(MACHDEP)
-+dnl Note that $host_os cann't be translated directly into python
-+dnl specific $MACHDEP. As example on linux (kernel 2.x) the script below
-+dnl will set MACHDEP to "linux2" but $host_os is only "linux".
-+dnl Another point is in cross-compilation environment we cannot distinguish
-+dnl linux with 1.x(if someone still use it) and 2.x host kernels.
-+dnl As example setup.py check for linux2(get from sys.platform) and will
-+dnl install some host plaform specific files into subdirectory "plat-linux2".
- if test -z "$MACHDEP"
- then
- 	ac_sys_system=`uname -s`
-@@ -292,12 +360,19 @@
- 			   tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
- 	MACHDEP="$ac_md_system$ac_md_release"
- 
-+	dnl override MACHDEP only on certain host systems
-+	case $host in
-+	*-*-cygwin*) MACHDEP="cygwin";;
-+	*-*-darwin*) MACHDEP="darwin";;
-+	*-*-atheos*) MACHDEP="atheos";;
-+	esac
-+
- 	case $MACHDEP in
- 	linux*) MACHDEP="linux2";;
- 	cygwin*) MACHDEP="cygwin";;
- 	darwin*) MACHDEP="darwin";;
- 	atheos*) MACHDEP="atheos";;
--        irix646) MACHDEP="irix6";;
-+	irix646) MACHDEP="irix6";;
- 	'')	MACHDEP="unknown";;
- 	esac
- fi
-@@ -446,10 +521,6 @@
- CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
- EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
- 
--AC_MSG_CHECKING(machine type as reported by uname -m)
--ac_sys_machine=`uname -m`
--AC_MSG_RESULT($ac_sys_machine)
--
- # checks for alternative programs
- 
- # compiler flags are generated in two sets, BASECFLAGS and OPT.  OPT is just
-@@ -575,6 +646,13 @@
- AC_USE_SYSTEM_EXTENSIONS
- 
- # Check for unsupported systems
-+case $host in
-+  *-*-beos*)
-+    AC_MSG_WARN([
-+  Support for BeOS is deprecated as of Python 2.6.
-+  See PEP 11 for the gory details.
-+  ]);;
-+esac
- case $ac_sys_system/$ac_sys_release in
- atheos*|Linux*/1*)
-    echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
-@@ -728,22 +806,23 @@
- 
- AC_MSG_CHECKING(for --enable-profiling)
- AC_ARG_ENABLE(profiling,
--              AS_HELP_STRING([--enable-profiling], [enable C-level code profiling]),
--[ac_save_cc="$CC"
-- CC="$CC -pg"
-- AC_RUN_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
--   [ac_enable_profiling="yes"],
--   [ac_enable_profiling="no"],
--   [ac_enable_profiling="no"])
-- CC="$ac_save_cc"])
--AC_MSG_RESULT($ac_enable_profiling)
--
--case "$ac_enable_profiling" in
--    "yes")
--	BASECFLAGS="-pg $BASECFLAGS"
--	LDFLAGS="-pg $LDFLAGS"
--    ;;
--esac
-+              AS_HELP_STRING([--enable-profiling], [enable C-level code profiling]))
-+if test "x$enable_profiling" = xyes; then
-+  py_save_CFLAGS="$CFLAGS"
-+  CFLAGS="$CFLAGS -pg"
-+  AC_COMPILE_IFELSE([AC_LANG_SOURCE([[]])],
-+    [],
-+    [enable_profiling=no])
-+  CFLAGS="$py_save_CFLAGS"
-+else
-+  enable_profiling=no
-+fi
-+AC_MSG_RESULT($enable_profiling)
-+
-+if test "x$enable_profiling" = xyes; then
-+  BASECFLAGS="-pg $BASECFLAGS"
-+  LDFLAGS="-pg $LDFLAGS"
-+fi
- 
- AC_MSG_CHECKING(LDLIBRARY)
- 
-@@ -835,8 +914,7 @@
- AC_MSG_RESULT($LDLIBRARY)
- 
- AC_PROG_RANLIB
--AC_SUBST(AR)
--AC_CHECK_PROGS(AR, ar aal, ar)
-+AC_CHECK_TOOLS(AR, ar aal, ar)
- 
- # tweak ARFLAGS only if the user didn't set it on the command line
- AC_SUBST(ARFLAGS)
-@@ -995,7 +1073,7 @@
-     # if using gcc on alpha, use -mieee to get (near) full IEEE 754
-     # support.  Without this, treatment of subnormals doesn't follow
-     # the standard.
--    case $ac_sys_machine in
-+    case $host in
-          alpha*)
-                 BASECFLAGS="$BASECFLAGS -mieee"
-                 ;;
-@@ -2717,7 +2795,11 @@
- else
- 	MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
- fi
--AC_MSG_RESULT(MACHDEP_OBJS)
-+if test -z "$MACHDEP_OBJS"; then
-+  AC_MSG_RESULT([none])
-+else
-+  AC_MSG_RESULT([$MACHDEP_OBJS])
-+fi
- 
- # checks for library functions
- AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
-@@ -3139,7 +3221,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 "$ac_cv_buggy_getaddrinfo" = yes
- then
- 	if test $ipv6 = yes
- 	then
-@@ -3648,6 +3730,7 @@
- fi
- 
- # Multiprocessing check for broken sem_getvalue
-+if test $ac_cv_func_sem_getvalue = yes; then
- AC_MSG_CHECKING(for broken sem_getvalue)
- AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
- AC_RUN_IFELSE([AC_LANG_SOURCE([[
-@@ -3682,6 +3765,7 @@
-   AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
-   [define to 1 if your sem_getvalue is broken.])
- fi
-+fi
- 
- # determine what size digit to use for Python's longs
- AC_MSG_CHECKING([digit size for Python's longs])
-@@ -3865,7 +3949,7 @@
- # with setup.py.
- py_cv_lib_readline=no
- AC_MSG_CHECKING([how to link readline libs])
--for py_libtermcap in "" ncursesw ncurses curses termcap; do
-+for py_libtermcap in "" tinfo ncursesw ncurses curses termcap; do
-   if test -z "$py_libtermcap"; then
-     READLINE_LIBS="-lreadline"
-   else
-@@ -3878,9 +3962,9 @@
-   if test $py_cv_lib_readline = yes; then
-     break
-   fi
-+  READLINE_LIBS=
- done
--# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
--#AC_SUBST([READLINE_LIBS])
-+AC_SUBST([READLINE_LIBS])
- if test $py_cv_lib_readline = no; then
-   AC_MSG_RESULT([none])
- else
-@@ -4163,26 +4247,34 @@
-   [AC_MSG_RESULT(no)]
- )
- 
--AC_MSG_CHECKING(for /dev/ptmx)
-+AC_MSG_NOTICE([checking for device files])
- 
--if test -r /dev/ptmx
--then
--  AC_MSG_RESULT(yes)
--  AC_DEFINE(HAVE_DEV_PTMX, 1,
--  [Define if we have /dev/ptmx.])
--else
--  AC_MSG_RESULT(no)
-+dnl NOTE: Inform user how to proceed with files when cross compiling.
-+if test "x$cross_compiling" = xyes; then
-+  if test "${ac_cv_file__dev_ptmx+set}" != set; then
-+    AC_MSG_CHECKING([for /dev/ptmx])
-+    AC_MSG_RESULT([not set])
-+    AC_MSG_ERROR([set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling])
-+  fi
-+  if test "${ac_cv_file__dev_ptc+set}" != set; then
-+    AC_MSG_CHECKING([for /dev/ptc])
-+    AC_MSG_RESULT([not set])
-+    AC_MSG_ERROR([set ac_cv_file__dev_ptc to yes/no in your CONFIG_SITE file when cross compiling])
-+  fi
- fi
- 
--AC_MSG_CHECKING(for /dev/ptc)
--
--if test -r /dev/ptc
--then
--  AC_MSG_RESULT(yes)
-+# FIXME: autoconf macro AC_CHECK_FILES is better but require additional
-+# changes in posixmodule.c : 's/HAVE_DEV_/HAVE__DEV_/g'
-+# To keep patch minimal I left defines as before.
-+AC_CHECK_FILE(/dev/ptmx, [], [])
-+if test "x$ac_cv_file__dev_ptmx" = xyes; then
-+  AC_DEFINE(HAVE_DEV_PTMX, 1,
-+  [Define to 1 if you have the /dev/ptmx device file.])
-+fi
-+AC_CHECK_FILE(/dev/ptc, [], [])
-+if test "x$ac_cv_file__dev_ptc" = xyes; then
-   AC_DEFINE(HAVE_DEV_PTC, 1,
--  [Define if we have /dev/ptc.])
--else
--  AC_MSG_RESULT(no)
-+  [Define to 1 if you have the /dev/ptc device file.])
- fi
- 
- if test "$have_long_long" = yes
-@@ -4320,36 +4412,28 @@
- AC_MSG_RESULT(done)
- 
- # generate output files
--AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
--AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
--AC_OUTPUT
-+AC_CONFIG_COMMANDS_PRE([
-+AC_MSG_NOTICE([creating Modules/Setup])
- 
--echo "creating Modules/Setup"
- if test ! -f Modules/Setup
- then
- 	cp $srcdir/Modules/Setup.dist Modules/Setup
- fi
- 
--echo "creating Modules/Setup.local"
-+AC_MSG_NOTICE([creating Modules/Setup.local])
- if test ! -f Modules/Setup.local
- then
- 	echo "# Edit this file for local setup changes" >Modules/Setup.local
--fi
-+fi])
- 
--echo "creating Makefile"
--$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
-+AC_CONFIG_COMMANDS([Makefile],
-+[$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
- 			-s Modules Modules/Setup.config \
- 			Modules/Setup.local Modules/Setup
- 
--case $ac_sys_system in
--BeOS)
--        AC_MSG_WARN([
--
--  Support for BeOS is deprecated as of Python 2.6.
--  See PEP 11 for the gory details.
--  ])
--  ;;
--*) ;;
--esac
- 
--mv config.c Modules
-+mv config.c Modules])
-+AC_CONFIG_FILES([setup_info])
-+AC_CONFIG_FILES([Makefile.pre Modules/Setup.config Misc/python.pc])
-+AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
-+AC_OUTPUT
-diff -urN a/Lib/distutils/README b/Lib/distutils/README
---- a/Lib/distutils/README	2012-04-10 00:07:29.000000000 +0100
-+++ b/Lib/distutils/README	2012-06-25 19:39:10.611815002 +0100
-@@ -9,5 +9,10 @@
-     http://www.python.org/sigs/distutils-sig/
- 
- WARNING : Distutils must remain compatible with 2.3
-+NOTE: After "Revision 77704 : taking sysconfig out of distutils"
-+Distutils package is not compatible with versions before 2.7a3.
-+Although "Revision 77759 : reintroduced the names in Distutils for APIs
-+that were relocated"(i.e. API is backward compatibile) to cross compile
-+python on build system has to be at least version 2.7a3.
- 
- $Id$
-diff -urN a/Lib/sysconfig.py b/Lib/sysconfig.py
---- a/Lib/sysconfig.py	2012-04-10 00:07:31.000000000 +0100
-+++ b/Lib/sysconfig.py	2012-06-25 19:39:10.611815002 +0100
-@@ -3,7 +3,15 @@
- """
- import sys
- import os
--from os.path import pardir, realpath
-+# revert patch from issue 7880 :
-+#  - the test case (from issue 7880) works for me
-+#  - realpath break cross compilation
-+# => so lets use abspath again ;)
-+# NOTE "Issue #6612: Fix site and sysconfig to catch os.getcwd() error,
-+# eg. if the current directory was deleted." replase all occurrence of
-+# realpath with _safe_realpath. Instead to update _safe_realpath to use
-+# abspath the cross-compilation revert all!
-+from os.path import pardir, abspath
- 
- _INSTALL_SCHEMES = {
-     'posix_prefix': {
-@@ -94,27 +102,21 @@
- _CONFIG_VARS = None
- _USER_BASE = None
- 
--def _safe_realpath(path):
--    try:
--        return realpath(path)
--    except OSError:
--        return path
--
- if sys.executable:
--    _PROJECT_BASE = os.path.dirname(_safe_realpath(sys.executable))
-+    _PROJECT_BASE = os.path.dirname(abspath(sys.executable))
- else:
-     # sys.executable can be empty if argv[0] has been changed and Python is
-     # unable to retrieve the real program name
--    _PROJECT_BASE = _safe_realpath(os.getcwd())
-+    _PROJECT_BASE = abspath(os.getcwd())
- 
- if os.name == "nt" and "pcbuild" in _PROJECT_BASE[-8:].lower():
--    _PROJECT_BASE = _safe_realpath(os.path.join(_PROJECT_BASE, pardir))
-+    _PROJECT_BASE = abspath(os.path.join(_PROJECT_BASE, pardir))
- # PC/VS7.1
- if os.name == "nt" and "\\pc\\v" in _PROJECT_BASE[-10:].lower():
--    _PROJECT_BASE = _safe_realpath(os.path.join(_PROJECT_BASE, pardir, pardir))
-+    _PROJECT_BASE = abspath(os.path.join(_PROJECT_BASE, pardir, pardir))
- # PC/AMD64
- if os.name == "nt" and "\\pcbuild\\amd64" in _PROJECT_BASE[-14:].lower():
--    _PROJECT_BASE = _safe_realpath(os.path.join(_PROJECT_BASE, pardir, pardir))
-+    _PROJECT_BASE = abspath(os.path.join(_PROJECT_BASE, pardir, pardir))
- 
- def is_python_build():
-     for fn in ("Setup.dist", "Setup.local"):
-@@ -313,7 +315,7 @@
-     vars['SO'] = '.pyd'
-     vars['EXE'] = '.exe'
-     vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT
--    vars['BINDIR'] = os.path.dirname(_safe_realpath(sys.executable))
-+    vars['BINDIR'] = os.path.dirname(abspath(sys.executable))
- 
- #
- # public APIs
-diff -urN a/Makefile.pre.in b/Makefile.pre.in
---- a/Makefile.pre.in	2012-04-10 00:07:33.000000000 +0100
-+++ b/Makefile.pre.in	2012-06-25 19:39:10.612814691 +0100
-@@ -187,6 +187,10 @@
- PROFILE_TASK=	$(srcdir)/Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck
- #PROFILE_TASK=	$(srcdir)/Lib/test/regrtest.py
- 
-+# Don't define HOST_OS as makefile macro !
-+@CROSS_ON@RUNPYTHON=	HOST_OS=@HOST_OS@ @SYSPYTHON@
-+@CROSS_OFF@RUNPYTHON=	$(RUNSHARED) ./$(BUILDPYTHON)
-+
- # === Definitions added by makesetup ===
- 
- 
-@@ -402,14 +406,14 @@
- 			$(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
- 
- platform: $(BUILDPYTHON)
--	$(RUNSHARED) ./$(BUILDPYTHON) -E -c 'import sys ; from sysconfig import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform
-+	$(RUNPYTHON) -E -c 'import sys ; from sysconfig import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform
- 
- 
- # Build the shared modules
- sharedmods: $(BUILDPYTHON)
- 	@case $$MAKEFLAGS in \
--	*s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \
--	*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \
-+	*s*) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' $(RUNPYTHON) -E $(srcdir)/setup.py -q build;; \
-+	*) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' $(RUNPYTHON) -E $(srcdir)/setup.py build;; \
- 	esac
- 
- # Build static library
-@@ -426,10 +430,10 @@
- 
- libpython$(VERSION).so: $(LIBRARY_OBJS)
- 	if test $(INSTSONAME) != $(LDLIBRARY); then \
--		$(BLDSHARED) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
-+		$(LDSHARED) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
- 		$(LN) -f $(INSTSONAME) $@; \
- 	else \
--		$(BLDSHARED) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
-+		$(LDSHARED) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
- 	fi
- 
- libpython$(VERSION).dylib: $(LIBRARY_OBJS)
-@@ -485,18 +489,17 @@
- oldsharedmods: $(SHAREDMODS)
- 
- 
-+setup_info: setup_info.in config.status
-+	$(SHELL) ./config.status $@
-+
-+
- Makefile Modules/config.c: Makefile.pre \
- 				$(srcdir)/Modules/config.c.in \
- 				$(MAKESETUP) \
- 				Modules/Setup.config \
- 				Modules/Setup \
- 				Modules/Setup.local
--	$(SHELL) $(MAKESETUP) -c $(srcdir)/Modules/config.c.in \
--				-s Modules \
--				Modules/Setup.config \
--				Modules/Setup.local \
--				Modules/Setup
--	@mv config.c Modules
-+	$(SHELL) ./config.status Makefile
- 	@echo "The Makefile was updated, you may need to re-run make."
- 
- 
-@@ -539,6 +542,7 @@
- 	$(MAINCC) -c $(PY_CFLAGS) -o $@ $(srcdir)/Modules/python.c
- 
- 
-+# FIXME: next may fail in cross-compilation environment
- # Use a stamp file to prevent make -j invoking pgen twice
- $(GRAMMAR_H) $(GRAMMAR_C): Parser/pgen.stamp
- Parser/pgen.stamp: $(PGEN) $(GRAMMAR_INPUT)
-@@ -708,6 +712,7 @@
- 
- TESTOPTS=	-l $(EXTRATESTOPTS)
- TESTPROG=	$(srcdir)/Lib/test/regrtest.py
-+# FIXME: next test may fail in cross-compilation environment
- TESTPYTHON=	$(RUNSHARED) ./$(BUILDPYTHON) -Wd -3 -E -tt $(TESTPYTHONOPTS)
- test:		all platform
- 		-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
-@@ -938,26 +943,26 @@
- 		$(INSTALL_DATA) $(srcdir)/Modules/xxmodule.c \
- 			$(DESTDIR)$(LIBDEST)/distutils/tests ; \
- 	fi
--	PYTHONPATH=$(DESTDIR)$(LIBDEST)  $(RUNSHARED) \
--		./$(BUILDPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
-+	PYTHONPATH=$(DESTDIR)$(LIBDEST) \
-+		$(RUNPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
- 		-d $(LIBDEST) -f \
- 		-x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
- 		$(DESTDIR)$(LIBDEST)
--	PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
--		./$(BUILDPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
-+	PYTHONPATH=$(DESTDIR)$(LIBDEST) \
-+		$(RUNPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
- 		-d $(LIBDEST) -f \
- 		-x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
- 		$(DESTDIR)$(LIBDEST)
--	-PYTHONPATH=$(DESTDIR)$(LIBDEST)  $(RUNSHARED) \
--		./$(BUILDPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
-+	-PYTHONPATH=$(DESTDIR)$(LIBDEST) \
-+		$(RUNPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
- 		-d $(LIBDEST)/site-packages -f \
- 		-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
--	-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
--		./$(BUILDPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
-+	-PYTHONPATH=$(DESTDIR)$(LIBDEST) \
-+		$(RUNPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
- 		-d $(LIBDEST)/site-packages -f \
- 		-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
--	-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
--		./$(BUILDPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"
-+	-PYTHONPATH=$(DESTDIR)$(LIBDEST) \
-+		$(RUNPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"
- 
- # Create the PLATDIR source directory, if one wasn't distributed..
- $(srcdir)/Lib/$(PLATDIR):
-@@ -1062,7 +1067,7 @@
- # Install the dynamically loadable modules
- # This goes into $(exec_prefix)
- sharedinstall: sharedmods
--	$(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \
-+	$(RUNPYTHON) -E $(srcdir)/setup.py install \
- 	   	--prefix=$(prefix) \
- 		--install-scripts=$(BINDIR) \
- 		--install-platlib=$(DESTSHARED) \
-@@ -1100,7 +1105,7 @@
- 		fi; \
- 	done
- 	$(LN) -fsn include/python$(VERSION) $(DESTDIR)$(prefix)/Headers
--	sed 's/%VERSION%/'"`$(RUNSHARED) ./$(BUILDPYTHON) -c 'import platform; print platform.python_version()'`"'/g' < $(RESSRCDIR)/Info.plist > $(DESTDIR)$(prefix)/Resources/Info.plist
-+	sed 's/%VERSION%/'"`$(RUNPYTHON) -c 'import platform; print platform.python_version()'`"'/g' < $(RESSRCDIR)/Info.plist > $(DESTDIR)$(prefix)/Resources/Info.plist
- 	$(LN) -fsn $(VERSION) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/Current
- 	$(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/$(PYTHONFRAMEWORK)
- 	$(LN) -fsn Versions/Current/Headers $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Headers
-@@ -1134,20 +1139,19 @@
- 
- # This installs a few of the useful scripts in Tools/scripts
- scriptsinstall:
--	SRCDIR=$(srcdir) $(RUNSHARED) \
--	./$(BUILDPYTHON) $(srcdir)/Tools/scripts/setup.py install \
-+	SRCDIR=$(srcdir) \
-+	$(RUNPYTHON) $(srcdir)/Tools/scripts/setup.py install \
- 	--prefix=$(prefix) \
- 	--install-scripts=$(BINDIR) \
- 	--root=$(DESTDIR)/
- 
- # Build the toplevel Makefile
- Makefile.pre: Makefile.pre.in config.status
--	CONFIG_FILES=Makefile.pre CONFIG_HEADERS= $(SHELL) config.status
--	$(MAKE) -f Makefile.pre Makefile
-+	$(SHELL) ./config.status $@
- 
- # Run the configure script.
- config.status:	$(srcdir)/configure
--	$(SHELL) $(srcdir)/configure $(CONFIG_ARGS)
-+	$(SHELL) ./config.status --recheck
- 
- .PRECIOUS: config.status $(BUILDPYTHON) Makefile Makefile.pre
- 
-@@ -1162,8 +1166,8 @@
- # Rerun configure with the same options as it was run last time,
- # provided the config.status script exists
- recheck:
--	$(SHELL) config.status --recheck
--	$(SHELL) config.status
-+	$(SHELL) ./config.status --recheck
-+	$(SHELL) ./config.status
- 
- # Rebuild the configure script from configure.in; also rebuild pyconfig.h.in
- autoconf:
-@@ -1260,7 +1264,7 @@
- 
- # Perform some verification checks on any modified files.
- patchcheck:
--	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/patchcheck.py
-+	$(RUNPYTHON) $(srcdir)/Tools/scripts/patchcheck.py
- 
- # Dependencies
- 
-diff -urN a/pyconfig.h.in b/pyconfig.h.in
---- a/pyconfig.h.in	2012-04-10 00:07:36.000000000 +0100
-+++ b/pyconfig.h.in	2012-06-25 19:39:10.612814691 +0100
-@@ -161,10 +161,10 @@
- /* Define to 1 if you have the device macros. */
- #undef HAVE_DEVICE_MACROS
- 
--/* Define if we have /dev/ptc. */
-+/* Define to 1 if you have the /dev/ptc device file. */
- #undef HAVE_DEV_PTC
- 
--/* Define if we have /dev/ptmx. */
-+/* Define to 1 if you have the /dev/ptmx device file. */
- #undef HAVE_DEV_PTMX
- 
- /* Define to 1 if you have the <direct.h> header file. */
-diff -urN a/setup_info.in b/setup_info.in
---- a/setup_info.in	1970-01-01 01:00:00.000000000 +0100
-+++ b/setup_info.in	2012-06-25 19:39:10.612814691 +0100
-@@ -0,0 +1,3 @@
-+# file with data from configure file
-+
-+READLINE_LIBS=@READLINE_LIBS@
-diff -urN a/setup.py b/setup.py
---- a/setup.py	2012-04-10 00:07:36.000000000 +0100
-+++ b/setup.py	2012-06-25 19:42:29.000000000 +0100
-@@ -17,6 +17,22 @@
- from distutils.command.install_lib import install_lib
- from distutils.spawn import find_executable
- 
-+
-+def _get_platform():
-+    # Get value of host platform (set only if cross-compile)
-+    # otherwise value of sys.platform
-+    host_platform = os.environ.get('HOST_OS')
-+    if host_platform is None:
-+        host_platform = sys.platform
-+    for platform in ['cygwin', 'beos', 'darwin', 'atheos', 'osf1']:
-+        if host_platform.startswith(platform):
-+            return platform
-+    return host_platform
-+
-+host_platform = _get_platform()
-+cross_compiling = (not os.environ.get('HOST_OS') is None)
-+
-+
- # Were we compiled --with-pydebug or with #define Py_DEBUG?
- COMPILED_WITH_PYDEBUG = hasattr(sys, 'gettotalrefcount')
- 
-@@ -60,7 +76,7 @@
-     'paths' is a list of additional locations to check; if the file is
-         found in one of them, the resulting list will contain the directory.
-     """
--    if sys.platform == 'darwin':
-+    if host_platform == 'darwin':
-         # Honor the MacOSX SDK setting when one was specified.
-         # An SDK is a directory with the same structure as a real
-         # system, but with only header files and libraries.
-@@ -70,7 +86,7 @@
-     for dir in std_dirs:
-         f = os.path.join(dir, filename)
- 
--        if sys.platform == 'darwin' and is_macosx_sdk_path(dir):
-+        if host_platform == 'darwin' and is_macosx_sdk_path(dir):
-             f = os.path.join(sysroot, dir[1:], filename)
- 
-         if os.path.exists(f): return []
-@@ -79,7 +95,7 @@
-     for dir in paths:
-         f = os.path.join(dir, filename)
- 
--        if sys.platform == 'darwin' and is_macosx_sdk_path(dir):
-+        if host_platform == 'darwin' and is_macosx_sdk_path(dir):
-             f = os.path.join(sysroot, dir[1:], filename)
- 
-         if os.path.exists(f):
-@@ -93,7 +109,7 @@
-     if result is None:
-         return None
- 
--    if sys.platform == 'darwin':
-+    if host_platform == 'darwin':
-         sysroot = macosx_sdk_root()
- 
-     # Check whether the found file is in one of the standard directories
-@@ -102,7 +118,7 @@
-         # Ensure path doesn't end with path separator
-         p = p.rstrip(os.sep)
- 
--        if sys.platform == 'darwin' and is_macosx_sdk_path(p):
-+        if host_platform == 'darwin' and is_macosx_sdk_path(p):
-             if os.path.join(sysroot, p[1:]) == dirname:
-                 return [ ]
- 
-@@ -115,7 +131,7 @@
-         # Ensure path doesn't end with path separator
-         p = p.rstrip(os.sep)
- 
--        if sys.platform == 'darwin' and is_macosx_sdk_path(p):
-+        if host_platform == 'darwin' and is_macosx_sdk_path(p):
-             if os.path.join(sysroot, p[1:]) == dirname:
-                 return [ p ]
- 
-@@ -172,8 +188,7 @@
- 
-         # Platform-dependent module source and include directories
-         incdirlist = []
--        platform = self.get_platform()
--        if platform == 'darwin' and ("--disable-toolbox-glue" not in
-+        if host_platform == 'darwin' and ("--disable-toolbox-glue" not in
-             sysconfig.get_config_var("CONFIG_ARGS")):
-             # Mac OS X also includes some mac-specific modules
-             macmoddir = os.path.join(srcdir, 'Mac/Modules')
-@@ -286,7 +301,7 @@
-                 ext.name)
-             return
- 
--        if self.get_platform() == 'darwin' and (
-+        if host_platform == 'darwin' and (
-                 sys.maxint > 2**32 and '-arch' in ext.extra_link_args):
-             # Don't bother doing an import check when an extension was
-             # build with an explicit '-arch' flag on OSX. That's currently
-@@ -300,10 +315,14 @@
- 
-         # Workaround for Cygwin: Cygwin currently has fork issues when many
-         # modules have been imported
--        if self.get_platform() == 'cygwin':
-+        if host_platform == 'cygwin':
-             self.announce('WARNING: skipping import check for Cygwin-based "%s"'
-                 % ext.name)
-             return
-+        if cross_compiling:
-+            self.announce('WARNING: skipping import check for cross-compiled "%s"'
-+                % ext.name)
-+            return
-         ext_filename = os.path.join(
-             self.build_lib,
-             self.get_ext_filename(self.get_ext_fullname(ext.name)))
-@@ -338,13 +357,6 @@
-                           level=3)
-             self.failed.append(ext.name)
- 
--    def get_platform(self):
--        # Get value of sys.platform
--        for platform in ['cygwin', 'beos', 'darwin', 'atheos', 'osf1']:
--            if sys.platform.startswith(platform):
--                return platform
--        return sys.platform
--
-     def add_multiarch_paths(self):
-         # Debian/Ubuntu multiarch support.
-         # https://wiki.ubuntu.com/MultiarchSpec
-@@ -368,9 +380,13 @@
-             os.unlink(tmpfile)
- 
-     def detect_modules(self):
--        # Ensure that /usr/local is always used
--        add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
--        add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
-+        pyconfig_h_data = open('pyconfig.h').read()
-+        setup_info_data = open('setup_info').read()
-+
-+        if not cross_compiling:
-+            # Ensure that /usr/local is always used
-+            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()
- 
-         # Add paths specified in the environment variables LDFLAGS and
-@@ -379,6 +395,9 @@
-         # directly since an inconsistently reproducible issue comes up where
-         # the environment variable is not set even though the value were passed
-         # into configure and stored in the Makefile (issue found on OS X 10.3).
-+        # NOTE: In cross-compilation environment python for build system
-+        # is linked in top build directory under name syspython to get
-+        # above to work (distutils hack).
-         for env_var, arg_name, dir_list in (
-                 ('LDFLAGS', '-R', self.compiler.runtime_library_dirs),
-                 ('LDFLAGS', '-L', self.compiler.library_dirs),
-@@ -423,35 +442,37 @@
-         except NameError:
-             have_unicode = 0
- 
--        # lib_dirs and inc_dirs are used to search for files;
--        # if a file is found in one of those directories, it can
--        # be assumed that no additional -I,-L directives are needed.
--        lib_dirs = self.compiler.library_dirs + [
--            '/lib64', '/usr/lib64',
--            '/lib', '/usr/lib',
--            ]
--        inc_dirs = self.compiler.include_dirs + ['/usr/include']
-+        lib_dirs = self.compiler.library_dirs
-+        inc_dirs = self.compiler.include_dirs
-+        if not cross_compiling:
-+            # lib_dirs and inc_dirs are used to search for files;
-+            # if a file is found in one of those directories, it can
-+            # be assumed that no additional -I,-L directives are needed.
-+            lib_dirs += [
-+                '/lib64', '/usr/lib64',
-+                '/lib', '/usr/lib',
-+                ]
-+            inc_dirs += ['/usr/include']
-         exts = []
-         missing = []
- 
-         config_h = sysconfig.get_config_h_filename()
-         config_h_vars = sysconfig.parse_config_h(open(config_h))
- 
--        platform = self.get_platform()
-         srcdir = sysconfig.get_config_var('srcdir')
- 
-         # Check for AtheOS which has libraries in non-standard locations
--        if platform == 'atheos':
-+        if host_platform == 'atheos':
-             lib_dirs += ['/system/libs', '/atheos/autolnk/lib']
-             lib_dirs += os.getenv('LIBRARY_PATH', '').split(os.pathsep)
-             inc_dirs += ['/system/include', '/atheos/autolnk/include']
-             inc_dirs += os.getenv('C_INCLUDE_PATH', '').split(os.pathsep)
- 
-         # OSF/1 and Unixware have some stuff in /usr/ccs/lib (like -ldb)
--        if platform in ['osf1', 'unixware7', 'openunix8']:
-+        if host_platform in ['osf1', 'unixware7', 'openunix8']:
-             lib_dirs += ['/usr/ccs/lib']
- 
--        if platform == 'darwin':
-+        if host_platform == 'darwin':
-             # This should work on any unixy platform ;-)
-             # If the user has bothered specifying additional -I and -L flags
-             # in OPT and LDFLAGS we might as well use them here.
-@@ -470,7 +491,7 @@
- 
-         # Check for MacOS X, which doesn't need libm.a at all
-         math_libs = ['m']
--        if platform in ['darwin', 'beos']:
-+        if host_platform in ['darwin', 'beos']:
-             math_libs = []
- 
-         # XXX Omitted modules: gl, pure, dl, SGI-specific modules
-@@ -536,13 +557,12 @@
-         else:
-             missing.append('unicodedata')
-         # access to ISO C locale support
--        data = open('pyconfig.h').read()
--        m = re.search(r"#s*define\s+WITH_LIBINTL\s+1\s*", data)
-+        m = re.search(r"#s*define\s+WITH_LIBINTL\s+1\s*", pyconfig_h_data)
-         if m is not None:
-             locale_libs = ['intl']
-         else:
-             locale_libs = []
--        if platform == 'darwin':
-+        if host_platform == 'darwin':
-             locale_extra_link_args = ['-framework', 'CoreFoundation']
-         else:
-             locale_extra_link_args = []
-@@ -584,7 +604,7 @@
-         exts.append( Extension('cPickle', ['cPickle.c']) )
- 
-         # Memory-mapped files (also works on Win32).
--        if platform not in ['atheos']:
-+        if host_platform not in ['atheos']:
-             exts.append( Extension('mmap', ['mmapmodule.c']) )
-         else:
-             missing.append('mmap')
-@@ -620,12 +640,32 @@
-             missing.extend(['imageop'])
- 
-         # readline
--        do_readline = self.compiler.find_library_file(lib_dirs, 'readline')
-+        do_readline = re.search(r"#s*define\s+HAVE_LIBREADLINE\s+1\s*", pyconfig_h_data)
-+
-         readline_termcap_library = ""
-         curses_library = ""
-+
-         # Determine if readline is already linked against curses or tinfo.
--        if do_readline and find_executable('ldd'):
--            fp = os.popen("ldd %s" % do_readline)
-+        # NOTE readline_termcap_library is flag used only if cannot determine readline libs
-+        readline_conf = False
-+        readline_conf_termcap = ""
-+        if do_readline:
-+            m = re.search(r"\s*READLINE_LIBS\s*=\s*(?P<rl>-l.*)", setup_info_data)
-+            if m:
-+                readline_conf = True
-+                ln = m.group('rl')
-+                if 'curses' in ln:
-+                    readline_conf_termcap = re.sub(
-+                        r'.*-l(n?cursesw?).*', r'\1', ln
-+                    ).rstrip()
-+                elif 'tinfo' in ln: # termcap interface split out from ncurses
-+                    readline_conf_termcap = 'tinfo'
-+                else: # may be readline is linked with termcap interface library
-+                    readline_conf = False
-+
-+        if do_readline and not readline_conf and find_executable('ldd'):
-+            rl_lib = self.compiler.find_library_file(lib_dirs, 'readline')
-+            fp = os.popen("ldd %s" % rl_lib)
-             ldd_output = fp.readlines()
-             ret = fp.close()
-             if ret is None or ret >> 8 == 0:
-@@ -640,7 +680,9 @@
-                         break
-         # Issue 7384: If readline is already linked against curses,
-         # use the same library for the readline and curses modules.
--        if 'curses' in readline_termcap_library:
-+        if 'curses' in readline_conf_termcap:
-+            curses_library = readline_conf_termcap
-+        elif 'curses' in readline_termcap_library:
-             curses_library = readline_termcap_library
-         elif self.compiler.find_library_file(lib_dirs, 'ncursesw'):
-             curses_library = 'ncursesw'
-@@ -649,7 +691,7 @@
-         elif self.compiler.find_library_file(lib_dirs, 'curses'):
-             curses_library = 'curses'
- 
--        if platform == 'darwin':
-+        if host_platform == 'darwin':
-             os_release = int(os.uname()[2].split('.')[0])
-             dep_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
-             if dep_target and dep_target.split('.') < ['10', '5']:
-@@ -661,7 +703,7 @@
-                 if find_file('readline/rlconf.h', inc_dirs, []) is None:
-                     do_readline = False
-         if do_readline:
--            if platform == 'darwin' and os_release < 9:
-+            if host_platform == 'darwin' and os_release < 9:
-                 # In every directory on the search path search for a dynamic
-                 # library and then a static library, instead of first looking
-                 # for dynamic libraries on the entiry path.
-@@ -739,7 +781,7 @@
-                 inc_dirs + search_for_ssl_incs_in)
-         if opensslv_h:
-             name = os.path.join(opensslv_h[0], 'openssl/opensslv.h')
--            if sys.platform == 'darwin' and is_macosx_sdk_path(name):
-+            if host_platform == 'darwin' and is_macosx_sdk_path(name):
-                 name = os.path.join(macosx_sdk_root(), name[1:])
-             try:
-                 incfile = open(name, 'r')
-@@ -883,7 +925,7 @@
- 
-         db_ver_inc_map = {}
- 
--        if sys.platform == 'darwin':
-+        if host_platform == 'darwin':
-             sysroot = macosx_sdk_root()
- 
-         class db_found(Exception): pass
-@@ -893,7 +935,7 @@
-             for d in inc_dirs + db_inc_paths:
-                 f = os.path.join(d, "db.h")
- 
--                if sys.platform == 'darwin' and is_macosx_sdk_path(d):
-+                if host_platform == 'darwin' and is_macosx_sdk_path(d):
-                     f = os.path.join(sysroot, d[1:], "db.h")
- 
-                 if db_setup_debug: print "db: looking for db.h in", f
-@@ -943,7 +985,7 @@
-                     db_incdir.replace("include", 'lib'),
-                 ]
- 
--                if sys.platform != 'darwin':
-+                if host_platform != 'darwin':
-                     db_dirs_to_check = filter(os.path.isdir, db_dirs_to_check)
- 
-                 else:
-@@ -1018,13 +1060,13 @@
-         # Scan the default include directories before the SQLite specific
-         # ones. This allows one to override the copy of sqlite on OSX,
-         # where /usr/include contains an old version of sqlite.
--        if sys.platform == 'darwin':
-+        if host_platform == 'darwin':
-             sysroot = macosx_sdk_root()
- 
-         for d in inc_dirs + sqlite_inc_paths:
-             f = os.path.join(d, "sqlite3.h")
- 
--            if sys.platform == 'darwin' and is_macosx_sdk_path(d):
-+            if host_platform == 'darwin' and is_macosx_sdk_path(d):
-                 f = os.path.join(sysroot, d[1:], "sqlite3.h")
- 
-             if os.path.exists(f):
-@@ -1073,7 +1115,7 @@
-                 '_sqlite/util.c', ]
- 
-             sqlite_defines = []
--            if sys.platform != "win32":
-+            if host_platform != "win32":
-                 sqlite_defines.append(('MODULE_NAME', '"sqlite3"'))
-             else:
-                 sqlite_defines.append(('MODULE_NAME', '\\"sqlite3\\"'))
-@@ -1081,7 +1123,7 @@
-             # Comment this out if you want the sqlite3 module to be able to load extensions.
-             sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1"))
- 
--            if sys.platform == 'darwin':
-+            if host_platform == 'darwin':
-                 # In every directory on the search path search for a dynamic
-                 # library and then a static library, instead of first looking
-                 # for dynamic libraries on the entire path.
-@@ -1115,7 +1157,7 @@
-         # when attempting to compile and it will fail.
-         f = "/usr/include/db.h"
- 
--        if sys.platform == 'darwin':
-+        if host_platform == 'darwin':
-             if is_macosx_sdk_path(f):
-                 sysroot = macosx_sdk_root()
-                 f = os.path.join(sysroot, f[1:])
-@@ -1128,7 +1170,7 @@
-                 ### XXX this should be fixed to not be platform-dependent
-                 ### but I don't have direct access to an osf1 platform and
-                 ### seemed to be muffing the search somehow
--                libraries = platform == "osf1" and ['db'] or None
-+                libraries = host_platform == "osf1" and ['db'] or None
-                 if libraries is not None:
-                     exts.append(Extension('bsddb185', ['bsddbmodule.c'],
-                                           libraries=libraries))
-@@ -1141,7 +1183,7 @@
- 
-         dbm_order = ['gdbm']
-         # The standard Unix dbm module:
--        if platform not in ['cygwin']:
-+        if host_platform not in ['cygwin']:
-             config_args = [arg.strip("'")
-                            for arg in sysconfig.get_config_var("CONFIG_ARGS").split()]
-             dbm_args = [arg for arg in config_args
-@@ -1219,17 +1261,17 @@
-             missing.append('gdbm')
- 
-         # Unix-only modules
--        if platform not in ['win32']:
-+        if host_platform not in ['win32']:
-             # Steen Lumholt's termios module
-             exts.append( Extension('termios', ['termios.c']) )
-             # Jeremy Hylton's rlimit interface
--            if platform not in ['atheos']:
-+            if host_platform not in ['atheos']:
-                 exts.append( Extension('resource', ['resource.c']) )
-             else:
-                 missing.append('resource')
- 
-             # Sun yellow pages. Some systems have the functions in libc.
--            if (platform not in ['cygwin', 'atheos', 'qnx6'] and
-+            if (host_platform not in ['cygwin', 'atheos', 'qnx6'] and
-                 find_file('rpcsvc/yp_prot.h', inc_dirs, []) is not None):
-                 if (self.compiler.find_library_file(lib_dirs, 'nsl')):
-                     libs = ['nsl']
-@@ -1253,7 +1295,7 @@
-             curses_libs = [curses_library]
-             exts.append( Extension('_curses', ['_cursesmodule.c'],
-                                    libraries = curses_libs) )
--        elif curses_library == 'curses' and platform != 'darwin':
-+        elif curses_library == 'curses' and host_platform != 'darwin':
-                 # OSX has an old Berkeley curses, not good enough for
-                 # the _curses module.
-             if (self.compiler.find_library_file(lib_dirs, 'terminfo')):
-@@ -1304,7 +1346,7 @@
-                     break
-             if version >= version_req:
-                 if (self.compiler.find_library_file(lib_dirs, 'z')):
--                    if sys.platform == "darwin":
-+                    if host_platform == "darwin":
-                         zlib_extra_link_args = ('-Wl,-search_paths_first',)
-                     else:
-                         zlib_extra_link_args = ()
-@@ -1336,7 +1378,7 @@
- 
-         # Gustavo Niemeyer's bz2 module.
-         if (self.compiler.find_library_file(lib_dirs, 'bz2')):
--            if sys.platform == "darwin":
-+            if host_platform == "darwin":
-                 bz2_extra_link_args = ('-Wl,-search_paths_first',)
-             else:
-                 bz2_extra_link_args = ()
-@@ -1409,7 +1451,7 @@
-         if sys.maxint == 0x7fffffff:
-             # This requires sizeof(int) == sizeof(long) == sizeof(char*)
-             dl_inc = find_file('dlfcn.h', [], inc_dirs)
--            if (dl_inc is not None) and (platform not in ['atheos']):
-+            if (dl_inc is not None) and (host_platform not in ['atheos']):
-                 exts.append( Extension('dl', ['dlmodule.c']) )
-             else:
-                 missing.append('dl')
-@@ -1420,29 +1462,29 @@
-         self.detect_ctypes(inc_dirs, lib_dirs)
- 
-         # Richard Oudkerk's multiprocessing module
--        if platform == 'win32':             # Windows
-+        if host_platform == 'win32':
-             macros = dict()
-             libraries = ['ws2_32']
- 
--        elif platform == 'darwin':          # Mac OSX
-+        elif host_platform == 'darwin':
-             macros = dict()
-             libraries = []
- 
--        elif platform == 'cygwin':          # Cygwin
-+        elif host_platform == 'cygwin':
-             macros = dict()
-             libraries = []
- 
--        elif platform in ('freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', 'freebsd8'):
-+        elif host_platform in ('freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', 'freebsd8'):
-             # FreeBSD's P1003.1b semaphore support is very experimental
-             # and has many known problems. (as of June 2008)
-             macros = dict()
-             libraries = []
- 
--        elif platform.startswith('openbsd'):
-+        elif host_platform.startswith('openbsd'):
-             macros = dict()
-             libraries = []
- 
--        elif platform.startswith('netbsd'):
-+        elif host_platform.startswith('netbsd'):
-             macros = dict()
-             libraries = []
- 
-@@ -1450,7 +1492,7 @@
-             macros = dict()
-             libraries = ['rt']
- 
--        if platform == 'win32':
-+        if host_platform == 'win32':
-             multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c',
-                                      '_multiprocessing/semaphore.c',
-                                      '_multiprocessing/pipe_connection.c',
-@@ -1477,26 +1519,26 @@
- 
- 
-         # Platform-specific libraries
--        if platform == 'linux2':
-+        if host_platform == 'linux2':
-             # Linux-specific modules
-             exts.append( Extension('linuxaudiodev', ['linuxaudiodev.c']) )
-         else:
-             missing.append('linuxaudiodev')
- 
--        if (platform in ('linux2', 'freebsd4', 'freebsd5', 'freebsd6',
-+        if (host_platform in ('linux2', 'freebsd4', 'freebsd5', 'freebsd6',
-                         'freebsd7', 'freebsd8')
--            or platform.startswith("gnukfreebsd")):
-+            or host_platform.startswith("gnukfreebsd")):
-             exts.append( Extension('ossaudiodev', ['ossaudiodev.c']) )
-         else:
-             missing.append('ossaudiodev')
- 
--        if platform == 'sunos5':
-+        if host_platform == 'sunos5':
-             # SunOS specific modules
-             exts.append( Extension('sunaudiodev', ['sunaudiodev.c']) )
-         else:
-             missing.append('sunaudiodev')
- 
--        if platform == 'darwin':
-+        if host_platform == 'darwin':
-             # _scproxy
-             exts.append(Extension("_scproxy", [os.path.join(srcdir, "Mac/Modules/_scproxy.c")],
-                 extra_link_args= [
-@@ -1505,7 +1547,7 @@
-                 ]))
- 
- 
--        if platform == 'darwin' and ("--disable-toolbox-glue" not in
-+        if host_platform == 'darwin' and ("--disable-toolbox-glue" not in
-                 sysconfig.get_config_var("CONFIG_ARGS")):
- 
-             if int(os.uname()[2].split('.')[0]) >= 8:
-@@ -1701,8 +1743,7 @@
-         # Rather than complicate the code below, detecting and building
-         # AquaTk is a separate method. Only one Tkinter will be built on
-         # Darwin - either AquaTk, if it is found, or X11 based Tk.
--        platform = self.get_platform()
--        if (platform == 'darwin' and
-+        if (host_platform == 'darwin' and
-             self.detect_tkinter_darwin(inc_dirs, lib_dirs)):
-             return
- 
-@@ -1725,7 +1766,7 @@
-             # Check for the include files on Debian and {Free,Open}BSD, where
-             # they're put in /usr/include/{tcl,tk}X.Y
-             dotversion = version
--            if '.' not in dotversion and "bsd" in sys.platform.lower():
-+            if '.' not in dotversion and "bsd" in host_platform.lower():
-                 # OpenBSD and FreeBSD use Tcl/Tk library names like libtcl83.a,
-                 # but the include subdirs are named like .../include/tcl8.3.
-                 dotversion = dotversion[:-1] + '.' + dotversion[-1]
-@@ -1751,7 +1792,7 @@
-                 include_dirs.append(dir)
- 
-         # Check for various platform-specific directories
--        if platform == 'sunos5':
-+        if host_platform == 'sunos5':
-             include_dirs.append('/usr/openwin/include')
-             added_lib_dirs.append('/usr/openwin/lib')
-         elif os.path.exists('/usr/X11R6/include'):
-@@ -1767,7 +1808,7 @@
-             added_lib_dirs.append('/usr/X11/lib')
- 
-         # If Cygwin, then verify that X is installed before proceeding
--        if platform == 'cygwin':
-+        if host_platform == 'cygwin':
-             x11_inc = find_file('X11/Xlib.h', [], include_dirs)
-             if x11_inc is None:
-                 return
-@@ -1786,11 +1827,11 @@
-         libs.append('tk'+ version)
-         libs.append('tcl'+ version)
- 
--        if platform in ['aix3', 'aix4']:
-+        if host_platform in ['aix3', 'aix4']:
-             libs.append('ld')
- 
-         # Finally, link with the X11 libraries (not appropriate on cygwin)
--        if platform != "cygwin":
-+        if host_platform != "cygwin":
-             libs.append('X11')
- 
-         ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
-@@ -1842,7 +1883,7 @@
- 
-     def configure_ctypes(self, ext):
-         if not self.use_system_libffi:
--            if sys.platform == 'darwin':
-+            if host_platform == 'darwin':
-                 return self.configure_ctypes_darwin(ext)
- 
-             srcdir = sysconfig.get_config_var('srcdir')
-@@ -1860,12 +1901,17 @@
-                                          ffi_configfile):
-                 from distutils.dir_util import mkpath
-                 mkpath(ffi_builddir)
--                config_args = []
-+                #NOTE: best solution is to add to configure script
-+                # as config subdirectory and to exclude darwin
-+                # (see configure_ctypes_darwin).
-+                #FIXME: lets for now pass all top configure arguments
-+                #and do not modify configure script.
-+                config_args = sysconfig.get_config_var("CONFIG_ARGS")
- 
-                 # Pass empty CFLAGS because we'll just append the resulting
-                 # CFLAGS to Python's; -g or -O2 is to be avoided.
--                cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \
--                      % (ffi_builddir, ffi_srcdir, " ".join(config_args))
-+                cmd = "cd %s && env CFLAGS='' '%s/configure' %s --srcdir='%s'" \
-+                      % (ffi_builddir, ffi_srcdir, config_args, ffi_srcdir)
- 
-                 res = os.system(cmd)
-                 if res or not os.path.exists(ffi_configfile):
-@@ -1902,7 +1948,7 @@
-                    '_ctypes/cfield.c']
-         depends = ['_ctypes/ctypes.h']
- 
--        if sys.platform == 'darwin':
-+        if host_platform == 'darwin':
-             sources.append('_ctypes/malloc_closure.c')
-             sources.append('_ctypes/darwin/dlfcn_simple.c')
-             extra_compile_args.append('-DMACOSX')
-@@ -1910,7 +1956,7 @@
- # XXX Is this still needed?
- ##            extra_link_args.extend(['-read_only_relocs', 'warning'])
- 
--        elif sys.platform == 'sunos5':
-+        elif host_platform == 'sunos5':
-             # XXX This shouldn't be necessary; it appears that some
-             # of the assembler code is non-PIC (i.e. it has relocations
-             # when it shouldn't. The proper fix would be to rewrite
-@@ -1921,7 +1967,7 @@
-             # finding some -z option for the Sun compiler.
-             extra_link_args.append('-mimpure-text')
- 
--        elif sys.platform.startswith('hp-ux'):
-+        elif host_platform.startswith('hp-ux'):
-             extra_link_args.append('-fPIC')
- 
-         ext = Extension('_ctypes',
-@@ -1938,7 +1984,7 @@
-         if not '--with-system-ffi' in sysconfig.get_config_var("CONFIG_ARGS"):
-             return
- 
--        if sys.platform == 'darwin':
-+        if host_platform == 'darwin':
-             # OS X 10.5 comes with libffi.dylib; the include files are
-             # in /usr/include/ffi
-             inc_dirs.append('/usr/include/ffi')
diff --git a/build/tools/toolchain-patches/python/Python-2.7.3/0001-MINGW.patch b/build/tools/toolchain-patches/python/Python-2.7.3/0001-MINGW.patch
deleted file mode 100644
index 4e160b4..0000000
--- a/build/tools/toolchain-patches/python/Python-2.7.3/0001-MINGW.patch
+++ /dev/null
@@ -1,2851 +0,0 @@
-diff -urN a/configure.in b/configure.in
---- a/configure.in	2012-06-24 16:36:39.855815810 +0100
-+++ b/configure.in	2012-06-24 16:36:40.072817294 +0100
-@@ -84,7 +84,15 @@
- fi
- 
- AC_SUBST(VERSION)
-+case $host in
-+  *-*-mingw*)
-+  dnl To be compatible with MSVC build.
-+VERSION=`echo PYTHON_VERSION | sed -e 's|\.||g'`
-+  ;;
-+  *)
- VERSION=PYTHON_VERSION
-+  ;;
-+esac
- 
- AC_SUBST(SOVERSION)
- SOVERSION=1.0
-@@ -345,6 +353,26 @@
- dnl linux with 1.x(if someone still use it) and 2.x host kernels.
- dnl As example setup.py check for linux2(get from sys.platform) and will
- dnl install some host plaform specific files into subdirectory "plat-linux2".
-+dnl In addition $host_os may contain specific settings for some host systems
-+dnl as example mingwNN{YYYY} but the host winNN. So we may set MACHDEP
-+dnl to winNN in this case, i.e. different host systems from gnu autotools
-+dnl point of view but same for python.
-+if test -z "$MACHDEP"
-+then
-+	dnl set MACHDEP only on certain host systems
-+	case $host in
-+	*-*-mingw*)
-+	dnl we use only case based on "host triplet"
-+	ac_sys_system=ignore
-+	dnl FIXME: what is correct:
-+	dnl - PLATFORM is always "win32" (see define in PC/pyconfig.h )
-+	dnl - getplatform.o is build with -DPLATFORM='"$(MACHDEP)"'
-+	dnl - the platform specific files go in plat-$(MACHDEP)
-+	dnl - but an item in PYTHONPATH is "plat-win" !!! oops
-+	MACHDEP=win
-+	;;
-+	esac
-+fi
- if test -z "$MACHDEP"
- then
- 	ac_sys_system=`uname -s`
-@@ -494,6 +522,16 @@
- fi
- AC_MSG_RESULT($MACHDEP)
- 
-+AC_MSG_CHECKING([for init system calls])
-+AC_SUBST(INITSYS)
-+case $host in
-+  # FIXME: May configure lack detection for os2 host system ?
-+  #?#*-*-os2*)	INITSYS=os2;;
-+  *-*-mingw*)	INITSYS=nt;;
-+  *)		INITSYS=posix;;
-+esac
-+AC_MSG_RESULT([$INITSYS])
-+
- # And add extra plat-mac for darwin
- AC_SUBST(EXTRAPLATDIR)
- AC_SUBST(EXTRAMACHDEPPATH)
-@@ -801,6 +839,10 @@
-   *)
-     enable_shared="no";;
-   esac
-+  case $host in
-+  *-*-mingw*)
-+    enable_shared="yes";;
-+  esac
- fi
- AC_MSG_RESULT($enable_shared)
- 
-@@ -902,6 +944,14 @@
- 	;;
- 
-   esac
-+  case $host in
-+    *-*-mingw*)
-+          LDLIBRARY='libpython$(VERSION).dll.a'
-+          DLLLIBRARY='libpython$(VERSION).dll'
-+          dnl setup.py add it for mingw host
-+          dnl BLDLIBRARY='-L. -lpython$(VERSION)'
-+          ;;
-+  esac
- else # shared is disabled
-   case $ac_sys_system in
-     CYGWIN*)
-@@ -909,6 +959,10 @@
-           LDLIBRARY='libpython$(VERSION).dll.a'
-           ;;
-   esac
-+  case $host in
-+    *-*-mingw*)
-+          LDLIBRARY='libpython$(VERSION).a';;
-+  esac
- fi
- 
- AC_MSG_RESULT($LDLIBRARY)
-@@ -968,6 +1022,8 @@
- 	esac
- fi
- 
-+dnl TODO: to move --with-pydebug earlier in script and to group
-+dnl debug related statements togeder (if posible)
- # Check for --with-pydebug
- AC_MSG_CHECKING(for --with-pydebug)
- AC_ARG_WITH(pydebug, 
-@@ -982,6 +1038,29 @@
- else AC_MSG_RESULT(no); Py_DEBUG='false'
- fi],
- [AC_MSG_RESULT(no)])
-+# FIXME: We define BUILDEXEEXT and LDLIBRARY above but:
-+#  For debug versions MSVC build prepend suffix by '_d'.
-+#  If we support this convention we may modify distutils(TODO).
-+#  To support different build directories is good "--with-pydebug"
-+#  to be earlier in the script(why i wrote this?).
-+if test "x$Py_DEBUG" = xtrue; then
-+  case $host in
-+    dnl TODO: This is good to be where we define LDLIBRARY
-+    dnl but --with-pydebug is defined too late in the script.
-+    # Since Makefile.pre.in may isn't suitable for now we will not
-+    # change LDLIBRARY.
-+    *-*-mingw*)
-+      BUILDEXEEXT=_d$BUILDEXEEXT
-+      if test x$enable_shared = xyes; then
-+        #LDLIBRARY='libpython$(VERSION)_d.dll.a'
-+        DLLLIBRARY='libpython$(VERSION)_d.dll'
-+      else # shared is disabled
-+        #LDLIBRARY='libpython$(VERSION)_d.dll.a';;
-+        :
-+      fi
-+      ;;
-+  esac
-+fi
- 
- # XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
- # merged with this chunk of code?
-@@ -998,6 +1077,8 @@
- 
- # tweak OPT based on compiler and platform, only if the user didn't set
- # it on the command line
-+# NOTE: If user set OPT at this point script ignore all previously set
-+# options (not important - BeOS is depricated for python 2.6+).
- AC_SUBST(OPT)
- if test "${OPT-unset}" = "unset"
- then
-@@ -1077,6 +1158,10 @@
-          alpha*)
-                 BASECFLAGS="$BASECFLAGS -mieee"
-                 ;;
-+         *-*-mingw*)
-+                #MSVC in-compatable storage layout for bitfields in structures (Roumen has -mms-bitfields)
-+                BASECFLAGS="$BASECFLAGS"
-+                ;;
-     esac
- 
-     case $ac_sys_system in
-@@ -1209,8 +1294,15 @@
-     ;;
- esac
- 
-+dnl NOTE: although Py_DEBUG is set earlier in the script we can't move
-+dnl before "# tweak OPT based on compiler" - if user specify environment
-+dnl variable OPT we will lost our settings!!!
-+dnl FIXME: why script add debug definition to OPT instead to BASECFLAGS?
- if test "$Py_DEBUG" = 'true'; then
--  :
-+  case $host in
-+    dnl Same as in PC/pyconfig.h but order in opposite(Py_DEBUG=>-D_DEBUG).
-+    *-*-mingw*) OPT="-D_DEBUG $OPT";;
-+  esac
- else
-   OPT="-DNDEBUG $OPT"
- fi
-@@ -1397,6 +1489,20 @@
- AC_MSG_RESULT($ac_cv_pthread)
- fi
- 
-+if test "x$ac_cv_kpthread" = xno && \
-+   test "x$ac_cv_kthread" = xno && \
-+   test "x$ac_cv_pthread" = xno && \
-+   test "x$ac_cv_pthread_is_default" = xno
-+then
-+	AC_MSG_CHECKING(for NT threads)
-+	AC_CACHE_VAL(ac_cv_ntthread,
-+	[AC_LINK_IFELSE([
-+		AC_LANG_PROGRAM([], [_beginthread(0, 0, 0);])],
-+	ac_cv_ntthread=yes,
-+	ac_cv_ntthread=no)])
-+	AC_MSG_RESULT([$ac_cv_ntthread])
-+fi
-+
- # If we have set a CC compiler flag for thread support then
- # check if it works for CXX, too.
- ac_cv_cxx_thread=no
-@@ -1417,6 +1523,9 @@
- then 
-   CXX="$CXX -pthread"
-   ac_cv_cxx_thread=yes
-+elif test "x$ac_cv_ntthread" = xyes
-+then
-+  ac_cv_cxx_thread=always
- fi
- 
- if test $ac_cv_cxx_thread = yes
-@@ -1458,7 +1567,7 @@
- sys/termio.h sys/time.h \
- sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
- sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
--bluetooth/bluetooth.h linux/tipc.h spawn.h util.h)
-+bluetooth/bluetooth.h linux/tipc.h spawn.h util.h winsock2.h)
- AC_HEADER_DIRENT
- AC_HEADER_MAJOR
- 
-@@ -1667,19 +1776,20 @@
- elif test "$ac_cv_pthread" = "yes"
- then CC="$CC -pthread"
- fi
--AC_MSG_CHECKING(for pthread_t)
--have_pthread_t=no
--AC_COMPILE_IFELSE([
--  AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t x; x = *(pthread_t*)0;]])
--],[have_pthread_t=yes],[])
--AC_MSG_RESULT($have_pthread_t)
--if test "$have_pthread_t" = yes ; then
-+dnl NOTE: avoid duplicate check for pthread_t(it is done in AC_CHECK_SIZEOF(pthread_t...) )
-+dnl AC_MSG_CHECKING(for pthread_t)
-+dnl have_pthread_t=no
-+dnl AC_COMPILE_IFELSE([
-+dnl   AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t x; x = *(pthread_t*)0;]])
-+dnl ],[have_pthread_t=yes],[])
-+dnl AC_MSG_RESULT($have_pthread_t)
-+dnl if test "$have_pthread_t" = yes ; then
-   AC_CHECK_SIZEOF(pthread_t, [], [
- #ifdef HAVE_PTHREAD_H
- #include <pthread.h>
- #endif
-   ])
--fi
-+dnl fi
- CC="$ac_save_cc"
- 
- AC_MSG_CHECKING(for --enable-toolbox-glue)
-@@ -1840,6 +1950,16 @@
- 	CYGWIN*)   SO=.dll;;
- 	*)	   SO=.so;;
- 	esac
-+	case $host in
-+	*-*-mingw*)
-+	#NOTE: see _PyImport_DynLoadFiletab in dynload_win.c
-+	if test "x$Py_DEBUG" = xtrue; then
-+		SO=_d.pyd
-+	else
-+		SO=.pyd
-+	fi
-+	;;
-+	esac
- else
- 	# this might also be a termcap variable, see #610332
-         echo
-@@ -1996,6 +2116,12 @@
- 		LDCXXSHARED="g++ -shared";;
- 	*)	LDSHARED="ld";;
- 	esac
-+	case $host in
-+	*-*-mingw*)
-+		LDSHARED='$(CC) -shared -Wl,--enable-auto-image-base'
-+		LDCXXSHARED='$(CXX) -shared -Wl,--enable-auto-image-base'
-+		;;
-+	esac
- fi
- AC_MSG_RESULT($LDSHARED)
- LDCXXSHARED=${LDCXXSHARED-$LDSHARED}
-@@ -2093,6 +2219,12 @@
- 		# when running test_compile.py.
- 		LINKFORSHARED='-Wl,-E -N 2048K';;
- 	esac
-+	case $host in
-+	*-*-mingw*)
-+		if test x$enable_shared = xyes; then
-+			LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
-+		fi;;
-+	esac
- fi
- AC_MSG_RESULT($LINKFORSHARED)
- 
-@@ -2109,6 +2241,12 @@
- 	*)
- 		CFLAGSFORSHARED='$(CCSHARED)'
- 	esac
-+	case $host in
-+	*-*-mingw*)
-+		# TODO mingw may needs CCSHARED when building extension DLLs
-+		# but not when building the interpreter DLL.
-+		CFLAGSFORSHARED='';;
-+	esac
- fi
- AC_MSG_RESULT($CFLAGSFORSHARED)
- 
-@@ -2141,9 +2279,18 @@
- fi
- 
- # check if we need libintl for locale functions
-+case $host in
-+  *-*-mingw*)
-+  dnl Native windows build don't use libintl (see _localemodule.c).
-+  dnl Also we don't like setup.py to add "intl" library to the list
-+  dnl when build _locale module.
-+  ;;
-+  *)
- AC_CHECK_LIB(intl, textdomain,
- 	AC_DEFINE(WITH_LIBINTL, 1,
- 	[Define to 1 if libintl is needed for locale functions.]))
-+  ;;
-+esac
- 
- # checks for system dependent C++ extensions support
- case "$ac_sys_system" in
-@@ -2325,6 +2472,13 @@
-     AC_DEFINE(WITH_THREAD)
-     posix_threads=yes
-     THREADOBJ="Python/thread.o"
-+elif test "x$ac_cv_ntthread" = xyes
-+then
-+    AC_DEFINE(WITH_THREAD)
-+    posix_threads=no
-+    THREADOBJ="Python/thread.o"
-+    AC_DEFINE(NT_THREADS, 1,
-+	[Define to 1 if you want to use native NT threads])
- else
-     if test ! -z "$with_threads" -a -d "$with_threads"
-     then LDFLAGS="$LDFLAGS -L$with_threads"
-@@ -2488,6 +2642,18 @@
- fi
- 
- 
-+AC_SUBST(BUILDIN_WIN32_MODULE)
-+BUILDIN_WIN32_MODULE='#'
-+case $host in
-+  *-*-mingw*)
-+    # On win32 host(mingw build MSYS environment) site.py fail to load
-+    # if _functools is not build-in by reason of dependency:
-+    #   setup->site->locale->functools&operator
-+    BUILDIN_WIN32_MODULE=
-+  ;;
-+esac
-+
-+
- # Check for enable-ipv6
- AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
- AC_MSG_CHECKING([if --enable-ipv6 is specified])
-@@ -2777,6 +2943,14 @@
- 	fi
- 	;;
- 	esac
-+	case $host in
-+	*-*-mingw*)
-+	# FIXME: it is good to use portable "$OBJEXT" instead "o" but
-+	# python build isn't yet ready to use it (see Makefile.pre.in)
-+	#DYNLOADFILE="dynload_win.$OBJEXT"
-+	DYNLOADFILE="dynload_win.o"
-+	;;
-+	esac
- fi
- AC_MSG_RESULT($DYNLOADFILE)
- if test "$DYNLOADFILE" != "dynload_stub.o"
-@@ -2789,6 +2963,11 @@
- 
- AC_SUBST(MACHDEP_OBJS)
- AC_MSG_CHECKING(MACHDEP_OBJS)
-+case $host in
-+  *-*-mingw*)
-+    extra_machdep_objs="PC/dl_nt.o PC/getpathp.o PC/import_nt.o"
-+    ;;
-+esac
- if test -z "$MACHDEP_OBJS"
- then
- 	MACHDEP_OBJS=$extra_machdep_objs
-@@ -2818,6 +2997,17 @@
-  sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
-  truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty)
- 
-+dnl NOTE: On windows platform some functions aren't C functions and require
-+dnl additional non-standard decoration and may be libraries.
-+dnl As example winsock2 functions, although are based on berkeley sockets
-+dnl use stdcall convention. Also they require an additional library ws2_32.
-+dnl One of those functions is "getpeername" (see list above)
-+dnl and can't be detected by script. Now this impact mingw host platforms.
-+dnl Since this function is used only by socketmodule, module include
-+dnl necessary headers and is linked with requred libs (see setup.py)
-+dnl windows exception will be handled in module code.
-+dnl FIXME: If you don't like this, write appropriate check here.
-+
- # For some functions, having a definition is not sufficient, since
- # we want to take their address.
- AC_MSG_CHECKING(for chroot)
-@@ -3218,6 +3408,15 @@
- [ac_cv_buggy_getaddrinfo=yes],
- [ac_cv_buggy_getaddrinfo=yes]))
- fi
-+case $host in
-+  *-*-mingw*)
-+  #FIXME: mingw "w32api" define getaddinfo if WINVER >= 0x501, i.e. XP or greater.
-+  #TODO: mingw require additional check.
-+  #NOTE: above check is not correct for windows platforms.
-+  #  ac_cv_buggy_getaddrinfo=no
-+    :
-+    ;;
-+esac
- 
- AC_MSG_RESULT($ac_cv_buggy_getaddrinfo)
- 
-@@ -3273,19 +3472,33 @@
- 
- AC_MSG_CHECKING(for addrinfo)
- AC_CACHE_VAL(ac_cv_struct_addrinfo,
--AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[struct addrinfo a]])],
-+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-+#ifdef HAVE_WINSOCK2_H
-+#  include <ws2tcpip.h>
-+#else
-+#  include <netdb.h>
-+#endif]],
-+    [[struct addrinfo a]])],
-   [ac_cv_struct_addrinfo=yes],
-   [ac_cv_struct_addrinfo=no]))
- AC_MSG_RESULT($ac_cv_struct_addrinfo)
- if test $ac_cv_struct_addrinfo = yes; then
--	AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
-+	AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo])
- fi
- 
- AC_MSG_CHECKING(for sockaddr_storage)
- AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
--#		include <sys/types.h>
--#		include <sys/socket.h>]], [[struct sockaddr_storage s]])],
-+#ifdef HAVE_SYS_TYPES_H
-+#include <sys/types.h>
-+#endif
-+#ifdef HAVE_SYS_SOCKET_H
-+#include <sys/socket.h>
-+#endif
-+#ifdef HAVE_WINSOCK2_H
-+#include <winsock2.h>
-+#endif]],
-+    [[struct sockaddr_storage s]])],
-   [ac_cv_struct_sockaddr_storage=yes],
-   [ac_cv_struct_sockaddr_storage=no]))
- AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
-@@ -3479,11 +3692,16 @@
- 
- # check for --with-libm=...
- AC_SUBST(LIBM)
-+dnl obsolete style to set libraries for a system
- case $ac_sys_system in
- Darwin) ;;
- BeOS) ;;
- *) LIBM=-lm
- esac
-+dnl new style to set libraries for host system
-+case $host in
-+  *-*-mingw*) LIBM=;;
-+esac
- AC_MSG_CHECKING(for --with-libm=STRING)
- AC_ARG_WITH(libm,
-             AS_HELP_STRING([--with-libm=STRING], [math library]),
-@@ -3517,6 +3735,13 @@
- # **************************************************
- # * Check for various properties of floating point *
- # **************************************************
-+case $host in
-+  *-*-mingw*)
-+    ac_cv_little_endian_double=yes
-+    ac_cv_big_endian_double=no
-+    ac_cv_mixed_endian_double=no
-+  ;;
-+esac
- 
- AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
- AC_CACHE_VAL(ac_cv_little_endian_double, [
-@@ -3600,6 +3825,8 @@
- 
- # This inline assembler syntax may also work for suncc and icc,
- # so we try it on all platforms.
-+# Note MSVC build use Python/dtoa.c, but I could not find any reason
-+# to use this file for GCC(mingw*) builds, so mingw* will use gcc asm :)
- 
- AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
-@@ -3647,6 +3874,11 @@
- [ac_cv_x87_double_rounding=yes],
- [ac_cv_x87_double_rounding=no])
- CC="$ac_save_cc"
-+if test "x$cross_compiling" = xyes; then
-+  case $host in
-+    *-*-mingw*) ac_cv_x87_double_rounding=yes;;
-+  esac
-+fi
- AC_MSG_RESULT($ac_cv_x87_double_rounding)
- if test "$ac_cv_x87_double_rounding" = yes
- then
-@@ -3664,6 +3896,12 @@
- # On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
- # -0. on some architectures.
- AC_MSG_CHECKING(whether tanh preserves the sign of zero)
-+case $host in
-+  *-*-mingw*)
-+    # Some MSVC runtimes don't preserve zero sign.
-+    # On mingw host we will use always replacement function.
-+    ac_cv_tanh_preserves_zero_sign=no;;
-+esac
- AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
- AC_RUN_IFELSE([AC_LANG_SOURCE([[
- #include <math.h>
-@@ -3689,6 +3927,12 @@
- 
- AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
- AC_CHECK_FUNCS([hypot lgamma log1p round tgamma])
-+dnl NOTE:
-+dnl MSVC build PC/pyconfig.h define HAVE_DECL_ISINF but it is useless
-+dnl since header define Py_IS_INFINITY as (!_finite(X) && !_isnan(X)).
-+dnl Also in pymath.h is commented too how PC/pyconfig.h define isinf.
-+dnl For mingw to keep compatibility with MSVC build we will define
-+dnl Py_IS_INFINITY in pyport.h.
- AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
- 
- LIBS=$LIBS_SAVE
-@@ -3698,6 +3942,13 @@
- # the kernel module that provides POSIX semaphores
- # isn't loaded by default, so an attempt to call
- # sem_open results in a 'Signal 12' error.
-+if test $ac_cv_func_sem_open = yes; then
-+case $host in
-+  *-*-mingw*)
-+    # GCC 4.4+ (mingw) support posix threads(!)
-+    # bug we won't use them on windows platform.
-+    ac_cv_posix_semaphores_enabled=no;;
-+esac
- AC_MSG_CHECKING(whether POSIX semaphores are enabled)
- AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
- AC_RUN_IFELSE([AC_LANG_SOURCE([[
-@@ -3723,6 +3974,9 @@
- [ac_cv_posix_semaphores_enabled=yes])
- )
- AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
-+else
-+   ac_cv_posix_semaphores_enabled=no
-+fi
- if test $ac_cv_posix_semaphores_enabled = no
- then
-   AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
-@@ -3732,6 +3986,16 @@
- # Multiprocessing check for broken sem_getvalue
- if test $ac_cv_func_sem_getvalue = yes; then
- AC_MSG_CHECKING(for broken sem_getvalue)
-+case $host in
-+  *-*-mingw*)
-+    # GCC(mingw) 4.4+ require and use posix threads(pthreads-w32)
-+    # Also system may contain installed pthreads-w32.
-+    # NOTE the test case below don't work for pthreads-w32:
-+    # - SEM_FAILED is not defined;
-+    # - sem_open is stub;
-+    # - sem_getvalue work(!).
-+    ac_cv_broken_sem_getvalue=no;;
-+esac
- AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
- AC_RUN_IFELSE([AC_LANG_SOURCE([[
- #include <unistd.h>
-@@ -3818,6 +4082,9 @@
- then
-   # check whether wchar_t is signed or not
-   AC_MSG_CHECKING(whether wchar_t is signed)
-+  case $host in
-+    *-*-mingw*) ac_cv_wchar_t_signed=no;;
-+  esac
-   AC_CACHE_VAL(ac_cv_wchar_t_signed, [
-   AC_RUN_IFELSE([AC_LANG_SOURCE([[
-   #include <wchar.h>
-@@ -4248,6 +4515,12 @@
- )
- 
- AC_MSG_NOTICE([checking for device files])
-+case $host in
-+  *-*-mingw*)
-+    ac_cv_file__dev_ptmx=ignore #NOTE: under MSYS environment device exist
-+    ac_cv_file__dev_ptc=no
-+    ;;
-+esac
- 
- dnl NOTE: Inform user how to proceed with files when cross compiling.
- if test "x$cross_compiling" = xyes; then
-@@ -4279,6 +4552,9 @@
- 
- if test "$have_long_long" = yes
- then
-+  case $host in
-+    *-*-mingw*) ac_cv_have_long_long_format=yes;;
-+  esac
-   AC_MSG_CHECKING(for %lld and %llu printf() format support)
-   AC_CACHE_VAL(ac_cv_have_long_long_format,
-   AC_RUN_IFELSE([AC_LANG_SOURCE([[[
-@@ -4331,6 +4607,9 @@
- fi
- 
- 
-+case $host in
-+  *-*-mingw*) ac_cv_have_size_t_format=no;;
-+esac
- AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
- AC_RUN_IFELSE([AC_LANG_SOURCE([[
- #include <stdio.h>
-@@ -4377,6 +4656,8 @@
-   [Define to printf format modifier for Py_ssize_t])
- fi
- 
-+dnl NOTE: check is incorrect for win host systems, i.e. mingw and etc.,
-+dnl but on those systems socklen_t is defined in ws2tcpip.h as int ;)
- AC_CHECK_TYPE(socklen_t,,
-   AC_DEFINE(socklen_t,int,
-             [Define to `int' if <sys/socket.h> does not define.]),[
-@@ -4401,8 +4682,39 @@
-   THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
- done
- 
-+# FIXME: in cross-compilation env. (mingw on linux) how to select correct compiler ?
-+# The current py-code will created modules with .so suffix and environment
-+# variable setting SO=$(SO) don't help
-+# see output of: python setup.py build --help-compiler
-+AC_SUBST(PYMOD_BUILDOPT)
-+case $host in
-+  *-*-mingw*) PYMOD_BUILDOPT="--compiler mingw32";;
-+esac
-+
-+dnl Objects for python and modules
-+# Python interpreter main program for frozen scripts
-+AC_SUBST(PYTHON_OBJS_FROZENMAIN)
-+PYTHON_OBJS_FROZENMAIN="Python/frozenmain.o"
-+# MODULE_GETPATH - default sys.path calculations
-+AC_SUBST(MODULE_GETPATH)
-+MODULE_GETPATH=Modules/getpath.o
-+case $host in
-+  *-*-mingw*)
-+    dnl "PC" is project sub-directory and we has to prepend user defined flags
-+    CPPFLAGS="-I\$(srcdir)/Python -I\$(srcdir)/PC $CPPFLAGS"
-+
-+    # FIXME: why windows builds don't use PC/frozen_dllmain.o ?
-+    PYTHON_OBJS_FROZENMAIN=""
-+    # default sys.path calculations for windows platforms
-+    MODULE_GETPATH=PC/getpathp.o
-+    ;;
-+esac
-+
- AC_SUBST(SRCDIRS)
- SRCDIRS="Parser Grammar Objects Python Modules Mac"
-+case $host in
-+  *-*-mingw*) SRCDIRS="$SRCDIRS PC";;
-+esac
- AC_MSG_CHECKING(for build directories)
- for dir in $SRCDIRS; do
-     if test ! -d $dir; then
-diff -urN a/Include/objimpl.h b/Include/objimpl.h
---- a/Include/objimpl.h	2012-04-10 00:07:29.000000000 +0100
-+++ b/Include/objimpl.h	2012-06-24 16:36:40.068817267 +0100
-@@ -256,6 +256,12 @@
-         Py_ssize_t gc_refs;
-     } gc;
-     long double dummy;  /* force worst-case alignment */
-+#if defined(__MINGW32__)
-+/* FIXME: what about 64-bit platforms ?
-+ * see http://mail.python.org/pipermail/python-dev/2009-July/090724.html
-+ */
-+	double dummy1;
-+#endif
- } PyGC_Head;
- 
- extern PyGC_Head *_PyGC_generation0;
-diff -urN a/Include/pymath.h b/Include/pymath.h
---- a/Include/pymath.h	2012-04-10 00:07:29.000000000 +0100
-+++ b/Include/pymath.h	2012-06-24 16:36:40.068817267 +0100
-@@ -109,6 +109,8 @@
-  *    non-infinite value v sitting in an 80-bit x87 register such that
-  *    v becomes infinite when spilled from the register to 64-bit memory.
-  * Note: PC/pyconfig.h defines Py_IS_INFINITY as _isinf
-+ * FIXME: PC/pyconfig.h defines Py_IS_INFINITY as (!_finite(X) && !_isnan(X))
-+ * so that above note isn't correct !!!
-  */
- #ifndef Py_IS_INFINITY
- #  if defined HAVE_DECL_ISINF && HAVE_DECL_ISINF == 1
-diff -urN a/Include/pyport.h b/Include/pyport.h
---- a/Include/pyport.h	2012-04-10 00:07:29.000000000 +0100
-+++ b/Include/pyport.h	2012-06-24 16:36:40.069817274 +0100
-@@ -656,6 +656,137 @@
- #endif /* 0 */
- 
- 
-+#ifdef __MINGW32__
-+/* FIXME: some of next definitions specific to gcc(mingw build) can be
-+   generalized on definitions of _WIN32 or WIN32 and to be common for
-+   all windows build instead explicitly to define only for non-autotools
-+   based builds (see PC/pyconfig.h for details). */
-+#if defined(_WIN64)
-+#  define MS_WIN64
-+#endif
-+#if !defined(MS_WIN32) && defined(_WIN32)
-+#  define MS_WIN32
-+#endif
-+#if !defined(MS_WIN32) && defined(_WIN32)
-+#  define MS_WIN32
-+#endif
-+#if !defined(MS_WINDOWS) && defined(MS_WIN32)
-+#  define MS_WINDOWS
-+#endif
-+
-+#ifndef PYTHONPATH
-+#  define PYTHONPATH ".\\DLLs;.\\lib;.\\lib\\plat-win;.\\lib\\lib-tk"
-+#endif
-+
-+/* python 2.6+ requires Windows 2000 or greater. */
-+#define Py_WINVER 0x0500
-+
-+#if defined(Py_BUILD_CORE) || defined(Py_BUILD_CORE_MODULE)
-+/* FIXME if NTDDI_xxx is in use by mingw (see PC/pyconfig.h) */
-+#ifndef WINVER
-+#  define WINVER Py_WINVER
-+#endif
-+#ifndef _WIN32_WINNT
-+#  define _WIN32_WINNT Py_WINVER
-+#endif
-+#endif
-+
-+#ifdef PLATFORM
-+/*NOTE: if compile getplatform.c PLATFORM is set to MACHDEP that is
-+  "win" for mingw build (see respective comment in configure.in). */
-+# undef PLATFORM
-+#endif
-+/* always set to "win32" - see PC/pyconfig.h */
-+#define PLATFORM "win32"
-+
-+#if defined(MS_WIN64)
-+#  define SIZEOF_HKEY 8
-+#elif defined(MS_WIN32)
-+#  define SIZEOF_HKEY 4
-+#endif
-+
-+/*NOTE: mingw has isinf as macro defined in math.h.
-+  Since PC/pyconfig.h define Py_IS_INFINITY(X) that cover HAVE_DECL_ISFINITE
-+  here for Py_IS_INFINITY we define same as for MSVC build.
-+  This makes HAVE_DECL_ISFINITE needless.
-+  Also see commants in configure.in and pymath.h. */
-+#define Py_IS_INFINITY(X) (!_finite(X) && !_isnan(X))
-+
-+#ifndef HAVE_LARGEFILE_SUPPORT
-+/*
-+  FIXME: on windows platforms:
-+   - Python use PY_LONG_LONG(!) for Py_off_t (_fileio.c);
-+   - HAVE_LARGEFILE_SUPPORT is defined in PC/pyconfig.h;
-+   - PC/pyconfig.h define 4 for SIZEOF_OFF_T and 8 for SIZEOF_FPOS_T;
-+   - If HAVE_LARGEFILE_SUPPORT isn't defined python will use off_t(!)
-+   for Py_off_t (see fileobjects.c and bz2module.c).
-+  Since for mingw configure detect 4 for size of "off_t" and 8 - for
-+  "fpos_t" we has to define HAVE_LARGEFILE_SUPPORT too.
-+  TODO: to test with AC_SYS_LARGEFILE and appropriate updates in
-+  python code.
-+*/
-+#  define HAVE_LARGEFILE_SUPPORT
-+#endif
-+
-+#if defined(Py_ENABLE_SHARED)
-+#  define MS_COREDLL 1 /* deprecated old symbol, but still in use for windows code */
-+#else
-+#  define MS_NO_COREDLL 1
-+#endif
-+
-+#if Py_UNICODE_SIZE == 2
-+/* For mingw is 2 but FIXME: What about to raise error in configure if
-+   unicode size isn't two ? Did python windows code support ucs4 ? */
-+#  define Py_WIN_WIDE_FILENAMES
-+#endif
-+
-+/* NOTE: Don't define HAVE_STDDEF_H.
-+ * It is defined by PC/pyconfig.h and used by Include/Python.h
-+ * (with comment For size_t?) but isn't required for mingw  */
-+#define Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE
-+
-+/* All other defines from PC/pyconfig.h are in autoconf generated
-+   pyconfig.h */
-+#if 0
-+/*FIXME:
-+  MSDN:
-+    "The getaddrinfo function was added to the ws2_32.dll on Windows XP
-+    and later."
-+  mingw:
-+    getaddrinfo and getnameinfo is defined for WINVER >= 0x0501.
-+  PC/pyconfig.h:
-+    "Python 2.6+ requires Windows 2000 or greater"
-+  So far so good but socketmodule.h define HAVE_GETADDRINFO and
-+  HAVE_GETNAMEINFO under very specific condition :
-+    # ifdef SIO_GET_MULTICAST_FILTER
-+    #  include <MSTcpIP.h>
-+  So the question is "Separate SDKs" required for w2k in MSVC build ?
-+  TODO: resolve later, may by configure :-/. For now python code will
-+  use fake implementation and if user define appropriate value for
-+  WINVER - the functionas from C runtime.
-+  For details see socketmodule.c .
-+  */
-+#ifndef HAVE_GETADDRINFO
-+#  define HAVE_GETADDRINFO
-+#endif
-+#ifndef HAVE_GETNAMEINFO
-+#  define HAVE_GETNAMEINFO
-+#endif
-+#endif
-+
-+/* Refer to <Modules/_math.h> .
-+   For mingw host configure detect functions described as HAVE_XXX
-+   in _math.h but as MSVC don't define them we will undefine HAVE_XXX
-+   too to use _Py_* replacements same as MSVC build .
-+ */
-+#undef HAVE_ACOSH
-+#undef HAVE_ASINH
-+#undef HAVE_ATANH
-+#undef HAVE_EXPM1
-+#undef HAVE_LOG1P
-+
-+#endif /*def __MINGW32__*/
-+
- /* On 4.4BSD-descendants, ctype functions serves the whole range of
-  * wchar_t character set rather than single byte code points only.
-  * This characteristic can break some operations of string object
-@@ -709,12 +840,12 @@
- */
- 
- /*
--  All windows ports, except cygwin, are handled in PC/pyconfig.h.
-+  MSVC windows port is handled in PC/pyconfig.h.
- 
--  BeOS and cygwin are the only other autoconf platform requiring special
--  linkage handling and both of these use __declspec().
-+  BeOS, mingw32 and cygwin use autoconf and require special
-+  linkage handling and all of these use __declspec().
- */
--#if defined(__CYGWIN__) || defined(__BEOS__)
-+#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BEOS__)
- #       define HAVE_DECLSPEC_DLL
- #endif
- 
-@@ -737,9 +868,17 @@
-         /* Under Cygwin, auto-import functions to prevent compilation */
-         /* failures similar to those described at the bottom of 4.1: */
-         /* http://docs.python.org/extending/windows.html#a-cookbook-approach */
--#                       if !defined(__CYGWIN__)
-+#                       if !defined(__CYGWIN__) && !defined(__MINGW32__)
- #                               define PyAPI_FUNC(RTYPE) __declspec(dllimport) RTYPE
--#                       endif /* !__CYGWIN__ */
-+#                       else
-+#                               define PyAPI_FUNC(RTYPE) RTYPE
-+#                       endif /* !__CYGWIN__  !__MINGW32__ */
-+            /* NOTE: The issue3945 "compile error in _fileio.c (cygwin)"
-+             * was resolved with modification of code.
-+             * This issue was resolved for gcc(mingw) with enabling auto
-+             * import feature. Since _fileio.c problem now disappear there
-+             * is no more reasons to avoid dllimport for gcc(mingw).
-+             */
- #                       define PyAPI_DATA(RTYPE) extern __declspec(dllimport) RTYPE
-         /* module init functions outside the core must be exported */
- #                       if defined(__cplusplus)
-diff -urN a/Lib/ctypes/test/test_as_parameter.py b/Lib/ctypes/test/test_as_parameter.py
---- a/Lib/ctypes/test/test_as_parameter.py	2012-04-10 00:07:29.000000000 +0100
-+++ b/Lib/ctypes/test/test_as_parameter.py	2012-06-24 16:36:40.066817253 +0100
-@@ -1,6 +1,7 @@
- import unittest
- from ctypes import *
- import _ctypes_test
-+import sys
- 
- dll = CDLL(_ctypes_test.__file__)
- 
-@@ -171,6 +172,10 @@
-         s2h = dll.ret_2h_func(self.wrap(inp))
-         self.assertEqual((s2h.x, s2h.y), (99*2, 88*3))
- 
-+    # This is known cdecl incompatibility between GCC
-+    # and MSVC. It is addressed in GCC issue #36834.
-+    # Python libffi detect it and complain.
-+    @unittest.skipIf(sys.platform == "win32" and sys.version.find("GCC") >= 0, 'XFAIL GCC(mingw)')
-     def test_struct_return_8H(self):
-         class S8I(Structure):
-             _fields_ = [("a", c_int),
-diff -urN a/Lib/ctypes/test/test_functions.py b/Lib/ctypes/test/test_functions.py
---- a/Lib/ctypes/test/test_functions.py	2012-04-10 00:07:29.000000000 +0100
-+++ b/Lib/ctypes/test/test_functions.py	2012-06-24 16:36:40.065817247 +0100
-@@ -359,6 +359,10 @@
-             s2h = windll.s_ret_2h_func(S2H(99, 88))
-             self.assertEqual((s2h.x, s2h.y), (99*2, 88*3))
- 
-+    # This is known cdecl incompatibility between GCC
-+    # and MSVC. It is addressed in GCC issue #36834.
-+    # Python libffi detect it and complain.
-+    @unittest.skipIf(sys.platform == "win32" and sys.version.find("GCC") >= 0, 'XFAIL GCC(mingw)')
-     def test_struct_return_8H(self):
-         class S8I(Structure):
-             _fields_ = [("a", c_int),
-diff -urN a/Lib/ctypes/util.py b/Lib/ctypes/util.py
---- a/Lib/ctypes/util.py	2012-04-10 00:07:29.000000000 +0100
-+++ b/Lib/ctypes/util.py	2012-06-24 16:36:40.066817253 +0100
-@@ -7,6 +7,11 @@
- if os.name == "nt":
- 
-     def _get_build_version():
-+        #***********************************************************
-+        # NOTE: As example for GCC(mingw) build sys.version return:
-+        # '2.7a0 (trunk:<REVISION>M, <DATE>, <TIME>) \n[GCC 3.4.5 (mingw special)]'
-+        # '2.7a0 (trunk:<REVISION>M, <DATE>, <TIME>) \n[GCC 4.4.0]'
-+        #***********************************************************
-         """Return the version of MSVC that was used to build Python.
- 
-         For Python 2.3 and up, the version number is included in
-@@ -30,6 +35,15 @@
-         return None
- 
-     def find_msvcrt():
-+        #************************************************************
-+        # FIXME: For GCC(mingw) runtime don't depend from compiler
-+        # version ;). We may use -D__MSVCRT_VERSION__ to detect which
-+        # verion is requested by user, but the name of the library
-+        # to be default.
-+        # As example WXP is with version 7.0 of msvcrt.dll.
-+        # Anyway since _get_build_version return 6 in most(standard)
-+        # cases this method will return msvcrt{d}. May be not so bad.
-+        #************************************************************
-         """Return the name of the VC runtime dll"""
-         version = _get_build_version()
-         if version is None:
-diff -urN a/Lib/distutils/ccompiler.py b/Lib/distutils/ccompiler.py
---- a/Lib/distutils/ccompiler.py	2012-04-10 00:07:29.000000000 +0100
-+++ b/Lib/distutils/ccompiler.py	2012-06-24 16:36:40.064817240 +0100
-@@ -916,6 +916,8 @@
-         osname = os.name
-     if platform is None:
-         platform = sys.platform
-+    if osname == "nt" and sys.version.find('GCC') >= 0:
-+        return 'mingw32'
-     for pattern, compiler in _default_compilers:
-         if re.match(pattern, platform) is not None or \
-            re.match(pattern, osname) is not None:
-diff -urN a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py
---- a/Lib/distutils/command/build_ext.py	2012-04-10 00:07:29.000000000 +0100
-+++ b/Lib/distutils/command/build_ext.py	2012-06-24 16:36:40.059817205 +0100
-@@ -19,7 +19,8 @@
- from distutils.util import get_platform
- from distutils import log
- 
--if os.name == 'nt':
-+# GCC(mingw): os.name is "nt" but build system is posix
-+if os.name == 'nt' and sys.version.find('GCC') < 0:
-     from distutils.msvccompiler import get_build_version
-     MSVC_VERSION = int(get_build_version())
- 
-@@ -179,7 +180,8 @@
-         # for extensions under windows use different directories
-         # for Release and Debug builds.
-         # also Python's library directory must be appended to library_dirs
--        if os.name == 'nt':
-+        # GCC(mingw): os.name is "nt" but build system is posix
-+        if os.name == 'nt' and sys.version.find('GCC') < 0:
-             # the 'libs' directory is for binary installs - we assume that
-             # must be the *native* platform.  But we don't really support
-             # cross-compiling via a binary install anyway, so we let it go.
-@@ -221,7 +223,8 @@
- 
-         # for extensions under Cygwin and AtheOS Python's library directory must be
-         # appended to library_dirs
--        if sys.platform[:6] == 'cygwin' or sys.platform[:6] == 'atheos':
-+        if (sys.platform[:6] == 'cygwin' or sys.platform[:6] == 'atheos'
-+            or (sys.platform == 'win32' and sys.version.find('GCC') >= 0)):
-             if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")):
-                 # building third party extensions
-                 self.library_dirs.append(os.path.join(sys.prefix, "lib",
-@@ -699,6 +702,34 @@
-         # pyconfig.h that MSVC groks.  The other Windows compilers all seem
-         # to need it mentioned explicitly, though, so that's what we do.
-         # Append '_d' to the python import library on debug builds.
-+
-+        # FIXME: What is purpose of code below ?
-+        # The posix build system khow requred libraries to build a module.
-+        # The libraries are stored in config(Makefile) variables BLDLIBRARY,
-+        # MODLIBS and SHLIBS. Note that some variables may contain linker
-+        # flags.
-+        # NOTE: For now we will check only GCC(mingw) compiler as is clear
-+        # that we build for windows platfrom.
-+        # The code for GCC(mingw) is not correct but this is distutils
-+        # limitation - we has to pass variables to the linker as is
-+        # instead only library names.
-+        if self.compiler.compiler_type == 'mingw32':
-+            from distutils import sysconfig
-+            template = "python%s"
-+            if self.debug:
-+                template = template + '_d'
-+            extra = [(template % (sysconfig.get_config_var('VERSION')))]
-+            for lib in sysconfig.get_config_var('BLDLIBRARY').split():
-+                if lib.startswith('-l'):
-+                    extra.append(lib[2:])
-+            for lib in sysconfig.get_config_var('MODLIBS').split():
-+                if lib.startswith('-l'):
-+                    extra.append(lib[2:])
-+            for lib in sysconfig.get_config_var('SHLIBS').split():
-+                if lib.startswith('-l'):
-+                    extra.append(lib[2:])
-+            return ext.libraries + extra
-+
-         if sys.platform == "win32":
-             from distutils.msvccompiler import MSVCCompiler
-             if not isinstance(self.compiler, MSVCCompiler):
-diff -urN a/Lib/distutils/cygwinccompiler.py b/Lib/distutils/cygwinccompiler.py
---- a/Lib/distutils/cygwinccompiler.py	2012-04-10 00:07:29.000000000 +0100
-+++ b/Lib/distutils/cygwinccompiler.py	2012-06-24 16:36:40.062817226 +0100
-@@ -60,6 +60,18 @@
-     """Include the appropriate MSVC runtime library if Python was built
-     with MSVC 7.0 or later.
-     """
-+    # FIXME: next code is from issue870382
-+    # MS C-runtime libraries never support backward compatibility.
-+    # Linking to a different library without to specify correct runtime
-+    # version for the headers will link renamed functions to msvcrt.
-+    # See issue3308: this piece of code is python problem even
-+    # with correct w32api headers.
-+    # Issue: for MSVC compiler we can get the version and from version
-+    # to determine mcvcrt as code below. But what about if python is
-+    # build with GCC compiler?
-+    # Output of sys.version is information for python build on first
-+    # line, on the next line is information for the compiler and the
-+    # output lack information for the C-runtime.
-     msc_pos = sys.version.find('MSC v.')
-     if msc_pos != -1:
-         msc_ver = sys.version[msc_pos+6:msc_pos+10]
-@@ -77,6 +89,8 @@
-             return ['msvcr90']
-         else:
-             raise ValueError("Unknown MS Compiler version %s " % msc_ver)
-+    else:
-+        return []
- 
- 
- class CygwinCCompiler (UnixCCompiler):
-@@ -85,6 +99,9 @@
-     obj_extension = ".o"
-     static_lib_extension = ".a"
-     shared_lib_extension = ".dll"
-+    # FIXME: dylib_... = ".dll.a" is not enought for binutils
-+    # loader on win32 platform !!!
-+    dylib_lib_extension = ".dll.a"
-     static_lib_format = "lib%s%s"
-     shared_lib_format = "%s%s"
-     exe_extension = ".exe"
-@@ -103,6 +120,10 @@
-                 "Compiling may fail because of undefined preprocessor macros."
-                 % details)
- 
-+        # Next line of code is problem for cross-compiled enviroment:
-+        # NOTE: GCC cross-compiler is prefixed by the <hostarch>-<hostos>-
-+        # and by default binaries are installed in same directory
-+        # as native compiler.
-         self.gcc_version, self.ld_version, self.dllwrap_version = \
-             get_versions()
-         self.debug_print(self.compiler_type + ": gcc %s, ld %s, dllwrap %s\n" %
-@@ -127,6 +148,9 @@
-         else:
-             shared_option = "-mdll -static"
- 
-+        # FIXME:
-+        # Hard-code may override unix-compiler settings and isn't
-+        # possible to use Makefile variables to pass correct flags !
-         # Hard-code GCC because that's what this is all about.
-         # XXX optimization, warnings etc. should be customizable.
-         self.set_executables(compiler='gcc -mcygwin -O -Wall',
-@@ -271,12 +295,20 @@
-         if output_dir is None: output_dir = ''
-         obj_names = []
-         for src_name in source_filenames:
--            # use normcase to make sure '.rc' is really '.rc' and not '.RC'
--            (base, ext) = os.path.splitext (os.path.normcase(src_name))
-+            # FIXME: "bogus checks for suffix" - as example the commented
-+            # by #BOGUS# code break valid assembler suffix ".S" !
-+            #BOGUS## use normcase to make sure '.rc' is really '.rc' and not '.RC'
-+            #BOGUS#base, ext = os.path.splitext(os.path.normcase(src_name))
-+            base, ext = os.path.splitext (src_name)
-+            ext_normcase = os.path.normcase(ext)
-+            if ext_normcase in ['.rc','.res']:
-+                ext = ext_normcase
-             if ext not in (self.src_extensions + ['.rc','.res']):
-                 raise UnknownFileError, \
-                       "unknown file type '%s' (from '%s')" % \
-                       (ext, src_name)
-+            base = os.path.splitdrive(base)[1] # Chop off the drive
-+            base = base[os.path.isabs(base):]  # If abs, chop off leading /
-             if strip_dir:
-                 base = os.path.basename (base)
-             if ext == '.res' or ext == '.rc':
-diff -urN a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py
---- a/Lib/distutils/sysconfig.py	2012-04-10 00:07:29.000000000 +0100
-+++ b/Lib/distutils/sysconfig.py	2012-06-24 16:48:40.044705953 +0100
-@@ -72,19 +72,21 @@
-     if prefix is None:
-         prefix = plat_specific and EXEC_PREFIX or PREFIX
- 
--    if os.name == "posix":
-+    # GCC(mingw): os.name is "nt" but build system is posix
-+    if os.name == "posix" or sys.version.find('GCC') >= 0:
-         if python_build:
--            buildir = os.path.dirname(sys.executable)
-+            # NOTE: sysconfig.py-20091210
-+            # Assume the executable is in the build directory.  The
-+            # pyconfig.h file should be in the same directory.  Since
-+            # the build directory may not be the source directory, we
-+            # must use "srcdir" from the makefile to find the "Include"
-+            # directory.
-+            base = os.path.dirname(os.path.abspath(sys.executable))
-             if plat_specific:
--                # python.h is located in the buildir
--                inc_dir = buildir
-+                return base
-             else:
--                # the source dir is relative to the buildir
--                srcdir = os.path.abspath(os.path.join(buildir,
--                                         get_config_var('srcdir')))
--                # Include is located in the srcdir
--                inc_dir = os.path.join(srcdir, "Include")
--            return inc_dir
-+                incdir = os.path.join(get_config_var('srcdir'), 'Include')
-+                return os.path.normpath(incdir)
-         return os.path.join(prefix, "include", "python" + get_python_version())
-     elif os.name == "nt":
-         return os.path.join(prefix, "include")
-@@ -146,14 +148,25 @@
- def customize_compiler(compiler):
-     """Do any platform-specific customization of a CCompiler instance.
- 
--    Mainly needed on Unix, so we can plug in the information that
--    varies across Unices and is stored in Python's Makefile.
--    """
-+     Mainly needed on Unix, so we can plug in the information that
-+     varies across Unices and is stored in Python's Makefile.
-+
-+     NOTE (known limitation of python build/install system):
-+     In cross-build environment make macros like CC and LDSHARED
-+     contain cross-compiler/linker instead of host compiler/linker.
-+     """
-+
-+    posix_build = None
-     if compiler.compiler_type == "unix":
-+       posix_build = True
-+    elif compiler.compiler_type == "mingw32":
-+        # GCC(mingw): if build system is posix
-+        if sys.version.find('GCC') >= 0:
-+            posix_build = True
-+    if posix_build == True:
-         (cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \
--            get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
--                            'CCSHARED', 'LDSHARED', 'SO', 'AR',
--                            'ARFLAGS')
-+             get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
-+                             'CCSHARED', 'LDSHARED', 'SO', 'AR', 'ARFLAGS')
- 
-         newcc = None
-         if 'CC' in os.environ:
-@@ -227,7 +240,8 @@
- def get_config_h_filename():
-     """Return full pathname of installed pyconfig.h file."""
-     if python_build:
--        if os.name == "nt":
-+        # GCC(mingw): os.name is "nt" but build system is posix
-+        if os.name == "nt" and sys.version.find('GCC') < 0:
-             inc_dir = os.path.join(project_base, "PC")
-         else:
-             inc_dir = project_base
-@@ -460,6 +474,11 @@
- 
- def _init_nt():
-     """Initialize the module as appropriate for NT"""
-+    if sys.version.find('GCC') >= 0:
-+        # GCC(mingw) use posix build system
-+        # FIXME: may be modification has to be in get_config_vars ?
-+        _init_posix()
-+        return
-     g = {}
-     # set basic install directories
-     g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1)
-diff -urN a/Lib/distutils/tests/test_bdist_msi.py b/Lib/distutils/tests/test_bdist_msi.py
---- a/Lib/distutils/tests/test_bdist_msi.py	2012-04-10 00:07:29.000000000 +0100
-+++ b/Lib/distutils/tests/test_bdist_msi.py	2012-06-24 16:42:30.055201499 +0100
-@@ -11,6 +11,7 @@
-                        support.LoggingSilencer,
-                        unittest.TestCase):
- 
-+    @unittest.skip("Require bdist_msi")
-     def test_minimal(self):
-         # minimal test XXX need more tests
-         from distutils.command.bdist_msi import bdist_msi
-diff -urN a/Lib/distutils/tests/test_build_ext.py b/Lib/distutils/tests/test_build_ext.py
---- a/Lib/distutils/tests/test_build_ext.py	2012-04-10 00:07:29.000000000 +0100
-+++ b/Lib/distutils/tests/test_build_ext.py	2012-06-24 16:36:40.060817212 +0100
-@@ -60,6 +60,11 @@
-             sys.stdout = StringIO()
-         try:
-             cmd.ensure_finalized()
-+            #Broken after issue 7712(r78136) : add a temp_cwd context manager to test_support ...
-+            #Without current working dir: "...cannot find -lpython27"
-+            #NOTE: [py3k svn r85559] First (uncontroversial) part of issue 9807, barry.warsaw, 2010-10-16 :
-+            #  new _fixup_command is bogus, so we will use own work-around
-+            cmd.library_dirs.insert(0, test_support.SAVEDCWD)
-             cmd.run()
-         finally:
-             sys.stdout = old_stdout
-@@ -280,6 +285,12 @@
-         # returns wrong result with --inplace
-         other_tmp_dir = os.path.realpath(self.mkdtemp())
-         old_wd = os.getcwd()
-+        #Without current working dir: "...cannot find -lpython27"
-+        #NOTE: After issue #7712(r78136) test cannot use old_wd !
-+        #cmd.library_dirs.insert(0, old_wd)
-+        #NOTE: [py3k svn r85559] First (uncontroversial) part of issue 9807, barry.warsaw, 2010-10-16 :
-+        #  new _fixup_command is bogus, so we will use own work-around
-+        cmd.library_dirs.insert(0, test_support.SAVEDCWD)
-         os.chdir(other_tmp_dir)
-         try:
-             cmd.inplace = 1
-diff -urN a/Lib/distutils/tests/test_config_cmd.py b/Lib/distutils/tests/test_config_cmd.py
---- a/Lib/distutils/tests/test_config_cmd.py	2012-04-10 00:07:30.000000000 +0100
-+++ b/Lib/distutils/tests/test_config_cmd.py	2012-06-24 16:36:40.061817219 +0100
-@@ -38,6 +38,7 @@
-         self.assertEqual(len(self._logs), numlines+1)
- 
-     def test_search_cpp(self):
-+        # TODO: mingw host ?
-         if sys.platform == 'win32':
-             return
-         pkg_dir, dist = self.create_dist()
-diff -urN a/Lib/distutils/tests/test_sysconfig.py b/Lib/distutils/tests/test_sysconfig.py
---- a/Lib/distutils/tests/test_sysconfig.py	2012-04-10 00:07:30.000000000 +0100
-+++ b/Lib/distutils/tests/test_sysconfig.py	2012-06-24 16:36:40.060817212 +0100
-@@ -43,9 +43,15 @@
-         # This is not much of a test.  We make sure Python.h exists
-         # in the directory returned by get_python_inc() but we don't know
-         # it is the correct file.
-+        #Broken after issue 7712(r78136) : add a temp_cwd context manager to test_support ...
-+        #NOTE: Its fail on platforms without root directory support(like windows)
-+        #where temp and current working directories may stay on different drivers.
-+        old_wd = os.getcwd()
-+        os.chdir(SAVEDCWD)
-         self.assertTrue(os.path.isdir(inc_dir), inc_dir)
-         python_h = os.path.join(inc_dir, "Python.h")
-         self.assertTrue(os.path.isfile(python_h), python_h)
-+        os.chdir(old_wd)
- 
-     def test_parse_makefile_base(self):
-         self.makefile = test.test_support.TESTFN
-diff -urN a/Lib/distutils/tests/test_unixccompiler.py b/Lib/distutils/tests/test_unixccompiler.py
---- a/Lib/distutils/tests/test_unixccompiler.py	2012-04-10 00:07:30.000000000 +0100
-+++ b/Lib/distutils/tests/test_unixccompiler.py	2012-06-24 16:36:40.060817212 +0100
-@@ -120,7 +120,7 @@
-         def gcv(v):
-             return 'xxx'
-         sysconfig.get_config_var = gcv
--        self.assertEqual(self.cc.rpath_foo(), '-R/foo')
-+        self.assertEqual(self.cc.rpath_foo(), '-blibpath:/foo')
- 
- 
- def test_suite():
-diff -urN a/Lib/distutils/unixccompiler.py b/Lib/distutils/unixccompiler.py
---- a/Lib/distutils/unixccompiler.py	2012-04-10 00:07:30.000000000 +0100
-+++ b/Lib/distutils/unixccompiler.py	2012-06-24 16:36:40.061817219 +0100
-@@ -292,6 +292,8 @@
-             return ["+s", "-L" + dir]
-         elif sys.platform[:7] == "irix646" or sys.platform[:6] == "osf1V5":
-             return ["-rpath", dir]
-+        elif sys.platform[:3] == "aix":
-+            return "-blibpath:" + dir
-         elif self._is_gcc(compiler):
-             return "-Wl,-R" + dir
-         else:
-diff -urN a/Lib/sysconfig.py b/Lib/sysconfig.py
---- a/Lib/sysconfig.py	2012-06-24 16:36:39.858815831 +0100
-+++ b/Lib/sysconfig.py	2012-06-24 16:36:40.064817240 +0100
-@@ -128,8 +128,13 @@
- 
- if _PYTHON_BUILD:
-     for scheme in ('posix_prefix', 'posix_home'):
--        _INSTALL_SCHEMES[scheme]['include'] = '{projectbase}/Include'
--        _INSTALL_SCHEMES[scheme]['platinclude'] = '{srcdir}'
-+        _INSTALL_SCHEMES[scheme]['include'] = '{srcdir}/Include'
-+        _INSTALL_SCHEMES[scheme]['platinclude'] = '{projectbase}'
-+
-+    # GCC(mingw) use posix build system
-+    if os.name == "nt" and sys.version.find('GCC') >= 0:
-+        _INSTALL_SCHEMES['nt']['include'] = '{srcdir}/Include'
-+        _INSTALL_SCHEMES['nt']['platinclude'] = '{projectbase}'
- 
- def _subst_vars(s, local_vars):
-     try:
-@@ -354,7 +359,8 @@
- def get_config_h_filename():
-     """Returns the path of pyconfig.h."""
-     if _PYTHON_BUILD:
--        if os.name == "nt":
-+        # GCC(mingw): os.name is "nt" but build system is posix
-+        if os.name == "nt" and sys.version.find('GCC') < 0:
-             inc_dir = os.path.join(_PROJECT_BASE, "PC")
-         else:
-             inc_dir = _PROJECT_BASE
-@@ -416,9 +422,19 @@
-         _CONFIG_VARS['platbase'] = _EXEC_PREFIX
-         _CONFIG_VARS['projectbase'] = _PROJECT_BASE
- 
--        if os.name in ('nt', 'os2'):
--            _init_non_posix(_CONFIG_VARS)
-+        # GCC(mingw) use posix build system
-+        posix_build = None
-         if os.name == 'posix':
-+            posix_build = True
-+        else:
-+            if os.name in ('nt', 'os2'):
-+                if sys.version.find('GCC') >= 0:
-+                    posix_build = True
-+                else:
-+                    posix_build = False
-+        if posix_build == False:
-+            _init_non_posix(_CONFIG_VARS)
-+        if posix_build == True:
-             _init_posix(_CONFIG_VARS)
- 
-         # Setting 'userbase' is done below the call to the
-@@ -433,7 +449,7 @@
-         # Normally it is relative to the build directory.  However, during
-         # testing, for example, we might be running a non-installed python
-         # from a different directory.
--        if _PYTHON_BUILD and os.name == "posix":
-+        if _PYTHON_BUILD and posix_build == True:
-             base = _PROJECT_BASE
-             try:
-                 cwd = os.getcwd()
-diff -urN a/Lib/test/regrtest.py b/Lib/test/regrtest.py
---- a/Lib/test/regrtest.py	2012-04-10 00:07:31.000000000 +0100
-+++ b/Lib/test/regrtest.py	2012-06-24 16:36:40.058817197 +0100
-@@ -388,7 +388,7 @@
-             found_garbage = []
- 
-     if single:
--        filename = os.path.join(TEMPDIR, 'pynexttest')
-+        filename = os.path.join(tempfile.gettempdir(), 'pynexttest')
-         try:
-             fp = open(filename, 'r')
-             next_test = fp.read().strip()
-@@ -1523,8 +1523,7 @@
-     # to keep the test files in a subfolder.  It eases the cleanup of leftover
-     # files using command "make distclean".
-     if sysconfig.is_python_build():
--        TEMPDIR = os.path.join(sysconfig.get_config_var('srcdir'), 'build')
--        TEMPDIR = os.path.abspath(TEMPDIR)
-+        TEMPDIR = os.path.abspath('build')
-         if not os.path.exists(TEMPDIR):
-             os.mkdir(TEMPDIR)
- 
-diff -urN a/Lib/test/test_curses.py b/Lib/test/test_curses.py
---- a/Lib/test/test_curses.py	2012-04-10 00:07:31.000000000 +0100
-+++ b/Lib/test/test_curses.py	2012-06-24 16:36:40.059817205 +0100
-@@ -167,11 +167,16 @@
-     curses.delay_output(1)
-     curses.echo() ; curses.echo(1)
- 
--    f = tempfile.TemporaryFile()
-+    fx = tempfile.TemporaryFile()
-+    # cf tempfile.py TemporaryFile vs NamedTemporaryFile
-+    if os.name != 'posix' or os.sys.platform == 'cygwin':
-+        f = fx.file
-+    else:
-+        f = fx
-     stdscr.putwin(f)
-     f.seek(0)
-     curses.getwin(f)
--    f.close()
-+    fx.close()
- 
-     curses.halfdelay(1)
-     curses.intrflush(1)
-diff -urN a/Lib/test/test_os.py b/Lib/test/test_os.py
---- a/Lib/test/test_os.py	2012-04-10 00:07:32.000000000 +0100
-+++ b/Lib/test/test_os.py	2012-06-24 16:36:40.058817197 +0100
-@@ -325,7 +325,11 @@
- 
-             def test_large_time(self):
-                 t1 = 5000000000 # some day in 2128
--                os.utime(self.fname, (t1, t1))
-+                try:
-+                    #Note fail if time_t is 32 bit
-+                    os.utime(self.fname, (t1, t1))
-+                except OverflowError:
-+                    self.skipTest("requires at least 64-bit time_t")
-                 self.assertEqual(os.stat(self.fname).st_mtime, t1)
- 
-         def test_1686475(self):
-diff -urN a/Lib/test/test_sundry.py b/Lib/test/test_sundry.py
---- a/Lib/test/test_sundry.py	2012-04-10 00:07:32.000000000 +0100
-+++ b/Lib/test/test_sundry.py	2012-06-24 16:36:40.059817205 +0100
-@@ -27,7 +27,11 @@
- 
-             import distutils.command.bdist_dumb
-             if sys.platform.startswith('win'):
--                import distutils.command.bdist_msi
-+                try:
-+                    import distutils.command.bdist_msi # if msi module is not build
-+                except ImportError:
-+                    if test_support.verbose:
-+                        print "skipping bdist_msi"
-             import distutils.command.bdist
-             import distutils.command.bdist_rpm
-             import distutils.command.bdist_wininst
-diff -urN a/Makefile.pre.in b/Makefile.pre.in
---- a/Makefile.pre.in	2012-06-24 16:36:39.859815838 +0100
-+++ b/Makefile.pre.in	2012-06-24 16:36:40.070817281 +0100
-@@ -198,7 +198,7 @@
- # Modules
- MODULE_OBJS=	\
- 		Modules/config.o \
--		Modules/getpath.o \
-+		@MODULE_GETPATH@ \
- 		Modules/main.o \
- 		Modules/gcmodule.o
- 
-@@ -273,7 +273,7 @@
- 		Python/codecs.o \
- 		Python/errors.o \
- 		Python/frozen.o \
--		Python/frozenmain.o \
-+		@PYTHON_OBJS_FROZENMAIN@ \
- 		Python/future.o \
- 		Python/getargs.o \
- 		Python/getcompiler.o \
-@@ -410,10 +410,15 @@
- 
- 
- # Build the shared modules
-+# FIXME: in cross-compilation env. (mingw on linux) how to select correct
-+# compiler/linker ?
-+# The current py-code will created modules with .so suffix and environment
-+# variable setting SO=$(SO) don't help.
-+# Also it link modules with gcc instead mingw...
- sharedmods: $(BUILDPYTHON)
- 	@case $$MAKEFLAGS in \
--	*s*) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' $(RUNPYTHON) -E $(srcdir)/setup.py -q build;; \
--	*) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' $(RUNPYTHON) -E $(srcdir)/setup.py build;; \
-+	*s*) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' $(RUNPYTHON) -E $(srcdir)/setup.py -q build @PYMOD_BUILDOPT@;; \
-+	*) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' $(RUNPYTHON) -E $(srcdir)/setup.py build @PYMOD_BUILDOPT@;; \
- 	esac
- 
- # Build static library
-@@ -530,6 +535,7 @@
- 	      -DHGBRANCH="\"`LC_ALL=C $(HGBRANCH)`\"" \
- 	      -o $@ $(srcdir)/Modules/getbuildinfo.c
- 
-+# default sys.path calculations
- Modules/getpath.o: $(srcdir)/Modules/getpath.c Makefile
- 	$(CC) -c $(PY_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \
- 		-DPREFIX='"$(prefix)"' \
-@@ -538,6 +544,10 @@
- 		-DVPATH='"$(VPATH)"' \
- 		-o $@ $(srcdir)/Modules/getpath.c
- 
-+# default sys.path calculations for windows platforms
-+PC/getpathp.o: $(srcdir)/PC/getpathp.c
-+	$(CC) -c $(PY_CFLAGS) -o $@ $(srcdir)/PC/getpathp.c
-+
- Modules/python.o: $(srcdir)/Modules/python.c
- 	$(MAINCC) -c $(PY_CFLAGS) -o $@ $(srcdir)/Modules/python.c
- 
-diff -urN a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
---- a/Modules/_ctypes/_ctypes.c	2012-04-10 00:07:33.000000000 +0100
-+++ b/Modules/_ctypes/_ctypes.c	2012-06-24 16:36:40.076817320 +0100
-@@ -3168,11 +3168,27 @@
-     mangled_name = alloca(strlen(name) + 1 + 1 + 1 + 3); /* \0 _ @ %d */
-     if (!mangled_name)
-         return NULL;
-+    /* FIXME: for stdcall decorated export functions MSVC compiler add
-+     * underscore, but GCC compiler create them without.
-+     * As well functions from system libraries are without underscore.
-+     * This is visible by example for _ctypes_test.pyd module.
-+     * Solutions:
-+     * - If a python module is build with gcc option --add-stdcall-alias
-+     * the module will contain XXX as alias for function XXX@ as result
-+     * first search in this method will succeed.
-+     * - Distutil may use compiler to create def-file, to modify it as
-+     * add underscore alias and with new def file to create module.
-+     * - Or may be just to search for function without underscore.
-+     */
-     for (i = 0; i < 32; ++i) {
-         sprintf(mangled_name, "_%s@%d", name, i*4);
-         address = (PPROC)GetProcAddress(handle, mangled_name);
-         if (address)
-             return address;
-+        sprintf(mangled_name, "%s@%d", name, i*4);
-+        address = (PPROC)GetProcAddress(handle, mangled_name);
-+        if (address)
-+            return address;
-     }
-     return NULL;
- #endif
-diff -urN a/Modules/_ctypes/libffi_msvc/win32.S b/Modules/_ctypes/libffi_msvc/win32.S
---- a/Modules/_ctypes/libffi_msvc/win32.S	1970-01-01 01:00:00.000000000 +0100
-+++ b/Modules/_ctypes/libffi_msvc/win32.S	2012-06-24 16:36:40.076817320 +0100
-@@ -0,0 +1,154 @@
-+/* -----------------------------------------------------------------------
-+   win32.S - Copyright (c) 1996, 1998, 2001, 2002  Red Hat, Inc.
-+	     Copyright (c) 2001  John Beniton
-+	     Copyright (c) 2002  Ranjit Mathew
-+
-+
-+   X86 Foreign Function Interface
-+
-+   Permission is hereby granted, free of charge, to any person obtaining
-+   a copy of this software and associated documentation files (the
-+   ``Software''), to deal in the Software without restriction, including
-+   without limitation the rights to use, copy, modify, merge, publish,
-+   distribute, sublicense, and/or sell copies of the Software, and to
-+   permit persons to whom the Software is furnished to do so, subject to
-+   the following conditions:
-+
-+   The above copyright notice and this permission notice shall be included
-+   in all copies or substantial portions of the Software.
-+
-+   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-+   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-+   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-+   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-+   OTHER DEALINGS IN THE SOFTWARE.
-+   ----------------------------------------------------------------------- */
-+
-+#define LIBFFI_ASM
-+#include <fficonfig.h>
-+#include <ffi.h>
-+
-+.text
-+
-+.globl ffi_prep_args
-+
-+        # This assumes we are using gas.
-+        .balign 16
-+.globl _ffi_call_x86
-+
-+_ffi_call_x86:
-+        pushl %ebp
-+        movl  %esp,%ebp
-+
-+	#THe: save previous %esi, and store the current stack pointer in %esi
-+	pushl %esi
-+	movl %esp,%esi
-+
-+        # Make room for all of the new args.
-+        movl  16(%ebp),%ecx
-+        subl  %ecx,%esp
-+
-+        movl  %esp,%eax
-+
-+        # Place all of the ffi_prep_args in position
-+        pushl 12(%ebp)
-+        pushl %eax
-+        call  *8(%ebp)
-+
-+        # Return stack to previous state and call the function
-+        addl  $8,%esp
-+
-+        # FIXME: Align the stack to a 128-bit boundary to avoid
-+        # potential performance hits.
-+
-+	call  *28(%ebp)
-+
-+	# Load ecif->cif->abi
-+#masm#	mov ecx, [ebp + 12]
-+        movl  12(%ebp),%ecx
-+#masm#	mov ecx, [ecx]ecif.cif
-+	movl  (%ecx),%ecx
-+#masm#	mov ecx, [ecx]ecif.cif.abi
-+	movl  (%ecx),%ecx
-+#masm#	cmp ecx, FFI_STDCALL
-+        cmpl  $2,%ecx
-+        je   noclean
-+
-+	# STDCALL: Remove the space we pushed for the args
-+        movl  16(%ebp),%ecx
-+        addl  %ecx,%esp
-+
-+	# CDECL: Caller has already cleaned the stack
-+noclean:
-+	# Check that esp has the same value as before!
-+	sub %esp,%esi # calculate stack pointer difference
-+
-+        # Load %ecx with the return type code
-+        movl  20(%ebp),%ecx
-+
-+        # If the return value pointer is NULL, assume no return value.
-+        cmpl  $0,24(%ebp)
-+        jne   retint
-+
-+        # Even if there is no space for the return value, we are
-+        # obliged to handle floating-point values.
-+        cmpl  $FFI_TYPE_FLOAT,%ecx
-+        jne   noretval
-+        fstp  %st(0)
-+
-+        jmp   epilogue
-+
-+retint:
-+        cmpl  $FFI_TYPE_INT,%ecx
-+        jne   retfloat
-+        # Load %ecx with the pointer to storage for the return value
-+        movl  24(%ebp),%ecx
-+        movl  %eax,0(%ecx)
-+        jmp   epilogue
-+
-+retfloat:
-+        cmpl  $FFI_TYPE_FLOAT,%ecx
-+        jne   retdouble
-+         # Load %ecx with the pointer to storage for the return value
-+        movl  24(%ebp),%ecx
-+        fstps (%ecx)
-+        jmp   epilogue
-+
-+retdouble:
-+        cmpl  $FFI_TYPE_DOUBLE,%ecx
-+        jne   retlongdouble
-+        # Load %ecx with the pointer to storage for the return value
-+        movl  24(%ebp),%ecx
-+        fstpl (%ecx)
-+        jmp   epilogue
-+
-+retlongdouble:
-+        cmpl  $FFI_TYPE_LONGDOUBLE,%ecx
-+        jne   retint64
-+        # Load %ecx with the pointer to storage for the return value
-+        movl  24(%ebp),%ecx
-+        fstpt (%ecx)
-+        jmp   epilogue
-+
-+retint64:
-+        cmpl  $FFI_TYPE_SINT64,%ecx
-+        jne   retstruct
-+        # Load %ecx with the pointer to storage for the return value
-+        movl  24(%ebp),%ecx
-+        movl  %eax,0(%ecx)
-+        movl  %edx,4(%ecx)
-+
-+retstruct:
-+        # Nothing to do!
-+
-+noretval:
-+epilogue:
-+	movl %esi,%eax # return the stack pointer detlta in %eax
-+	popl %esi # restore previous %esi
-+        movl %ebp,%esp
-+        popl %ebp
-+        ret
-+
-+.ffi_call_x86_end:
-diff -urN a/Modules/getaddrinfo.c b/Modules/getaddrinfo.c
---- a/Modules/getaddrinfo.c	2012-04-10 00:07:34.000000000 +0100
-+++ b/Modules/getaddrinfo.c	2012-06-24 16:36:40.075817314 +0100
-@@ -232,6 +232,9 @@
-     return YES;
- }
- 
-+#ifndef EAI_BADHINTS
-+#  define EAI_BADHINTS EAI_BADFLAGS
-+#endif
- int
- getaddrinfo(const char*hostname, const char*servname,
-             const struct addrinfo *hints, struct addrinfo **res)
-diff -urN a/Modules/getnameinfo.c b/Modules/getnameinfo.c
---- a/Modules/getnameinfo.c	2012-04-10 00:07:34.000000000 +0100
-+++ b/Modules/getnameinfo.c	2012-06-24 16:36:40.074817308 +0100
-@@ -48,6 +48,14 @@
- #include "addrinfo.h"
- #endif
- 
-+#ifndef IN_EXPERIMENTAL
-+#define IN_EXPERIMENTAL(i)  (((i) & 0xe0000000U) == 0xe0000000U)
-+#endif
-+
-+#ifndef IN_LOOPBACKNET
-+#define IN_LOOPBACKNET	    127
-+#endif
-+
- #define SUCCESS 0
- #define YES 1
- #define NO  0
-diff -urN a/Modules/_io/fileio.c b/Modules/_io/fileio.c
---- a/Modules/_io/fileio.c	2012-04-10 00:07:33.000000000 +0100
-+++ b/Modules/_io/fileio.c	2012-06-24 16:36:40.073817301 +0100
-@@ -29,7 +29,9 @@
- 
- #ifdef MS_WINDOWS
- /* can simulate truncate with Win32 API functions; see file_truncate */
-+#ifndef HAVE_FTRUNCATE
- #define HAVE_FTRUNCATE
-+#endif
- #define WIN32_LEAN_AND_MEAN
- #include <windows.h>
- #endif
-diff -urN a/Modules/_io/_iomodule.h b/Modules/_io/_iomodule.h
---- a/Modules/_io/_iomodule.h	2012-04-10 00:07:33.000000000 +0100
-+++ b/Modules/_io/_iomodule.h	2012-06-24 16:36:40.073817301 +0100
-@@ -72,7 +72,7 @@
-     PyObject *filename; /* Not used, but part of the IOError object */
-     Py_ssize_t written;
- } PyBlockingIOErrorObject;
--PyAPI_DATA(PyObject *) PyExc_BlockingIOError;
-+extern PyObject* PyExc_BlockingIOError;
- 
- /*
-  * Offset type for positioning.
-diff -urN a/Modules/_localemodule.c b/Modules/_localemodule.c
---- a/Modules/_localemodule.c	2012-04-10 00:07:33.000000000 +0100
-+++ b/Modules/_localemodule.c	2012-06-24 16:36:40.081817356 +0100
-@@ -10,6 +10,13 @@
- ******************************************************************/
- 
- #include "Python.h"
-+#ifdef __MINGW32__
-+/* The header libintl.h and library libintl may exist on mingw host.
-+ * To be compatible with MSVC build we has to undef some defines.
-+ */
-+#undef HAVE_LIBINTL_H
-+#undef HAVE_BIND_TEXTDOMAIN_CODESET
-+#endif
- 
- #include <stdio.h>
- #include <locale.h>
-diff -urN a/Modules/_math.c b/Modules/_math.c
---- a/Modules/_math.c	2012-04-10 00:07:33.000000000 +0100
-+++ b/Modules/_math.c	2012-06-24 16:36:40.081817356 +0100
-@@ -5,6 +5,29 @@
- #include <float.h>
- #include "_math.h"
- 
-+#if defined(__MINGW32__)
-+#  define USE_MINGWEX_MATH
-+#endif
-+
-+#ifdef USE_MINGWEX_MATH
-+/* To avoid problems with many MSVCRT implementations we will
-+ * use a work-around
-+ */
-+#define MAXLOG 7.09782712893383996843E2
-+#define MINLOG -7.45133219101941108420E2
-+
-+static double fake_exp (double x) {
-+  if (isnan(x)) { return(x); }
-+  if (isinf(x)) { return(x > 0.0 ? x : 0.0); }
-+  if (x > MAXLOG) { errno = ERANGE; return(INFINITY); }
-+/* the correct code is to set ERANGE but why windows build bot don't fail ? */
-+  if (x < MINLOG) { errno = ERANGE; return(0.0); }
-+
-+  return(exp(x));
-+}
-+#define exp	fake_exp
-+#endif /*def USE_MINGWEX_MATH*/
-+
- /* The following copyright notice applies to the original
-    implementations of acosh, asinh and atanh. */
- 
-@@ -179,9 +202,28 @@
-         if (u == 1.0)
-             return x;
-         else
-+#if 0
-             return (u - 1.0) * x / log(u);
-+#else
-+        {   /* avoid precision error */
-+            double r;
-+            r = x / log(u);
-+            return((u - 1.0) * r);
-+        }
-+#endif
-     }
-     else
-+#ifdef USE_MINGWEX_MATH
-+/* to avout errors with correct fake_exp:
-+  expm10211:expm1(-1420.0): expected -1.0, got 'OverflowError'
-+  expm10212:expm1(-1450.0): expected -1.0, got 'OverflowError'
-+  expm10213:expm1(-1500.0): expected -1.0, got 'OverflowError'
-+  expm10214:expm1(-1e+50): expected -1.0, got 'OverflowError'
-+  expm10215:expm1(-1.79e+308): expected -1.0, got 'OverflowError'
-+*/
-+        if (x < MINLOG) { return(-1.0); }
-+        else
-+#endif
-         return exp(x) - 1.0;
- }
- 
-diff -urN a/Modules/mathmodule.c b/Modules/mathmodule.c
---- a/Modules/mathmodule.c	2012-04-10 00:07:34.000000000 +0100
-+++ b/Modules/mathmodule.c	2012-06-24 16:36:40.079817342 +0100
-@@ -60,6 +60,30 @@
- extern double copysign(double, double);
- #endif
- 
-+#if defined(__MINGW32__)
-+#  define USE_MINGWEX_MATH
-+#endif
-+
-+#ifdef USE_MINGWEX_MATH
-+/* Since ldexp() is broken on many MSVCRT implementations and mingwex
-+ * library provide a long double version we will use it as work-around.
-+ * As example broken ldexp return for ldexp(1., INT_MAX) 0(zero) instead inf.
-+ * With this work-around math test testLdexp pass.
-+ */
-+static double fake_ldexp (double x, int expn) { return ldexpl (x, expn); }
-+#define ldexp	fake_ldexp
-+
-+/* Since pow() is broken on many MSVCRT implementations and library
-+ * mingwex provide a long double version we will use it as work-around.
-+ * As example broken pow return for pow(132.97585637020967, 126.95117632943295)
-+ * 4.1252919849060512e+269 instead 4.1252919849057403e+269.
-+ * With this work-around math test test_mtestfile pass for gamma.
-+ */
-+static double fake_pow (double x, double y) { return powl (x, y); }
-+#define pow	fake_pow
-+
-+#endif /*def USE_MINGWEX_MATH*/
-+
- /*
-    sin(pi*x), giving accurate results for all finite x (especially x
-    integral or close to an integer).  This is here for use in the
-diff -urN a/Modules/_multiprocessing/multiprocessing.c b/Modules/_multiprocessing/multiprocessing.c
---- a/Modules/_multiprocessing/multiprocessing.c	2012-04-10 00:07:33.000000000 +0100
-+++ b/Modules/_multiprocessing/multiprocessing.c	2012-06-24 16:36:40.081817356 +0100
-@@ -332,6 +332,12 @@
-         Py_DECREF(temp); Py_DECREF(value); return; }              \
-     Py_DECREF(value)
- 
-+#ifndef MS_WINDOWS
-+/* GCC(mingw) 4.4+ require and use posix threads(pthreads-w32)
-+ * Also system may contain installed pthreads-w32.
-+ * As multiprocessing is based on windows methods we must
-+ * comment all those flags
-+ */
- #if defined(HAVE_SEM_OPEN) && !defined(POSIX_SEMAPHORES_NOT_ENABLED)
-     ADD_FLAG(HAVE_SEM_OPEN);
- #endif
-@@ -345,8 +351,10 @@
-     ADD_FLAG(HAVE_BROKEN_SEM_GETVALUE);
- #endif
- #ifdef HAVE_BROKEN_SEM_UNLINK
-+/* FIXME: why use this? Note before was for cygwin and darwin ? */
-     ADD_FLAG(HAVE_BROKEN_SEM_UNLINK);
- #endif
-+#endif /*ndef MS_WINDOWS*/
-     if (PyModule_AddObject(module, "flags", temp) < 0)
-         return;
- }
-diff -urN a/Modules/posixmodule.c b/Modules/posixmodule.c
---- a/Modules/posixmodule.c	2012-04-10 00:07:34.000000000 +0100
-+++ b/Modules/posixmodule.c	2012-06-24 16:36:40.078817335 +0100
-@@ -128,6 +128,16 @@
- #define HAVE_CWAIT      1
- #define HAVE_FSYNC      1
- #define fsync _commit
-+#elif defined(__MINGW32__)	/* GCC (mingw special) compiler */
-+/*#define HAVE_GETCWD	1 - detected by configure*/
-+#define HAVE_SPAWNV	1
-+/*#define HAVE_EXECV	1 - detected by configure*/
-+#define HAVE_PIPE	1
-+#define HAVE_POPEN	1
-+#define HAVE_SYSTEM	1
-+#define HAVE_CWAIT	1
-+#define HAVE_FSYNC	1
-+#define fsync _commit
- #else
- #if defined(PYOS_OS2) && defined(PYCC_GCC) || defined(__VMS)
- /* Everything needed is defined in PC/os2emx/pyconfig.h or vms/pyconfig.h */
-@@ -256,7 +266,7 @@
- #endif
- #endif
- 
--#ifdef _MSC_VER
-+#if defined(_MSC_VER) || defined(__MINGW32__)
- #ifdef HAVE_DIRECT_H
- #include <direct.h>
- #endif
-@@ -272,7 +282,7 @@
- #include <shellapi.h>   /* for ShellExecute() */
- #define popen   _popen
- #define pclose  _pclose
--#endif /* _MSC_VER */
-+#endif /* _MSC_VER || __MINGW32__ */
- 
- #if defined(PYCC_VACPP) && defined(PYOS_OS2)
- #include <io.h>
-@@ -447,7 +457,7 @@
- */
- #include <crt_externs.h>
- static char **environ;
--#elif !defined(_MSC_VER) && ( !defined(__WATCOMC__) || defined(__QNX__) )
-+#elif !defined(_MSC_VER) && !defined(__MINGW32__) && ( !defined(__WATCOMC__) || defined(__QNX__) )
- extern char **environ;
- #endif /* !_MSC_VER */
- 
-@@ -1382,6 +1392,13 @@
- }
- 
- #ifdef MS_WINDOWS
-+#ifdef __MINGW32__
-+/* NOTE: All sample MSDN wincrypt programs include this header.
-+ * It is required if we use mingw w32api.
-+ * Why MSVC builds don't include it ?
-+ */
-+#  include <wincrypt.h>
-+#endif
- 
- /* IsUNCRoot -- test whether the supplied path is of the form \\SERVER\SHARE\,
-    where / can be used in place of \ and the trailing slash is optional.
-@@ -9251,7 +9268,7 @@
- }
- 
- 
--#if (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__)) && !defined(__QNX__)
-+#if (defined(_MSC_VER) || defined (__MINGW32__) || defined(__WATCOMC__) || defined(__BORLANDC__)) && !defined(__QNX__)
- #define INITFUNC initnt
- #define MODNAME "nt"
- 
-diff -urN a/Modules/readline.c b/Modules/readline.c
---- a/Modules/readline.c	2012-04-10 00:07:34.000000000 +0100
-+++ b/Modules/readline.c	2012-06-24 16:36:40.079817342 +0100
-@@ -11,6 +11,11 @@
- #include <errno.h>
- #include <sys/time.h>
- 
-+#ifdef MS_WINDOWS
-+/* on windows select don't work on files */
-+#undef HAVE_SELECT
-+#endif
-+
- #if defined(HAVE_SETLOCALE)
- /* GNU readline() mistakenly sets the LC_CTYPE locale.
-  * This is evil.  Only the user or the app's main() should do this!
-@@ -880,6 +885,10 @@
-     /* Allow $if term= in .inputrc to work */
-     rl_terminal_name = getenv("TERM");
- #endif
-+#ifdef MS_WINDOWS
-+    /* FIXME: need more test before to skip this hack */
-+    rl_terminal_name = "dumb";
-+#endif
-     /* Force rebind of TAB to insert-tab */
-     rl_bind_key('\t', rl_insert);
-     /* Bind both ESC-TAB and ESC-ESC to the completion function */
-@@ -1139,6 +1148,9 @@
- 
- 
- 
-+#ifndef MS_WINDOWS
-+    /* FIXME: windows readline(prompt) may not work ? */
-     PyOS_ReadlineFunctionPointer = call_readline;
-+#endif
-     setup_readline();
- }
-diff -urN a/Modules/selectmodule.c b/Modules/selectmodule.c
---- a/Modules/selectmodule.c	2012-04-10 00:07:34.000000000 +0100
-+++ b/Modules/selectmodule.c	2012-06-24 16:39:30.641981474 +0100
-@@ -111,9 +111,10 @@
-         v = PyObject_AsFileDescriptor( o );
-         if (v == -1) goto finally;
- 
--#if defined(_MSC_VER)
-+#if defined(_MSC_VER) || defined(__MINGW32__)
-+/* FIXME: why not #ifdef Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE ? */
-         max = 0;                             /* not used for Win32 */
--#else  /* !_MSC_VER */
-+#else  /* !_MSC_VER & !__MINGW32__ */
-         if (!_PyIsSelectable_fd(v)) {
-             PyErr_SetString(PyExc_ValueError,
-                         "filedescriptor out of range in select()");
-@@ -121,7 +122,7 @@
-         }
-         if (v > max)
-             max = v;
--#endif /* _MSC_VER */
-+#endif /* _MSC_VER, __MINGW32__ */
-         FD_SET(v, set);
- 
-         /* add object and its file descriptor to the list */
-diff -urN a/Modules/Setup.config.in b/Modules/Setup.config.in
---- a/Modules/Setup.config.in	2012-04-10 00:07:33.000000000 +0100
-+++ b/Modules/Setup.config.in	2012-06-24 16:36:40.074817308 +0100
-@@ -3,11 +3,22 @@
- # The purpose of this file is to conditionally enable certain modules
- # based on configure-time options.
- 
-+# init system calls(posix/nt/...) for INITFUNC (used by makesetup)
-+@INITSYS@ posixmodule.c
-+
- # Threading
- @USE_THREAD_MODULE@thread threadmodule.c
- 
- # The signal module
- @USE_SIGNAL_MODULE@signal signalmodule.c
- 
-+# On win32 host(mingw build in MSYS environment) show that site.py
-+# fail to load if some modules are not build-in:
-+@BUILDIN_WIN32_MODULE@_functools _functoolsmodule.c	# Tools for working with functions and callable objects
-+@BUILDIN_WIN32_MODULE@operator operator.c	# operator.add() and similar goodies
-+@BUILDIN_WIN32_MODULE@_locale _localemodule.c	# -lintl
-+@BUILDIN_WIN32_MODULE@_winreg ../PC/_winreg.c
-+
-+
- # The rest of the modules previously listed in this file are built
- # by the setup.py script in Python 2.1 and later.
-diff -urN a/Modules/Setup.dist b/Modules/Setup.dist
---- a/Modules/Setup.dist	2012-04-10 00:07:33.000000000 +0100
-+++ b/Modules/Setup.dist	2012-06-24 16:36:40.074817308 +0100
-@@ -112,9 +112,10 @@
- # This only contains the minimal set of modules required to run the 
- # setup.py script in the root of the Python source tree.
- 
--posix posixmodule.c		# posix (UNIX) system calls
- errno errnomodule.c		# posix (UNIX) errno values
--pwd pwdmodule.c			# this is needed to find out the user's home dir
-+#FIXME: setup.py detect this module along with grp and spwd.
-+#FIXME: what about to comment ?
-+#pwd pwdmodule.c			# this is needed to find out the user's home dir
- 				# if $HOME is not set
- _sre _sre.c			# Fredrik Lundh's new regular expressions
- _codecs _codecsmodule.c		# access to the builtin codecs and codec registry
-diff -urN a/Modules/signalmodule.c b/Modules/signalmodule.c
---- a/Modules/signalmodule.c	2012-04-10 00:07:34.000000000 +0100
-+++ b/Modules/signalmodule.c	2012-06-24 16:36:40.078817335 +0100
-@@ -7,7 +7,7 @@
- #include "intrcheck.h"
- 
- #ifdef MS_WINDOWS
--#include <Windows.h>
-+#include <windows.h>
- #ifdef HAVE_PROCESS_H
- #include <process.h>
- #endif
-diff -urN a/Modules/socketmodule.c b/Modules/socketmodule.c
---- a/Modules/socketmodule.c	2012-04-10 00:07:34.000000000 +0100
-+++ b/Modules/socketmodule.c	2012-06-24 16:36:40.080817349 +0100
-@@ -91,6 +91,15 @@
- #endif
- 
- #include "Python.h"
-+#ifndef HAVE_GETPEERNAME
-+/* FIXME: see comments in configure.in. Also PC/pyconfig.h define it.
-+ * Since only this module use getpeername why don't remove declaration
-+ * from PC/pyconfig.h and define here if is defined MS_WIN32 ?
-+ */
-+#ifdef __MINGW32__
-+#  define HAVE_GETPEERNAME
-+#endif
-+#endif /* ndef HAVE_GETPEERNAME */
- #include "structmember.h"
- 
- #undef MAX
-@@ -312,6 +321,35 @@
-   /* Do not include addrinfo.h for MSVC7 or greater. 'addrinfo' and
-    * EAI_* constants are defined in (the already included) ws2tcpip.h.
-    */
-+#elif defined(__MINGW32__)
-+/* FIXME: getaddrinfo(HAVE_GETADDRINFO) depend from WINVER
-+   TODO: resolve later(see comments in pyport.h) */
-+#if 0
-+/* To use getaddrinfo/getnameinfo from runtime for version before 0x0501
-+   we has to define those functions (see below).
-+   In all cases mingw linker succeed to link binaries.
-+   If you enable this code the load of module will fail on w2k
-+   with message like this one:
-+   "The specified procedure could not be found" */
-+#  if (_WIN32_WINNT < 0x0501)
-+void WSAAPI freeaddrinfo (struct addrinfo*);
-+int WSAAPI getaddrinfo (const char*,const char*,const struct addrinfo*,
-+		        struct addrinfo**);
-+int WSAAPI getnameinfo(const struct sockaddr*,socklen_t,char*,DWORD,
-+		       char*,DWORD,int);
-+#  endif
-+#  define HAVE_GETADDRINFO
-+#  define HAVE_GETNAMEINFO
-+#else
-+#  if (_WIN32_WINNT < 0x0501)
-+   /* Internal implemetation that has to work on w2k and latest. */
-+#    define EAI_ADDRFAMILY
-+#    include "addrinfo.h"
-+#  else
-+#    define HAVE_GETADDRINFO
-+#    define HAVE_GETNAMEINFO
-+#  endif
-+#endif
- #else
- #  include "addrinfo.h"
- #endif
-@@ -349,6 +387,16 @@
- #if !defined(HAVE_GETADDRINFO)
- /* avoid clashes with the C library definition of the symbol. */
- #define getaddrinfo fake_getaddrinfo
-+#ifdef __MINGW32__
-+#ifdef gai_strerror
-+/* NOTE: Mingw w32api always define gai_strerror to gai_strerror{A|W}
-+   but getaddrinfo is defined if _WIN32_WINNT >= 0x0501.
-+   MSDN say that gai_strerror() exist for w95 and later and
-+   getaddrinfo()/getnameinfo() for wxp and later.
-+   Since we use fake function to suppress warnign we has to undef. */
-+#  undef gai_strerror
-+#endif
-+#endif /*def __MINGW32__*/
- #define gai_strerror fake_gai_strerror
- #define freeaddrinfo fake_freeaddrinfo
- #include "getaddrinfo.c"
-@@ -2912,7 +2960,31 @@
- Shut down the reading side of the socket (flag == SHUT_RD), the writing side\n\
- of the socket (flag == SHUT_WR), or both ends (flag == SHUT_RDWR).");
- 
-+#ifndef SIO_RCVALL
-+#ifdef __MINGW32__
-+/* MSDN: SIO_RCVALL defined on w2k and later */
-+/* note "Separate SDKs" required for w2k    */
-+/* 0x98000001 = _WSAIOW(IOC_VENDOR,1)       */
-+#  define SIO_RCVALL	0x98000001
-+#  define RCVALL_OFF	0
-+#  define RCVALL_ON	1
-+   /* NOTE: MSDN - this feature is not implemented */
-+#  define RCVALL_SOCKETLEVELONLY	2
-+
-+/* 0x98000004 = _WSAIOW(IOC_VENDOR,4) */
-+#  define SIO_KEEPALIVE_VALS	0x98000004
-+struct tcp_keepalive {
-+    u_long onoff;
-+    u_long keepalivetime;
-+    u_long keepaliveinterval;
-+};
-+#endif /* def __MINGW32__ */
-+#endif /* ndef SIO_RCVALL */
-+
- #if defined(MS_WINDOWS) && defined(SIO_RCVALL)
-+/* If isn't defined test_socket.py fail with:
-+AttributeError: type object '_socket.socket' has no attribute 'ioctl'
-+*/
- static PyObject*
- sock_ioctl(PySocketSockObject *s, PyObject *arg)
- {
-diff -urN a/Modules/socketmodule.h b/Modules/socketmodule.h
---- a/Modules/socketmodule.h	2012-04-10 00:07:34.000000000 +0100
-+++ b/Modules/socketmodule.h	2012-06-24 16:36:40.079817342 +0100
-@@ -13,6 +13,13 @@
- # endif
- 
- #else /* MS_WINDOWS */
-+#ifdef socklen_t
-+/* Configure script define to int on windows for GCC compiler.
-+   Avoid GCC 4.4+ error (two or more data types in declaration specifiers)
-+   as undef it first.
-+ */
-+# undef socklen_t
-+#endif
- # include <winsock2.h>
- # include <ws2tcpip.h>
- /* VC6 is shipped with old platform headers, and does not have MSTcpIP.h
-diff -urN a/Objects/fileobject.c b/Objects/fileobject.c
---- a/Objects/fileobject.c	2012-04-10 00:07:34.000000000 +0100
-+++ b/Objects/fileobject.c	2012-06-24 16:36:40.082817363 +0100
-@@ -9,9 +9,17 @@
- #endif /* HAVE_SYS_TYPES_H */
- 
- #ifdef MS_WINDOWS
-+#if !defined(__MINGW32__)
-+/* avoid 'warning: "fileno" redefined' */
- #define fileno _fileno
-+#endif
- /* can simulate truncate with Win32 API functions; see file_truncate */
-+#ifndef HAVE_FTRUNCATE
-+/* NOTE: autotool based build check and set it
-+   FIXME: why isn't defined in PC/pyconfig.h ?
-+ */
- #define HAVE_FTRUNCATE
-+#endif
- #define WIN32_LEAN_AND_MEAN
- #include <windows.h>
- #endif
-diff -urN a/PC/msvcrtmodule.c b/PC/msvcrtmodule.c
---- a/PC/msvcrtmodule.c	2012-04-10 00:07:35.000000000 +0100
-+++ b/PC/msvcrtmodule.c	2012-06-24 16:36:40.057817190 +0100
-@@ -22,6 +22,31 @@
- #include <conio.h>
- #include <sys/locking.h>
- 
-+#if defined(__MINGW32__)
-+#if __MSVCRT_VERSION__ >= 0x0700
-+# define _WCONIO_DEFINED
-+/* NOTE: Up to version ?.?? mingw don't define functions
-+ * listed below. Also it require module to be linked with
-+ * ms-vcrt at least verion 7.
-+ * To build with different runtimes see:
-+ *  http://www.mingw.org/wiki/HOWTO_Use_the_GCC_specs_file
-+ *
-+ * Also note that NT5.1(XP), shiped with msvcrt version 7.0,
-+ * contain all those functions, but library name is msvcrt.dll.
-+ * So if you like module to run on w2k as is you must define
-+ * appropriate __MSVCRT_VERSION__ .
-+ * If you like those functions even on w2k you must link
-+ * with appropriate runtime and to pack it in distributions.
-+ * This is what MSVC build do - it is build and packed
-+ * with version 9.0 of Microsoft C-runtime.
-+ */
-+_CRTIMP wint_t __cdecl __MINGW_NOTHROW	_getwch (void);
-+_CRTIMP wint_t __cdecl __MINGW_NOTHROW	_getwche (void);
-+_CRTIMP wint_t __cdecl __MINGW_NOTHROW	_putwch (wchar_t);
-+_CRTIMP wint_t __cdecl __MINGW_NOTHROW	_ungetwch(wint_t);
-+#endif /* __MSVCRT_VERSION__ >= 0x0700 */
-+#endif
-+
- #ifdef _MSC_VER
- #if _MSC_VER >= 1500 && _MSC_VER < 1600
- #include <crtassem.h>
-@@ -346,6 +371,7 @@
-     if (!PyArg_ParseTuple(args, "u:ungetwch", &ch))
-         return NULL;
- 
-+    /* FIXME: why _ungetch is called instead _ungetwch */
-     if (_ungetch(ch) == EOF)
-         return PyErr_SetFromErrno(PyExc_IOError);
-     Py_INCREF(Py_None);
-diff -urN a/PC/_winreg.c b/PC/_winreg.c
---- a/PC/_winreg.c	2012-04-10 00:07:35.000000000 +0100
-+++ b/PC/_winreg.c	2012-06-24 16:36:40.057817190 +0100
-@@ -17,6 +17,18 @@
- #include "malloc.h" /* for alloca */
- #include "windows.h"
- 
-+#if defined(__MINGW32__)
-+_CRTIMP size_t __cdecl __MINGW_NOTHROW _mbstrlen(const char *s);
-+#endif
-+
-+#if !defined(REG_LEGAL_CHANGE_FILTER)
-+#define REG_LEGAL_CHANGE_FILTER                 \
-+                (REG_NOTIFY_CHANGE_NAME          |\
-+                 REG_NOTIFY_CHANGE_ATTRIBUTES    |\
-+                 REG_NOTIFY_CHANGE_LAST_SET      |\
-+                 REG_NOTIFY_CHANGE_SECURITY)
-+#endif
-+
- static BOOL PyHKEY_AsHKEY(PyObject *ob, HKEY *pRes, BOOL bNoneOK);
- static PyObject *PyHKEY_FromHKEY(HKEY h);
- static BOOL PyHKEY_Close(PyObject *obHandle);
-@@ -1087,6 +1099,15 @@
- static PyObject *
- PyDeleteKeyEx(PyObject *self, PyObject *args)
- {
-+#ifndef KEY_WOW64_64KEY
-+/* KEY_WOW64_64KEY is defined for _WIN32_WINNT >= 0x0502,
-+  i.e. Windows Server 2003 with SP1, Windows XP with SP2
-+  and not supported on w2k
-+ */
-+    PyErr_SetString(PyExc_NotImplementedError,
-+                    "not implemented on this platform");
-+    return NULL;
-+#else /*def KEY_WOW64_64KEY*/
-     HKEY hKey;
-     PyObject *obKey;
-     HMODULE hMod;
-@@ -1122,6 +1143,7 @@
-         return PyErr_SetFromWindowsErrWithFunction(rc, "RegDeleteKeyEx");
-     Py_INCREF(Py_None);
-     return Py_None;
-+#endif
- }
- 
- static PyObject *
-diff -urN a/pyconfig.h.in b/pyconfig.h.in
---- a/pyconfig.h.in	2012-06-24 16:36:39.859815838 +0100
-+++ b/pyconfig.h.in	2012-06-24 16:36:40.073817301 +0100
-@@ -49,7 +49,7 @@
- /* Define to 1 if you have the `acosh' function. */
- #undef HAVE_ACOSH
- 
--/* struct addrinfo (netdb.h) */
-+/* struct addrinfo */
- #undef HAVE_ADDRINFO
- 
- /* Define to 1 if you have the `alarm' function. */
-@@ -888,6 +888,9 @@
- /* Define to 1 if you have the `wcscoll' function. */
- #undef HAVE_WCSCOLL
- 
-+/* Define to 1 if you have the <winsock2.h> header file. */
-+#undef HAVE_WINSOCK2_H
-+
- /* Define if tzset() actually switches the local timezone in a meaningful way.
-    */
- #undef HAVE_WORKING_TZSET
-@@ -915,6 +918,9 @@
- /* Define if mvwdelch in curses.h is an expression. */
- #undef MVWDELCH_IS_EXPRESSION
- 
-+/* Define to 1 if you want to use native NT threads */
-+#undef NT_THREADS
-+
- /* Define to the address where bug reports for this package should be sent. */
- #undef PACKAGE_BUGREPORT
- 
-diff -urN a/Python/dynload_win.c b/Python/dynload_win.c
---- a/Python/dynload_win.c	2012-04-10 00:07:35.000000000 +0100
-+++ b/Python/dynload_win.c	2012-06-24 16:36:40.066817253 +0100
-@@ -11,9 +11,11 @@
- #include "importdl.h"
- #include <windows.h>
- 
--// "activation context" magic - see dl_nt.c...
-+#ifdef Py_ENABLE_SHARED
-+/* "activation context" magic - see dl_nt.c... */
- extern ULONG_PTR _Py_ActivateActCtx();
- void _Py_DeactivateActCtx(ULONG_PTR cookie);
-+#endif
- 
- const struct filedescr _PyImport_DynLoadFiletab[] = {
- #ifdef _DEBUG
-@@ -25,6 +27,12 @@
- };
- 
- 
-+#if defined(__MINGW32__)
-+/* NOTE strcasecmp fail to compile with GCC for windows hosts
-+ * with  error: conflicting types for 'strcasecmp'
-+ */
-+#  define strcasecmp fake_strcasecmp
-+#endif
- /* Case insensitive string compare, to avoid any dependencies on particular
-    C RTL implementations */
- 
-@@ -190,11 +198,15 @@
-                             sizeof(pathbuf),
-                             pathbuf,
-                             &dummy)) {
-+#ifdef Py_ENABLE_SHARED
-             ULONG_PTR cookie = _Py_ActivateActCtx();
-+#endif
-             /* XXX This call doesn't exist in Windows CE */
-             hDLL = LoadLibraryEx(pathname, NULL,
-                                  LOAD_WITH_ALTERED_SEARCH_PATH);
-+#ifdef Py_ENABLE_SHARED
-             _Py_DeactivateActCtx(cookie);
-+#endif
-         }
- 
-         /* restore old error mode settings */
-diff -urN a/Python/fileblocks.c b/Python/fileblocks.c
---- a/Python/fileblocks.c	1970-01-01 01:00:00.000000000 +0100
-+++ b/Python/fileblocks.c	2012-06-24 16:36:40.067817260 +0100
-@@ -0,0 +1,17 @@
-+/*
-+-- Macro: AC_STRUCT_ST_BLOCKS
-+    If `struct stat' contains an `st_blocks' member, define
-+    `HAVE_STRUCT_STAT_ST_BLOCKS'.  Otherwise, require an `AC_LIBOBJ'
-+    replacement of `fileblocks'.
-+*/
-+
-+#if !HAVE_STRUCT_STAT_ST_BLOCKS
-+/* If necessary you may see gnulib for replacement function:
-+off_t st_blocks (off_t size)
-+You may found code available under GPL2 or GPL3.
-+*/
-+#else
-+/* This declaration is solely to ensure that after preprocessing
-+   this file is never empty.  */
-+typedef int textutils_fileblocks_unused;
-+#endif
-diff -urN a/Python/thread.c b/Python/thread.c
---- a/Python/thread.c	2012-04-10 00:07:35.000000000 +0100
-+++ b/Python/thread.c	2012-06-24 16:36:40.067817260 +0100
-@@ -7,6 +7,16 @@
- 
- #include "Python.h"
- 
-+#ifdef __MINGW32__
-+/* GCC 4.4+ (mingw) support posix threads!
-+  Note: macro __MINGW_GCC is defined for GCC 4.4+ but
-+  not for GCC 3.4.5 (last stable from 3.x )
-+  Instead to use __MINGW_GCC we will use more common
-+  __MINGW32__ to prevent case when in GCC 3.4.5 build
-+  envirionment is installed posix thread package.
-+ */
-+# undef HAVE_PTHREAD_H
-+#endif
- 
- #ifndef _POSIX_THREADS
- /* This means pthreads are not implemented in libc headers, hence the macro
-diff -urN a/setup.py b/setup.py
---- a/setup.py	2012-06-24 16:36:39.861815851 +0100
-+++ b/setup.py	2012-06-24 16:36:40.071817288 +0100
-@@ -24,7 +24,8 @@
-     host_platform = os.environ.get('HOST_OS')
-     if host_platform is None:
-         host_platform = sys.platform
--    for platform in ['cygwin', 'beos', 'darwin', 'atheos', 'osf1']:
-+    # NOTE: for mingw* host we cannot return 'win32' (see below)
-+    for platform in ['cygwin', 'mingw', 'beos', 'darwin', 'atheos', 'osf1']:
-         if host_platform.startswith(platform):
-             return platform
-     return host_platform
-@@ -33,8 +34,7 @@
- cross_compiling = (not os.environ.get('HOST_OS') is None)
- 
- 
--# Were we compiled --with-pydebug or with #define Py_DEBUG?
--COMPILED_WITH_PYDEBUG = hasattr(sys, 'gettotalrefcount')
-+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 = []
-@@ -181,7 +181,7 @@
-         # with Modules/ and adding Python's include directory to the path.
-         (srcdir,) = sysconfig.get_config_vars('srcdir')
-         if not srcdir:
--            # Maybe running on Windows but not using CYGWIN?
-+            # Maybe running on Windows but not using posix build?
-             raise ValueError("No source directory; cannot proceed.")
-         srcdir = os.path.abspath(srcdir)
-         moddirlist = [os.path.join(srcdir, 'Modules')]
-@@ -247,8 +247,38 @@
-         if compiler is not None:
-             (ccshared,cflags) = sysconfig.get_config_vars('CCSHARED','CFLAGS')
-             args['compiler_so'] = compiler + ' ' + ccshared + ' ' + cflags
-+
-+        # FIXME: Is next correct ?
-+        # To link modules we need LDSHARED passed to setup.py otherwise
-+        # distutils will use linker from build system if cross-compiling.
-+        linker_so = os.environ.get('LDSHARED')
-+        if linker_so is not None:
-+            args['linker_so'] = linker_so
-+
-         self.compiler.set_executables(**args)
- 
-+        if host_platform in ['mingw', 'win32']:
-+            # FIXME: best way to pass just build python library to the modules
-+            self.compiler.library_dirs.insert(0, '.')
-+            data = open('pyconfig.h').read()
-+            m = re.search(r"#s*define\s+Py_DEBUG\s+1\s*", data)
-+            if m is not None:
-+                self.compiler.libraries.append("python" + str(sysconfig.get_config_var('VERSION')) + "_d")
-+            else:
-+                self.compiler.libraries.append("python" + str(sysconfig.get_config_var('VERSION')))
-+
-+        if host_platform in ['mingw', 'win32']:
-+            # NOTE: See comment for SHLIBS in configure.in .
-+            # Although it look obsolete since setup.py add module
-+            # required libraries we will pass list too.
-+            # As example this will allow us to propage static
-+            # libraries like mingwex to modules.
-+            for lib in sysconfig.get_config_var('SHLIBS').split():
-+                if lib.startswith('-l'):
-+                    self.compiler.libraries.append(lib[2:])
-+                else:
-+                    self.compiler.libraries.append(lib)
-+
-         build_ext.build_extensions(self)
- 
-         longest = max([len(e.name) for e in self.extensions])
-@@ -432,6 +462,8 @@
-             # (PYTHONFRAMEWORK is set) to avoid # linking problems when
-             # building a framework with different architectures than
-             # the one that is currently installed (issue #7473)
-+            # NOTE: revision 25103:[ #420565 ] add search in sys.prefix
-+            # before current source tree !?!?!?! No comment!
-             add_dir_to_list(self.compiler.library_dirs,
-                             sysconfig.get_config_var("LIBDIR"))
-             add_dir_to_list(self.compiler.include_dirs,
-@@ -479,6 +511,7 @@
-             #   NOTE: using shlex.split would technically be more correct, but
-             # also gives a bootstrap problem. Let's hope nobody uses directories
-             # with whitespace in the name to store libraries.
-+            # FIXME: Why LDFLAGS again ?
-             cflags, ldflags = sysconfig.get_config_vars(
-                     'CFLAGS', 'LDFLAGS')
-             for item in cflags.split():
-@@ -491,7 +524,7 @@
- 
-         # Check for MacOS X, which doesn't need libm.a at all
-         math_libs = ['m']
--        if host_platform in ['darwin', 'beos']:
-+        if host_platform in ['darwin', 'beos', 'mingw', 'win32']:
-             math_libs = []
- 
-         # XXX Omitted modules: gl, pure, dl, SGI-specific modules
-@@ -535,14 +568,20 @@
-         # heapq
-         exts.append( Extension("_heapq", ["_heapqmodule.c"]) )
-         # operator.add() and similar goodies
--        exts.append( Extension('operator', ['operator.c']) )
-+        # On win32 host(mingw build in MSYS environment) show that site.py
-+        # fail to load if some modules are not build-in:
-+        if host_platform not in ['mingw', 'win32']:
-+            exts.append( Extension('operator', ['operator.c']) )
-         # Python 3.1 _io library
-         exts.append( Extension("_io",
-             ["_io/bufferedio.c", "_io/bytesio.c", "_io/fileio.c",
-              "_io/iobase.c", "_io/_iomodule.c", "_io/stringio.c", "_io/textio.c"],
--             depends=["_io/_iomodule.h"], include_dirs=["Modules/_io"]))
-+             depends=["_io/_iomodule.h"], include_dirs=[os.path.join(srcdir,"Modules/_io")]))
-         # _functools
--        exts.append( Extension("_functools", ["_functoolsmodule.c"]) )
-+        # On win32 host(mingw build in MSYS environment) show that site.py
-+        # fail to load if some modules are not build-in:
-+        if host_platform not in ['mingw', 'win32']:
-+            exts.append( Extension("_functools", ["_functoolsmodule.c"]) )
-         # _json speedups
-         exts.append( Extension("_json", ["_json.c"]) )
-         # Python C API test module
-@@ -568,7 +607,10 @@
-             locale_extra_link_args = []
- 
- 
--        exts.append( Extension('_locale', ['_localemodule.c'],
-+        # On win32 host(mingw build in MSYS environment) show that site.py
-+        # fail to load if some modules are not build-in:
-+        if host_platform not in ['mingw', 'win32']:
-+            exts.append( Extension('_locale', ['_localemodule.c'],
-                                libraries=locale_libs,
-                                extra_link_args=locale_extra_link_args) )
- 
-@@ -577,24 +619,35 @@
-         # supported...)
- 
-         # fcntl(2) and ioctl(2)
--        libs = []
--        if (config_h_vars.get('FLOCK_NEEDS_LIBBSD', False)):
--            # May be necessary on AIX for flock function
--            libs = ['bsd']
--        exts.append( Extension('fcntl', ['fcntlmodule.c'], libraries=libs) )
--        # pwd(3)
--        exts.append( Extension('pwd', ['pwdmodule.c']) )
--        # grp(3)
--        exts.append( Extension('grp', ['grpmodule.c']) )
--        # spwd, shadow passwords
--        if (config_h_vars.get('HAVE_GETSPNAM', False) or
--                config_h_vars.get('HAVE_GETSPENT', False)):
--            exts.append( Extension('spwd', ['spwdmodule.c']) )
-+        if host_platform not in ['mingw', 'win32']:
-+            libs = []
-+            if (config_h_vars.get('FLOCK_NEEDS_LIBBSD', False)):
-+                # May be necessary on AIX for flock function
-+                libs = ['bsd']
-+            exts.append( Extension('fcntl', ['fcntlmodule.c'], libraries=libs) )
-+        else:
-+            missing.append('fcntl')
-+        if host_platform not in ['mingw', 'win32']:
-+            # pwd(3)
-+            exts.append( Extension('pwd', ['pwdmodule.c']) )
-+            # grp(3)
-+            exts.append( Extension('grp', ['grpmodule.c']) )
-+            # spwd, shadow passwords
-+            if (config_h_vars.get('HAVE_GETSPNAM', False) or
-+                    config_h_vars.get('HAVE_GETSPENT', False)):
-+                exts.append( Extension('spwd', ['spwdmodule.c']) )
-+            else:
-+                missing.append('spwd')
-         else:
--            missing.append('spwd')
-+            missing.extend(['pwd', 'grp', 'spwd'])
- 
-         # select(2); not on ancient System V
--        exts.append( Extension('select', ['selectmodule.c']) )
-+        if host_platform in ['mingw', 'win32']:
-+            select_libs = ['ws2_32']
-+        else:
-+            select_libs = []
-+        exts.append( Extension('select', ['selectmodule.c'],
-+                               libraries=select_libs) )
- 
-         # Fred Drake's interface to the Python parser
-         exts.append( Extension('parser', ['parsermodule.c']) )
-@@ -610,8 +663,11 @@
-             missing.append('mmap')
- 
-         # Lance Ellinghaus's syslog module
--        # syslog daemon interface
--        exts.append( Extension('syslog', ['syslogmodule.c']) )
-+        if host_platform not in ['mingw', 'win32']:
-+            # syslog daemon interface
-+            exts.append( Extension('syslog', ['syslogmodule.c']) )
-+        else:
-+            missing.append('syslog')
- 
-         # George Neville-Neil's timing module:
-         # Deprecated in PEP 4 http://www.python.org/peps/pep-0004.html
-@@ -730,18 +786,25 @@
-             missing.append('readline')
- 
-         # crypt module.
--
--        if self.compiler.find_library_file(lib_dirs, 'crypt'):
--            libs = ['crypt']
-+        if host_platform not in ['mingw', 'win32']:
-+            if self.compiler.find_library_file(lib_dirs, 'crypt'):
-+                libs = ['crypt']
-+            else:
-+                libs = []
-+            exts.append( Extension('crypt', ['cryptmodule.c'], libraries=libs) )
-         else:
--            libs = []
--        exts.append( Extension('crypt', ['cryptmodule.c'], libraries=libs) )
-+            missing.append('crypt')
- 
-         # CSV files
-         exts.append( Extension('_csv', ['_csv.c']) )
- 
-         # socket(2)
-+        if host_platform in ['mingw', 'win32']:
-+            socket_libs = ['ws2_32']
-+        else:
-+            socket_libs = []
-         exts.append( Extension('_socket', ['socketmodule.c'],
-+                               libraries=socket_libs,
-                                depends = ['socketmodule.h']) )
-         # Detect SSL support for the socket module (via _ssl)
-         search_for_ssl_incs_in = [
-@@ -763,10 +826,13 @@
- 
-         if (ssl_incs is not None and
-             ssl_libs is not None):
-+            _ssl_libs = ['ssl', 'crypto']
-+            if host_platform in ['mingw', 'win32']:
-+                _ssl_libs.append('ws2_32')
-             exts.append( Extension('_ssl', ['_ssl.c'],
-                                    include_dirs = ssl_incs,
-                                    library_dirs = ssl_libs,
--                                   libraries = ['ssl', 'crypto'],
-+                                   libraries = _ssl_libs,
-                                    depends = ['socketmodule.h']), )
-         else:
-             missing.append('_ssl')
-@@ -802,14 +868,17 @@
-             if have_usable_openssl:
-                 # The _hashlib module wraps optimized implementations
-                 # of hash functions from the OpenSSL library.
-+                # NOTE: _hashlib require only OpenSSL crypto library !
-                 exts.append( Extension('_hashlib', ['_hashopenssl.c'],
-                                        include_dirs = ssl_incs,
-                                        library_dirs = ssl_libs,
--                                       libraries = ['ssl', 'crypto']) )
-+                                       libraries = ['crypto']) )
-             else:
-                 print ("warning: openssl 0x%08x is too old for _hashlib" %
-                        openssl_ver)
-                 missing.append('_hashlib')
-+        # NOTE: MSVC build alwais include _md5 and _sha modules
-+        # as build-in modules
-         if COMPILED_WITH_PYDEBUG or not have_usable_openssl:
-             # The _sha module implements the SHA1 hash algorithm.
-             exts.append( Extension('_sha', ['shamodule.c']) )
-@@ -845,6 +914,29 @@
-         min_db_ver = (4, 1)
-         db_setup_debug = False   # verbose debug prints from this script?
- 
-+        # Modules with some Windows dependencies:
-+        if host_platform in ['mingw', 'win32']:
-+            srcdir = sysconfig.get_config_var('srcdir')
-+            pc_srcdir = os.path.abspath(os.path.join(srcdir, 'PC'))
-+
-+            exts.append( Extension('msvcrt', [os.path.join(pc_srcdir, p)
-+                for p in ['msvcrtmodule.c']]) )
-+
-+            exts.append( Extension('_msi', [os.path.join(pc_srcdir, p)
-+                for p in ['_msi.c']]) )
-+
-+            exts.append( Extension('_subprocess', [os.path.join(pc_srcdir, p)
-+                for p in ['_subprocess.c']]) )
-+
-+            # On win32 host(mingw build in MSYS environment) show that site.py
-+            # fail to load if some modules are not build-in:
-+            #exts.append( Extension('_winreg', [os.path.join(pc_srcdir, p)
-+            #    for p in ['_winreg.c']]) )
-+
-+            exts.append( Extension('winsound', [os.path.join(pc_srcdir, p)
-+                for p in ['winsound.c']],
-+                libraries=['winmm']) )
-+
-         def allow_db_ver(db_ver):
-             """Returns a boolean if the given BerkeleyDB version is acceptable.
- 
-@@ -1115,6 +1207,7 @@
-                 '_sqlite/util.c', ]
- 
-             sqlite_defines = []
-+            #NOTE: don't add mingw here
-             if host_platform != "win32":
-                 sqlite_defines.append(('MODULE_NAME', '"sqlite3"'))
-             else:
-@@ -1253,7 +1346,8 @@
-                 missing.append('dbm')
- 
-         # Anthony Baxter's gdbm module.  GNU dbm(3) will require -lgdbm:
--        if ('gdbm' in dbm_order and
-+        if (host_platform not in ['mingw', 'win32'] and
-+            'gdbm' in dbm_order and
-             self.compiler.find_library_file(lib_dirs, 'gdbm')):
-             exts.append( Extension('gdbm', ['gdbmmodule.c'],
-                                    libraries = ['gdbm'] ) )
-@@ -1261,7 +1355,7 @@
-             missing.append('gdbm')
- 
-         # Unix-only modules
--        if host_platform not in ['win32']:
-+        if host_platform not in ['mingw', 'win32']:
-             # Steen Lumholt's termios module
-             exts.append( Extension('termios', ['termios.c']) )
-             # Jeremy Hylton's rlimit interface
-@@ -1451,7 +1545,7 @@
-         if sys.maxint == 0x7fffffff:
-             # This requires sizeof(int) == sizeof(long) == sizeof(char*)
-             dl_inc = find_file('dlfcn.h', [], inc_dirs)
--            if (dl_inc is not None) and (host_platform not in ['atheos']):
-+            if (dl_inc is not None) and (host_platform not in ['atheos', 'mingw', 'win32']):
-                 exts.append( Extension('dl', ['dlmodule.c']) )
-             else:
-                 missing.append('dl')
-@@ -1462,7 +1556,7 @@
-         self.detect_ctypes(inc_dirs, lib_dirs)
- 
-         # Richard Oudkerk's multiprocessing module
--        if host_platform == 'win32':
-+        if host_platform in ['mingw', 'win32']:
-             macros = dict()
-             libraries = ['ws2_32']
- 
-@@ -1490,9 +1584,11 @@
- 
-         else:                                   # Linux and other unices
-             macros = dict()
--            libraries = ['rt']
-+            # NOTE: line below is never used before to add MINGW platform
-+            #libraries = ['rt']
-+            libraries = []
- 
--        if host_platform == 'win32':
-+        if host_platform in ['mingw', 'win32']:
-             multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c',
-                                      '_multiprocessing/semaphore.c',
-                                      '_multiprocessing/pipe_connection.c',
-@@ -1509,7 +1605,9 @@
-                 multiprocessing_srcs.append('_multiprocessing/semaphore.c')
- 
-         if sysconfig.get_config_var('WITH_THREAD'):
-+            #FIXME: why above set libraries aren't used ?
-             exts.append ( Extension('_multiprocessing', multiprocessing_srcs,
-+                                    libraries=libraries,
-                                     define_macros=macros.items(),
-                                     include_dirs=["Modules/_multiprocessing"]))
-         else:
-@@ -1550,6 +1648,7 @@
-         if host_platform == 'darwin' and ("--disable-toolbox-glue" not in
-                 sysconfig.get_config_var("CONFIG_ARGS")):
- 
-+            #FIXME: next fail in cross-compilation environment
-             if int(os.uname()[2].split('.')[0]) >= 8:
-                 # We're on Mac OS X 10.4 or later, the compiler should
-                 # support '-Wno-deprecated-declarations'. This will
-@@ -1795,6 +1894,9 @@
-         if host_platform == 'sunos5':
-             include_dirs.append('/usr/openwin/include')
-             added_lib_dirs.append('/usr/openwin/lib')
-+        elif host_platform in ['mingw', 'win32']:
-+            # mingw&win32 don't use X11 headers and libraries
-+            pass
-         elif os.path.exists('/usr/X11R6/include'):
-             include_dirs.append('/usr/X11R6/include')
-             added_lib_dirs.append('/usr/X11R6/lib64')
-@@ -1830,8 +1932,8 @@
-         if host_platform in ['aix3', 'aix4']:
-             libs.append('ld')
- 
--        # Finally, link with the X11 libraries (not appropriate on cygwin)
--        if host_platform != "cygwin":
-+        # Finally, link with the X11 libraries (not appropriate on cygwin, mingw)
-+        if not host_platform in ['cygwin', 'mingw', 'win32']:
-             libs.append('X11')
- 
-         ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
-@@ -1882,6 +1984,38 @@
-         return True
- 
-     def configure_ctypes(self, ext):
-+        if host_platform in ['mingw', 'win32']:
-+            # win32 platform use own sources and includes
-+            # from Modules/_ctypes/libffi_msvc/
-+            srcdir = sysconfig.get_config_var('srcdir')
-+
-+            ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules',
-+                                         '_ctypes'))
-+            sources = [os.path.join(ffi_srcdir, p)
-+                for p in ['malloc_closure.c',
-+                         ]]
-+            ext.sources.extend(sources)
-+
-+            ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules',
-+                                         '_ctypes', 'libffi_msvc'))
-+            #FIXME: _ctypes/libffi_msvc/win64.asm ?
-+            sources = [os.path.join(ffi_srcdir, p)
-+                for p in ['ffi.c',
-+                          'prep_cif.c',
-+                          'win32.S',
-+                         ]]
-+            # NOTE: issue2942 don't resolve problem with assembler code.
-+            # It seems to me that python refuse to build an extension
-+            # if exist a source with unknown suffix.
-+            self.compiler.src_extensions.append('.s')
-+            self.compiler.src_extensions.append('.S')
-+            ext.include_dirs.append(ffi_srcdir)
-+            ext.sources.extend(sources)
-+            ext.libraries.extend(['ole32', 'oleaut32', 'uuid'])
-+            #AdditionalOptions="/EXPORT:DllGetClassObject,PRIVATE /EXPORT:DllCanUnloadNow,PRIVATE"
-+            ext.export_symbols.extend(['DllGetClassObject PRIVATE',
-+                                       'DllCanUnloadNow PRIVATE'])
-+            return True
-         if not self.use_system_libffi:
-             if host_platform == 'darwin':
-                 return self.configure_ctypes_darwin(ext)
-@@ -1934,6 +2068,11 @@
-                                fficonfig['ffi_sources'])
-             ext.include_dirs.extend(include_dirs)
-             ext.extra_compile_args.extend(extra_compile_args)
-+            if host_platform in ['mingw', 'win32']:
-+                ext.libraries.extend(['ole32', 'oleaut32', 'uuid'])
-+                #AdditionalOptions="/EXPORT:DllGetClassObject,PRIVATE /EXPORT:DllCanUnloadNow,PRIVATE"
-+                ext.export_symbols.extend(['DllGetClassObject PRIVATE',
-+                                           'DllCanUnloadNow PRIVATE'])
-         return True
- 
-     def detect_ctypes(self, inc_dirs, lib_dirs):
-@@ -1977,7 +2116,12 @@
-                         libraries=[],
-                         sources=sources,
-                         depends=depends)
-+        if host_platform in ['mingw', 'win32']:
-+            ctypes_test_libs = ['oleaut32']
-+        else:
-+            ctypes_test_libs = []
-         ext_test = Extension('_ctypes_test',
-+                             libraries=ctypes_test_libs,
-                              sources=['_ctypes/_ctypes_test.c'])
-         self.extensions.extend([ext, ext_test])
- 
diff --git a/build/tools/toolchain-patches/python/Python-2.7.3/0002-MINGW-use-posix-getpath.patch b/build/tools/toolchain-patches/python/Python-2.7.3/0002-MINGW-use-posix-getpath.patch
deleted file mode 100644
index 529c883..0000000
--- a/build/tools/toolchain-patches/python/Python-2.7.3/0002-MINGW-use-posix-getpath.patch
+++ /dev/null
@@ -1,460 +0,0 @@
-diff -urN a/configure.in b/configure.in
---- a/configure.in	2012-06-30 13:55:03.293615455 +0100
-+++ b/configure.in	2012-06-30 13:55:21.634756095 +0100
-@@ -522,6 +522,27 @@
- fi
- AC_MSG_RESULT($MACHDEP)
- 
-+# Windows uses ; to separate paths, everything else uses :
-+AC_MSG_CHECKING(DELIM)
-+DELIM=:
-+if test "$MACHDEP" = "win"
-+then
-+	DELIM=\;
-+fi
-+AC_MSG_RESULT([$DELIM])
-+AC_SUBST(DELIM)
-+
-+# MSYS make uses a 'virtual' VPATH, but getpath.c uses
-+# GetModuleFileNameW (replacing \ with /). This allows the user to
-+# define the 'actual 'real' value. Note, it should contain / not \,
-+# which is what is returned by "pwd -W".
-+AC_ARG_VAR(MSYSVPATH,
-+           For MSYS, allows specifying the real VPATH. Use / not \)
-+if test -z "$MSYSVPATH"; then
-+    MSYSVPATH=$srcdir
-+fi
-+AC_SUBST(MSYSVPATH)
-+
- AC_MSG_CHECKING([for init system calls])
- AC_SUBST(INITSYS)
- case $host in
-@@ -2965,7 +2986,7 @@
- AC_MSG_CHECKING(MACHDEP_OBJS)
- case $host in
-   *-*-mingw*)
--    extra_machdep_objs="PC/dl_nt.o PC/getpathp.o PC/import_nt.o"
-+    extra_machdep_objs="PC/dl_nt.o Modules/getpath.o PC/import_nt.o"
-     ;;
- esac
- if test -z "$MACHDEP_OBJS"
-@@ -4170,6 +4191,28 @@
- # check for endianness
- AC_C_BIGENDIAN
- 
-+# REPARSE_DATA_BUFFER is in winnt.h on mingw32 and (unusably) ddk/ntifs.h on mingw64.
-+case $host in
-+  *-*-mingw*)
-+AC_CACHE_CHECK([if struct REPARSE_DATA_BUFFER is in winnt.h],
-+[ac_cv_struct_reparse_data_buffer_in_winnt_h],
-+  [AC_COMPILE_IFELSE(
-+    [AC_LANG_PROGRAM(
-+      [#include <windows.h>
-+       #include <winnt.h>],
-+      [REPARSE_DATA_BUFFER rdb],
-+    )],
-+    [ac_cv_struct_reparse_data_buffer_in_winnt_h=yes],
-+    [ac_cv_struct_reparse_data_buffer_in_winnt_h=no]
-+  )
-+])
-+if test "x${ac_cv_struct_reparse_data_buffer_in_winnt_h}" = xyes; then
-+  AC_DEFINE([REPARSE_DATA_BUFFER_IN_WINNT], [], [REPARSE_DATA_BUFFER in winnt.h])
-+  AC_SUBST(REPARSE_DATA_BUFFER_IN_WINNT)
-+fi
-+  ;;
-+esac
-+
- # Check whether right shifting a negative integer extends the sign bit
- # or fills with zeros (like the Cray J90, according to Tim Peters).
- AC_MSG_CHECKING(whether right shift extends the sign bit)
-@@ -4706,7 +4749,8 @@
-     # FIXME: why windows builds don't use PC/frozen_dllmain.o ?
-     PYTHON_OBJS_FROZENMAIN=""
-     # default sys.path calculations for windows platforms
--    MODULE_GETPATH=PC/getpathp.o
-+    # MODULE_GETPATH=PC/getpathp.o
-+    MODULE_GETPATH=Modules/getpath.o
-     ;;
- esac
- 
-diff -urN a/Include/osdefs.h b/Include/osdefs.h
---- a/Include/osdefs.h	2012-04-10 00:07:29.000000000 +0100
-+++ b/Include/osdefs.h	2012-06-30 13:55:21.636756112 +0100
-@@ -10,7 +10,7 @@
- /* Mod by chrish: QNX has WATCOM, but isn't DOS */
- #if !defined(__QNX__)
- #if defined(MS_WINDOWS) || defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__DJGPP__) || defined(PYOS_OS2)
--#if defined(PYOS_OS2) && defined(PYCC_GCC)
-+#if (defined(PYOS_OS2) && defined(PYCC_GCC)) || defined(__MINGW32__)
- #define MAXPATHLEN 260
- #define SEP '/'
- #define ALTSEP '\\'
-diff -urN a/Lib/distutils/cygwinccompiler.py b/Lib/distutils/cygwinccompiler.py
---- a/Lib/distutils/cygwinccompiler.py	2012-06-30 13:55:03.298615492 +0100
-+++ b/Lib/distutils/cygwinccompiler.py	2012-06-30 13:55:21.636756112 +0100
-@@ -55,6 +55,7 @@
- from distutils.file_util import write_file
- from distutils.errors import DistutilsExecError, CompileError, UnknownFileError
- from distutils import log
-+from subprocess import Popen, PIPE
- 
- def get_msvcr():
-     """Include the appropriate MSVC runtime library if Python was built
-@@ -442,7 +443,13 @@
-     from distutils.spawn import find_executable
-     import re
- 
--    gcc_exe = find_executable('gcc')
-+    gcc_exe = os.environ.get('CC') or find_executable('gcc')
-+    ld_exe = find_executable('ld')
-+    out = Popen(gcc_exe+' --print-prog-name ld', shell=True, stdout=PIPE).stdout
-+    try:
-+        ld_exe = str(out.read()).strip()
-+    finally:
-+        out.close()
-     if gcc_exe:
-         out = os.popen(gcc_exe + ' -dumpversion','r')
-         out_string = out.read()
-@@ -454,7 +461,6 @@
-             gcc_version = None
-     else:
-         gcc_version = None
--    ld_exe = find_executable('ld')
-     if ld_exe:
-         out = os.popen(ld_exe + ' -v','r')
-         out_string = out.read()
-@@ -466,7 +472,7 @@
-             ld_version = None
-     else:
-         ld_version = None
--    dllwrap_exe = find_executable('dllwrap')
-+    dllwrap_exe = os.environ.get('DLLWRAP') or find_executable('dllwrap')
-     if dllwrap_exe:
-         out = os.popen(dllwrap_exe + ' --version','r')
-         out_string = out.read()
-diff -urN a/Lib/plat-generic/regen b/Lib/plat-generic/regen
---- a/Lib/plat-generic/regen	2012-04-10 00:07:30.000000000 +0100
-+++ b/Lib/plat-generic/regen	2012-06-30 13:55:21.636756112 +0100
-@@ -1,3 +1,9 @@
- #! /bin/sh
- set -v
--python$EXE ../../Tools/scripts/h2py.py -i '(u_long)' /usr/include/netinet/in.h
-+if [ -n $1 ]; then
-+    CCINSTALL=$($1 -print-search-dirs | head -1 | cut -d' ' -f2)
-+    REGENHEADER=$CCINSTALL/include/stddef.h
-+else
-+    REGENHEADER=/usr/include/netinet/in.h
-+fi
-+python$EXE ../../Tools/scripts/h2py.py -i '(u_long)' $REGENHEADER
-diff -urN a/Makefile.pre.in b/Makefile.pre.in
---- a/Makefile.pre.in	2012-06-30 13:55:03.303615532 +0100
-+++ b/Makefile.pre.in	2012-06-30 14:02:09.315869117 +0100
-@@ -27,6 +27,7 @@
- VERSION=	@VERSION@
- srcdir=		@srcdir@
- VPATH=		@srcdir@
-+MSYSVPATH=	@MSYSVPATH@
- 
- CC=		@CC@
- CXX=		@CXX@
-@@ -78,7 +79,8 @@
- # C flags used for building the interpreter object files
- PY_CFLAGS=	$(CFLAGS) $(CPPFLAGS) $(CFLAGSFORSHARED) -DPy_BUILD_CORE
- 
--
-+# ; on Windows otherwise :
-+DELIM=		@DELIM@
- # Machine-dependent subdirectories
- MACHDEP=	@MACHDEP@
- 
-@@ -541,7 +543,7 @@
- 		-DPREFIX='"$(prefix)"' \
- 		-DEXEC_PREFIX='"$(exec_prefix)"' \
- 		-DVERSION='"$(VERSION)"' \
--		-DVPATH='"$(VPATH)"' \
-+		-DVPATH='"$(MSYSVPATH)"' \
- 		-o $@ $(srcdir)/Modules/getpath.c
- 
- # default sys.path calculations for windows platforms
-@@ -838,6 +840,7 @@
- 	if test -f $(LDLIBRARY); then \
- 		if test -n "$(DLLLIBRARY)" ; then \
- 			$(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \
-+			mkdir -p $(DESTDIR)$(LIBPL); $(INSTALL_SHARED) $(LDLIBRARY)  $(DESTDIR)$(LIBPL); \
- 		else \
- 			$(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \
- 			if test $(LDLIBRARY) != $(INSTSONAME); then \
-@@ -982,7 +985,7 @@
- 	export PYTHONPATH; PYTHONPATH="`pwd`/Lib"; \
- 	export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \
- 	export EXE; EXE="$(BUILDEXE)"; \
--	cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen
-+	cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen $(CC)
- 
- python-config: $(srcdir)/Misc/python-config.in
- 	# Substitution happens here, as the completely-expanded BINDIR
-diff -urN a/Modules/getpath.c b/Modules/getpath.c
---- a/Modules/getpath.c	2012-04-10 00:07:34.000000000 +0100
-+++ b/Modules/getpath.c	2012-06-30 13:55:21.637756119 +0100
-@@ -10,6 +10,10 @@
- #include <mach-o/dyld.h>
- #endif
- 
-+#ifdef MS_WINDOWS
-+#include <windows.h>
-+#endif
-+
- /* Search in some common locations for the associated Python libraries.
-  *
-  * Two directories must be found, the platform independent directory
-@@ -128,6 +132,10 @@
- static char prefix[MAXPATHLEN+1];
- static char exec_prefix[MAXPATHLEN+1];
- static char progpath[MAXPATHLEN+1];
-+#ifdef MS_WINDOWS
-+static char dllpath[MAXPATHLEN+1];
-+extern HANDLE PyWin_DLLhModule;
-+#endif
- static char *module_search_path = NULL;
- static char lib_python[] = "lib/python" VERSION;
- 
-@@ -137,7 +145,7 @@
-     size_t i = strlen(dir);
-     while (i > 0 && dir[i] != SEP)
-         --i;
--    dir[i] = '\0';
-+    dir[i] = 0;
- }
- 
- 
-@@ -208,7 +216,11 @@
- joinpath(char *buffer, char *stuff)
- {
-     size_t n, k;
-+#ifdef MS_WINDOWS
-+    if (stuff[0] == SEP || (stuff[0] != 0 && stuff[1] == L':'))
-+#else
-     if (stuff[0] == SEP)
-+#endif
-         n = 0;
-     else {
-         n = strlen(buffer);
-@@ -229,7 +241,11 @@
- static void
- copy_absolute(char *path, char *p)
- {
-+#ifdef MS_WINDOWS
-+    if (p[0] == SEP || (p[0] != 0 && p[1] == ':'))
-+#else
-     if (p[0] == SEP)
-+#endif
-         strcpy(path, p);
-     else {
-         if (!getcwd(path, MAXPATHLEN)) {
-@@ -249,7 +265,11 @@
- {
-     char buffer[MAXPATHLEN + 1];
- 
-+#ifdef MS_WINDOWS
-+    if (path[0] == SEP || (path[0] != 0 && path[1] == L':'))
-+#else
-     if (path[0] == SEP)
-+#endif
-         return;
-     copy_absolute(buffer, path);
-     strcpy(path, buffer);
-@@ -367,6 +387,35 @@
- }
- 
- 
-+#ifdef MS_WINDOWS
-+/* Calculates dllpath and progpath, replacing \\ with / */
-+int GetWindowsModulePaths()
-+{
-+    int result = 0;
-+    wchar_t* seps;
-+    result = GetModuleFileNameW(NULL, progpath, MAXPATHLEN);
-+    seps = wcschr(progpath, L'\\');
-+    while(seps) {
-+        *seps = L'/';
-+        seps = wcschr(seps, L'\\');
-+    }
-+    dllpath[0] = 0;
-+#ifdef Py_ENABLE_SHARED
-+    if (PyWin_DLLhModule) {
-+        if((GetModuleFileNameW(PyWin_DLLhModule, dllpath, MAXPATHLEN) > 0)) {
-+            result = 1;
-+            seps = wcschr(dllpath, L'\\');
-+            while(seps) {
-+                *seps = L'/';
-+                seps = wcschr(seps, L'\\');
-+            }
-+        }
-+    }
-+#endif
-+    return result;
-+}
-+#endif /* MS_WINDOWS */
-+
- static void
- calculate_path(void)
- {
-@@ -418,6 +467,10 @@
-      else if(0 == _NSGetExecutablePath(progpath, &nsexeclength) && progpath[0] == SEP)
-        ;
- #endif /* __APPLE__ */
-+#ifdef MS_WINDOWS
-+    else if(GetWindowsModulePaths()) {
-+    }
-+#endif /* MS_WINDOWS */
-         else if (path) {
-                 while (1) {
-                         char *delim = strchr(path, DELIM);
-@@ -445,7 +498,11 @@
-         }
-         else
-                 progpath[0] = '\0';
-+#ifdef MS_WINDOWS
-+        if (progpath[0] != '\0' && progpath[0] != SEP && progpath[1] != ':')
-+#else
-         if (progpath[0] != SEP && progpath[0] != '\0')
-+#endif
-                 absolutize(progpath);
-         strncpy(argv0_path, progpath, MAXPATHLEN);
-         argv0_path[MAXPATHLEN] = '\0';
-@@ -691,8 +748,6 @@
-     return progpath;
- }
- 
--
- #ifdef __cplusplus
- }
- #endif
--
-diff -urN a/Modules/posixmodule.c b/Modules/posixmodule.c
---- a/Modules/posixmodule.c	2012-06-30 13:55:03.309615577 +0100
-+++ b/Modules/posixmodule.c	2012-06-30 13:55:21.638756126 +0100
-@@ -2180,7 +2180,7 @@
-             Py_END_ALLOW_THREADS
-             /* FindNextFile sets error to ERROR_NO_MORE_FILES if
-                it got to the end of the directory. */
--            if (!result && GetLastError() != ERROR_NO_MORE_FILES) {
-+            if (!result && GetLastError() != 0 && GetLastError() != ERROR_NO_MORE_FILES) {
-                 Py_DECREF(d);
-                 win32_error_unicode("FindNextFileW", wnamebuf);
-                 FindClose(hFindFile);
-@@ -2248,7 +2248,7 @@
-         Py_END_ALLOW_THREADS
-         /* FindNextFile sets error to ERROR_NO_MORE_FILES if
-            it got to the end of the directory. */
--        if (!result && GetLastError() != ERROR_NO_MORE_FILES) {
-+        if (!result && GetLastError() != 0 && GetLastError() != ERROR_NO_MORE_FILES) {
-             Py_DECREF(d);
-             win32_error("FindNextFile", namebuf);
-             FindClose(hFindFile);
-diff -urN a/Modules/Setup.config.in b/Modules/Setup.config.in
---- a/Modules/Setup.config.in	2012-06-30 13:55:03.310615585 +0100
-+++ b/Modules/Setup.config.in	2012-06-30 13:55:21.639756133 +0100
-@@ -18,6 +18,9 @@
- @BUILDIN_WIN32_MODULE@operator operator.c	# operator.add() and similar goodies
- @BUILDIN_WIN32_MODULE@_locale _localemodule.c	# -lintl
- @BUILDIN_WIN32_MODULE@_winreg ../PC/_winreg.c
-+@BUILDIN_WIN32_MODULE@time timemodule.c
-+@BUILDIN_WIN32_MODULE@_subprocess ../PC/_subprocess.c
-+@BUILDIN_WIN32_MODULE@msvcrt ../PC/msvcrtmodule.c
- 
- 
- # The rest of the modules previously listed in this file are built
-diff -urN a/Modules/Setup.dist b/Modules/Setup.dist
---- a/Modules/Setup.dist	2012-06-30 13:55:03.311615593 +0100
-+++ b/Modules/Setup.dist	2012-06-30 13:55:21.639756133 +0100
-@@ -84,14 +84,14 @@
- # Empty since this is now just the runtime prefix.
- DESTPATH=
- 
--# Site specific path components -- should begin with : if non-empty
-+# Site specific path components -- should begin with $(DELIM) if non-empty
- SITEPATH=
- 
- # Standard path components for test modules
- TESTPATH=
- 
- # Path components for machine- or system-dependent modules and shared libraries
--MACHDEPPATH=:plat-$(MACHDEP)
-+MACHDEPPATH=$(DELIM)plat-$(MACHDEP)
- EXTRAMACHDEPPATH=
- 
- # Path component for the Tkinter-related modules
-diff -urN a/Modules/socketmodule.h b/Modules/socketmodule.h
---- a/Modules/socketmodule.h	2012-06-30 13:55:03.312615601 +0100
-+++ b/Modules/socketmodule.h	2012-06-30 13:55:21.639756133 +0100
-@@ -28,7 +28,7 @@
-  * I use SIO_GET_MULTICAST_FILTER to detect a decent SDK.
-  */
- # ifdef SIO_GET_MULTICAST_FILTER
--#  include <MSTcpIP.h> /* for SIO_RCVALL */
-+#  include <mstcpip.h> /* for SIO_RCVALL */
- #  define HAVE_ADDRINFO
- #  define HAVE_SOCKADDR_STORAGE
- #  define HAVE_GETADDRINFO
-diff -urN a/Parser/metagrammar.c b/Parser/metagrammar.c
---- a/Parser/metagrammar.c	2012-04-10 00:07:35.000000000 +0100
-+++ b/Parser/metagrammar.c	2012-06-30 13:55:21.639756133 +0100
-@@ -139,7 +139,7 @@
-     {7, 0},
-     {8, 0},
- };
--static grammar _PyParser_Grammar = {
-+static grammar _PyParser_MetaGrammar = {
-     6,
-     dfas,
-     {19, labels},
-@@ -149,7 +149,7 @@
- grammar *
- meta_grammar(void)
- {
--    return &_PyParser_Grammar;
-+    return &_PyParser_MetaGrammar;
- }
- 
- grammar *
-diff -urN a/Python/pythonrun.c b/Python/pythonrun.c
---- a/Python/pythonrun.c	2012-04-10 00:07:35.000000000 +0100
-+++ b/Python/pythonrun.c	2012-06-30 13:55:21.640756141 +0100
-@@ -18,6 +18,9 @@
- #include "eval.h"
- #include "marshal.h"
- #include "abstract.h"
-+#ifdef __MINGW32__
-+#include "osdefs.h"
-+#endif
- 
- #ifdef HAVE_SIGNAL_H
- #include <signal.h>
-@@ -666,6 +669,13 @@
- void
- Py_SetProgramName(char *pn)
- {
-+#ifdef __MINGW32__
-+    char* seps = strchr(pn, ALTSEP);
-+    while(seps) {
-+        *seps = SEP;
-+        seps = strchr(seps, ALTSEP);
-+    }
-+#endif
-     if (pn && *pn)
-         progname = pn;
- }
-diff -urN a/setup.py b/setup.py
---- a/setup.py	2012-06-30 13:55:03.315615622 +0100
-+++ b/setup.py	2012-06-30 13:55:21.641756149 +0100
-@@ -923,7 +923,8 @@
-                 for p in ['msvcrtmodule.c']]) )
- 
-             exts.append( Extension('_msi', [os.path.join(pc_srcdir, p)
--                for p in ['_msi.c']]) )
-+                for p in ['_msi.c']],
-+                libraries=['msi','cabinet','rpcrt4']) ) # To link with lib(msi|cabinet|rpcrt4).a
- 
-             exts.append( Extension('_subprocess', [os.path.join(pc_srcdir, p)
-                 for p in ['_subprocess.c']]) )
diff --git a/build/tools/toolchain-patches/python/Python-2.7.3/0003-DARWIN-CROSS.patch b/build/tools/toolchain-patches/python/Python-2.7.3/0003-DARWIN-CROSS.patch
deleted file mode 100644
index e4c5388..0000000
--- a/build/tools/toolchain-patches/python/Python-2.7.3/0003-DARWIN-CROSS.patch
+++ /dev/null
@@ -1,127 +0,0 @@
-diff -urN a/configure.in b/configure.in
---- a/configure.in	2012-06-24 18:27:16.477514024 +0100
-+++ b/configure.in	2012-06-24 18:40:43.391973689 +0100
-@@ -5,7 +5,7 @@
- # Set VERSION so we only need to edit in one place (i.e., here)
- m4_define(PYTHON_VERSION, 2.7)
- 
--AC_PREREQ(2.65)
-+AC_PREREQ(2.61)
- 
- AC_REVISION($Revision$)
- AC_INIT(python, PYTHON_VERSION, http://bugs.python.org/)
-@@ -230,6 +230,9 @@
- 		fi
- 		enable_framework=
- 		;;
-+	*-*-darwin*)
-+		ac_sys_system=Darwin
-+		;;
- 	*)
- 		PYTHONFRAMEWORKPREFIX="${enableval}"
- 		PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
-@@ -371,6 +374,11 @@
- 	dnl - but an item in PYTHONPATH is "plat-win" !!! oops
- 	MACHDEP=win
- 	;;
-+    *-*-darwin*)
-+	ac_sys_system=Darwin
-+	ac_sys_version=11
-+    MACHDEP=darwin
-+    ;;
- 	esac
- fi
- if test -z "$MACHDEP"
-@@ -1211,7 +1219,7 @@
- 	    # Calculate the right deployment target for this build.
- 	    #
- 	    cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
--	    if test ${cur_target} '>' 10.2; then
-+	    if test ${cur_target} > 10.2; then
- 		    cur_target=10.3
- 		    if test ${enable_universalsdk}; then
- 			    if test "${UNIVERSAL_ARCHS}" = "all"; then
-@@ -1231,7 +1239,7 @@
- 				    cur_target='10.5'
- 			    fi
- 		    else
--			    if test `/usr/bin/arch` = "i386"; then
-+			    if test "$($OSX_ARCH_PROG)" = "i386"; then
- 				    # On Intel macs default to a deployment
- 				    # target of 10.4, that's the first OSX
- 				    # release with Intel support.
-@@ -1851,6 +1859,15 @@
-     ;;
- esac
- 
-+if test "x$cross_compiling" = xyes; then
-+    function arch
-+    {
-+        echo i386
-+    }
-+    OSX_ARCH_PROG=arch
-+else
-+    OSX_ARCH_PROG=/usr/bin/arch
-+fi
- 
- ARCH_RUN_32BIT=""
- AC_SUBST(LIBTOOL_CRUFT)
-@@ -1860,7 +1877,7 @@
-     if test "${enable_universalsdk}"; then
- 	    :
-     else
--        LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
-+        LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only $($OSX_ARCH_PROG)"
-     fi
-     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
-     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
-@@ -1885,7 +1902,7 @@
-     ]])],[ac_osx_32bit=yes],[ac_osx_32bit=no],[ac_osx_32bit=yes])
-     
-     if test "${ac_osx_32bit}" = "yes"; then
--    	case `/usr/bin/arch` in
-+    	case $($OSX_ARCH_PROG) in
-     	i386) 
-     		MACOSX_DEFAULT_ARCH="i386" 
-     		;;
-@@ -1897,7 +1914,7 @@
-     		;;
-     	esac
-     else
--    	case `/usr/bin/arch` in
-+    	case $($OSX_ARCH_PROG) in
-     	i386) 
-     		MACOSX_DEFAULT_ARCH="x86_64" 
-     		;;
-@@ -1936,8 +1953,8 @@
- fi
- 
- AC_MSG_CHECKING(for dyld)
--case $ac_sys_system/$ac_sys_release in
--  Darwin/*)
-+case $host in
-+  *darwin*)
-   	AC_DEFINE(WITH_DYLD, 1, 
-         [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
-          dynamic linker (dyld) instead of the old-style (NextStep) dynamic
-@@ -2061,7 +2078,7 @@
- 		# Use -undefined dynamic_lookup whenever possible (10.3 and later).
- 		# This allows an extension to be used in any Python
- 
--		if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
-+		if test ${MACOSX_DEPLOYMENT_TARGET} > 10.2
- 		then
- 			if test "${enable_universalsdk}"; then
- 				LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
-diff -urN a/Modules/parsermodule.c b/Modules/parsermodule.c
---- a/Modules/parsermodule.c	2012-04-10 00:07:34.000000000 +0100
-+++ b/Modules/parsermodule.c	2012-06-24 18:27:16.738515771 +0100
-@@ -39,7 +39,7 @@
- #include "ast.h"
- #include "pyarena.h"
- 
--extern grammar _PyParser_Grammar; /* From graminit.c */
-+PyAPI_DATA(grammar) _PyParser_Grammar; /* From graminit.c */
- 
- #ifdef lint
- #include <note.h>
diff --git a/build/tools/toolchain-patches/python/Python-2.7.3/0004-MINGW-FIXES-sysconfig-like-posix.patch b/build/tools/toolchain-patches/python/Python-2.7.3/0004-MINGW-FIXES-sysconfig-like-posix.patch
deleted file mode 100644
index a67ba20..0000000
--- a/build/tools/toolchain-patches/python/Python-2.7.3/0004-MINGW-FIXES-sysconfig-like-posix.patch
+++ /dev/null
@@ -1,78 +0,0 @@
-diff -urN a/configure.in b/configure.in
---- a/configure.in	2012-06-30 12:58:46.040253992 +0100
-+++ b/configure.in	2012-06-30 12:59:01.148368383 +0100
-@@ -86,8 +86,8 @@
- AC_SUBST(VERSION)
- case $host in
-   *-*-mingw*)
--  dnl To be compatible with MSVC build.
--VERSION=`echo PYTHON_VERSION | sed -e 's|\.||g'`
-+  dnl To be *incompatible* with MSVC build!
-+VERSION=PYTHON_VERSION
-   ;;
-   *)
- VERSION=PYTHON_VERSION
-diff -urN a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py
---- a/Lib/distutils/sysconfig.py	2012-06-30 12:58:46.010253764 +0100
-+++ b/Lib/distutils/sysconfig.py	2012-06-30 13:06:42.525821215 +0100
-@@ -115,7 +115,7 @@
-     if prefix is None:
-         prefix = plat_specific and EXEC_PREFIX or PREFIX
- 
--    if os.name == "posix":
-+    if os.name == "posix" or sys.version.find('GCC') >= 0:
-         libpython = os.path.join(prefix,
-                                  "lib", "python" + get_python_version())
-         if standard_lib:
-diff -urN a/Lib/sysconfig.py b/Lib/sysconfig.py
---- a/Lib/sysconfig.py	2012-06-30 12:58:46.013253788 +0100
-+++ b/Lib/sysconfig.py	2012-06-30 12:59:01.150368397 +0100
-@@ -35,13 +35,13 @@
-         'data'   : '{base}',
-         },
-     'nt': {
--        'stdlib': '{base}/Lib',
--        'platstdlib': '{base}/Lib',
--        'purelib': '{base}/Lib/site-packages',
--        'platlib': '{base}/Lib/site-packages',
--        'include': '{base}/Include',
--        'platinclude': '{base}/Include',
--        'scripts': '{base}/Scripts',
-+        'stdlib': '{base}/lib/python{py_version_short}',
-+        'platstdlib': '{base}/lib/python{py_version_short}',
-+        'purelib': '{base}/lib/python{py_version_short}',
-+        'platlib': '{base}/lib/python{py_version_short}',
-+        'include': '{base}/include/python{py_version_short}',
-+        'platinclude': '{base}/include/python{py_version_short}',
-+        'scripts': '{base}/bin',
-         'data'   : '{base}',
-         },
-     'os2': {
-@@ -64,12 +64,12 @@
-         'data'   : '{userbase}',
-         },
-     'nt_user': {
--        'stdlib': '{userbase}/Python{py_version_nodot}',
--        'platstdlib': '{userbase}/Python{py_version_nodot}',
--        'purelib': '{userbase}/Python{py_version_nodot}/site-packages',
--        'platlib': '{userbase}/Python{py_version_nodot}/site-packages',
--        'include': '{userbase}/Python{py_version_nodot}/Include',
--        'scripts': '{userbase}/Scripts',
-+        'stdlib': '{userbase}/lib/python{py_version_short}',
-+        'platstdlib': '{userbase}/lib/python{py_version_short}',
-+        'purelib': '{userbase}/lib/python{py_version_short}',
-+        'platlib': '{userbase}/lib/python{py_version_short}',
-+        'include': '{userbase}/include/python{py_version_short}',
-+        'scripts': '{userbase}/bin',
-         'data'   : '{userbase}',
-         },
-     'posix_user': {
-@@ -319,7 +319,7 @@
-     vars['INCLUDEPY'] = get_path('include')
-     vars['SO'] = '.pyd'
-     vars['EXE'] = '.exe'
--    vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT
-+    vars['VERSION'] = _PY_VERSION_SHORT
-     vars['BINDIR'] = os.path.dirname(abspath(sys.executable))
- 
- #
diff --git a/build/tools/toolchain-patches/python/Python-2.7.3/0005-MINGW-pdcurses_ISPAD.patch b/build/tools/toolchain-patches/python/Python-2.7.3/0005-MINGW-pdcurses_ISPAD.patch
deleted file mode 100644
index 5b8bf19..0000000
--- a/build/tools/toolchain-patches/python/Python-2.7.3/0005-MINGW-pdcurses_ISPAD.patch
+++ /dev/null
@@ -1,15 +0,0 @@
-diff -urN a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c
---- a/Modules/_cursesmodule.c	2012-04-10 00:07:33.000000000 +0100
-+++ b/Modules/_cursesmodule.c	2012-06-24 20:58:36.644526289 +0100
-@@ -91,6 +91,11 @@
-   set_form_sub set_form_term set_form_userptr set_form_win
-   set_max_field set_new_page unpost_form
- 
-+#ifdef __MINGW32__
-+#ifndef _ISPAD
-+#define _ISPAD 0x10
-+#endif
-+#endif
- 
- */
- 
diff --git a/build/tools/toolchain-patches/python/Python-2.7.3/0006-MINGW-static-tcltk.patch b/build/tools/toolchain-patches/python/Python-2.7.3/0006-MINGW-static-tcltk.patch
deleted file mode 100644
index 003bc2b..0000000
--- a/build/tools/toolchain-patches/python/Python-2.7.3/0006-MINGW-static-tcltk.patch
+++ /dev/null
@@ -1,73 +0,0 @@
-diff -urN a/setup.py b/setup.py
---- a/setup.py	2012-06-24 21:00:44.404442659 +0100
-+++ b/setup.py	2012-06-24 21:00:44.607444094 +0100
-@@ -504,7 +504,7 @@
-         if host_platform in ['osf1', 'unixware7', 'openunix8']:
-             lib_dirs += ['/usr/ccs/lib']
- 
--        if host_platform == 'darwin':
-+        if host_platform in ['darwin', 'mingw', 'win32']:
-             # This should work on any unixy platform ;-)
-             # If the user has bothered specifying additional -I and -L flags
-             # in OPT and LDFLAGS we might as well use them here.
-@@ -514,6 +514,8 @@
-             # FIXME: Why LDFLAGS again ?
-             cflags, ldflags = sysconfig.get_config_vars(
-                     'CFLAGS', 'LDFLAGS')
-+            cflags = cflags + ' ' + ('',os.environ.get('CC'))[os.environ.get('CC') != None]
-+            ldflags = ldflags + ' ' + ('',os.environ.get('LDSHARED'))[os.environ.get('LDSHARED') != None]
-             for item in cflags.split():
-                 if item.startswith('-I'):
-                     inc_dirs.append(item[2:])
-@@ -1851,14 +1853,19 @@
-         # The versions with dots are used on Unix, and the versions without
-         # dots on Windows, for detection by cygwin.
-         tcllib = tklib = tcl_includes = tk_includes = None
--        for version in ['8.6', '86', '8.5', '85', '8.4', '84', '8.3', '83',
--                        '8.2', '82', '8.1', '81', '8.0', '80']:
--            tklib = self.compiler.find_library_file(lib_dirs,
--                                                        'tk' + version)
--            tcllib = self.compiler.find_library_file(lib_dirs,
--                                                         'tcl' + version)
--            if tklib and tcllib:
--                # Exit the loop when we've found the Tcl/Tk libraries
-+        tcltk_suffix = None
-+        for suffix in ['', 's']:
-+            for version in ['8.6', '86', '8.5', '85', '8.4', '84', '8.3', '83',
-+                            '8.2', '82', '8.1', '81', '8.0', '80', '']:
-+                tklib = self.compiler.find_library_file(lib_dirs,
-+                                                            'tk' + version + suffix)
-+                tcllib = self.compiler.find_library_file(lib_dirs,
-+                                                             'tcl' + version + suffix)
-+                if tklib and tcllib:
-+                    # Exit the loop when we've found the Tcl/Tk libraries
-+                    tcltk_suffix = suffix
-+                    break
-+            if tcltk_suffix != None:
-                 break
- 
-         # Now check for the header files
-@@ -1927,15 +1934,21 @@
-             libs.append('BLT')
- 
-         # Add the Tcl/Tk libraries
--        libs.append('tk'+ version)
--        libs.append('tcl'+ version)
-+        libs.append('tk'+ version + tcltk_suffix)
-+        libs.append('tcl'+ version + tcltk_suffix)
-+        if host_platform in ['mingw', 'win32']:
-+            for winlib in ['ws2_32','gdi32','comctl32','comdlg32','imm32','uuid','oleaut32','ole32']:
-+                libs.append( winlib )
- 
-         if host_platform in ['aix3', 'aix4']:
-             libs.append('ld')
- 
-         # Finally, link with the X11 libraries (not appropriate on cygwin, mingw)
-+        # ...on those platforms, define STATIC_BUILD if linking to static tcl/tk.
-         if not host_platform in ['cygwin', 'mingw', 'win32']:
-             libs.append('X11')
-+        elif tcllib.endswith('s.a'):
-+            defs.append( ('STATIC_BUILD',1) )
- 
-         ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
-                         define_macros=[('WITH_APPINIT', 1)] + defs,
diff --git a/build/tools/toolchain-patches/python/Python-2.7.3/0007-MINGW-x86_64-size_t-format-specifier-pid_t.patch b/build/tools/toolchain-patches/python/Python-2.7.3/0007-MINGW-x86_64-size_t-format-specifier-pid_t.patch
deleted file mode 100644
index 654179e..0000000
--- a/build/tools/toolchain-patches/python/Python-2.7.3/0007-MINGW-x86_64-size_t-format-specifier-pid_t.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff -urN a/Include/pyport.h b/Include/pyport.h
---- a/Include/pyport.h	2012-06-24 21:07:38.061405267 +0100
-+++ b/Include/pyport.h	2012-06-24 21:07:38.294405980 +0100
-@@ -190,9 +190,11 @@
- /* Smallest negative value of type Py_ssize_t. */
- #define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1)
- 
-+/*
- #if SIZEOF_PID_T > SIZEOF_LONG
- #   error "Python doesn't support sizeof(pid_t) > sizeof(long)"
- #endif
-+*/
- 
- /* PY_FORMAT_SIZE_T is a platform-specific modifier for use in a printf
-  * format to convert an argument with the width of a size_t or Py_ssize_t.
-@@ -224,6 +226,8 @@
- #       define PY_FORMAT_SIZE_T "l"
- #   elif defined(MS_WINDOWS)
- #       define PY_FORMAT_SIZE_T "I"
-+#   elif defined(__MINGW32__) && defined(__USE_MINGW_ANSI_STDIO)
-+#       define PY_FORMAT_SIZE_T "z"
- #   else
- #       error "This platform's pyconfig.h needs to define PY_FORMAT_SIZE_T"
- #   endif
diff --git a/build/tools/toolchain-patches/python/Python-2.7.3/0008-Python-disable-dbm.patch b/build/tools/toolchain-patches/python/Python-2.7.3/0008-Python-disable-dbm.patch
deleted file mode 100644
index 31eeeeb..0000000
--- a/build/tools/toolchain-patches/python/Python-2.7.3/0008-Python-disable-dbm.patch
+++ /dev/null
@@ -1,89 +0,0 @@
---- a/setup.py	2012-06-25 09:30:17.882413273 +0100
-+++ b/setup.py	2012-06-25 09:30:23.282464119 +0100
-@@ -1277,86 +1277,6 @@
-         else:
-             missing.append('bsddb185')
- 
--        dbm_order = ['gdbm']
--        # The standard Unix dbm module:
--        if host_platform not in ['cygwin']:
--            config_args = [arg.strip("'")
--                           for arg in sysconfig.get_config_var("CONFIG_ARGS").split()]
--            dbm_args = [arg for arg in config_args
--                        if arg.startswith('--with-dbmliborder=')]
--            if dbm_args:
--                dbm_order = [arg.split('=')[-1] for arg in dbm_args][-1].split(":")
--            else:
--                dbm_order = "ndbm:gdbm:bdb".split(":")
--            dbmext = None
--            for cand in dbm_order:
--                if cand == "ndbm":
--                    if find_file("ndbm.h", inc_dirs, []) is not None:
--                        # Some systems have -lndbm, others don't
--                        if self.compiler.find_library_file(lib_dirs,
--                                                               'ndbm'):
--                            ndbm_libs = ['ndbm']
--                        else:
--                            ndbm_libs = []
--                        print "building dbm using ndbm"
--                        dbmext = Extension('dbm', ['dbmmodule.c'],
--                                           define_macros=[
--                                               ('HAVE_NDBM_H',None),
--                                               ],
--                                           libraries=ndbm_libs)
--                        break
--
--                elif cand == "gdbm":
--                    if self.compiler.find_library_file(lib_dirs, 'gdbm'):
--                        gdbm_libs = ['gdbm']
--                        if self.compiler.find_library_file(lib_dirs,
--                                                               'gdbm_compat'):
--                            gdbm_libs.append('gdbm_compat')
--                        if find_file("gdbm/ndbm.h", inc_dirs, []) is not None:
--                            print "building dbm using gdbm"
--                            dbmext = Extension(
--                                'dbm', ['dbmmodule.c'],
--                                define_macros=[
--                                    ('HAVE_GDBM_NDBM_H', None),
--                                    ],
--                                libraries = gdbm_libs)
--                            break
--                        if find_file("gdbm-ndbm.h", inc_dirs, []) is not None:
--                            print "building dbm using gdbm"
--                            dbmext = Extension(
--                                'dbm', ['dbmmodule.c'],
--                                define_macros=[
--                                    ('HAVE_GDBM_DASH_NDBM_H', None),
--                                    ],
--                                libraries = gdbm_libs)
--                            break
--                elif cand == "bdb":
--                    if db_incs is not None:
--                        print "building dbm using bdb"
--                        dbmext = Extension('dbm', ['dbmmodule.c'],
--                                           library_dirs=dblib_dir,
--                                           runtime_library_dirs=dblib_dir,
--                                           include_dirs=db_incs,
--                                           define_macros=[
--                                               ('HAVE_BERKDB_H', None),
--                                               ('DB_DBM_HSEARCH', None),
--                                               ],
--                                           libraries=dblibs)
--                        break
--            if dbmext is not None:
--                exts.append(dbmext)
--            else:
--                missing.append('dbm')
--
--        # Anthony Baxter's gdbm module.  GNU dbm(3) will require -lgdbm:
--        if (host_platform not in ['mingw', 'win32'] and
--            'gdbm' in dbm_order and
--            self.compiler.find_library_file(lib_dirs, 'gdbm')):
--            exts.append( Extension('gdbm', ['gdbmmodule.c'],
--                                   libraries = ['gdbm'] ) )
--        else:
--            missing.append('gdbm')
--
-         # Unix-only modules
-         if host_platform not in ['mingw', 'win32']:
-             # Steen Lumholt's termios module
diff --git a/build/tools/toolchain-patches/python/Python-2.7.3/0009-Disable-Grammar-dependency-on-pgen-executable.patch b/build/tools/toolchain-patches/python/Python-2.7.3/0009-Disable-Grammar-dependency-on-pgen-executable.patch
deleted file mode 100644
index 917925c..0000000
--- a/build/tools/toolchain-patches/python/Python-2.7.3/0009-Disable-Grammar-dependency-on-pgen-executable.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -urN a/Makefile.pre.in b/Makefile.pre.in
---- a/Makefile.pre.in	2012-06-25 22:56:29.837375577 +0100
-+++ b/Makefile.pre.in	2012-06-25 22:57:01.293606243 +0100
-@@ -557,7 +557,7 @@
- # FIXME: next may fail in cross-compilation environment
- # Use a stamp file to prevent make -j invoking pgen twice
- $(GRAMMAR_H) $(GRAMMAR_C): Parser/pgen.stamp
--Parser/pgen.stamp: $(PGEN) $(GRAMMAR_INPUT)
-+Parser/pgen.stamp: $(GRAMMAR_INPUT)
- 		-@$(INSTALL) -d Include
- 		$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
- 		-touch Parser/pgen.stamp
diff --git a/build/tools/toolchain-patches/python/Python-2.7.3/0010-add-python-config-sh.patch b/build/tools/toolchain-patches/python/Python-2.7.3/0010-add-python-config-sh.patch
deleted file mode 100644
index c497156..0000000
--- a/build/tools/toolchain-patches/python/Python-2.7.3/0010-add-python-config-sh.patch
+++ /dev/null
@@ -1,110 +0,0 @@
-diff -urN a/configure.in b/configure.in
---- a/configure.in	2012-06-30 01:06:22.326507693 +0100
-+++ b/configure.in	2012-06-30 01:06:22.717510412 +0100
-@@ -4807,6 +4807,6 @@
- 
- mv config.c Modules])
- AC_CONFIG_FILES([setup_info])
--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
-diff -urN a/Makefile.pre.in b/Makefile.pre.in
---- a/Makefile.pre.in	2012-06-30 01:06:22.339507783 +0100
-+++ b/Makefile.pre.in	2012-06-30 01:06:22.718510418 +0100
-@@ -987,10 +987,12 @@
- 	export EXE; EXE="$(BUILDEXE)"; \
- 	cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen $(CC)
- 
--python-config: $(srcdir)/Misc/python-config.in
-+python-config: $(srcdir)/Misc/python-config.in $(srcdir)/Misc/python-config.sh.in
- 	# 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
-+	# Replace makefile compat. variable references with shell script compat. ones
-+	sed -e "s,\$$(\([A-Za-z0-9_]*\)),\$$\{\1\},g" < Misc/python-config.sh >python-config.sh
- 
- # Install the include files
- INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)
-@@ -1049,6 +1051,8 @@
- 	$(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
-+	$(INSTALL_SCRIPT) python-config.sh $(DESTDIR)$(BINDIR)/python-config.sh
-+
- 	rm python-config
- 	@if [ -s Modules/python.exp -a \
- 		"`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \
-diff -urN a/Misc/python-config.sh.in b/Misc/python-config.sh.in
---- a/Misc/python-config.sh.in	1970-01-01 01:00:00.000000000 +0100
-+++ b/Misc/python-config.sh.in	2012-06-30 01:09:08.311648080 +0100
-@@ -0,0 +1,69 @@
-+#!/bin/sh
-+
-+exit_with_usage ()
-+{
-+    echo "Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--help"
-+    exit 1
-+}
-+
-+prefix="@prefix@"
-+exec_prefix="@exec_prefix@"
-+includedir="@includedir@"
-+VERSION="@VERSION@"
-+#libdir="@libdir@"
-+libdir=$prefix/lib/python$VERSION/config
-+LIBM="@LIBM@"
-+LIBC="@LIBC@"
-+SYSLIBS="$LIBM $LIBC"
-+LIBS="@LIBS@ $SYSLIBS -lpython$VERSION"
-+ABIFLAGS="@ABIFLAGS@"
-+BASECFLAGS="@BASECFLAGS@"
-+CFLAGS="@CFLAGS@"
-+LDLIBRARY="@LDLIBRARY@"
-+LINKFORSHARED="@LINKFORSHARED@"
-+OPT="@OPT@"
-+
-+for ARG in $*
-+do
-+    case $ARG in
-+        --prefix)
-+            echo $prefix
-+            exit 0
-+        ;;
-+        --exec-prefix)
-+            echo $exec_prefix
-+            exit 0
-+        ;;
-+        --includes)
-+            echo -I$includedir/python$VERSION
-+            exit 0
-+        ;;
-+        --libs)
-+            echo $LIBS
-+            exit 0
-+        ;;
-+        --cflags)
-+            echo -I$includedir/python$VERSION $BASECFLAGS $CFLAGS $OPT
-+            exit 0
-+        ;;
-+        --ldflags)
-+        # I'm not handling the case of not Py_ENABLE_SHARED here.
-+        # As there's no AC_SUBST for Py_ENABLE_SHARED (though I should just
-+        # add that to be honest with you!)
-+        # From python-config there's:
-+        # if not getvar('Py_ENABLE_SHARED'):
-+        #     libs.insert(0, '-L' + getvar('LIBPL'))
-+        #     libs.extend(getvar('LINKFORSHARED').split())
-+            echo -L$libdir $LIBS $LINKFORSHARED
-+            exit 0
-+        ;;
-+        *.py)
-+        # configuring GDB uses:
-+        # ${python_prog} ${srcdir}/python/python-config.py --includes
-+        # so skip any .py files passed as arguments.
-+        ;;
-+        *)
-+            exit_with_usage
-+        ;;
-+esac
-+done
diff --git a/build/tools/toolchain-patches/python/Python-2.7.3/0011-re-configure-d.patch b/build/tools/toolchain-patches/python/Python-2.7.3/0011-re-configure-d.patch
deleted file mode 100644
index 064f854..0000000
--- a/build/tools/toolchain-patches/python/Python-2.7.3/0011-re-configure-d.patch
+++ /dev/null
@@ -1,1617 +0,0 @@
-diff -urN a/configure b/configure
---- a/configure	2012-04-10 00:07:36.000000000 +0100
-+++ b/configure	2012-07-04 23:52:44.000000000 +0100
-@@ -597,7 +597,12 @@
- 
- ac_subst_vars='LTLIBOBJS
- SRCDIRS
-+MODULE_GETPATH
-+PYTHON_OBJS_FROZENMAIN
-+PYMOD_BUILDOPT
- THREADHEADERS
-+READLINE_LIBS
-+REPARSE_DATA_BUFFER_IN_WINNT
- UNICODE_OBJS
- LIBC
- LIBM
-@@ -611,6 +616,7 @@
- MACHDEP_OBJS
- DYNLOADFILE
- DLINCLDIR
-+BUILDIN_WIN32_MODULE
- THREADOBJ
- LDLAST
- USE_THREAD_MODULE
-@@ -641,6 +647,7 @@
- HGVERSION
- SVNVERSION
- ARFLAGS
-+ac_ct_AR
- AR
- RANLIB
- GNULD
-@@ -669,8 +676,13 @@
- CONFIGURE_MACOSX_DEPLOYMENT_TARGET
- EXTRAMACHDEPPATH
- EXTRAPLATDIR
-+INITSYS
-+MSYSVPATH
-+DELIM
- SGI_ABI
- MACHDEP
-+HOST_OS
-+HOST_CPU
- FRAMEWORKINSTALLAPPSPREFIX
- FRAMEWORKUNIXTOOLSPREFIX
- FRAMEWORKALTINSTALLLAST
-@@ -688,6 +700,18 @@
- CONFIG_ARGS
- SOVERSION
- VERSION
-+SYSPYTHON
-+LN_S
-+CROSS_OFF
-+CROSS_ON
-+host_os
-+host_vendor
-+host_cpu
-+host
-+build_os
-+build_vendor
-+build_cpu
-+build
- target_alias
- host_alias
- build_alias
-@@ -764,6 +788,7 @@
-       ac_precious_vars='build_alias
- host_alias
- target_alias
-+MSYSVPATH
- CC
- CFLAGS
- LDFLAGS
-@@ -1368,6 +1393,10 @@
- _ACEOF
- 
-   cat <<\_ACEOF
-+
-+System types:
-+  --build=BUILD     configure for building on BUILD [guessed]
-+  --host=HOST       cross-compile to build programs to run on HOST [BUILD]
- _ACEOF
- fi
- 
-@@ -1435,6 +1464,7 @@
-   --with-libc=STRING      C library
- 
- Some influential environment variables:
-+  MSYSVPATH   For MSYS
-   CC          C compiler command
-   CFLAGS      C compiler flags
-   LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
-@@ -2692,6 +2722,106 @@
- 
- ac_config_headers="$ac_config_headers pyconfig.h"
- 
-+ac_aux_dir=
-+for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
-+  if test -f "$ac_dir/install-sh"; then
-+    ac_aux_dir=$ac_dir
-+    ac_install_sh="$ac_aux_dir/install-sh -c"
-+    break
-+  elif test -f "$ac_dir/install.sh"; then
-+    ac_aux_dir=$ac_dir
-+    ac_install_sh="$ac_aux_dir/install.sh -c"
-+    break
-+  elif test -f "$ac_dir/shtool"; then
-+    ac_aux_dir=$ac_dir
-+    ac_install_sh="$ac_aux_dir/shtool install -c"
-+    break
-+  fi
-+done
-+if test -z "$ac_aux_dir"; then
-+  as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
-+fi
-+
-+# These three variables are undocumented and unsupported,
-+# and are intended to be withdrawn in a future Autoconf release.
-+# They can cause serious problems if a builder's source tree is in a directory
-+# whose full name contains unusual characters.
-+ac_config_guess="$SHELL $ac_aux_dir/config.guess"  # Please don't use this var.
-+ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.
-+ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
-+
-+
-+# Make sure we can run config.sub.
-+$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
-+  as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
-+
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
-+$as_echo_n "checking build system type... " >&6; }
-+if test "${ac_cv_build+set}" = set; then :
-+  $as_echo_n "(cached) " >&6
-+else
-+  ac_build_alias=$build_alias
-+test "x$ac_build_alias" = x &&
-+  ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
-+test "x$ac_build_alias" = x &&
-+  as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
-+ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
-+  as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
-+
-+fi
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
-+$as_echo "$ac_cv_build" >&6; }
-+case $ac_cv_build in
-+*-*-*) ;;
-+*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
-+esac
-+build=$ac_cv_build
-+ac_save_IFS=$IFS; IFS='-'
-+set x $ac_cv_build
-+shift
-+build_cpu=$1
-+build_vendor=$2
-+shift; shift
-+# Remember, the first character of IFS is used to create $*,
-+# except with old shells:
-+build_os=$*
-+IFS=$ac_save_IFS
-+case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
-+
-+
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
-+$as_echo_n "checking host system type... " >&6; }
-+if test "${ac_cv_host+set}" = set; then :
-+  $as_echo_n "(cached) " >&6
-+else
-+  if test "x$host_alias" = x; then
-+  ac_cv_host=$ac_cv_build
-+else
-+  ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
-+    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
-+fi
-+
-+fi
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
-+$as_echo "$ac_cv_host" >&6; }
-+case $ac_cv_host in
-+*-*-*) ;;
-+*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
-+esac
-+host=$ac_cv_host
-+ac_save_IFS=$IFS; IFS='-'
-+set x $ac_cv_host
-+shift
-+host_cpu=$1
-+host_vendor=$2
-+shift; shift
-+# Remember, the first character of IFS is used to create $*,
-+# except with old shells:
-+host_os=$*
-+IFS=$ac_save_IFS
-+case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
-+
-+
- 
- 
- if test "$prefix" != "/"; then
-@@ -2707,8 +2837,95 @@
- rm confdefs.h
- mv confdefs.h.new confdefs.h
- 
-+if test "x$cross_compiling" = xyes; then
-+  CROSS_ON=''
-+  CROSS_OFF='#'
-+else
-+  CROSS_ON='#'
-+  CROSS_OFF=''
-+fi
-+
-+
-+
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
-+$as_echo_n "checking whether ln -s works... " >&6; }
-+LN_S=$as_ln_s
-+if test "$LN_S" = "ln -s"; then
-+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-+$as_echo "yes" >&6; }
-+else
-+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5
-+$as_echo "no, using $LN_S" >&6; }
-+fi
-+
-+if test "x$cross_compiling" = xyes; then
-+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cross-compilation is incomplete" >&5
-+$as_echo "$as_me: WARNING: cross-compilation is incomplete" >&2;}
-+
-+      # Extract the first word of "python", so it can be a program name with args.
-+set dummy python; ac_word=$2
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+$as_echo_n "checking for $ac_word... " >&6; }
-+if test "${ac_cv_path_SYSPYTHON+set}" = set; then :
-+  $as_echo_n "(cached) " >&6
-+else
-+  case $SYSPYTHON in
-+  [\\/]* | ?:[\\/]*)
-+  ac_cv_path_SYSPYTHON="$SYSPYTHON" # Let the user override the test with a path.
-+  ;;
-+  *)
-+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-+as_dummy="$PATH:/usr/local/bin
-+  "
-+for as_dir in $as_dummy
-+do
-+  IFS=$as_save_IFS
-+  test -z "$as_dir" && as_dir=.
-+    for ac_exec_ext in '' $ac_executable_extensions; do
-+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-+    ac_cv_path_SYSPYTHON="$as_dir/$ac_word$ac_exec_ext"
-+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+    break 2
-+  fi
-+done
-+  done
-+IFS=$as_save_IFS
-+
-+  test -z "$ac_cv_path_SYSPYTHON" && ac_cv_path_SYSPYTHON="none"
-+  ;;
-+esac
-+fi
-+SYSPYTHON=$ac_cv_path_SYSPYTHON
-+if test -n "$SYSPYTHON"; then
-+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SYSPYTHON" >&5
-+$as_echo "$SYSPYTHON" >&6; }
-+else
-+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-+$as_echo "no" >&6; }
-+fi
-+
-+
-+  if test "x$SYSPYTHON" = xnone; then
-+    as_fn_error $? "python program is required in cross-compilation environment" "$LINENO" 5
-+  fi
-+  SYSPYOSNAME=`${SYSPYTHON} -c "import os; print os.name"`
-+  case $SYSPYOSNAME in
-+  posix)
-+                                    rm -f syspython
-+    ${LN_S} ${SYSPYTHON} syspython
-+    SYSPYTHON=./syspython
-+  esac
-+fi
- 
-+
-+case $host in
-+  *-*-mingw*)
-+  VERSION=2.7
-+  ;;
-+  *)
- VERSION=2.7
-+  ;;
-+esac
- 
- 
- SOVERSION=1.0
-@@ -2873,6 +3090,9 @@
- 		fi
- 		enable_framework=
- 		;;
-+	*-*-darwin*)
-+		ac_sys_system=Darwin
-+		;;
- 	*)
- 		PYTHONFRAMEWORKPREFIX="${enableval}"
- 		PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
-@@ -2977,10 +3197,38 @@
- ##
- # Set name for machine-dependent library files
- 
-+HOST_CPU=$host_cpu
-+
-+HOST_OS=$host_os
-+
-+
-+
-+if test "x$cross_compiling" = xyes; then
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-+  May be value of MACHDEP isn't correct if cross-compiling.
-+  You may tweak configure script for you host system: $host" >&5
-+$as_echo "$as_me: WARNING:
-+  May be value of MACHDEP isn't correct if cross-compiling.
-+  You may tweak configure script for you host system: $host" >&2;}
-+fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking MACHDEP" >&5
- $as_echo_n "checking MACHDEP... " >&6; }
- if test -z "$MACHDEP"
- then
-+		case $host in
-+	*-*-mingw*)
-+		ac_sys_system=ignore
-+						MACHDEP=win
-+	;;
-+    *-*-darwin*)
-+	ac_sys_system=Darwin
-+	ac_sys_version=11
-+    MACHDEP=darwin
-+    ;;
-+	esac
-+fi
-+if test -z "$MACHDEP"
-+then
- 	ac_sys_system=`uname -s`
- 	if test "$ac_sys_system" = "AIX" \
- 	-o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
-@@ -2994,12 +3242,18 @@
- 			   tr -d '/ ' | sed 's/^[A-Z]\.//' | sed 's/\..*//'`
- 	MACHDEP="$ac_md_system$ac_md_release"
- 
-+		case $host in
-+	*-*-cygwin*) MACHDEP="cygwin";;
-+	*-*-darwin*) MACHDEP="darwin";;
-+	*-*-atheos*) MACHDEP="atheos";;
-+	esac
-+
- 	case $MACHDEP in
- 	linux*) MACHDEP="linux2";;
- 	cygwin*) MACHDEP="cygwin";;
- 	darwin*) MACHDEP="darwin";;
- 	atheos*) MACHDEP="atheos";;
--        irix646) MACHDEP="irix6";;
-+	irix646) MACHDEP="irix6";;
- 	'')	MACHDEP="unknown";;
- 	esac
- fi
-@@ -3129,6 +3383,40 @@
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MACHDEP" >&5
- $as_echo "$MACHDEP" >&6; }
- 
-+# Windows uses ; to separate paths, everything else uses :
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking DELIM" >&5
-+$as_echo_n "checking DELIM... " >&6; }
-+DELIM=:
-+if test "$MACHDEP" = "win"
-+then
-+	DELIM=\;
-+fi
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $DELIM" >&5
-+$as_echo "$DELIM" >&6; }
-+
-+
-+# MSYS make uses a 'virtual' VPATH, but getpath.c uses
-+# GetModuleFileNameW (replacing \ with /). This allows the user to
-+# define the 'actual 'real' value. Note, it should contain / not \,
-+# which is what is returned by "pwd -W".
-+
-+if test -z "$MSYSVPATH"; then
-+    MSYSVPATH=$srcdir
-+fi
-+
-+
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for init system calls" >&5
-+$as_echo_n "checking for init system calls... " >&6; }
-+
-+case $host in
-+  # FIXME: May configure lack detection for os2 host system ?
-+  #?#*-*-os2*)	INITSYS=os2;;
-+  *-*-mingw*)	INITSYS=nt;;
-+  *)		INITSYS=posix;;
-+esac
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INITSYS" >&5
-+$as_echo "$INITSYS" >&6; }
-+
- # And add extra plat-mac for darwin
- 
- 
-@@ -3158,12 +3446,6 @@
- CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
- EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
- 
--{ $as_echo "$as_me:${as_lineno-$LINENO}: checking machine type as reported by uname -m" >&5
--$as_echo_n "checking machine type as reported by uname -m... " >&6; }
--ac_sys_machine=`uname -m`
--{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_sys_machine" >&5
--$as_echo "$ac_sys_machine" >&6; }
--
- # checks for alternative programs
- 
- # compiler flags are generated in two sets, BASECFLAGS and OPT.  OPT is just
-@@ -4676,6 +4958,17 @@
- 
- 
- # Check for unsupported systems
-+case $host in
-+  *-*-beos*)
-+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-+  Support for BeOS is deprecated as of Python 2.6.
-+  See PEP 11 for the gory details.
-+  " >&5
-+$as_echo "$as_me: WARNING:
-+  Support for BeOS is deprecated as of Python 2.6.
-+  See PEP 11 for the gory details.
-+  " >&2;};;
-+esac
- case $ac_sys_system/$ac_sys_release in
- atheos*|Linux*/1*)
-    echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
-@@ -4844,6 +5137,10 @@
-   *)
-     enable_shared="no";;
-   esac
-+  case $host in
-+  *-*-mingw*)
-+    enable_shared="yes";;
-+  esac
- fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5
- $as_echo "$enable_shared" >&6; }
-@@ -4852,37 +5149,34 @@
- $as_echo_n "checking for --enable-profiling... " >&6; }
- # Check whether --enable-profiling was given.
- if test "${enable_profiling+set}" = set; then :
--  enableval=$enable_profiling; ac_save_cc="$CC"
-- CC="$CC -pg"
-- if test "$cross_compiling" = yes; then :
--  ac_enable_profiling="no"
--else
-+  enableval=$enable_profiling;
-+fi
-+
-+if test "x$enable_profiling" = xyes; then
-+  py_save_CFLAGS="$CFLAGS"
-+  CFLAGS="$CFLAGS -pg"
-   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
- /* end confdefs.h.  */
--int main() { return 0; }
-+
- _ACEOF
--if ac_fn_c_try_run "$LINENO"; then :
--  ac_enable_profiling="yes"
-+if ac_fn_c_try_compile "$LINENO"; then :
-+
- else
--  ac_enable_profiling="no"
-+  enable_profiling=no
- fi
--rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
--  conftest.$ac_objext conftest.beam conftest.$ac_ext
-+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-+  CFLAGS="$py_save_CFLAGS"
-+else
-+  enable_profiling=no
- fi
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_profiling" >&5
-+$as_echo "$enable_profiling" >&6; }
- 
-- CC="$ac_save_cc"
-+if test "x$enable_profiling" = xyes; then
-+  BASECFLAGS="-pg $BASECFLAGS"
-+  LDFLAGS="-pg $LDFLAGS"
- fi
- 
--{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_enable_profiling" >&5
--$as_echo "$ac_enable_profiling" >&6; }
--
--case "$ac_enable_profiling" in
--    "yes")
--	BASECFLAGS="-pg $BASECFLAGS"
--	LDFLAGS="-pg $LDFLAGS"
--    ;;
--esac
--
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking LDLIBRARY" >&5
- $as_echo_n "checking LDLIBRARY... " >&6; }
- 
-@@ -4964,6 +5258,12 @@
- 	;;
- 
-   esac
-+  case $host in
-+    *-*-mingw*)
-+          LDLIBRARY='libpython$(VERSION).dll.a'
-+          DLLLIBRARY='libpython$(VERSION).dll'
-+                              ;;
-+  esac
- else # shared is disabled
-   case $ac_sys_system in
-     CYGWIN*)
-@@ -4971,6 +5271,10 @@
-           LDLIBRARY='libpython$(VERSION).dll.a'
-           ;;
-   esac
-+  case $host in
-+    *-*-mingw*)
-+          LDLIBRARY='libpython$(VERSION).a';;
-+  esac
- fi
- 
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LDLIBRARY" >&5
-@@ -5068,11 +5372,11 @@
-   RANLIB="$ac_cv_prog_RANLIB"
- fi
- 
--
--for ac_prog in ar aal
--do
--  # Extract the first word of "$ac_prog", so it can be a program name with args.
--set dummy $ac_prog; ac_word=$2
-+if test -n "$ac_tool_prefix"; then
-+  for ac_prog in ar aal
-+  do
-+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
- $as_echo_n "checking for $ac_word... " >&6; }
- if test "${ac_cv_prog_AR+set}" = set; then :
-@@ -5088,7 +5392,7 @@
-   test -z "$as_dir" && as_dir=.
-     for ac_exec_ext in '' $ac_executable_extensions; do
-   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--    ac_cv_prog_AR="$ac_prog"
-+    ac_cv_prog_AR="$ac_tool_prefix$ac_prog"
-     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-     break 2
-   fi
-@@ -5108,9 +5412,65 @@
- fi
- 
- 
--  test -n "$AR" && break
-+    test -n "$AR" && break
-+  done
-+fi
-+if test -z "$AR"; then
-+  ac_ct_AR=$AR
-+  for ac_prog in ar aal
-+do
-+  # Extract the first word of "$ac_prog", so it can be a program name with args.
-+set dummy $ac_prog; ac_word=$2
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+$as_echo_n "checking for $ac_word... " >&6; }
-+if test "${ac_cv_prog_ac_ct_AR+set}" = set; then :
-+  $as_echo_n "(cached) " >&6
-+else
-+  if test -n "$ac_ct_AR"; then
-+  ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
-+else
-+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-+for as_dir in $PATH
-+do
-+  IFS=$as_save_IFS
-+  test -z "$as_dir" && as_dir=.
-+    for ac_exec_ext in '' $ac_executable_extensions; do
-+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-+    ac_cv_prog_ac_ct_AR="$ac_prog"
-+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+    break 2
-+  fi
-+done
-+  done
-+IFS=$as_save_IFS
-+
-+fi
-+fi
-+ac_ct_AR=$ac_cv_prog_ac_ct_AR
-+if test -n "$ac_ct_AR"; then
-+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
-+$as_echo "$ac_ct_AR" >&6; }
-+else
-+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-+$as_echo "no" >&6; }
-+fi
-+
-+
-+  test -n "$ac_ct_AR" && break
- done
--test -n "$AR" || AR="ar"
-+
-+  if test "x$ac_ct_AR" = x; then
-+    AR="ar"
-+  else
-+    case $cross_compiling:$ac_tool_warned in
-+yes:)
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-+ac_tool_warned=yes ;;
-+esac
-+    AR=$ac_ct_AR
-+  fi
-+fi
- 
- 
- # tweak ARFLAGS only if the user didn't set it on the command line
-@@ -5226,35 +5586,6 @@
- 		INSTALL="${srcdir}/install-sh -c"
- 	fi
- esac
--ac_aux_dir=
--for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
--  if test -f "$ac_dir/install-sh"; then
--    ac_aux_dir=$ac_dir
--    ac_install_sh="$ac_aux_dir/install-sh -c"
--    break
--  elif test -f "$ac_dir/install.sh"; then
--    ac_aux_dir=$ac_dir
--    ac_install_sh="$ac_aux_dir/install.sh -c"
--    break
--  elif test -f "$ac_dir/shtool"; then
--    ac_aux_dir=$ac_dir
--    ac_install_sh="$ac_aux_dir/shtool install -c"
--    break
--  fi
--done
--if test -z "$ac_aux_dir"; then
--  as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
--fi
--
--# These three variables are undocumented and unsupported,
--# and are intended to be withdrawn in a future Autoconf release.
--# They can cause serious problems if a builder's source tree is in a directory
--# whose full name contains unusual characters.
--ac_config_guess="$SHELL $ac_aux_dir/config.guess"  # Please don't use this var.
--ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.
--ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
--
--
- # Find a good install program.  We prefer a C program (faster),
- # so one script is as good as another.  But avoid the broken or
- # incompatible versions:
-@@ -5383,6 +5714,27 @@
- $as_echo "no" >&6; }
- fi
- 
-+# FIXME: We define BUILDEXEEXT and LDLIBRARY above but:
-+#  For debug versions MSVC build prepend suffix by '_d'.
-+#  If we support this convention we may modify distutils(TODO).
-+#  To support different build directories is good "--with-pydebug"
-+#  to be earlier in the script(why i wrote this?).
-+if test "x$Py_DEBUG" = xtrue; then
-+  case $host in
-+            # Since Makefile.pre.in may isn't suitable for now we will not
-+    # change LDLIBRARY.
-+    *-*-mingw*)
-+      BUILDEXEEXT=_d$BUILDEXEEXT
-+      if test x$enable_shared = xyes; then
-+        #LDLIBRARY='libpython$(VERSION)_d.dll.a'
-+        DLLLIBRARY='libpython$(VERSION)_d.dll'
-+      else # shared is disabled
-+        #LDLIBRARY='libpython$(VERSION)_d.dll.a';;
-+        :
-+      fi
-+      ;;
-+  esac
-+fi
- 
- # XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
- # merged with this chunk of code?
-@@ -5399,6 +5751,8 @@
- 
- # tweak OPT based on compiler and platform, only if the user didn't set
- # it on the command line
-+# NOTE: If user set OPT at this point script ignore all previously set
-+# options (not important - BeOS is depricated for python 2.6+).
- 
- if test "${OPT-unset}" = "unset"
- then
-@@ -5493,10 +5847,14 @@
-     # if using gcc on alpha, use -mieee to get (near) full IEEE 754
-     # support.  Without this, treatment of subnormals doesn't follow
-     # the standard.
--    case $ac_sys_machine in
-+    case $host in
-          alpha*)
-                 BASECFLAGS="$BASECFLAGS -mieee"
-                 ;;
-+         *-*-mingw*)
-+                #MSVC in-compatable storage layout for bitfields in structures (Roumen has -mms-bitfields)
-+                BASECFLAGS="$BASECFLAGS"
-+                ;;
-     esac
- 
-     case $ac_sys_system in
-@@ -5527,7 +5885,7 @@
- 	    # Calculate the right deployment target for this build.
- 	    #
- 	    cur_target=`sw_vers -productVersion | sed 's/\(10\.[0-9]*\).*/\1/'`
--	    if test ${cur_target} '>' 10.2; then
-+	    if test ${cur_target} > 10.2; then
- 		    cur_target=10.3
- 		    if test ${enable_universalsdk}; then
- 			    if test "${UNIVERSAL_ARCHS}" = "all"; then
-@@ -5547,7 +5905,7 @@
- 				    cur_target='10.5'
- 			    fi
- 		    else
--			    if test `/usr/bin/arch` = "i386"; then
-+			    if test "$($OSX_ARCH_PROG)" = "i386"; then
- 				    # On Intel macs default to a deployment
- 				    # target of 10.4, that's the first OSX
- 				    # release with Intel support.
-@@ -5632,7 +5990,9 @@
- esac
- 
- if test "$Py_DEBUG" = 'true'; then
--  :
-+  case $host in
-+        *-*-mingw*) OPT="-D_DEBUG $OPT";;
-+  esac
- else
-   OPT="-DNDEBUG $OPT"
- fi
-@@ -5961,6 +6321,41 @@
- $as_echo "$ac_cv_pthread" >&6; }
- fi
- 
-+if test "x$ac_cv_kpthread" = xno && \
-+   test "x$ac_cv_kthread" = xno && \
-+   test "x$ac_cv_pthread" = xno && \
-+   test "x$ac_cv_pthread_is_default" = xno
-+then
-+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for NT threads" >&5
-+$as_echo_n "checking for NT threads... " >&6; }
-+	if test "${ac_cv_ntthread+set}" = set; then :
-+  $as_echo_n "(cached) " >&6
-+else
-+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-+/* end confdefs.h.  */
-+
-+
-+int
-+main ()
-+{
-+_beginthread(0, 0, 0);
-+  ;
-+  return 0;
-+}
-+_ACEOF
-+if ac_fn_c_try_link "$LINENO"; then :
-+  ac_cv_ntthread=yes
-+else
-+  ac_cv_ntthread=no
-+fi
-+rm -f core conftest.err conftest.$ac_objext \
-+    conftest$ac_exeext conftest.$ac_ext
-+fi
-+
-+	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_ntthread" >&5
-+$as_echo "$ac_cv_ntthread" >&6; }
-+fi
-+
- # If we have set a CC compiler flag for thread support then
- # check if it works for CXX, too.
- ac_cv_cxx_thread=no
-@@ -5982,6 +6377,9 @@
- then
-   CXX="$CXX -pthread"
-   ac_cv_cxx_thread=yes
-+elif test "x$ac_cv_ntthread" = xyes
-+then
-+  ac_cv_cxx_thread=always
- fi
- 
- if test $ac_cv_cxx_thread = yes
-@@ -6127,7 +6525,7 @@
- sys/termio.h sys/time.h \
- sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
- sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
--bluetooth/bluetooth.h linux/tipc.h spawn.h util.h
-+bluetooth/bluetooth.h linux/tipc.h spawn.h util.h winsock2.h
- do :
-   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
- ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-@@ -7321,29 +7719,6 @@
- elif test "$ac_cv_pthread" = "yes"
- then CC="$CC -pthread"
- fi
--{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_t" >&5
--$as_echo_n "checking for pthread_t... " >&6; }
--have_pthread_t=no
--cat confdefs.h - <<_ACEOF >conftest.$ac_ext
--/* end confdefs.h.  */
--
--  #include <pthread.h>
--int
--main ()
--{
--pthread_t x; x = *(pthread_t*)0;
--  ;
--  return 0;
--}
--
--_ACEOF
--if ac_fn_c_try_compile "$LINENO"; then :
--  have_pthread_t=yes
--fi
--rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
--{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_pthread_t" >&5
--$as_echo "$have_pthread_t" >&6; }
--if test "$have_pthread_t" = yes ; then
-   # The cast to long int works around a bug in the HP C Compiler
- # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
- # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
-@@ -7382,7 +7757,6 @@
- _ACEOF
- 
- 
--fi
- CC="$ac_save_cc"
- 
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --enable-toolbox-glue" >&5
-@@ -7429,6 +7803,15 @@
-     ;;
- esac
- 
-+if test "x$cross_compiling" = xyes; then
-+    function arch
-+    {
-+        echo i386
-+    }
-+    OSX_ARCH_PROG=arch
-+else
-+    OSX_ARCH_PROG=/usr/bin/arch
-+fi
- 
- ARCH_RUN_32BIT=""
- 
-@@ -7438,7 +7821,7 @@
-     if test "${enable_universalsdk}"; then
- 	    :
-     else
--        LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
-+        LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only $($OSX_ARCH_PROG)"
-     fi
-     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
-     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
-@@ -7478,7 +7861,7 @@
- 
- 
-     if test "${ac_osx_32bit}" = "yes"; then
--    	case `/usr/bin/arch` in
-+    	case $($OSX_ARCH_PROG) in
-     	i386)
-     		MACOSX_DEFAULT_ARCH="i386"
-     		;;
-@@ -7490,7 +7873,7 @@
-     		;;
-     	esac
-     else
--    	case `/usr/bin/arch` in
-+    	case $($OSX_ARCH_PROG) in
-     	i386)
-     		MACOSX_DEFAULT_ARCH="x86_64"
-     		;;
-@@ -7533,8 +7916,8 @@
- 
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dyld" >&5
- $as_echo_n "checking for dyld... " >&6; }
--case $ac_sys_system/$ac_sys_release in
--  Darwin/*)
-+case $host in
-+  *darwin*)
- 
- $as_echo "#define WITH_DYLD 1" >>confdefs.h
- 
-@@ -7570,6 +7953,16 @@
- 	CYGWIN*)   SO=.dll;;
- 	*)	   SO=.so;;
- 	esac
-+	case $host in
-+	*-*-mingw*)
-+	#NOTE: see _PyImport_DynLoadFiletab in dynload_win.c
-+	if test "x$Py_DEBUG" = xtrue; then
-+		SO=_d.pyd
-+	else
-+		SO=.pyd
-+	fi
-+	;;
-+	esac
- else
- 	# this might also be a termcap variable, see #610332
-         echo
-@@ -7656,7 +8049,7 @@
- 		# Use -undefined dynamic_lookup whenever possible (10.3 and later).
- 		# This allows an extension to be used in any Python
- 
--		if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
-+		if test ${MACOSX_DEPLOYMENT_TARGET} > 10.2
- 		then
- 			if test "${enable_universalsdk}"; then
- 				LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
-@@ -7732,6 +8125,12 @@
- 		LDCXXSHARED="g++ -shared";;
- 	*)	LDSHARED="ld";;
- 	esac
-+	case $host in
-+	*-*-mingw*)
-+		LDSHARED='$(CC) -shared -Wl,--enable-auto-image-base'
-+		LDCXXSHARED='$(CXX) -shared -Wl,--enable-auto-image-base'
-+		;;
-+	esac
- fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LDSHARED" >&5
- $as_echo "$LDSHARED" >&6; }
-@@ -7833,6 +8232,12 @@
- 		# when running test_compile.py.
- 		LINKFORSHARED='-Wl,-E -N 2048K';;
- 	esac
-+	case $host in
-+	*-*-mingw*)
-+		if test x$enable_shared = xyes; then
-+			LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
-+		fi;;
-+	esac
- fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LINKFORSHARED" >&5
- $as_echo "$LINKFORSHARED" >&6; }
-@@ -7851,6 +8256,12 @@
- 	*)
- 		CFLAGSFORSHARED='$(CCSHARED)'
- 	esac
-+	case $host in
-+	*-*-mingw*)
-+		# TODO mingw may needs CCSHARED when building extension DLLs
-+		# but not when building the interpreter DLL.
-+		CFLAGSFORSHARED='';;
-+	esac
- fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CFLAGSFORSHARED" >&5
- $as_echo "$CFLAGSFORSHARED" >&6; }
-@@ -8029,6 +8440,10 @@
- fi
- 
- # check if we need libintl for locale functions
-+case $host in
-+  *-*-mingw*)
-+        ;;
-+  *)
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for textdomain in -lintl" >&5
- $as_echo_n "checking for textdomain in -lintl... " >&6; }
- if test "${ac_cv_lib_intl_textdomain+set}" = set; then :
-@@ -8071,6 +8486,8 @@
- 
- fi
- 
-+  ;;
-+esac
- 
- # checks for system dependent C++ extensions support
- case "$ac_sys_system" in
-@@ -8532,6 +8949,15 @@
- 
-     posix_threads=yes
-     THREADOBJ="Python/thread.o"
-+elif test "x$ac_cv_ntthread" = xyes
-+then
-+    $as_echo "#define WITH_THREAD 1" >>confdefs.h
-+
-+    posix_threads=no
-+    THREADOBJ="Python/thread.o"
-+
-+$as_echo "#define NT_THREADS 1" >>confdefs.h
-+
- else
-     if test ! -z "$with_threads" -a -d "$with_threads"
-     then LDFLAGS="$LDFLAGS -L$with_threads"
-@@ -9063,6 +9489,18 @@
- fi
- 
- 
-+
-+BUILDIN_WIN32_MODULE='#'
-+case $host in
-+  *-*-mingw*)
-+    # On win32 host(mingw build MSYS environment) site.py fail to load
-+    # if _functools is not build-in by reason of dependency:
-+    #   setup->site->locale->functools&operator
-+    BUILDIN_WIN32_MODULE=
-+  ;;
-+esac
-+
-+
- # Check for enable-ipv6
- 
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking if --enable-ipv6 is specified" >&5
-@@ -9517,6 +9955,14 @@
- 	fi
- 	;;
- 	esac
-+	case $host in
-+	*-*-mingw*)
-+	# FIXME: it is good to use portable "$OBJEXT" instead "o" but
-+	# python build isn't yet ready to use it (see Makefile.pre.in)
-+	#DYNLOADFILE="dynload_win.$OBJEXT"
-+	DYNLOADFILE="dynload_win.o"
-+	;;
-+	esac
- fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DYNLOADFILE" >&5
- $as_echo "$DYNLOADFILE" >&6; }
-@@ -9532,14 +9978,24 @@
- 
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking MACHDEP_OBJS" >&5
- $as_echo_n "checking MACHDEP_OBJS... " >&6; }
-+case $host in
-+  *-*-mingw*)
-+    extra_machdep_objs="PC/dl_nt.o Modules/getpath.o PC/import_nt.o"
-+    ;;
-+esac
- if test -z "$MACHDEP_OBJS"
- then
- 	MACHDEP_OBJS=$extra_machdep_objs
- else
- 	MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
- fi
--{ $as_echo "$as_me:${as_lineno-$LINENO}: result: MACHDEP_OBJS" >&5
--$as_echo "MACHDEP_OBJS" >&6; }
-+if test -z "$MACHDEP_OBJS"; then
-+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5
-+$as_echo "none" >&6; }
-+else
-+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MACHDEP_OBJS" >&5
-+$as_echo "$MACHDEP_OBJS" >&6; }
-+fi
- 
- # checks for library functions
- for ac_func in alarm setitimer getitimer bind_textdomain_codeset chown \
-@@ -9569,6 +10025,7 @@
- done
- 
- 
-+
- # For some functions, having a definition is not sufficient, since
- # we want to take their address.
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for chroot" >&5
-@@ -10901,11 +11358,20 @@
- fi
- 
- fi
-+case $host in
-+  *-*-mingw*)
-+  #FIXME: mingw "w32api" define getaddinfo if WINVER >= 0x501, i.e. XP or greater.
-+  #TODO: mingw require additional check.
-+  #NOTE: above check is not correct for windows platforms.
-+  #  ac_cv_buggy_getaddrinfo=no
-+    :
-+    ;;
-+esac
- 
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_buggy_getaddrinfo" >&5
- $as_echo "$ac_cv_buggy_getaddrinfo" >&6; }
- 
--if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
-+if test $have_getaddrinfo = no || test "$ac_cv_buggy_getaddrinfo" = yes
- then
- 	if test $ipv6 = yes
- 	then
-@@ -11211,7 +11677,12 @@
- else
-   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
- /* end confdefs.h.  */
--#include <netdb.h>
-+
-+#ifdef HAVE_WINSOCK2_H
-+#  include <ws2tcpip.h>
-+#else
-+#  include <netdb.h>
-+#endif
- int
- main ()
- {
-@@ -11244,8 +11715,15 @@
-   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
- /* end confdefs.h.  */
- 
--#		include <sys/types.h>
--#		include <sys/socket.h>
-+#ifdef HAVE_SYS_TYPES_H
-+#include <sys/types.h>
-+#endif
-+#ifdef HAVE_SYS_SOCKET_H
-+#include <sys/socket.h>
-+#endif
-+#ifdef HAVE_WINSOCK2_H
-+#include <winsock2.h>
-+#endif
- int
- main ()
- {
-@@ -11829,6 +12307,9 @@
- BeOS) ;;
- *) LIBM=-lm
- esac
-+case $host in
-+  *-*-mingw*) LIBM=;;
-+esac
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-libm=STRING" >&5
- $as_echo_n "checking for --with-libm=STRING... " >&6; }
- 
-@@ -11878,6 +12359,13 @@
- # **************************************************
- # * Check for various properties of floating point *
- # **************************************************
-+case $host in
-+  *-*-mingw*)
-+    ac_cv_little_endian_double=yes
-+    ac_cv_big_endian_double=no
-+    ac_cv_mixed_endian_double=no
-+  ;;
-+esac
- 
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C doubles are little-endian IEEE 754 binary64" >&5
- $as_echo_n "checking whether C doubles are little-endian IEEE 754 binary64... " >&6; }
-@@ -12018,6 +12506,8 @@
- 
- # This inline assembler syntax may also work for suncc and icc,
- # so we try it on all platforms.
-+# Note MSVC build use Python/dtoa.c, but I could not find any reason
-+# to use this file for GCC(mingw*) builds, so mingw* will use gcc asm :)
- 
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we can use gcc inline assembler to get and set x87 control word" >&5
- $as_echo_n "checking whether we can use gcc inline assembler to get and set x87 control word... " >&6; }
-@@ -12097,6 +12587,11 @@
- fi
- 
- CC="$ac_save_cc"
-+if test "x$cross_compiling" = xyes; then
-+  case $host in
-+    *-*-mingw*) ac_cv_x87_double_rounding=yes;;
-+  esac
-+fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_x87_double_rounding" >&5
- $as_echo "$ac_cv_x87_double_rounding" >&6; }
- if test "$ac_cv_x87_double_rounding" = yes
-@@ -12117,6 +12612,12 @@
- # -0. on some architectures.
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether tanh preserves the sign of zero" >&5
- $as_echo_n "checking whether tanh preserves the sign of zero... " >&6; }
-+case $host in
-+  *-*-mingw*)
-+    # Some MSVC runtimes don't preserve zero sign.
-+    # On mingw host we will use always replacement function.
-+    ac_cv_tanh_preserves_zero_sign=no;;
-+esac
- if test "${ac_cv_tanh_preserves_zero_sign+set}" = set; then :
-   $as_echo_n "(cached) " >&6
- else
-@@ -12225,6 +12726,13 @@
- # the kernel module that provides POSIX semaphores
- # isn't loaded by default, so an attempt to call
- # sem_open results in a 'Signal 12' error.
-+if test $ac_cv_func_sem_open = yes; then
-+case $host in
-+  *-*-mingw*)
-+    # GCC 4.4+ (mingw) support posix threads(!)
-+    # bug we won't use them on windows platform.
-+    ac_cv_posix_semaphores_enabled=no;;
-+esac
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether POSIX semaphores are enabled" >&5
- $as_echo_n "checking whether POSIX semaphores are enabled... " >&6; }
- if test "${ac_cv_posix_semaphores_enabled+set}" = set; then :
-@@ -12268,6 +12776,9 @@
- 
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_posix_semaphores_enabled" >&5
- $as_echo "$ac_cv_posix_semaphores_enabled" >&6; }
-+else
-+   ac_cv_posix_semaphores_enabled=no
-+fi
- if test $ac_cv_posix_semaphores_enabled = no
- then
- 
-@@ -12276,8 +12787,19 @@
- fi
- 
- # Multiprocessing check for broken sem_getvalue
-+if test $ac_cv_func_sem_getvalue = yes; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for broken sem_getvalue" >&5
- $as_echo_n "checking for broken sem_getvalue... " >&6; }
-+case $host in
-+  *-*-mingw*)
-+    # GCC(mingw) 4.4+ require and use posix threads(pthreads-w32)
-+    # Also system may contain installed pthreads-w32.
-+    # NOTE the test case below don't work for pthreads-w32:
-+    # - SEM_FAILED is not defined;
-+    # - sem_open is stub;
-+    # - sem_getvalue work(!).
-+    ac_cv_broken_sem_getvalue=no;;
-+esac
- if test "${ac_cv_broken_sem_getvalue+set}" = set; then :
-   $as_echo_n "(cached) " >&6
- else
-@@ -12329,6 +12851,7 @@
- $as_echo "#define HAVE_BROKEN_SEM_GETVALUE 1" >>confdefs.h
- 
- fi
-+fi
- 
- # determine what size digit to use for Python's longs
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking digit size for Python's longs" >&5
-@@ -12450,6 +12973,9 @@
-   # check whether wchar_t is signed or not
-   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether wchar_t is signed" >&5
- $as_echo_n "checking whether wchar_t is signed... " >&6; }
-+  case $host in
-+    *-*-mingw*) ac_cv_wchar_t_signed=no;;
-+  esac
-   if test "${ac_cv_wchar_t_signed+set}" = set; then :
-   $as_echo_n "(cached) " >&6
- else
-@@ -12784,6 +13310,46 @@
-  esac
- 
- 
-+# REPARSE_DATA_BUFFER is in winnt.h on mingw32 and (unusably) ddk/ntifs.h on mingw64.
-+case $host in
-+  *-*-mingw*)
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if struct REPARSE_DATA_BUFFER is in winnt.h" >&5
-+$as_echo_n "checking if struct REPARSE_DATA_BUFFER is in winnt.h... " >&6; }
-+if test "${ac_cv_struct_reparse_data_buffer_in_winnt_h+set}" = set; then :
-+  $as_echo_n "(cached) " >&6
-+else
-+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-+/* end confdefs.h.  */
-+#include <windows.h>
-+       #include <winnt.h>
-+int
-+main ()
-+{
-+REPARSE_DATA_BUFFER rdb
-+  ;
-+  return 0;
-+}
-+_ACEOF
-+if ac_fn_c_try_compile "$LINENO"; then :
-+  ac_cv_struct_reparse_data_buffer_in_winnt_h=yes
-+else
-+  ac_cv_struct_reparse_data_buffer_in_winnt_h=no
-+
-+fi
-+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-+
-+fi
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_reparse_data_buffer_in_winnt_h" >&5
-+$as_echo "$ac_cv_struct_reparse_data_buffer_in_winnt_h" >&6; }
-+if test "x${ac_cv_struct_reparse_data_buffer_in_winnt_h}" = xyes; then
-+
-+$as_echo "#define REPARSE_DATA_BUFFER_IN_WINNT /**/" >>confdefs.h
-+
-+
-+fi
-+  ;;
-+esac
-+
- # Check whether right shifting a negative integer extends the sign bit
- # or fills with zeros (like the Cray J90, according to Tim Peters).
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether right shift extends the sign bit" >&5
-@@ -12875,7 +13441,7 @@
- py_cv_lib_readline=no
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link readline libs" >&5
- $as_echo_n "checking how to link readline libs... " >&6; }
--for py_libtermcap in "" ncursesw ncurses curses termcap; do
-+for py_libtermcap in "" tinfo ncursesw ncurses curses termcap; do
-   if test -z "$py_libtermcap"; then
-     READLINE_LIBS="-lreadline"
-   else
-@@ -12908,9 +13474,9 @@
-   if test $py_cv_lib_readline = yes; then
-     break
-   fi
-+  READLINE_LIBS=
- done
--# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
--#AC_SUBST([READLINE_LIBS])
-+
- if test $py_cv_lib_readline = no; then
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5
- $as_echo "none" >&6; }
-@@ -13659,38 +14225,89 @@
- fi
- rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- 
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for device files" >&5
-+$as_echo "$as_me: checking for device files" >&6;}
-+case $host in
-+  *-*-mingw*)
-+    ac_cv_file__dev_ptmx=ignore #NOTE: under MSYS environment device exist
-+    ac_cv_file__dev_ptc=no
-+    ;;
-+esac
-+
-+if test "x$cross_compiling" = xyes; then
-+  if test "${ac_cv_file__dev_ptmx+set}" != set; then
-+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for /dev/ptmx" >&5
-+$as_echo_n "checking for /dev/ptmx... " >&6; }
-+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: not set" >&5
-+$as_echo "not set" >&6; }
-+    as_fn_error $? "set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling" "$LINENO" 5
-+  fi
-+  if test "${ac_cv_file__dev_ptc+set}" != set; then
-+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for /dev/ptc" >&5
-+$as_echo_n "checking for /dev/ptc... " >&6; }
-+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: not set" >&5
-+$as_echo "not set" >&6; }
-+    as_fn_error $? "set ac_cv_file__dev_ptc to yes/no in your CONFIG_SITE file when cross compiling" "$LINENO" 5
-+  fi
-+fi
-+
-+# FIXME: autoconf macro AC_CHECK_FILES is better but require additional
-+# changes in posixmodule.c : 's/HAVE_DEV_/HAVE__DEV_/g'
-+# To keep patch minimal I left defines as before.
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for /dev/ptmx" >&5
- $as_echo_n "checking for /dev/ptmx... " >&6; }
-+if test "${ac_cv_file__dev_ptmx+set}" = set; then :
-+  $as_echo_n "(cached) " >&6
-+else
-+  test "$cross_compiling" = yes &&
-+  as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5
-+if test -r "/dev/ptmx"; then
-+  ac_cv_file__dev_ptmx=yes
-+else
-+  ac_cv_file__dev_ptmx=no
-+fi
-+fi
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_file__dev_ptmx" >&5
-+$as_echo "$ac_cv_file__dev_ptmx" >&6; }
-+if test "x$ac_cv_file__dev_ptmx" = x""yes; then :
- 
--if test -r /dev/ptmx
--then
--  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
--$as_echo "yes" >&6; }
-+fi
-+
-+if test "x$ac_cv_file__dev_ptmx" = xyes; then
- 
- $as_echo "#define HAVE_DEV_PTMX 1" >>confdefs.h
- 
--else
--  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
--$as_echo "no" >&6; }
- fi
--
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for /dev/ptc" >&5
- $as_echo_n "checking for /dev/ptc... " >&6; }
-+if test "${ac_cv_file__dev_ptc+set}" = set; then :
-+  $as_echo_n "(cached) " >&6
-+else
-+  test "$cross_compiling" = yes &&
-+  as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5
-+if test -r "/dev/ptc"; then
-+  ac_cv_file__dev_ptc=yes
-+else
-+  ac_cv_file__dev_ptc=no
-+fi
-+fi
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_file__dev_ptc" >&5
-+$as_echo "$ac_cv_file__dev_ptc" >&6; }
-+if test "x$ac_cv_file__dev_ptc" = x""yes; then :
- 
--if test -r /dev/ptc
--then
--  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
--$as_echo "yes" >&6; }
-+fi
-+
-+if test "x$ac_cv_file__dev_ptc" = xyes; then
- 
- $as_echo "#define HAVE_DEV_PTC 1" >>confdefs.h
- 
--else
--  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
--$as_echo "no" >&6; }
- fi
- 
- if test "$have_long_long" = yes
- then
-+  case $host in
-+    *-*-mingw*) ac_cv_have_long_long_format=yes;;
-+  esac
-   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for %lld and %llu printf() format support" >&5
- $as_echo_n "checking for %lld and %llu printf() format support... " >&6; }
-   if test "${ac_cv_have_long_long_format+set}" = set; then :
-@@ -13762,6 +14379,9 @@
- fi
- 
- 
-+case $host in
-+  *-*-mingw*) ac_cv_have_size_t_format=no;;
-+esac
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for %zd printf() format support" >&5
- $as_echo_n "checking for %zd printf() format support... " >&6; }
- if test "${ac_cv_have_size_t_format+set}" = set; then :
-@@ -13861,8 +14481,38 @@
-   THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
- done
- 
-+# FIXME: in cross-compilation env. (mingw on linux) how to select correct compiler ?
-+# The current py-code will created modules with .so suffix and environment
-+# variable setting SO=$(SO) don't help
-+# see output of: python setup.py build --help-compiler
-+
-+case $host in
-+  *-*-mingw*) PYMOD_BUILDOPT="--compiler mingw32";;
-+esac
-+
-+# Python interpreter main program for frozen scripts
-+
-+PYTHON_OBJS_FROZENMAIN="Python/frozenmain.o"
-+# MODULE_GETPATH - default sys.path calculations
-+
-+MODULE_GETPATH=Modules/getpath.o
-+case $host in
-+  *-*-mingw*)
-+        CPPFLAGS="-I\$(srcdir)/Python -I\$(srcdir)/PC $CPPFLAGS"
-+
-+    # FIXME: why windows builds don't use PC/frozen_dllmain.o ?
-+    PYTHON_OBJS_FROZENMAIN=""
-+    # default sys.path calculations for windows platforms
-+    # MODULE_GETPATH=PC/getpathp.o
-+    MODULE_GETPATH=Modules/getpath.o
-+    ;;
-+esac
-+
- 
- SRCDIRS="Parser Grammar Objects Python Modules Mac"
-+case $host in
-+  *-*-mingw*) SRCDIRS="$SRCDIRS PC";;
-+esac
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for build directories" >&5
- $as_echo_n "checking for build directories... " >&6; }
- for dir in $SRCDIRS; do
-@@ -13874,7 +14524,13 @@
- $as_echo "done" >&6; }
- 
- # generate output files
--ac_config_files="$ac_config_files Makefile.pre Modules/Setup.config Misc/python.pc"
-+
-+
-+ac_config_commands="$ac_config_commands Makefile"
-+
-+ac_config_files="$ac_config_files setup_info"
-+
-+ac_config_files="$ac_config_files Makefile.pre Modules/Setup.config Misc/python.pc Misc/python-config.sh"
- 
- ac_config_files="$ac_config_files Modules/ld_so_aix"
- 
-@@ -13978,6 +14634,21 @@
- 
- 
- 
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: creating Modules/Setup" >&5
-+$as_echo "$as_me: creating Modules/Setup" >&6;}
-+
-+if test ! -f Modules/Setup
-+then
-+	cp $srcdir/Modules/Setup.dist Modules/Setup
-+fi
-+
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: creating Modules/Setup.local" >&5
-+$as_echo "$as_me: creating Modules/Setup.local" >&6;}
-+if test ! -f Modules/Setup.local
-+then
-+	echo "# Edit this file for local setup changes" >Modules/Setup.local
-+fi
-+
- : ${CONFIG_STATUS=./config.status}
- ac_write_fail=0
- ac_clean_files_save=$ac_clean_files
-@@ -14412,6 +15083,7 @@
- # Files that config.status was made for.
- config_files="$ac_config_files"
- config_headers="$ac_config_headers"
-+config_commands="$ac_config_commands"
- 
- _ACEOF
- 
-@@ -14441,6 +15113,9 @@
- Configuration headers:
- $config_headers
- 
-+Configuration commands:
-+$config_commands
-+
- Report bugs to <http://bugs.python.org/>."
- 
- _ACEOF
-@@ -14575,9 +15250,12 @@
-     "Mac/IDLE/Makefile") CONFIG_FILES="$CONFIG_FILES Mac/IDLE/Makefile" ;;
-     "Mac/Resources/framework/Info.plist") CONFIG_FILES="$CONFIG_FILES Mac/Resources/framework/Info.plist" ;;
-     "Mac/Resources/app/Info.plist") CONFIG_FILES="$CONFIG_FILES Mac/Resources/app/Info.plist" ;;
-+    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
-+    "setup_info") CONFIG_FILES="$CONFIG_FILES setup_info" ;;
-     "Makefile.pre") CONFIG_FILES="$CONFIG_FILES Makefile.pre" ;;
-     "Modules/Setup.config") CONFIG_FILES="$CONFIG_FILES Modules/Setup.config" ;;
-     "Misc/python.pc") CONFIG_FILES="$CONFIG_FILES Misc/python.pc" ;;
-+    "Misc/python-config.sh") CONFIG_FILES="$CONFIG_FILES Misc/python-config.sh" ;;
-     "Modules/ld_so_aix") CONFIG_FILES="$CONFIG_FILES Modules/ld_so_aix" ;;
- 
-   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;;
-@@ -14592,6 +15270,7 @@
- if $ac_need_defaults; then
-   test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
-   test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
-+  test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
- fi
- 
- # Have a temporary directory for convenience.  Make it in the build tree
-@@ -14886,7 +15565,7 @@
- fi # test -n "$CONFIG_HEADERS"
- 
- 
--eval set X "  :F $CONFIG_FILES  :H $CONFIG_HEADERS    "
-+eval set X "  :F $CONFIG_FILES  :H $CONFIG_HEADERS    :C $CONFIG_COMMANDS"
- shift
- for ac_tag
- do
-@@ -15123,11 +15802,19 @@
-   fi
-  ;;
- 
--
-+  :C)  { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
-+$as_echo "$as_me: executing $ac_file commands" >&6;}
-+ ;;
-   esac
- 
- 
-   case $ac_file$ac_mode in
-+    "Makefile":C) $SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
-+			-s Modules Modules/Setup.config \
-+			Modules/Setup.local Modules/Setup
-+
-+
-+mv config.c Modules ;;
-     "Modules/ld_so_aix":F) chmod +x Modules/ld_so_aix ;;
- 
-   esac
-@@ -15167,38 +15854,3 @@
- $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
- fi
- 
--
--echo "creating Modules/Setup"
--if test ! -f Modules/Setup
--then
--	cp $srcdir/Modules/Setup.dist Modules/Setup
--fi
--
--echo "creating Modules/Setup.local"
--if test ! -f Modules/Setup.local
--then
--	echo "# Edit this file for local setup changes" >Modules/Setup.local
--fi
--
--echo "creating Makefile"
--$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
--			-s Modules Modules/Setup.config \
--			Modules/Setup.local Modules/Setup
--
--case $ac_sys_system in
--BeOS)
--        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
--
--  Support for BeOS is deprecated as of Python 2.6.
--  See PEP 11 for the gory details.
--  " >&5
--$as_echo "$as_me: WARNING:
--
--  Support for BeOS is deprecated as of Python 2.6.
--  See PEP 11 for the gory details.
--  " >&2;}
--  ;;
--*) ;;
--esac
--
--mv config.c Modules
-diff -urN a/pyconfig.h.in b/pyconfig.h.in
---- a/pyconfig.h.in	2012-07-04 23:46:02.751554822 +0100
-+++ b/pyconfig.h.in	2012-07-04 23:46:13.306624284 +0100
-@@ -969,6 +969,9 @@
- /* Define if you want to have a Unicode type. */
- #undef Py_USING_UNICODE
- 
-+/* REPARSE_DATA_BUFFER in winnt.h */
-+#undef REPARSE_DATA_BUFFER_IN_WINNT
-+
- /* assume C89 semantics that RETSIGTYPE is always void */
- #undef RETSIGTYPE
-