# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-misc/emelfm2/emelfm2-0.8.1.ebuild,v 1.5 2012/04/20 20:36:08 tomph Exp $

EAPI=4
inherit eutils multilib toolchain-funcs

DESCRIPTION="A file manager that implements the popular two-pane design"
HOMEPAGE="http://emelfm2.net/"
SRC_URI="http://emelfm2.net/rel/${P}.tar.bz2"

LICENSE="GPL-3"
SLOT="0"
KEYWORDS="amd64 ~ppc ~ppc64 ~sparc x86"
# kernelfam only works on linux ATM - see Makefile.config
IUSE="acl kernelfam nls policykit spell thumbs udisk"
# TODO also depends on magic.h, libmagic (sys-apps/file ?)
# glib >= 2.26 supports dbus interaction, otherwise, >= 2.6 is sufficient
COMMON_DEPEND=">=dev-libs/glib-2.26:2
  >=x11-libs/gtk+-2.6:2
  acl? ( sys-apps/acl )
  policykit? ( sys-auth/polkit )
  spell? ( >=app-text/gtkspell-2.0.14:2 )"
RDEPEND="${COMMON_DEPEND}
  udisk? ( sys-fs/udisks )"
DEPEND="${COMMON_DEPEND}
  dev-util/pkgconfig
  nls? ( sys-devel/gettext )"

RESTRICT="test"

pkg_setup() {
  make_opt() {
    use ${1} && echo "${2}=1" || echo "${2}=0"
  }

  makeopts=(
    STRIP=0
    DOCS_VERSION=1
    $(make_opt nls I18N)
    $(make_opt kernelfam WITH_KERNELFAM)
    $(make_opt spell EDITOR_SPELLCHECK)
    $(make_opt udisk WITH_UDISKS)
    $(make_opt thumbs WITH_THUMBS)
    $(make_opt acl WITH_ACL)
    $(make_opt policykit WITH_POLKIT)
    )
}

src_prepare() {
}

src_compile() {
  tc-export CC
  emake PREFIX="/usr" LIB_DIR="/usr/$(get_libdir)" ${makeopts[@]}
}

src_install() {
  emake PREFIX="${D}/usr" LIB_DIR="${D}/usr/$(get_libdir)" ${makeopts[@]} install
  newicon icons/${PN}_48.png ${PN}.png
}
