[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r18730: {torvm} Add support for multi-lingual MSI packages, initial native m (in torvm/trunk/build/win32: . files patches)



Author: coderman
Date: 2009-03-01 09:43:35 -0500 (Sun, 01 Mar 2009)
New Revision: 18730

Added:
   torvm/trunk/build/win32/patches/python3-mingw.patch
Modified:
   torvm/trunk/build/win32/Makefile
   torvm/trunk/build/win32/files/buildall.sh
   torvm/trunk/build/win32/patches/vidalia-torvm.patch
Log:
Add support for multi-lingual MSI packages, initial native mingw32 support for python 3.0.1.

Modified: torvm/trunk/build/win32/Makefile
===================================================================
--- torvm/trunk/build/win32/Makefile	2009-03-01 10:50:17 UTC (rev 18729)
+++ torvm/trunk/build/win32/Makefile	2009-03-01 14:43:35 UTC (rev 18730)
@@ -17,79 +17,79 @@
 # with an autorun.inf that launches a build of all the win32 parts.
 # 
 ZLIB_F=zlib-1.2.3-bin.zip
-ZLIB_URL=http://downloads.sourceforge.net/gnuwin32/zlib-1.2.3-bin.zip?modtime=1122324542&big_mirror=1
+ZLIB_URL=http://downloads.sourceforge.net/gnuwin32/zlib-1.2.3-bin.zip?big_mirror=1
 ZLIB_SUM=becbcaf5076e307e743b1edc6a5645849eba9ebc
 
 GZIP_F=gzip-1.3.12-1-bin.zip
-GZIP_URL=http://downloads.sourceforge.net/gnuwin32/gzip-1.3.12-1-bin.zip?modtime=1213401872&big_mirror=1
+GZIP_URL=http://downloads.sourceforge.net/gnuwin32/gzip-1.3.12-1-bin.zip?big_mirror=1
 GZIP_SUM=69901b7a58e324e39653d4282deaf5ab5bb5c07f
 
 BZIP2_F=bzip2-1.0.5-bin.zip
-BZIP2_URL=http://downloads.sourceforge.net/gnuwin32/bzip2-1.0.5-bin.zip?modtime=1206045010&big_mirror=1
+BZIP2_URL=http://downloads.sourceforge.net/gnuwin32/bzip2-1.0.5-bin.zip?big_mirror=1
 BZIP2_SUM=618ba51d3d6838e71a922febf717471b7d5f54e2
 
 LIBARCH_F=libarchive-2.4.12-1-bin.zip
-LIBARCH_URL=http://downloads.sourceforge.net/gnuwin32/libarchive-2.4.12-1-bin.zip?modtime=1215347767&big_mirror=1
+LIBARCH_URL=http://downloads.sourceforge.net/gnuwin32/libarchive-2.4.12-1-bin.zip?big_mirror=1
 LIBARCH_SUM=02eb2fe2200705d0067f03780c6d65f51ae69e42
 
 BINUTILS_F=binutils-2.18.50-20080109-2.tar.gz
-BINUTILS_URL=http://downloads.sourceforge.net/mingw/binutils-2.18.50-20080109-2.tar.gz?modtime=1206567544&big_mirror=1
+BINUTILS_URL=http://downloads.sourceforge.net/mingw/binutils-2.18.50-20080109-2.tar.gz?big_mirror=1
 BINUTILS_SUM=4a47e75604765f671ca233bb503f1ca67fd93af0
 
 GCCORE_F=gcc-core-3.4.5-20060117-3.tar.gz
-GCCORE_URL=http://downloads.sourceforge.net/mingw/gcc-core-3.4.5-20060117-3.tar.gz?modtime=1209046227&big_mirror=1
+GCCORE_URL=http://downloads.sourceforge.net/mingw/gcc-core-3.4.5-20060117-3.tar.gz?big_mirror=1
 GCCORE_SUM=1ba77819f5749954fda080c0137af359a09760fc
 
 GPP_F=gcc-g++-3.4.5-20060117-3.tar.gz
-GPP_URL=http://downloads.sourceforge.net/mingw/gcc-g%2B%2B-3.4.5-20060117-3.tar.gz?modtime=1209046244&big_mirror=1
+GPP_URL=http://downloads.sourceforge.net/mingw/gcc-g%2B%2B-3.4.5-20060117-3.tar.gz?big_mirror=1
 GPP_SUM=1d31f990d4027f171ab8c55374bec815a46c16dd
 
 MINGWRUN_F=mingw-runtime-3.14.tar.gz
-MINGWRUN_URL=http://downloads.sourceforge.net/mingw/mingw-runtime-3.14.tar.gz?modtime=1198749088&big_mirror=1
+MINGWRUN_URL=http://downloads.sourceforge.net/mingw/mingw-runtime-3.14.tar.gz?big_mirror=1
 MINGWRUN_SUM=ebd523dff5cb5bc476124a283b3ba9781f907fea
 
 MINGWUTIL_F=mingw-utils-0.3.tar.gz
-MINGWUTIL_URL=http://downloads.sourceforge.net/mingw/mingw-utils-0.3.tar.gz?modtime=1077362266&big_mirror=1
+MINGWUTIL_URL=http://downloads.sourceforge.net/mingw/mingw-utils-0.3.tar.gz?big_mirror=1
 MINGWUTIL_SUM=7ae32742ece1e89978784634aed824775cf47336
 
 MAKE_F=mingw32-make-3.81-20080326-3.tar.gz
-MAKE_URL=http://downloads.sourceforge.net/mingw/mingw32-make-3.81-20080326-3.tar.gz?modtime=1212658958&big_mirror=1
+MAKE_URL=http://downloads.sourceforge.net/mingw/mingw32-make-3.81-20080326-3.tar.gz?big_mirror=1
 MAKE_SUM=86ab2ddffdd2df6245856bb0dd50fbd8ba372767
 
 W32API_F=w32api-3.11.tar.gz
-W32API_URL=http://downloads.sourceforge.net/mingw/w32api-3.11.tar.gz?modtime=1198748420&big_mirror=1
+W32API_URL=http://downloads.sourceforge.net/mingw/w32api-3.11.tar.gz?big_mirror=1
 W32API_SUM=0969cde19c3a85012b4924cb49cf2e9ef3d1b6df
 
 MSYS_F=MSYS-1.0.11-20071204.tar.bz2
-MSYS_URL=http://downloads.sourceforge.net/mingw/MSYS-1.0.11-20071204.tar.bz2?modtime=1196807934&big_mirror=1
+MSYS_URL=http://downloads.sourceforge.net/mingw/MSYS-1.0.11-20071204.tar.bz2?big_mirror=1
 MSYS_SUM=9a1207b04ffaf8880c58de643609e4deed3e1563
 
 MSYSCORE_F=msysCORE-1.0.11-2007.01.19-1.tar.bz2
-MSYSCORE_URL=http://downloads.sourceforge.net/mingw/msysCORE-1.0.11-2007.01.19-1.tar.bz2?modtime=1169214215&big_mirror=1
+MSYSCORE_URL=http://downloads.sourceforge.net/mingw/msysCORE-1.0.11-2007.01.19-1.tar.bz2?big_mirror=1
 MSYSCORE_SUM=65870650914925dfd8451a9452bff3cdb8320221
 
 BASH_F=bash-3.1-MSYS-1.0.11-1.tar.bz2
-BASH_URL=http://downloads.sourceforge.net/mingw/bash-3.1-MSYS-1.0.11-1.tar.bz2?modtime=1195140582&big_mirror=1
+BASH_URL=http://downloads.sourceforge.net/mingw/bash-3.1-MSYS-1.0.11-1.tar.bz2?big_mirror=1
 BASH_SUM=a440bb5a6e2edfe703b67877c7e7e48504aad6dc
 
 DIFFUTIL_F=diffutils-2.8.7-MSYS-1.0.11-1.tar.bz2
-DIFFUTIL_URL=http://downloads.sourceforge.net/mingw/diffutils-2.8.7-MSYS-1.0.11-1.tar.bz2?modtime=1196332674&big_mirror=1
+DIFFUTIL_URL=http://downloads.sourceforge.net/mingw/diffutils-2.8.7-MSYS-1.0.11-1.tar.bz2?big_mirror=1
 DIFFUTIL_SUM=a34f0470674b6bb807e505839a477f9b9c70facf
 
 LIBTOOL_F=libtool1.5-1.5.25a-1-bin.tar.bz2
-LIBTOOL_URL=http://downloads.sourceforge.net/mingw/libtool1.5-1.5.25a-1-bin.tar.bz2?modtime=1190250326&big_mirror=1
+LIBTOOL_URL=http://downloads.sourceforge.net/mingw/libtool1.5-1.5.25a-1-bin.tar.bz2?big_mirror=1
 LIBTOOL_SUM=7e7206011471dbe79f5298d76ea9530288b2a6dd
 
 MINIRES_F=minires-1.01-1-MSYS-1.0.11-1.tar.bz2
-MINIRES_URL=http://downloads.sourceforge.net/mingw/minires-1.01-1-MSYS-1.0.11-1.tar.bz2?modtime=1206482214&big_mirror=1
+MINIRES_URL=http://downloads.sourceforge.net/mingw/minires-1.01-1-MSYS-1.0.11-1.tar.bz2?big_mirror=1
 MINIRES_SUM=c077e08cce446656ff0c0b3f30a327652f9c9986
 
 MSYSZLIB_F=zlib-1.2.3-MSYS-1.0.11-1.tar.bz2
-MSYSZLIB_URL=http://downloads.sourceforge.net/mingw/zlib-1.2.3-MSYS-1.0.11-1.tar.bz2?modtime=1206455079&big_mirror=1
+MSYSZLIB_URL=http://downloads.sourceforge.net/mingw/zlib-1.2.3-MSYS-1.0.11-1.tar.bz2?big_mirror=1
 MSYSZLIB_SUM=dff1a110b165d7ba4d7804b1c2f4a023823eec90
 
 MSYSCRYPT_F=crypt-1.1-1-MSYS-1.0.11-1.tar.bz2
-MSYSCRYPT_URL=http://downloads.sourceforge.net/mingw/crypt-1.1-1-MSYS-1.0.11-1.tar.bz2?modtime=1206481779&big_mirror=1
+MSYSCRYPT_URL=http://downloads.sourceforge.net/mingw/crypt-1.1-1-MSYS-1.0.11-1.tar.bz2?big_mirror=1
 MSYSCRYPT_SUM=072e9a158d41e73aa5a766df016494dab74085e4
 
 M4_F=m4-1.4.7-MSYS.tar.bz2
@@ -97,11 +97,11 @@
 M4_SUM=a00ed987824456946777d92f600612f344211dcc
 
 SSL_F=openssl-0.9.8g-1-MSYS-1.0.11-2-dll098.tar.gz
-SSL_URL=http://downloads.sourceforge.net/mingw/openssl-0.9.8g-1-MSYS-1.0.11-2-dll098.tar.gz?modtime=1206734099&big_mirror=1
+SSL_URL=http://downloads.sourceforge.net/mingw/openssl-0.9.8g-1-MSYS-1.0.11-2-dll098.tar.gz?big_mirror=1
 SSL_SUM=eba5f37fdec2982727556a3dbb5ea6fd04296b76
 
 SSH_F=openssh-4.7p1-MSYS-1.0.11-1-bin.tar.gz
-SSH_URL=http://downloads.sourceforge.net/mingw/openssh-4.7p1-MSYS-1.0.11-1-bin.tar.gz?modtime=1206734972&big_mirror=1
+SSH_URL=http://downloads.sourceforge.net/mingw/openssh-4.7p1-MSYS-1.0.11-1-bin.tar.gz?big_mirror=1
 SSH_SUM=bf1617bf43de198cea7c197621494baec9520bcb
 
 ZLIBSRC_F=zlib-1.2.3.tar.gz
@@ -117,15 +117,15 @@
 LIBEVENT_SUM=82c05a893688810aafc2b372b567a837eb115732
 
 ACONF_F=autoconf2.5-2.61-1-bin.tar.bz2
-ACONF_URL=http://downloads.sourceforge.net/mingw/autoconf2.5-2.61-1-bin.tar.bz2?modtime=1190249465&big_mirror=1
+ACONF_URL=http://downloads.sourceforge.net/mingw/autoconf2.5-2.61-1-bin.tar.bz2?big_mirror=1
 ACONF_SUM=7f05699dfeb0fea12b490da7204eeb89644a3bf7
 
 AMAKE_F=automake1.9-1.9.6-2-bin.tar.bz2
-AMAKE_URL=http://downloads.sourceforge.net/mingw/automake1.9-1.9.6-2-bin.tar.bz2?modtime=1190249841&big_mirror=1
+AMAKE_URL=http://downloads.sourceforge.net/mingw/automake1.9-1.9.6-2-bin.tar.bz2?big_mirror=1
 AMAKE_SUM=685dd354868ebb6fca148a300f20b55e1c036fca
 
 PERL_F=perl-5.6.1-MSYS-1.0.11-1.tar.bz2
-PERL_URL=http://downloads.sourceforge.net/mingw/perl-5.6.1-MSYS-1.0.11-1.tar.bz2?modtime=1206455338&big_mirror=1
+PERL_URL=http://downloads.sourceforge.net/mingw/perl-5.6.1-MSYS-1.0.11-1.tar.bz2?big_mirror=1
 PERL_SUM=ff1f07a061c7958bc9043f0085a55ff0101b1be4
 
 GROFF_F=groff-1.19.2.tar.gz
@@ -140,23 +140,32 @@
 SSLSRC_URL=http://www.openssl.org/source/openssl-0.9.8j.tar.gz
 SSLSRC_SUM=f70f7127a26e951e8a0d854c0c9e6b4c24df78e4
 
+PYTHON_F=Python-3.0.1.tar.bz2
+PYTHON_URL=http://www.python.org/ftp/python/3.0.1/$(PYTHON_F)
+PYTHON_SUM=6206059f0c04336e8d6550d2cdd88ab91f2657ff
+
 PY2EXE_F=py2exe-0.6.9.zip
 PY2EXE_TGZ=py2exe.tar.gz
-PY2EXE_URL=http://downloads.sourceforge.net/py2exe/py2exe-0.6.9.zip?modtime=1226789941&big_mirror=1
+PY2EXE_URL=http://downloads.sourceforge.net/py2exe/py2exe-0.6.9.zip?big_mirror=1
 PY2EXE_SUM=f1a2cdfbf6d142f6ff54edfcf9d127e2d07169d5
 
-WIX_F=wix3.0.4721.0-binaries.zip
+WIX_F=wix3.0.4805.0-binaries.zip
 WIX_TGZ=wix.tar.gz
-WIX_URL=http://downloads.sourceforge.net/wix/wix3.0.4721.0-binaries.zip?modtime=1227270606&big_mirror=1
-WIX_SUM=3035442aeab28a01f1cb032c610f375f763a0f88
+WIX_URL=http://downloads.sourceforge.net/wix/wix3.0.4805.0-binaries.zip?big_mirror=1
+WIX_SUM=58dcedd89efcf9b80f7d6f1c0c5f9ee44a800892
 
+WIXSRC_F=wix3.0.4805.0-sources.zip
+WIXSRC_TGZ=wixsrc.tar.gz
+WIXSRC_URL=http://downloads.sourceforge.net/wix/wix3.0.4805.0-sources.zip?big_mirror=1
+WIXSRC_SUM=60d5bfa98fcf8f902586067393eb3ac7e4b12f82
+
 GNURX_F=mingw-libgnurx-2.5.1-src.tar.gz
-GNURX_URL=http://downloads.sourceforge.net/mingw/mingw-libgnurx-2.5.1-src.tar.gz?modtime=1178542293&big_mirror=1
+GNURX_URL=http://downloads.sourceforge.net/mingw/mingw-libgnurx-2.5.1-src.tar.gz?big_mirror=1
 GNURX_SUM=f1e4af2541645dac82362b618aaa849658cd4988
 
 NSIS_VER=2.42
 NSIS_F=nsis-$(NSIS_VER).zip
-NSIS_URL=http://downloads.sourceforge.net/nsis/nsis-2.42.zip?modtime=1229784735&big_mirror=1
+NSIS_URL=http://downloads.sourceforge.net/nsis/nsis-2.42.zip?big_mirror=1
 NSIS_SUM=a1aef12a33f16273ac9109fde28713399f6a8016
 NSIS_TGZ=nsis-2.42.tar.gz
 
@@ -165,7 +174,7 @@
 SEVNZIP_INST=true
 SEVNZIP_VER=464
 SEVNZIP_F=7z464.msi
-SEVNZIP_URL=http://downloads.sourceforge.net/sevenzip/7z464.msi?modtime=1230949842&big_mirror=1
+SEVNZIP_URL=http://downloads.sourceforge.net/sevenzip/7z464.msi?big_mirror=1
 SEVNZIP_SUM=19a06e188a83452dc9273290dbef71220686c4c1
 
 SDL_F=SDL-1.2.13.tar.gz
@@ -209,7 +218,7 @@
 VIDALIA_TGZ=$(VIDALIA_NAME).tar.gz
 VIDALIA_SVN=https://svn.vidalia-project.net/svn/vidalia/
 VIDALIA_BR=trunk
-VIDALIA_VER=3560
+VIDALIA_VER=3597
 
 # for package resources
 TORSVN_NAME=tor-latest
@@ -239,7 +248,7 @@
 # buildscripts need some dire clean up...
 OK:=echo -n
 
-ALLFILES=$(ZLIB_F) $(GZIP_F) $(BZIP2_F) $(LIBARCH_F) $(BINUTILS_F) $(GCCORE_F) $(GPP_F) $(MINGWRUN_F) $(MINGWUTIL_F) $(MAKE_F) $(W32API_F) $(MSYS_F) $(MSYSCORE_F) $(BASH_F) $(DIFFUTIL_F) $(LIBTOOL_F) $(MINIRES_F) $(MSYSZLIB_F) $(MSYSCRYPT_F) $(M4_F) $(SSL_F) $(SSH_F) $(ZLIBSRC_F) $(PTHREADS_F) $(LIBEVENT_F) $(AMAKE_F) $(ACONF_F) $(PERL_F) $(GROFF_F) $(CMAKE_F) $(QT_F) $(NSIS_F) $(SSLSRC_F) $(PY2EXE_F) $(WIX_F) $(GNURX_F) $(POLIPO_F) $(SDL_F) $(WPCAPSRC_F) $(QEMU_F) $(OVPN_F)
+ALLFILES=$(ZLIB_F) $(GZIP_F) $(BZIP2_F) $(LIBARCH_F) $(BINUTILS_F) $(GCCORE_F) $(GPP_F) $(MINGWRUN_F) $(MINGWUTIL_F) $(MAKE_F) $(W32API_F) $(MSYS_F) $(MSYSCORE_F) $(BASH_F) $(DIFFUTIL_F) $(LIBTOOL_F) $(MINIRES_F) $(MSYSZLIB_F) $(MSYSCRYPT_F) $(M4_F) $(SSL_F) $(SSH_F) $(ZLIBSRC_F) $(PTHREADS_F) $(LIBEVENT_F) $(AMAKE_F) $(ACONF_F) $(PERL_F) $(GROFF_F) $(CMAKE_F) $(QT_F) $(NSIS_F) $(SSLSRC_F) $(PYTHON_F) $(PY2EXE_F) $(WIX_F) $(WIXSRC_F) $(GNURX_F) $(POLIPO_F) $(SDL_F) $(WPCAPSRC_F) $(QEMU_F) $(OVPN_F)
 
 # adjust if we're dealing with non source, zip or tar archives for a package
 SEVNZIP_OPT_DL=
@@ -289,8 +298,10 @@
 	@if [ ! -e $(WDLDIR)/$(QT_F) ]; then $(DLCMD) "$(QT_URL)" $(QT_SUM) "$(WDLDIR)/$(QT_F)"; fi
 	@if [ ! -e $(WDLDIR)/$(NSIS_F) ]; then $(DLCMD) "$(NSIS_URL)" $(NSIS_SUM) "$(WDLDIR)/$(NSIS_F)"; fi
 	@if [ ! -e $(WDLDIR)/$(SSLSRC_F) ]; then $(DLCMD) "$(SSLSRC_URL)" $(SSLSRC_SUM) "$(WDLDIR)/$(SSLSRC_F)"; fi
+	@if [ ! -e $(WDLDIR)/$(PYTHON_F) ]; then $(DLCMD) "$(PYTHON_URL)" $(PYTHON_SUM) "$(WDLDIR)/$(PYTHON_F)"; fi
 	@if [ ! -e $(WDLDIR)/$(PY2EXE_F) ]; then $(DLCMD) "$(PY2EXE_URL)" $(PY2EXE_SUM) "$(WDLDIR)/$(PY2EXE_F)"; fi
 	@if [ ! -e $(WDLDIR)/$(WIX_F) ]; then $(DLCMD) "$(WIX_URL)" $(WIX_SUM) "$(WDLDIR)/$(WIX_F)"; fi
+	@if [ ! -e $(WDLDIR)/$(WIXSRC_F) ]; then $(DLCMD) "$(WIXSRC_URL)" $(WIXSRC_SUM) "$(WDLDIR)/$(WIXSRC_F)"; fi
 	@if [ ! -e $(WDLDIR)/$(GNURX_F) ]; then $(DLCMD) "$(GNURX_URL)" $(GNURX_SUM) "$(WDLDIR)/$(GNURX_F)"; fi
 	@if [ ! -e $(WDLDIR)/$(POLIPO_F) ]; then $(DLCMD) "$(POLIPO_URL)" $(POLIPO_SUM) "$(WDLDIR)/$(POLIPO_F)"; fi
 	@if [ ! -e $(WDLDIR)/$(SDL_F) ]; then $(DLCMD) "$(SDL_URL)" $(SDL_SUM) "$(WDLDIR)/$(SDL_F)"; fi
@@ -358,6 +369,7 @@
 	mv $(ISODIR)/dl/$(OVPN_F) $(ISODIR)/dl/src/; \
 	mv $(ISODIR)/dl/$(ZLIBSRC_F) $(ISODIR)/dl/src/; \
 	mv $(ISODIR)/dl/$(LIBEVENT_F) $(ISODIR)/dl/src/; \
+	mv $(ISODIR)/dl/$(PYTHON_F) $(ISODIR)/dl/src/; \
 	echo "--- Repacking WinPCAP archive ..."; \
 	$(UNZIP) $(WDLDIR)/$(WPCAPSRC_F); mv winpcap WpcapSrc_$(WPCAPSRC_VER); tar cf $(ISODIR)/dl/src/WpcapSrc_$(WPCAPSRC_VER).tar WpcapSrc_$(WPCAPSRC_VER); gzip -9 $(ISODIR)/dl/src/WpcapSrc_$(WPCAPSRC_VER).tar; rm -rf WpcapSrc_$(WPCAPSRC_VER) $(ISODIR)/dl/$(WPCAPSRC_F); \
 	echo "--- Repacking Py2Exe archive ..."; \
@@ -366,6 +378,8 @@
 	$(UNZIP) $(WDLDIR)/$(NSIS_F); tar zcf $(ISODIR)/dl/$(NSIS_TGZ) nsis-$(NSIS_VER); rm -rf nsis-$(NSIS_VER) $(ISODIR)/dl/$(NSIS_F); \
 	echo "--- Repacking WiX archive ..."; \
 	$(UNZIP) $(WDLDIR)/$(WIX_F) -d wix; tar zcf $(ISODIR)/dl/$(WIX_TGZ) wix; rm -rf wix $(ISODIR)/dl/$(WIX_F); \
+	echo "--- Repacking WiX sources archive ..."; \
+	$(UNZIP) $(WDLDIR)/$(WIXSRC_F) -d wixsrc; tar zcf $(ISODIR)/dl/$(WIXSRC_TGZ) wixsrc; rm -rf wixsrc $(ISODIR)/dl/$(WIXSRC_F); \
 	echo "--- Repacking Qt archive ..."; \
 	$(UNZIP) $(WDLDIR)/$(QT_F) -d qt-$(QT_VER); mv qt-$(QT_VER)/qt-*/* qt-$(QT_VER)/; rm -rf qt-$(QT_VER)/qt-*; tar zcf $(ISODIR)/dl/src/$(QT_TGZ) qt-$(QT_VER); rm -rf qt-$(QT_VER) $(ISODIR)/dl/$(QT_F); \
 	echo "--- Exporting Vidalia version $(VIDALIA_VER) from local mirror ..."; \

Modified: torvm/trunk/build/win32/files/buildall.sh
===================================================================
--- torvm/trunk/build/win32/files/buildall.sh	2009-03-01 10:50:17 UTC (rev 18729)
+++ torvm/trunk/build/win32/files/buildall.sh	2009-03-01 14:43:35 UTC (rev 18730)
@@ -13,12 +13,12 @@
   if [[ "$sysdrive" == "" ]]; then
     sysdrive=`echo $SYSTEMDRIVE | sed 's/:.*//'`
     if [ ! -d /$sysdrive ]; then
-      # msys not happy about whatever odd location windows installed into...
+      # msys not happy about whatever odd location windows installed into.
       sysdrive=c
     fi
   fi
   # make sure we express sys drive as lower case because of msys pedantic'ness
-  # or that of the sub scripts and whatever else get confused...
+  # or that of the sub scripts and whatever else get confused.
   # boy, wouldn't tr be nice? tr -t '[:upper:]' '[:lower:]'
   for DL in a b c d e f g h i j k l m n o p q r s t u v w x y z; do
     echo $sysdrive | grep -i "^[${DL}]" >/dev/null
@@ -27,7 +27,7 @@
     fi
   done
   if [ ! -d /$sysdrive ]; then
-    echo "Bogus sysdrive Windows root set: $sysdrive , using defaults..."
+    echo "Bogus sysdrive Windows root set: $sysdrive , using defaults ..."
     sysdrive=c
   fi
   echo "Using Windows system drive root /$sysdrive , ${sysdrive}:\\"
@@ -58,7 +58,7 @@
     chmod +x $bstatefile
   fi
   
-  export libdir="${ddir}/lib"
+  export bdlibdir="${ddir}/lib"
   export bindir="${ddir}/bin"
   export statedir="${ddir}/state"
   export instdir="${brootdir}/Installer"
@@ -151,6 +151,9 @@
   
   export NSIS_DIR=nsis-2.42
   export PATH="${PATH}:/${NSIS_DIR}/Bin:/${NSIS_DIR}:/${NSIS_DIR}/bin"
+
+  export WIXSRC_DIR=wixsrc
+  export WIXSRC_FILE=wixsrc.tar.gz
   
   if [ -d "$VS80COMNTOOLS" ]; then
     export VSTOOLSDIR="$VS80COMNTOOLS"
@@ -184,7 +187,7 @@
   if [[ "$bld_dsub" == "" ]]; then
     export bld_dsub="${BUILD_SCP_DIR}/${build_date}"
     if [[ "$BUILD_SCP_NOSUBDIR" == "TRUE" ]]; then
-      # dont include the date subdir in any copied destinations...
+      # dont include the date subdir in any copied destinations.
       export bld_dsub="${BUILD_SCP_DIR}"
     fi
   fi
@@ -207,14 +210,14 @@
 else
 
 
-# SECOND PASS - begin build process ...
+# SECOND PASS - begin build process
   
 function pkgbuilt () {
   echo "export $1=yes" >> $bstatefile
 }
 
 if [[ "$MSYS_SETUP" != "yes" ]]; then
-  echo "Setting up MSYS build environment..."
+  echo "Setting up MSYS build environment ..."
   if [ -f ~/.ssh/user ]; then
     chmod 700 ~/.ssh >/dev/null 2>&1
     if [ ! -f ~/.ssh/id_rsa ]; then
@@ -224,7 +227,7 @@
     chmod 600 ~/.ssh/id_rsa >/dev/null 2>&1
   fi
 
-  for dir in $ddir $libdir $bindir $statedir $brootdir $instdir $thandir $bundledir; do
+  for dir in $ddir $bdlibdir $bindir $statedir $brootdir $instdir $thandir $bundledir; do
     if [ ! -d $dir ]; then
       mkdir -p $dir
     fi
@@ -235,7 +238,7 @@
   tar xf /dl/m4*
 
   if [ -d /usr/usr ]; then
-    # ahh, gotta love the msys /usr <-> / equivalence hack...
+    # ahh, gotta love the msys /usr <-> / equivalence hack.
     cd /usr/usr
     if [ -d local ]; then
       mv local ../
@@ -257,12 +260,19 @@
   # we only need the dll for ssh and friends.
   rm -f /include/zlib.h /include/zconf.h /lib/libz.a /lib/libz.dll.a 
 
+  # if WiX sources available extract into expected location for
+  # localization support.
+  cd /src
+  if [ -d /$WIXSRC_DIR ]; then
+    mv /$WIXSRC_DIR ./
+  fi
+
   pkgbuilt MSYS_SETUP
 fi
 
 if [[ "$PKGS_INSTALLED" != "yes" ]]; then
   anyfail=0
-  echo "Checking for any packages to install..."
+  echo "Checking for any packages to install ..."
   if [[ "$SEVNZIP_INST" == "true" ]]; then
     if [ ! -f "/dl/${SEVNZIP_PKG}" ]; then
       echo "ERROR: Unable to locate expected 7zip package for install at location: /${SEVNZIP_PKG}"
@@ -326,7 +336,6 @@
 fi
 
 
-# package builds start here ...
 if [[ "$PTHREADS_BUILT" != "yes" ]]; then
   echo "Building pthreads-w32 ..."
   cd /usr/src
@@ -337,11 +346,11 @@
     echo "ERROR: pthreads-32 build failed." >&2
     exit 1
   fi
-  # make install not quite sane yet ...
+  # XXX make install not quite sane yet
   cp *.a /lib/
   cp *.dll /bin/
   cp *.h /usr/include/
-  cp pthreadGC2.dll $libdir/
+  cp pthreadGC2.dll $bdlibdir/
 
   pkgbuilt PTHREADS_BUILT
 fi
@@ -352,31 +361,27 @@
   cd /usr/src
   tar zxf $ZLIB_FILE
   cd $ZLIB_DIR
-  (
-    # LIBZ configure is odd... perhaps these should be renamed
-    unset libdir
-    ./configure --prefix=/usr --enable-shared
-    if (( $? != 0 )); then
-      echo "ERROR: zlib configure failed." >&2
-      exit 1
-    fi
-    make
-    if (( $? != 0 )); then
-      echo "ERROR: zlib build failed." >&2
-      exit 1
-    fi
-    make install
-    if (( $? != 0 )); then
-      echo "ERROR: zlib install failed." >&2
-      exit 1
-    fi
-    make -f win32/Makefile.gcc
-    if (( $? != 0 )); then
-      echo "ERROR: zlib dynamic build failed." >&2
-      exit 1
-    fi
-  )
-  cp *.dll $libdir/
+  ./configure --prefix=/usr --enable-shared
+  if (( $? != 0 )); then
+    echo "ERROR: zlib configure failed." >&2
+    exit 1
+  fi
+  make
+  if (( $? != 0 )); then
+    echo "ERROR: zlib build failed." >&2
+    exit 1
+  fi
+  make install
+  if (( $? != 0 )); then
+    echo "ERROR: zlib install failed." >&2
+    exit 1
+  fi
+  make -f win32/Makefile.gcc
+  if (( $? != 0 )); then
+    echo "ERROR: zlib dynamic build failed." >&2
+    exit 1
+  fi
+  cp *.dll $bdlibdir/
 
   pkgbuilt ZLIB_BUILT
 fi
@@ -419,7 +424,7 @@
     exit 1
   fi
   make install
-  cp /usr/bin/SDL.dll $libdir/
+  cp /usr/bin/SDL.dll $bdlibdir/
 
   pkgbuilt SDL_BUILT
 fi
@@ -463,8 +468,8 @@
     echo "ERROR: openvpn tap-win32 driver build failed." >&2
     exit 1
   fi
-  cp i386/${TAPDRVN}.sys $libdir/
-  cp i386/OemWin2k.inf $libdir/${TAPDRVN}.inf
+  cp i386/${TAPDRVN}.sys $bdlibdir/
+  cp i386/OemWin2k.inf $bdlibdir/${TAPDRVN}.inf
 
   pkgbuilt OPENVPN_BUILT
 fi
@@ -493,14 +498,14 @@
     echo "ERROR: WinPcap npf.sys driver build failed." >&2
     exit 1
   fi
-  cp $NPFDRV_F $libdir/tornpf.sys
+  cp $NPFDRV_F $bdlibdir/tornpf.sys
   cd Dll/Project
   make
   if (( $? != 0 )); then
     echo "ERROR: WinPcap Packet user space library build failed." >&2
     exit 1
   fi
-  cp torpkt.dll $libdir/
+  cp torpkt.dll $bdlibdir/
   cd $wpbase
   cd wpcap/PRJ
   make
@@ -508,7 +513,7 @@
     echo "ERROR: WinPcap libwpcap user space library build failed." >&2
     exit 1
   fi
-  cp torpcap.dll $libdir/
+  cp torpcap.dll $bdlibdir/
 
   pkgbuilt WPCAP_BUILT
 fi
@@ -650,7 +655,7 @@
   tar zxf $TOR_FILE
   cd $TOR_DIR
   if [ ! -f configure ]; then
-    echo "Attempting autogen..."
+    echo "Attempting autogen ..."
     aclocal
     autoheader
     autoconf
@@ -683,11 +688,25 @@
   cp /src/$OPENSSL_DIR/ssleay32-0.9.8.dll bin/
   # line conversion prior to MSI packaging and other documentation prep
   ( 
-    # this has to run detached or else troff tries to eat our controlling tty leading to badness...
-    # TODO : tech this thing how to wait properly ...
+    # this has to run detached or else troff tries to eat our controlling tty
+    # resulting in a hung build without user interaction.
     groff -m man -F /share -M /share/tmac -T html doc/tor.1 > Usage.html &
+    i=20
+    pc=0
+    while (( $i > 0 )); do
+      sleep 1
+      i=$(expr $i - 1)
+      if [ -f Usage.html ]; then
+        cc=$(cat Usage.html | wc -c)
+        if (( $cc > $pc )); then
+          pc=$cc
+        else
+          # all done generating
+          i=0
+        fi
+      fi
+    done
   )
-  sleep 5
   ls -lh Usage.html
   for FILE in README ChangeLog LICENSE Authors src/config/torrc.sample; do
     if [ -f $FILE ]; then
@@ -698,9 +717,10 @@
     fi
   done
 
-  pkgbuilt OPENSSL_BUILT
+  pkgbuilt TOR_BUILT
 fi
 
+
 if [[ "$PYCRYPTO_BUILT" != "yes" ]]; then
   echo "Building PyCrypto ..."
   cd /usr/src
@@ -744,7 +764,7 @@
   cd /usr/src
   tar zxf thandy-latest.tar.gz
   cd thandy-latest
-  echo "Starting build..."
+  echo "Starting python Thandy build ..."
   python setup.py build
   if (( $? != 0 )); then
     echo "ERROR: Thandy build failed."
@@ -937,8 +957,8 @@
 
 
 # don't forget the kernel and virtual disk
-cp $KERNEL_IMAGE $libdir/
-cp $VMHDD_IMAGE $libdir/
+cp $KERNEL_IMAGE $bdlibdir/
+cp $VMHDD_IMAGE $bdlibdir/
 
 
 # Microsoft Installer package build
@@ -946,17 +966,31 @@
 TORUI_WXS=WixUI_Tor.wxs
 TOR_WXS_DIR=contrib
 WIX_UI=/wix/WixUIExtension.dll
+WIXSRC_WXLDIR=/src/$WIXSRC_DIR/src/ext/UIExtension/wixlib
+DEF_WXL_LANG=en-us
+WXL_LANGS="cs-cz de-de en-us es-es fr-fr hu-hu it-it ja-jp nl-nl pl-pl ru-ru uk-ua"
+# XXX currently problems with WiX handling of: zh_CN zh_TW
+VIDALIA_LANGS="cs de en es fa fi fr he it nl pl pt ro ru sv"
+WIX_ALL_LOC_LINK=""
+for LANG in $WXL_LANGS; do
+  WIX_ALL_LOC_LINK="${WIX_ALL_LOC_LINK} -loc WixUI_${LANG}.wxl"
+done
+for LANG in $VIDALIA_LANGS; do
+  WIX_ALL_LOC_LINK="${WIX_ALL_LOC_LINK} -loc vidalia_${LANG}.wxl"
+done
 
+# XXX for now this eats up too much time and space
+# rely on the multi-lingual packages if possible.
+BUILD_IND_LANGS=no
+
 if [[ "$PACKAGES_BUILT" != "yes" ]]; then
   echo "Building bundle packages ..."
   echo "Expanding package dir ..."
-  cd /usr/src
+  cd /src
   tar zxf pkg.tgz
   if [ -f /usr/src/$VIDALIA_DIR/src/vidalia/vidalia.exe ]; then
     echo "Creating Vidalia MSI package ..."
-    cd /usr/src/$VIDALIA_DIR
-    ls -l src/vidalia/vidalia.exe
-    mkdir bin
+    cd /src/$VIDALIA_DIR
     for FILE in QtCore4.dll QtGui4.dll QtNetwork4.dll QtXml4.dll QtSvg4.dll; do
       cp /$sysdrive/Qt/$QT_VER/bin/$FILE bin/
     done
@@ -974,16 +1008,17 @@
     fi
     if [[ "$DEBUG_NO_STRIP" == "" ]]; then
       echo "Stripping debug symbols from binaries and libraries ..."
-      strip $libdir/*.dll
+      strip $bdlibdir/*.dll
       strip $bindir/*.exe
       strip $ddir/*.exe
       strip bin/*.dll
       strip bin/*.exe
     fi
 
-
+    cp $WIXSRC_WXLDIR/*.wxl ./
+    cp pkg/win32/*.wxl ./
     candle.exe pkg/win32/*.wxs
-    light.exe -out vidalia.msi vidalia.wixobj WixUI_Tor.wixobj -ext $WIX_UI
+    light.exe -out vidalia.msi vidalia.wixobj WixUI_Custom.wixobj $WIX_ALL_LOC_LINK -ext $WIX_UI
     if [ -f vidalia.msi ]; then
       cp vidalia.msi $bundledir
       cp vidalia.msi ../pkg/
@@ -992,9 +1027,32 @@
     else
       echo "ERROR: unable to build vidalia MSI installer."
     fi
+    if [[ "$BUILD_IND_LANGS" == "yes" ]]; then
+      for LANG in $VIDALIA_LANGS; do
+        WIXCULTURE=$DEF_WXL_LANG
+        for WIXLANG in $WXL_LANGS; do
+          pre=$(echo $WIXLANG | sed 's/-.*//')
+          if [[ "$pre" == "$LANG" ]]; then
+            WIXCULTURE=$WIXLANG
+          fi
+        done
+        outfile="vidalia-${LANG}.msi"
+        echo "Linking localized $outfile ..."
+        light.exe -out $outfile vidalia.wixobj WixUI_Custom.wixobj -cultures:$WIXCULTURE -loc "vidalia_${LANG}.wxl" -ext $WIX_UI
+        if [ -f $outfile ]; then
+          cp $outfile $bundledir
+          cp $outfile ../pkg/
+          ls -l $outfile
+        else
+          echo "ERROR: unable to link localized $outfile vidalia MSI installer."
+        fi
+      done
+    fi
   fi
   cd /usr/src/pkg
   echo "Copying various package dependencies into place ..."
+  cp $WIXSRC_WXLDIR/*.wxl ./
+  cp /src/$VIDALIA_DIR/pkg/win32/*.wxl ./
   cp ../torvm-w32/tor-icon-32.ico ./torvm.ico
   # DONT STRIP PY2EXEs!
   cp $thandir/Thandy.exe bin/
@@ -1014,7 +1072,7 @@
   candle.exe *.wxs
 
   echo "Linking torvm MSI installer package ..."
-  light.exe -out torvm.msi WixUI_Tor.wixobj torvm.wixobj -ext $WIX_UI
+  light.exe -out torvm.msi WixUI_Tor.wixobj torvm.wixobj $WIX_ALL_LOC_LINK -ext $WIX_UI
   if [ -f torvm.msi ]; then
     cp torvm.msi $bundledir
     ls -l torvm.msi
@@ -1023,7 +1081,7 @@
   fi
 
   echo "Linking tor MSI installer package ..."
-  light.exe -out tor.msi WixUI_Tor.wixobj tor.wixobj -ext $WIX_UI
+  light.exe -out tor.msi WixUI_Tor.wixobj tor.wixobj $WIX_ALL_LOC_LINK -ext $WIX_UI
   if [ -f tor.msi ]; then
     cp tor.msi $bundledir
     ls -l tor.msi
@@ -1032,7 +1090,7 @@
   fi
 
   echo "Linking polipo MSI installer package ..."
-  light.exe -out polipo.msi WixUI_Tor.wixobj polipo.wixobj -ext $WIX_UI
+  light.exe -out polipo.msi WixUI_Tor.wixobj polipo.wixobj $WIX_ALL_LOC_LINK -ext $WIX_UI
   if [ -f polipo.msi ]; then
     cp polipo.msi $bundledir
     ls -l polipo.msi
@@ -1043,7 +1101,7 @@
   if [ -f /src/$TORBUTTON_FILE ]; then
     cp /src/$TORBUTTON_FILE torbutton.xpi
     echo "Linking torbutton MSI installer package ..."
-    light.exe -out torbutton.msi WixUI_Tor.wixobj torbutton.wixobj -ext $WIX_UI
+    light.exe -out torbutton.msi WixUI_Tor.wixobj torbutton.wixobj $WIX_ALL_LOC_LINK -ext $WIX_UI
     if [ -f torbutton.msi ]; then
       cp torbutton.msi $bundledir
       ls -l torbutton.msi
@@ -1053,7 +1111,7 @@
   fi
 
   echo "Linking thandy MSI installer package ..."
-  light.exe -out thandy.msi WixUI_Tor.wixobj thandy.wixobj -ext $WIX_UI
+  light.exe -out thandy.msi WixUI_Tor.wixobj thandy.wixobj $WIX_ALL_LOC_LINK -ext $WIX_UI
   if [ -f thandy.msi ]; then
     cp thandy.msi $bundledir
     ls -l thandy.msi

Added: torvm/trunk/build/win32/patches/python3-mingw.patch
===================================================================
--- torvm/trunk/build/win32/patches/python3-mingw.patch	                        (rev 0)
+++ torvm/trunk/build/win32/patches/python3-mingw.patch	2009-03-01 14:43:35 UTC (rev 18730)
@@ -0,0 +1,2774 @@
+diff -Naur a/Include/pymath.h b/Include/pymath.h
+--- a/Include/pymath.h	2008-08-19 21:42:13.000000000 +0000
++++ b/Include/pymath.h	2009-03-01 04:37:26.000000000 +0000
+@@ -102,6 +102,8 @@
+  *    it really can't be implemented correctly (& easily) before C99.
+  *    Override in pyconfig.h if you have a better spelling on your platform.
+  * 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
+ #ifdef HAVE_ISINF
+diff -Naur a/Include/pyport.h b/Include/pyport.h
+--- a/Include/pyport.h	2009-01-16 04:13:17.000000000 +0000
++++ b/Include/pyport.h	2009-03-01 12:31:57.159139480 +0000
+@@ -460,6 +460,126 @@
+ #endif /* defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) */
+ 
+ 
++#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 ".\\Lib;.\\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
++
++#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
+@@ -506,10 +626,10 @@
+ /*
+   All windows ports, except cygwin, are handled in PC/pyconfig.h.
+ 
+-  Cygwin is the only other autoconf platform requiring special
+-  linkage handling and it uses __declspec().
++  BeOS, mingw32 and cygwin use autoconf and require special
++  linkage handling and all of these use __declspec().
+ */
+-#if defined(__CYGWIN__)
++#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BEOS__)
+ #	define HAVE_DECLSPEC_DLL
+ #endif
+ 
+@@ -527,13 +647,22 @@
+ #				define PyMODINIT_FUNC PyObject*
+ #			endif /* __CYGWIN__ */
+ #		else /* Py_BUILD_CORE */
++			/* FIXME: FAQ.html#3.24 link below is no longer valid */
+ 			/* Building an extension module, or an embedded situation */
+ 			/* public Python functions and data are imported */
+ 			/* Under Cygwin, auto-import functions to prevent compilation */
+ 			/* failures similar to http://python.org/doc/FAQ.html#3.24 */
+-#			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 -Naur a/Lib/ctypes/test/test_as_parameter.py b/Lib/ctypes/test/test_as_parameter.py
+--- a/Lib/ctypes/test/test_as_parameter.py	2007-05-03 21:05:51.000000000 +0000
++++ b/Lib/ctypes/test/test_as_parameter.py	2009-03-01 04:37:26.000000000 +0000
+@@ -1,6 +1,7 @@
+ import unittest
+ from ctypes import *
+ import _ctypes_test
++import sys
+ 
+ dll = CDLL(_ctypes_test.__file__)
+ 
+@@ -171,6 +172,11 @@
+         self.failUnlessEqual((s2h.x, s2h.y), (99*2, 88*3))
+ 
+     def test_struct_return_8H(self):
++        if sys.version.find("mingw") >= 0:
++            # This is known cdecl incompatibility between GCC
++            # and MSVC. It is addressed in GCC issue #36834.
++            # Python libffi detect it and complain.
++            return
+         class S8I(Structure):
+             _fields_ = [("a", c_int),
+                         ("b", c_int),
+diff -Naur a/Lib/ctypes/test/test_functions.py b/Lib/ctypes/test/test_functions.py
+--- a/Lib/ctypes/test/test_functions.py	2007-11-02 23:46:40.000000000 +0000
++++ b/Lib/ctypes/test/test_functions.py	2009-03-01 04:37:26.000000000 +0000
+@@ -359,6 +359,11 @@
+             self.failUnlessEqual((s2h.x, s2h.y), (99*2, 88*3))
+ 
+     def test_struct_return_8H(self):
++        if sys.version.find("mingw") >= 0:
++            # This is known cdecl incompatibility between GCC
++            # and MSVC. It is addressed in GCC issue #36834.
++            # Python libffi detect it and complain.
++            return
+         class S8I(Structure):
+             _fields_ = [("a", c_int),
+                         ("b", c_int),
+diff -Naur a/Lib/ctypes/util.py b/Lib/ctypes/util.py
+--- a/Lib/ctypes/util.py	2009-01-10 22:42:12.000000000 +0000
++++ b/Lib/ctypes/util.py	2009-03-01 04:37:26.000000000 +0000
+@@ -4,6 +4,11 @@
+ if os.name == "nt":
+ 
+     def _get_build_version():
++        #***********************************************************
++        # NOTE: As example for GCC(mingw) build sys.version return:
++        # 2.6rc2+ (trunk:<REVISION>M, <DATE>, <TIME>)
++        # [GCC 3.4.5 (mingw special)]
++        #***********************************************************
+         """Return the version of MSVC that was used to build Python.
+ 
+         For Python 2.3 and up, the version number is included in
+@@ -27,6 +32,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 -Naur a/Lib/distutils/ccompiler.py b/Lib/distutils/ccompiler.py
+--- a/Lib/distutils/ccompiler.py	2008-12-21 00:55:55.000000000 +0000
++++ b/Lib/distutils/ccompiler.py	2009-03-01 04:37:25.000000000 +0000
+@@ -1022,6 +1022,8 @@
+         osname = os.name
+     if platform is None:
+         platform = sys.platform
++    if osname == "nt" and sys.version.find('mingw') >= 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 -Naur a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py
+--- a/Lib/distutils/command/build_ext.py	2009-02-05 22:58:41.000000000 +0000
++++ b/Lib/distutils/command/build_ext.py	2009-03-01 04:37:25.000000000 +0000
+@@ -16,7 +16,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('mingw') < 0:
+     from distutils.msvccompiler import get_build_version
+     MSVC_VERSION = int(get_build_version())
+ 
+@@ -177,7 +178,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('mingw') < 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.
+@@ -219,7 +221,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[:6] == 'atheos' or sys.version.find('mingw') >= 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",
+@@ -669,6 +671,35 @@
+         # 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.
++        from distutils.cygwinccompiler import Mingw32CCompiler
++        if isinstance(self.compiler, Mingw32CCompiler):
++            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 -Naur a/Lib/distutils/cygwinccompiler.py b/Lib/distutils/cygwinccompiler.py
+--- a/Lib/distutils/cygwinccompiler.py	2008-08-19 18:57:56.000000000 +0000
++++ b/Lib/distutils/cygwinccompiler.py	2009-03-01 05:11:34.000000000 +0000
+@@ -58,6 +58,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]
+@@ -75,6 +87,8 @@
+             return ['msvcr90']
+         else:
+             raise ValueError("Unknown MS Compiler version %i " % msc_Ver)
++    else:
++        return []
+ 
+ 
+ class CygwinCCompiler (UnixCCompiler):
+@@ -83,6 +97,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"
+@@ -101,6 +118,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 <host-triplet>-
++        # 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" %
+@@ -125,6 +146,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',
+@@ -269,11 +293,19 @@
+         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 -Naur a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py
+--- a/Lib/distutils/sysconfig.py	2009-02-10 12:41:19.000000000 +0000
++++ b/Lib/distutils/sysconfig.py	2009-03-01 04:37:25.000000000 +0000
+@@ -70,7 +70,8 @@
+     """
+     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('mingw') >= 0:
+         if python_build:
+             base = os.path.dirname(os.path.abspath(sys.executable))
+             if plat_specific:
+@@ -196,7 +197,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('mingw') < 0:
+             inc_dir = os.path.join(project_base, "PC")
+         else:
+             inc_dir = project_base
+@@ -414,6 +416,11 @@
+ 
+ def _init_nt():
+     """Initialize the module as appropriate for NT"""
++    if sys.version.find('mingw') >= 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 -Naur a/Lib/distutils/version.py b/Lib/distutils/version.py
+--- a/Lib/distutils/version.py	2009-01-27 18:31:30.000000000 +0000
++++ b/Lib/distutils/version.py	2009-03-01 13:20:27.890641032 +0000
+@@ -338,7 +338,12 @@
+         if isinstance(other, str):
+             other = LooseVersion(other)
+ 
+-        return cmp(self.version, other.version)
++        if self.version == other.version:
++            return 0 
++        if self.version < other.version:
++            return -1 
++        if self.version > other.version:
++            return 1 
+ 
+ 
+ # end class LooseVersion
+diff -Naur a/Makefile.pre.in b/Makefile.pre.in
+--- a/Makefile.pre.in	2009-01-13 22:15:07.000000000 +0000
++++ b/Makefile.pre.in	2009-03-01 04:37:27.000000000 +0000
+@@ -179,6 +179,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 variable !
++@CROSS_ON@RUNPYTHON=	HOST_OS=@HOST_OS@ @SYSPYTHON@
++@CROSS_OFF@RUNPYTHON=	$(RUNSHARED) ./$(BUILDPYTHON)
++
+ # === Definitions added by makesetup ===
+ 
+ 
+@@ -186,7 +190,7 @@
+ # Modules
+ MODULE_OBJS=	\
+ 		Modules/config.o \
+-		Modules/getpath.o \
++		@MODULE_GETPATH@ \
+ 		Modules/main.o \
+ 		Modules/gcmodule.o
+ 
+@@ -258,7 +262,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 \
+@@ -501,6 +505,7 @@
+ 		$(srcdir)/Modules/getbuildinfo.c
+ 	$(CC) -c $(PY_CFLAGS) -DSVNVERSION=\"`LC_ALL=C $(SVNVERSION)`\" -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)"' \
+@@ -509,10 +514,15 @@
+ 		-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
+ 
+ 
++# FIXME: next may fail in cross-compilation environment
+ $(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT)
+ 		-@$(INSTALL) -d Include
+ 		-$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
+@@ -980,7 +990,7 @@
+ # Install the dynamically loadable modules
+ # This goes into $(exec_prefix)
+ sharedinstall:
+-	$(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \
++	$(RUNPYTHON) -E $(srcdir)/setup.py install \
+ 	   	--prefix=$(prefix) \
+ 		--install-scripts=$(BINDIR) \
+ 		--install-platlib=$(DESTSHARED) \
+@@ -1058,8 +1068,8 @@
+ 
+ # 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)
+@@ -1195,7 +1205,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 -Naur a/Modules/Setup.config.in b/Modules/Setup.config.in
+--- a/Modules/Setup.config.in	2008-05-25 13:05:15.000000000 +0000
++++ b/Modules/Setup.config.in	2009-03-01 13:19:43.208433760 +0000
+@@ -9,5 +9,20 @@
+ # The signal module
+ @USE_SIGNAL_MODULE@signal signalmodule.c
+ 
++# init system calls(posix/nt/...) for INITFUNC (used by makesetup)
++@INITSYS@ posixmodule.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@_collections _collectionsmodule.c	
++@BUILDIN_WIN32_MODULE@time timemodule.c	
++@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@msvcrt ../PC/msvcrtmodule.c
++@BUILDIN_WIN32_MODULE@_subprocess ../PC/_subprocess.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 -Naur a/Modules/Setup.dist b/Modules/Setup.dist
+--- a/Modules/Setup.dist	2008-11-27 09:53:28.000000000 +0000
++++ b/Modules/Setup.dist	2009-03-01 04:37:28.000000000 +0000
+@@ -105,9 +105,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 -Naur a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
+--- a/Modules/_ctypes/_ctypes.c	2009-02-02 20:41:29.000000000 +0000
++++ b/Modules/_ctypes/_ctypes.c	2009-03-01 04:37:29.000000000 +0000
+@@ -3029,14 +3029,32 @@
+ 	   funcname -> _funcname@<n>
+ 	   where n is 0, 4, 8, 12, ..., 128
+ 	 */
++	/* TODO: memory leak for mangled_name
++	 */
+ 	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 -Naur a/Modules/_fileio.c b/Modules/_fileio.c
+--- a/Modules/_fileio.c	2009-02-02 20:41:29.000000000 +0000
++++ b/Modules/_fileio.c	2009-03-01 04:37:33.000000000 +0000
+@@ -22,7 +22,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 -Naur a/Modules/_localemodule.c b/Modules/_localemodule.c
+--- a/Modules/_localemodule.c	2009-02-01 10:41:18.000000000 +0000
++++ b/Modules/_localemodule.c	2009-03-01 04:37:34.000000000 +0000
+@@ -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 -Naur a/Modules/cmathmodule.c b/Modules/cmathmodule.c
+--- a/Modules/cmathmodule.c	2008-07-16 03:43:04.000000000 +0000
++++ b/Modules/cmathmodule.c	2009-03-01 04:37:33.000000000 +0000
+@@ -55,6 +55,21 @@
+ static Py_complex c_tanh(Py_complex);
+ static PyObject * math_error(void);
+ 
++#ifndef TANH_PRESERVES_ZERO_SIGN
++#ifdef __MINGW32__
++/* "math" module has a cross-platform atan2() implemenation, but
++ * "cmath" lack it.
++ * Since atan2() is broken on some msvcrt implementations and mingw32
++ * provide a long double version we will use it as work-arround
++ * independently from define of TANH_PRESERVES_ZERO_SIGN.
++ * NOTE: For mingw host configure override always result after check
++ * so that TANH_PRESERVES_ZERO_SIGN is not defined.
++ */
++static double fake_atan2 (double y, double x) { return atan2l (y, x); }
++#define atan2	fake_atan2
++#endif
++#endif /*ndef TANH_PRESERVES_ZERO_SIGN*/
++
+ /* Code to deal with special values (infinities, NaNs, etc.). */
+ 
+ /* special_type takes a double and returns an integer code indicating
+diff -Naur a/Modules/getaddrinfo.c b/Modules/getaddrinfo.c
+--- a/Modules/getaddrinfo.c	2007-02-27 19:06:23.000000000 +0000
++++ b/Modules/getaddrinfo.c	2009-03-01 04:37:29.000000000 +0000
+@@ -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 -Naur a/Modules/getnameinfo.c b/Modules/getnameinfo.c
+--- a/Modules/getnameinfo.c	2007-02-27 19:06:23.000000000 +0000
++++ b/Modules/getnameinfo.c	2009-03-01 04:37:28.000000000 +0000
+@@ -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 -Naur a/Modules/mathmodule.c b/Modules/mathmodule.c
+--- a/Modules/mathmodule.c	2008-12-21 00:55:55.000000000 +0000
++++ b/Modules/mathmodule.c	2009-03-01 04:37:33.000000000 +0000
+@@ -60,6 +60,15 @@
+ extern double copysign(double, double);
+ #endif
+ 
++#ifdef __MINGW32__
++/* Since ldexp() is broken on some msvcrt implementations and mingw32
++ * provide a long double version we will use it as work-arround.
++ * Broken ldexp return for ldexp(1., INT_MAX) 0(zero) instead inf.
++ */
++static double fake_ldexp (double x, int expn) { return ldexpl (x, expn); }
++#define ldexp	fake_ldexp
++#endif
++
+ /* Call is_error when errno != 0, and where x is the result libm
+  * returned.  is_error will usually set up an exception and return
+  * true (1), but may return false (0) without setting up an exception.
+diff -Naur a/Modules/posixmodule.c b/Modules/posixmodule.c
+--- a/Modules/posixmodule.c	2008-12-29 18:23:24.000000000 +0000
++++ b/Modules/posixmodule.c	2009-03-01 04:40:25.000000000 +0000
+@@ -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 */
+@@ -252,7 +262,7 @@
+ #endif
+ #endif
+ 
+-#ifdef _MSC_VER
++#if defined(_MSC_VER) || defined(__MINGW32__)
+ #ifdef HAVE_DIRECT_H
+ #include <direct.h>
+ #endif
+@@ -338,7 +348,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 */
+ 
+@@ -6618,6 +6628,13 @@
+ #endif
+ 
+ #ifdef MS_WINDOWS
++#ifdef __MINGW32__
++/* FIXME: 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
+ 
+ PyDoc_STRVAR(win32_urandom__doc__,
+ "urandom(n) -> str\n\n\
+@@ -7340,7 +7357,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 PyInit_nt
+ #define MODNAME "nt"
+ 
+diff -Naur a/Modules/python.c b/Modules/python.c
+--- a/Modules/python.c	2008-10-19 14:15:00.000000000 +0000
++++ b/Modules/python.c	2009-03-01 10:54:30.736930752 +0000
+@@ -7,7 +7,7 @@
+ #include <floatingpoint.h>
+ #endif
+ 
+-#ifdef MS_WINDOWS
++#if 0
+ int
+ wmain(int argc, wchar_t **argv)
+ {
+diff -Naur a/Modules/selectmodule.c b/Modules/selectmodule.c
+--- a/Modules/selectmodule.c	2009-02-02 20:41:29.000000000 +0000
++++ b/Modules/selectmodule.c	2009-03-01 04:37:29.000000000 +0000
+@@ -108,9 +108,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 (v < 0 || v >= FD_SETSIZE) {
+ 			PyErr_SetString(PyExc_ValueError,
+ 				    "filedescriptor out of range in select()");
+@@ -118,7 +119,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 */
+@@ -161,7 +162,8 @@
+ 	for (j = 0; fd2obj[j].sentinel >= 0; j++) {
+ 		fd = fd2obj[j].fd;
+ 		if (FD_ISSET(fd, set)) {
+-#ifndef _MSC_VER
++#if !defined(_MSC_VER) && !defined(__MINGW32__)
++/* FIXME: why not #ifndef Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE ? */
+ 			if (fd > FD_SETSIZE) {
+ 				PyErr_SetString(PyExc_SystemError,
+ 			   "filedescriptor out of range returned in select()");
+diff -Naur a/Modules/socketmodule.c b/Modules/socketmodule.c
+--- a/Modules/socketmodule.c	2009-02-06 02:50:18.000000000 +0000
++++ b/Modules/socketmodule.c	2009-03-01 04:37:34.000000000 +0000
+@@ -90,6 +90,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
+@@ -300,6 +309,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
+@@ -337,6 +375,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"
+@@ -2681,7 +2729,21 @@
+ 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__
++/* defined in mstcpip.h, also note "Separate SDKs" required for w2k */
++/* TODO: to test on w2k */
++#  define SIO_RCVALL	0x98000001
++#  define RCVALL_OFF	0
++#  define RCVALL_ON	1
++   /* NOTE: MSDN - this feature is not implemented */
++#  define RCVALL_SOCKETLEVELONLY	2
++#endif
++#endif
+ #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 -Naur a/Objects/fileobject.c b/Objects/fileobject.c
+--- a/Objects/fileobject.c	2009-02-02 20:41:29.000000000 +0000
++++ b/Objects/fileobject.c	2009-03-01 05:20:50.000000000 +0000
+@@ -13,6 +13,22 @@
+ #define FUNLOCKFILE(f)
+ #endif
+ 
++#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
++
+ /* Newline flags */
+ #define NEWLINE_UNKNOWN	0	/* No newline seen, yet */
+ #define NEWLINE_CR 1		/* \r newline seen */
+diff -Naur a/PC/msvcrtmodule.c b/PC/msvcrtmodule.c
+--- a/PC/msvcrtmodule.c	2008-11-30 22:46:23.000000000 +0000
++++ b/PC/msvcrtmodule.c	2009-03-01 13:04:57.105141936 +0000
+@@ -21,9 +21,33 @@
+ #include <io.h>
+ #include <conio.h>
+ #include <sys/locking.h>
+-#include <crtdbg.h>
+ #include <windows.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
+ #include <crtassem.h>
+@@ -260,6 +284,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 -Naur a/PC/winreg.c b/PC/winreg.c
+--- a/PC/winreg.c	2009-02-02 20:41:29.000000000 +0000
++++ b/PC/winreg.c	2009-03-01 04:37:25.000000000 +0000
+@@ -16,6 +16,18 @@
+ #include "structmember.h"
+ #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);
+diff -Naur a/Python/dynload_win.c b/Python/dynload_win.c
+--- a/Python/dynload_win.c	2009-01-27 23:50:56.000000000 +0000
++++ b/Python/dynload_win.c	2009-03-01 04:37:26.000000000 +0000
+@@ -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,10 @@
+ };
+ 
+ 
++#if defined(__MINGW32__)
++/* strcasecmp fail to compile on gcc(mingw32 special) */
++#  define strcasecmp fake_strcasecmp
++#endif
+ /* Case insensitive string compare, to avoid any dependencies on particular
+    C RTL implementations */
+ 
+@@ -190,11 +196,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 -Naur a/Python/fileblocks.c b/Python/fileblocks.c
+--- a/Python/fileblocks.c	1970-01-01 00:00:00.000000000 +0000
++++ b/Python/fileblocks.c	2009-03-01 04:37:26.000000000 +0000
+@@ -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 -Naur a/Python/import.c b/Python/import.c
+--- a/Python/import.c	2009-02-02 20:41:29.000000000 +0000
++++ b/Python/import.c	2009-03-01 06:38:20.798516552 +0000
+@@ -23,9 +23,11 @@
+ #endif
+ 
+ #ifdef MS_WINDOWS
++#ifndef __MINGW32__
+ /* for stat.st_mode */
+ typedef unsigned short mode_t;
+ #endif
++#endif
+ 
+ extern time_t PyOS_GetLastModificationTime(char *, FILE *);
+ 						/* In getmtime.c */
+diff -Naur a/Python/pythonrun.c b/Python/pythonrun.c
+--- a/Python/pythonrun.c	2009-01-26 22:03:09.000000000 +0000
++++ b/Python/pythonrun.c	2009-03-01 06:39:17.371916088 +0000
+@@ -35,8 +35,10 @@
+ #ifdef MS_WINDOWS
+ #undef BYTE
+ #include "windows.h"
++#ifndef __MINGW32__
+ #define PATH_MAX MAXPATHLEN
+ #endif
++#endif
+ 
+ #ifndef Py_REF_DEBUG
+ #define PRINT_TOTAL_REFS()
+diff -Naur a/configure b/configure
+--- a/configure	2009-01-05 19:53:36.000000000 +0000
++++ b/configure	2009-03-01 06:56:29.070074128 +0000
+@@ -1,5 +1,5 @@
+ #! /bin/sh
+-# From configure.in Revision: 68280 .
++# From configure.in Revision: 68442 .
+ # Guess values for system-dependent variables and create Makefiles.
+ # Generated by GNU Autoconf 2.61 for python 3.0.
+ #
+@@ -669,6 +669,7 @@
+ FRAMEWORKALTINSTALLLAST
+ FRAMEWORKUNIXTOOLSPREFIX
+ MACHDEP
++INITSYS
+ SGI_ABI
+ CONFIGURE_MACOSX_DEPLOYMENT_TARGET
+ EXPORT_MACOSX_DEPLOYMENT_TARGET
+@@ -717,6 +718,7 @@
+ USE_THREAD_MODULE
+ LDLAST
+ THREADOBJ
++BUILDIN_WIN32_MODULE
+ DLINCLDIR
+ DYNLOADFILE
+ MACHDEP_OBJS
+@@ -730,6 +732,9 @@
+ LIBM
+ LIBC
+ THREADHEADERS
++PYMOD_BUILDOPT
++PYTHON_OBJS_FROZENMAIN
++MODULE_GETPATH
+ SRCDIRS
+ LTLIBOBJS'
+ ac_subst_files=''
+@@ -1811,7 +1816,14 @@
+ mv confdefs.h.new confdefs.h
+ 
+ 
++case $host in
++  *-*-mingw*)
++  VERSION=`echo 3.0 | sed -e 's|\.||g'`
++  ;;
++  *)
+ VERSION=3.0
++  ;;
++esac
+ 
+ 
+ SOVERSION=1.0
+@@ -2034,6 +2046,15 @@
+ echo $ECHO_N "checking MACHDEP... $ECHO_C" >&6; }
+ if test -z "$MACHDEP"
+ then
++		case $host in
++	*-*-mingw*)
++		ac_sys_system=ignore
++						MACHDEP=win
++	;;
++	esac
++fi
++if test -z "$MACHDEP"
++then
+ 	ac_sys_system=`uname -s`
+ 	if test "$ac_sys_system" = "AIX" -o "$ac_sys_system" = "Monterey64" \
+ 	-o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
+@@ -2056,6 +2077,19 @@
+ 	esac
+ fi
+ 
++{ echo "$as_me:$LINENO: checking for init system calls" >&5
++echo $ECHO_N "checking for init system calls... $ECHO_C" >&6; }
++
++case $host in
++  # FIXME: May configure lack detection for os2 host system ?
++  #?#*-*-os2*)	INITSYS=os2;;
++  *-*-mingw*)	INITSYS=nt;;
++  *)		INITSYS=posix;;
++esac
++{ echo "$as_me:$LINENO: result: $INITSYS" >&5
++echo "${ECHO_T}$INITSYS" >&6; }
++
++
+ # Some systems cannot stand _XOPEN_SOURCE being defined at all; they
+ # disable features if it is defined, without any means to access these
+ # features as extensions. For these systems, we skip the definition of
+@@ -2228,7 +2262,7 @@
+ if test "${with_gcc+set}" = set; then
+   withval=$with_gcc;
+ 	case $withval in
+-	no)	CC=cc
++	no)	CC=${CC:-cc}
+ 		without_gcc=yes;;
+ 	yes)	CC=gcc
+ 		without_gcc=no;;
+@@ -3949,6 +3983,10 @@
+   *)
+     enable_shared="no";;
+   esac
++  case $host in
++  *-*-mingw*)
++    enable_shared="yes";;
++  esac
+ fi
+ { echo "$as_me:$LINENO: result: $enable_shared" >&5
+ echo "${ECHO_T}$enable_shared" >&6; }
+@@ -4092,6 +4130,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*)
+@@ -4099,6 +4143,10 @@
+           LDLIBRARY='libpython$(VERSION).dll.a'
+           ;;
+   esac
++  case $host in
++    *-*-mingw*)
++          LDLIBRARY='libpython$(VERSION).a';;
++  esac
+ fi
+ 
+ { echo "$as_me:$LINENO: result: $LDLIBRARY" >&5
+@@ -4446,6 +4494,27 @@
+ echo "${ECHO_T}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?
+@@ -4462,6 +4531,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 -z "$OPT"
+ then
+@@ -4584,6 +4655,10 @@
+          alpha*)
+                 BASECFLAGS="$BASECFLAGS -mieee"
+                 ;;
++         *-*-mingw*)
++                #MSVC compatable storage layout for bitfields in structures
++                BASECFLAGS="$BASECFLAGS -mms-bitfields"
++                ;;
+     esac
+ 
+     case $ac_sys_system in
+@@ -4669,7 +4744,9 @@
+ esac
+ 
+ if test "$Py_DEBUG" = 'true'; then
+-  :
++  case $host in
++        *-*-mingw*) OPT="-D_DEBUG $OPT";;
++  esac
+ else
+   OPT="-DNDEBUG $OPT"
+ fi
+@@ -5185,6 +5262,65 @@
+ echo "${ECHO_T}$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
++	{ echo "$as_me:$LINENO: checking for NT threads" >&5
++echo $ECHO_N "checking for NT threads... $ECHO_C" >&6; }
++	if test "${ac_cv_ntthread+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.  */
++
++int
++main ()
++{
++_beginthread(0, 0, 0);
++  ;
++  return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (ac_try="$ac_link"
++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_link") 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_exeext &&
++       $as_test_x conftest$ac_exeext; then
++  ac_cv_ntthread=yes
++else
++  echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++	ac_cv_ntthread=no
++fi
++
++rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
++      conftest$ac_exeext conftest.$ac_ext
++fi
++
++	{ echo "$as_me:$LINENO: result: $ac_cv_ntthread" >&5
++echo "${ECHO_T}$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
+@@ -5206,6 +5342,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
+@@ -5525,6 +5664,7 @@
+ 
+ 
+ 
++
+ for ac_header in asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
+ fcntl.h grp.h \
+ ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \
+@@ -5536,7 +5676,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
++bluetooth/bluetooth.h linux/tipc.h winsock2.h
+ do
+ as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+@@ -12906,6 +13046,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
+@@ -13032,6 +13182,11 @@
+ 	atheos*) LDSHARED="gcc -shared";;
+ 	*)	LDSHARED="ld";;
+ 	esac
++	case $host in
++	*-*-mingw*)
++		LDSHARED='$(CC) -shared -Wl,--enable-auto-image-base'
++		;;
++	esac
+ fi
+ { echo "$as_me:$LINENO: result: $LDSHARED" >&5
+ echo "${ECHO_T}$LDSHARED" >&6; }
+@@ -13133,6 +13288,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
+ { echo "$as_me:$LINENO: result: $LINKFORSHARED" >&5
+ echo "${ECHO_T}$LINKFORSHARED" >&6; }
+@@ -13151,6 +13312,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
+ { echo "$as_me:$LINENO: result: $CFLAGSFORSHARED" >&5
+ echo "${ECHO_T}$CFLAGSFORSHARED" >&6; }
+@@ -13830,6 +13997,19 @@
+ 
+     posix_threads=yes
+     THREADOBJ="Python/thread.o"
++elif test "x$ac_cv_ntthread" = xyes
++then
++    cat >>confdefs.h <<\_ACEOF
++#define WITH_THREAD 1
++_ACEOF
++
++    posix_threads=no
++    THREADOBJ="Python/thread.o"
++
++cat >>confdefs.h <<\_ACEOF
++#define NT_THREADS 1
++_ACEOF
++
+ else
+     if test ! -z "$with_threads" -a -d "$with_threads"
+     then LDFLAGS="$LDFLAGS -L$with_threads"
+@@ -15155,6 +15335,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
+ 
+ 
+@@ -15763,6 +15955,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
+ { echo "$as_me:$LINENO: result: $DYNLOADFILE" >&5
+ echo "${ECHO_T}$DYNLOADFILE" >&6; }
+@@ -15780,6 +15980,11 @@
+ 
+ { echo "$as_me:$LINENO: checking MACHDEP_OBJS" >&5
+ echo $ECHO_N "checking MACHDEP_OBJS... $ECHO_C" >&6; }
++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
+@@ -15881,7 +16086,7 @@
+  mremap nice pathconf pause plock poll pthread_init \
+  putenv readlink realpath \
+  select setegid seteuid setgid \
+- setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
++ setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
+  sigaction siginterrupt sigrelse strftime strlcpy \
+  sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
+  truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll wcsxfrm _getpty
+@@ -15978,6 +16183,7 @@
+ done
+ 
+ 
++
+ # For some functions, having a definition is not sufficient, since
+ # we want to take their address.
+ { echo "$as_me:$LINENO: checking for chroot" >&5
+@@ -18653,9 +18859,19 @@
+ sed 's/^/| /' conftest.$ac_ext >&5
+ 
+ 
+-{ echo "$as_me:$LINENO: result: no" >&5
++case $host in
++  #FIXME: mingw define getaddinfo if WINVER >= 0x501, i.e. XP or greater.
++  #TODO: mingw require additional check.
++  #*-*-mingw*)
++  #  AC_MSG_RESULT([yes])
++  #  buggygetaddrinfo=no
++  #  ;;
++  *)
++    { echo "$as_me:$LINENO: result: no" >&5
+ echo "${ECHO_T}no" >&6; }
+-buggygetaddrinfo=yes
++    buggygetaddrinfo=yes
++    ;;
++esac
+ 
+ fi
+ 
+@@ -19894,7 +20110,11 @@
+ cat >>conftest.$ac_ext <<_ACEOF
+ /* end confdefs.h.  */
+ 
+-#		include <netdb.h>
++#ifdef HAVE_WINSOCK2_H
++#  include <ws2tcpip.h>
++#else
++#  include <netdb.h>
++#endif
+ int
+ main ()
+ {
+@@ -19953,8 +20173,15 @@
+ cat >>conftest.$ac_ext <<_ACEOF
+ /* 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 ()
+ {
+@@ -21157,6 +21384,9 @@
+ Darwin) ;;
+ *) LIBM=-lm
+ esac
++case $host in
++  *-*-mingw*) LIBM=;;
++esac
+ { echo "$as_me:$LINENO: checking for --with-libm=STRING" >&5
+ echo $ECHO_N "checking for --with-libm=STRING... $ECHO_C" >&6; }
+ 
+@@ -21279,6 +21509,12 @@
+ 
+ fi
+ 
++case $host in
++  *-*-mingw*)
++    # Some MSVC runtimes don't preserve zero sign.
++    # On mingw host we will use always replacemnt function.
++    ac_cv_tanh_preserves_zero_sign=no;;
++esac
+ { echo "$as_me:$LINENO: result: $ac_cv_tanh_preserves_zero_sign" >&5
+ echo "${ECHO_T}$ac_cv_tanh_preserves_zero_sign" >&6; }
+ if test "$ac_cv_tanh_preserves_zero_sign" = yes
+@@ -22029,7 +22265,10 @@
+ else
+ 
+   if test "$cross_compiling" = yes; then
+-  ac_cv_wchar_t_signed=yes
++  case $host in
++  *-*-mingw*) ac_cv_wchar_t_signed=no;;
++  *)          ac_cv_wchar_t_signed=yes;;
++  esac
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+ /* confdefs.h.  */
+@@ -24229,8 +24468,37 @@
+   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
++    ;;
++esac
++
+ 
+ SRCDIRS="Parser Grammar Objects Python Modules Mac"
++case $host in
++  *-*-mingw*) SRCDIRS="$SRCDIRS PC";;
++esac
+ { echo "$as_me:$LINENO: checking for build directories" >&5
+ echo $ECHO_N "checking for build directories... $ECHO_C" >&6; }
+ for dir in $SRCDIRS; do
+@@ -24918,6 +25186,7 @@
+ FRAMEWORKALTINSTALLLAST!$FRAMEWORKALTINSTALLLAST$ac_delim
+ FRAMEWORKUNIXTOOLSPREFIX!$FRAMEWORKUNIXTOOLSPREFIX$ac_delim
+ MACHDEP!$MACHDEP$ac_delim
++INITSYS!$INITSYS$ac_delim
+ SGI_ABI!$SGI_ABI$ac_delim
+ CONFIGURE_MACOSX_DEPLOYMENT_TARGET!$CONFIGURE_MACOSX_DEPLOYMENT_TARGET$ac_delim
+ EXPORT_MACOSX_DEPLOYMENT_TARGET!$EXPORT_MACOSX_DEPLOYMENT_TARGET$ac_delim
+@@ -24961,7 +25230,6 @@
+ LINKFORSHARED!$LINKFORSHARED$ac_delim
+ CFLAGSFORSHARED!$CFLAGSFORSHARED$ac_delim
+ SHLIBS!$SHLIBS$ac_delim
+-USE_SIGNAL_MODULE!$USE_SIGNAL_MODULE$ac_delim
+ _ACEOF
+ 
+   if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
+@@ -25003,10 +25271,12 @@
+ ac_delim='%!_!# '
+ for ac_last_try in false false false false false :; do
+   cat >conf$$subs.sed <<_ACEOF
++USE_SIGNAL_MODULE!$USE_SIGNAL_MODULE$ac_delim
+ SIGNAL_OBJS!$SIGNAL_OBJS$ac_delim
+ USE_THREAD_MODULE!$USE_THREAD_MODULE$ac_delim
+ LDLAST!$LDLAST$ac_delim
+ THREADOBJ!$THREADOBJ$ac_delim
++BUILDIN_WIN32_MODULE!$BUILDIN_WIN32_MODULE$ac_delim
+ DLINCLDIR!$DLINCLDIR$ac_delim
+ DYNLOADFILE!$DYNLOADFILE$ac_delim
+ MACHDEP_OBJS!$MACHDEP_OBJS$ac_delim
+@@ -25020,11 +25290,14 @@
+ LIBM!$LIBM$ac_delim
+ LIBC!$LIBC$ac_delim
+ THREADHEADERS!$THREADHEADERS$ac_delim
++PYMOD_BUILDOPT!$PYMOD_BUILDOPT$ac_delim
++PYTHON_OBJS_FROZENMAIN!$PYTHON_OBJS_FROZENMAIN$ac_delim
++MODULE_GETPATH!$MODULE_GETPATH$ac_delim
+ SRCDIRS!$SRCDIRS$ac_delim
+ LTLIBOBJS!$LTLIBOBJS$ac_delim
+ _ACEOF
+ 
+-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 19; 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
+diff -Naur a/configure.in b/configure.in
+--- a/configure.in	2009-01-09 04:17:34.000000000 +0000
++++ b/configure.in	2009-03-01 06:56:36.479947656 +0000
+@@ -34,7 +34,15 @@
+ mv confdefs.h.new confdefs.h
+ 
+ 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
+@@ -214,6 +222,22 @@
+ AC_MSG_CHECKING(MACHDEP)
+ 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`
+ 	if test "$ac_sys_system" = "AIX" -o "$ac_sys_system" = "Monterey64" \
+ 	-o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
+@@ -235,6 +259,17 @@
+ 	'')	MACHDEP="unknown";;
+ 	esac
+ fi
++
++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])
++
+ 	
+ # Some systems cannot stand _XOPEN_SOURCE being defined at all; they
+ # disable features if it is defined, without any means to access these
+@@ -607,6 +642,10 @@
+   *)
+     enable_shared="no";;
+   esac
++  case $host in
++  *-*-mingw*)
++    enable_shared="yes";;
++  esac
+ fi
+ AC_MSG_RESULT($enable_shared)
+ 
+@@ -700,6 +739,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*)
+@@ -707,6 +754,10 @@
+           LDLIBRARY='libpython$(VERSION).dll.a'
+           ;;
+   esac
++  case $host in
++    *-*-mingw*)
++          LDLIBRARY='libpython$(VERSION).a';;
++  esac
+ fi
+ 
+ AC_MSG_RESULT($LDLIBRARY)
+@@ -744,6 +795,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, 
+@@ -758,6 +811,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?
+@@ -774,6 +850,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 -z "$OPT"
+ then
+@@ -854,6 +932,10 @@
+          alpha*)
+                 BASECFLAGS="$BASECFLAGS -mieee"
+                 ;;
++         *-*-mingw*)
++                #MSVC compatable storage layout for bitfields in structures
++                BASECFLAGS="$BASECFLAGS -mms-bitfields"
++                ;;
+     esac
+ 
+     case $ac_sys_system in
+@@ -936,8 +1018,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
+@@ -1132,6 +1221,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
+@@ -1152,6 +1255,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
+@@ -1193,7 +1299,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)
++bluetooth/bluetooth.h linux/tipc.h winsock2.h)
+ AC_HEADER_DIRENT
+ AC_HEADER_MAJOR
+ 
+@@ -1520,6 +1626,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
+@@ -1640,6 +1756,11 @@
+ 	atheos*) LDSHARED="gcc -shared";;
+ 	*)	LDSHARED="ld";;
+ 	esac
++	case $host in
++	*-*-mingw*)
++		LDSHARED='$(CC) -shared -Wl,--enable-auto-image-base'
++		;;
++	esac
+ fi
+ AC_MSG_RESULT($LDSHARED)
+ BLDSHARED=${BLDSHARED-$LDSHARED}
+@@ -1737,6 +1858,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)
+ 
+@@ -1753,6 +1880,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)
+ 
+@@ -1920,6 +2053,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"
+@@ -2079,6 +2219,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])
+@@ -2345,6 +2497,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"
+@@ -2357,6 +2517,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
+@@ -2374,11 +2539,22 @@
+  mremap nice pathconf pause plock poll pthread_init \
+  putenv readlink realpath \
+  select setegid seteuid setgid \
+- setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
++ setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
+  sigaction siginterrupt sigrelse strftime strlcpy \
+  sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
+  truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll wcsxfrm _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)
+@@ -2759,8 +2935,18 @@
+ buggygetaddrinfo=yes,
+ AC_MSG_RESULT(buggy)
+ buggygetaddrinfo=yes)], [
+-AC_MSG_RESULT(no)
+-buggygetaddrinfo=yes
++case $host in
++  #FIXME: mingw define getaddinfo if WINVER >= 0x501, i.e. XP or greater.
++  #TODO: mingw require additional check.
++  #*-*-mingw*)
++  #  AC_MSG_RESULT([yes])
++  #  buggygetaddrinfo=no
++  #  ;;
++  *)
++    AC_MSG_RESULT([no])
++    buggygetaddrinfo=yes
++    ;;
++esac
+ ])
+ 
+ if test "$buggygetaddrinfo" = "yes"; then
+@@ -2812,20 +2998,31 @@
+ AC_MSG_CHECKING(for addrinfo)
+ AC_CACHE_VAL(ac_cv_struct_addrinfo,
+ AC_TRY_COMPILE([
+-#		include <netdb.h>],
++#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_TRY_COMPILE([
+-#		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],
+ 	[struct sockaddr_storage s],
+ 	ac_cv_struct_sockaddr_storage=yes,
+ 	ac_cv_struct_sockaddr_storage=no))
+@@ -3019,6 +3216,10 @@
+ Darwin) ;;
+ *) 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,
+             AC_HELP_STRING(--with-libm=STRING, math library),
+@@ -3075,6 +3276,12 @@
+ ac_cv_tanh_preserves_zero_sign=yes,
+ ac_cv_tanh_preserves_zero_sign=no,
+ ac_cv_tanh_preserves_zero_sign=no)])
++case $host in
++  *-*-mingw*)
++    # Some MSVC runtimes don't preserve zero sign.
++    # On mingw host we will use always replacemnt function.
++    ac_cv_tanh_preserves_zero_sign=no;;
++esac
+ AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
+ if test "$ac_cv_tanh_preserves_zero_sign" = yes
+ then
+@@ -3129,7 +3336,10 @@
+   ],
+   ac_cv_wchar_t_signed=yes,
+   ac_cv_wchar_t_signed=no,
+-  ac_cv_wchar_t_signed=yes)])
++  [case $host in
++  *-*-mingw*) ac_cv_wchar_t_signed=no;;
++  *)          ac_cv_wchar_t_signed=yes;;
++  esac])])
+   AC_MSG_RESULT($ac_cv_wchar_t_signed)
+ fi
+ 
+@@ -3628,8 +3838,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 -Naur a/pyconfig.h.in b/pyconfig.h.in
+--- a/pyconfig.h.in	2008-09-07 06:24:49.000000000 +0000
++++ b/pyconfig.h.in	2009-03-01 08:51:03.668976240 +0000
+@@ -28,7 +28,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. */
+@@ -58,6 +58,10 @@
+ /* Define to 1 if you have the <bluetooth.h> header file. */
+ #undef HAVE_BLUETOOTH_H
+ 
++/* Define if mbstowcs(NULL, "text", 0) does not return the number of wide
++   chars that would be converted. */
++#undef HAVE_BROKEN_MBSTOWCS
++
+ /* Define if nice() returns success/failure instead of the new priority. */
+ #undef HAVE_BROKEN_NICE
+ 
+@@ -122,8 +126,11 @@
+ /* Define if we have /dev/ptc. */
+ #undef HAVE_DEV_PTC
+ 
++/* disable openpty always */
++#if 0
+ /* Define if we have /dev/ptmx. */
+ #undef HAVE_DEV_PTMX
++#endif
+ 
+ /* Define to 1 if you have the <direct.h> header file. */
+ #undef HAVE_DIRECT_H
+@@ -180,8 +187,11 @@
+ /* Define to 1 if you have the `fork' function. */
+ #undef HAVE_FORK
+ 
++/* disable forkpty always */
++#if 0
+ /* Define to 1 if you have the `forkpty' function. */
+ #undef HAVE_FORKPTY
++#endif
+ 
+ /* Define to 1 if you have the `fpathconf' function. */
+ #undef HAVE_FPATHCONF
+@@ -357,7 +367,7 @@
+ /* Define to 1 if you have the <libintl.h> header file. */
+ #undef HAVE_LIBINTL_H
+ 
+-/* Define to 1 if you have the `readline' library (-lreadline). */
++/* Define if you have the readline library (-lreadline). */
+ #undef HAVE_LIBREADLINE
+ 
+ /* Define to 1 if you have the `resolv' library (-lresolv). */
+@@ -420,8 +430,11 @@
+ /* Define to 1 if you have the `nice' function. */
+ #undef HAVE_NICE
+ 
++/* disable openpty always */
++#if 0
+ /* Define to 1 if you have the `openpty' function. */
+ #undef HAVE_OPENPTY
++#endif
+ 
+ /* Define if compiling using MacOS X 10.5 SDK or later. */
+ #undef HAVE_OSX105_SDK
+@@ -447,6 +460,8 @@
+ /* Define if your compiler supports function prototype */
+ #undef HAVE_PROTOTYPES
+ 
++/* disable pthreads, pty always */
++#if 0
+ /* Define if you have GNU PTH threads. */
+ #undef HAVE_PTH
+ 
+@@ -464,6 +479,7 @@
+ 
+ /* Define to 1 if you have the <pty.h> header file. */
+ #undef HAVE_PTY_H
++#endif /* force disable */
+ 
+ /* Define to 1 if you have the `putenv' function. */
+ #undef HAVE_PUTENV
+@@ -800,9 +816,8 @@
+ /* Define to 1 if you have the `wcsxfrm' function. */
+ #undef HAVE_WCSXFRM
+ 
+-/* Define if mbstowcs(NULL, "text", 0) does not return the number of 
+-   wide chars that would be converted */
+-#undef HAVE_BROKEN_MBSTOWCS
++/* 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.
+    */
+@@ -811,8 +826,11 @@
+ /* Define if the zlib library has inflateCopy */
+ #undef HAVE_ZLIB_COPY
+ 
++/* disable getpty always */
++#if 0
+ /* Define to 1 if you have the `_getpty' function. */
+ #undef HAVE__GETPTY
++#endif
+ 
+ /* Define if you are using Mach cthreads directly under /include */
+ #undef HURD_C_THREADS
+@@ -831,6 +849,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 -Naur a/setup.py b/setup.py
+--- a/setup.py	2009-02-10 16:25:06.000000000 +0000
++++ b/setup.py	2009-03-01 04:46:38.000000000 +0000
+@@ -115,7 +115,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.")
+ 
+         # Figure out the location of the source code for extension modules
+@@ -189,8 +189,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 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 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])
+@@ -261,6 +291,10 @@
+             self.announce('WARNING: skipping import check for Cygwin-based "%s"'
+                 % ext.name)
+             return
++        if os.environ.get('HOST_OS') is not None:
++            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)))
+@@ -302,6 +336,19 @@
+             self.failed.append(ext.name)
+ 
+     def get_platform(self):
++        # Get value of host platform (set only if cross-compile)
++        host_os=os.environ.get('HOST_OS')
++        if host_os is not None:
++                # FIXME: extend for other host platforms.
++                # Until isn't confirmed that we can use 'win32' in all places
++                # where 'mingw' is use alone this method has to return 'mingw'
++                # otherwise uncomment next two lines:
++                #if host_os.startswith('mingw'):
++                #    return 'win32'
++                for platform in ['mingw', 'cygwin', 'beos', 'darwin', 'atheos', 'osf1']:
++                    if host_os.startswith(platform):
++                        return platform
++                return host_os
+         # Get value of sys.platform
+         for platform in ['cygwin', 'darwin', 'atheos', 'osf1']:
+             if sys.platform.startswith(platform):
+@@ -319,6 +366,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).
++        # 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),
+@@ -388,6 +438,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():
+@@ -400,7 +451,7 @@
+ 
+         # Check for MacOS X, which doesn't need libm.a at all
+         math_libs = ['m']
+-        if platform in ['darwin', 'mac']:
++        if platform in ['darwin', 'mac', 'mingw', 'win32']:
+             math_libs = []
+ 
+         # XXX Omitted modules: gl, pure, dl, SGI-specific modules
+@@ -438,9 +489,11 @@
+         # heapq
+         exts.append( Extension("_heapq", ["_heapqmodule.c"]) )
+         # operator.add() and similar goodies
+-        exts.append( Extension('operator', ['operator.c']) )
++        if platform not in ['mingw', 'win32']:
++            exts.append( Extension('operator', ['operator.c']) )
+         # _functools
+-        exts.append( Extension("_functools", ["_functoolsmodule.c"]) )
++        if platform not in ['mingw', 'win32']:
++            exts.append( Extension("_functools", ["_functoolsmodule.c"]) )
+         # C-optimized pickle replacement
+         exts.append( Extension("_pickle", ["_pickle.c"]) )
+         # atexit
+@@ -467,7 +520,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 platform not in ['mingw', 'win32']:
++            exts.append( Extension('_locale', ['_localemodule.c'],
+                                libraries=locale_libs,
+                                extra_link_args=locale_extra_link_args) )
+ 
+@@ -476,8 +532,11 @@
+         # supported...)
+ 
+         # fcntl(2) and ioctl(2)
+-        exts.append( Extension('fcntl', ['fcntlmodule.c']) )
+-        if platform not in ['mac']:
++        if platform not in ['mingw', 'win32']:
++            exts.append( Extension('fcntl', ['fcntlmodule.c']) )
++        else:
++            missing.append('fcntl')
++        if platform not in ['mac', 'mingw', 'win32']:
+             # pwd(3)
+             exts.append( Extension('pwd', ['pwdmodule.c']) )
+             # grp(3)
+@@ -492,7 +551,12 @@
+             missing.extend(['pwd', 'grp', 'spwd'])
+ 
+         # select(2); not on ancient System V
+-        exts.append( Extension('select', ['selectmodule.c']) )
++        if 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']) )
+@@ -504,7 +568,7 @@
+             missing.append('mmap')
+ 
+         # Lance Ellinghaus's syslog module
+-        if platform not in ['mac']:
++        if platform not in ['mac', 'mingw', 'win32']:
+             # syslog daemon interface
+             exts.append( Extension('syslog', ['syslogmodule.c']) )
+         else:
+@@ -526,6 +590,11 @@
+ 
+         # readline
+         do_readline = self.compiler.find_library_file(lib_dirs, 'readline')
++        if platform in ['mingw', 'win32']:
++            # MSVC builds don't use readline.
++            # In cross-compilation environment readline check will
++            # find libraries on build system.
++            do_readline = False
+         if platform == 'darwin': # and os.uname()[2] < '9.':
+             # MacOSX 10.4 has a broken readline. Don't try to build
+             # the readline module unless the user has installed a fixed
+@@ -535,7 +604,7 @@
+             if find_file('readline/rlconf.h', inc_dirs, []) is None:
+                 do_readline = False
+         if do_readline:
+-            if sys.platform == 'darwin':
++            if 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.
+@@ -565,7 +634,7 @@
+         else:
+             missing.append('readline')
+ 
+-        if platform not in ['mac']:
++        if platform not in ['mac', 'mingw', 'win32']:
+             # crypt module.
+ 
+             if self.compiler.find_library_file(lib_dirs, 'crypt'):
+@@ -580,7 +649,12 @@
+         exts.append( Extension('_csv', ['_csv.c']) )
+ 
+         # socket(2)
++        if 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 = [
+@@ -602,10 +676,13 @@
+ 
+         if (ssl_incs is not None and
+             ssl_libs is not None):
++            _ssl_libs = ['ssl', 'crypto']
++            if 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')
+@@ -658,6 +735,29 @@
+             exts.append( Extension('_md5', ['md5module.c']) )
+             exts.append( Extension('_sha1', ['sha1module.c']) )
+ 
++        # Modules with some Windows dependencies:
++        if 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']) )
++
+         # Modules that provide persistent dictionary-like semantics.  You will
+         # probably want to arrange for at least one of them to be available on
+         # your machine, though none are defined by default because of library
+@@ -747,13 +847,14 @@
+                 '_sqlite/util.c', ]
+ 
+             sqlite_defines = []
+-            if sys.platform != "win32":
++            #NOTE: don't add mingw here
++            if platform != 'win32':
+                 sqlite_defines.append(('MODULE_NAME', '"sqlite3"'))
+             else:
+                 sqlite_defines.append(('MODULE_NAME', '\\"sqlite3\\"'))
+ 
+ 
+-            if sys.platform == 'darwin':
++            if 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 entiry path.
+@@ -775,7 +876,7 @@
+             missing.append('_sqlite3')
+ 
+         # The standard Unix dbm module:
+-        if platform not in ['cygwin']:
++        if platform not in ['cygwin', 'mingw', 'win32']:
+             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'):
+@@ -818,7 +919,7 @@
+             missing.append('_gdbm')
+ 
+         # Unix-only modules
+-        if platform not in ['mac', 'win32']:
++        if platform not in ['mac', 'mingw', 'win32']:
+             # Steen Lumholt's termios module
+             exts.append( Extension('termios', ['termios.c']) )
+             # Jeremy Hylton's rlimit interface
+@@ -843,7 +944,12 @@
+         # Curses support, requiring the System V version of curses, often
+         # provided by the ncurses library.
+         panel_library = 'panel'
+-        if (self.compiler.find_library_file(lib_dirs, 'ncursesw')):
++        if platform in ['mingw', 'win32']:
++            # MSVC build is without _curses module.
++            # Also in cross-compilation environment the code below
++            # find libraries from build system, so ignore it.
++            pass
++        elif (self.compiler.find_library_file(lib_dirs, 'ncursesw')):
+             curses_libs = ['ncursesw']
+             # Bug 1464056: If _curses.so links with ncursesw,
+             # _curses_panel.so must link with panelw.
+@@ -906,7 +1012,7 @@
+                     break
+             if version >= version_req:
+                 if (self.compiler.find_library_file(lib_dirs, 'z')):
+-                    if sys.platform == "darwin":
++                    if platform == "darwin":
+                         zlib_extra_link_args = ('-Wl,-search_paths_first',)
+                     else:
+                         zlib_extra_link_args = ()
+@@ -938,7 +1044,7 @@
+ 
+         # Gustavo Niemeyer's bz2 module.
+         if (self.compiler.find_library_file(lib_dirs, 'bz2')):
+-            if sys.platform == "darwin":
++            if platform == "darwin":
+                 bz2_extra_link_args = ('-Wl,-search_paths_first',)
+             else:
+                 bz2_extra_link_args = ()
+@@ -1000,7 +1106,7 @@
+         # _fileio -- supposedly cross platform
+         exts.append(Extension('_fileio', ['_fileio.c']))
+         # Richard Oudkerk's multiprocessing module
+-        if platform == 'win32':             # Windows
++        if platform in ['mingw', 'win32']:  # Windows
+             macros = dict()
+             libraries = ['ws2_32']
+ 
+@@ -1048,7 +1154,7 @@
+                 )
+             libraries = ['rt']
+ 
+-        if platform == 'win32':
++        if platform in ['mingw', 'win32']:
+             multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c',
+                                      '_multiprocessing/semaphore.c',
+                                      '_multiprocessing/pipe_connection.c',
+@@ -1192,7 +1298,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 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]
+@@ -1221,6 +1327,9 @@
+         if platform == 'sunos5':
+             include_dirs.append('/usr/openwin/include')
+             added_lib_dirs.append('/usr/openwin/lib')
++        elif 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')
+@@ -1256,8 +1365,8 @@
+         if platform in ['aix3', 'aix4']:
+             libs.append('ld')
+ 
+-        # Finally, link with the X11 libraries (not appropriate on cygwin)
+-        if platform != "cygwin":
++        # Finally, link with the X11 libraries (not appropriate on cygwin, mingw)
++        if not platform in ['cygwin', 'mingw', 'win32']:
+             libs.append('X11')
+ 
+         ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
+@@ -1308,8 +1417,32 @@
+         return True
+ 
+     def configure_ctypes(self, ext):
++        platform = self.get_platform()
++        if 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', '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')
++            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 sys.platform == 'darwin':
++            if platform == 'darwin':
+                 return self.configure_ctypes_darwin(ext)
+ 
+             (srcdir,) = sysconfig.get_config_vars('srcdir')
+@@ -1373,14 +1506,15 @@
+                    '_ctypes/malloc_closure.c']
+         depends = ['_ctypes/ctypes.h']
+ 
+-        if sys.platform == 'darwin':
++        platform = self.get_platform()
++        if platform == 'darwin':
+             sources.append('_ctypes/darwin/dlfcn_simple.c')
+             extra_compile_args.append('-DMACOSX')
+             include_dirs.append('_ctypes/darwin')
+ # XXX Is this still needed?
+ ##            extra_link_args.extend(['-read_only_relocs', 'warning'])
+ 
+-        elif sys.platform == 'sunos5':
++        elif 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
+@@ -1391,7 +1525,7 @@
+             # finding some -z option for the Sun compiler.
+             extra_link_args.append('-mimpure-text')
+ 
+-        elif sys.platform.startswith('hp-ux'):
++        elif platform.startswith('hp-ux'):
+             extra_link_args.append('-fPIC')
+ 
+         ext = Extension('_ctypes',
+@@ -1401,14 +1535,19 @@
+                         libraries=[],
+                         sources=sources,
+                         depends=depends)
++        if 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])
+ 
+         if not '--with-system-ffi' in sysconfig.get_config_var("CONFIG_ARGS"):
+             return
+ 
+-        if sys.platform == 'darwin':
++        if platform == 'darwin':
+             # OS X 10.5 comes with libffi.dylib; the include files are
+             # in /usr/include/ffi
+             inc_dirs.append('/usr/include/ffi')

