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

EAPI=4
inherit eutils flag-o-matic toolchain-funcs versionator

MY_P=${PN}-$(replace_all_version_separators "")

DESCRIPTION="A portable viewer of binary files, hexadecimal and disassembler modes."
HOMEPAGE="http://beye.sourceforge.net/"
SRC_URI="mirror://sourceforge/project/beye/biew/${PV}/${MY_P}-src.tar.bz2"
S="${WORKDIR}"/${MY_P}

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="gpm"

RDEPEND="gpm? ( sys-libs/gpm )"
DEPEND="${RDEPEND}"

src_configure() {
	if use gpm; then
		append-flags -DHAVE_MOUSE
	else
		append-flags -UHAVE_MOUSE
	fi
	sed -i -e 's^man/man1/biew.1^share/man/man1/biew.1^' makefile
	econf --datadir=/usr/share/${PN} \
		--cc=$(tc-getCC) \
		--ld=$(tc-getCC) \
		--as=$(tc-getAS) \
		--ranlib=$(tc-getRANLIB)
}

src_compile() {
	emake LDFLAGS="${LDFLAGS}"
}

src_install() {
	emake DESTDIR="${D}" install
	dodoc doc/biew_en.txt doc/release.txt doc/unix.txt
}