lalbornoz 340f4c
export CFLAGS="${CFLAGS_PACKAGES}";
lalbornoz 340f4c
parse_with_pkg_name "${2}"							\
lalbornoz 340f4c
	"ftp://ftp.gnu.org/gnu/coreutils/coreutils-${COREUTILS}.tar.xz" ""	\
lalbornoz 340f4c
	"ftp://ftp.gnu.org/gnu/diffutils/diffutils-${DIFFUTILS}.tar.xz" ""	\
lalbornoz 340f4c
	"http://alpha.gnu.org/gnu/findutils/findutils-${FINDUTILS}.tar.gz"	\
lalbornoz 340f4c
		"CFLAGS=${CFLAGS:+${CFLAGS} }-Dendpwent=setpwent"		\
lalbornoz 340f4c
	"ftp://ftp.gnu.org/gnu/patch/patch-${PATCH}.tar.gz" ""			\
lalbornoz 340f4c
	"ftp://ftp.gnu.org/gnu/gawk/gawk-${GAWK}.tar.xz" ""			\
lalbornoz 340f4c
	"ftp://ftp.gnu.org/gnu/bash/bash-${BASH}.tar.gz"			\
lalbornoz 340f4c
		"_configure_extra_args=--without-bash-malloc"			\
lalbornoz 340f4c
	"ftp://ftp.gnu.org/gnu/make/make-${MAKE}.tar.bz2" ""			\
lalbornoz 340f4c
	"ftp://ftp.gnu.org/gnu/grep/grep-${GREP}.tar.xz" ""			\
lalbornoz 340f4c
	"ftp://ftp.gnu.org/gnu/grep/grep-${GREP}.tar.xz" ""			\
lalbornoz 340f4c
	"ftp://ftp.gnu.org/gnu/sed/sed-${SED}.tar.bz2" ""			\
lalbornoz 340f4c
	"ftp://sourceware.org/pub/binutils/snapshots/binutils-${BINUTILS_VERSION}.tar.bz2" "";
lalbornoz 340f4c
lalbornoz 340f4c
if is_build_script_done finished; then
lalbornoz 340f4c
        exit 212;
lalbornoz 340f4c
else
lalbornoz 340f4c
	fetch "${_pkg_url}";
lalbornoz 340f4c
	if [ "${_pkg_name}" = "binutils" ]\
lalbornoz 340f4c
	&& [ "${3}" = "host" ]; then
lalbornoz 340f4c
		_configure_args="--disable-werror,--prefix=${PREFIX},--with-sysroot=${PREFIX_TARGET}";
lalbornoz 340f4c
		_no_config_cache=${_no_prefix:=1}; _target="${TARGET}";
lalbornoz 340f4c
	else
lalbornoz 340f4c
		_configure_args="-C,--host=${HOST_NATIVE},--prefix=";
lalbornoz 340f4c
	fi;
lalbornoz 340f4c
fi;
lalbornoz 340f4c
if ! is_build_script_done extracted; then
lalbornoz 340f4c
	rm_if_exists "${_pkg_subdir}";
lalbornoz 340f4c
	tar -axf "${_pkg_fname}";
lalbornoz 340f4c
	set_build_script_done extracted -patched;
lalbornoz 340f4c
fi;
lalbornoz 340f4c
if ! is_build_script_done patched; then
lalbornoz 340f4c
	patch -d "${_pkg_subdir}" -p1			\
lalbornoz 340f4c
		< "portage/${_pkg_subdir}.midipix.patch";
lalbornoz 340f4c
	set_build_script_done patched -configured;
lalbornoz 340f4c
fi;
lalbornoz 340f4c
if ! is_build_script_done configured; then
lalbornoz 340f4c
	rm_if_exists -c -m "${_pkg_subdir}-build-${_target:-native}";
lalbornoz 340f4c
	[ ${_no_config_cache:-0} -eq 0 ] &&\
lalbornoz 340f4c
		cp -a "../portage/config.cache" .;
lalbornoz 340f4c
	run_configure_with_extra_args			\
lalbornoz 340f4c
		"../${_pkg_subdir}/configure" "${_configure_args}" --target="${TARGET}";
lalbornoz 340f4c
	set_build_script_done configured -built;
lalbornoz 340f4c
else
lalbornoz 340f4c
	cd "${_pkg_subdir}-build-${_target:-native}";
lalbornoz 340f4c
fi;
lalbornoz 340f4c
if ! is_build_script_done built; then
lalbornoz 340f4c
	make ${MAKEFLAGS};
lalbornoz 340f4c
	set_build_script_done built -installed;
lalbornoz 340f4c
fi;
lalbornoz 340f4c
if ! is_build_script_done installed; then
lalbornoz 340f4c
	if [ ${_no_prefix:-0} -eq 0 ]; then
lalbornoz 340f4c
		make ${MAKEFLAGS} DESTDIR="${PREFIX_NATIVE}" install;
lalbornoz 340f4c
	else
lalbornoz 340f4c
		make ${MAKEFLAGS} install;
lalbornoz 340f4c
	fi;
lalbornoz 340f4c
	set_build_script_done installed finished;
lalbornoz 340f4c
fi;
lalbornoz 340f4c
lalbornoz 340f4c
# vim:filetype=sh