Update reference toolchain to

gcc 4.4.2
binutils 2.20
gdb 7.0

and add mingw support.

Signed-off-by: Stefan Reinauer <stepan@coresystems.de>


Index: util/crossgcc/patches/binutils-2.20_no-i386-svr4-asm-comments.patch
===================================================================
--- util/crossgcc/patches/binutils-2.20_no-i386-svr4-asm-comments.patch	(revision 0)
+++ util/crossgcc/patches/binutils-2.20_no-i386-svr4-asm-comments.patch	(revision 0)
@@ -0,0 +1,10 @@
+--- binutils-2.20/gas/config/tc-i386.c~	2009-01-20 14:19:04.000000000 +0100
++++ binutils-2.20/gas/config/tc-i386.c	2009-01-20 14:20:47.000000000 +0100
+@@ -318,6 +318,7 @@
+ 	 && !defined (TE_GNU)				\
+ 	 && !defined (TE_LINUX)				\
+  	 && !defined (TE_NETWARE)			\
++	 && 0						\
+ 	 && !defined (TE_FreeBSD)			\
+ 	 && !defined (TE_NetBSD)))
+ /* This array holds the chars that always start a comment.  If the
Index: util/crossgcc/patches/gcc-4.4.2_less-junk-in-crtbegin.patch
===================================================================
--- util/crossgcc/patches/gcc-4.4.2_less-junk-in-crtbegin.patch	(revision 0)
+++ util/crossgcc/patches/gcc-4.4.2_less-junk-in-crtbegin.patch	(revision 0)
@@ -0,0 +1,50 @@
+--- t/gcc-4.4.2/gcc/crtstuff.c	Fr. Apr 10 01:23:07 2009
++++ gcc-4.4.2/gcc/crtstuff.c	Di. Jul 28 16:43:28 2009
+@@ -204,6 +204,7 @@
+   = { (func_ptr) (-1) };
+ #endif /* __DTOR_LIST__ alternatives */
+ 
++#if 0
+ #ifdef USE_EH_FRAME_REGISTRY
+ /* Stick a label at the beginning of the frame unwind info so we can register
+    and deregister it with the exception handling library code.  */
+@@ -219,6 +220,7 @@
+   __attribute__ ((unused, section(JCR_SECTION_NAME), aligned(sizeof(void*))))
+   = { };
+ #endif /* JCR_SECTION_NAME */
++#endif
+ 
+ #if defined(INIT_SECTION_ASM_OP) || defined(INIT_ARRAY_SECTION_ASM_OP)
+ 
+@@ -309,6 +311,7 @@
+   }
+ #endif /* !defined(FINI_ARRAY_SECTION_ASM_OP) */
+ 
++#if 0
+ #ifdef USE_EH_FRAME_REGISTRY
+ #ifdef CRT_GET_RFIB_DATA
+   /* If we used the new __register_frame_info_bases interface,
+@@ -320,6 +323,7 @@
+     __deregister_frame_info (__EH_FRAME_BEGIN__);
+ #endif
+ #endif
++#endif
+ 
+   completed = 1;
+ }
+@@ -333,6 +337,7 @@
+   = { __do_global_dtors_aux };
+ #endif /* !defined(FINI_SECTION_ASM_OP) */
+ 
++#if 0
+ #if defined(USE_EH_FRAME_REGISTRY) || defined(JCR_SECTION_NAME)
+ /* Stick a call to __register_frame_info into the .init section.  For some
+    reason calls with no arguments work more reliably in .init, so stick the
+@@ -364,6 +369,7 @@
+     }
+ #endif /* JCR_SECTION_NAME */
+ }
++#endif
+ 
+ #ifdef INIT_SECTION_ASM_OP
+ CRT_CALL_STATIC_FUNCTION (INIT_SECTION_ASM_OP, frame_dummy)
Index: util/crossgcc/buildgcc
===================================================================
--- util/crossgcc/buildgcc	(revision 5009)
+++ util/crossgcc/buildgcc	(working copy)
@@ -28,10 +28,12 @@
 
 # version numbers
 GMP_VERSION=4.3.1
-MPFR_VERSION=2.4.1
-GCC_VERSION=4.4.1
-BINUTILS_VERSION=2.19.1
-GDB_VERSION=6.8
+MPFR_VERSION=2.4.2
+GCC_VERSION=4.4.2
+BINUTILS_VERSION=2.20
+GDB_VERSION=7.0
+W32API_VERSION=3.13
+MINGWRT_VERSION=3.16
 
 # archive locations
 GMP_ARCHIVE="ftp://ftp.gmplib.org/pub/gmp-${GMP_VERSION}/gmp-${GMP_VERSION}.tar.bz2"
@@ -39,12 +41,16 @@
 GCC_ARCHIVE="ftp://ftp.gwdg.de/pub/gnu/ftp/gnu/gcc/gcc-${GCC_VERSION}/gcc-core-${GCC_VERSION}.tar.bz2"
 BINUTILS_ARCHIVE="http://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VERSION}.tar.bz2"
 GDB_ARCHIVE="http://ftp.gnu.org/gnu/gdb/gdb-${GDB_VERSION}.tar.bz2"