Modified: torvm/trunk/build/win32/patches/vidalia-torvm.patch
===================================================================
--- torvm/trunk/build/win32/patches/vidalia-torvm.patch	2009-03-01 10:50:17 UTC (rev 18729)
+++ torvm/trunk/build/win32/patches/vidalia-torvm.patch	2009-03-01 14:43:35 UTC (rev 18730)
@@ -1,72 +1,6 @@
-diff -Naur a/pkg/win32/WixUI_Tor.wxs b/pkg/win32/WixUI_Tor.wxs
---- a/pkg/win32/WixUI_Tor.wxs	1970-01-01 00:00:00.000000000 +0000
-+++ b/pkg/win32/WixUI_Tor.wxs	2009-02-20 06:33:55.000000000 +0000
-@@ -0,0 +1,62 @@
-+<?xml version="1.0" encoding="UTF-8"?>
-+<!--
-+    Copyright (c) Microsoft Corporation.  All rights reserved.
-+    
-+    The use and distribution terms for this software are covered by the
-+    Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
-+    which can be found in the file CPL.TXT at the root of this distribution.
-+    By using this software in any fashion, you are agreeing to be bound by
-+    the terms of this license.
-+    
-+    You must not remove this notice, or any other, from this software.
-+
-+    This is modified from WixUI_Mondo to omit EULA and other parts not necessary
-+    for Tor installation.
-+-->
-+<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi";>
-+    <Fragment>
-+        <UI Id="WixUI_Tor">
-+            <TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
-+            <TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
-+            <TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />
-+
-+            <Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
-+            <Property Id="WixUI_Mode" Value="Tor" />
-+
-+            <DialogRef Id="ErrorDlg" />
-+            <DialogRef Id="FatalError" />
-+            <DialogRef Id="FilesInUse" />
-+            <DialogRef Id="MsiRMFilesInUse" />
-+            <DialogRef Id="PrepareDlg" />
-+            <DialogRef Id="ProgressDlg" />
-+            <DialogRef Id="ResumeDlg" />
-+            <DialogRef Id="UserExit" />
-+
-+            <Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>
-+
-+            <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="SetupTypeDlg">1</Publish>
-+
-+            <Publish Dialog="SetupTypeDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
-+            <Publish Dialog="SetupTypeDlg" Control="TypicalButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
-+            <Publish Dialog="SetupTypeDlg" Control="CustomButton" Event="NewDialog" Value="CustomizeDlg">1</Publish>
-+
-+            <Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="1">WixUI_InstallMode = "Change"</Publish>
-+            <Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="SetupTypeDlg" Order="2">WixUI_InstallMode = "InstallCustom"</Publish>
-+            <Publish Dialog="CustomizeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
-+
-+            <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="CustomizeDlg" Order="1">WixUI_InstallMode = "InstallCustom"</Publish>
-+            <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="SetupTypeDlg" Order="2">WixUI_InstallMode = "InstallTypical" OR WixUI_InstallMode = "InstallComplete"</Publish>
-+            <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="CustomizeDlg" Order="3">WixUI_InstallMode = "Change"</Publish>
-+            <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="4">WixUI_InstallMode = "Repair" OR WixUI_InstallMode = "Remove"</Publish>
-+
-+            <Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg">1</Publish>
-+
-+            <Publish Dialog="MaintenanceTypeDlg" Control="ChangeButton" Event="NewDialog" Value="CustomizeDlg">1</Publish>
-+            <Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
-+            <Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
-+            <Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg">1</Publish>
-+        </UI>
-+
-+        <UIRef Id="WixUI_Common" />
-+    </Fragment>
-+</Wix>
 diff -Naur a/pkg/win32/polipo.conf b/pkg/win32/polipo.conf
 --- a/pkg/win32/polipo.conf	2008-04-06 00:00:07.066809000 +0000
