# -*- 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
# $Id: Portfile 118464 2014-04-02 21:05:27Z ryandesign@macports.org $

PortSystem 1.0

name            optipng
version         0.7.5
categories      graphics
license         zlib
maintainers     ryandesign openmaintainer
description     PNG file optimizer
long_description \
        OptiPNG is a PNG optimizer that recompresses the image files to a \
        smaller size, without losing any information.  The idea has been \
        inspired from pngcrush (http://pmt.sourceforge.net/pngcrush), and \
        is explained in detail in the PNG-Tech article 'A guide to PNG \
        optimization'.  The implementation is carried forward in OptiPNG, \
        which offers a faster execution per trial, and a wider search space.

platforms       darwin

homepage        http://optipng.sourceforge.net/
master_sites    sourceforge:project/${name}/OptiPNG/${name}-${version}

checksums       rmd160  96ffdd9628d03939bb52c98d63c6d1b2cac42313 \
                sha256  74e54b798b012dff8993fb8d90185ca83f18cfa4935f4a93b0bcfc33c849619d

# Doesn't depend on libpng or zlib since it uses its own, modified versions.
# Clear cppflags and ldflags to ensure an already-installed libpng is not used.
configure.cppflags
configure.ldflags

configure.args-append  --mandir=${prefix}/share/man

configure.universal_args-delete --disable-dependency-tracking

variant universal {}

build.args-append   CC="${configure.cc} ${configure.cflags} [get_canonical_archflags cc]"

post-destroot {
    set docdir ${prefix}/share/doc/${subport}
    xinstall -d ${destroot}${docdir}
    xinstall -m 644 -W ${worksrcpath} \
        AUTHORS.txt \
        LICENSE.txt \
        README.txt \
        doc/history.txt \
        doc/todo.txt \
        ${destroot}${docdir}
}

# The default SourceForge livecheck rule doesn't work with OptiPNG.
livecheck.type  regex
livecheck.url   ${homepage}
livecheck.regex "<b>OptiPNG&nbsp;(\\d+\\.\\d+\\.\\d+)</b></font> \\(stable\\)"
