# --- T2-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
# 
# T2 SDE: architecture/powerpc64/parse-config
# Copyright (C) 2004 - 2009 The T2 SDE Project
# 
# More information can be found in the files COPYING and README.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- T2-COPYRIGHT-NOTE-END ---

# Note: this is a copy of sparc64/parse-config

alter_arch()
{
	echo_status "Altering arch_{machine,target} to powerpc ..."
	# tweak target and other defines
	arch_machine=${arch_machine/64/}
	arch_target=${arch_target/64/}
	atstage native && arch_build=${arch_build/64/}

	# let the libdir and configure options regenerate
	set_confopt
}

powerpc64_build_32()
{
	# fork, make a copy of the variables, so we fully restore to normal
	(
	local _arch_machine=$arch_machine _arch_target=$arch_target _arch_build=$arch_build
	alter_arch
	arch_sizeof_long=4 arch_sizeof_char_p=4
        var_append GCC_WRAPPER_INSERT ' ' '-m32'
        var_append CPP_WRAPPER_INSERT ' ' '-m32'
	build_package $pkg $pkg.conf
	)

	# let it continue to build just normal, as if nothing happened
	make distclean
}

case $pkg in
	util-linux|e2fsprogs)
		# we need a 32bit lib for yaboot :-(
		hook_add preconf 1 "powerpc64_build_32"
		;;
esac