-+++ b/pkg/win32/polipo.conf	2009-02-20 06:33:55.000000000 +0000
++++ b/pkg/win32/polipo.conf	2009-03-01 00:53:58.321690488 +0000
 @@ -36,8 +36,9 @@
  
  # Uncomment this if you want to use a parent SOCKS proxy:
@@ -100,12 +34,12 @@
  
  ### HTTP
 diff -Naur a/pkg/win32/vidalia.wxs.in b/pkg/win32/vidalia.wxs.in
---- a/pkg/win32/vidalia.wxs.in	2009-01-31 04:32:04.562803000 +0000
-+++ b/pkg/win32/vidalia.wxs.in	2009-02-20 19:43:57.000000000 +0000
-@@ -1,221 +1,223 @@
+--- a/pkg/win32/vidalia.wxs.in	2009-02-24 05:46:46.615879000 +0000
++++ b/pkg/win32/vidalia.wxs.in	2009-03-01 12:03:50.515548280 +0000
+@@ -1,260 +1,263 @@
  <?xml version="1.0" encoding="Windows-1252" ?>
  <!-- 
--  $Id: vidalia.wxs.in 3486 2009-01-31 04:32:04Z edmanm $
+-  $Id: vidalia.wxs.in 3586 2009-02-24 05:46:46Z edmanm $
 +  $Id: vidalia.wxs.in 3329 2008-11-21 02:04:34Z edmanm $
 +
 +  This file is part of Vidalia, and is subject to the license terms in the
