# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI=2

inherit eutils flag-o-matic toolchain-funcs libtool texlive-common

DESCRIPTION="ko.TeX is a collection of LaTeX packages made by Koaunghi Un,
Dohyun Kim and Kangsoo Kim to replace HLaTeX and Hangul-ucs.
See http://project.ktug.or.kr/ko.TeX/ for more information."

S="${WORKDIR}"


DEPEND="!dev-tex/bin-kotex
	media-fonts/unfonts
	 media-fonts/unfonts-extra
	 dev-texlive/texlive-basic
	 dev-tex/kotex-dist
	 "

HOMEPAGE="http://www.ktug.or.kr/"
SRC_URI="http://ftp.ktug.or.kr/KTUG/texlive/2012/archive/kotex-utils.tar.xz ->
kotex-utils-20121114.tar.xz
		http://ftp.ktug.or.kr/KTUG/texlive/2012/archive/kotex-utils.source.tar.xz
		-> kotex-utils.source-20121114.tar.xz"

LICENSE="GPL-2"

SLOT="0"
KEYWORDS="~x86 ~ppc ~alpha ~amd64 ~ppc-macos"
IUSE=""

src_unpack() {
  for i in ${A}
  do
  	s="${DISTDIR%}/${i}"
  	xz -dc -- ${s} | tar xof -
  done

}
src_compile() {
	mkdir bin
	cd ${S}/texmf-dist/source/latex/kotex-util/
	gcc -o ${S}/bin/hmakeindex hmakeindex.c
	gcc -o ${S}/bin/hbibtex hbibtex.c
	cd ${S}/texmf-dist/scripts/kotex-util/perl/
	for file in *.pl
	do
		cp $file ${S}/bin/${file%.pl}
	done	
	chmod a+x ${S}/bin/*
	}	

	
src_install() {
	insinto ${TEXMF_DIST_PATH}
	doins -r texmf-dist
	insinto /usr/bin
	doins bin/*
}
