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

# AT_SYMLINK_NOFOLLOW
legacysupport.newest_darwin_requires_legacy 13

name                libfilezilla
version             0.55.4
revision            0

categories          devel
maintainers         nomaintainer
license             GPL-2+

description         Shared component for Filezilla programs

long_description    Small and modern C++ library, offering some basic \
                    functionality to build high-performing, \
                    platform-independent programs.

homepage            https://lib.filezilla-project.org

# Developer site seems to generate one-time link now, and direct download
# from there does not work anymore, it redirects to an html page. For now,
# use the source from Arch Linux archive.
# master_sites        https://download.filezilla-project.org/libfilezilla

master_sites        https://sources.archlinux.org/other/libfilezilla

use_xz              yes

checksums           rmd160  84628db6c3d1240587cfcf4e3dc73fe1ecc57e0a \
                    sha256  cbc4199df26ede57e01c621ffbeb5bfce8330c67230621ef2aca553bb3f505ee \
                    size    570276

patchfiles-append   patch-util.diff

# unix/poller.cpp:45:11: error: use of undeclared identifier 'errno'
patchfiles-append   patch-errno.diff

depends_build-append \
                    port:gettext \
                    path:bin/perl:perl5 \
                    path:bin/pkg-config:pkgconfig

depends_lib-append  port:gmp \
                    path:lib/pkgconfig/gnutls.pc:gnutls \
                    port:libiconv \
                    port:nettle

depends_test-append port:cppunit

compiler.cxx_standard   2017
compiler.thread_local_storage   yes

configure.env-append \
                    DX_PERL=${prefix}/bin/perl

configure.args-append \
                    --disable-doxygen-doc

platform darwin {
    if {${os.major} < 11} {
        # process.cpp: error: invalid conversion from 'uint32_t*' {aka 'unsigned int*'} to 'UInt32*' {aka 'long unsigned int*'} [-fpermissive]
        configure.cxxflags-append \
                    -fpermissive
    }
}

if {[string match *gcc* ${configure.compiler}]} {
    configure.ldflags-append \
                    -latomic
}
if {[string match *gcc-7* ${configure.compiler}]} {
    patchfiles-append   patch-gcc7.diff
}

test.run            yes
test.target         check

livecheck.type      regex
livecheck.url       ${master_sites}
livecheck.regex     ${name}-(\[0-9.\]+)\\.tar\\.xz