@@ -121,9 +55,14 @@
 +    light.exe vidalia.wixobj -out vidalia.msi -ext C:\Path\to\Wix\bin\WixUIExtension.dll
   -->
  <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi";>
--  <Product Name="Vidalia @VERSION@" Id="B3C22D59-D907-4559-9569-92AAA34DB6F0"
 +  <?define ThisProductVersion="@VER_MAJOR@.@VER_MINOR@.@VER_PATCH@" ?>
 +  <?define ThisProductVersionDisp="@VERSION@" ?>
++  <?define VidaliaVersion="@VERSION@" ?>
++  <?define TorVersion="latest" ?>
++  <?define TorbuttonVersion="latest" ?>
++  <?define PolipoVersion="latest" ?>
++  <?define PrivoxyVersion="latest" ?>
++  <?define VidaliaBundleVersion="bundle-@VERSION@" ?>
 +  <?define UpgradeCode="147903e8-fa6f-47f0-bf97-b7250337b2b7" ?>
 +  
 +  <?define CurrProductGUID="0a57c31b-6cce-4bd0-b3ef-652a6cceb914" ?>
@@ -134,6 +73,7 @@
 +  <?define CurrGeoIPCacheGUID="8686ff7a-d812-44db-8c11-b94478495096" ?>
 +  <?define CurrPolipoConfigGUID="2151ad60-10ce-4e91-ab44-d1895d3b001d" ?>
 +  <?define CurrMarblePluginGUID="0212a411-960d-4729-b03b-3c95777a4551" ?>
