# -*- 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.1.0 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
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  cb6909cbcc7c0bb19b8e985dbd7fcbca1b651772 \
                    sha256  10973f4b4199eafa1d5735ef661ddb2ec2f97319ee9fd1824d4aabe08cff5265 \
                    size    512036

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