# -*- 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
PortGroup           legacysupport 1.1

# strndup
legacysupport.newest_darwin_requires_legacy 10

github.setup        aqbanking gwenhywfar 5.12.2
github.tarball_from archive
name                gwenhywfar5

checksums           rmd160  a3a5916e91f24d7118d663e25515d4417b4e4ef6 \
                    sha256  64e044f41a4ea59d3c5a7afe77ed8fed3ee850277f9310183bb5fcb0b2329633 \
                    size    1796046

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

description         Utility library required by aqbanking and related software.
long_description    {*}${description}

homepage            https://www.aquamaniac.de/rdm/projects/gwenhywfar

conflicts           gwenhywfar4 gwenhywfar4-gtk gwenhywfar4-gtk3

depends_lib         path:lib/libssl.dylib:openssl \
                    port:libgcrypt \
                    port:gettext \
                    port:libxml2 \
                    path:lib/pkgconfig/gnutls.pc:gnutls

depends_build       port:libtool \
                    port:automake \
                    port:autoconf \
                    port:pkgconfig

configure.args      --enable-static

conflicts-delete  $subport

subport gwenhywfar5-gtk2 {
        depends_lib-append      path:lib/pkgconfig/gtk+-2.0.pc:gtk2
        configure.args-append   --with-guis="gtk2 cpp" --disable-qt4 --disable-qt5
}

subport gwenhywfar5-gtk3 {
        depends_lib-append      path:lib/pkgconfig/gtk+-3.0.pc:gtk3
        configure.args-append   --with-guis="gtk3 cpp" --disable-qt4 --disable-qt5
}

patchfiles          configure.ac.patch

pre-configure {
    system -W ${worksrcpath} "\
        aclocal -Im4 -I${prefix}/share/aclocal && \
        autoconf && \
        autoheader && \
        glibtoolize && \
        automake --add-missing \
        "
}

if {$subport eq $name} {
    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"
}

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

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


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