From c23ebc013e7483da35d5d1961ff887b82442126a Mon Sep 17 00:00:00 2001
From: davehome <davehome@redthumb.info.tm>
Date: Wed, 20 Jul 2011 16:38:06 -0600
Subject: [PATCH] mingw-w64-*: Fix wrksrc/build_wrksrc vars; revbump.

---
 srcpkgs/mingw-w64-crt/template     | 23 ++++++++++++-----------
 srcpkgs/mingw-w64-gcc/template     | 20 +++++++++++---------
 srcpkgs/mingw-w64-headers/template | 14 ++++++++------
 srcpkgs/mingw-w64-libgcc/template  | 24 ++++++++++++------------
 4 files changed, 43 insertions(+), 38 deletions(-)

diff --git a/srcpkgs/mingw-w64-crt/template b/srcpkgs/mingw-w64-crt/template
index 5a2e7dd5312..d3aaf8ed360 100644
--- a/srcpkgs/mingw-w64-crt/template
+++ b/srcpkgs/mingw-w64-crt/template
@@ -1,12 +1,12 @@
 # Template build file for 'mingw-w64-crt'
 #
 _shortname=mingw-w64
-pkgname=$_shortname-crt
+pkgname=${_shortname}-crt
 _majversion=1.0
 _snapshot=20110523
-version=${_majversion}.$_snapshot
-revision=1
-distfiles=${SOURCEFORGE_SITE}/$_shortname/$_shortname/$_shortname-v$_majversion-snapshot-$_snapshot.tar.bz2
+version=${_majversion}.${_snapshot}
+revision=2
+distfiles=${SOURCEFORGE_SITE}/${_shortname}/${_shortname}/${_shortname}-v${_majversion}-snapshot-${_snapshot}.tar.bz2
 build_style=custom-install
 short_desc="The mingw-w64 cross-compiler runtime"
 maintainer="davehome <davehome@redthumb.info.tm>"
@@ -41,17 +41,19 @@ fi
 
 strip_cmd=${_mingwprefix}/bin/${_mingwtriplet}-strip
 
+wrksrc=${_shortname}-v${_majversion}-${_snapshot}
+build_wrksrc=${pkgname}
+
 do_build()
 {
 	unset LD_LIBRARY_PATH LDLIBPATH LDFLAGS CPPFLAGS
 	local SAVEDPATH=$PATH
 	export PATH="/opt/bin:/usr/local/bin:/usr/local/sbin:/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin"
 
-	cd ${wrksrc}/../$_shortname-v$_majversion-$_snapshot/$pkgname && \
-		./configure --prefix=${_mingwprefix} --with-sysroot=${_mingwprefix} \
-			--host=${_mingwtriplet} ${_multilib_args} \
-			--bindir=${_mingwprefix}/bin --libdir=${_mingwprefix}/lib \
-			--libexecdir=${_mingwprefix}/lib
+	./configure --prefix=${_mingwprefix} --with-sysroot=${_mingwprefix} \
+		--host=${_mingwtriplet} ${_multilib_args} \
+		--bindir=${_mingwprefix}/bin --libdir=${_mingwprefix}/lib \
+		--libexecdir=${_mingwprefix}/lib
             
 	make ${makejobs}
 	
@@ -65,8 +67,7 @@ do_install()
 	local SAVEDPATH=$PATH
 	export PATH="/opt/bin:/usr/local/bin:/usr/local/sbin:/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin"
 
-	cd ${wrksrc}/../$_shortname-v$_majversion-$_snapshot/$pkgname && \
-		make DESTDIR=${DESTDIR} install
+	make DESTDIR=${DESTDIR} install
 
 	export PATH=$SAVEDPATH
 }
diff --git a/srcpkgs/mingw-w64-gcc/template b/srcpkgs/mingw-w64-gcc/template
index 8819f62ffa5..8b5276f8328 100644
--- a/srcpkgs/mingw-w64-gcc/template
+++ b/srcpkgs/mingw-w64-gcc/template
@@ -3,7 +3,7 @@
 pkgname=mingw-w64-gcc
 _majorver=4.6
 version=${_majorver}.1