++  <?define CurrPluginDataDirGUID="e72719f3-e92c-4b2c-a8bb-4865436f5734" ?>
 +  <?define CurrDocumentsGUID="abfaae86-352e-4b63-b9b3-c222936f24b3" ?>
 +  <?define CurrConfigFileGUID="4428ffd8-710d-4550-b51d-16e69e073981" ?>
 +  <?define CurrStartMenuGUID="69d3f4bb-755c-4ade-aeb1-771fd5f8ba60" ?>
@@ -141,13 +81,33 @@
 +  <?define CurrDocsOnDesktopGUID="1e141231-e111-4567-94a6-7f42def8a516" ?>
 +  <?define CurrStartupGUID="6073bd5b-8eee-465e-9eca-f1ec7c6ddd67" ?>
 +  <?define CurrLocalProgramsGUID="24aaf630-09aa-45ef-a3cc-4088302b3488" ?>
-+
+ 
+-  <?define VidaliaVersion="@VER_MAJOR@.@VER_MINOR@.@VER_PATCH@" ?>
+-  <?define VidaliaUpgradeCode="B7FBFE11-D7CA-4895-A1FB-1D7E065E4D04" ?>
+-  <?define VidaliaProductGuid="B3C22D59-D907-4559-9569-92AAA34DB6F0" ?>
+-  <?define VidaliaDocumentsGuid="6A51C86C-A7D4-407f-9B84-7ADCE016E939" ?>
+-  <?define QtLibraryGuid="00F354CB-B313-4100-8900-11293A66B385" ?>
+-  <?define QtImageFormatPluginsGuid="9A0F1EA5-3A5F-4456-B211-9368C24E22F3" ?>
+-  <?define MinGWLibraryGuid="2287E844-F9CD-4129-8BD0-50D071698194" ?>
+-  <?define OpenSSLLibraryGuid="C3EDC2EC-D0B1-452a-83A6-85B0BC94735B" ?>
+-  <?define MarbleWidgetLibraryGuid="A2968B8D-0E23-4649-B8F3-A988A04F823C" ?>
+-  <?define MarblePluginsGuid="B4665EC1-3082-4fca-AA7E-60512ED62EF6" ?>
+-  <?define MarbleLegendsDataGuid="FA6F733F-8249-4b2b-B978-2AA04E06F5D5" ?>
+-  <?define MarbleBlueMarbleDataGuid="392FEE6B-374A-447a-AECC-0422915305DB" ?>
+-  <?define MarbleCityLightsDataGuid="DBF9FBE7-012D-4457-ABB4-9085F7E784F8" ?>
+-  <?define MarbleMwdbiiDataGuid="56ACE658-6892-408a-91E5-7B5BD23D8829" ?>
+-  <?define MarbleSrtmDataGuid="2C3A9C67-92CB-4fc6-A2F6-AD9118AFD58C" ?>
+-  <?define MarblePlacemarkDataGuid="27D54547-A819-435b-9A0C-13284169A9D9" ?>
+-  <?define MarbleStarsDataGuid="8C5C3F32-67E6-4a4a-9B6C-6D67A6D44D67" ?>
+-  <?define MarbleSvgDataGuid="03E25BCA-4C58-4571-9F17-061D52877714" ?>
+-
+-  <Product Name="Vidalia @VERSION@" Id="$(var.VidaliaProductGuid)"
 +  <Product Name="Vidalia $(var.ThisProductVersionDisp)" Id="$(var.CurrProductGUID)"
             Language="1033" Codepage="1252"
