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

# this ebuild is copied from the ardour2 pro-audio-overlay ebuild.

DESCRIPTION="Ardourd is a proof-of-concept libardour-based record/playback, song, and mixer engine daemon as part of a modular audio production system"
HOMEPAGE="http://ayyi.org"
SRC_URI="http://ayyi.org/files/${P}.tar.bz2"

LICENSE="GPL"
SLOT="0"
KEYWORDS="~x86"
IUSE="debug sse vst"

RDEPEND="
	>=dev-util/pkgconfig-0.8.0
	>=media-libs/liblrdf-0.4.0
	>=media-libs/raptor-1.2.0
	>=media-libs/ladspa-sdk-1.12
	>=media-libs/libsamplerate-0.0.14
	media-libs/liblo
	>=media-libs/libsndfile-1.0.18
	>=dev-libs/libxml2-2.5.7
	dev-libs/libxslt
	>=dev-libs/glib-2.10
	>=dev-libs/boost-1.33.1
	>=media-sound/jack-audio-connection-kit-0.119.0
	>=x11-libs/gtk+-2.10
	>=media-libs/taglib-1.5.0
	sys-apps/dbus
	dev-libs/dbus-glib
	vst? ( >=app-emulation/wine-1.0 )"
DEPEND="${RDEPEND}
	sys-devel/bison
	sys-devel/autoconf
	sys-devel/automake
	>=dev-util/pkgconfig-0.8.0"

src_compile() {

	local myconf="--freedesktop --prefix=/usr"
		use debug     && myconf="$myconf --debug"
		use vst       && myconf="$myconf --vst"
	if use sse || use altivec ;then
		myconf="$myconf --fpu-optimization"
	fi
	#	use lv2       && myconf="$myconf --lv2"

	einfo "./waf $myconf" # show configure options
	./waf configure $myconf || die "failed to configure"
	./waf build ${MAKEOPTS/-s/} || die "failed to build"
}

src_install() {
	#scons DESTDIR="${D}" install || die "make install failed"
	#if use vst;then
	#	newbin vst/ardourd_vst.exe.so ardourd.exe.so
	#	newbin vst/ardourd_vst ardourd
	#	fperms 644 /usr/bin/ardourd.exe.so
	#	sed -i -e'/^appname/'i"export\ LD_LIBRARY_PATH=\"/usr/lib/ardour2/:\$LD_LIBRARY_PATH\"" ${D}/usr/bin/ardourd

	#	# fix ardour file_name
	#	sed -i -e 's@ardour_vst@ardour2@' ${D}/usr/bin/ardourd
	#else
	#	# fix ardour path
	#	sed -i -e 's:'${D}'::g' ${D}/usr/bin/ardourd
	#fi

	./waf --destdir="${D}" install || die "install failed"
}

agree_vst() {
	local ANSWER="no"
	einfo "Are you building Ardour for personal use (rather than distribution to others)? [yes/no]: "
	read ANSWER
	if [ "$ANSWER" == "y" ] || [ "$ANSWER" == "yes" ];then
		einfo "OK, VST support will be enabled"
		# delete question from SConscript
		#sed -i -e '/Make\ sure\ they/,/print\ \"OK,\ VST\ support\ will\ be\ enabled\"/d' "${S}"/SConstruct || die " failed to del vst question"
	else
		eerror "You cannot build Ardour with VST support for distribution to others"
		eerror "It is a violation of several different licenses"

		eerror "use: USE=-vst emerge $P"
		eerror "to disable vst support"
		return 1
	fi
}