-revision=3
+revision=4
 distfiles=http://ftp.gnu.org/pub/gnu/gcc/gcc-$version/gcc-$version.tar.bz2
 build_style=custom-install
 short_desc="The GNU C Compiler (for mingw-w64)"
@@ -35,8 +35,6 @@ Add_dependency build gawk
 Add_dependency full mingw-w64-binutils
 Add_dependency full mingw-w64-headers
 
-wrksrc=gcc-${version}
-
 _mingwprefix=/opt
 
 if [ "${xbps_machine}" = "x86_64" ]; then
@@ -50,6 +48,14 @@ else
 	_multilib_args="--disable-multilib --disable-64bit --enable-32bit"
 fi
 
+wrksrc=gcc-${version}
+build_wrksrc=${pkgname}-build
+
+pre_configure()
+{
+	mkdir -p ${wrksrc}/${build_wrksrc}
+}
+
 do_build()
 {
 	# As specified in the LFS book, disable installing libiberty.
@@ -57,14 +63,11 @@ do_build()
 	# Do not run fixincludes
 	sed -i 's@\./fixinc\.sh@-c true@' ${wrksrc}/gcc/Makefile.in
 
-	mkdir -p ${wrksrc}/../mingw-w64-gcc-${version}-build
-
 	unset LD_LIBRARY_PATH LDLIBPATH LDFLAGS CPPFLAGS
 	local SAVEDPATH=$PATH
 	export PATH="/opt/bin:/usr/local/bin:/usr/local/sbin:/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin"
 
-	cd ${wrksrc}/../mingw-w64-gcc-${version}-build && ${wrksrc}/configure \
-		--prefix=${_mingwprefix} --with-sysroot=${_mingwprefix} \
+	../configure --prefix=${_mingwprefix} --with-sysroot=${_mingwprefix} \
 		--bindir=${_mingwprefix}/bin --target=${_mingwtriplet} \
 		${_multilib_args} --enable-threads=win32 --disable-win32-registry \
 		--enable-version-specific-runtime-libs --enable-__cxa_atexit \
@@ -83,8 +86,7 @@ do_build()
 
 do_install()
 {
-	cd ${wrksrc}/../mingw-w64-gcc-${version}-build && \
-		make DESTDIR=${DESTDIR} ${makejobs} install-gcc
+	make DESTDIR=${DESTDIR} ${makejobs} install-gcc
 
 	# Remove useless manpages
 	rm -rf ${DESTDIR}/${_mingwprefix}/share
diff --git a/srcpkgs/mingw-w64-headers/template b/srcpkgs/mingw-w64-headers/template
index 23990fff960..16ef85601eb 100644
--- a/srcpkgs/mingw-w64-headers/template
+++ b/srcpkgs/mingw-w64-headers/template
@@ -1,12 +1,13 @@
 # Template file for 'mingw-w64-headers'
 _shortname=mingw-w64
-pkgname=$_shortname-headers
+pkgname=${_shortname}-headers
 _majversion=1.0
 _snapshot=20110523
-version=${_majversion}.$_snapshot
-distfiles="${SOURCEFORGE_SITE}/$_shortname/$_shortname/$_shortname-v$_majversion-snapshot-$_snapshot.tar.bz2"
+version=${_majversion}.${_snapshot}
+revision=1
+distfiles="${SOURCEFORGE_SITE}/${_shortname}/${_shortname}/${_shortname}-v${_majversion}-snapshot-${_snapshot}.tar.bz2"
 build_style=custom-install
-short_desc="mingw-w64 headers"
+short_desc="mingw-w64 headers, psdk, directx sdk"
 maintainer="davehome <davehome@redthumb.info.tm>"
 homepage="http://mingw-w64.sourceforge.net/"
 license="Public Domain, BSD, LGPL, ZPL"
@@ -26,10 +27,11 @@ long_desc="
 nostrip=yes
 noverifyrdeps=yes
 
-wrksrc=$_shortname-v$_majversion-$_snapshot/$pkgname
-
 _mingwprefix=/opt
 
+wrksrc=${_shortname}-v${_majversion}-${_snapshot}
+build_wrksrc=${pkgname}
+
 do_build()
 {
 	if [ "${xbps_machine}" = "x86_64" ]; then
diff --git a/srcpkgs/mingw-w64-libgcc/template b/srcpkgs/mingw-w64-libgcc/template
index 17fb82a3e86..cf1be38b9db 100644
--- a/srcpkgs/mingw-w64-libgcc/template
+++ b/srcpkgs/mingw-w64-libgcc/template
@@ -3,6 +3,7 @@
 pkgname=mingw-w64-libgcc
 _majorver=4.6
 version=${_majorver}.1
+revision=1
 distfiles=http://ftp.gnu.org/pub/gnu/gcc/gcc-$version/gcc-$version.tar.bz2
 build_style=custom-install
 short_desc="The GNU C Compiler (libs for mingw-w64)"
@@ -35,8 +36,6 @@ Add_dependency full mingw-w64-headers
 Add_dependency full mingw-w64-gcc
 Add_dependency full mingw-w64-crt
 
-wrksrc=gcc-${version}
-
 _mingwprefix=/opt
 
 if [ "${xbps_machine}" = "x86_64" ]; then
@@ -52,6 +51,14 @@ fi
 
 strip_cmd=${_mingwprefix}/bin/${_mingwtriplet}-strip
 
+wrksrc=gcc-${version}
+build_wrksrc=${pkgname}-build
+
+pre_configure()
+{
+	mkdir -p ${wrksrc}/${build_wrksrc}
+}
+
 do_build()
 {
 	# As specified in the LFS book, disable installing libiberty.
@@ -59,11 +66,6 @@ do_build()
 	# Do not run fixincludes
 	sed -i 's@\./fixinc\.sh@-c true@' ${wrksrc}/gcc/Makefile.in
 
-	[ -d ${wrksrc}/../mingw-w64-gcc-${version}-build ] && \
-		rm -rf ${wrksrc}/../mingw-w64-gcc-${version}-build
-
-	mkdir -p ${wrksrc}/../mingw-w64-gcc-${version}-build
-
 	unset LD_LIBRARY_PATH LDLIBPATH LDFLAGS CPPFLAGS
 	local SAVEDPATH=$PATH
 	export PATH="/opt/bin:/usr/local/bin:/usr/local/sbin:/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin"
@@ -71,8 +73,7 @@ do_build()
 	# This is set just in case
 	export RANLIB=${_mingwprefix}/bin/${_mingwtriplet}-ranlib
 
-	cd ${wrksrc}/../mingw-w64-gcc-${version}-build && ${wrksrc}/configure \
-		--prefix=${_mingwprefix} --with-sysroot=${_mingwprefix} \
+	../configure --prefix=${_mingwprefix} --with-sysroot=${_mingwprefix} \
 		--bindir=${_mingwprefix}/bin --target=${_mingwtriplet} \
 		${_multilib_args} --enable-threads=win32 --disable-win32-registry \
 		--enable-version-specific-runtime-libs --enable-__cxa_atexit \
@@ -97,12 +98,11 @@ do_install()
 
 	# These make targets prevent anything from all-gcc from being installed
 	# Therefore, no conflicts with mingw-w64-gcc package.. perfect.
-	cd ${wrksrc}/../mingw-w64-gcc-${version}-build && \
-		make DESTDIR=${DESTDIR} ${makejobs} installdirs install-target
+	make DESTDIR=${DESTDIR} ${makejobs} installdirs install-target
 
 	# Run ranlib on the *.a libs
 	# The compile/install targets don't do this automagically 
-	cd ${wrksrc}/../mingw-w64-gcc-${version}-build && \
+	cd ${wrksrc}/${build_wrksrc} && \
 		${RANLIB} `find | grep -E "\.a$" | xargs`
 
 	unset RANLIB