--           Version="@VER_MAJOR@.@VER_MINOR@.@VER_PATCH@" 
+-           Version="$(var.VidaliaVersion)" 
 +           Version="$(var.ThisProductVersion)"
             Manufacturer="vidalia-project.net"
--           UpgradeCode="B7FBFE11-D7CA-4895-A1FB-1D7E065E4D04">
+-           UpgradeCode="$(var.VidaliaUpgradeCode)">
 +           UpgradeCode="$(var.UpgradeCode)">
      
      <Package Id="*" Keywords="Installer"
@@ -158,10 +118,30 @@
 -             Languages="1033"  SummaryCodepage="1252" />
 +             Languages="1033"  SummaryCodepage="1252"
 +             InstallPrivileges="limited" />
++
++    <!-- Properties used for variable replacement in translations. -->
++    <Property Id="LANGUAGE_CODE" Value="!(loc.LanguageCode)" />
++    <Property Id="VIDALIA_NAME" Value="Vidalia" />
++    <Property Id="VIDALIA_DESC" Value="Vidalia $(var.VidaliaVersion)" />
++    <Property Id="TOR_NAME" Value="Tor" />
++    <Property Id="TOR_DESC" Value="Tor $(var.TorVersion)" />
++    <Property Id="PRIVOXY_NAME" Value="Privoxy" />
++    <Property Id="PRIVOXY_DESC" Value="Privoxy $(var.PrivoxyVersion)" />
++    <Property Id="POLIPO_NAME" Value="Polipo" />
++    <Property Id="POLIPO_DESC" Value="Polipo $(var.PolipoVersion)" />
++    <Property Id="TORBUTTON_NAME" Value="Torbutton" />
++    <Property Id="TORBUTTON_DESC" Value="Torbutton $(var.TorbuttonVersion)" />
++    <Property Id="BUNDLE_NAME" Value="Vidalia Bundle" />
++    <Property Id="BUNDLE_DESC" Value="Vidalia Bundle $(var.VidaliaBundleVersion)" />
  
      <Media Id="1" Cabinet="Vidalia.cab" CompressionLevel="high"
             EmbedCab="yes" DiskPrompt="CD-ROM #1" />
 -    <Property Id="DiskPrompt" Value="Vidalia @VERSION@ Installation [1]" />
