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

github.setup        kornelski pngquant 3.0.3
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision            0

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

description         command-line utility and library for lossy compression of PNG images

long_description    pngquant is a {*}${description}. \
                    The conversion reduces file sizes significantly (often as \
                    much as 70%) and preserves full alpha transparency. \
                    Generated images are compatible with all modern web \
                    browsers, and have better fallback in IE6 than 24-bit PNGs.

homepage            https://pngquant.org/

fetch.type          git

post-extract {
    system -W ${worksrcpath} "git submodule update --init --recursive"
}

depends_lib-append  port:lcms2 \
                    port:libpng \
                    port:zlib
                    
depends_build-append \
                    path:bin/pkg-config:pkgconfig

cargo.offline_cmd   {}

build.pre_args-append \
                    --features=lcms2,cocoa

destroot {
    xinstall -m 0755 \
        ${worksrcpath}/target/[cargo.rust_platform]/release/${name} \
        ${destroot}${prefix}/bin/

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

    set docdir ${prefix}/share/doc/${subport}
    xinstall -d ${destroot}${docdir}
    xinstall -m 644 -W ${worksrcpath} \
        CHANGELOG \
        COPYRIGHT \
        README.md \
        ${destroot}${docdir}
}
