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

github.setup        synfig synfig 1.4.5 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
categories          graphics
maintainers         {ryandesign @ryandesign} openmaintainer
license             GPL-2+

homepage            https://www.synfig.org
master_sites        sourceforge:project/synfig/stable/${version}/source/
dist_subdir         ${subport}
distname            ${subport}-${version}

compiler.cxx_standard \
                    2011

if {${subport} in [list ${name} ${name}studio]} {
    depends_build       port:intltool \
                        path:bin/pkg-config:pkgconfig

    # checking for XML::Parser... configure: error: XML::Parser perl module is required for intltool
    # https://bugs.launchpad.net/intltool/+bug/1197875
    # https://github.com/synfig/synfig/issues/794
    use_autoreconf      yes
    autoreconf.args     -fvi
    configure.checks.implicit_function_declaration.whitelist-append strchr
}

if {${subport} eq ${name}} {
    revision            0
    checksums           rmd160  d8bc8a38524e657fcdc24edf5d7c7b4278920ab9 \
                        sha256  51a395f7dceb2ec51721043eb9b9f7149477a3399d92d624eef266f155521bc1 \
                        size    5219077

    description         vector-based 2-D animation package

    long_description    Synfig is a {*}${description}. It is designed to be \
                        capable of producing feature-film-quality animation. \
                        It eliminates the need for tweening, preventing the \
                        need to hand-draw each frame. Synfig features spatial \
                        and temporal resolution independence (sharp and smooth \
                        at any resolution or framerate), high dynamic range \
                        images, and a flexible plugin system.

    depends_lib         path:lib/pkgconfig/cairo.pc:cairo \
                        port:ETL \
                        path:lib/libavcodec.dylib:ffmpeg \
                        port:freetype \
                        port:fontconfig \
                        port:gettext \
                        port:ImageMagick \
                        path:include/turbojpeg.h:libjpeg-turbo \
                        port:libdv \
                        port:libiconv \
                        port:libmng \
                        port:libpng \
                        port:libsigcxx2 \
                        port:libtool \
                        port:libxmlxx2 \
                        port:mlt \
                        port:openexr \
                        path:lib/pkgconfig/pango.pc:pango

    configure.args      --with-boost=[boost::install_area]

    post-destroot {
        set docdir ${destroot}${prefix}/share/doc/${subport}
        xinstall -d ${docdir}
        xinstall -m 0644 -W ${worksrcpath} \
            ABOUT-NLS \
            AUTHORS \
            COPYING \
            ChangeLog \
            ChangeLog.old \
            NEWS \
            README \
            TODO \
            ${docdir}
    }

    github.livecheck.regex  {(\d+\.\d*[02468](?:\.\d+)*)}
} else {
    livecheck.type      none
}

subport ETL {
    revision            0
    checksums           rmd160  5c8e64aa6a2d520ddcc56a2fc1b751d37ecded41 \
                        sha256  fbd0328296bfe12f52d53389740c0f3fea5005152b9da43f52ac1f5ab6e22c73 \
                        size    277975

    supported_archs     noarch
    platforms           any

    description         multi-platform class and template library

    long_description    ETL is a {*}${description} designed to add new datatypes \
                        and functions which combine well with the existing \
                        types and functions from the C++ Standard Template \
                        Library (STL).

    depends_lib-append  path:lib/pkgconfig/glibmm-2.68.pc:glibmm

    # ETL-config is a wrapper around pkg-config
    depends_lib-append  path:bin/pkg-config:pkgconfig

    post-patch {
        # https://github.com/synfig/synfig/issues/3371
        reinplace -W ${worksrcpath}/config "1s|^#!/usr/bin/sh|#!/bin/sh|" \
            config.guess config.sub install-sh
    }

    post-destroot {
        set docdir ${destroot}${prefix}/share/doc/${subport}
        xinstall -d ${docdir}
        xinstall -m 0644 -W ${worksrcpath} \
            AUTHORS \
            ChangeLog \
            COPYING \
            NEWS \
            README \
            ${docdir}
    }
}

subport synfigstudio {
    revision            0
    checksums           rmd160  ca2b9366cf25e2e17391145336208b4b3c25b767 \
                        sha256  82a2d8a6d03f72443f8ddeb9d7ea38214313c1ac56f4ddba3e872464e8f91568 \
                        size    6870810

    description         synfig animation studio

    long_description    Synfig Studio is the animation studio for synfig and \
                        provides a GUI to create Synfig animations which are \
                        saved in Synfig .sif or .sifz format.

    depends_lib         port:ETL \
                        port:gtkmm3 \
                        port:synfig

    configure.args      --disable-jack

    post-destroot {
        foreach f [glob ${destroot}${prefix}/share/mime/*] {
            if {[file isfile ${f}]} {
                delete ${f}
            }
        }

        set docdir ${destroot}${prefix}/share/doc/${subport}
        xinstall -d ${docdir}
        xinstall -m 0644 -W ${worksrcpath} \
            ABOUT-NLS \
            AUTHORS \
            COPYING \
            ChangeLog \
            ChangeLog.old \
            NEWS \
            README \
            TODO \
            ${docdir}
    }

    post-activate {
        system "${prefix}/bin/update-mime-database ${prefix}/share/mime"
    }

    post-deactivate {
        system "${prefix}/bin/update-mime-database ${prefix}/share/mime"
    }
}