+-
+-    <Upgrade Id="$(var.VidaliaUpgradeCode)">
+-      <UpgradeVersion Property="UPGRADEFOUND" OnlyDetect="no"
+-                      Minimum="0.0.1" IncludeMinimum="yes"
+-                      Maximum="$(var.VidaliaVersion)" IncludeMaximum="no" />
 +    <Property Id="DiskPrompt" Value="Vidalia $(var.ThisProductVersionDisp) Installation Volume [1]" />
 +    <Property Id="ALLUSERS" Secure="yes"/>
 +    <Property Id="ReinstallModeText">omus</Property>
@@ -188,14 +168,19 @@
 +        Maximum="$(var.ThisProductVersion)"
 +        IncludeMaximum="no"
 +      />
-+    </Upgrade>
-+
+     </Upgrade>
  
 -    <!-- Define the target installation directory hierarchy -->
++
      <Directory Id="TARGETDIR" Name="SourceDir">
 -      <Directory Id="ProgramFilesFolder" Name="ProgramFilesDir">
 -        <Directory Id="INSTALLDIR" Name="Vidalia">
--          <Directory Id="MarblePluginsDir" Name="plugins" />
+-          <Directory Id="PluginsDir" Name="plugins">
+-            <Directory Id="QtPluginsDir" Name="qt">
+-              <Directory Id="QtImageFormatPluginsDir" Name="imageformats" />
+-            </Directory>
+-            <Directory Id="MarblePluginsDir" Name="marble" />
+-          </Directory>
 -          <Directory Id="MarbleDataDir" Name="data">
 -            <Directory Id="MarbleMapsDir" Name="maps">
 -              <Directory Id="MarbleEarthMapsDir" Name="earth">
@@ -242,11 +227,13 @@
 +              <RegistryValue Name="Version" Value="$(var.ThisProductVersion)" Type="string" KeyPath="yes" />
 +            </RegistryKey>
 +            <File Id="VidaliaExe" DiskId="1"
-+                  Name="vidalia.exe" Source="src\vidalia\vidalia.exe" />
++                  Name="vidalia.exe" Source="bin\vidalia-2d.exe" />
++            <File Id="VidaliaMarbleExe" DiskId="1"
++                  Name="vidalia-marble.exe" Source="bin\vidalia-marble.exe" />
 +          </Component>
  
 -      <!-- Vidalia-related documents -->
--      <Component Id="VidaliaDocuments" Guid="6A51C86C-A7D4-407f-9B84-7ADCE016E939">
+-      <Component Id="VidaliaDocuments" Guid="$(var.VidaliaDocumentsGuid)">
 -        <File Id="VidaliaReadme" DiskId="1"
 -              Name="README" Source="@Vidalia_SOURCE_DIR@\README" />
 -        <File Id="VidaliaCredits" DiskId="1"
@@ -279,10 +266,12 @@
 +                  Name="QtXml4.dll" Source="bin\QtXml4.dll" />
 +            <File Id="QtSvg4Dll" DiskId="1"
 +                  Name="QtSvg4.dll" Source="bin\QtSvg4.dll" />
++            <File Id="MarbleQtWidgetDll" DiskId="1"
++              Name="libmarblewidget.dll" Source="bin/libmarblewidget.dll" />
 +          </Component>
  
 -      <!-- Qt-related library files -->
--      <Component Id="QtLibrary" Guid="00F354CB-B313-4100-8900-11293A66B385">
+-      <Component Id="QtLibrary" Guid="$(var.QtLibraryGuid)">
 -        <File Id="QtCore4Dll" DiskId="1"
 -              Name="QtCore4.dll" Source="@QT_BINARY_DIR@\QtCore4.dll" />
 -        <File Id="QtGui4Dll" DiskId="1"
@@ -306,7 +295,7 @@
 +          </Component>
  
 -      <!-- MinGW-related library files -->
--      <Component Id="MinGWLibrary" Guid="2287E844-F9CD-4129-8BD0-50D071698194">
+-      <Component Id="MinGWLibrary" Guid="$(var.MinGWLibraryGuid)">
 -        <File Id="MinGWDll" DiskId="1"
 -              Name="mingwm10.dll" Source="@MINGW_BINARY_DIR@\mingwm10.dll" />
 -      </Component>
@@ -324,21 +313,45 @@
 +          </Component>
  
 -      <!-- OpenSSL-related library files -->
--      <Component Id="OpenSSLLibrary" Guid="C3EDC2EC-D0B1-452a-83A6-85B0BC94735B">
+-      <Component Id="OpenSSLLibrary" Guid="$(var.OpenSSLLibraryGuid)">
 -        <File Id="ssleay32dll" DiskId="1"
 -              Name="ssleay32.dll" Source="@OPENSSL_BINARY_DIR@\ssleay32.dll" />
 -      </Component>
 -      
 -      <!-- Marble-related library files -->
--      <Component Id="MarbleWidgetLibrary" Guid="A2968B8D-0E23-4649-B8F3-A988A04F823C">
+-      <Component Id="MarbleWidgetLibrary" Guid="$(var.MarbleWidgetLibraryGuid)">
 -        <File Id="MarbleWidgetDll" DiskId="1"
 -              Name="libmarblewidget.dll" Source="@MARBLEWIDGET_LIBRARY@" />
 -      </Component>
 -    </DirectoryRef>
--    
++          <!-- Place this here until argument parsing with quoted escapes works as expected. -->
++          <Component Id="PolipoConfig" Guid="$(var.CurrPolipoConfigGUID)">
++            <RegistryKey Root="HKCU" Key="Software\Vidalia" Action="createAndRemoveOnUninstall">
++              <RegistryValue Name="PolipoConfigFile" Value="1" Type="integer" KeyPath="yes" />
++            </RegistryKey>
++            <File
++              Id="PolipoConfigFile"
++              Name="polipocfg.txt"
++              Source="pkg/win32/polipo.conf"
++              Vital="yes"
++              ReadOnly="no"
++              DiskId="1"
++            />
++          </Component>
+ 
+-    <!-- Qt-related plugin files -->
+-    <DirectoryRef Id="QtImageFormatPluginsDir">
+-      <Component Id="QtImageFormatPlugins" Guid="$(var.QtImageFormatPluginsGuid)">
+-        <File Id="QJpeg4Dll" DiskId="1"
+-              Name="qjpeg4.dll" Source="@QT_PLUGINS_DIR@\imageformats\qjpeg4.dll" />
+-      </Component>
+-    </DirectoryRef>
++         </Directory>
++        </Directory>
+ 
 -    <!-- Marble-related plugin files -->
 -    <DirectoryRef Id="MarblePluginsDir">
--      <Component Id="MarblePlugins" Guid="B4665EC1-3082-4fca-AA7E-60512ED62EF6">
+-      <Component Id="MarblePlugins" Guid="$(var.MarblePluginsGuid)">
 -        <File Id="MarbleOverviewMapPlugin" DiskId="1"
 -              Name="libMarbleOverviewMap.dll" Source="@MARBLE_OVERVIEWMAP_PLUGIN@" />
 -        <File Id="MarbleStarsPlugin" DiskId="1"
@@ -348,7 +361,7 @@
 -          
 -    <!-- Marble-related data files -->
 -    <DirectoryRef Id="MarbleDataDir">
--      <Component Id="MarbleLegendsData" Guid="FA6F733F-8249-4b2b-B978-2AA04E06F5D5">
+-      <Component Id="MarbleLegendsData" Guid="$(var.MarbleLegendsDataGuid)">
 -        <File Id="LandColorsLegend" DiskId="1"
 -              Name="landcolors.leg" Source="@MARBLE_DATA_DIR@\landcolors.leg" />
 -        <File Id="SeaColorsLegend" DiskId="1"
@@ -356,19 +369,19 @@
 -      </Component>
 -    </DirectoryRef>
 -    <DirectoryRef Id="MarbleBlueMarbleDataDir">
--      <Component Id="MarbleBlueMarbleData" Guid="392FEE6B-374A-447a-AECC-0422915305DB">
+-      <Component Id="MarbleBlueMarbleData" Guid="$(var.MarbleBlueMarbleDataGuid)">
 -        <File Id="MarbleBlueMarbleDgml" DiskId="1"
 -              Name="bluemarble.dgml" Source="@MARBLE_DATA_DIR@\maps\earth\bluemarble\bluemarble.dgml" />
 -      </Component>
 -    </DirectoryRef>
 -    <DirectoryRef Id="MarbleCityLightsDataDir">
--      <Component Id="MarbleCityLightsData" Guid="DBF9FBE7-012D-4457-ABB4-9085F7E784F8">
+-      <Component Id="MarbleCityLightsData" Guid="$(var.MarbleCityLightsDataGuid)">
 -        <File Id="MarbleCityLightsDgml" DiskId="1"
 -              Name="citylights.dgml" Source="@MARBLE_DATA_DIR@\maps\earth\citylights\citylights.dgml" />
 -      </Component>
 -    </DirectoryRef>
 -    <DirectoryRef Id="MarbleSrtmDataDir">
--      <Component Id="MarbleSrtmData" Guid="2C3A9C67-92CB-4fc6-A2F6-AD9118AFD58C">
+-      <Component Id="MarbleSrtmData" Guid="$(var.MarbleSrtmDataGuid)">
 -        <File Id="MarbleSrtmDgml" DiskId="1"
 -              Name="srtm.dgml" Source="@MARBLE_DATA_DIR@\maps\earth\srtm\srtm.dgml" />
 -        <File Id="MarbleSrtmJpg" DiskId="1"
@@ -376,7 +389,7 @@
 -      </Component>
 -    </DirectoryRef>
 -    <DirectoryRef Id="MarbleMwdbiiDir">
--      <Component Id="MarbleMwdbiiData" Guid="56ACE658-6892-408a-91E5-7B5BD23D8829">
+-      <Component Id="MarbleMwdbiiData" Guid="$(var.MarbleMwdbiiDataGuid)">
 -        <File Id="DatelinePnt" DiskId="1"
 -              Name="DATELINE.PNT" Source="@MARBLE_DATA_DIR@\mwdbii\DATELINE.PNT" />
 -        <File Id="PAustPnt" DiskId="1"
@@ -408,7 +421,7 @@
 -      </Component>
 -    </DirectoryRef>
 -    <DirectoryRef Id="MarblePlacemarkDataDir">
--      <Component Id="MarblePlacemarkData" Guid="27D54547-A819-435b-9A0C-13284169A9D9">
+-      <Component Id="MarblePlacemarkData" Guid="$(var.MarblePlacemarkDataGuid)">
 -        <File Id="BasePlacemarksCache" DiskId="1"
 -              Name="baseplacemarks.cache" Source="@MARBLE_DATA_DIR@\placemarks\baseplacemarks.cache" />
 -        <File Id="BoundaryPlacemarksCache" DiskId="1"
@@ -418,13 +431,13 @@
 -      </Component>
 -    </DirectoryRef>
 -    <DirectoryRef Id="MarbleStarsDataDir">
--      <Component Id="MarbleStarsData" Guid="8C5C3F32-67E6-4a4a-9B6C-6D67A6D44D67">
+-      <Component Id="MarbleStarsData" Guid="$(var.MarbleStarsDataGuid)">
 -        <File Id="StarsDat" DiskId="1"
 -              Name="stars.dat" Source="@MARBLE_DATA_DIR@\stars\stars.dat" />
 -      </Component>
 -    </DirectoryRef>
 -    <DirectoryRef Id="MarbleSvgDataDir">
--      <Component Id="MarbleSvgData" Guid="03E25BCA-4C58-4571-9F17-061D52877714">
+-      <Component Id="MarbleSvgData" Guid="$(var.MarbleSvgDataGuid)">
 -        <File Id="WorldMapSvg" DiskId="1"
 -              Name="worldmap.svg" Source="@MARBLE_DATA_DIR@\svg\worldmap.svg" />
 -      </Component>
@@ -439,47 +452,6 @@
 -      <ComponentRef Id="MarbleStarsData" />
 -      <ComponentRef Id="MarbleSvgData" />
 -    </ComponentGroup>
