# -*- 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.49.0
revision            0

categories          devel
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
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

# Deleloper 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 Debian archive.
# master_sites        https://download.filezilla-project.org/libfilezilla/

master_sites        https://deb.debian.org/debian/pool/main/libf/libfilezilla/

use_xz              yes
distname            ${name}_${version}.orig

checksums           rmd160  483bf576f3595851ffc2f109824bc1e3de505534 \
                    sha256  79ff30e5124068c116c8dc8fc4581922afa2d3720f7b6bee9c8f8fe419617488 \
                    size    554000

worksrcdir          ${name}-${version}

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\\.bz2
