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

# inherit eutils

DESCRIPTION="Gofer interpreter including Tcl/Tk interface"
HOMEPAGE="http://www.informatik.uni-ulm.de/pm/projekte/TkGofer/"
SRC_URI="http://www.informatik.uni-ulm.de/pm/projekte/TkGofer/tkg${PV}.tar.gz"
LICENSE="" # none specified
SLOT="0"
KEYWORDS="~x86"
IUSE=""
DEPEND=">=dev-lang/tcl-7.6 >=dev-lang/tk-4.2"
S=${WORKDIR}/${PN}${PV}

src_compile() {
	sed -i 	-e's:/usr/local:/usr:' \
		-e's:LinkFlags="-ltk... -ltcl... :LinkFlags="-ltk -ltcl :' \
		-e's:CompilerFlags=".*":CompilerFlags="-DUSE_READLINE=1":' \
		-e's: -lsocket : -lncurses -lreadline :' \
		-e's:Architecture=".*":Architecture="LINUX":' \
		-e's:LibX11=".*":LibX11="/usr/X11R6/lib":' \
		tkgofer.install || die "sed for tkgofer.install failed"
	./tkgofer.install || die "tkgofer.install failed"
	sed -i	-e"s:${S}:/usr:" \
		-e"s:\\(PreludeDir=\"\\).*\":\\1/usr/lib/${PN}/Preludes\":" \
		-e"s:\\(BinDir=\"\\).*\":\\1/usr/lib/${PN}/Bin\":" \
		-e"s:\\(TclDir=\"\\).*\":\\1/usr/lib/${PN}/Tcl\":" \
		-e"s:\\(HelpDir=\"\\).*\":\\1/usr/share/doc/${PF}\":" \
		Bin/tkgofer || die "sed for tkgofer failed"
}

src_install() {
	insinto /usr/lib/${PN}/Preludes; doins Preludes/*
	insinto /usr/lib/${PN}/Tcl; doins Tcl/*
	exeinto /usr/lib/${PN}/Bin; doexe Bin/*
	dodir /usr/bin
	dosym /usr/lib/${PN}/Bin/tkgofer /usr/bin/tkgofer
	dodoc readme Doc/*
}