-+          <!-- Place this here until argument parsing with quoted escapes works as expected. -->
-+          <Component Id="PolipoConfig" Guid="$(var.CurrPolipoConfigGUID)">
-+            <RegistryKey Root="HKCU" Key="Software\Vidalia" Action="createAndRemoveOnUninstall">
-+              <RegistryValue Name="PolipoConfigFile" Value="1" Type="integer" KeyPath="yes" />
-+            </RegistryKey>
-+            <File
-+              Id="PolipoConfigFile"
-+              Name="polipocfg.txt"
-+              Source="pkg/win32/polipo.conf"
-+              Vital="yes"
-+              ReadOnly="no"
-+              DiskId="1"
-+            />
-+          </Component>
-+
-+          <!-- Marble plugin library file -->
-+          <Component Id="MarblePlugin" Guid="$(var.CurrMarblePluginGUID)">
-+            <RegistryKey Root="HKCU" Key="Software\Vidalia" Action="createAndRemoveOnUninstall">
-+              <RegistryValue Name="MarblePluginLibrary" Value="1" Type="integer" KeyPath="yes" />
-+            </RegistryKey>
-+            <File Id="MarbleWidgetDll" DiskId="1"
-+              Name="libmarblewidget.dll" Source="bin/libmarblewidget.dll" />
-+            <File Id="MarbleOverview.dll" DiskId="1"
-+              Name="libMarbleOverviewMap.dll" Source="bin/libMarbleOverviewMap.dll" />
-+            <File Id="MarbleStars.dll" DiskId="1"
-+              Name="libMarbleStarsPlugin.dll" Source="bin/libMarbleStarsPlugin.dll" />
-+            <File Id="CompassFloat.dll" DiskId="1"
-+              Name="libCompassFloatItem.dll" Source="bin/libCompassFloatItem.dll" />
-+            <File Id="MapScaleFloat.dll" DiskId="1"
-+              Name="libMapScaleFloatItem.dll" Source="bin/libMapScaleFloatItem.dll" />
-+            <File Id="MarbleCrosshairs.dll" DiskId="1"
-+              Name="libMarbleCrosshairsPlugin.dll" Source="bin/libMarbleCrosshairsPlugin.dll" />
-+            <File Id="MarbleGeoData.dll" DiskId="1"
-+              Name="libMarbleGeoDataPlugin.dll" Source="bin/libMarbleGeoDataPlugin.dll" />
-+            <File Id="NavigationFloat.dll" DiskId="1"
-+              Name="libNavigationFloatItem.dll" Source="bin/libNavigationFloatItem.dll" />
-+          </Component>
-+
-+         </Directory>
-+        </Directory>
-+
 +        <Directory Id="INSTALLDIR" Name="Vidalia">
 +          <Component Id="GeoIPCache" Guid="$(var.CurrGeoIPCacheGUID)">
 +            <CreateFolder/>
@@ -496,6 +468,39 @@
 +              DiskId="1"
 +            /> 
 +          </Component>
++          <Directory Id="LocalPluginsDir" Name="plugins">
++            <!-- Marble plugin library file -->
++            <Component Id="MarblePlugin" Guid="$(var.CurrMarblePluginGUID)">
++              <CreateFolder/>
++              <RemoveFolder Id="RemoveLocalPluginsDir" On="uninstall" />
++              <RegistryKey Root="HKCU" Key="Software\Vidalia" Action="createAndRemoveOnUninstall">
++                <RegistryValue Name="MarblePluginLibrary" Value="1" Type="integer" KeyPath="yes" />
++              </RegistryKey>
++              <File Id="MarbleOverview.dll" DiskId="1"
++                Name="libMarbleOverviewMap.dll" Source="bin/libMarbleOverviewMap.dll" />
++              <File Id="MarbleStars.dll" DiskId="1"
++                Name="libMarbleStarsPlugin.dll" Source="bin/libMarbleStarsPlugin.dll" />
++              <File Id="CompassFloat.dll" DiskId="1"
++                Name="libCompassFloatItem.dll" Source="bin/libCompassFloatItem.dll" />
++              <File Id="MapScaleFloat.dll" DiskId="1"
++                Name="libMapScaleFloatItem.dll" Source="bin/libMapScaleFloatItem.dll" />
++              <File Id="MarbleCrosshairs.dll" DiskId="1"
++                Name="libMarbleCrosshairsPlugin.dll" Source="bin/libMarbleCrosshairsPlugin.dll" />
++              <File Id="MarbleGeoData.dll" DiskId="1"
++                Name="libMarbleGeoDataPlugin.dll" Source="bin/libMarbleGeoDataPlugin.dll" />
++              <File Id="NavigationFloat.dll" DiskId="1"
++                Name="libNavigationFloatItem.dll" Source="bin/libNavigationFloatItem.dll" />
++            </Component>
++            <Directory Id="LocalPluginsDataDir" Name="data">
++              <Component Id="PluginDataDir" Guid="$(var.CurrPluginDataDirGUID)">
++                <CreateFolder/>
++                <RemoveFolder Id="RemoveLocalPluginsDataDir" On="uninstall" />
++                <RegistryKey Root="HKCU" Key="Software\Vidalia" Action="createAndRemoveOnUninstall">
++                  <RegistryValue Name="PluginDataDir" Value="1" Type="integer" KeyPath="yes" />
++                </RegistryKey>
++              </Component>
++            </Directory>
++          </Directory>
 +        </Directory>
 +      </Directory>
  
@@ -514,10 +519,14 @@
 -                      Directory="ShortcutFolder" WorkingDirectory="INSTALLDIR"
 +                      Name="Vidalia" Target="[LocalProgramsInstDir]vidalia.exe"
 +                      Directory="ShortcutFolder" WorkingDirectory="LocalProgramsInstDir"
++                      Icon="vidalia.ico" IconIndex="0" />
++            <Shortcut Id="VidaliaMarbleStartMenuShortcut"
++                      Name="Vidalia Marble" Target="[LocalProgramsInstDir]vidalia-marble.exe"
++                      Directory="ShortcutFolder" WorkingDirectory="LocalProgramsInstDir"
                        Icon="vidalia.ico" IconIndex="0" />
              <RemoveFolder Id="RemoveShortcutFolder" On="uninstall" />
            </Component>
-@@ -223,41 +225,43 @@
+@@ -262,73 +265,79 @@
        </Directory>
  
        <Directory Id="DesktopFolder" Name="Desktop">
@@ -532,6 +541,10 @@
 -                    Directory="DesktopFolder" WorkingDirectory="INSTALLDIR"
 +                    Name="Vidalia" Target="[LocalProgramsInstDir]vidalia.exe"
 +                    Directory="DesktopFolder" WorkingDirectory="LocalProgramsInstDir"
++                    Icon="vidalia.ico" IconIndex="0" />
++          <Shortcut Id="VidaliaMarbleDesktopShortcut"
++                    Name="Vidalia Marble" Target="[LocalProgramsInstDir]vidalia-marble.exe"
++                    Directory="DesktopFolder" WorkingDirectory="LocalProgramsInstDir"
                      Icon="vidalia.ico" IconIndex="0" />
          </Component>
        </Directory>
@@ -552,8 +565,9 @@
      <!-- Build up the feature hierarchy -->
      <Feature Id="Complete" Title="Vidalia"
               Level="1" Display="expand" ConfigurableDirectory="INSTALLDIR"
-              Description="Vidalia is application that helps you control, monitor, and configure the Tor software.">
+-             Description="Vidalia is application that helps you control, monitor, and configure the Tor software.">
 -      <Feature Id="MainApplication" Title="Vidalia @VERSION@"
++             Description="!(loc.VidaliaAppDesc)">
 +      <Feature Id="MainApplication" Title="Vidalia $(var.ThisProductVersionDisp)"
                 AllowAdvertise="no" Absent="disallow" Level="1"
                 Description="Main application">
@@ -561,6 +575,7 @@
          <ComponentRef Id="VidaliaExecutable" />
 -        <ComponentRef Id="VidaliaDocuments" />
          <ComponentRef Id="QtLibrary" />
+-        <ComponentRef Id="QtImageFormatPlugins" />
          <ComponentRef Id="MinGWLibrary" />
          <ComponentRef Id="OpenSSLLibrary" />
 -        <ComponentRef Id="MarbleWidgetLibrary" />
@@ -569,24 +584,44 @@
 +        <ComponentRef Id="GeoIPCache" />
 +        <ComponentRef Id="PolipoConfig" />
 +        <ComponentRef Id="MarblePlugin" />
++        <ComponentRef Id="PluginDataDir" />
        </Feature>
        <Feature Id="Shortcuts" Title="Shortcuts"
                 AllowAdvertise="no" Absent="allow" Level="1"
-@@ -280,10 +284,15 @@
+-               Description="Add a shortcut to Vidalia to your Start menu or Desktop.">
++               Description="!(loc.VidaliaShortcutsDesc)">
+         <Feature Id="StartMenuShortcuts" Title="Add to Start menu"
+                  AllowAdvertise="no" Absent="allow" Level="1"
+-                 Description="Add Vidalia to your Start menu">
++                 Description="!(loc.VidaliaShortcutsDesc)">
+           <ComponentRef Id="AddVidaliaToStartMenu" />
+         </Feature>
+         <Feature Id="DesktopShortcuts" Title="Add to Desktop"
+                  AllowAdvertise="no" Absent="allow" Level="1"
+-                 Description="Add Vidalia to your Desktop">
++                 Description="!(loc.VidaliaShortcutsDesc)">
+           <ComponentRef Id="AddVidaliaToDesktop" />
+         </Feature>
+         <Feature Id="RunAtStartup" Title="Run at Startup"
+                  AllowAdvertise="no" Absent="allow" Level="1"
+-                 Description="Run Vidalia automatically when your system starts">
++                 Description="!(loc.VidaliaStartupDesc)">
+           <ComponentRef Id="AddToStartupItems" />
+         </Feature>
        </Feature>
      </Feature>
  
+-    <!-- Upgrade installation sequence -->
 +    <!-- Upgrade installation sequence. -->
-+    <InstallExecuteSequence>
-+      <RemoveExistingProducts After="InstallValidate" />
-+    </InstallExecuteSequence>
-+
+     <InstallExecuteSequence>
+       <RemoveExistingProducts After="InstallValidate" />
+     </InstallExecuteSequence>
+ 
      <!-- Set the UI options -->
--    <UIRef Id="WixUI_Custom" />
+     <UIRef Id="WixUI_Custom" />
 -    <Icon Id="vidalia.ico" SourceFile="@Vidalia_SOURCE_DIR@\src\vidalia\res\icons\vidalia.ico" />
 -    <WixVariable Id="WixUIBannerBmp" Value="@Vidalia_SOURCE_DIR@\pkg\win32\msi-header.bmp" />
 -    <WixVariable Id="WixUIDialogBmp" Value="@Vidalia_SOURCE_DIR@\pkg\win32\msi-welcome.bmp" />
-+    <UIRef Id="WixUI_Tor" />
 +    <Icon Id="vidalia.ico" SourceFile="src\vidalia\res\icons\vidalia.ico" />
 +    <WixVariable Id="WixUIBannerBmp" Value="pkg\win32\msi-header.bmp" />
 +    <WixVariable Id="WixUIDialogBmp" Value="pkg\win32\msi-welcome.bmp" />
@@ -594,7 +629,7 @@
  </Wix>
 diff -Naur a/src/common/win32.cpp b/src/common/win32.cpp
 --- a/src/common/win32.cpp	2009-02-16 22:53:13.437184000 +0000
-+++ b/src/common/win32.cpp	2009-02-20 06:33:55.000000000 +0000
++++ b/src/common/win32.cpp	2009-03-01 00:53:58.321690488 +0000
 @@ -67,16 +67,20 @@
  QString
  win32_program_files_folder()
@@ -622,7 +657,7 @@
  /** Returns the value in keyName at keyLocation. 
 diff -Naur a/src/vidalia/config/torsettings.cpp b/src/vidalia/config/torsettings.cpp
 --- a/src/vidalia/config/torsettings.cpp	2009-01-30 05:20:24.536180000 +0000
-+++ b/src/vidalia/config/torsettings.cpp	2009-02-20 06:33:56.000000000 +0000
++++ b/src/vidalia/config/torsettings.cpp	2009-03-01 00:53:58.322690336 +0000
 @@ -61,6 +61,7 @@
  {
  #if defined(Q_OS_WIN32)
@@ -649,7 +684,7 @@
    setDefault(SETTING_AUTH_METHOD,   toString(DEFAULT_AUTH_METHOD));
 diff -Naur a/src/vidalia/config/vidaliasettings.cpp b/src/vidalia/config/vidaliasettings.cpp
 --- a/src/vidalia/config/vidaliasettings.cpp	2009-02-03 02:09:39.844750000 +0000
-+++ b/src/vidalia/config/vidaliasettings.cpp	2009-02-20 06:33:56.000000000 +0000
++++ b/src/vidalia/config/vidaliasettings.cpp	2009-03-01 00:53:58.323690184 +0000
 @@ -71,9 +71,16 @@
    setDefault(SETTING_SHOW_MAINWINDOW_AT_START, true);
    setDefault(SETTING_BROWSER_EXECUTABLE, "");
@@ -672,7 +707,7 @@
  #else
 diff -Naur a/src/vidalia/network/geoipresolver.cpp b/src/vidalia/network/geoipresolver.cpp
 --- a/src/vidalia/network/geoipresolver.cpp	2008-12-30 18:48:55.745877000 +0000
-+++ b/src/vidalia/network/geoipresolver.cpp	2009-02-20 06:33:56.000000000 +0000
++++ b/src/vidalia/network/geoipresolver.cpp	2009-03-01 00:53:58.324690032 +0000
 @@ -24,13 +24,13 @@
  #endif
  
@@ -707,7 +742,7 @@
  }
 diff -Naur a/src/vidalia/network/tormapwidget.cpp b/src/vidalia/network/tormapwidget.cpp
 --- a/src/vidalia/network/tormapwidget.cpp	2009-02-19 21:15:24.029490000 +0000
-+++ b/src/vidalia/network/tormapwidget.cpp	2009-02-20 06:36:59.000000000 +0000
++++ b/src/vidalia/network/tormapwidget.cpp	2009-03-01 00:53:58.324690032 +0000
 @@ -24,8 +24,8 @@
  using namespace Marble;
  
@@ -734,7 +769,7 @@
    TorMapWidgetPopupMenu *popupMenu  = new TorMapWidgetPopupMenu(this);
 diff -Naur a/src/vidalia/res/entrust-secure-server-root.crt b/src/vidalia/res/entrust-secure-server-root.crt
 --- a/src/vidalia/res/entrust-secure-server-root.crt	1970-01-01 00:00:00.000000000 +0000
-+++ b/src/vidalia/res/entrust-secure-server-root.crt	2009-02-20 06:33:56.000000000 +0000
++++ b/src/vidalia/res/entrust-secure-server-root.crt	2009-03-01 00:53:58.324690032 +0000
 @@ -0,0 +1,30 @@
 +-----BEGIN CERTIFICATE-----
 +MIIE2DCCBEGgAwIBAgIEN0rSQzANBgkqhkiG9w0BAQUFADCBwzELMAkGA1UE
@@ -768,7 +803,7 @@
 +-----END CERTIFICATE-----
 diff -Naur a/src/vidalia/res/gd-class2-root.crt b/src/vidalia/res/gd-class2-root.crt
 --- a/src/vidalia/res/gd-class2-root.crt	1970-01-01 00:00:00.000000000 +0000
-+++ b/src/vidalia/res/gd-class2-root.crt	2009-02-20 06:33:56.000000000 +0000
++++ b/src/vidalia/res/gd-class2-root.crt	2009-03-01 00:53:58.325689880 +0000
 @@ -0,0 +1,24 @@
 +-----BEGIN CERTIFICATE-----
 +MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEh
@@ -796,7 +831,7 @@
 +-----END CERTIFICATE-----
 diff -Naur a/src/vidalia/res/vidalia.qrc b/src/vidalia/res/vidalia.qrc
 --- a/src/vidalia/res/vidalia.qrc	2009-02-01 00:34:33.066938000 +0000
-+++ b/src/vidalia/res/vidalia.qrc	2009-02-20 06:33:56.000000000 +0000
++++ b/src/vidalia/res/vidalia.qrc	2009-03-01 00:53:58.325689880 +0000
 @@ -290,5 +290,7 @@
      </qresource>
      <qresource prefix="/geoip">
@@ -807,7 +842,7 @@
  </RCC>
 diff -Naur a/src/vidalia/updateprocess.cpp b/src/vidalia/updateprocess.cpp
 --- a/src/vidalia/updateprocess.cpp	2009-01-03 20:10:16.806554000 +0000
-+++ b/src/vidalia/updateprocess.cpp	2009-02-20 06:33:56.000000000 +0000
++++ b/src/vidalia/updateprocess.cpp	2009-03-01 00:53:58.326689728 +0000
 @@ -234,13 +234,23 @@
  QString
  UpdateProcess::updateExecutable()
@@ -833,3 +868,33 @@
  }
  
  QString
+diff -Naur a/src/vidalia/vidalia.cpp b/src/vidalia/vidalia.cpp
+--- a/src/vidalia/vidalia.cpp	2009-02-24 04:56:35.504853000 +0000
++++ b/src/vidalia/vidalia.cpp	2009-03-01 00:53:58.327689576 +0000
+@@ -89,6 +89,11 @@
+ Vidalia::Vidalia(QStringList args, int &argc, char **argv)
+ : QApplication(argc, argv)
+ {
++  QString programFiles = win32_program_files_folder() + "\\Vidalia";
++  QString plugins = dataDirectory() + "\\plugins";
++  QApplication::setLibraryPaths(QStringList(programFiles));
++  QApplication::addLibraryPath(plugins);
++
+   qInstallMsgHandler(qt_msg_handler);
+ 
+   /* Read in all our command-line arguments. */
+@@ -125,12 +130,8 @@
+ 
+ #ifdef USE_MARBLE
+   /* Tell Marble where to stash its generated data */
+-  Marble::MarbleDirs::setMarbleDataPath(dataDirectory());
+-
+-#ifdef Q_OS_WIN32
+-  Marble::MarbleDirs::setMarblePluginPath(vApp->applicationDirPath() 
+-                                            + "/plugins/marble");
+-#endif
++  Marble::MarbleDirs::setMarbleDataPath(plugins + "\\data");
++  Marble::MarbleDirs::setMarblePluginPath(plugins);
+ #endif
+ }
+