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

inherit eutils wxwidgets

MY_P="${P/m/M}"
IUSE="flac mpc unicode"
DESCRIPTION="Musik is a cross platform wxGTK2 based music player"
HOMEPAGE="http://musik.berlios.de/"
SRC_URI="http://download.berlios.de/musik/${MY_P}.tar.bz2"
KEYWORDS="~x86"
SLOT="0"
LICENSE="GPL-2"
S="${WORKDIR}/${MY_P}"
RDEPEND=">=media-libs/id3lib-3.8.3-r1
		>=media-libs/libogg-1.0
		>=media-libs/libvorbis-1.0-r2
		~media-libs/fmod-3.74
		>=x11-libs/gtk+-2.0
		>=x11-libs/wxGTK-2.5.3
		=dev-db/sqlite-2*
		flac? ( >=media-libs/flac-1.1 )
		mpc? ( ~media-libs/libmusepack-1.1-r1 )"
DEPEND="${RDEPEND}
		>=dev-util/cmake-1.6.7"

onoff() {
	useq $1 && echo ON || echo OFF
}

pkg_setup() {
	WX_GTK_VER="2.6"
	if use unicode; then
		need-wxwidgets unicode
	else
		need-wxwidgets gtk2
	fi
}

src_compile() {
	cmake . \
		-D"CMAKE_INSTALL_PREFIX:STRING=/usr" \
		-D"CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE:STRING=${wxconfig}" \
		-D"OPTION_SUPPORT_APE:BOOL=OFF" \
		-D"OPTION_SUPPORT_FLAC:BOOL=$(onoff flac)" \
		-D"OPTION_SUPPORT_MPC:BOOL=$(onoff mpc)" \
		-D"WXWINDOWS_USE_SHARED_LIBS:BOOL=ON" \
		-D"WXWINDOWS_USE_UNICODE:BOOL=$(onoff unicode)" \
		|| die "cmake failed"
	emake || die "make failed"
}

src_install() {
	make DESTDIR=${D} install || die "make install failed"
	rm -f ${D}/usr/share/locale/*/LC_MESSAGES/wxstd.mo
}