+W32API_ARCHIVE="http://downloads.sourceforge.net/project/mingw/MinGW%20API%20for%20MS-Windows/Current%20Release_%20w32api-${W32API_VERSION}/w32api-${W32API_VERSION}-mingw32-src.tar.gz"
+MINGWRT_ARCHIVE="http://downloads.sourceforge.net/project/mingw/MinGW%20Runtime/mingwrt-${MINGWRT_VERSION}/mingwrt-${MINGWRT_VERSION}-mingw32-src.tar.gz"
 
 GMP_DIR="gmp-${GMP_VERSION}"
 MPFR_DIR="mpfr-${MPFR_VERSION}"
 GCC_DIR="gcc-${GCC_VERSION}"
 BINUTILS_DIR="binutils-${BINUTILS_VERSION}"
 GDB_DIR="gdb-${GDB_VERSION}"
+W32API_DIR="w32api-${W32API_VERSION}-mingw32"
+MINGWRT_DIR="mingwrt-${MINGWRT_VERSION}-mingw32"
 
 SAVETEMPS=0
 
@@ -82,7 +88,7 @@
 cleanup()
 {
 	printf "Cleaning up temporary files... "
-	rm -rf build-* combined gcc-* gmp-* mpfr-* binutils-* gdb-*
+	rm -rf build-* combined gcc-* gmp-* mpfr-* binutils-* gdb-* w32api-* mingwrt-*
 	printf "${green}ok${NC}\n"
 }
 
@@ -158,9 +164,14 @@
 	esac
 done
 
+MINGW_ARCHIVES=""
+if [ "$TARGETARCH" = "i386-mingw32" ]; then
+	MINGW_ARCHIVES="$W32API_ARCHIVE $MINGWRT_ARCHIVE"
+fi
+
 printf "Downloading tar balls ... \n"
 mkdir -p tarballs
-for ARCHIVE in $GMP_ARCHIVE $MPFR_ARCHIVE $GCC_ARCHIVE $BINUTILS_ARCHIVE $GDB_ARCHIVE; do
+for ARCHIVE in $GMP_ARCHIVE $MPFR_ARCHIVE $GCC_ARCHIVE $BINUTILS_ARCHIVE $GDB_ARCHIVE $MINGW_ARCHIVES; do
 	FILE=`basename $ARCHIVE`
 	printf " * $FILE "
 	test -f tarballs/$FILE && printf "(cached)" || (
@@ -175,8 +186,13 @@
 printf "Downloaded tar balls ... "
 printf "${green}ok${NC}\n"
 
+MINGW_PACKAGES=""
+if [ "$TARGETARCH" = "i386-mingw32" ]; then
+	MINGW_PACKAGES="W32API MINGWRT"
+fi
+
 printf "Unpacking and patching ... \n"
-for PACKAGE in GMP MPFR GCC BINUTILS GDB; do
+for PACKAGE in GMP MPFR GCC BINUTILS GDB $MINGW_PACKAGES; do
 	archive=$PACKAGE"_ARCHIVE"
 	archive=${!archive}
 	dir=$PACKAGE"_DIR"
@@ -186,7 +202,7 @@
 		test ${archive:${#archive}-2:2} = "gz" && FLAGS=zxf
 		test ${archive:${#archive}-3:3} = "bz2" && FLAGS=jxf
 		$TAR $FLAGS tarballs/`basename $archive`
-		for patch in patches/${!dir}"_*.patch"; do
+		for patch in patches/${!dir}_*.patch; do
 			test -r $patch || continue
 			printf "   o `basename $patch`\n"
 			patch -s -N -p0 < `echo $patch`
@@ -196,6 +212,11 @@
 printf "Unpacked and patched ... "
 printf "${green}ok${NC}\n"
 
+if [ "$TARGETARCH" = "i386-mingw32" ]; then
+	mkdir -p $TARGETDIR/i386-mingw32/sys-include
+	mv $MINGWRT_DIR/include/* $W32API_DIR/include/* $TARGETDIR/i386-mingw32/sys-include
+fi
+
 mkdir -p build-gmp build-mpfr build-binutils build-gcc build-gdb
 if [ -f build-gmp/.success ]; then
 	printf "Skipping GMP as it is already built\n"
@@ -293,7 +314,7 @@
 	# libiberty is not compiled with CFLAGS_FOR_BUILD.
 	CFLAGS_FOR_BUILD="$HOSTCFLAGS" ../gcc-${GCC_VERSION}/configure \
 		--prefix=$TARGETDIR --libexecdir=$TARGETDIR/lib \
-		--target=${TARGETARCH} --disable-werror \
+		--target=${TARGETARCH} --disable-werror --disable-shared \
 		--disable-libssp --disable-bootstrap --disable-nls \
 		--with-gmp=$DESTDIR$TARGETDIR --with-mpfr=$DESTDIR$TARGETDIR \
 		|| touch .failed
