summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/Python-2.6.1-mingw.patch1265
-rw-r--r--python/Python-2.6.1.patch232
-rw-r--r--python/makefile.mk158
-rw-r--r--python/prj/build.lst3
-rw-r--r--python/prj/d.lst108
-rw-r--r--python/pyversion.mk26
6 files changed, 1792 insertions, 0 deletions
diff --git a/python/Python-2.6.1-mingw.patch b/python/Python-2.6.1-mingw.patch
new file mode 100644
index 000000000000..63067227c112
--- /dev/null
+++ b/python/Python-2.6.1-mingw.patch
@@ -0,0 +1,1265 @@
+--- misc/Python-2.6.1/Include/pyport.h 2008-06-11 16:41:16.000000000 +0900
++++ misc/build/Python-2.6.1/Include/pyport.h 2009-03-29 23:28:13.859000000 +0900
+@@ -3,6 +3,26 @@
+
+ #include "pyconfig.h" /* include for defines */
+
++#if defined(__MINGW32__)
++#undef HAVE_FORKPTY
++#undef HAVE_OPENPTY
++#undef HAVE_DEV_PTMX
++#undef _POSIX_THREADS
++#define MS_WINDOWS
++#define MS_WIN32
++#define Py_WIN_WIDE_FILENAMES
++#ifndef PYTHONPATH
++# define PYTHONPATH ".\\lib;.\\lib\\python" VERSION ";.\\lib\\python" VERSION "\\lib-dynload;.\\lib\\python" VERSION "\\plat-winmingw32;.\\lib\\python" VERSION "\\lib-tk"
++#endif
++#define NT_THREADS
++#define WITH_THREAD
++#define WINVER 0x0501
++#define HAVE_ADDRINFO
++#define HAVE_GETADDRINFO
++#define HAVE_GETNAMEINFO
++#define HAVE_GETPEERNAME
++#endif
++
+ #ifdef HAVE_STDINT_H
+ #include <stdint.h>
+ #endif
+--- misc/Python-2.6.1/Lib/distutils/ccompiler.py 2008-02-22 03:18:37.000000000 +0900
++++ misc/build/Python-2.6.1/Lib/distutils/ccompiler.py 2009-04-04 01:00:37.014250000 +0900
+@@ -1058,6 +1058,7 @@
+ # on a cygwin built python we can use gcc like an ordinary UNIXish
+ # compiler
+ ('cygwin.*', 'unix'),
++ ('winmingw*', 'unix'),
+ ('os2emx', 'emx'),
+
+ # OS name mappings
+--- misc/Python-2.6.1/Lib/distutils/command/build_ext.py 2008-08-17 13:16:04.000000000 +0900
++++ misc/build/Python-2.6.1/Lib/distutils/command/build_ext.py 2009-04-04 01:05:32.311125000 +0900
+@@ -223,7 +223,7 @@
+
+ # 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[:8] == 'winmingw' or sys.platform[:6] == 'atheos':
+ 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",
+@@ -729,7 +729,7 @@
+ # don't extend ext.libraries, it may be shared with other
+ # extensions, it is a reference to the original list
+ return ext.libraries + [pythonlib]
+- elif sys.platform[:6] == "cygwin":
++ elif sys.platform[:6] == "cygwin" or sys.platform[:8] == "winmingw":
+ template = "python%d.%d"
+ pythonlib = (template %
+ (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
+--- misc/Python-2.6.1/Lib/distutils/command/install.py 2008-05-07 07:41:46.000000000 +0900
++++ misc/build/Python-2.6.1/Lib/distutils/command/install.py 2009-04-05 23:15:56.540750000 +0900
+@@ -362,9 +362,10 @@
+
+ # Convert directories from Unix /-separated syntax to the local
+ # convention.
+- self.convert_paths('lib', 'purelib', 'platlib',
+- 'scripts', 'data', 'headers',
+- 'userbase', 'usersite')
++ if os.sep != '/':
++ self.convert_paths('lib', 'purelib', 'platlib',
++ 'scripts', 'data', 'headers',
++ 'userbase', 'usersite')
+
+ # Well, we're not actually fully completely finalized yet: we still
+ # have to deal with 'extra_path', which is the hack for allowing
+@@ -376,7 +377,7 @@
+
+ # If a new root directory was supplied, make all the installation
+ # dirs relative to it.
+- if self.root is not None:
++ if self.root is not None and self.root != "":
+ self.change_roots('libbase', 'lib', 'purelib', 'platlib',
+ 'scripts', 'data', 'headers')
+
+@@ -515,7 +516,10 @@
+ def convert_paths (self, *names):
+ for name in names:
+ attr = "install_" + name
+- setattr(self, attr, convert_path(getattr(self, attr)))
++ if self.root is None or self.root == "":
++ setattr(self, attr, getattr(self, attr).replace('/', os.sep))
++ else:
++ setattr(self, attr, convert_path(getattr(self, attr)))
+
+
+ def handle_extra_path (self):
+--- misc/Python-2.6.1/Lib/distutils/spawn.py 2004-11-11 07:23:15.000000000 +0900
++++ misc/build/Python-2.6.1/Lib/distutils/spawn.py 2009-03-22 19:38:32.935625000 +0900
+@@ -186,7 +186,7 @@
+ path = os.environ['PATH']
+ paths = string.split(path, os.pathsep)
+ (base, ext) = os.path.splitext(executable)
+- if (sys.platform == 'win32' or os.name == 'os2') and (ext != '.exe'):
++ if (sys.platform == 'win32' or sys.platform[:8] == "winmingw" or os.name == 'os2') and (ext != '.exe'):
+ executable = executable + '.exe'
+ if not os.path.isfile(executable):
+ for p in paths:
+--- misc/Python-2.6.1/Lib/distutils/sysconfig.py 2008-06-05 21:58:24.000000000 +0900
++++ misc/build/Python-2.6.1/Lib/distutils/sysconfig.py 2009-03-29 10:56:10.965750000 +0900
+@@ -381,6 +381,9 @@
+
+ raise DistutilsPlatformError(my_msg)
+
++ if sys.platform[:8] == "winmingw":
++ g['SO'] = '.pyd'
++
+ # On MacOSX we need to check the setting of the environment variable
+ # MACOSX_DEPLOYMENT_TARGET: configure bases some choices on it so
+ # it needs to be compatible.
+@@ -510,6 +513,9 @@
+ global _config_vars
+ if _config_vars is None:
+ func = globals().get("_init_" + os.name)
++ if sys.platform[:8] == "winmingw":
++ func = globals().get("_init_posix")
++
+ if func:
+ func()
+ else:
+--- misc/Python-2.6.1/Lib/distutils/unixccompiler.py 2008-07-16 22:24:06.000000000 +0900
++++ misc/build/Python-2.6.1/Lib/distutils/unixccompiler.py 2009-04-04 01:11:18.420500000 +0900
+@@ -139,7 +139,7 @@
+ shared_lib_extension = ".so"
+ dylib_lib_extension = ".dylib"
+ static_lib_format = shared_lib_format = dylib_lib_format = "lib%s%s"
+- if sys.platform == "cygwin":
++ if sys.platform == "cygwin" or sys.platform == "winmingw":
+ exe_extension = ".exe"
+
+ def preprocess(self, source,
+--- misc/Python-2.6.1/Lib/os.py 2008-09-02 14:36:11.000000000 +0900
++++ misc/build/Python-2.6.1/Lib/os.py 2009-03-22 16:55:18.356375000 +0900
+@@ -38,7 +38,21 @@
+ except AttributeError:
+ return [n for n in dir(module) if n[0] != '_']
+
+-if 'posix' in _names:
++if 'winmingw32' in _names:
++ name = 'nt'
++ linesep = '\r\n'
++ from posix import *
++ try:
++ from posix import _exit
++ except ImportError:
++ pass
++ import ntpath as path
++
++ import posix
++ __all__.extend(_get_exports_list(posix))
++ del posix
++
++elif 'posix' in _names:
+ name = 'posix'
+ linesep = '\n'
+ from posix import *
+--- misc/Python-2.6.1/Lib/socket.py 2008-08-08 13:27:28.000000000 +0900
++++ misc/build/Python-2.6.1/Lib/socket.py 2009-04-02 00:40:46.941750000 +0900
+@@ -148,7 +148,7 @@
+ 'sendall', 'setblocking',
+ 'settimeout', 'gettimeout', 'shutdown')
+
+-if os.name == "nt":
++if os.name == "nt" and sys.platform[:8] != "winmingw":
+ _socketmethods = _socketmethods + ('ioctl',)
+
+ if sys.platform == "riscos":
+--- misc/Python-2.6.1/Makefile.pre.in 2008-10-22 01:48:37.000000000 +0900
++++ misc/build/Python-2.6.1/Makefile.pre.in 2009-04-08 23:38:27.989250000 +0900
+@@ -105,6 +105,16 @@
+ LDSHARED= @LDSHARED@
+ BLDSHARED= @BLDSHARED@
+ DESTSHARED= $(BINLIBDEST)/lib-dynload
++ifeq (@MACHDEP@,winmingw32)
++DESTSHAREDFORRULES= $(shell cd $(DESTSHARED) && pwd || echo DESTSHARED)
++LIBPYTHONPATH= $(shell cd $(DESTDIR)$(LIBDEST) && cmd /c cd | sed -e s:\\\\:/:g)
++DESTPYTHONPATH= $(LIBPYTHONPATH);$(shell cd $(DESTDIR)$(DESTSHARED) && cmd /c cd | sed -e s:\\\\:/:g)
++LIBDESTPARAM= $(shell if test -z "$(DESTDIR)" ; then cd $(LIBDEST) && cmd /c cd | sed -e s:\\\\:/:g ; else echo $(LIBDEST) ; fi)
++PREFIXPARAM= $(shell if test -z "$(DESTDIR)" ; then cd $(prefix) && cmd /c cd | sed -e s:\\\\:/:g ; else echo $(prefix) ; fi)
++BINDIRPARAM= $(shell if test -z "$(DESTDIR)" ; then cd $(BINDIR) && cmd /c cd | sed -e s:\\\\:/:g ; else echo $(BINDIR) ; fi)
++DESTSHAREDPARAM= $(shell if test -z "$(DESTDIR)" ; then cd $(DESTSHARED) && cmd /c cd | sed -e s:\\\\:/:g ; else echo $(DESTSHARED) ; fi)
++DESTDIRPARAM= $(shell if test ! -z "$(DESTDIR)" ; then cd $(DESTDIR) && cmd /c | sed -e s:\\\\:/:g ; fi)
++endif
+
+ # Executable suffix (.exe on Windows and Mac OS X)
+ EXE= @EXEEXT@
+@@ -187,7 +197,7 @@
+ # Modules
+ MODULE_OBJS= \
+ Modules/config.o \
+- Modules/getpath.o \
++ @GETPATH_OBJS@ \
+ Modules/main.o \
+ Modules/gcmodule.o
+
+@@ -507,6 +517,10 @@
+ -DVPATH='"$(VPATH)"' \
+ -o $@ $(srcdir)/Modules/getpath.c
+
++PC/getpathp.o: $(srcdir)/PC/getpathp.c Makefile
++ $(CC) -c $(PY_CFLAGS) -DVERSION='"$(VERSION)"' \
++ -o $@ $(srcdir)/PC/getpathp.c
++
+ Modules/python.o: $(srcdir)/Modules/python.c
+ $(MAINCC) -c $(PY_CFLAGS) -o $@ $(srcdir)/Modules/python.c
+
+@@ -544,6 +558,12 @@
+ Objects/unicodectype.o: $(srcdir)/Objects/unicodectype.c \
+ $(srcdir)/Objects/unicodetype_db.h
+
++Objects/exceptions.o: $(srcdir)/Objects/exceptions.c
++ $(CC) -c $(PY_CFLAGS) -I$(srcdir)/PC -o $@ $(srcdir)/Objects/exceptions.c
++
++PC/import_nt.o: $(srcdir)/PC/import_nt.c
++ $(CC) -c $(PY_CFLAGS) -I$(srcdir)/Python -o $@ $(srcdir)/PC/import_nt.c
++
+ STRINGLIB_HEADERS= \
+ $(srcdir)/Include/bytes_methods.h \
+ $(srcdir)/Objects/stringlib/count.h \
+@@ -727,7 +747,11 @@
+ # Install shared libraries enabled by Setup
+ DESTDIRS= $(exec_prefix) $(LIBDIR) $(BINLIBDEST) $(DESTSHARED)
+
++ifeq (@MACHDEP@,winmingw32)
++oldsharedinstall: $(DESTSHAREDFORRULES) $(SHAREDMODS)
++else
+ oldsharedinstall: $(DESTSHARED) $(SHAREDMODS)
++endif
+ @for i in X $(SHAREDMODS); do \
+ if test $$i != X; then \
+ echo $(INSTALL_SHARED) $$i $(DESTSHARED)/`basename $$i`; \
+@@ -735,7 +759,11 @@
+ fi; \
+ done
+
++ifeq (@MACHDEP@,winmingw32)
++$(DESTSHAREDFORRULES):
++else
+ $(DESTSHARED):
++endif
+ @for i in $(DESTDIRS); \
+ do \
+ if test ! -d $(DESTDIR)$$i; then \
+@@ -822,7 +850,11 @@
+ multiprocessing multiprocessing/dummy \
+ lib-old \
+ curses $(MACHDEPS)
++ifeq (@MACHDEP@,winmingw32)
++libinstall: build_all $(srcdir)/Lib/$(PLATDIR) sharedinstall
++else
+ libinstall: build_all $(srcdir)/Lib/$(PLATDIR)
++endif
+ @for i in $(SCRIPTDIR) $(LIBDEST); \
+ do \
+ if test ! -d $(DESTDIR)$$i; then \
+@@ -878,6 +910,26 @@
+ done; \
+ done
+ $(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
++ifeq (@MACHDEP@,winmingw32)
++ PYTHONPATH="$(DESTPYTHONPATH)" $(RUNSHARED) \
++ ./$(BUILDPYTHON) -Wi -tt $(LIBPYTHONPATH)/compileall.py \
++ -d $(LIBDESTPARAM) -f \
++ -x 'bad_coding|badsyntax|site-packages' $(LIBPYTHONPATH)
++ PYTHONPATH="$(DESTPYTHONPATH)" $(RUNSHARED) \
++ ./$(BUILDPYTHON) -Wi -tt -O $(LIBPYTHONPATH)/compileall.py \
++ -d $(LIBDESTPARAM) -f \
++ -x 'bad_coding|badsyntax|site-packages' $(LIBPYTHONPATH)
++ -PYTHONPATH="$(DESTPYTHONPATH)" $(RUNSHARED) \
++ ./$(BUILDPYTHON) -Wi -t $(LIBPYTHONPATH)/compileall.py \
++ -d $(LIBDESTPARAM)/site-packages -f \
++ -x badsyntax $(LIBPYTHONPATH)/site-packages
++ -PYTHONPATH="$(DESTPYTHONPATH)" $(RUNSHARED) \
++ ./$(BUILDPYTHON) -Wi -t -O $(LIBPYTHONPATH)/compileall.py \
++ -d $(LIBDESTPARAM)/site-packages -f \
++ -x badsyntax $(LIBPYTHONPATH)/site-packages
++ -PYTHONPATH="$(DESTPYTHONPATH)" $(RUNSHARED) \
++ ./$(BUILDPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"
++else
+ PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+ ./$(BUILDPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
+ -d $(LIBDEST) -f \
+@@ -896,16 +948,19 @@
+ -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
+ -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+ ./$(BUILDPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"
++endif
+
+ # Create the PLATDIR source directory, if one wasn't distributed..
+ $(srcdir)/Lib/$(PLATDIR):
+ mkdir $(srcdir)/Lib/$(PLATDIR)
++ifneq (@MACHDEP@,winmingw32)
+ cp $(srcdir)/Lib/plat-generic/regen $(srcdir)/Lib/$(PLATDIR)/regen
+ export PATH; PATH="`pwd`:$$PATH"; \
+ export PYTHONPATH; PYTHONPATH="`pwd`/Lib"; \
+ export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \
+ export EXE; EXE="$(BUILDEXE)"; \
+ cd $(srcdir)/Lib/$(PLATDIR); ./regen
++endif
+
+ # Install the include files
+ INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)
+@@ -992,12 +1047,21 @@
+
+ # Install the dynamically loadable modules
+ # This goes into $(exec_prefix)
++ifeq (@MACHDEP@,winmingw32)
++sharedinstall: $(DESTSHAREDFORRULES)
++ $(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \
++ --prefix=$(PREFIXPARAM) \
++ --install-scripts=$(BINDIRPARAM) \
++ --install-platlib=$(DESTSHAREDPARAM) \
++ --root=$(DESTDIRPARAM)
++else
+ sharedinstall:
+ $(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \
+ --prefix=$(prefix) \
+ --install-scripts=$(BINDIR) \
+ --install-platlib=$(DESTSHARED) \
+ --root=/$(DESTDIR)
++endif
+
+ # Here are a couple of targets for MacOSX again, to install a full
+ # framework-based Python. frameworkinstall installs everything, the
+--- misc/Python-2.6.1/Modules/Setup.config.in 2002-12-13 02:37:50.000000000 +0900
++++ misc/build/Python-2.6.1/Modules/Setup.config.in 2009-03-21 18:46:57.988875000 +0900
+@@ -9,5 +9,9 @@
+ # The signal module
+ @USE_SIGNAL_MODULE@signal signalmodule.c
+
++# The password module
++@USE_PASSWORD_MODULE@pwd pwdmodule.c # this is needed to find out the user's home dir
++ # if $HOME is not set
++
+ # The rest of the modules previously listed in this file are built
+ # by the setup.py script in Python 2.1 and later.
+--- misc/Python-2.6.1/Modules/Setup.dist 2008-11-27 19:15:12.000000000 +0900
++++ misc/build/Python-2.6.1/Modules/Setup.dist 2009-03-21 18:46:53.785750000 +0900
+@@ -114,7 +114,7 @@
+
+ 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
++#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
+--- misc/Python-2.6.1/Modules/_ctypes/libffi/configure 2008-05-24 00:06:50.000000000 +0900
++++ misc/build/Python-2.6.1/Modules/_ctypes/libffi/configure 2009-04-05 08:30:43.964750000 +0900
+@@ -22707,19 +22707,41 @@
+ multilib_arg=
+ fi
+
++case $host_os in
++mingw*)
++ srcdir=`cd $srcdir && cmd /c cd | sed -e 's:\\\\:/:g'`
++ ;;
++esac
++
+ ac_config_commands="$ac_config_commands include"
+
+ ac_config_commands="$ac_config_commands src"
+
+
++case $host_os in
++mingw*)
++ac_config_commands="$ac_config_commands mingw_ffitarget.h"
++
++;;
++*)
+ ac_config_links="$ac_config_links include/ffitarget.h:src/$TARGETDIR/ffitarget.h"
+
++;;
++esac
+
+ ac_config_files="$ac_config_files include/ffi.h"
+
+
++case $host_os in
++mingw*)
++ac_config_commands="$ac_config_commands mingw_ffi_common.h"
++
++;;
++*)
+ ac_config_links="$ac_config_links include/ffi_common.h:include/ffi_common.h"
+
++;;
++esac
+
+ ac_config_files="$ac_config_files fficonfig.py"
+
+@@ -23506,8 +23528,10 @@
+ "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
+ "include") CONFIG_COMMANDS="$CONFIG_COMMANDS include" ;;
+ "src") CONFIG_COMMANDS="$CONFIG_COMMANDS src" ;;
++ "mingw_ffitarget.h") CONFIG_COMMANDS="$CONFIG_COMMANDS mingw_ffitarget.h" ;;
+ "include/ffitarget.h") CONFIG_LINKS="$CONFIG_LINKS include/ffitarget.h:src/$TARGETDIR/ffitarget.h" ;;
+ "include/ffi.h") CONFIG_FILES="$CONFIG_FILES include/ffi.h" ;;
++ "mingw_ffi_common.h") CONFIG_COMMANDS="$CONFIG_COMMANDS mingw_ffi_common.h" ;;
+ "include/ffi_common.h") CONFIG_LINKS="$CONFIG_LINKS include/ffi_common.h:include/ffi_common.h" ;;
+ "fficonfig.py") CONFIG_FILES="$CONFIG_FILES fficonfig.py" ;;
+
+@@ -24386,6 +24410,16 @@
+ test -d src || mkdir src
+ test -d src/$TARGETDIR || mkdir src/$TARGETDIR
+ ;;
++ "mingw_ffitarget.h":C)
++{ echo "$as_me:$LINENO: copying $srcdir/src/$TARGETDIR/ffitarget.h to include/ffitarget.h" >&5
++echo "$as_me: copying $srcdir/src/$TARGETDIR/ffitarget.h to include/ffitarget.h" >&6;}
++cp -p $srcdir/src/$TARGETDIR/ffitarget.h include/ffitarget.h
++ ;;
++ "mingw_ffi_common.h":C)
++{ echo "$as_me:$LINENO: copying $srcdir/include/ffi_common.h to include/ffi_common.h" >&5
++echo "$as_me: copying $srcdir/include/ffi_common.h to include/ffi_common.h" >&6;}
++cp -p $srcdir/include/ffi_common.h include/ffi_common.h
++ ;;
+
+ esac
+ done # for ac_tag
+--- misc/Python-2.6.1/Modules/_ctypes/libffi/configure.ac 2008-05-24 00:06:50.000000000 +0900
++++ misc/build/Python-2.6.1/Modules/_ctypes/libffi/configure.ac 2009-04-05 08:30:27.527250000 +0900
+@@ -358,17 +358,43 @@
+ multilib_arg=
+ fi
+
++case $host_os in
++mingw*)
++ srcdir=`cd $srcdir && cmd /c cd | sed -e 's:\\\\:/:g'`
++ ;;
++esac
++
+ AC_CONFIG_COMMANDS(include, [test -d include || mkdir include])
+ AC_CONFIG_COMMANDS(src, [
+ test -d src || mkdir src
+ test -d src/$TARGETDIR || mkdir src/$TARGETDIR
+ ], [TARGETDIR="$TARGETDIR"])
+
++case $host_os in
++mingw*)
++AC_CONFIG_COMMANDS(mingw_ffitarget.h, [
++AC_MSG_NOTICE(copying $srcdir/src/$TARGETDIR/ffitarget.h to include/ffitarget.h)
++cp -p $srcdir/src/$TARGETDIR/ffitarget.h include/ffitarget.h
++])
++;;
++*)
+ AC_CONFIG_LINKS(include/ffitarget.h:src/$TARGETDIR/ffitarget.h)
++;;
++esac
+
+ AC_CONFIG_FILES(include/ffi.h)
+
++case $host_os in
++mingw*)
++AC_CONFIG_COMMANDS(mingw_ffi_common.h, [
++AC_MSG_NOTICE(copying $srcdir/include/ffi_common.h to include/ffi_common.h)
++cp -p $srcdir/include/ffi_common.h include/ffi_common.h
++])
++;;
++*)
+ AC_CONFIG_LINKS(include/ffi_common.h:include/ffi_common.h)
++;;
++esac
+
+ AC_CONFIG_FILES(fficonfig.py)
+
+--- misc/Python-2.6.1/Modules/_ctypes/libffi/include/ffi.h.in 2008-04-05 01:01:54.000000000 +0900
++++ misc/build/Python-2.6.1/Modules/_ctypes/libffi/include/ffi.h.in 2009-03-24 20:53:04.519875000 +0900
+@@ -350,7 +350,11 @@
+ ffi_type *rtype,
+ ffi_type **atypes);
+
++#ifdef MS_WIN32
++int ffi_call(ffi_cif *cif,
++#else
+ void ffi_call(ffi_cif *cif,
++#endif
+ void (*fn)(void),
+ void *rvalue,
+ void **avalue);
+--- misc/Python-2.6.1/Modules/config.c.in 2008-09-19 08:20:28.000000000 +0900
++++ misc/build/Python-2.6.1/Modules/config.c.in 2009-03-22 16:28:09.418875000 +0900
+@@ -48,6 +48,9 @@
+ {"__builtin__", NULL},
+ {"sys", NULL},
+ {"exceptions", NULL},
++#ifdef __MINGW32__
++ {"winmingw32", NULL},
++#endif
+
+ /* This lives in gcmodule.c */
+ {"gc", initgc},
+--- misc/Python-2.6.1/Modules/posixmodule.c 2008-10-10 03:06:58.000000000 +0900
++++ misc/build/Python-2.6.1/Modules/posixmodule.c 2009-03-22 20:04:01.404375000 +0900
+@@ -131,6 +131,15 @@
+ #define HAVE_FSYNC 1
+ #define fsync _commit
+ #else
++#ifdef __MINGW32__
++#define HAVE_SPAWNV 1
++#define HAVE_EXECV 1
++#define HAVE_GETCWD 1
++#define HAVE_OPENDIR 1
++#define HAVE_PIPE 1
++#define HAVE_POPEN 1
++#define HAVE_SYSTEM 1
++#else
+ #if defined(PYOS_OS2) && defined(PYCC_GCC) || defined(__VMS)
+ /* Everything needed is defined in PC/os2emx/pyconfig.h or vms/pyconfig.h */
+ #else /* all other compilers */
+@@ -156,6 +165,7 @@
+ #define HAVE_WAIT 1
+ #define HAVE_TTYNAME 1
+ #endif /* PYOS_OS2 && PYCC_GCC && __VMS */
++#endif /* __MINGW32__ */
+ #endif /* _MSC_VER */
+ #endif /* __BORLANDC__ */
+ #endif /* ! __WATCOMC__ || __QNX__ */
+@@ -275,6 +285,14 @@
+ #define pclose _pclose
+ #endif /* _MSC_VER */
+
++#ifdef __MINGW32__
++#include "osdefs.h"
++#include <windows.h>
++#include <shellapi.h> /* for ShellExecute() */
++#define popen _popen
++#define pclose _pclose
++#endif
++
+ #if defined(PYCC_VACPP) && defined(PYOS_OS2)
+ #include <io.h>
+ #endif /* OS2 */
+@@ -350,7 +368,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 */
+
+@@ -775,7 +793,7 @@
+ int st_ctime_nsec;
+ };
+
+-static __int64 secs_between_epochs = 11644473600; /* Seconds between 1.1.1601 and 1.1.1970 */
++static __int64 secs_between_epochs = 11644473600LL; /* Seconds between 1.1.1601 and 1.1.1970 */
+
+ static void
+ FILE_TIME_to_time_t_nsec(FILETIME *in_ptr, int *time_out, int* nsec_out)
+@@ -8189,7 +8207,7 @@
+ }
+ #endif
+
+-#ifdef MS_WINDOWS
++#if defined(MS_WINDOWS) && !defined(__MINGW32__)
+
+ PyDoc_STRVAR(win32_urandom__doc__,
+ "urandom(n) -> str\n\n\
+@@ -8605,7 +8623,7 @@
+ #ifdef HAVE_GETLOADAVG
+ {"getloadavg", posix_getloadavg, METH_NOARGS, posix_getloadavg__doc__},
+ #endif
+- #ifdef MS_WINDOWS
++ #if defined(MS_WINDOWS) && !defined(__MINGW32__)
+ {"urandom", win32_urandom, METH_VARARGS, win32_urandom__doc__},
+ #endif
+ #ifdef __VMS
+--- misc/Python-2.6.1/Modules/socketmodule.c 2008-08-12 23:49:50.000000000 +0900
++++ misc/build/Python-2.6.1/Modules/socketmodule.c 2009-03-29 20:55:19.750375000 +0900
+@@ -312,7 +312,7 @@
+ /* Do not include addrinfo.h for MSVC7 or greater. 'addrinfo' and
+ * EAI_* constants are defined in (the already included) ws2tcpip.h.
+ */
+-#else
++#elif !defined(__MINGW32__)
+ # include "addrinfo.h"
+ #endif
+
+--- misc/Python-2.6.1/PC/_winreg.c 2008-06-09 13:58:54.000000000 +0900
++++ misc/build/Python-2.6.1/PC/_winreg.c 2009-04-12 18:25:01.944250000 +0900
+@@ -1630,6 +1630,9 @@
+ }
+
+ #define ADD_KEY(val) inskey(d, #val, val)
++#ifndef 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
+
+ PyMODINIT_FUNC init_winreg(void)
+ {
+--- misc/Python-2.6.1/Python/dynload_win.c 2008-01-24 02:15:06.000000000 +0900
++++ misc/build/Python-2.6.1/Python/dynload_win.c 2009-03-21 22:05:59.683125000 +0900
+@@ -24,6 +24,7 @@
+ /* Case insensitive string compare, to avoid any dependencies on particular
+ C RTL implementations */
+
++#ifndef __MINGW32__
+ static int strcasecmp (char *string1, char *string2)
+ {
+ int first, second;
+@@ -37,6 +38,7 @@
+
+ return (first - second);
+ }
++#endif
+
+
+ /* Function to return the name of the "python" DLL that the supplied module
+--- misc/Python-2.6.1/Python/frozenmain.c 2002-07-01 00:26:10.000000000 +0900
++++ misc/build/Python-2.6.1/Python/frozenmain.c 2009-03-22 15:36:03.993875000 +0900
+@@ -3,7 +3,7 @@
+
+ #include "Python.h"
+
+-#ifdef MS_WINDOWS
++#if defined(MS_WINDOWS) && !defined(__MINGW32__)
+ extern void PyWinFreeze_ExeInit(void);
+ extern void PyWinFreeze_ExeTerm(void);
+ extern int PyInitFrozenExtensions(void);
+@@ -32,12 +32,12 @@
+ setbuf(stderr, (char *)NULL);
+ }
+
+-#ifdef MS_WINDOWS
++#if defined(MS_WINDOWS) && !defined(__MINGW32__)
+ PyInitFrozenExtensions();
+ #endif /* MS_WINDOWS */
+ Py_SetProgramName(argv[0]);
+ Py_Initialize();
+-#ifdef MS_WINDOWS
++#if defined(MS_WINDOWS) && !defined(__MINGW32__)
+ PyWinFreeze_ExeInit();
+ #endif
+
+@@ -60,7 +60,7 @@
+ if (inspect && isatty((int)fileno(stdin)))
+ sts = PyRun_AnyFile(stdin, "<stdin>") != 0;
+
+-#ifdef MS_WINDOWS
++#if defined(MS_WINDOWS) && !defined(__MINGW32__)
+ PyWinFreeze_ExeTerm();
+ #endif
+ Py_Finalize();
+--- misc/Python-2.6.1/configure 2008-11-17 02:57:10.000000000 +0900
++++ misc/build/Python-2.6.1/configure 2009-04-11 16:57:56.149375000 +0900
+@@ -719,8 +719,10 @@
+ USE_THREAD_MODULE
+ LDLAST
+ THREADOBJ
++USE_PASSWORD_MODULE
+ DLINCLDIR
+ DYNLOADFILE
++GETPATH_OBJS
+ MACHDEP_OBJS
+ TRUE
+ LIBOBJS
+@@ -2201,6 +2203,13 @@
+ LDFLAGS="$SGI_ABI $LDFLAGS"
+ MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
+ fi
++case $MACHDEP in
++ *mingw*|*MINGW*|*MinGW*)
++ MACHDEP="winmingw32"
++ ac_sys_system=`uname -s`
++ ac_sys_release=`uname -r`
++ ;;
++esac
+ { echo "$as_me:$LINENO: result: $MACHDEP" >&5
+ echo "${ECHO_T}$MACHDEP" >&6; }
+
+@@ -3995,7 +4004,7 @@
+ if test -z "$enable_shared"
+ then
+ case $ac_sys_system in
+- CYGWIN* | atheos*)
++ CYGWIN* | MINGW* | atheos*)
+ enable_shared="yes";;
+ *)
+ enable_shared="no";;
+@@ -4096,7 +4105,7 @@
+ BeOS*)
+ LDLIBRARY='libpython$(VERSION).so'
+ ;;
+- CYGWIN*)
++ CYGWIN* | MINGW*)
+ LDLIBRARY='libpython$(VERSION).dll.a'
+ DLLLIBRARY='libpython$(VERSION).dll'
+ ;;
+@@ -4142,7 +4151,7 @@
+ esac
+ else # shared is disabled
+ case $ac_sys_system in
+- CYGWIN*)
++ CYGWIN* | MINGW*)
+ BLDLIBRARY='$(LIBRARY)'
+ LDLIBRARY='libpython$(VERSION).dll.a'
+ ;;
+@@ -12645,6 +12654,10 @@
+ _ACEOF
+
+
++ac_cv_sizeof_off_t=`echo $ac_cv_sizeof_off_t | tr -d '\015'`
++ac_cv_sizeof_long=`echo $ac_cv_sizeof_long | tr -d '\015'`
++ac_cv_sizeof_long_long=`echo $ac_cv_sizeof_long_long | tr -d '\015'`
++ac_cv_sizeof_short=`echo $ac_cv_sizeof_short | tr -d '\015'`
+ { echo "$as_me:$LINENO: checking whether to enable large file support" >&5
+ echo $ECHO_N "checking whether to enable large file support... $ECHO_C" >&6; }
+ if test "$have_long_long" = yes -a \
+@@ -12985,7 +12998,7 @@
+ *) SO=.sl;;
+ esac
+ ;;
+- CYGWIN*) SO=.dll;;
++ CYGWIN* | MINGW*) SO=.dll;;
+ *) SO=.so;;
+ esac
+ else
+@@ -13113,7 +13126,7 @@
+ fi;;
+ SCO_SV*) LDSHARED='$(CC) -Wl,-G,-Bexport';;
+ Monterey*) LDSHARED="cc -G -dy -Bdynamic -Bexport -L/usr/lib/ia64l64";;
+- CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
++ CYGWIN* | MINGW*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base ${LDFLAGS}";;
+ atheos*) LDSHARED="gcc -shared";;
+ *) LDSHARED="ld";;
+ esac
+@@ -13205,7 +13218,7 @@
+ LINKFORSHARED="-Xlinker --export-dynamic"
+ fi;;
+ esac;;
+- CYGWIN*)
++ CYGWIN* | MINGW*)
+ if test $enable_shared = "no"
+ then
+ LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
+@@ -13229,7 +13242,7 @@
+ if test ! "$LIBRARY" = "$LDLIBRARY"
+ then
+ case $ac_sys_system in
+- CYGWIN*)
++ CYGWIN* | MINGW*)
+ # Cygwin needs CCSHARED when building extension DLLs
+ # but not when building the interpreter DLL.
+ CFLAGSFORSHARED='';;
+@@ -15443,7 +15456,7 @@
+ #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+ _ACEOF
+ case $ac_sys_system in
+- CYGWIN*)
++ CYGWIN* | MINGW*)
+
+ cat >>confdefs.h <<\_ACEOF
+ #define HAVE_BROKEN_PTHREAD_SIGMASK 1
+@@ -15457,6 +15470,17 @@
+ fi
+
+
++case $MACHDEP in
++winmingw*)
++ THREADOBJ="Python/thread.o"
++ USE_THREAD_MODULE="#"
++ USE_PASSWORD_MODULE="#"
++ ;;
++*)
++ USE_PASSWORD_MODULE=""
++ ;;
++esac
++
+ # Check for enable-ipv6
+
+
+@@ -16057,6 +16081,11 @@
+ # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
+ Darwin/[0156]\..*) DYNLOADFILE="dynload_next.o";;
+ atheos*) DYNLOADFILE="dynload_atheos.o";;
++ CYGWIN* | MINGW*)
++ case $MACHDEP in
++ winmingw*) DYNLOADFILE="dynload_win.o PC/import_nt.o PC/dl_nt.o";;
++ esac
++ ;;
+ *)
+ # use dynload_shlib.c and dlopen() if we have it; otherwise stub
+ # out any dynamic loading
+@@ -16078,6 +16107,21 @@
+
+ fi
+
++
++{ echo "$as_me:$LINENO: checking GETPATH_OBJS" >&5
++echo $ECHO_N "checking GETPATH_OBJS... $ECHO_C" >&6; }
++if test -z "$GETPATH_OBJS"
++then
++ case $MACHDEP in
++ winmingw*)
++ GETPATH_OBJS='PC/getpathp.o';;
++ *)
++ GETPATH_OBJS='Modules/getpath.o';;
++ esac
++fi
++{ echo "$as_me:$LINENO: result: $GETPATH_OBJS" >&5
++echo "${ECHO_T}$GETPATH_OBJS" >&6; }
++
+ # MACHDEP_OBJS can be set to platform-specific object files needed by Python
+
+
+@@ -19952,6 +19996,112 @@
+
+ fi
+
++case $MACHDEP in
++winmingw*)
++{ echo "$as_me:$LINENO: checking for struct stat.st_blocks" >&5
++echo $ECHO_N "checking for struct stat.st_blocks... $ECHO_C" >&6; }
++if test "${ac_cv_member_struct_stat_st_blocks+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++$ac_includes_default
++int
++main ()
++{
++static struct stat ac_aggr;
++if (ac_aggr.st_blocks)
++return 0;
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext
++if { (ac_try="$ac_compile"
++case "(($ac_try" in
++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
++ *) ac_try_echo=$ac_try;;
++esac
++eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
++ (eval "$ac_compile") 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } && {
++ test -z "$ac_c_werror_flag" ||
++ test ! -s conftest.err
++ } && test -s conftest.$ac_objext; then
++ ac_cv_member_struct_stat_st_blocks=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++$ac_includes_default
++int
++main ()
++{
++static struct stat ac_aggr;
++if (sizeof ac_aggr.st_blocks)
++return 0;
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext
++if { (ac_try="$ac_compile"
++case "(($ac_try" in
++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
++ *) ac_try_echo=$ac_try;;
++esac
++eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
++ (eval "$ac_compile") 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } && {
++ test -z "$ac_c_werror_flag" ||
++ test ! -s conftest.err
++ } && test -s conftest.$ac_objext; then
++ ac_cv_member_struct_stat_st_blocks=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ ac_cv_member_struct_stat_st_blocks=no
++fi
++
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++fi
++
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++fi
++{ echo "$as_me:$LINENO: result: $ac_cv_member_struct_stat_st_blocks" >&5
++echo "${ECHO_T}$ac_cv_member_struct_stat_st_blocks" >&6; }
++if test $ac_cv_member_struct_stat_st_blocks = yes; then
++
++cat >>confdefs.h <<_ACEOF
++#define HAVE_STRUCT_STAT_ST_BLOCKS 1
++_ACEOF
++
++
++fi
++
++;;
++*)
+ { echo "$as_me:$LINENO: checking for struct stat.st_blocks" >&5
+ echo $ECHO_N "checking for struct stat.st_blocks... $ECHO_C" >&6; }
+ if test "${ac_cv_member_struct_stat_st_blocks+set}" = set; then
+@@ -20066,6 +20216,8 @@
+ fi
+
+
++;;
++esac
+
+ { echo "$as_me:$LINENO: checking for time.h that defines altzone" >&5
+ echo $ECHO_N "checking for time.h that defines altzone... $ECHO_C" >&6; }
+@@ -22530,6 +22682,7 @@
+
+
+
++ac_cv_sizeof_wchar_t=`echo $ac_cv_sizeof_wchar_t | tr -d '\015'`
+
+ if test "$enable_unicode" = "no"
+ then
+@@ -25368,8 +25521,10 @@
+ USE_THREAD_MODULE!$USE_THREAD_MODULE$ac_delim
+ LDLAST!$LDLAST$ac_delim
+ THREADOBJ!$THREADOBJ$ac_delim
++USE_PASSWORD_MODULE!$USE_PASSWORD_MODULE$ac_delim
+ DLINCLDIR!$DLINCLDIR$ac_delim
+ DYNLOADFILE!$DYNLOADFILE$ac_delim
++GETPATH_OBJS!$GETPATH_OBJS$ac_delim
+ MACHDEP_OBJS!$MACHDEP_OBJS$ac_delim
+ TRUE!$TRUE$ac_delim
+ LIBOBJS!$LIBOBJS$ac_delim
+@@ -25386,7 +25541,7 @@
+ LTLIBOBJS!$LTLIBOBJS$ac_delim
+ _ACEOF
+
+- if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 22; then
++ if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 24; then
+ break
+ elif $ac_last_try; then
+ { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+--- misc/Python-2.6.1/configure.in 2008-11-16 17:02:56.000000000 +0900
++++ misc/build/Python-2.6.1/configure.in 2009-04-11 16:56:07.258750000 +0900
+@@ -359,6 +359,13 @@
+ LDFLAGS="$SGI_ABI $LDFLAGS"
+ MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
+ fi
++case $MACHDEP in
++ *mingw*|*MINGW*|*MinGW*)
++ MACHDEP="winmingw32"
++ ac_sys_system=`uname -s`
++ ac_sys_release=`uname -r`
++ ;;
++esac
+ AC_MSG_RESULT($MACHDEP)
+
+ # And add extra plat-mac for darwin
+@@ -643,7 +650,7 @@
+ if test -z "$enable_shared"
+ then
+ case $ac_sys_system in
+- CYGWIN* | atheos*)
++ CYGWIN* | MINGW* | atheos*)
+ enable_shared="yes";;
+ *)
+ enable_shared="no";;
+@@ -694,7 +701,7 @@
+ BeOS*)
+ LDLIBRARY='libpython$(VERSION).so'
+ ;;
+- CYGWIN*)
++ CYGWIN* | MINGW*)
+ LDLIBRARY='libpython$(VERSION).dll.a'
+ DLLLIBRARY='libpython$(VERSION).dll'
+ ;;
+@@ -740,7 +747,7 @@
+ esac
+ else # shared is disabled
+ case $ac_sys_system in
+- CYGWIN*)
++ CYGWIN* | MINGW*)
+ BLDLIBRARY='$(LIBRARY)'
+ LDLIBRARY='libpython$(VERSION).dll.a'
+ ;;
+@@ -1402,6 +1409,10 @@
+ AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t,
+ [The number of bytes in an off_t.])
+
++ac_cv_sizeof_off_t=`echo $ac_cv_sizeof_off_t | tr -d '\015'`
++ac_cv_sizeof_long=`echo $ac_cv_sizeof_long | tr -d '\015'`
++ac_cv_sizeof_long_long=`echo $ac_cv_sizeof_long_long | tr -d '\015'`
++ac_cv_sizeof_short=`echo $ac_cv_sizeof_short | tr -d '\015'`
+ AC_MSG_CHECKING(whether to enable large file support)
+ if test "$have_long_long" = yes -a \
+ "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
+@@ -1581,7 +1592,7 @@
+ *) SO=.sl;;
+ esac
+ ;;
+- CYGWIN*) SO=.dll;;
++ CYGWIN* | MINGW*) SO=.dll;;
+ *) SO=.so;;
+ esac
+ else
+@@ -1703,7 +1714,7 @@
+ fi;;
+ SCO_SV*) LDSHARED='$(CC) -Wl,-G,-Bexport';;
+ Monterey*) LDSHARED="cc -G -dy -Bdynamic -Bexport -L/usr/lib/ia64l64";;
+- CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
++ CYGWIN* | MINGW*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base ${LDFLAGS}";;
+ atheos*) LDSHARED="gcc -shared";;
+ *) LDSHARED="ld";;
+ esac
+@@ -1791,7 +1802,7 @@
+ LINKFORSHARED="-Xlinker --export-dynamic"
+ fi;;
+ esac;;
+- CYGWIN*)
++ CYGWIN* | MINGW*)
+ if test $enable_shared = "no"
+ then
+ LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
+@@ -1813,7 +1824,7 @@
+ if test ! "$LIBRARY" = "$LDLIBRARY"
+ then
+ case $ac_sys_system in
+- CYGWIN*)
++ CYGWIN* | MINGW*)
+ # Cygwin needs CCSHARED when building extension DLLs
+ # but not when building the interpreter DLL.
+ CFLAGSFORSHARED='';;
+@@ -2149,13 +2160,24 @@
+ fi
+ AC_CHECK_FUNCS(pthread_sigmask,
+ [case $ac_sys_system in
+- CYGWIN*)
++ CYGWIN* | MINGW*)
+ AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
+ [Define if pthread_sigmask() does not work on your system.])
+ ;;
+ esac])
+ fi
+
++AC_SUBST(USE_PASSWORD_MODULE)
++case $MACHDEP in
++winmingw*)
++ THREADOBJ="Python/thread.o"
++ USE_THREAD_MODULE="#"
++ USE_PASSWORD_MODULE="#"
++ ;;
++*)
++ USE_PASSWORD_MODULE=""
++ ;;
++esac
+
+ # Check for enable-ipv6
+ AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
+@@ -2415,6 +2437,11 @@
+ # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
+ Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
+ atheos*) DYNLOADFILE="dynload_atheos.o";;
++ CYGWIN* | MINGW*)
++ case $MACHDEP in
++ winmingw*) DYNLOADFILE="dynload_win.o PC/import_nt.o PC/dl_nt.o";;
++ esac
++ ;;
+ *)
+ # use dynload_shlib.c and dlopen() if we have it; otherwise stub
+ # out any dynamic loading
+@@ -2432,6 +2459,19 @@
+ [Defined when any dynamic module loading is enabled.])
+ fi
+
++AC_SUBST(GETPATH_OBJS)
++AC_MSG_CHECKING(GETPATH_OBJS)
++if test -z "$GETPATH_OBJS"
++then
++ case $MACHDEP in
++ winmingw*)
++ GETPATH_OBJS='PC/getpathp.o';;
++ *)
++ GETPATH_OBJS='Modules/getpath.o';;
++ esac
++fi
++AC_MSG_RESULT($GETPATH_OBJS)
++
+ # MACHDEP_OBJS can be set to platform-specific object files needed by Python
+
+ AC_SUBST(MACHDEP_OBJS)
+@@ -2862,7 +2902,14 @@
+ AC_CHECK_MEMBERS([struct stat.st_flags])
+ AC_CHECK_MEMBERS([struct stat.st_gen])
+ AC_CHECK_MEMBERS([struct stat.st_birthtime])
++case $MACHDEP in
++winmingw*)
++AC_CHECK_MEMBERS([struct stat.st_blocks])
++;;
++*)
+ AC_STRUCT_ST_BLOCKS
++;;
++esac
+
+ AC_MSG_CHECKING(for time.h that defines altzone)
+ AC_CACHE_VAL(ac_cv_header_time_altzone,
+@@ -3247,6 +3294,7 @@
+ AH_TEMPLATE(PY_UNICODE_TYPE,
+ [Define as the integral type used for Unicode representation.])
+
++ac_cv_sizeof_wchar_t=`echo $ac_cv_sizeof_wchar_t | tr -d '\015'`
+ AC_SUBST(UNICODE_OBJS)
+ if test "$enable_unicode" = "no"
+ then
+--- misc/Python-2.6.1/setup.py 2008-11-05 05:43:31.000000000 +0900
++++ misc/build/Python-2.6.1/setup.py 2009-04-12 16:02:22.654125000 +0900
+@@ -234,6 +234,18 @@
+ if not self.configure_ctypes(ext):
+ return
+
++ if self.get_platform() == "winmingw":
++ if ext.name == '_ctypes_test':
++ ext.libraries.append('oleaut32')
++ elif ext.name == 'select':
++ ext.libraries.append('ws2_32')
++ elif ext.name == '_socket':
++ ext.libraries.append('ws2_32')
++ if ext.name == '_ctypes':
++ ext.libraries.append('uuid')
++ ext.libraries.append('oleaut32')
++ ext.libraries.append('ole32')
++
+ try:
+ build_ext.build_extension(self, ext)
+ except (CCompilerError, DistutilsError), why:
+@@ -263,7 +275,7 @@
+
+ # Workaround for Cygwin: Cygwin currently has fork issues when many
+ # modules have been imported
+- if self.get_platform() == 'cygwin':
++ if self.get_platform() in ['cygwin', 'winmingw']:
+ self.announce('WARNING: skipping import check for Cygwin-based "%s"'
+ % ext.name)
+ return
+@@ -303,7 +315,7 @@
+
+ def get_platform(self):
+ # Get value of sys.platform
+- for platform in ['cygwin', 'beos', 'darwin', 'atheos', 'osf1']:
++ for platform in ['cygwin', 'winmingw', 'beos', 'darwin', 'atheos', 'osf1']:
+ if sys.platform.startswith(platform):
+ return platform
+ return sys.platform
+@@ -1009,7 +1021,7 @@
+ missing.append('bsddb185')
+
+ # The standard Unix dbm module:
+- if platform not in ['cygwin']:
++ if platform not in ['cygwin', 'winmingw']:
+ 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'):
+@@ -1053,7 +1065,7 @@
+ missing.append('resource')
+
+ # Sun yellow pages. Some systems have the functions in libc.
+- if platform not in ['cygwin', 'atheos', 'qnx6']:
++ if platform not in ['cygwin', 'winmingw', 'atheos', 'qnx6']:
+ if (self.compiler.find_library_file(lib_dirs, 'nsl')):
+ libs = ['nsl']
+ else:
+@@ -1252,14 +1264,14 @@
+ )
+ libraries = []
+
+- elif platform == 'cygwin': # Cygwin
++ elif platform in ['cygwin', 'winmingw']: # Cygwin
+ macros = dict(
+ HAVE_SEM_OPEN=1,
+ HAVE_SEM_TIMEDWAIT=1,
+ HAVE_FD_TRANSFER=0,
+ HAVE_BROKEN_SEM_UNLINK=1
+ )
+- libraries = []
++ libraries = ['ws2_32']
+
+ elif platform in ('freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', 'freebsd8'):
+ # FreeBSD's P1003.1b semaphore support is very experimental
+@@ -1287,7 +1299,7 @@
+ )
+ libraries = ['rt']
+
+- if platform == 'win32':
++ if platform in ['win32', 'winmingw']:
+ multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c',
+ '_multiprocessing/semaphore.c',
+ '_multiprocessing/pipe_connection.c',
+@@ -1305,6 +1317,7 @@
+
+ exts.append ( Extension('_multiprocessing', multiprocessing_srcs,
+ define_macros=macros.items(),
++ libraries=libraries,
+ include_dirs=["Modules/_multiprocessing"]))
+ # End multiprocessing
+
+@@ -1423,6 +1436,10 @@
+ '-framework', 'Carbon']) )
+
+
++ if platform == 'winmingw':
++ exts.append( Extension('_winreg', ['../PC/_winreg.c']) )
++ exts.append( Extension('winsound', ['../PC/winsound.c'], libraries = ['winmm']) )
++
+ self.extensions.extend(exts)
+
+ # Call the method for detecting whether _tkinter can be compiled
+@@ -1575,7 +1592,7 @@
+ added_lib_dirs.append('/usr/X11/lib')
+
+ # If Cygwin, then verify that X is installed before proceeding
+- if platform == 'cygwin':
++ if platform in ['cygwin', 'winmingw']:
+ x11_inc = find_file('X11/Xlib.h', [], include_dirs)
+ if x11_inc is None:
+ return
+@@ -1598,7 +1615,7 @@
+ libs.append('ld')
+
+ # Finally, link with the X11 libraries (not appropriate on cygwin)
+- if platform != "cygwin":
++ if not platform in ["cygwin", "winmingw"]:
+ libs.append('X11')
+
+ ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
+@@ -1669,6 +1686,8 @@
+ from distutils.dir_util import mkpath
+ mkpath(ffi_builddir)
+ config_args = []
++ if self.get_platform() == "winmingw":
++ config_args.append(" --build=mingw32")
+
+ # Pass empty CFLAGS because we'll just append the resulting
+ # CFLAGS to Python's; -g or -O2 is to be avoided.
diff --git a/python/Python-2.6.1.patch b/python/Python-2.6.1.patch
new file mode 100644
index 000000000000..781889d84e3f
--- /dev/null
+++ b/python/Python-2.6.1.patch
@@ -0,0 +1,232 @@
+--- misc/Python-2.6.1/Include/pyport.h Wed Jun 11 09:41:16 2008
++++ misc/build/Python-2.6.1/Include/pyport.h Fri Apr 17 09:02:52 2009
+@@ -449,11 +449,6 @@
+ in platform-specific #ifdefs.
+ **************************************************************************/
+
+-#ifdef SOLARIS
+-/* Unchecked */
+-extern int gethostname(char *, int);
+-#endif
+-
+ #ifdef __BEOS__
+ /* Unchecked */
+ /* It's in the libs, but not the headers... - [cjh] */
+--- misc/Python-2.6.1/PCbuild/pcbuild.sln 2008-06-27 04:30:34.000000000 +0200
++++ misc/build/Python-2.6.1/PCbuild/pcbuild.sln 2009-03-09 22:48:14.546329900 +0100
+@@ -38,12 +38,12 @@
+ {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}
+ EndProjectSection
+ EndProject
+-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_bsddb", "_bsddb.vcproj", "{B4D38F3F-68FB-42EC-A45D-E00657BB3627}"
+- ProjectSection(ProjectDependencies) = postProject
+- {6DE10744-E396-40A5-B4E2-1B69AA7C8D31} = {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}
+- {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}
+- EndProjectSection
+-EndProject
++#Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_bsddb", "_bsddb.vcproj", "{B4D38F3F-68FB-42EC-A45D-E00657BB3627}"
++# ProjectSection(ProjectDependencies) = postProject
++# {6DE10744-E396-40A5-B4E2-1B69AA7C8D31} = {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}
++# {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}
++# EndProjectSection
++#EndProject
+ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_ctypes", "_ctypes.vcproj", "{0E9791DB-593A-465F-98BC-681011311618}"
+ ProjectSection(ProjectDependencies) = postProject
+ {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}
+@@ -69,34 +69,34 @@
+ {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}
+ EndProjectSection
+ EndProject
+-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_sqlite3", "_sqlite3.vcproj", "{13CECB97-4119-4316-9D42-8534019A5A44}"
+- ProjectSection(ProjectDependencies) = postProject
+- {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}
+- {A1A295E5-463C-437F-81CA-1F32367685DA} = {A1A295E5-463C-437F-81CA-1F32367685DA}
+- EndProjectSection
+-EndProject
+-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_ssl", "_ssl.vcproj", "{C6E20F84-3247-4AD6-B051-B073268F73BA}"
+- ProjectSection(ProjectDependencies) = postProject
+- {B11D750F-CD1F-4A96-85CE-E69A5C5259F9} = {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}
+- {86937F53-C189-40EF-8CE8-8759D8E7D480} = {86937F53-C189-40EF-8CE8-8759D8E7D480}
+- {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}
+- EndProjectSection
+-EndProject
++#Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_sqlite3", "_sqlite3.vcproj", "{13CECB97-4119-4316-9D42-8534019A5A44}"
++# ProjectSection(ProjectDependencies) = postProject
++# {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}
++# {A1A295E5-463C-437F-81CA-1F32367685DA} = {A1A295E5-463C-437F-81CA-1F32367685DA}
++# EndProjectSection
++#EndProject
++#Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_ssl", "_ssl.vcproj", "{C6E20F84-3247-4AD6-B051-B073268F73BA}"
++# ProjectSection(ProjectDependencies) = postProject
++# {B11D750F-CD1F-4A96-85CE-E69A5C5259F9} = {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}
++# {86937F53-C189-40EF-8CE8-8759D8E7D480} = {86937F53-C189-40EF-8CE8-8759D8E7D480}
++# {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}
++# EndProjectSection
++#EndProject
+ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_testcapi", "_testcapi.vcproj", "{6901D91C-6E48-4BB7-9FEC-700C8131DF1D}"
+ ProjectSection(ProjectDependencies) = postProject
+ {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}
+ EndProjectSection
+ EndProject
+-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_tkinter", "_tkinter.vcproj", "{4946ECAC-2E69-4BF8-A90A-F5136F5094DF}"
+- ProjectSection(ProjectDependencies) = postProject
+- {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}
+- EndProjectSection
+-EndProject
+-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bz2", "bz2.vcproj", "{73FCD2BD-F133-46B7-8EC1-144CD82A59D5}"
+- ProjectSection(ProjectDependencies) = postProject
+- {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}
+- EndProjectSection
+-EndProject
++#Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_tkinter", "_tkinter.vcproj", "{4946ECAC-2E69-4BF8-A90A-F5136F5094DF}"
++# ProjectSection(ProjectDependencies) = postProject
++# {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}
++# EndProjectSection
++#EndProject
++#Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bz2", "bz2.vcproj", "{73FCD2BD-F133-46B7-8EC1-144CD82A59D5}"
++# ProjectSection(ProjectDependencies) = postProject
++# {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}
++# EndProjectSection
++#EndProject
+ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "select", "select.vcproj", "{18CAE28C-B454-46C1-87A0-493D91D97F03}"
+ ProjectSection(ProjectDependencies) = postProject
+ {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}
+@@ -114,17 +114,17 @@
+ EndProject
+ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bdist_wininst", "bdist_wininst.vcproj", "{EB1C19C1-1F18-421E-9735-CAEE69DC6A3C}"
+ EndProject
+-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_hashlib", "_hashlib.vcproj", "{447F05A8-F581-4CAC-A466-5AC7936E207E}"
+- ProjectSection(ProjectDependencies) = postProject
+- {B11D750F-CD1F-4A96-85CE-E69A5C5259F9} = {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}
+- {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}
+- EndProjectSection
+-EndProject
+-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqlite3", "sqlite3.vcproj", "{A1A295E5-463C-437F-81CA-1F32367685DA}"
+- ProjectSection(ProjectDependencies) = postProject
+- {6DE10744-E396-40A5-B4E2-1B69AA7C8D31} = {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}
+- EndProjectSection
+-EndProject
++#Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_hashlib", "_hashlib.vcproj", "{447F05A8-F581-4CAC-A466-5AC7936E207E}"
++#ProjectSection(ProjectDependencies) = postProject
++# {B11D750F-CD1F-4A96-85CE-E69A5C5259F9} = {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}
++# {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}
++# EndProjectSection
++#EndProject
++#Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqlite3", "sqlite3.vcproj", "{A1A295E5-463C-437F-81CA-1F32367685DA}"
++# ProjectSection(ProjectDependencies) = postProject
++# {6DE10744-E396-40A5-B4E2-1B69AA7C8D31} = {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}
++# EndProjectSection
++#EndProject
+ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_multiprocessing", "_multiprocessing.vcproj", "{9E48B300-37D1-11DD-8C41-005056C00008}"
+ ProjectSection(ProjectDependencies) = postProject
+ {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}
+--- misc/Python-2.6.1/Lib/test/test_threading.py.bak 2009-03-12 07:59:17.000000000 +0000
++++ misc/build/Python-2.6.1/Lib/test/test_threading.py 2009-03-12 10:48:04.000000000 +0000
+@@ -382,7 +382,7 @@
+ return
+ # Skip platforms with known problems forking from a worker thread.
+ # See http://bugs.python.org/issue3863.
+- if sys.platform in ('freebsd4', 'freebsd5', 'freebsd6', 'os2emx'):
++ if sys.platform in ('freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', 'os2emx'):
+ print >>sys.stderr, ('Skipping test_3_join_in_forked_from_thread'
+ ' due to known OS bugs on'), sys.platform
+ return
+
+--- misc/Python-2.6.1/Modules/_ctypes/libffi/configure.orig 2008-05-24 00:06:50.000000000 +0900
++++ misc/build/Python-2.6.1/Modules/_ctypes/libffi/configure 2008-10-09 20:24:02.000000000 +0900
+@@ -4725,7 +4725,7 @@
+ rm -rf conftest*
+ ;;
+
+-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
++amd64-*-freebsd*|x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
+ s390*-*linux*|sparc*-*linux*)
+ # Find out which ABI we are using.
+
+--- misc/Python-2.6.1/Python/thread_pthread.h.orig 2006-06-13 16:04:24.000000000 +0100
++++ misc/build/Python-2.6.1/Python/thread_pthread.h 2009-03-12 10:55:49.000000000 +0000
+@@ -26,13 +26,18 @@
+ #endif
+ #endif
+
++#ifdef __FreeBSD__
++#include <osreldate.h>
++#endif
++
+ /* The POSIX spec says that implementations supporting the sem_*
+ family of functions must indicate this by defining
+ _POSIX_SEMAPHORES. */
+ #ifdef _POSIX_SEMAPHORES
+ /* On FreeBSD 4.x, _POSIX_SEMAPHORES is defined empty, so
+ we need to add 0 to make it work there as well. */
+-#if (_POSIX_SEMAPHORES+0) == -1
++#if defined(__FreeBSD__) && __FreeBSD_version < 701104 && \
++ (_POSIX_SEMAPHORES+0) == -1
+ #define HAVE_BROKEN_POSIX_SEMAPHORES
+ #else
+ #include <semaphore.h>
+@@ -44,7 +49,6 @@
+ in default setting. So the process scope is preferred to get
+ enough number of threads to work. */
+ #ifdef __FreeBSD__
+-#include <osreldate.h>
+ #if __FreeBSD_version >= 500000 && __FreeBSD_version < 504101
+ #undef PTHREAD_SYSTEM_SCHED_SUPPORTED
+ #endif
+@@ -149,6 +153,9 @@
+ {
+ pthread_t th;
+ int status;
++#ifdef __FreeBSD__
++ sigset_t set, oset;
++#endif
+ #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
+ pthread_attr_t attrs;
+ #endif
+@@ -177,7 +184,10 @@
+ #if defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
+ pthread_attr_setscope(&attrs, PTHREAD_SCOPE_SYSTEM);
+ #endif
+-
++#ifdef __FreeBSD__
++ sigfillset(&set);
++ SET_THREAD_SIGMASK(SIG_BLOCK, &set, &oset);
++#endif
+ status = pthread_create(&th,
+ #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
+ &attrs,
+@@ -188,6 +198,9 @@
+ (void *)arg
+ );
+
++#ifdef __FreeBSD__
++ SET_THREAD_SIGMASK(SIG_SETMASK, &oset, NULL);
++#endif
+ #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
+ pthread_attr_destroy(&attrs);
+ #endif
+--- misc/Python-2.6.1/configure 2008-11-17 02:57:10.000000000 +0900
++++ misc/build/Python-2.6.1/configure 2009-03-23 21:18:42.000000000 +0900
+@@ -4110,11 +4110,6 @@
+ LDLIBRARY='libpython$(VERSION).so'
+ BLDLIBRARY='-L. -lpython$(VERSION)'
+ RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
+- case $ac_sys_system in
+- FreeBSD*)
+- SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
+- ;;
+- esac
+ INSTSONAME="$LDLIBRARY".$SOVERSION
+ ;;
+ hp*|HP*)
+--- misc/Python-2.6.1/configure Sun Nov 16 18:57:10 2008
++++ misc/build/Python-2.6.1/configure Thu Apr 16 15:16:03 2009
+@@ -4102,7 +4102,7 @@
+ ;;
+ SunOS*)
+ LDLIBRARY='libpython$(VERSION).so'
+- BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
++ BLDLIBRARY=-R\'\$\$ORIGIN\'' -L. -lpython$(VERSION)'
+ RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
+ INSTSONAME="$LDLIBRARY".$SOVERSION
+ ;;
diff --git a/python/makefile.mk b/python/makefile.mk
new file mode 100644
index 000000000000..a84fccb6c9fc
--- /dev/null
+++ b/python/makefile.mk
@@ -0,0 +1,158 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2008 by Sun Microsystems, Inc.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.39 $
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org 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 Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=.
+
+PRJNAME=so_python
+TARGET=so_python
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : pyversion.mk
+
+.IF "$(SYSTEM_PYTHON)" == "YES"
+all:
+ @echo "An already available installation of python should exist on your system."
+ @echo "Therefore the version provided here does not need to be built in addition."
+.ENDIF
+
+
+# --- Files --------------------------------------------------------
+
+
+TARFILE_NAME=Python-$(PYVERSION)
+PATCH_FILES=Python-$(PYVERSION).patch
+
+CONFIGURE_DIR=
+
+.IF "$(GUI)"=="UNX"
+BUILD_DIR=
+MYCWD=$(shell @pwd)/$(INPATH)/misc/build
+
+# CLFLAGS get overwritten in Makefile.pre.in
+.IF "$(SYSBASE)"!=""
+CC+:=-I$(SYSBASE)$/usr$/include
+python_LDFLAGS+=-L$(SYSBASE)/usr/lib
+.IF "$(COMNAME)"=="sunpro5"
+CC+:=$(C_RESTRICTIONFLAGS)
+.ENDIF # "$(COMNAME)"=="sunpro5"
+.ENDIF # "$(SYSBASE)"!=""
+
+.IF "$(OS)$(COM)"=="LINUXGCC"
+python_LDFLAGS+=-Wl,-z,noexecstack
+.ENDIF
+
+.IF "$(OS)$(CPU)"=="SOLARISU"
+CC+:=$(ARCH_FLAGS)
+python_LDFLAGS+=$(ARCH_FLAGS)
+.ENDIF
+
+CONFIGURE_ACTION=$(AUGMENT_LIBRARY_PATH) ./configure --prefix=$(MYCWD)/python-inst --enable-shared CFLAGS="$(python_CFLAGS)" LDFLAGS="$(python_LDFLAGS)"
+.IF "$(OS)$(CPU)" == "SOLARISI"
+CONFIGURE_ACTION += --disable-ipv6
+.ENDIF
+.IF "$(OS)" == "IRIX"
+BUILD_ACTION=$(ENV_BUILD) gmake -j$(EXTMAXPROCESS) ; gmake install
+.ELSE
+BUILD_ACTION=$(ENV_BUILD) $(GNUMAKE) -j$(EXTMAXPROCESS) ; $(GNUMAKE) install ; chmod -R ug+w $(MYCWD)/python-inst
+.ENDIF
+.ELSE
+# ----------------------------------
+# WINDOWS
+# ----------------------------------
+.IF "$(COM)"=="GCC"
+PATCH_FILES=Python-$(PYVERSION)-mingw.patch
+BUILD_DIR=
+MYCWD=$(shell cygpath -m $(shell @pwd))/$(INPATH)/misc/build
+python_CFLAGS=-mno-cygwin -mthreads
+python_LDFLAGS=-mno-cygwin -mthreads
+CONFIGURE_ACTION=./configure --prefix=$(MYCWD)/python-inst --enable-shared CC="$(CC:s/guw.exe //)" CXX="$(CXX:s/guw.exe //)" MACHDEP=MINGW32 LN="cp -p" CFLAGS="$(python_CFLAGS)" LDFLAGS="$(python_LDFLAGS)"
+BUILD_ACTION=$(ENV_BUILD) make ; make install
+.ELSE
+#PYTHONPATH:=..$/Lib
+#.EXPORT : PYTHONPATH
+
+#.IF "$(CCNUMVER)" <= "001400000000"
+#EXFLAGS="/GX /YX"
+#.ELSE
+#.IF "$(WINDOWS_VISTA_PSDK)"!=""
+#EXFLAGS="/EHa /Zc:wchar_t- /D "_CRT_SECURE_NO_DEPRECATE""
+#ADDITIONALLIBS=ws2_32.lib
+#.ELSE #"$(WINDOWS_VISTA_PSDK)"!=""
+#EXFLAGS="/EHa /Zc:wchar_t- /D "_CRT_SECURE_NO_DEPRECATE""
+#.ENDIF #"$(WINDOWS_VISTA_PSDK)"!=""
+#.ENDIF
+
+BUILD_DIR=PCbuild
+
+# Build python executable and then runs a minimal script. Running the minimal script
+# ensures that certain *.pyc files are generated which would otherwise be created on
+# solver during registration in insetoo_native
+.IF "$(SYSBASE)" != ""
+BUILD_ACTION=$(COMPATH)$/vcpackages$/vcbuild.exe -useenv pcbuild.sln "Release|Win32"
+.ELSE
+BUILD_ACTION=$(COMPATH)$/vcpackages$/vcbuild.exe pcbuild.sln "Release|Win32"
+.ENDIF # "$(SYSBASE)" != ""
+.ENDIF
+.ENDIF
+
+PYVERSIONFILE=$(MISC)$/pyversion.mk
+
+# --- Targets ------------------------------------------------------
+
+
+.INCLUDE : set_ext.mk
+.INCLUDE : target.mk
+.INCLUDE : tg_ext.mk
+
+.IF "$(L10N_framework)"==""
+.IF "$(GUI)" != "UNX"
+.IF "$(COM)"!="GCC"
+PYCONFIG:=$(MISC)$/build$/pyconfig.h
+$(MISC)$/build$/$(TARFILE_NAME)$/PC$/pyconfig.h : $(PACKAGE_DIR)$/$(CONFIGURE_FLAG_FILE)
+
+$(PACKAGE_DIR)$/$(BUILD_FLAG_FILE) : $(PYCONFIG)
+
+$(PYCONFIG) : $(MISC)$/build$/$(TARFILE_NAME)$/PC$/pyconfig.h
+ -rm -f $@
+ cat $(MISC)$/build$/$(TARFILE_NAME)$/PC$/pyconfig.h > $@
+.ENDIF
+.ENDIF
+
+ALLTAR : $(PYVERSIONFILE)
+.ENDIF # "$(L10N_framework)"==""
+
+
+$(PYVERSIONFILE) : pyversion.mk $(PACKAGE_DIR)$/$(PREDELIVER_FLAG_FILE)
+ -rm -f $@
+ cat $? > $@
+
diff --git a/python/prj/build.lst b/python/prj/build.lst
new file mode 100644
index 000000000000..e7421332a750
--- /dev/null
+++ b/python/prj/build.lst
@@ -0,0 +1,3 @@
+py python : SO:so_prereq solenv NULL
+py python nmake - w,vc7 py_mkout NULL
+py python nmake - u py_mkout NULL
diff --git a/python/prj/d.lst b/python/prj/d.lst
new file mode 100644
index 000000000000..3ea7a063902c
--- /dev/null
+++ b/python/prj/d.lst
@@ -0,0 +1,108 @@
+mkdir: %_DEST%\lib%_EXT%\python
+mkdir: %_DEST%\lib%_EXT%\python\lib-old
+mkdir: %_DEST%\lib%_EXT%\python\lib-tk
+mkdir: %_DEST%\lib%_EXT%\python\site-packages
+mkdir: %_DEST%\lib%_EXT%\python\encodings
+mkdir: %_DEST%\lib%_EXT%\python\test
+mkdir: %_DEST%\lib%_EXT%\python\test\output
+mkdir: %_DEST%\lib%_EXT%\python\test\data
+mkdir: %_DEST%\lib%_EXT%\python\email
+mkdir: %_DEST%\lib%_EXT%\python\email\mime
+mkdir: %_DEST%\lib%_EXT%\python\compiler
+mkdir: %_DEST%\lib%_EXT%\python\hotshot
+mkdir: %_DEST%\lib%_EXT%\python\distutils
+mkdir: %_DEST%\lib%_EXT%\python\distutils\command
+mkdir: %_DEST%\lib%_EXT%\python\xml
+mkdir: %_DEST%\lib%_EXT%\python\xml\dom
+mkdir: %_DEST%\lib%_EXT%\python\xml\parsers
+mkdir: %_DEST%\lib%_EXT%\python\xml\sax
+mkdir: %_DEST%\lib%_EXT%\python\xml\etree
+mkdir: %_DEST%\lib%_EXT%\python\curses
+mkdir: %_DEST%\lib%_EXT%\python\plat-linux2
+mkdir: %_DEST%\lib%_EXT%\python\config
+mkdir: %_DEST%\lib%_EXT%\python\lib-dynload
+mkdir: %_DEST%\lib%_EXT%\python\bsddb
+mkdir: %_DEST%\lib%_EXT%\python\logging
+mkdir: %_DEST%\lib%_EXT%\python\idlelib
+mkdir: %_DEST%\lib%_EXT%\python\idlelib\Icons
+mkdir: %_DEST%\lib%_EXT%\python\wsgiref
+mkdir: %_DEST%\lib%_EXT%\python\json
+mkdir: %_DEST%\lib%_EXT%\python\lib2to3
+mkdir: %_DEST%\lib%_EXT%\python\lib2to3\fixes
+mkdir: %_DEST%\lib%_EXT%\python\lib2to3\pgen2
+mkdir: %_DEST%\lib%_EXT%\python\sqlite3
+mkdir: %_DEST%\lib%_EXT%\python\ctypes
+mkdir: %_DEST%\lib%_EXT%\python\ctypes\macholib
+
+..\%__SRC%\misc\build\Python-2.6.1\Lib\* %_DEST%\lib%_EXT%\python\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\lib-old\* %_DEST%\lib%_EXT%\python\lib-old\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\lib-tk\* %_DEST%\lib%_EXT%\python\lib-tk\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\site-packages\* %_DEST%\lib%_EXT%\python\site-packages\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\test\* %_DEST%\lib%_EXT%\python\test\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\test\output\* %_DEST%\lib%_EXT%\python\test\output\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\test\data\* %_DEST%\lib%_EXT%\python\test\data\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\encodings\* %_DEST%\lib%_EXT%\python\encodings\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\email\* %_DEST%\lib%_EXT%\python\email\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\email\mime\* %_DEST%\lib%_EXT%\python\email\mime\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\compiler\* %_DEST%\lib%_EXT%\python\compiler\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\hotshot\* %_DEST%\lib%_EXT%\python\hotshot\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\distutils\* %_DEST%\lib%_EXT%\python\distutils\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\distutils\command\* %_DEST%\lib%_EXT%\python\distutils\command\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\xml\* %_DEST%\lib%_EXT%\python\xml\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\xml\dom\* %_DEST%\lib%_EXT%\python\xml\dom\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\xml\parsers\* %_DEST%\lib%_EXT%\python\xml\parsers\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\xml\sax\* %_DEST%\lib%_EXT%\python\xml\sax\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\curses\* %_DEST%\lib%_EXT%\python\curses\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\plat-linux2\* %_DEST%\lib%_EXT%\python\plat-linux2\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\config\* %_DEST%\lib%_EXT%\python\config\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\bsddb\* %_DEST%\lib%_EXT%\python\bsddb\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\logging\* %_DEST%\lib%_EXT%\python\logging\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\idlelib\* %_DEST%\lib%_EXT%\python\idlelib\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\idlelib\Icons\* %_DEST%\lib%_EXT%\python\idlelib\Icons\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\wsgiref\* %_DEST%\lib%_EXT%\python\wsgiref\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\json\* %_DEST%\lib%_EXT%\python\json\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\lib2to3\* %_DEST%\lib%_EXT%\python\lib2to3\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\lib2to3\fixes\* %_DEST%\lib%_EXT%\python\lib2to3\fixes\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\lib2to3\pgen2\* %_DEST%\lib%_EXT%\python\lib2to3\pgen2\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\sqlite3\* %_DEST%\lib%_EXT%\python\sqlite3\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\ctypes\* %_DEST%\lib%_EXT%\python\ctypes\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\ctypes\macholib\* %_DEST%\lib%_EXT%\python\ctypes\macholib\*
+..\%__SRC%\misc\build\Python-2.6.1\Lib\xml\etree\* %_DEST%\lib%_EXT%\python\xml\etree
+
+..\pyversion.mk %_DEST%\inc%_EXT%\pyversion.mk
+
+..\%__SRC%\misc\build\Python-2.6.1\Include\* %_DEST%\inc%_EXT%\python\*
+
+#unix ONLY !
+..\%__SRC%\misc\build\python-inst\bin\python %_DEST%\bin%_EXT%\python
+..\%__SRC%\misc\build\Python-2.6.1\pyconfig.h %_DEST%\inc%_EXT%\python\pyconfig.h
+..\%__SRC%\misc\build\python-inst\lib\python2.6\lib-dynload\* %_DEST%\lib%_EXT%\python\lib-dynload\*
+..\%__SRC%\misc\build\python-inst\bin\python2.6 %_DEST%\bin%_EXT%\python
+..\%__SRC%\misc\build\python-inst\lib\libpython2.6.so.1.0 %_DEST%\lib%_EXT%\libpython2.6.so.1.0
+symlink: %_DEST%\lib%_EXT%\libpython2.6.so.1.0 %_DEST%\lib%_EXT%\libpython2.6.so
+
+# MacOS X
+..\%__SRC%\misc\build\python-inst\lib\libpython2.6.dylib %_DEST%\lib%_EXT%\libpython2.6.dylib
+
+#MingW ONLY !
+..\%__SRC%\misc\build\python-inst\bin\python.exe %_DEST%\bin%_EXT%\python.exe
+..\%__SRC%\misc\build\Python-2.6.1\libpython2.6.dll %_DEST%\bin%_EXT%\libpython2.6.dll
+
+# WINDOWS ONLY !
+..\%__SRC%\misc\build\pyconfig.h %_DEST%\inc%_EXT%\python\pyconfig.h
+..\%__SRC%\misc\build\Python-2.6.1\PCbuild\python.exe %_DEST%\bin%_EXT%\python.exe
+..\%__SRC%\misc\build\Python-2.6.1\PCbuild\python26.dll %_DEST%\bin%_EXT%\python26.dll
+..\%__SRC%\misc\build\Python-2.6.1\PCbuild\python26.lib %_DEST%\lib%_EXT%\python26.lib
+..\%__SRC%\misc\build\Python-2.6.1\PCbuild\_socket.pyd %_DEST%\lib%_EXT%\python\_socket.pyd
+..\%__SRC%\misc\build\Python-2.6.1\PCbuild\select.pyd %_DEST%\lib%_EXT%\python\select.pyd
+..\%__SRC%\misc\build\Python-2.6.1\PCbuild\unicodedata.pyd %_DEST%\lib%_EXT%\python\unicodedata.pyd
+..\%__SRC%\misc\build\Python-2.6.1\PCbuild\winsound.pyd %_DEST%\lib%_EXT%\python\winsound.pyd
+..\%__SRC%\misc\build\Python-2.6.1\PCbuild\pyexpat.pyd %_DEST%\lib%_EXT%\python\pyexpat.pyd
+..\%__SRC%\misc\build\Python-2.6.1\PCbuild\_testcapi.pyd %_DEST%\lib%_EXT%\python\_testcapi.pyd
+..\%__SRC%\misc\build\Python-2.6.1\PCbuild\_multiprocessing.pyd %_DEST%\lib%_EXT%\python\_multiprocessing.pyd
+..\%__SRC%\misc\build\Python-2.6.1\PCbuild\_msi.pyd %_DEST%\lib%_EXT%\python\_msi.pyd
+..\%__SRC%\misc\build\Python-2.6.1\PCbuild\_elementtree.pyd %_DEST%\lib%_EXT%\python\_elementtree.pyd
+..\%__SRC%\misc\build\Python-2.6.1\PCbuild\_ctypes.pyd %_DEST%\lib%_EXT%\python\_ctypes.pyd
+
+#linklib: libpython.so.*.*.*
+
diff --git a/python/pyversion.mk b/python/pyversion.mk
new file mode 100644
index 000000000000..55a616b12064
--- /dev/null
+++ b/python/pyversion.mk
@@ -0,0 +1,26 @@
+# when you want to change the python version, you must update the d.lst
+# in the python project accordingly !!!
+PYMAJOR=2
+PYMINOR=6
+PYMICRO=1
+PYVERSION=$(PYMAJOR).$(PYMINOR).$(PYMICRO)
+
+.IF "$(GUI)" == "UNX"
+.IF "$(OS)" == "MACOSX"
+PY_FULL_DLL_NAME=libpython$(PYMAJOR).$(PYMINOR).dylib
+.ELSE
+PY_FULL_DLL_NAME=libpython$(PYMAJOR).$(PYMINOR).so.1.0
+.ENDIF
+PYTHONLIB=-lpython$(PYMAJOR).$(PYMINOR)
+.ELIF "$(GUI)" == "OS2"
+PY_FULL_DLL_NAME=python$(PYMAJOR)$(PYMINOR).dll
+PYTHONLIB=python$(PYMAJOR)$(PYMINOR).lib
+.ELSE
+.IF "$(COM)" == "GCC"
+PY_FULL_DLL_NAME=libpython$(PYMAJOR).$(PYMINOR).dll
+PYTHONLIB=-lpython$(PYMAJOR).$(PYMINOR)
+.ELSE
+PY_FULL_DLL_NAME=python$(PYMAJOR)$(PYMINOR).dll
+PYTHONLIB=python$(PYMAJOR)$(PYMINOR).lib
+.ENDIF
+.ENDIF