# -*- 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           clang_dependency 1.0
PortGroup           cmake 1.0

# keep this in sync with port py-brotli
github.setup        google brotli 1.2.0 v
github.tarball_from archive
revision            0
categories          archivers
maintainers         nomaintainer
license             MIT

description         Brotli compression format

long_description    \
    Brotli is a generic-purpose lossless compression algorithm that is similar \
    in speed with deflate but offers more dense compression. This port installs \
    the bro tool, see also port py-brotli for python modules.

checksums           rmd160  949e0c56045b760b854714f45b0912936a9be53a \
                    sha256  816c96e8e8f193b40151dad7e8ff37b1221d019dbcb9c35cd3fadbfe6477dfec \
                    size    646315

# use cmake-bootstrap to avoid circular dependency:
# cmake depends on curl which depends on brotli.
depends_build-replace \
                    path:bin/cmake:cmake port:cmake-bootstrap
configure.cmd       ${prefix}/libexec/cmake-bootstrap/bin/cmake

# Disable the minimum version check of CMake to allow running cmake-bootstrap
patchfiles-append   patch-disable-cmake-ver-check-CmakeLists.txt.diff

subport ${name}-static {
    description-append  "(static libraries only)"

    long_description    \
        Brotli is a generic-purpose lossless compression algorithm that is similar \
        in speed with deflate but offers more dense compression. This port installs \
        only static libraries.

    configure.args-append   -DBUILD_SHARED_LIBS=OFF

    destroot {
        xinstall -m 0640 {*}[glob ${worksrcpath}/libbrotli*.a] \
            ${destroot}${prefix}/lib/
    }
}

test.run yes

if {${subport} eq ${name}} {
    post-destroot {
        xinstall -m 0640 {*}[glob ${worksrcpath}/docs/*.1] \
            ${destroot}${prefix}/share/man/man1/

        xinstall -m 0640 {*}[glob ${worksrcpath}/docs/*.3] \
            ${destroot}${prefix}/share/man/man3/
    }

    # Exclude pre-release candidates
    github.livecheck.regex  {([0-9.]+)}
} else {
    livecheck.type  none
}
