# -*- 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
PortGroup           github 1.0

github.setup        aqbanking aqbanking 6.9.2
github.tarball_from archive
name                aqbanking6

checksums           rmd160  28dab8ceaded5a3b97445b33a7a1073ebf134fb8 \
                    sha256  14a854ebed9d31c8f3c4a815ea9d5433d9e75e3eb3a7bf7acd4fa7e292b01586 \
                    size    3303002

categories          devel net finance
maintainers         {dports @drkp} openmaintainer
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://www.aquamaniac.de/rdm/projects/aqbanking

conflicts           aqbanking6 aqbanking6-gtk2 aqbanking6-gtk3 \
                    aqbanking5 aqbanking5-gtk aqbanking5-gtk3

depends_lib         port:ktoblzcheck \
                    port:libofx \
                    port:gmp \
                    path:lib/pkgconfig/gnutls.pc:gnutls

depends_build       port:pkgconfig

universal_variant no

patchfiles patch-src-plugins-backends-Makefile.am.diff

conflicts-delete  $subport

use_autoreconf     yes

# generate prerequisites for compilation, ignore errors
pre-build {
        system -W ${worksrcpath} "make typedefs || true"
        system -W ${worksrcpath} "make typefiles || true"
        system -W ${worksrcpath} "make types || true "
}

if {$subport == $name} {
    PortGroup qt4 1.0
    depends_lib-append  port:gwenhywfar5 \
                        port:qt4-mac
}

subport aqbanking6-gtk2 {
    depends_lib-append  port:gwenhywfar5-gtk2
}

subport aqbanking6-gtk3 {
    depends_lib-append  port:gwenhywfar5-gtk3
}

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"

# Makefiles not suitable for parallel build
use_parallel_build no

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

# allow installation to replace the equivalent subport of aqbanking5,
# to support migrating dependent ports to a new version
if {$subport == $name} {
    conflicts-delete aqbanking5
    pre-activate {
        if { ![catch {set vers [lindex [registry_active aqbanking5] 0]}] } {
            registry_deactivate_composite aqbanking5 "" [list ports_nodepcheck 1]
        }
    }
}
if {$subport == "aqbanking6-gtk"} {
    conflicts-delete aqbanking5-gtk
    pre-activate {
        if { ![catch {set vers [lindex [registry_active aqbanking5-gtk] 0]}] } {
            registry_deactivate_composite aqbanking5-gtk "" [list ports_nodepcheck 1]
        }
    }
}
if {$subport == "aqbanking6-gtk3"} {
    conflicts-delete aqbanking5-gtk3
    pre-activate {
        if { ![catch {set vers [lindex [registry_active aqbanking5-gtk3] 0]}] } {
            registry_deactivate_composite aqbanking5-gtk3 "" [list ports_nodepcheck 1]
        }
    }
}
