# -*- 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

PortSystem        1.0

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


categories        devel net finance
maintainers       {dports @drkp} openmaintainer
platforms         darwin
license           {GPL-2 GPL-3 OpenSSLException}

description       a generic online banking interface
long_description  aqbanking is a generic online banking interface mainly \
                  supporting Home Banking Computer Interface, a standard \
                  used for German checking accounts, but also suitable \
                  for OFX as used in several other countries. \
                  Note that the YellowNet backend (for Suisse Postfinance) \
                  is not available for OS X (upstream only has a Linux binary).

homepage          https://aquamaniac.de/rdm/projects/aqbanking

conflicts         aqbanking5 aqbanking5-devel aqbanking5-gtk aqbanking5-gtk-devel aqbanking5

depends_lib       port:ktoblzcheck \
                  port:libofx \
                  port:gmp \
                  port:gnutls

depends_build     port:pkgconfig

universal_variant no

conflicts-delete  $subport

if {$subport == $name} {
    depends_lib-append  port:gwenhywfar4 \
                        port:qt4-mac
}

subport aqbanking5-devel {
    depends_lib-append  port:gwenhywfar4-devel \
                        port:qt4-mac
}

subport aqbanking5-gtk {
    depends_lib-append  port:gwenhywfar4-gtk
}

subport aqbanking5-gtk-devel {
    depends_lib-append  port:gwenhywfar4-gtk-devel
}

subport aqbanking5-gtk3 {
    depends_lib-append  port:gwenhywfar4-gtk3
}

subport aqbanking5-gtk3-devel {
    depends_lib-append  port:gwenhywfar4-gtk3-devel
}


patchfiles        patch-aqbanking-config.cmake.in.diff

# There isn't currently a newer devel version.
# if {![string match "*-devel" $subport]} {
    version             5.8.2
    revision            1
    # this is specific to this port and *version* for downloading it
    set release         107

    checksums           rmd160  ce40afdce3d98a6cae7e709582399a28f761e97f \
                        sha256  93ca523fe175e72042db75f8c3fc6255ab058cf82caf52796e15f030809fb15e \
                        size    3824997

    if {$subport eq $name} {
        depends_lib-append port:gwenhywfar4
    }
# } else {
    # version             5.7.6beta
    # # this is specific to this port and *version* for downloading it
    # set release         215

    # checksums           rmd160  3923a8b166a7a67c239fa7ddce3196657a04dd39 \
    #                     sha256  f9420d8b34c2eee703a7d26dd71a849700fdb2d7372b7649a3488b5a69f55565
# }



master_sites      https://aquamaniac.de/rdm/attachments/download/${release}/

distname          aqbanking-${version}

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             PKG_CONFIG=${prefix}/bin/pkg-config QTDIR=${prefix}
configure.args-append \
                          --enable-static \
                          --disable-dependency-tracking \
                          --with-backends="aqhbci aqofxconnect aqnone aqpaypal"

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
}

use_parallel_build no

# Allow gtk3 version to replace any gtk2 version if it is installed
# This will conflicts during gnucash upgrade.
if {$subport == "aqbanking5-gtk3" || $subport == "aqbanking5-gtk3-devel"} {
    conflicts-delete aqbanking5-gtk aqbanking5-gtk-devel
    pre-activate {
        if { ![catch {set vers [lindex [registry_active aqbanking5-gtk] 0]}] } {
            registry_deactivate_composite aqbanking5-gtk "" [list ports_nodepcheck 1]
        }
        if { ![catch {set vers [lindex [registry_active aqbanking5-gtk-devel] 0]}] } {
            registry_deactivate_composite aqbanking5-gtk-devel "" [list ports_nodepcheck 1]
        }
    }
}

livecheck.type    regex
livecheck.url     https://aquamaniac.de/rdm/projects/aqbanking/files
if {[string match "*-devel" $subport]} {
    livecheck.regex   aqbanking-(\[0-9.\]*(beta)?)\\.tar
} else {
    livecheck.regex   aqbanking-(\[0-9.\]*)\\.tar
}

