From 46ebe8fb6314cf8a60abbf4a63df64d8992456cd Mon Sep 17 00:00:00 2001
From: Oliver Bock <oliver.bock@aei.mpg.de>
Date: Sun, 15 Feb 2009 02:44:59 +0100
Subject: [PATCH] Workaround for MinGW inconsistencies * Adjusted package
 naming conventions to current releases * Updated used packages to current
 releases

---
 build.sh                                      |  3 ++
 patches/x86-mingw32-build.sh.batch.patch      | 45 ++++++++++++++++
 .../x86-mingw32-build.sh.conf_versions.patch  | 26 +++++++++
 patches/x86-mingw32-build.sh.patch            | 53 +++++++++++++++++++
 4 files changed, 127 insertions(+)
 create mode 100644 patches/x86-mingw32-build.sh.batch.patch
 create mode 100644 patches/x86-mingw32-build.sh.conf_versions.patch
 create mode 100644 patches/x86-mingw32-build.sh.patch

diff --git a/build.sh b/build.sh
index fc5f2e0..6e46902 100755
--- a/build.sh
+++ b/build.sh
@@ -193,7 +193,10 @@ prepare_win32()
 	echo "Preparing MinGW build script..." | tee -a $LOGFILE
 	cd $ROOT/3rdparty/mingw/xscripts || failure
 	# note: svn has no force/overwrite switch. the file might not be updated when patched
+	patch x86-mingw32-build.sh < $ROOT/patches/x86-mingw32-build.sh.patch >> $LOGFILE || failure						# temporary workaround
+	patch x86-mingw32-build.sh.batch < $ROOT/patches/x86-mingw32-build.sh.batch.patch >> $LOGFILE || failure			# temporary workaround
 	patch x86-mingw32-build.sh.conf < $ROOT/patches/x86-mingw32-build.sh.conf.patch >> $LOGFILE || failure
+	patch x86-mingw32-build.sh.conf < $ROOT/patches/x86-mingw32-build.sh.conf_versions.patch >> $LOGFILE || failure		# temporary workaround
 	chmod +x x86-mingw32-build.sh >> $LOGFILE || failure
 
 	return 0
