# -*- 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
# kate: backspace-indents true; indent-pasted-text true; indent-width 4; keep-extra-spaces true; remove-trailing-spaces modified; replace-tabs true; replace-tabs-save true; syntax Tcl/Tk; tab-indents true; tab-width 4;
# $Id$

PortSystem        1.0

name              gwenhywfar4
revision          1
# This port offers the latest stable version (also as a gtk subport)
# as well as the latest beta version as gwenhywfar4-devel!

categories        devel net finance
maintainers       mk dports openmaintainer
platforms         darwin
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

conflicts         gwenhywfar gwenhywfar4 gwenhywfar4-devel gwenhywfar4-gtk gwenhywfar4-gtk-devel

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

depends_build     port:libtool \
                  port:pkgconfig

configure.args    --enable-static

conflicts-delete  $subport


# Usually the port has a different version than the *-devel subports
if {$subport eq $name || $subport eq "gwenhywfar4-gtk"} {
    version                 4.14.0
    # this is specific to this port and *version* for downloading it
    set release             01

    checksums               md5     b0662b7c1451b6e6fcad41a00c4db713 \
                            sha1    9e00927c1b3a7d02408caf0e3540619d2e75c069 \
                            rmd160  c092c53e4137b47d5595eb57be6cb9bbb186314d
}

subport gwenhywfar4-gtk {}
subport gwenhywfar4-devel {}
subport gwenhywfar4-gtk-devel {}

patchfiles      patch-shlib-extensions.diff

if {[string match "*-devel" $subport]} {
    version                 4.14.0
    # this is specific to this port and *version* for downloading it
    set release             01

    checksums               md5     b0662b7c1451b6e6fcad41a00c4db713 \
                            sha1    9e00927c1b3a7d02408caf0e3540619d2e75c069 \
                            rmd160  c092c53e4137b47d5595eb57be6cb9bbb186314d
}

if {$subport eq $name || $subport eq "gwenhywfar4-devel"} {
    # the correct way to depend on Qt4:
    PortGroup               qt4 1.0
    configure.args-append   --with-qt4-libs=${qt_libs_dir} \
                            --with-qt4-includes=${qt_includes_dir} \
                            --with-qt4-moc=${qt_moc_cmd} \
                            --with-qt4-uic=${qt_uic_cmd} \
                            --with-guis="qt4 cpp cocoa"
}

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

if {[string match "gwenhywfar4-gtk*" $subport]} {
    depends_lib-append      port:gtk2
    configure.args-append   --with-guis="gtk2 cpp" --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
}

configure.args-append   --disable-dependency-tracking --disable-silent-rules

livecheck.type    regex
livecheck.url     http://www2.aquamaniac.de/sites/download/packages.php?package=01&showall=1
if {[string match "*-devel" $subport]} {
    livecheck.regex   gwenhywfar-(\[0-9.\]*beta)\\.tar
} else {
    livecheck.regex   gwenhywfar-(\[0-9.\]*)\\.tar
}