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

EAPI="2"
inherit qt4 cmake-utils multilib

DESCRIPTION="Qt lightScribe - OS labeler for Linux"
HOMEPAGE="http://sourceforge.net/projects/qlscribe/"
SRC_URI="mirror://sourceforge/${PN}/${PF}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="debug multilib"

DEPEND="x11-libs/qt-gui:4
	app-cdr/liblightscribe
	amd64? ( app-emulation/emul-linux-x86-baselibs )"
RDEPEND="${DEPEND}
	dev-util/cmake[qt4]"

mycmakeargs="-DDBUS_SYSTEM_POLICY_DIR=/etc/dbus-1/system.d
            -DDBUS_SYSTEM_SERVICE_DIR=/usr/share/dbus-1/services"

src_prepare() {
	epatch "${FILESDIR}"/${P}-gentoo-3.patch  || die "Error applying patch"
}

src_compile() {
	# hack in Library path cant use get_libdir as it would change vars used in the build
	# format not match
	# so add both dirs for lib32 (amd64) and lib (x86)
	export LD_LIBRARY_PATH="/usr/lib32/libstdc++-v3:/usr/lib/libstdc++-v3:${LD_LIBRARY_PATH}"
	cmake-utils_src_make

}

src_install() {
	cmake-utils_src_install

	has_multilib_profile && ABI="x86"
	make_wrapper lscribed-wrapper "/usr/sbin/lscribed" /usr/bin /usr/$(get_libdir)/libstdc++-v3
	dosed "s%sbin/lscribed%bin/lscribed-wrapper%" /usr/share/dbus-1/services/org.lightscribe.Manager.service
}