diff --git a/patches/x86-mingw32-build.sh.batch.patch b/patches/x86-mingw32-build.sh.batch.patch
new file mode 100644
index 0000000..8e0bc66
--- /dev/null
+++ b/patches/x86-mingw32-build.sh.batch.patch
@@ -0,0 +1,45 @@
+--- x86-mingw32-build.sh.batch
++++ x86-mingw32-build.sh.batch.new	2009-02-15 01:51:59.000000000 +0100
+@@ -32,14 +32,14 @@
+   if isyes $ALLOW_DOWNLOADS
+   then
+     option GCC_VERSION "`enumerate $PACKAGE_DIR/gcc-core- -src.tar.gz`"
+-    option BINUTILS_VERSION "`enumerate $PACKAGE_DIR/binutils- -src.tar.gz`"
+-    option RUNTIME_VERSION "`enumerate $PACKAGE_DIR/mingw-runtime- -src.tar.gz`"
+-    option W32API_VERSION "`enumerate $PACKAGE_DIR/w32api- -src.tar.gz`"
++    option BINUTILS_VERSION "`enumerate $PACKAGE_DIR/binutils- -mingw32-src.tar.gz`"
++    option RUNTIME_VERSION "`enumerate $PACKAGE_DIR/mingwrt- -mingw32-src.tar.gz`"
++    option W32API_VERSION "`enumerate $PACKAGE_DIR/w32api- -mingw32-src.tar.gz`"
+   else
+     GCC_VERSION=`enumerate $PACKAGE_DIR/gcc-core- -src.tar.gz`
+-    BINUTILS_VERSION=`enumerate $PACKAGE_DIR/binutils- -src.tar.gz`
+-    RUNTIME_VERSION=`enumerate $PACKAGE_DIR/mingw-runtime- -src.tar.gz`
+-    W32API_VERSION=`enumerate $PACKAGE_DIR/w32api- -src.tar.gz`
++    BINUTILS_VERSION=`enumerate $PACKAGE_DIR/binutils- -mingw32-src.tar.gz`
++    RUNTIME_VERSION=`enumerate $PACKAGE_DIR/mingwrt- -mingw32-src.tar.gz`
++    W32API_VERSION=`enumerate $PACKAGE_DIR/w32api- -mingw32-src.tar.gz`
+   fi
+   GCC_VERSION=`newest $GCC_VERSION`
+   BINUTILS_VERSION=`newest $BINUTILS_VERSION`
+@@ -73,17 +73,17 @@
+ esac
+ case $BUILD_COMPONENTS in *binutils*)
+   test -n "$BINUTILS_VERSION" && \
+-    option DOWNLOAD binutils-$BINUTILS_VERSION-src.tar.gz
++    option DOWNLOAD binutils-$BINUTILS_VERSION-mingw32-src.tar.gz
+   option BINUTILS_BASE_OPTIONS "$BINUTILS_USER_OPTIONS" ;;
+ esac
+-case $BUILD_COMPONENTS in *mingw-runtime*)
++case $BUILD_COMPONENTS in *mingwrt*)
+   test -n "$RUNTIME_VERSION" && \
+-    option DOWNLOAD mingw-runtime-$RUNTIME_VERSION-src.tar.gz
++    option DOWNLOAD mingwrt-$RUNTIME_VERSION-mingw32-src.tar.gz
+   option RUNTIME_BASE_OPTIONS "$RUNTIME_USER_OPTIONS" ;;
+ esac
+ case $BUILD_COMPONENTS in *w32api*)
+   test -n "$W32API_VERSION" && \
+-    option DOWNLOAD w32api-$W32API_VERSION-src.tar.gz
++    option DOWNLOAD w32api-$W32API_VERSION-mingw32-src.tar.gz
+   option W32API_BASE_OPTIONS "$W32API_USER_OPTIONS" ;;
+ esac
+ 
diff --git a/patches/x86-mingw32-build.sh.conf_versions.patch b/patches/x86-mingw32-build.sh.conf_versions.patch
new file mode 100644
index 0000000..07a8bb7
--- /dev/null
+++ b/patches/x86-mingw32-build.sh.conf_versions.patch
@@ -0,0 +1,26 @@
+--- x86-mingw32-build.sh.conf
++++ x86-mingw32-build.sh.conf.new	2009-02-15 01:16:34.000000000 +0100
+@@ -48,10 +48,10 @@
+ #
+ # 4) Package versions, from which the compiler will be built.
+ #
+-     assume GCC_VERSION                   3.4.5-20060117-1
+-     assume BINUTILS_VERSION              2.18.50-20080109
+-     assume RUNTIME_VERSION               3.14
+-     assume W32API_VERSION                3.11
++     assume GCC_VERSION                   3.4.5-20060117-2
++     assume BINUTILS_VERSION              2.19.1
++     assume RUNTIME_VERSION               3.15.2
++     assume W32API_VERSION                3.13
+      assume GDC_VERSION                   0.24
+ #
+ # 5) Automatic patching of downloaded packages: if any appropriately
+@@ -80,7 +80,7 @@
+      option BUILD_COMPONENTS              headers
+      option BUILD_COMPONENTS              gcc
+      option BUILD_COMPONENTS              w32api
+-     option BUILD_COMPONENTS              mingw-runtime
++     option BUILD_COMPONENTS              mingwrt
+ #
+ # 7) GCC language options.  The compiler MUST be built to support
+ #    at least `C' language.
diff --git a/patches/x86-mingw32-build.sh.patch b/patches/x86-mingw32-build.sh.patch
new file mode 100644
index 0000000..53b7702
--- /dev/null
+++ b/patches/x86-mingw32-build.sh.patch
@@ -0,0 +1,53 @@
+--- x86-mingw32-build.sh
++++ x86-mingw32-build.sh.new	2009-02-15 00:22:14.000000000 +0100
+@@ -77,7 +77,7 @@
+       then
+         cd binutils*/build
+       else
+-	$RUN prepare binutils-$BINUTILS_VERSION
++	$RUN prepare binutils-$BINUTILS_VERSION "-mingw32-src"
+ 	$RUN setbuilddir binutils*
+ 	$RUN ../configure --prefix="$INSTALL_DIR" --target="$TARGET" \
+ 	  $GLOBAL_BASE_OPTIONS $BINUTILS_BASE_OPTIONS || die $? \
+@@ -126,9 +126,9 @@
+       cd "$WORKING_DIR"; test $LEAN_BUILD && rm -rf build-gcc
+       ;;
+ 
+-    headers | mingw-runtime | w32api)
+-      test -r mingw-runtime-*/configure || $RUN prepare mingw-runtime-$RUNTIME_VERSION
+-      test -r w32api-*/configure || $RUN prepare w32api-$W32API_VERSION
++    headers | mingwrt | w32api)
++      test -r mingwrt-*/configure || $RUN prepare mingwrt-$RUNTIME_VERSION "-mingw32-src"
++      test -r w32api-*/configure || $RUN prepare w32api-$W32API_VERSION "-mingw32-src"
+       case $COMPONENT in
+ 	headers)
+ 	  $RUN mkdir -p "$INSTALL_DIR/include"
+@@ -136,16 +136,16 @@
+ 	    $RUN cd "$INSTALL_DIR" && $RUN ln -s . usr )
+           test -e "$INSTALL_DIR/usr/local" || (
+ 	    $RUN cd "$INSTALL_DIR/usr" && $RUN ln -s . local )
+-	  $RUN cp -r mingw-runtime-*/include "$INSTALL_DIR" || die $? \
++	  $RUN cp -r mingwrt-*/include "$INSTALL_DIR" || die $? \
+             "$unrecoverable installing mingw-runtime headers"
+ 	  $RUN cp -r w32api-*/include "$INSTALL_DIR" || die $? \
+             "$unrecoverable installing w32api headers"
+ 	  ;;
+-	mingw-runtime)
++	mingwrt)
+           test -e w32api || $RUN ln -s w32api-* w32api
+ 	  ;;
+       esac
+-      case $COMPONENT in mingw-runtime | w32api)
++      case $COMPONENT in mingwrt | w32api)
+ 	setbuilddir ${COMPONENT}-*
+ 	$RUN ../configure --prefix="$INSTALL_DIR" --host="$TARGET" \
+           --build=${BUILD_PLATFORM=`../config.guess`} || die $? \
+@@ -160,7 +160,7 @@
+       ;;
+ 
+   esac; done
+-  cd "$WORKING_DIR"; test $LEAN_BUILD && $RUN rm -rf mingw-runtime-* w32api-*
++  cd "$WORKING_DIR"; test $LEAN_BUILD && $RUN rm -rf mingwrt-* w32api-*
+   BUILD_COMPONENTS=`case $BUILD_COMPONENTS in *gcc*) echo gcc ;; esac`
+ done
+ 
-- 
GitLab