# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $ $

DESCRIPTION="Webpage image gallery creation perl script"
HOMEPAGE="http://bbgallery.sourceforge.net/"
SRC_URI="mirror://sourceforge/bbgallery/${P}.tar.bz2"

SLOT="0"
LICENSE="GPL-2"
KEYWORDS="~x86 ~ppc ~sparc ~alpha ~amd64"
IUSE=""

RDEPEND="dev-lang/perl
	 media-gfx/imagemagick
	 dev-perl/URI
	 dev-perl/libwww-perl
	 dev-perl/HTML-Template
	 dev-perl/HTML-Parser"

DEPEND="sys-apps/sed"

inherit eutils

src_unpack() {
	unpack ${A}
	cd "${S}"
	epatch "${FILESDIR}"/bbgallery-1.2.0-imagemagick.patch
}

src_compile() {
	emake || die "compile failed"
}

src_install() {
	dobin bbgallery || die "dobin failed"
	newbin Contrib/JPG2jpg.pl JPG2jpg || die "newbin failed"

	exeinto /usr/lib/bbgallery
	doexe gimp_scale.pl || die "doexe failed"
	cp -r template ${D}/usr/lib/bbgallery/
	ln -s "${D}"/usr/lib/bbgallery/template/monochrome "${D}"/usr/lib/bbgallery/template/default
	dodoc CHANGELOG CREDITS README
	dohtml doc/*.html
}