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

# NOTE: for the time being this ebuild only makes the console version of
# the plextor-tool. This is because it should be used as a substitute for
# cdspeed, which doesn't work on all plextor drives (e.g. my SCSI PX-32TS).
#
# If you really need the gnome applet, feel free to include it in this ebuild.
# It should be possible though to build only the command line version!

#inherit eutils

MY_P="${PN}-${PV}.src"
E_CFLAGS="${CFLAGS}"	# that's what it is on my system...

DESCRIPTION="Tool to change the parameters of a Plextor CD-ROM drive"
HOMEPAGE="http://das.ist.org/~georg/"
SRC_URI="http://das.ist.org/~georg/files/${MY_P}.tar.bz2"

#RESTRICT="nomirror"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~x86"  # any other archs?
#IUSE="X gnome"   # maybe if we want the gnome-applet too...
IUSE=""

RDEPEND="virtual/libc"
DEPEND="${RDEPEND}
	>=sys-apps/sed-4"

S=${WORKDIR}/${PN}

src_unpack() {
	unpack ${A}
	cd ${S}/src
	sed -i \
		-e 's:^CFLAGS=:CFLAGS=$(E_CFLAGS) :' \
		Makefile || die "sed Makefile failed"
	echo "CFLAGS added: ${E_CFLAGS}"
}

src_compile() {
	# No autoconf used in this source...
	cd ${S}/src      # go into src directory
	
	# delete the files we want to compile, in case they exist:
	rm -f plextor-tool.8.gz
	rm -f plextor-tool
	
	export E_CFLAGS		# I've no idea if that's okay here,
				# but at least it worked...
	
	make plextor-tool.8.gz || die "make of plextor-tool.8.gz failed"
	make plextor-tool || die "make of plextor-tool failed"
}

src_install() {
	dodoc doc/COPYING doc/INSTALL.linux doc/NEWS doc/README
	dobin src/plextor-tool || die "dobin failed"
	dosym plextor-tool /usr/bin/pxspeed
	doman src/plextor-tool.8.gz
}
