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

name                wget2
version             2.2.0
revision            0

homepage            https://gitlab.com/gnuwget/wget2

description         \
    GNU Wget2 is the successor of GNU Wget, a file and recursive website \
    downloader.

long_description    {*}${description}.

categories          net www
license             GPL-3+
maintainers         {gmail.com:herby.gillot @herbygillot} \
                    openmaintainer

master_sites        gnu:wget
use_lzip            yes

checksums           rmd160  1195a2fc4e3cc229d1b95c04db0b62afe446b89a \
                    sha256  ffa5e49db90c9ddc0c830b66e473630c679b1b0a26a53d24981d4f0efa1c90b6 \
                    size    2214840

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

depends_lib-append  port:brotli \
                    port:bzip2 \
                    port:gettext-runtime \
                    port:gpgme \
                    port:libhsts \
                    port:libidn2 \
                    port:libmicrohttpd \
                    port:libpsl \
                    port:lzlib \
                    port:lzma \
                    port:nghttp2 \
                    port:pcre2 \
                    port:zlib \
                    port:zstd

# https://trac.macports.org/wiki/WimplicitFunctionDeclaration#strchr
configure.checks.implicit_function_declaration.whitelist-append strchr

configure.args-append \
                    --disable-doc \
                    --disable-silent-rules \
                    --with-plugin-support

configure.args-append \
                    --with-brotlidec \
                    --with-bzip2 \
                    --with-gpgme \
                    --with-gpgme-prefix=${prefix} \
                    --with-libhsts \
                    --with-libidn2 \
                    --with-libmicrohttpd \
                    --with-libnghttp2 \
                    --with-libpcre2 \
                    --with-libpsl \
                    --with-lzip \
                    --with-lzma \
                    --with-zlib \
                    --with-zstd \
                    --without-ssl

compiler.blacklist-append \
                    {*gcc-[34].*}

variant gnutls conflicts ssl description {SSL support via GnuTLS} {
    configure.args-replace \
                    --without-ssl --with-ssl=gnutls

    depends_lib-append \
                    path:lib/pkgconfig/gnutls.pc:gnutls
}

variant ssl conflicts gnutls description {SSL support via OpenSSL} {
    PortGroup       openssl 1.0

    configure.args-replace \
                    --without-ssl --with-ssl=openssl
}

if {![variant_isset ssl]} {
    default_variants +gnutls
}

post-destroot {
    xinstall -m 0444 ${worksrcpath}/docs/man/man1/${name}.1 \
        ${destroot}${prefix}/share/man/man1/
}

livecheck.distname  ${name}
