# -*- 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            gimp-gap
conflicts       gimp-gap-devel
version         2.6.0
revision        9
license         GPL-2+
set branch      [join [lrange [split ${version} .] 0 1] .]
set ffmpeg-vers 0.5.6
set ffmpeg-name ffmpeg-${ffmpeg-vers}
categories      graphics
maintainers     {devans @dbevans}

description     The Gimp Animation Package.

long_description \
                GIMP-GAP, the GIMP Animation Package, is a collection of plug-ins to \
                extend GIMP with capabilities to edit and create animations as \
                sequences of single frames.

universal_variant  no
use_parallel_build no

homepage        http://www.gimp.org/
master_sites    gimp:gimp/plug-ins/v${branch}/gap/:gap \
                http://www.ffmpeg.org/releases/:ffmpeg

use_bzip2       yes

distfiles       ${distname}${extract.suffix}:gap \
                ${ffmpeg-name}${extract.suffix}:ffmpeg

checksums       ${distname}${extract.suffix} \
                    md5     249ed829de8b78675c0fe4ef4212089f \
                    sha1    5ce9b73de4c992bd2a527197847033e15eb2c346 \
                    rmd160  2121eae37bd02f8e784cd377d1a48515221a97e8 \
                ${ffmpeg-name}${extract.suffix} \
                    md5     4dc369e19df67f0e67a87a389a7dafbd \
                    sha1    1187f2d7dd45c1f72a0eadd47058568b94349a00 \
                    rmd160  814720c3adbb85053e528783a11b18904dc87f40

patch.dir       ${workpath}
patchfiles      patch-extern_libs-configure_options_ffmpeg.txt.diff \
                patch-extern_libs-Makefile.in.diff \
                patch-ffmpeg-Makefile.diff \
                patch-configure.in-ccache.diff

post-patch     {
                   if {${build_arch} ne ""} {
                       set ffmpeg_extras "--cc=${configure.cc} --arch=${build_arch}"
                   } else {
                       set ffmpeg_extras "--cc=${configure.cc}"
                   }
                   reinplace "s|MP_FFMPEG_EXTRAS|${ffmpeg_extras}|" ${worksrcpath}/extern_libs/configure_options_ffmpeg.txt
               }

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

depends_lib     path:lib/pkgconfig/gimp-2.0.pc:gimp2 \
                port:lame \
                port:XviD \
                port:bzip2 \
                port:zlib

depends_run     path:bin/mplayer:MPlayer

# reconfigure using upstream autogen.sh for intltool 0.51 compatibility

post-patch {
    xinstall -m 755 ${filespath}/autogen.sh ${worksrcpath}
}

configure.cmd   ./autogen.sh

# TODO: Fix the actual bug.  This just masks the problem to build successfully
if {[string match *clang* ${configure.compiler}]} {
    configure.cflags-append -Wno-return-type
}

configure.args  --disable-audio-support \
                --disable-libmpeg3 \
                --disable-ff-libfaac \
                --disable-ff-libfaad \
                --disable-ff-libx264 \
                --enable-gdkpixbuf-pview \
                --with-ffmpegsrcdir=${workpath}/${ffmpeg-name} \
                --with-ff-extra-cflags=-I${prefix}/include \
                --with-ff-extra-ldflags=-L${prefix}/lib

post-destroot {
    foreach dir {howto reference} {
        xinstall -d ${destroot}${prefix}/share/${name}/$dir
        foreach txt [glob -d ${worksrcpath}/docs/$dir/txt *.txt] {
            xinstall -m 644 $txt ${destroot}${prefix}/share/${name}/$dir
        }
    }
}

livecheck.type  regex
livecheck.url   http://ftp.gtk.org/pub/gimp/plug-ins/v${branch}/gap/
livecheck.regex "${name}-(\\d+(?:\\.\\d+)*)${extract.suffix}"
