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

epoch                   1
github.setup            autotrace autotrace 0.31.10
revision                1
checksums               rmd160  f617e82d09dcb080a37e732b4debea082296ed20 \
                        sha256  14627f93bb02fe14eeda0163434a7cb9b1f316c0f1727f0bdf6323a831ffe80d \
                        size    924682

categories              graphics
maintainers             {ryandesign @ryandesign} openmaintainer
license                 GPL-2+ LGPL-2.1+

description             Convert bitmaps to vector graphics

long_description        The aim of the AutoTrace project is the development of a \
                        freely available application with a functionality similar \
                        to CorelTrace or Adobe Streamline.

github.tarball_from     archive

# No pre-generated configure script provided.
use_autoreconf          yes
autoreconf.cmd          ./autogen.sh
autoreconf.args

depends_build           port:autoconf \
                        port:automake \
                        port:gettext \
                        port:intltool \
                        port:libtool \
                        path:bin/pkg-config:pkgconfig

depends_lib             port:gettext-runtime \
                        path:lib/pkgconfig/glib-2.0.pc:glib2 \
                        port:ImageMagick \
                        port:libpng \
                        port:pstoedit

patchfiles              no-ming.patch

post-patch {
    # https://github.com/autotrace/autotrace/issues/136
    set v [split ${version} .]
    set re [list \
        "/^AC_INIT/s|\[0-9.\]+|${version}|" \
        "/^MAJOR_VERSION=/s|\[0-9\]+|[lindex ${v} 0]|" \
        "/^MINOR_VERSION=/s|\[0-9\]+|[lindex ${v} 1]|" \
        "/^MICRO_VERSION=/s|\[0-9\]+|[lindex ${v} 2]|" \
    ]
    reinplace -E [join ${re} {;}] ${worksrcpath}/configure.ac
}

configure.args          --with-magick=ImageMagick \
                        --with-png \
                        --with-pstoedit

post-destroot {
    set docdir ${prefix}/share/doc/${subport}
    xinstall -m 0755 -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} AUTHORS COPYING COPYING.LIB \
        FAQ README.md THANKS TODO doc/HACKING doc/despeckle.txt \
        ${destroot}${docdir}
}