summaryrefslogtreecommitdiff
path: root/python/Python-2.6.2-cross.patch
blob: 58bf277fd7b36033dd65b5ed5c57a68ab19be958 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
--- misc/build/Python-2.6.1/configure.in	2009-03-30 19:56:14.000000000 +0200
+++ misc/build/Python-2.6.1/configure.in	2009-05-09 13:48:16.000000000 +0200
@@ -12,6 +12,11 @@
 AC_CONFIG_SRCDIR([Include/object.h])
 AC_CONFIG_HEADER(pyconfig.h)
 
+# find compiler while respecting --host setting
+AC_CANONICAL_HOST()
+AC_CHECK_TOOLS(CC,gcc cc)
+AC_CHECK_TOOLS(CXX,g++ c++)
+
 dnl This is for stuff that absolutely must end up in pyconfig.h.
 dnl Please use pyport.h instead, if possible.
 AH_TOP([
@@ -215,8 +220,8 @@
 # Set name for machine-dependent library files
 AC_SUBST(MACHDEP)
 AC_MSG_CHECKING(MACHDEP)
-if test -z "$MACHDEP"
-then
+if test -z "$MACHDEP"; then
+    if test "$cross_compiling" = "no"; 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
@@ -224,6 +229,24 @@
 	else
 		ac_sys_release=`uname -r`
 	fi
+    else
+	#m=`$CC -dumpmachine`
+ 	#changequote(<<, >>)#dnl
+	#ac_sys_system=`expr "$m" : "[^-]*-\([^-]*\)"`
+ 	#changequote([, ])#dnl
+	
+	m=`$CC -dumpmachine`
+	ac_sys_system=`echo $m | cut -d- -f3`
+
+	case $ac_sys_system in
+	cygwin*) ac_sys_system=`echo $ac_sys_system | sed s/cygwin/CYGWIN/g `;;
+	darwin*) ac_sys_system=`echo $ac_sys_system | sed s/darwin/Darwin/g `;;
+	linux*) ac_sys_system=`echo $ac_sys_system | sed s/linux/Linux/g `;;
+	esac
+	
+
+    fi
+    
 	ac_md_system=`echo $ac_sys_system |
 			   tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
 	ac_md_release=`echo $ac_sys_release |
@@ -232,6 +255,7 @@
 
 	case $MACHDEP in
 	cygwin*) MACHDEP="cygwin";;
+	mingw*) MACHDEP="mingw";;
 	darwin*) MACHDEP="darwin";;
 	atheos*) MACHDEP="atheos";;
         irix646) MACHDEP="irix6";;
@@ -363,7 +387,7 @@
 fi
 AC_MSG_RESULT($MACHDEP)
 
-# And add extra plat-mac for darwin
+# And add extra plat-mac for Darwin
 AC_SUBST(EXTRAPLATDIR)
 AC_SUBST(EXTRAMACHDEPPATH)
 AC_MSG_CHECKING(EXTRAPLATDIR)
@@ -382,6 +406,23 @@
 fi
 AC_MSG_RESULT($EXTRAPLATDIR)
 
+AC_MSG_CHECKING(posix flavour)
+if test -z "$POSIX"
+then
+	case $ac_sys_system/$ac_sys_release in
+	mingw*)
+		DELIM=';'
+		POSIX=nt
+		;;
+	*)
+		DELIM=':'
+		POSIX=posix
+ 		;;
+	esac
+ fi	
+AC_SUBST(DELIM)
+AC_MSG_RESULT($POSIX)
+
 # Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
 # it may influence the way we can build extensions, so distutils
 # needs to check it
@@ -546,9 +587,11 @@
 then
     AC_MSG_RESULT(yes)
     BUILDEXEEXT=.exe
+    case_sensitive=no
 else
-	AC_MSG_RESULT(no)
-	BUILDEXEEXT=$EXEEXT
+    AC_MSG_RESULT(no)
+    BUILDEXEEXT=$EXEEXT
+    case_sensitive=yes
 fi
 rmdir CaseSensitiveTestDir
 
@@ -645,7 +688,7 @@
 if test -z "$enable_shared"
 then 
   case $ac_sys_system in
-  CYGWIN* | atheos*)
+  CYGWIN* | atheos* | mingw*)
     enable_shared="yes";;
   *)
     enable_shared="no";;
@@ -700,6 +743,10 @@
           LDLIBRARY='libpython$(VERSION).dll.a'
           DLLLIBRARY='libpython$(VERSION).dll'
           ;;
+    mingw*)
+          LDLIBRARY='libpython$(VERSION).dll.a'
+          DLLLIBRARY='libpython$(VERSION).dll'
+          ;;
     SunOS*)
 	  LDLIBRARY='libpython$(VERSION).so'
 	  BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
@@ -752,14 +799,18 @@
           BLDLIBRARY='$(LIBRARY)'
           LDLIBRARY='libpython$(VERSION).dll.a'
           ;;
+    mingw*)
+          BLDLIBRARY='$(LIBRARY)'
+          LDLIBRARY='libpython$(VERSION).dll.a'
+          ;;
   esac
 fi
 
 AC_MSG_RESULT($LDLIBRARY)
 
-AC_PROG_RANLIB
-AC_SUBST(AR)
-AC_CHECK_PROGS(AR, ar aal, ar)
+# find tools while respecting --host setting
+AC_CHECK_TOOL(RANLIB,ranlib)
+AC_CHECK_TOOLS(AR,ar aal,ar)
 
 AC_SUBST(SVNVERSION)
 AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
@@ -965,6 +1016,9 @@
 	OSF*)
 	    BASECFLAGS="$BASECFLAGS -mieee"
 	    ;;
+	mingw*)
+	    OPT="-DMS_WINDOWS -DPy_WIN_WIDE_FILENAMES $OPT"
+	    ;;
     esac
     ;;
 
@@ -1013,7 +1067,7 @@
 if test $ac_cv_opt_olimit_ok = yes; then
     case $ac_sys_system in
 	# XXX is this branch needed? On MacOSX 10.2.2 the result of the
-	# olimit_ok test is "no".  Is it "yes" in some other Darwin-esque
+	# olimit_ok test is "no".  Is it "yes" in some other darwin-esque
 	# environment?
         Darwin*)
 	    ;;
@@ -1590,6 +1644,7 @@
 		esac
 		;;
 	CYGWIN*)   SO=.dll;;
+	mingw*)    SO=.dll;;
 	*)	   SO=.so;;
 	esac
 else
@@ -1713,6 +1768,8 @@
 	SCO_SV*) LDSHARED='$(CC) -Wl,-G,-Bexport';;
 	Monterey*) LDSHARED="cc -G -dy -Bdynamic -Bexport -L/usr/lib/ia64l64";;
 	CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
+	mingw*) LDSHARED='$(CC) -mdll'
+		BLDSHARED='$(CC) -mdll libpython$(VERSION).dll';;
 	atheos*) LDSHARED="gcc -shared";;
 	*)	LDSHARED="ld";;
 	esac
@@ -1805,6 +1862,11 @@
 		then
 			LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
 		fi;;
+	mingw*)
+ 		if test $enable_shared = "no"
+ 		then
+ 			LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
+ 		fi;;
 	QNX*)
 		# -Wl,-E causes the symbols to be added to the dynamic
 		# symbol table so that they can be found when a module
@@ -1882,6 +1944,16 @@
 # BeOS' sockets are stashed in libnet.
 AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
 AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
+AC_CHECK_HEADER(winsock2.h)
+AC_CHECK_LIB(wsock32, select, [LIBS="-lws2_32 -lwsock32 $LIBS"], [], $LIBS) # Mingw32 select
+save_LIBS="$LIBS"
+LIBS="-lws2_32 -lwsock32 $LIBS"
+AC_MSG_CHECKING([for include <winsock2.h> select in libwinsock32])
+AC_TRY_LINK([#include <winsock2.h>],
+            [select (1,2,3,4,5);],
+ 	    [AC_MSG_RESULT(yes)],
+	    [AC_MSG_RESULT(no)]
+	    [LIBS="$save_LIBS"])
 
 case "$ac_sys_system" in
 BeOS*)
@@ -2424,6 +2496,7 @@
 	# Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
 	Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
 	atheos*) DYNLOADFILE="dynload_atheos.o";;
+	mingw*) DYNLOADFILE="dynload_win.o";;
 	*)
 	# use dynload_shlib.c and dlopen() if we have it; otherwise stub
 	# out any dynamic loading
@@ -2568,7 +2641,7 @@
 # On Tru64, chflags seems to be present, but calling it will
 # exit Python
 AC_MSG_CHECKING(for chflags)
