# -*- 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           muniversal 1.0
PortGroup           gobject_introspection 1.0

name                gegl-0.3
set gname           gegl
version             0.3.34
revision            17
set branch          [join [lrange [split ${version} .] 0 1] .]
license             {GPL-3+ LGPL-3+}
categories          graphics
maintainers         {mascguy @mascguy} openmaintainer

description         GEGL is a graph based image processing framework.

long_description    GEGL is a graph based image processing framework offering image processing and \
                    compositing on large images. GEGL is suitable for projects ranging from small \
                    one-off projects to interactive applications.

homepage            http://gegl.org/
master_sites        gimp:${gname}/${branch}/

use_bzip2           yes

distname            ${gname}-${version}

checksums           rmd160  d9f4ffbb1be827a8dbd4fc10e828325b4b85e384 \
                    sha256  5ca2227655ebf1ab2e252cee3eede219c758336394288ef301b93264b9411304 \
                    size    6707964

depends_build-append \
                    port:enscript \
                    port:gtk-doc \
                    port:pkgconfig \
                    port:w3m \
                    port:python27

depends_lib-append  path:lib/pkgconfig/babl-0.1.pc:babl \
                    path:lib/pkgconfig/gdk-pixbuf-2.0.pc:gdk-pixbuf2 \
                    path:lib/pkgconfig/gtk+-2.0.pc:gtk2 \
                    path:include/turbojpeg.h:libjpeg-turbo \
                    port:lua \
                    path:bin/dot:graphviz \
                    port:openexr2 \
                    port:exiv2 \
                    port:gexiv2 \
                    port:jasper \
                    port:json-glib \
                    port:lcms2 \
                    port:lensfun \
                    port:libraw \
                    path:lib/pkgconfig/librsvg-2.0.pc:librsvg \
                    path:lib/libavcodec.dylib:ffmpeg \
                    port:libspiro \
                    path:bin/vala:vala \
                    port:webp

patchfiles          patch-configure.ac.diff \
                    patch-gegl.pc.in.diff \
                    patch-gegl-0.3-exiv2.diff \
                    patch-cxx11.diff

# gegl patch for new libraw
# https://trac.macports.org/ticket/66777
# https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e37f1398f63db9f2a6fe4133599a7169f6780e38
patchfiles-append   patch-gegl-new-libraw.diff

# disable external operation ff-save for now
# AVFMT_RAWPICTURE removed in ffmpeg-devel
# https://trac.macports.org/ticket/55389
patchfiles-append  disable-broken-ffsave.patch

post-patch {
    # http://trac.macports.org/ticket/35148
    if {${os.major} < 10} {
        reinplace {s|OpenGL/CGLDevice\.h|OpenGL/CGLTypes.h|} \
                    ${worksrcpath}/gegl/opencl/cl_gl.h
    }
}

gobject_introspection yes

configure.pkg_config_path-append \
                ${prefix}/libexec/openexr2/lib/pkgconfig

# https://trac.macports.org/ticket/63663
compiler.cxx_standard 2011
configure.cxxflags-append  -std=gnu++11

use_autoreconf      yes
autoreconf.args     -fvi

configure.python    ${prefix}/bin/python2.7

configure.args      --disable-docs \
                    --disable-silent-rules \
                    --without-libv4l \
                    --without-mtg \
                    --without-sdl \
                    --without-umfpack

# use version specific binary suffix to avoid conflict with gegl

post-destroot {
    set suffix "-0.3"
    foreach bin [glob -nocomplain -tails -directory "${destroot}${prefix}/bin" *] {
        move ${destroot}${prefix}/bin/${bin} \
             ${destroot}${prefix}/bin/${bin}${suffix}
    }
}

platform darwin {
    if {${universal_possible} && [variant_isset universal]} {
        # In order to build universal on Leopard, you need MacPorts 2.1
        set merger_configure_args(x86_64) --build=${configure.build_arch}-apple-${os.platform}${os.version}
        set merger_configure_cflags(ppc) -fno-altivec
        set merger_configure_cxxflags(ppc) -fno-altivec
    } elseif {${configure.build_arch} eq "ppc"} {
        configure.cflags-append -fno-altivec
        configure.cxxflags-append -fno-altivec
    } elseif {${configure.build_arch} eq "x86_64"} {
        configure.args-append --build=${configure.build_arch}-apple-${os.platform}${os.version}
    }
}

# https://trac.macports.org/ticket/67002
if {[vercmp ${macosx_deployment_target} >= 11]} {
	configure.ldflags-append -Wl,-no_fixup_chains
}

variant html_doc description {Build html docs with enscript and asciidoc} {
    depends_build-append port:asciidoc
    configure.args-delete --disable-docs
    configure.args-append --enable-docs
}

variant workshop description {Enable build of workshop operations} {
    depends_lib-append port:lensfun
    configure.args-append --enable-workshop
}

#
# the following dummy variants are used
# to identify this port's binary dependencies
# inherited from libsdl and librsvg
#

variant x11 conflicts quartz {}
variant quartz conflicts x11 {}

if {![variant_isset quartz]} {
    default_variants +x11
}

livecheck.type      regex
livecheck.url       http://download.gimp.org/pub/${gname}/${branch}/
livecheck.regex     "${gname}-(\\d+(?:\\.\\d+)*)${extract.suffix}"
