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

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
# and the svn version as aqbanking5-svn!

# The package number is unique for aqbanking:
set package       03
revision          1

categories        devel net finance
maintainers       mk dports 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          http://www2.aquamaniac.de/sites/aqbanking/index.php

conflicts         aqbanking aqbanking5 aqbanking5-devel aqbanking5-gtk aqbanking5-gtk-devel aqbanking5-svn

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

depends_build     port:pkgconfig

universal_variant no

conflicts-delete  $subport


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

subport           aqbanking5-gtk {
   depends_lib-append  port:gwenhywfar4-gtk
   depends_lib-delete  port:qt4-mac
}

subport           aqbanking5-devel {}
subport           aqbanking5-gtk-devel {}

if {$subport eq $name || $subport eq "aqbanking5-gtk"} {
    version             5.5.1
    revision            2
    # this is specific to this port and *version* for downloading it
    set release         118

    checksums           md5     6069af5cafb97d1f4d3a8a08ba58b876 \
                        sha1    4783890253acf04dddede6d34bf81b8f1c24480d \
                        rmd160  67450fabccb2a403aa79ca97705211eacd107ca9

    if {$subport eq $name} {
        depends_lib-append port:gwenhywfar4
    }
}

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

    checksums           md5     1e263c2382d23839a3211612bd79d80f \
                        sha1    d8f93ad4fa12258b4b628e40133cce2d711d4bfa \
                        rmd160  2b9a62325da5b31f88cf302c6a081477e7730475

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

    if {$subport eq "aqbanking5-devel"} {
        depends_lib-append  port:gwenhywfar4-devel
    } else {
        depends_lib-append  port:gwenhywfar4-gtk-devel
        depends_lib-delete  port:qt4-mac
    }
}

subport aqbanking5-svn {
    fetch.type          svn
    svn.url             http://devel.aqbanking.de/svn/aqbanking/trunk
    # r2384 is indeed identical to 5.0.32beta
    svn.revision        2384
    version             svn-r${svn.revision}
    revision            2
    worksrcdir          trunk

    use_autoreconf      yes
    autoreconf.args     -fvi
    patchfiles-append   patch-Makefile.am.diff

    depends_lib-append  port:gwenhywfar4-devel
}

if {$subport ne "aqbanking5-svn"} {
    master_sites      http://www2.aquamaniac.de/sites/download/download.php?package=${package}&release=${release}&file=01&dummy=
}

distname          aqbanking-${version}
# This is only to be used in case the dist was directly created from git
#distname          aqbanking-${version}.0-git

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

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