-AC_TRY_RUN([
+AC_TRY_COMPILE([
 #include <sys/stat.h>
 #include <unistd.h>
 int main(int argc, char*argv[])
@@ -2577,13 +2650,13 @@
     return 1;
   return 0;
 }
-],AC_DEFINE(HAVE_CHFLAGS, 1, Define to 1 if you have the `chflags' function.)
+],void* p=chflags, AC_DEFINE(HAVE_CHFLAGS, 1, Define to 1 if you have the `chflags' function.)
   AC_MSG_RESULT(yes),
   AC_MSG_RESULT(no)
 )
 
 AC_MSG_CHECKING(for lchflags)
-AC_TRY_RUN([
+AC_TRY_COMPILE([
 #include <sys/stat.h>
 #include <unistd.h>
 int main(int argc, char*argv[])
@@ -2592,7 +2665,7 @@
     return 1;
   return 0;
 }
-],AC_DEFINE(HAVE_LCHFLAGS, 1, Define to 1 if you have the `lchflags' function.)
+],void* p=lchflags, AC_DEFINE(HAVE_LCHFLAGS, 1, Define to 1 if you have the `lchflags' function.)
   AC_MSG_RESULT(yes),
   AC_MSG_RESULT(no)
 )
@@ -2722,6 +2795,8 @@
   )
 )
 
+AC_CHECK_FUNCS(cwait fsync pipe popen spawnv system)
+
 AC_MSG_CHECKING(for major, minor, and makedev)
 AC_TRY_LINK([
 #if defined(MAJOR_IN_MKDEV)
@@ -2871,7 +2946,7 @@
 AC_CHECK_MEMBERS([struct stat.st_flags])
 AC_CHECK_MEMBERS([struct stat.st_gen])
 AC_CHECK_MEMBERS([struct stat.st_birthtime])
-AC_STRUCT_ST_BLOCKS
+#AC_STRUCT_ST_BLOCKS
 
 AC_MSG_CHECKING(for time.h that defines altzone)
 AC_CACHE_VAL(ac_cv_header_time_altzone,
@@ -3657,7 +3732,8 @@
 fi
 
 AC_MSG_CHECKING(for %zd printf() format support)
-AC_TRY_RUN([#include <stdio.h>
+AC_CACHE_VAL(ac_cv_printf_zd_format,
+		    AC_TRY_RUN([#include <stdio.h>
 #include <stddef.h>
 #include <string.h>
 
@@ -3693,7 +3769,7 @@
 }],
 [AC_MSG_RESULT(yes)
  AC_DEFINE(PY_FORMAT_SIZE_T, "z", [Define to printf format modifier for Py_ssize_t])],
- AC_MSG_RESULT(no))
+ AC_MSG_RESULT(no)))
 
 AC_CHECK_TYPE(socklen_t,,
   AC_DEFINE(socklen_t,int,
@@ -3704,6 +3780,9 @@
 #ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
 #endif
+#ifdef _WIN32
+#include <ws2tcpip.h>
+#endif
 ])
 
 AC_SUBST(THREADHEADERS)
@@ -3723,6 +3802,67 @@
 done
 AC_MSG_RESULT(done)
 
+# Cross compiling
+AC_SUBST(cross_compiling)
+
+if test "$cross_compiling" = "yes"; then
+    AC_MSG_CHECKING(cc for build)
+    ## /usr/bin/cc still uses wrong assembler
+    ## CC_FOR_BUILD="${CC_FOR_BUILD-/usr/bin/cc}"
+    CC_FOR_BUILD="${CC_FOR_BUILD-PATH=/usr/bin:$PATH cc}"
+else
+    CC_FOR_BUILD="${CC_FOR_BUILD-$CC}"
+fi   
+     
+if test "$cross_compiling" = "yes"; then
+   AC_MSG_RESULT($CC_FOR_BUILD)
+fi
+
+AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler (default: cc)])
+	
+if test "$cross_compiling" = "yes"; then
+    AC_MSG_CHECKING(python for build)
+    PYTHON_FOR_BUILD="${PYTHON_FOR_BUILD-python}"
+else
+    PYTHON_FOR_BUILD='$(BUILDPYTHON)'
+fi   
+
+if test "$cross_compiling" = "yes"; then
+    AC_MSG_RESULT($PYTHON_FOR_BUILD)
+fi
+AC_ARG_VAR(PYTHON_FOR_BUILD,[build system python (default: python)])
+AC_SUBST(PYTHON_FOR_BUILD)
+  			
+if test "$cross_compiling" = "yes"; then
+    CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD-}
+    changequote(<<, >>)#dnl
+    python_include=`$PYTHON_FOR_BUILD -c 'import sys; sys.stdout.write ("%s/include/python%s" % (sys.prefix, sys.version[:3]))'`
+    changequote([, ])#dnl
+    CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-"-I$python_include"}
+    CROSS_COMMENT=#
+    if test "$case_sensitive" = "yes"
+    then
+        EXEEXT_FOR_BUILD=
+    else
+        EXEEXT_FOR_BUILD=.exe
+    fi
+    LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-}
+    LIBS_FOR_BUILD=${LIBS_FOR_BUILD-}
+    O_FOR_BUILD=x
+    RUNSHARED="CROSS_TARGET=$ac_sys_system SRCDIR=$srcdir SO=${SO}"
+else
+    CROSS_COMMENT=
+    EXEEXT_FOR_BUILD=$BUILDEXEEXT
+    O_FOR_BUILD=o
+fi
+AC_SUBST(CFLAGS_FOR_BUILD)
+AC_SUBST(CPPFLAGS_FOR_BUILD)
+AC_SUBST(CROSS_COMMENT)
+AC_SUBST(EXEEXT_FOR_BUILD)
+AC_SUBST(LDFLAGS_FOR_BUILD)
+AC_SUBST(LIBS_FOR_BUILD)
+AC_SUBST(O_FOR_BUILD)
+
 # generate output files
 AC_CONFIG_FILES(Makefile.pre Modules/Setup.config)
 AC_OUTPUT
@@ -3732,6 +3872,9 @@
 then
 	cp $srcdir/Modules/Setup.dist Modules/Setup
 fi
+mv Modules/Setup Modules/Setup~
+sed -e "s/@POSIX@/$POSIX/g" < Modules/Setup~ > Modules/Setup
+
 
 echo "creating Modules/Setup.local"
 if test ! -f Modules/Setup.local
--- misc/build/Python-2.6.1/Include/osdefs.h	2006-04-25 17:29:46.000000000 +0200
+++ misc/build/Python-2.6.1/Include/osdefs.h	2009-05-09 13:35:04.000000000 +0200
@@ -9,7 +9,7 @@
 
 /* Mod by chrish: QNX has WATCOM, but isn't DOS */
 #if !defined(__QNX__)
-#if defined(MS_WINDOWS) || defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__DJGPP__) || defined(PYOS_OS2)
+#if defined(MS_WINDOWS) || defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__DJGPP__) || defined(PYOS_OS2) || defined(__MINGW32__) 
 #if defined(PYOS_OS2) && defined(PYCC_GCC)
 #define MAXPATHLEN 260
 #define SEP '/'
@@ -18,6 +18,7 @@
 #define SEP '\\'
 #define ALTSEP '/'
 #define MAXPATHLEN 256
+#define ROOTSEP ':'
 #endif
 #define DELIM ';'
 #endif
--- misc/build/Python-2.6.1/Include/pyport.h	2009-01-14 01:00:17.000000000 +0100
+++ misc/build/Python-2.6.1/Include/pyport.h	2009-05-09 13:35:04.000000000 +0200
@@ -551,31 +551,31 @@
   BeOS and cygwin are the only other autoconf platform requiring special
   linkage handling and both of these use __declspec().
 */
-#if defined(__CYGWIN__) || defined(__BEOS__)
+#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BEOS__)
 #	define HAVE_DECLSPEC_DLL
 #endif
 
 /* only get special linkage if built as shared or platform is Cygwin */
-#if defined(Py_ENABLE_SHARED) || defined(__CYGWIN__)
+#if defined(Py_ENABLE_SHARED) || defined(__CYGWIN__) || defined(__MINGW32__)
 #	if defined(HAVE_DECLSPEC_DLL)
 #		ifdef Py_BUILD_CORE
 #			define PyAPI_FUNC(RTYPE) __declspec(dllexport) RTYPE
 #			define PyAPI_DATA(RTYPE) extern __declspec(dllexport) RTYPE
 			/* module init functions inside the core need no external linkage */
 			/* except for Cygwin to handle embedding (FIXME: BeOS too?) */
-#			if defined(__CYGWIN__)
+#			if defined(__CYGWIN__) || defined(__MINGW32__)
 #				define PyMODINIT_FUNC __declspec(dllexport) void
-#			else /* __CYGWIN__ */
+#			else /* __CYGWIN__ || __MINGW32__ */
 #				define PyMODINIT_FUNC void
-#			endif /* __CYGWIN__ */
+#			endif /* __CYGWIN__ || __MINGW32__ */
 #		else /* Py_BUILD_CORE */
 			/* 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__ */
+#			endif /* !__CYGWIN__ && ! __MINGW32__ */
 #			define PyAPI_DATA(RTYPE) extern __declspec(dllimport) RTYPE
 			/* module init functions outside the core must be exported */
 #			if defined(__cplusplus)
--- misc/build/Python-2.6.1/Lib/distutils/command/build_ext.py	2009-02-05 23:55:00.000000000 +0100
+++ misc/build/Python-2.6.1/Lib/distutils/command/build_ext.py	2009-05-09 13:35:04.000000000 +0200
@@ -679,6 +679,8 @@
             ext_path[len(ext_path) - 1] = ext_path[len(ext_path) - 1][:8]
         # extensions in debug_mode are named 'module_d.pyd' under windows
         so_ext = get_config_var('SO')
+        if os.environ.get('CROSS_COMPILING') == 'yes':
+            so_ext = os.environ.get('SO')
         if os.name == 'nt' and self.debug:
             return apply(os.path.join, ext_path) + '_d' + so_ext
         return os.path.join(*ext_path) + so_ext
@@ -731,7 +733,7 @@
             # don't extend ext.libraries, it may be shared with other
             # extensions, it is a reference to the original list
             return ext.libraries + [pythonlib]
