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

perl5.branches      5.28 5.30 5.32 5.34
perl5.setup         IO-Compress-Brotli 0.019
revision            0
license             {Artistic-1 GPL}
maintainers         {devans @dbevans} openmaintainer
description         IO::Compress::Brotli - Read/Write Brotli buffers/streams
long_description    {*}${description}

checksums           rmd160  f519d8b2bcfef711d5e3908701cc1065850723ed \
                    sha256  37f40dd7cee44acea26f2f763a773e61d4ec223305ddeeca4612443cbf288fbf \
                    size    7814536

if {${perl5.major} != ""} {
    depends_build-append \
                    port:p${perl5.major}-alien-cmake3

    depends_lib-append \
                    port:p${perl5.major}-file-slurper \
                    port:p${perl5.major}-getopt-long \
                    port:p${perl5.major}-time-hires

    patchfiles      Makefile.PL.patch

    post-patch {
        set re [list \
            "s|@CC@|${configure.cc}|g" \
            "s|@CFLAGS@|${configure.cflags} [get_canonical_archflags cc]|g" \
            "s|@LDFLAGS@|${configure.ldflags} [get_canonical_archflags ld]|g" \
        ]
        reinplace [join ${re} {;}] ${worksrcpath}/Makefile.PL
    }

    # Makefile.PL uses Alien-cmake3 to use cmake and then make (without
    # specifying multiple make jobs) to build a bundled copy of brotli.
    # If MacPorts uses a parallel build, multiple cmake processes start
    # simultaneously and cause each other to fail.
    # https://github.com/timlegge/perl-IO-Compress-Brotli/issues/3
    # These problems and others would go away if we could use the MacPorts
    # brotli port but we can't yet.
    # https://github.com/timlegge/perl-IO-Compress-Brotli/issues/5
    use_parallel_build \
                    no
}
