# Copyright 2012 Funtoo Technologies
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=3

inherit eutils cmake-utils games

DESCRIPTION="An open source reimplementation of the role playing game The Elder Scrolls III: Morrowind"
HOMEPAGE="http://openmw.org/"
SRC_URI="http://${PN}.googlecode.com/files/${P}-source.tar.bz2"
LICENSE="GPL-3"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="audiere ffmpeg +mpg123"

RDEPEND=">=dev-games/ogre-1.7.0[cg,ois]
	dev-games/ois
	media-gfx/nvidia-cg-toolkit
	media-libs/freetype:2
	media-libs/openal
	sci-physics/bullet
	>=x11-libs/qt-gui-4.7.0:4
	audiere? ( media-libs/audiere )
	ffmpeg? ( media-video/ffmpeg )
	mpg123? ( media-libs/libsndfile
		media-sound/mpg123 )"
DEPEND="${RDEPEND}
	>=dev-libs/boost-1.45.0
	dev-util/pkgconfig"

S=${WORKDIR}/${P}-source

src_prepare() {
	epatch "${FILESDIR}"/${P}-cmake.patch

	sed \
		-e "s#globalPath(\"/etc/\")#globalPath(\"${GAMES_SYSCONFDIR}\")#" \
		-i components/files/linuxpath.cpp || die
}

src_configure() {
	local mycmakeargs=(
		-DBINDIR="${GAMES_BINDIR}"
		-DDATADIR="${GAMES_DATADIR}"/${PN}
		-DSYSCONFDIR="${GAMES_SYSCONFDIR}"/${PN}
		$(cmake-utils_use audiere USE_AUDIERE)
		$(cmake-utils_use ffmpeg USE_FFMPEG)
		$(cmake-utils_use mpg123 USE_MPG123)
	)

	cmake-utils_src_configure
}

src_install() {
	cmake-utils_src_install
	dodoc "${S}"/readme.txt
	prepgamesdirs
}