-        elif sys.platform[:6] == "cygwin":
+        elif sys.platform[:6] == "cygwin" or sys.platform[:5] == "mingw":
             template = "python%d.%d"
             pythonlib = (template %
                    (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
--- misc/build/Python-2.6.1/Lib/plat-mingw/regen	1970-01-01 01:00:00.000000000 +0100
+++ misc/build/Python-2.6.1/Lib/plat-mingw/regen	2009-05-09 13:35:04.000000000 +0200
@@ -0,0 +1,3 @@
+#! /bin/sh
+set -v
+python$EXE ../../Tools/scripts/h2py.py -i '(u_long)' /usr/include/netinet/in.h
--- misc/build/Python-2.6.1/Lib/plat-mingw32msvc2/regen	1970-01-01 01:00:00.000000000 +0100
+++ misc/build/Python-2.6.1/Lib/plat-mingw32msvc2/regen	2009-05-09 13:35:04.000000000 +0200
@@ -0,0 +1,3 @@
+#! /bin/sh
+set -v
+python$EXE ../../Tools/scripts/h2py.py -i '(u_long)' /usr/include/netinet/in.h
--- misc/build/Python-2.6.1/Lib/plat-pc/regen	1970-01-01 01:00:00.000000000 +0100
+++ misc/build/Python-2.6.1/Lib/plat-pc/regen	2009-05-09 13:35:04.000000000 +0200
@@ -0,0 +1,3 @@
+#! /bin/sh
+set -v
+python$EXE ../../Tools/scripts/h2py.py -i '(u_long)' /usr/include/netinet/in.h
--- misc/build/Python-2.6.1/Lib/test/test_future5.py	2008-10-26 21:59:05.000000000 +0100
+++ misc/build/Python-2.6.1/Lib/test/test_future5.py	2009-05-09 14:42:22.000000000 +0200
@@ -13,7 +13,7 @@
 
     def test_print_function(self):
         with test_support.captured_output("stderr") as s:
-            print("foo", file=sys.stderr)
+            print >> sys.stderr, "foo"
         self.assertEqual(s.getvalue(), "foo\n")
 
 
--- misc/build/Python-2.6.1/Makefile.pre.in	2009-02-24 12:07:44.000000000 +0100
+++ misc/build/Python-2.6.1/Makefile.pre.in	2009-05-09 13:35:04.000000000 +0200
@@ -18,6 +18,8 @@
 #
 # See also the section "Build instructions" in the README file.
 
+DELIM=@DELIM@
+
 # === Variables set by makesetup ===
 
 MODOBJS=        _MODOBJS_
@@ -72,6 +74,16 @@
 # C flags used for building the interpreter object files
 PY_CFLAGS=	$(CFLAGS) $(CPPFLAGS) $(CFLAGSFORSHARED) -DPy_BUILD_CORE
 
+# For cross compile: build compiler options
+CC_FOR_BUILD=	@CC_FOR_BUILD@
+CROSS_COMPILING=	@cross_compiling@
+EXEEXT_FOR_BUILD=	@EXEEXT_FOR_BUILD@
+O_FOR_BUILD=	@O_FOR_BUILD@
+
+CFLAGS_FOR_BUILD=	@CFLAGS_FOR_BUILD@
+CPPFLAGS_FOR_BUILD=	@CPPFLAGS_FOR_BUILD@ -I$(srcdir)/Include
+LDFLAGS_FOR_BUILD=	@LDFLAGS_FOR_BUILD@
+LIBS_FOR_BUILD=	@LIBS_FOR_BUILD@
 
 # Machine-dependent subdirectories
 MACHDEP=	@MACHDEP@
@@ -106,6 +118,10 @@
 BLDSHARED=	@BLDSHARED@
 DESTSHARED=	$(BINLIBDEST)/lib-dynload
 
+comma=,
+BLDFLAGS=$(subst -Wl$(comma),,$(LDFLAGS))
+
+
 # Executable suffix (.exe on Windows and Mac OS X)
 EXE=		@EXEEXT@
 BUILDEXE=	@BUILDEXEEXT@
@@ -174,7 +190,8 @@
 UNICODE_OBJS=   @UNICODE_OBJS@
 
 PYTHON=		python$(EXE)
-BUILDPYTHON=	python$(BUILDEXE)
+BUILDPYTHON=	python$(EXE)
+PYTHON_FOR_BUILD=	@PYTHON_FOR_BUILD@
 
 # The task to run while instrument when building the profile-opt target
 PROFILE_TASK=	$(srcdir)/Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck
@@ -204,7 +221,7 @@
 
 ##########################################################################
 # Parser
-PGEN=		Parser/pgen$(EXE)
+PGEN_FOR_BUILD=	Parser/pgen$(EXEEXT_FOR_BUILD)
 
 POBJS=		\
 		Parser/acceler.o \
@@ -221,18 +238,28 @@
 
 PARSER_OBJS=	$(POBJS) Parser/myreadline.o Parser/tokenizer.o
 
-PGOBJS=		\
-		Objects/obmalloc.o \
-		Python/mysnprintf.o \
-		Parser/tokenizer_pgen.o \
-		Parser/printgrammar.o \
-		Parser/pgenmain.o
-
-PARSER_HEADERS= \
-		Parser/parser.h \
-		Parser/tokenizer.h
+POBJS_FOR_BUILD=		\
+ 		Parser/acceler.$(O_FOR_BUILD) \
+ 		Parser/grammar1.$(O_FOR_BUILD) \
+ 		Parser/listnode.$(O_FOR_BUILD) \
+ 		Parser/node.$(O_FOR_BUILD) \
+ 		Parser/parser.$(O_FOR_BUILD) \
+ 		Parser/parsetok.$(O_FOR_BUILD) \
+ 		Parser/bitset.$(O_FOR_BUILD) \
+ 		Parser/metagrammar.$(O_FOR_BUILD) \
+ 		Parser/firstsets.$(O_FOR_BUILD) \
+ 		Parser/grammar.$(O_FOR_BUILD) \
+ 		Parser/pgen.$(O_FOR_BUILD)
+ 
+PGOBJS_FOR_BUILD=		\
+ 		Objects/obmalloc.$(O_FOR_BUILD) \
+ 		Python/mysnprintf.$(O_FOR_BUILD) \
+ 		Parser/tokenizer_pgen.$(O_FOR_BUILD) \
+ 		Parser/printgrammar.$(O_FOR_BUILD) \
+ 		Parser/pgenmain.$(O_FOR_BUILD)
+  
+PGENOBJS=	$(POBJS_FOR_BUILD) $(PGOBJS_FOR_BUILD)
 
-PGENOBJS=	$(PGENMAIN) $(POBJS) $(PGOBJS)
 
 ##########################################################################
 # AST
@@ -387,16 +414,15 @@
 			Modules/python.o \
 			$(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
 
-platform: $(BUILDPYTHON)
-	$(RUNSHARED) ./$(BUILDPYTHON) -E -c 'import sys ; from distutils.util import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform
-
+platform: @CROSS_COMMENT@ $(BUILDPYTHON)
+	  $(RUNSHARED) $(PYTHON_FOR_BUILD) -E -c 'import sys ; from distutils.util import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform
 
 # Build the shared modules
-sharedmods: $(BUILDPYTHON)
-	@case $$MAKEFLAGS in \
-	*s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \
-	*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \
-	esac
+sharedmods: @CROSS_COMMENT@ $(BUILDPYTHON)
+	case $$MAKEFLAGS in \
+	*-s*) $(RUNSHARED) CC='$(CC)' LDFLAGS="$(BLDFLAGS)" CROSS_COMPILING='$(CROSS_COMPILING)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' $(PYTHON_FOR_BUILD) -E $(srcdir)/setup.py -q build;; \
+	*) $(RUNSHARED) CC='$(CC)' LDFLAGS="$(BLDFLAGS)" CROSS_COMPILING='$(CROSS_COMPILING)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' $(PYTHON_FOR_BUILD) -E $(srcdir)/setup.py build;; \
+	esac
 
 # Build static library
 # avoid long command lines, same as LIBRARY_OBJS
@@ -515,12 +541,13 @@
 	$(MAINCC) -c $(PY_CFLAGS) -o $@ $(srcdir)/Modules/python.c
 
 
-$(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT)
+$(GRAMMAR_H) $(GRAMMAR_C): $(PGEN_FOR_BUILD) $(GRAMMAR_INPUT)
 		-@$(INSTALL) -d Include
-		-$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
+		-$(PGEN_FOR_BUILD) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
+
+$(PGEN_FOR_BUILD): $(PGENOBJS)
+		$(CC_FOR_BUILD) $(OPT) $(LDFLAGS_FOR_BUILD) $(PGENOBJS) $(LIBS_FOR_BUILD) -o $(PGEN_FOR_BUILD)
 
-$(PGEN):	$(PGENOBJS)
-		$(CC) $(OPT) $(LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN)
 
 Parser/grammar.o:	$(srcdir)/Parser/grammar.c \
 				$(srcdir)/Include/token.h \
@@ -578,6 +605,13 @@
 				$(STRINGLIB_HEADERS)
 
 ############################################################################
+# Cross compile rules
+
+.SUFFIXES: .x
+.c.x:
+	$(CC_FOR_BUILD) -c $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) -o $@ $<
+				
+############################################################################
 # Header files
 
 PYTHON_HEADERS= \
@@ -676,7 +710,7 @@
 
 TESTOPTS=	-l $(EXTRATESTOPTS)
 TESTPROG=	$(srcdir)/Lib/test/regrtest.py
