# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
# $Id: Portfile 87617 2011-11-28 21:35:26Z ryandesign@macports.org $

PortSystem        1.0

name              kmymoney
version           1.0.5
revision          1

categories        kde finance
maintainers       mk pixilla
platforms         darwin
license           GPL-2+

description       a personal finance manager
long_description  KMyMoney is the personal finance manager for KDE. \
                  It operates in a similar way to Microsoft Money and \
                  Quicken, it supports different account types, categorisation \
                  of expenses and incomes, reconciliation of bank accounts, \
                  QIF import/export, multiple currencies and initial online \
                  banking support. \
                  Released under the GNU General Public License. \
                  KMyMoney is free software. \
                  \
                  NB: This port contains a starter .app which is located in \
                  Applications/MacPorts and ensures that permissions of .kde \
                  directory are set properly to run kmymoney.

homepage          http://kmymoney2.sourceforge.net/index-home.html
master_sites      sourceforge:kmymoney2

livecheck.type    regex
livecheck.url     http://sourceforge.net/projects/kmymoney2/files/KMyMoney/
livecheck.regex   "(1\\.0\\.\\d+)"

distname          kmymoney2-${version}
use_bzip2         yes
checksums         md5     7be750718277ac7c577c574c712f53a2 \
                  sha1    dc496bb95353f0254125faa1de37b1431af06f1e \
                  rmd160  14a468b54335bd753cae0bc531ca648275cd1bfd

depends_build     port:libtool \
                  port:pkgconfig \
                  port:makeicns

depends_lib       port:aqbanking \
                  port:kdelibs3

# aqbanking and kdelibs3 aren't universal
universal_variant no

configure.cppflags-append  "-L${prefix}/lib"
configure.cflags-append    "-L${prefix}/lib"
configure.ldflags-append   "-Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib"
configure.env     MKDIR_P="mkdir -p" \
                  QTDIR=${prefix}/lib/qt3 \
                  HOME=${worksrcpath}
configure.args    --with-qt-dir=${prefix}/lib/qt3 \
                  --without-arts \
                  --enable-mac \
                  --enable-ofxbanking

variant no_ofx description {Without support for OFX} {
    configure.args-delete \
                  --enable-ofxbanking
}

post-configure {
    ln -sf ${prefix}/bin/glibtool ${worksrcpath}/libtool
    xinstall ${filespath}/KMyMoney.applescript ${worksrcpath}
    reinplace "s|__PREFIX__|${prefix}|" ${worksrcpath}/KMyMoney.applescript
}

build.env         HOME=${worksrcpath}

post-destroot {
    system "osacompile -o ${destroot}${applications_dir}/KMyMoney.app ${worksrcpath}/KMyMoney.applescript"
    system "makeicns -in ${worksrcpath}/kmymoney2/hi128-app-kmymoney2.png -out ${destroot}${applications_dir}/KMyMoney.app/Contents/Resources/applet.icns"
}
