# -*- 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                pngcrush
version             1.8.13
categories          graphics
maintainers         {snc @nerdling} openmaintainer
license             zlib
installs_libs       no

description         optimizer for PNG files

long_description    pngcrush reads in a PNG image, and writes it out again, \
                    with the optimum filter_type and zlib_level. It uses \
                    brute force (trying filter_type none, and libpng adaptive \
                    filtering, with compression levels 3 and 9). It does the \
                    most time-consuming method last in case it turns out to \
                    be the best. Optionally, it can remove unwanted chunks or \
                    add gAMA and sRGB chunks.

platforms           darwin freebsd

homepage            http://pmt.sourceforge.net/pngcrush/
master_sites        sourceforge:project/pmt/pngcrush/${version}
use_xz              yes

checksums           rmd160  ff93938e8e6ba8565386efdb51962f16b138a27d \
                    sha256  8fc18bcbcc65146769241e20f9e21e443b0f4538d581250dce89b1e969a30705

patchfiles          patch-Makefile.diff

# cannot use SSE includes on snowleopard, #52419
if {${os.platform} eq "darwin" && ${os.major} <= 10} {
    patchfiles-append   patch-Makefile-snowleopard.diff
}

# attempt to use Makefile-nolib for external libpng, zlib
# currently undefined libpng symbols
#depends_lib-append  port:libpng port:zlib
#patch {
#    file delete ${worksrcpath}/Makefile
#    reinplace s#/usr/local/include#${prefix}/include# ${worksrcpath}/Makefile-nolib
#    reinplace s#/usr/local/lib#${prefix}/lib# ${worksrcpath}/Makefile-nolib
#    file rename ${worksrcpath}/Makefile-nolib ${worksrcpath}/Makefile
#}
#configure.ldflags-append    -L${prefix}/lib

use_configure       no

variant universal {}

build.args-append   CC="${configure.cc} [get_canonical_archflags cc]" \
                    LD="${configure.cc} [get_canonical_archflags ld]"
build.post_args     CFLAGS="-I. -O3 -funroll-loops -fomit-frame-pointer -Wall -Wshadow -DZ_SOLO -DPNGCRUSH_COUNT_COLORS"

destroot {
    xinstall -m 755 -d ${destroot}${prefix}/bin
    xinstall -m 755 ${worksrcpath}/${name} ${destroot}${prefix}/bin
}

livecheck.url       http://sourceforge.net/api/file/index/project-id/1689/rss?path=%2F${name}
livecheck.regex     ${name}-(\\d+(\\.\\d+)+)\\.