# -*- 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 90490 2012-03-07 09:07:31Z mk@macports.org $

PortSystem        1.0

name              gwenhywfar4
version           4.3.2

# this is specific to this port and *version* for downloading it
set release       66
platforms         darwin

categories        devel net finance
maintainers       mk dports openmaintainer
license           {LGPL-2.1 OpenSSLException}

description       a utility library required by aqbanking and related software
long_description  ${description}

homepage          http://www2.aquamaniac.de/sites/aqbanking/index.php
master_sites      http://www2.aquamaniac.de/sites/download/download.php?package=01&release=${release}&file=01&dummy=
distname          gwenhywfar-${version}

checksums         md5     6fcd39f64e6357321cffeaca470fbe52 \
                  sha1    44061e18b5b516529c62711475b0a5272daa74f0 \
                  rmd160  2fbd8e68716b2ee8a9a4429d1f4f71424467dd0f

conflicts         gwenhywfar

depends_lib       port:openssl \
                  port:libgcrypt \
                  port:gettext \
                  port:libxml2 \
                  port:gnutls

depends_build     port:libtool \
                  port:pkgconfig

configure.args    --enable-static

patch.dir         ${workpath}/${distname}
patch.pre_args    -p1

if {$subport == $name} {
    conflicts-append        gwenhywfar4-gtk
    configure.args-append   --with-qt4-libs=${prefix}/lib \
                            --with-qt4-includes=${prefix}/include \
                            --with-qt4-moc=${prefix}/bin/moc \
                            --with-qt4-uic=${prefix}/bin/uic \
                            --with-guis=qt4
    depends_lib-append      path:bin/qmake:qt4-mac
}

subport gwenhywfar4-gtk {
    conflicts-append        gwenhywfar4
    depends_lib-append      port:gtk2
    configure.args-append   --with-guis=gtk2 --disable-qt4

    # Allow gwenhywfar4-gtk and aqbanking5-gtk to replace the old
    # gwenhywfar and aqbanking by deactivating them if installed. This
    # allows gnucash to switch versions without conflicts.
    #
    # kmymoney still depends on gwenhywfar/aqbanking, so don't
    # deactivate if it's installed.
    conflicts-delete        gwenhywfar
    pre-activate {
        if {![catch {set vers [lindex [registry_active gwenhywfar] 0]}]} {
            if {![catch {set vers [lindex [registry_active kmymoney] 0]}]} {
                ui_error "${subport} conflicts with gwenhywfar and aqbanking. Please uninstall the ports that depend on them."
                return -code error "conflict"
            }
            if {![catch {set vers [lindex [registry_active aqbanking] 0]}]} {
                registry_deactivate_composite aqbanking "" [list ports_nodepcheck 1]
            }
            registry_deactivate_composite gwenhywfar "" [list ports_nodepcheck 1]
        }
    }
}

variant enable_local_install description "Enable local installation mode (plugins, data, locale and config are located relatively to the binary)" {
    configure.args-append   --enable-local-install 
}

variant debug description "Enable debug." {
    configure.args-append --enable-debug
}

livecheck.type    regex
livecheck.url     http://www2.aquamaniac.de/sites/download/packages.php?package=01&showall=1
livecheck.regex   gwenhywfar-(\[0-9.\]*)\\.tar
