# SliTaz package receipt.

PACKAGE="h8300-gcc"
SOURCE="gcc"
VERSION="4.4.4"
CATEGORY="development"
SHORT_DESC="gcc targeting the H8/300"
MAINTAINER="rcx@zoominternet.net"
DEPENDS="h8300-binutils glibc-base gmp mpfr"
BUILD_DEPENDS="slitaz-toolchain gawk flex gmp gmp-dev mpfr mpfr-dev h8300-binutils"
TARBALL="$SOURCE-$VERSION.tar.bz2"
WEB_SITE="http://www.gnu.org/software/gcc/"
WGET_URL="$GNU_MIRROR/$SOURCE/$SOURCE-$VERSION/$TARBALL"

# Configuration only needs included if we're in the build/wok environment
if [ -e $WOK/h8300-toolchain/stuff/h8300.conf ] ; then
	. $WOK/h8300-toolchain/stuff/h8300.conf
fi

# Rules to configure and make the package.
compile_rules()
{
	rm -f -r $src/libssp $src/libstdc++-v3 $src/binutils
	mkdir -p $SOURCE-$VERSION-build
	cd $SOURCE-$VERSION-build
	$src/configure \
		--target=$H8300_TARGET \
		--enable-languages=c,c++ \
		--disable-nls \
		--enable-target-optspace \
		--enable-obsolete \
		--prefix=/usr \
		--libexecdir=/usr/lib \
		--infodir=/usr/share/info \
		--mandir=/usr/share/man \
		$CONFIGURE_ARGS &&
	make $MAKEFLAGS &&
	make DESTDIR=$src/_pkg install
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
	mkdir -p $fs/usr
	cp -a $_pkg/usr/bin $fs/usr
	cp -a $_pkg/usr/include $fs/usr
	# do not need to copy lib/libiberty.a
	mkdir -p $fs/usr/lib
	cp -a $_pkg/usr/lib/gcc $fs/usr/lib
	# Do not include the h8* variant folders; create separate packages if they are needed
	rm -r -f $fs/usr/lib/gcc/$H8300_TARGET/$VERSION/h8300h
	rm -r -f $fs/usr/lib/gcc/$H8300_TARGET/$VERSION/h8300s
	rm -r -f $fs/usr/lib/gcc/$H8300_TARGET/$VERSION/h8sx
}

# Rules to clean the package
clean_wok()
{
	rm -r $SOURCE-$VERSION-build
}