-TESTPYTHON=	$(RUNSHARED) ./$(BUILDPYTHON) -E -tt
+TESTPYTHON=	$(RUNSHARED) $(PYTHON_FOR_BUILD) -E -tt
 test:		all platform
 		-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
 		-$(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
@@ -830,7 +864,7 @@
 		multiprocessing multiprocessing/dummy \
 		lib-old \
 		curses $(MACHDEPS)
-libinstall:	build_all $(srcdir)/Lib/$(PLATDIR)
+libinstall: 	$(srcdir)/Lib/$(PLATDIR) @CROSS_COMMENT@ $(BUILDPYTHON)
 	@for i in $(SCRIPTDIR) $(LIBDEST); \
 	do \
 		if test ! -d $(DESTDIR)$$i; then \
@@ -887,19 +921,19 @@
 	done
 	$(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
 	PYTHONPATH=$(DESTDIR)$(LIBDEST)  $(RUNSHARED) \
-		./$(BUILDPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
+		$(PYTHON_FOR_BUILD) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
 		-d $(LIBDEST) -f \
 		-x 'bad_coding|badsyntax|site-packages' $(DESTDIR)$(LIBDEST)
 	PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
-		./$(BUILDPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
+		$(PYTHON_FOR_BUILD) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
 		-d $(LIBDEST) -f \
 		-x 'bad_coding|badsyntax|site-packages' $(DESTDIR)$(LIBDEST)
 	-PYTHONPATH=$(DESTDIR)$(LIBDEST)  $(RUNSHARED) \
-		./$(BUILDPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
+		$(PYTHON_FOR_BUILD) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
 		-d $(LIBDEST)/site-packages -f \
 		-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
 	-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
-		./$(BUILDPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
+		$(PYTHON_FOR_BUILD) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
 		-d $(LIBDEST)/site-packages -f \
 		-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
 	-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
@@ -909,9 +943,9 @@
 $(srcdir)/Lib/$(PLATDIR):
 	mkdir $(srcdir)/Lib/$(PLATDIR)
 	cp $(srcdir)/Lib/plat-generic/regen $(srcdir)/Lib/$(PLATDIR)/regen
-	export PATH; PATH="`pwd`:$$PATH"; \
-	export PYTHONPATH; PYTHONPATH="`pwd`/Lib"; \
-	export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \
+@CROSS_COMMENT@	export PATH; PATH="`pwd`:$$PATH"; \
+@CROSS_COMMENT@	export PYTHONPATH; PYTHONPATH="`pwd`/Lib"; \
+@CROSS_COMMENT@	export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \
 	export EXE; EXE="$(BUILDEXE)"; \
 	cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen
 
@@ -1001,8 +1035,9 @@
 # Install the dynamically loadable modules
 # This goes into $(exec_prefix)
 sharedinstall:
-	$(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \
-	   	--prefix=$(prefix) \
+	CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' CROSS_COMPILING='$(CROSS_COMPILING)' \
+		$(RUNSHARED) $(PYTHON_FOR_BUILD) -E $(srcdir)/setup.py install \
+		--prefix=$(prefix) \
 		--install-scripts=$(BINDIR) \
 		--install-platlib=$(DESTSHARED) \
 		--root=/$(DESTDIR)
@@ -1081,7 +1116,7 @@
 # This installs a few of the useful scripts in Tools/scripts
 scriptsinstall:
 	SRCDIR=$(srcdir) $(RUNSHARED) \
-	./$(BUILDPYTHON) $(srcdir)/Tools/scripts/setup.py install \
+	$(PYTHON_FOR_BUILD) $(srcdir)/Tools/scripts/setup.py install \
 	--prefix=$(prefix) \
 	--install-scripts=$(BINDIR) \
 	--root=/$(DESTDIR)
@@ -1145,11 +1180,12 @@
 	find . -name '*.gc??' -exec rm -f {} ';'
 
 clobber: clean profile-removal
-	-rm -f $(BUILDPYTHON) $(PGEN) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \
+	-rm -f $(BUILDPYTHON) $(PGEN_FOR_BUILD) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \
 		tags TAGS \
 		config.cache config.log pyconfig.h Modules/config.c
 	-rm -rf build platform
 	-rm -rf $(PYTHONFRAMEWORKDIR)
+	-rm -rf buildpython
 
 # Make things extra clean, before making a distribution:
 # remove all generated files, even Makefile[.pre]
--- misc/build/Python-2.6.1/Modules/datetimemodule.c	2008-06-11 09:41:16.000000000 +0200
+++ misc/build/Python-2.6.1/Modules/datetimemodule.c	2009-05-11 23:36:02.000000000 +0200
@@ -10,6 +10,10 @@
 
 #include <time.h>
 
+#ifdef MS_WINDOWS
+#include <winsock2.h>
+#endif
+
 #include "timefuncs.h"
 
 /* Differentiate between building the core module and building extension
--- misc/build/Python-2.6.1/Modules/dl_nt.c	1970-01-01 01:00:00.000000000 +0100
+++ misc/build/Python-2.6.1/Modules/dl_nt.c	2009-05-09 13:35:04.000000000 +0200
@@ -0,0 +1,39 @@
+/*
+
+Entry point for the Windows NT DLL.
+
+About the only reason for having this, is so initall() can automatically
+be called, removing that burden (and possible source of frustration if 
+forgotten) from the programmer.
+
+*/
+#include "windows.h"
+
+/* NT and Python share these */
+#include "pyconfig.h"
+#include "Python.h"
+
+char dllVersionBuffer[16] = ""; // a private buffer
+
+// Python Globals
+HMODULE PyWin_DLLhModule = NULL;
+const char *PyWin_DLLVersionString = dllVersionBuffer;
+
+
+BOOL	WINAPI	DllMain (HANDLE hInst, 
+						ULONG ul_reason_for_call,
+						LPVOID lpReserved)
+{
+	switch (ul_reason_for_call)
+	{
+		case DLL_PROCESS_ATTACH:
+			PyWin_DLLhModule = hInst;
+			// 1000 is a magic number I picked out of the air.  Could do with a #define, I spose...
+			LoadString(hInst, 1000, dllVersionBuffer, sizeof(dllVersionBuffer));
+			//initall();
+			break;
+		case DLL_PROCESS_DETACH:
+			break;
+	}
+	return TRUE;
+}
--- misc/build/Python-2.6.1/Modules/getpath.c	2007-03-10 08:38:14.000000000 +0100
+++ misc/build/Python-2.6.1/Modules/getpath.c	2009-05-09 13:35:04.000000000 +0200
@@ -125,6 +125,14 @@
 #define LANDMARK "os.py"
 #endif
 
+#ifndef __MINGW32__
+#define IS_ABSOLUTE(x) (x[0] == SEP)
+#else /* __MINGW32__ */
+#define IS_ABSOLUTE(x) (x[0] == SEP || x[0] == ALTSEP\
+			|| (x[1] && x[1] == ROOTSEP\
+			    && x[2] && (x[2] == SEP || x[2] == ALTSEP)))
+#endif /* __MINGW32__ */
+
 static char prefix[MAXPATHLEN+1];
 static char exec_prefix[MAXPATHLEN+1];
 static char progpath[MAXPATHLEN+1];
@@ -135,7 +143,12 @@
 reduce(char *dir)
 {
     size_t i = strlen(dir);
-    while (i > 0 && dir[i] != SEP)
+    while (i > 0
+	   && dir[i] != SEP
+#ifdef ALTSEP
+	   && dir[i] != ALTSEP
+#endif /* ALTSEP */
+	   )
         --i;
     dir[i] = '\0';
 }
@@ -208,11 +221,16 @@
 joinpath(char *buffer, char *stuff)
 {
     size_t n, k;
-    if (stuff[0] == SEP)
+    if (IS_ABSOLUTE(stuff))
         n = 0;
     else {
         n = strlen(buffer);
-        if (n > 0 && buffer[n-1] != SEP && n < MAXPATHLEN)
+        if (n > 0
+	    && buffer[n-1] != SEP
+#ifdef ALTSEP
+	    && buffer[n-1] != ALTSEP
+#endif /* ALTSEP */
+	    && n < MAXPATHLEN)
             buffer[n++] = SEP;
     }
     if (n > MAXPATHLEN)
@@ -229,11 +247,16 @@
 static void
 copy_absolute(char *path, char *p)
 {
-    if (p[0] == SEP)
+    if (IS_ABSOLUTE(p))
         strcpy(path, p);
     else {
         getcwd(path, MAXPATHLEN);
-        if (p[0] == '.' && p[1] == SEP)
+        if (p[0] == '.'
+	    && (p[1] == SEP
+#ifdef ALTSEP
+		|| p[1] == ALTSEP
+#endif /* ALTSEP */
+		))
             p += 2;
         joinpath(path, p);
     }
@@ -245,7 +268,7 @@
 {
     char buffer[MAXPATHLEN + 1];
 
-    if (path[0] == SEP)
+    if (IS_ABSOLUTE(path))
         return;
     copy_absolute(buffer, path);
     strcpy(path, buffer);
@@ -393,13 +416,23 @@
 #endif
 #endif
 
-	/* If there is no slash in the argv0 path, then we have to
-	 * assume python is on the user's $PATH, since there's no
-	 * other way to find a directory to start the search from.  If
-	 * $PATH isn't exported, you lose.
-	 */
-	if (strchr(prog, SEP))
-		strncpy(progpath, prog, MAXPATHLEN);
+    /* If PROG is an absolute name, then we're done.  If PROG is not
+     * an absolute name and contains SEP/ALTSEP, then it must be
+     * reachable from CWD.  Otherwise, python is on the user's $PATH,
+     * since there's no other way to find a directory to start the
+     * search from.  If $PATH isn't exported, you lose.
+     */
+    if (IS_ABSOLUTE(prog))
+    	strncpy(progpath, prog, MAXPATHLEN);
+    else if (strchr(prog, SEP)
+#ifdef ALTSEP
+	     || strchr(prog, ALTSEP)
+#endif /* ALTSEP */
+	     )
+      {
+    	getcwd(progpath, MAXPATHLEN);
+	joinpath(progpath, prog);
+      }
 #ifdef __APPLE__
      /* On Mac OS X, if a script uses an interpreter of the form
       * "#!/opt/python2.3/bin/python", the kernel only passes "python"
@@ -415,6 +448,9 @@
        ;
 #endif /* __APPLE__ */
 	else if (path) {
+#ifdef __MINGW32__
+		char const *ext = strchr(prog, '.') ? "" : ".exe";
+#endif
 		while (1) {
 			char *delim = strchr(path, DELIM);
 
@@ -429,9 +465,11 @@
 				strncpy(progpath, path, MAXPATHLEN);
 
 			joinpath(progpath, prog);
+#ifdef __MINGW32__
+			strcat(progpath, ext);
+#endif
 			if (isxfile(progpath))
 				break;
-
 			if (!delim) {
 				progpath[0] = '\0';
 				break;
@@ -441,7 +479,7 @@
 	}
 	else
 		progpath[0] = '\0';
-	if (progpath[0] != SEP)
+	if (!IS_ABSOLUTE(progpath))
 		absolutize(progpath);
 	strncpy(argv0_path, progpath, MAXPATHLEN);
 	argv0_path[MAXPATHLEN] = '\0';
@@ -487,7 +525,7 @@
         while (linklen != -1) {
             /* It's not null terminated! */
             tmpbuffer[linklen] = '\0';
-            if (tmpbuffer[0] == SEP)
+            if (IS_ABSOLUTE(tmpbuffer))
                 /* tmpbuffer should never be longer than MAXPATHLEN,
                    but extra check does not hurt */
                 strncpy(argv0_path, tmpbuffer, MAXPATHLEN);
@@ -554,7 +592,7 @@
     while (1) {
         char *delim = strchr(defpath, DELIM);
 
-        if (defpath[0] != SEP)
+        if (!IS_ABSOLUTE(defpath))
             /* Paths are relative to prefix */
             bufsz += prefixsz;
 
@@ -599,7 +637,7 @@
         while (1) {
             char *delim = strchr(defpath, DELIM);
 
-            if (defpath[0] != SEP) {
+            if (!IS_ABSOLUTE(defpath)) {
                 strcat(buf, prefix);
                 strcat(buf, separator);
             }
--- misc/build/Python-2.6.1/Modules/Makefile	1970-01-01 01:00:00.000000000 +0100
+++ misc/build/Python-2.6.1/Modules/Makefile	2009-05-11 22:34:01.000000000 +0200
@@ -0,0 +1,15 @@
+
+# Rules appended by makedepend
+
+./posixmodule.o: $(srcdir)/./posixmodule.c; $(CC) $(PY_CFLAGS)  -c $(srcdir)/./posixmodule.c -o ./posixmodule.o
+./ntmodule$(SO):  ./posixmodule.o; $(BLDSHARED)  ./posixmodule.o   -o ./ntmodule$(SO)
+./_sre.o: $(srcdir)/./_sre.c; $(CC) $(PY_CFLAGS)  -c $(srcdir)/./_sre.c -o ./_sre.o
+./_sre$(SO):  ./_sre.o; $(BLDSHARED)  ./_sre.o   -o ./_sre$(SO)
+./_codecsmodule.o: $(srcdir)/./_codecsmodule.c; $(CC) $(PY_CFLAGS)  -c $(srcdir)/./_codecsmodule.c -o ./_codecsmodule.o
+./_codecsmodule$(SO):  ./_codecsmodule.o; $(BLDSHARED)  ./_codecsmodule.o   -o ./_codecsmodule$(SO)
+./zipimport.o: $(srcdir)/./zipimport.c; $(CC) $(PY_CFLAGS)  -c $(srcdir)/./zipimport.c -o ./zipimport.o
+./zipimport$(SO):  ./zipimport.o; $(BLDSHARED)  ./zipimport.o   -o ./zipimport$(SO)
+./symtablemodule.o: $(srcdir)/./symtablemodule.c; $(CC) $(PY_CFLAGS)  -c $(srcdir)/./symtablemodule.c -o ./symtablemodule.o
+./_symtablemodule$(SO):  ./symtablemodule.o; $(BLDSHARED)  ./symtablemodule.o   -o ./_symtablemodule$(SO)
+./xxsubtype.o: $(srcdir)/./xxsubtype.c; $(CC) $(PY_CFLAGS)  -c $(srcdir)/./xxsubtype.c -o ./xxsubtype.o
+./xxsubtype$(SO):  ./xxsubtype.o; $(BLDSHARED)  ./xxsubtype.o   -o ./xxsubtype$(SO)
--- misc/build/Python-2.6.1/Modules/posixmodule.c	2009-04-06 08:47:37.000000000 +0200
+++ misc/build/Python-2.6.1/Modules/posixmodule.c	2009-05-09 13:35:04.000000000 +0200
@@ -96,6 +96,11 @@
 #include <sys/loadavg.h>
 #endif
 
+/* Additional defines for the mingw32 build */
+#if defined(__MINGW32__)
+#undef HAVE_DEV_PTMX
+#endif
+
 /* Various compilers have only certain posix functions */
 /* XXX Gosh I wish these were all moved into pyconfig.h */
 #if defined(PYCC_VACPP) && defined(PYOS_OS2)
@@ -131,6 +136,10 @@
 #define HAVE_FSYNC	1
 #define fsync _commit
 #else
+#ifdef __MINGW32__             /* MINGW32 (cross-)compiler*/
+#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 */
 #else			/* all other compilers */
@@ -156,12 +165,13 @@
 #define HAVE_WAIT       1
 #define HAVE_TTYNAME	1
 #endif  /* PYOS_OS2 && PYCC_GCC && __VMS */
+#endif  /* __MINGW32__ */
 #endif  /* _MSC_VER */
 #endif  /* __BORLANDC__ */
 #endif  /* ! __WATCOMC__ || __QNX__ */
 #endif /* ! __IBMC__ */
 
-#ifndef _MSC_VER
+#if !defined(_MSC_VER) && !defined(__MINGW32__)
 
 #if defined(__sgi)&&_COMPILER_VERSION>=700
 /* declare ctermid_r if compiling with MIPSPro 7.x in ANSI C mode
@@ -173,7 +183,7 @@
 #if defined(PYCC_VACPP)
 extern int mkdir(char *);
 #else
-#if ( defined(__WATCOMC__) || defined(_MSC_VER) ) && !defined(__QNX__)
+#if ( defined(__WATCOMC__) || defined(_MSC_VER) || defined(__MINGW32__)) && !defined(__QNX__)
 extern int mkdir(const char *);
 #else
 extern int mkdir(const char *, mode_t);
@@ -213,7 +223,7 @@
 #endif /* HAVE_LSTAT */
 #endif /* !HAVE_UNISTD_H */
 
-#endif /* !_MSC_VER */
+#endif /* !_MSC_VER && !__MINGW32__ */
 
 #ifdef HAVE_UTIME_H
 #include <utime.h>
@@ -258,7 +268,7 @@
 #endif
 #endif
 
-#ifdef _MSC_VER
+#if defined (_MSC_VER) || defined (__MINGW32__)
 #ifdef HAVE_DIRECT_H
 #include <direct.h>
 #endif
@@ -273,7 +283,7 @@
 #include <shellapi.h>	/* for ShellExecute() */
 #define popen	_popen
 #define pclose	_pclose
-#endif /* _MSC_VER */
+#endif /* _MSC_VER || __MINGW32__ */
 
 #if defined(PYCC_VACPP) && defined(PYOS_OS2)
 #include <io.h>
@@ -322,7 +332,7 @@
 
 /* choose the appropriate stat and fstat functions and return structs */
 #undef STAT
-#if defined(MS_WIN64) || defined(MS_WINDOWS)
+#if defined(MS_WIN64) || defined(MS_WINDOWS) || defined(__MINGW32__)
 #	define STAT win32_stat
 #	define FSTAT win32_fstat
 #	define STRUCT_STAT struct win32_stat
@@ -350,9 +360,9 @@
 */
 #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 */
+#endif /* !_MSC_VER && ! __MINGW32__ */
 
 static PyObject *
 convertenviron(void)
@@ -446,7 +456,7 @@
 	return rc;
 }
 
-#ifdef MS_WINDOWS
+#if defined (MS_WINDOWS)  || defined (__MINGW32__)
 static PyObject *
 win32_error(char* function, char* filename)
 {
@@ -749,7 +759,7 @@
 }
 #endif
 
-#ifdef MS_WINDOWS
+#if defined(MS_WINDOWS) || defined(__MINGW32__)
 /* The CRT of Windows has a number of flaws wrt. its stat() implementation:
    - time stamps are restricted to second resolution
    - file modification times suffer from forth-and-back conversions between
@@ -1074,7 +1084,7 @@
 	return 0;
 }
 
-#endif /* MS_WINDOWS */
+#endif /* MS_WINDOWS and __MINGW32__ */
 
 PyDoc_STRVAR(stat_result__doc__,
 "stat_result: Result from stat or lstat.\n\n\
@@ -1286,7 +1296,7 @@
 #else
         PyStructSequence_SET_ITEM(v, 1, PyInt_FromLong((long)st->st_ino));
 #endif
-#if defined(HAVE_LONG_LONG) && !defined(MS_WINDOWS)
+#if defined(HAVE_LONG_LONG) && !defined(MS_WINDOWS) && !defined(__MINGW32__)
         PyStructSequence_SET_ITEM(v, 2,
 				  PyLong_FromLongLong((PY_LONG_LONG)st->st_dev));
 #else
@@ -1369,7 +1379,7 @@
 	return v;
 }
 
-#ifdef MS_WINDOWS
+#if defined(MS_WINDOWS) || defined(__MINGW32__)
 
 /* IsUNCRoot -- test whether the supplied path is of the form \\SERVER\SHARE\,
    where / can be used in place of \ and the trailing slash is optional.
@@ -1429,7 +1439,7 @@
 	#undef ISSLASH
 }
 #endif /* Py_WIN_WIDE_FILENAMES */
-#endif /* MS_WINDOWS */
+#endif /* MS_WINDOWS and __MINGW32__ */
 
 static PyObject *
 posix_do_stat(PyObject *self, PyObject *args,
@@ -1482,7 +1492,7 @@
 	Py_END_ALLOW_THREADS
 
 	if (res != 0) {
-#ifdef MS_WINDOWS
+#if defined(MS_WINDOWS) || defined(__MINGW32__)
 		result = win32_error("stat", pathfree);
 #else
 		result = posix_error_with_filename(pathfree);
@@ -1630,7 +1640,7 @@
 static PyObject *
 posix_chdir(PyObject *self, PyObject *args)
 {
-#ifdef MS_WINDOWS
+#if defined(MS_WINDOWS) || defined(__MINGW32__)
 	return win32_1str(args, "chdir", "s:chdir", win32_chdir, "U:chdir", win32_wchdir);
 #elif defined(PYOS_OS2) && defined(PYCC_GCC)
 	return posix_1str(args, "et:chdir", _chdir2);
@@ -2073,7 +2083,7 @@
 {
 	/* XXX Should redo this putting the (now four) versions of opendir
 	   in separate files instead of having them all here... */
-#if defined(MS_WINDOWS) && !defined(HAVE_OPENDIR)
+#if (defined(MS_WINDOWS) || defined(__MINGW32__)) && !defined(HAVE_OPENDIR)
 
 	PyObject *d, *v;
 	HANDLE hFindFile;
@@ -2378,7 +2388,7 @@
 #endif /* which OS */
 }  /* end of posix_listdir */
 
-#ifdef MS_WINDOWS
+#if defined(MS_WINDOWS) || defined(__MINGW32__)
 /* A helper function for abspath on win32 */
 static PyObject *
 posix__getfullpathname(PyObject *self, PyObject *args)
@@ -2433,7 +2443,7 @@
 	}
 	return PyString_FromString(outbuf);
 } /* end of posix__getfullpathname */
-#endif /* MS_WINDOWS */
+#endif /* MS_WINDOWS and __MINGW32__ */
 
 PyDoc_STRVAR(posix_mkdir__doc__,
 "mkdir(path [, mode=0777])\n\n\
@@ -2486,7 +2496,7 @@
 	                      Py_FileSystemDefaultEncoding, &path, &mode))
 		return NULL;
 	Py_BEGIN_ALLOW_THREADS
-#if ( defined(__WATCOMC__) || defined(PYCC_VACPP) ) && !defined(__QNX__)
+#if ( defined(__WATCOMC__) || defined(PYCC_VACPP)) && !defined(__QNX__)
 	res = mkdir(path);
 #else
 	res = mkdir(path, mode);
@@ -2550,7 +2560,7 @@
 static PyObject *
 posix_rename(PyObject *self, PyObject *args)
 {
-#ifdef MS_WINDOWS
+#if defined(MS_WINDOWS) || defined(__MINGW32__)
 	PyObject *o1, *o2;
 	char *p1, *p2;
 	BOOL result;
@@ -2598,7 +2608,7 @@
 static PyObject *
 posix_rmdir(PyObject *self, PyObject *args)
 {
-#ifdef MS_WINDOWS
+#if defined(MS_WINDOWS) || defined(__MINGW32__)
 	return win32_1str(args, "rmdir", "s:rmdir", RemoveDirectoryA, "U:rmdir", RemoveDirectoryW);
 #else
 	return posix_1str(args, "et:rmdir", rmdir);
@@ -2613,7 +2623,7 @@
 static PyObject *
 posix_stat(PyObject *self, PyObject *args)
 {
-#ifdef MS_WINDOWS
+#if defined(MS_WINDOWS) || defined(__MINGW32__)
 	return posix_do_stat(self, args, "et:stat", STAT, "U:stat", win32_wstat);
 #else
 	return posix_do_stat(self, args, "et:stat", STAT, NULL, NULL);
@@ -2669,7 +2679,7 @@
 static PyObject *
 posix_unlink(PyObject *self, PyObject *args)
 {
-#ifdef MS_WINDOWS
+#if defined(MS_WINDOWS) || defined(__MINGW32__)
 	return win32_1str(args, "remove", "s:remove", DeleteFileA, "U:remove", DeleteFileW);
 #else
 	return posix_1str(args, "et:remove", unlink);
@@ -4720,7 +4730,7 @@
 
 #endif /* PYCC_??? */
 
-#elif defined(MS_WINDOWS)
+#elif defined(MS_WINDOWS) || defined(__MINGW32__)
 
 /*
  * Portable 'popen' replacement for Win32.
@@ -5913,7 +5923,7 @@
 #ifdef HAVE_LSTAT
 	return posix_do_stat(self, args, "et:lstat", lstat, NULL, NULL);
 #else /* !HAVE_LSTAT */
-#ifdef MS_WINDOWS
+#if defined(MS_WINDOWS) || defined(__MINGW32__)
 	return posix_do_stat(self, args, "et:lstat", STAT, "U:lstat", win32_wstat);
 #else
 	return posix_do_stat(self, args, "et:lstat", STAT, NULL, NULL);
@@ -6046,7 +6056,7 @@
 #endif /* HAVE_TIMES */
 
 
-#ifdef MS_WINDOWS
+#if defined(MS_WINDOWS) || defined(__MINGW32__)
 #define HAVE_TIMES	/* so the method table will pick it up */
 static PyObject *
 posix_times(PyObject *self, PyObject *noargs)
@@ -6070,7 +6080,7 @@
 		(double)0,
 		(double)0);
 }
-#endif /* MS_WINDOWS */
+#endif /* MS_WINDOWS and __MINGW32__ */
 
 #ifdef HAVE_TIMES
 PyDoc_STRVAR(posix_times__doc__,
@@ -6186,7 +6196,7 @@
 	int mode = 0777;
 	int fd;
 
-#ifdef MS_WINDOWS
+#if defined(MS_WINDOWS) || defined(__MINGW32__)
 	if (unicode_file_names()) {
 		PyUnicodeObject *po;
 		if (PyArg_ParseTuple(args, "Ui|i:mkdir", &po, &flag, &mode)) {
@@ -6305,7 +6315,7 @@
 posix_lseek(PyObject *self, PyObject *args)
 {
 	int fd, how;
-#if defined(MS_WIN64) || defined(MS_WINDOWS)
+#if defined(MS_WIN64) || defined(MS_WINDOWS) || defined(__MINGW32__)
 	PY_LONG_LONG pos, res;
 #else
 	off_t pos, res;
@@ -6332,7 +6342,7 @@
 		return NULL;
 
 	Py_BEGIN_ALLOW_THREADS
-#if defined(MS_WIN64) || defined(MS_WINDOWS)
+#if defined(MS_WIN64) || defined(MS_WINDOWS) || defined(__MINGW32__)
 	res = _lseeki64(fd, pos, how);
 #else
 	res = lseek(fd, pos, how);
@@ -6348,7 +6358,6 @@
 #endif
 }
 
-
 PyDoc_STRVAR(posix_read__doc__,
 "read(fd, buffersize) -> string\n\n\
 Read a file descriptor.");
@@ -6423,7 +6432,7 @@
 	res = FSTAT(fd, &st);
 	Py_END_ALLOW_THREADS
 	if (res != 0) {
-#ifdef MS_WINDOWS
+#if defined(MS_WINDOWS) || defined(__MINGW32__)
 		return win32_error("fstat", NULL);
 #else
 		return posix_error();
@@ -6462,7 +6471,7 @@
 		return NULL;
 	}
 	Py_BEGIN_ALLOW_THREADS
-#if !defined(MS_WINDOWS) && defined(HAVE_FCNTL_H)
+#if !defined(MS_WINDOWS) || !defined(__MINGW32__) && defined(HAVE_FCNTL_H)
 	if (mode[0] == 'a') {
 		/* try to make sure the O_APPEND flag is set */
 		int flags;
@@ -6523,7 +6532,7 @@
 
     return Py_BuildValue("(ii)", read, write);
 #else
-#if !defined(MS_WINDOWS)
+#if !defined(MS_WINDOWS) || !defined(__MINGW32__)
 	int fds[2];
 	int res;
 	Py_BEGIN_ALLOW_THREADS
@@ -6532,7 +6541,7 @@
 	if (res != 0)
 		return posix_error();
 	return Py_BuildValue("(ii)", fds[0], fds[1]);
-#else /* MS_WINDOWS */
+#else /* MS_WINDOWS and __MINGW32__ */
 	HANDLE read, write;
 	int read_fd, write_fd;
 	BOOL ok;
@@ -7078,7 +7087,7 @@
 		  "tempnam is a potential security risk to your program") < 0)
 	    return NULL;
 
-#ifdef MS_WINDOWS
+#if defined(MS_WINDOWS) || defined(__MINGW32__) 
     name = _tempnam(dir, pfx);
 #else
     name = tempnam(dir, pfx);
@@ -8137,7 +8146,7 @@
     return NULL;
 }
 
-#ifdef MS_WINDOWS
+#if defined(MS_WINDOWS) || defined(__MINGW32__)
 PyDoc_STRVAR(win32_startfile__doc__,
 "startfile(filepath [, operation]) - Start a file with its associated\n\
 application.\n\
@@ -8239,7 +8248,7 @@
 }
 #endif
 
-#ifdef MS_WINDOWS
+#if defined(MS_WINDOWS) && !defined(__MINGW32__)
 
 PyDoc_STRVAR(win32_urandom__doc__,
 "urandom(n) -> str\n\n\
@@ -8484,7 +8493,7 @@
 #endif /* HAVE_PLOCK */
 #ifdef HAVE_POPEN
 	{"popen",	posix_popen, METH_VARARGS, posix_popen__doc__},
-#ifdef MS_WINDOWS
+#if defined(MS_WINDOWS) || defined(__MINGW32__)
 	{"popen2",	win32_popen2, METH_VARARGS},
 	{"popen3",	win32_popen3, METH_VARARGS},
 	{"popen4",	win32_popen4, METH_VARARGS},
@@ -8649,13 +8658,13 @@
 	{"pathconf",	posix_pathconf, METH_VARARGS, posix_pathconf__doc__},
 #endif
 	{"abort",	posix_abort, METH_NOARGS, posix_abort__doc__},
-#ifdef MS_WINDOWS
+#if defined(MS_WINDOWS) || defined(__MINGW32__)
 	{"_getfullpathname",	posix__getfullpathname, METH_VARARGS, NULL},
 #endif
 #ifdef HAVE_GETLOADAVG
 	{"getloadavg",	posix_getloadavg, METH_NOARGS, posix_getloadavg__doc__},
 #endif
- #ifdef MS_WINDOWS
+ #if defined(MS_WINDOWS) && !defined(__MINGW32__)
  	{"urandom", win32_urandom, METH_VARARGS, win32_urandom__doc__},
  #endif
  #ifdef __VMS
@@ -8946,7 +8955,7 @@
 }
 
 
-#if (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__)) && !defined(__QNX__)
+#if (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined (__MINGW32__)) && !defined(__QNX__)
 #define INITFUNC initnt
 #define MODNAME "nt"
 
--- misc/build/Python-2.6.1/Modules/pwdmodule.c	2008-06-09 06:58:54.000000000 +0200
+++ misc/build/Python-2.6.1/Modules/pwdmodule.c	2009-05-09 13:35:04.000000000 +0200
@@ -1,9 +1,10 @@
-
 /* UNIX password file access module */
 
 #include "Python.h"
 #include "structseq.h"
 
+#ifndef __MINGW32__
+
 #include <sys/types.h>
 #include <pwd.h>
 
@@ -196,3 +197,9 @@
 	PyModule_AddObject(m, "struct_pwent", (PyObject *) &StructPwdType);
 	initialized = 1;
 }
+#else
+PyMODINIT_FUNC
+initpwd(void)
+{
+}
+#endif // !__MINGW32__
--- misc/build/Python-2.6.1/Modules/Setup.dist	2008-11-27 11:15:12.000000000 +0100
+++ misc/build/Python-2.6.1/Modules/Setup.dist	2009-05-12 00:28:08.000000000 +0200
@@ -91,12 +91,12 @@
 TESTPATH=
 
 # Path components for machine- or system-dependent modules and shared libraries
-MACHDEPPATH=:plat-$(MACHDEP)
+MACHDEPPATH=$(DELIM)plat-$(MACHDEP)
 EXTRAMACHDEPPATH=
 
 # Path component for the Tkinter-related modules
 # The TKPATH variable is always enabled, to save you the effort.
-TKPATH=:lib-tk
+TKPATH=$(DELIM)lib-tk
 
 # Path component for old modules.
 OLDPATH=:lib-old
@@ -112,9 +112,9 @@
 # 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
+@POSIX@ posixmodule.c		# posix (UNIX) system calls
 errno errnomodule.c		# posix (UNIX) errno values
-pwd pwdmodule.c			# this is needed to find out the user's home dir
+#pwd pwdmodule.c			# this is needed to find out the user's home dir
 				# if $HOME is not set
 _sre _sre.c			# Fredrik Lundh's new regular expressions
 _codecs _codecsmodule.c		# access to the builtin codecs and codec registry
@@ -162,33 +162,33 @@
 # it, depending on your system -- see the GNU readline instructions.
 # It's okay for this to be a shared library, too.
 
-#readline readline.c -lreadline -ltermcap
+readline readline.c -lreadline -ltermcap
 
 
 # Modules that should always be present (non UNIX dependent):
 
-#array arraymodule.c	# array objects
-#cmath cmathmodule.c # -lm # complex math library functions
-#math mathmodule.c # -lm # math library functions, e.g. sin()
-#_struct _struct.c	# binary structure packing/unpacking
-#time timemodule.c # -lm # time operations and variables
-#operator operator.c	# operator.add() and similar goodies
-#_weakref _weakref.c	# basic weak reference support
-#_testcapi _testcapimodule.c    # Python C API test module
-#_random _randommodule.c	# Random number generator
-#_collections _collectionsmodule.c # Container types
-#itertools itertoolsmodule.c	# Functions creating iterators for efficient looping 
-#strop stropmodule.c		# String manipulations
-#_functools _functoolsmodule.c	# Tools for working with functions and callable objects
-#_elementtree -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI _elementtree.c	# elementtree accelerator
+array arraymodule.c	# array objects
+cmath cmathmodule.c -lm # complex math library functions
+math mathmodule.c -lm # math library functions, e.g. sin()
+_struct _struct.c	# binary structure packing/unpacking
+time timemodule.c -lm # time operations and variables
+operator operator.c	# operator.add() and similar goodies
+_weakref _weakref.c	# basic weak reference support
+_testcapi _testcapimodule.c    # Python C API test module
+_random _randommodule.c	# Random number generator
+_collections _collectionsmodule.c # Container types
+itertools itertoolsmodule.c	# Functions creating iterators for efficient looping 
+strop stropmodule.c		# String manipulations
+_functools _functoolsmodule.c	# Tools for working with functions and callable objects
+_elementtree -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI _elementtree.c	# elementtree accelerator
 #_pickle _pickle.c	# pickle accelerator
-#datetime datetimemodule.c	# date/time type
-#_bisect _bisectmodule.c	# Bisection algorithms
+datetime datetimemodule.c	# date/time type
+_bisect _bisectmodule.c	# Bisection algorithms
 
-#unicodedata unicodedata.c    # static Unicode character database
+unicodedata unicodedata.c    # static Unicode character database
 
 # access to ISO C locale support
-#_locale _localemodule.c  # -lintl
+_locale _localemodule.c  -lintl
 
 
 # Modules with some UNIX dependencies -- on by default:
@@ -198,16 +198,16 @@
 #fcntl fcntlmodule.c	# fcntl(2) and ioctl(2)
 #spwd spwdmodule.c		# spwd(3) 
 #grp grpmodule.c		# grp(3)
-#select selectmodule.c	# select(2); not on ancient System V
+select selectmodule.c -lws2_32 -lwsock32	# select(2); not on ancient System V
 
 # Memory-mapped files (also works on Win32).
-#mmap mmapmodule.c
+mmap mmapmodule.c
 
 # CSV file helper
-#_csv _csv.c
+_csv _csv.c
 
 # Socket module helper for socket(2)
-#_socket socketmodule.c
+_socket socketmodule.c -lws2_32 -lwsock32
 
 # Socket module helper for SSL support; you must comment out the other
 # socket line above, and possibly edit the SSL variable:
@@ -248,14 +248,14 @@
 # Message-Digest Algorithm, described in RFC 1321.  The necessary files
 # md5.c and md5.h are included here.
 
-#_md5 md5module.c md5.c
+_md5 md5module.c md5.c
 
 
 # The _sha module implements the SHA checksum algorithms.
 # (NIST's Secure Hash Algorithms.)
-#_sha shamodule.c
-#_sha256 sha256module.c
-#_sha512 sha512module.c
+_sha shamodule.c
+_sha256 sha256module.c
+_sha512 sha512module.c
 
 
 # SGI IRIX specific modules -- off by default.
@@ -307,7 +307,7 @@
 
 # George Neville-Neil's timing module:
 
-#timing timingmodule.c
+timing timingmodule.c
 
 
 # The _tkinter module.
@@ -411,11 +411,11 @@
 #
 # Edit the variables DB and DBLIBVERto point to the db top directory
 # and the subdirectory of PORT where you built it.
-#DB=/usr/local/BerkeleyDB.4.0
-#DBLIBVER=4.0
-#DBINC=$(DB)/include
-#DBLIB=$(DB)/lib
-#_bsddb _bsddb.c -I$(DBINC) -L$(DBLIB) -ldb-$(DBLIBVER)
+DB=$(prefix)
+DBLIBVER=4.8
+DBINC=$(DB)/include
+DBLIB=$(DB)/lib
+_bsddb _bsddb.c -I$(DBINC) -L$(DBLIB) -ldb-$(DBLIBVER)
 
 # Historical Berkeley DB 1.85
 #
@@ -430,14 +430,14 @@
 
 
 # Helper module for various ascii-encoders
-#binascii binascii.c
+binascii binascii.c
 
 # Fred Drake's interface to the Python parser
-#parser parsermodule.c
+parser parsermodule.c
 
 # cStringIO and cPickle
-#cStringIO cStringIO.c
-#cPickle cPickle.c
+cStringIO cStringIO.c
+cPickle cPickle.c
 
 
 # Lee Busby's SIGFPE modules.
@@ -460,7 +460,7 @@
 # Andrew Kuchling's zlib module.
 # This require zlib 1.1.3 (or later).
 # See http://www.gzip.org/zlib/
-#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
+zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
 
 # Interface to the Expat XML parser
 #
@@ -473,23 +473,23 @@
 #
 # More information on Expat can be found at www.libexpat.org.
 #
-#pyexpat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI
+pyexpat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI
 
 
 # Hye-Shik Chang's CJKCodecs
 
 # multibytecodec is required for all the other CJK codec modules
-#_multibytecodec cjkcodecs/multibytecodec.c
+_multibytecodec cjkcodecs/multibytecodec.c
 
-#_codecs_cn cjkcodecs/_codecs_cn.c
-#_codecs_hk cjkcodecs/_codecs_hk.c
-#_codecs_iso2022 cjkcodecs/_codecs_iso2022.c
-#_codecs_jp cjkcodecs/_codecs_jp.c
-#_codecs_kr cjkcodecs/_codecs_kr.c
-#_codecs_tw cjkcodecs/_codecs_tw.c
+_codecs_cn cjkcodecs/_codecs_cn.c
+_codecs_hk cjkcodecs/_codecs_hk.c
+_codecs_iso2022 cjkcodecs/_codecs_iso2022.c
+_codecs_jp cjkcodecs/_codecs_jp.c
+_codecs_kr cjkcodecs/_codecs_kr.c
+_codecs_tw cjkcodecs/_codecs_tw.c
 
 # Example -- included for reference only:
 # xx xxmodule.c
 
 # Another example -- the 'xxsubtype' module shows C-level subtyping in action
-xxsubtype xxsubtype.c
+# xxsubtype xxsubtype.c
--- misc/build/Python-2.6.1/Modules/timemodule.c	2008-07-05 21:19:50.000000000 +0200
+++ misc/build/Python-2.6.1/Modules/timemodule.c	2009-05-09 13:35:04.000000000 +0200
@@ -42,6 +42,10 @@
 #include <windows.h>
 #include "pythread.h"
 
+#ifdef MS_WINDOWS
+#include <winsock2.h>
+#endif
+
 /* helper to allow us to interrupt sleep() on Windows*/
 static HANDLE hInterruptEvent = NULL;
 static BOOL WINAPI PyCtrlHandler(DWORD dwCtrlType)
@@ -837,7 +841,9 @@
 	   If Ctrl+C event delivered while not sleeping
 	   it will be ignored.
 	*/
+#ifdef WITH_THREAD
 	main_thread = PyThread_get_thread_ident();
+#endif
 	hInterruptEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
 	SetConsoleCtrlHandler( PyCtrlHandler, TRUE);
 #endif /* MS_WINDOWS */
@@ -939,8 +945,11 @@
 		 * by Guido, only the main thread can be interrupted.
 		 */
 		ul_millis = (unsigned long)millisecs;
-		if (ul_millis == 0 ||
-		    main_thread != PyThread_get_thread_ident())
+		if (ul_millis == 0
+#ifdef WITH_THREAD
+		    || main_thread != PyThread_get_thread_ident()
+#endif
+		    )
 			Sleep(ul_millis);
 		else {
 			DWORD rc;
--- misc/build/Python-2.6.1/Modules/xxsubtype.c	2007-07-21 08:55:02.000000000 +0200
+++ misc/build/Python-2.6.1/Modules/xxsubtype.c	2009-05-09 13:35:04.000000000 +0200
@@ -1,6 +1,10 @@
 #include "Python.h"
 #include "structmember.h"
 
+#ifndef CLOCKS_PER_SEC
+#include <bits/time.h>
+#endif
+
 PyDoc_STRVAR(xxsubtype__doc__,
 "xxsubtype is an example module showing how to subtype builtin types from C.\n"
 "test_descr.py in the standard test suite requires it in order to complete.\n"
--- misc/build/Python-2.6.1/Objects/exceptions.c	2008-07-30 19:45:10.000000000 +0200
+++ misc/build/Python-2.6.1/Objects/exceptions.c	2009-05-09 13:35:04.000000000 +0200
@@ -792,7 +792,7 @@
  *    WindowsError extends OSError
  */
 #ifdef MS_WINDOWS
-#include "errmap.h"
+#include "../PC/errmap.h"
 
 static int
 WindowsError_clear(PyWindowsErrorObject *self)
--- misc/build/Python-2.6.1/Python/dynload_shlib.c	2006-01-04 02:30:17.000000000 +0100
+++ misc/build/Python-2.6.1/Python/dynload_shlib.c	2009-05-09 13:35:04.000000000 +0200
@@ -32,7 +32,7 @@
 
 
 const struct filedescr _PyImport_DynLoadFiletab[] = {
-#ifdef __CYGWIN__
+#if defined(__CYGWIN__) || defined(__MINGW32__)
 	{".dll", "rb", C_EXTENSION},
 	{"module.dll", "rb", C_EXTENSION},
 #else
--- misc/build/Python-2.6.1/Python/dynload_win.c	2009-01-28 00:30:15.000000000 +0100
+++ misc/build/Python-2.6.1/Python/dynload_win.c	2009-05-09 13:35:04.000000000 +0200
@@ -1,7 +1,112 @@
 
 /* Support for dynamic loading of extension modules */
 
+/*
+Entry point for the Windows NT DLL.
+
+About the only reason for having this, is so initall() can automatically
+be called, removing that burden (and possible source of frustration if 
+forgotten) from the programmer.
+
+*/
+
 #include "Python.h"
+#include "windows.h"
+
+#ifdef Py_ENABLE_SHARED
+char dllVersionBuffer[16] = ""; // a private buffer
+
+// Python Globals
+HMODULE PyWin_DLLhModule = NULL;
+const char *PyWin_DLLVersionString = dllVersionBuffer;
+
+// Windows "Activation Context" work:
+// Our .pyd extension modules are generally built without a manifest (ie,
+// those included with Python and those built with a default distutils.
+// This requires we perform some "activation context" magic when loading our
+// extensions.  In summary:
+// * As our DLL loads we save the context being used.
+// * Before loading our extensions we re-activate our saved context.
+// * After extension load is complete we restore the old context.
+// As an added complication, this magic only works on XP or later - we simply
+// use the existence (or not) of the relevant function pointers from kernel32.
+// See bug 4566 (http://python.org/sf/4566) for more details.
+
+typedef BOOL (WINAPI * PFN_GETCURRENTACTCTX)(HANDLE *);
+typedef BOOL (WINAPI * PFN_ACTIVATEACTCTX)(HANDLE, ULONG_PTR *);
+typedef BOOL (WINAPI * PFN_DEACTIVATEACTCTX)(DWORD, ULONG_PTR);
+typedef BOOL (WINAPI * PFN_ADDREFACTCTX)(HANDLE);
+typedef BOOL (WINAPI * PFN_RELEASEACTCTX)(HANDLE);
+
+// locals and function pointers for this activation context magic.
+static HANDLE PyWin_DLLhActivationContext = NULL; // one day it might be public
+static PFN_GETCURRENTACTCTX pfnGetCurrentActCtx = NULL;
+static PFN_ACTIVATEACTCTX pfnActivateActCtx = NULL;
+static PFN_DEACTIVATEACTCTX pfnDeactivateActCtx = NULL;
+static PFN_ADDREFACTCTX pfnAddRefActCtx = NULL;
+static PFN_RELEASEACTCTX pfnReleaseActCtx = NULL;
+
+void _LoadActCtxPointers()
+{
+	HINSTANCE hKernel32 = GetModuleHandleW(L"kernel32.dll");
+	if (hKernel32)
+		pfnGetCurrentActCtx = (PFN_GETCURRENTACTCTX) GetProcAddress(hKernel32, "GetCurrentActCtx");
+	// If we can't load GetCurrentActCtx (ie, pre XP) , don't bother with the rest.
+	if (pfnGetCurrentActCtx) {
+		pfnActivateActCtx = (PFN_ACTIVATEACTCTX) GetProcAddress(hKernel32, "ActivateActCtx");
+		pfnDeactivateActCtx = (PFN_DEACTIVATEACTCTX) GetProcAddress(hKernel32, "DeactivateActCtx");
+		pfnAddRefActCtx = (PFN_ADDREFACTCTX) GetProcAddress(hKernel32, "AddRefActCtx");
+		pfnReleaseActCtx = (PFN_RELEASEACTCTX) GetProcAddress(hKernel32, "ReleaseActCtx");
+	}
+}
+
+ULONG_PTR _Py_ActivateActCtx()
+{
+	ULONG_PTR ret = 0;
+	if (PyWin_DLLhActivationContext && pfnActivateActCtx)
+		if (!(*pfnActivateActCtx)(PyWin_DLLhActivationContext, &ret)) {
+			OutputDebugString("Python failed to activate the activation context before loading a DLL\n");
+			ret = 0; // no promise the failing function didn't change it!
+		}
+	return ret;
+}
+
+void _Py_DeactivateActCtx(ULONG_PTR cookie)
+{
+	if (cookie && pfnDeactivateActCtx)
+		if (!(*pfnDeactivateActCtx)(0, cookie))
+			OutputDebugString("Python failed to de-activate the activation context\n");
+}
+
+BOOL	WINAPI	DllMain (HANDLE hInst, 
+						ULONG ul_reason_for_call,
+						LPVOID lpReserved)
+{
+	switch (ul_reason_for_call)
+	{
+		case DLL_PROCESS_ATTACH:
+			PyWin_DLLhModule = hInst;
+			// 1000 is a magic number I picked out of the air.  Could do with a #define, I spose...
+			LoadString(hInst, 1000, dllVersionBuffer, sizeof(dllVersionBuffer));
+
+			// and capture our activation context for use when loading extensions.
+			_LoadActCtxPointers();
+			if (pfnGetCurrentActCtx && pfnAddRefActCtx)
+				if ((*pfnGetCurrentActCtx)(&PyWin_DLLhActivationContext))
+					if (!(*pfnAddRefActCtx)(PyWin_DLLhActivationContext))
+						OutputDebugString("Python failed to load the default activation context\n");
+			break;
+
+		case DLL_PROCESS_DETACH:
+			if (pfnReleaseActCtx)
+				(*pfnReleaseActCtx)(PyWin_DLLhActivationContext);
+			break;
+	}
+	return TRUE;
+}
+
+#endif /* Py_ENABLE_SHARED */
+
 
 #ifdef HAVE_DIRECT_H
 #include <direct.h>
@@ -28,6 +133,9 @@
 /* Case insensitive string compare, to avoid any dependencies on particular
    C RTL implementations */
 
+#ifdef __MINGW32__
+#define strcasecmp py_strcasecmp
+#endif
 static int strcasecmp (char *string1, char *string2)
 { 
 	int first, second;
--- misc/build/Python-2.6.1/Python/frozenmain.c	2002-06-30 17:26:10.000000000 +0200
+++ misc/build/Python-2.6.1/Python/frozenmain.c	2009-05-09 13:35:04.000000000 +0200
@@ -3,7 +3,7 @@
 
 #include "Python.h"
 
-#ifdef MS_WINDOWS
+#if defined (MS_WINDOWS) && ! defined (__MINGW32__)
 extern void PyWinFreeze_ExeInit(void);
 extern void PyWinFreeze_ExeTerm(void);
 extern int PyInitFrozenExtensions(void);
@@ -32,12 +32,12 @@
 		setbuf(stderr, (char *)NULL);
 	}
 
-#ifdef MS_WINDOWS
+#if defined (MS_WINDOWS) && ! defined (__MINGW32__)
 	PyInitFrozenExtensions();
 #endif /* MS_WINDOWS */
 	Py_SetProgramName(argv[0]);
 	Py_Initialize();
-#ifdef MS_WINDOWS
+#if defined (MS_WINDOWS) && ! defined (__MINGW32__)
 	PyWinFreeze_ExeInit();
 #endif
 
@@ -60,7 +60,7 @@
 	if (inspect && isatty((int)fileno(stdin)))
 		sts = PyRun_AnyFile(stdin, "<stdin>") != 0;
 
-#ifdef MS_WINDOWS
+#if defined (MS_WINDOWS) && ! defined (__MINGW32__)
 	PyWinFreeze_ExeTerm();
 #endif
 	Py_Finalize();
--- misc/build/Python-2.6.1/README	2009-04-07 03:54:02.000000000 +0200
+++ misc/build/Python-2.6.1/README	2009-05-09 13:35:04.000000000 +0200
@@ -1160,6 +1160,37 @@
 do this.
 
 
+Cross Compiling
+---------------
+
+Python can be cross compiled by supplying different --build and --host
+parameters to configure.  Python is compiled on the "build" system and
+executed on the "host" system.  Cross compiling python requires a
+native Python on the build host, and a natively compiled tool `Pgen'.
+
+Before cross compiling, Python must first be compiled and installed on
+the build host.  The configure script will use `cc' and `python', or
+environment variables CC_FOR_BUILD or PYTHON_FOR_BUILD, eg:
+
+   CC_FOR_BUILD=gcc-3.3 \
+   PYTHON_FOR_BUILD=python2.4 \
+   .../configure --build=i686-linux --host=i586-mingw32
+
+Cross compiling has been tested under linux, mileage may vary for
+other platforms.
+
+A few reminders on using configure to cross compile:
+- Cross compile tools must be in PATH,
+- Cross compile tools must be prefixed with the host type
+  (ie i586-mingw32-gcc, i586-mingw32-ranlib, ...),
+- CC, CXX, AR, and RANLIB must be undefined when running configure,
+  they will be auto-detected.
+
+If you need a cross compiler, Debian ships several several (eg: avr,
+m68hc1x, mingw32), while dpkg-cross easily creates others.  Otherwise,
+check out Dan Kegel's crosstool: http://www.kegel.com/crosstool .
+
+
 Miscellaneous issues
 ====================
 
--- misc/build/Python-2.6.1/setup.py	2009-03-31 20:20:48.000000000 +0200
+++ misc/build/Python-2.6.1/setup.py	2009-05-09 13:35:04.000000000 +0200
@@ -19,6 +19,11 @@
 # This global variable is used to hold the list of modules to be disabled.
 disabled_module_list = []
 
+import os
+sysconfig.get_config_vars()
+sysconfig._config_vars.update (os.environ)
+
+
 def add_dir_to_list(dirlist, dir):
     """Add the directory 'dir' to the list 'dirlist' (at the front) if
     1) 'dir' is not already in 'dirlist'
@@ -115,6 +120,8 @@
         # Fix up the autodetected modules, prefixing all the source files
         # with Modules/ and adding Python's include directory to the path.
         (srcdir,) = sysconfig.get_config_vars('srcdir')
+        if os.environ.get('CROSS_COMPILING') == 'yes':
+            srcdir = os.environ.get('SRCDIR')
         if not srcdir:
             # Maybe running on Windows but not using CYGWIN?
             raise ValueError("No source directory; cannot proceed.")
@@ -267,6 +274,10 @@
             self.announce('WARNING: skipping import check for Cygwin-based "%s"'
                 % ext.name)
             return
+        if os.environ.get('CROSS_COMPILING') == 'yes':
+            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,11 +313,14 @@
             self.failed.append(ext.name)
 
     def get_platform(self):
-        # Get value of sys.platform
-        for platform in ['cygwin', 'beos', 'darwin', 'atheos', 'osf1']:
-            if sys.platform.startswith(platform):
+        # Get value of target's sys.platform
+        p = sys.platform
+        if os.environ.get('CROSS_COMPILING') == 'yes':
+            p = os.environ.get('CROSS_TARGET')
+        for platform in ['cygwin', 'mingw', 'beos', 'darwin', 'atheos', 'osf1']:
+            if p.startswith(platform):
                 return platform
-        return sys.platform
+        return p
 
     def detect_modules(self):
         # Ensure that /usr/local is always used
@@ -889,13 +903,11 @@
         # We hunt for #define SQLITE_VERSION "n.n.n"
         # We need to find >= sqlite version 3.0.8
         sqlite_incdir = sqlite_libdir = None
-        sqlite_inc_paths = [ '/usr/include',
-                             '/usr/include/sqlite',
-                             '/usr/include/sqlite3',
-                             '/usr/local/include',
-                             '/usr/local/include/sqlite',
-                             '/usr/local/include/sqlite3',
-                           ]
+        sqlite_inc_paths = []
+
+        # Broken for x-compile
+        #'/usr/include', '/usr/include/sqlite', '/usr/include/sqlite3', '/usr/local/include', '/usr/local/include/sqlite', '/usr/local/include/sqlite3', ]
+
         MIN_SQLITE_VERSION_NUMBER = (3, 0, 8)
         MIN_SQLITE_VERSION = ".".join([str(x)
                                     for x in MIN_SQLITE_VERSION_NUMBER])
@@ -1809,6 +1821,8 @@
     # mode 755. All installed directories will get mode 755.
 
     so_ext = sysconfig.get_config_var("SO")
+    if os.environ.get('CROSS_COMPILING') == 'yes':
+        so_ext = os.environ.get('SO')
 
     def install(self):
         outfiles = install_lib.install(self)
--- misc/build/Python-2.6.1/Python/thread.c	2008-08-04 09:33:37.000000000 +0200
+++ misc/build/Python-2.6.1/Python/thread.c	2009-05-12 01:00:57.000000000 +0200
@@ -61,6 +61,13 @@
 
 #endif /* _POSIX_THREADS */
 
+#ifdef __MINGW32__
+#ifdef _POSIX_THREADS
+#undef _POSIX_THREADS
+#endif
+#define NT_THREADS
+#endif
+
 
 #ifdef Py_DEBUG
 static int thread_debug = 0;
--- misc/build/Python-2.6.1/Modules/addrinfo.h	2009-05-12 01:30:32.000000000 +0200
+++ misc/build/Python-2.6.1/Modules/addrinfo.h	2009-05-12 01:34:34.000000000 +0200
@@ -123,7 +123,7 @@
 
 #endif /* !HAVE_GETNAMEINFO */
 
-#ifndef HAVE_ADDRINFO
+#if !defined(HAVE_ADDRINFO) && !defined(_WIN32)
 struct addrinfo {
 	int	ai_flags;	/* AI_PASSIVE, AI_CANONNAME */
 	int	ai_family;	/* PF_xxx */
@@ -136,7 +136,7 @@
 };
 #endif /* !HAVE_ADDRINFO */
 
-#ifndef HAVE_SOCKADDR_STORAGE
+#if !defined(HAVE_SOCKADDR_STORAGE) && !defined(_WIN32)
 /*
  * RFC 2553: protocol-independent placeholder for socket addresses
  */
--- misc/build/Python-2.6.1/Modules/socketmodule.c	2009-05-12 01:29:43.000000000 +0200
+++ misc/build/Python-2.6.1/Modules/socketmodule.c	2009-05-12 01:29:51.000000000 +0200
@@ -3134,7 +3134,11 @@
 	if (h->h_addrtype != af) {
 		/* Let's get real error message to return */
 		PyErr_SetString(socket_error,
+#ifdef _WIN32
+				(char *)strerror(WSAEAFNOSUPPORT));
+#else
 				(char *)strerror(EAFNOSUPPORT));
+#endif
 
 		return NULL;
 	}
--- misc/build/Python-2.6.1/Modules/socketmodule.h	2009-08-10 17:15:24.000000000 +0200
+++ misc/build/Python-2.6.1/Modules/socketmodule.h	2009-08-10 17:15:48.000000000 +0200
@@ -21,7 +21,7 @@
  * I use SIO_GET_MULTICAST_FILTER to detect a decent SDK.
  */
 # ifdef SIO_GET_MULTICAST_FILTER
-#  include <MSTcpIP.h> /* for SIO_RCVALL */
+#  include <mstcpip.h> /* for SIO_RCVALL */
 #  define HAVE_ADDRINFO
 #  define HAVE_SOCKADDR_STORAGE
 #  define HAVE_GETADDRINFO