# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4
# $Id: Portfile 108112 2013-07-13 07:45:33Z devans@macports.org $

PortSystem      1.0

name            cogl
version         1.12.2
revision        1
set branch      [join [lrange [split ${version} .] 0 1] .]
categories      graphics
description     A hardware accelerated 3D graphics API
long_description \
                Cogl is a small open source library for using 3D graphics hardware \
                for rendering. The API departs from the flat state machine style \
                of OpenGL and is designed to make it easy to write orthogonal \
                components that can render without stepping on each others toes.
license         LGPL-2+
maintainers     devans openmaintainer
platforms       darwin
homepage        http://blogs.gnome.org/clutter/
master_sites    gnome:sources/${name}/${branch}
use_xz          yes

checksums       rmd160  fb0bba618f06028e9c1c6b1904dfcc0fc4f659dc \
                sha256  31971d4c6543c589f6fc49ab1724dfbdc7062c58a7da842cb1935e32ca6e1d7e

depends_build   port:pkgconfig

depends_lib     path:lib/pkgconfig/cairo.pc:cairo \
                port:gobject-introspection \
                port:mesa \
                path:lib/pkgconfig/pango.pc:pango

configure.args  --enable-introspection=yes \
                --enable-cogl-pango=yes

patchfiles      leopard.patch

post-patch {
    reinplace "/SUBDIRS/s/tests//" ${worksrcpath}/Makefile.am
}

use_autoreconf  yes
autoreconf.args -fvi

#
# if clutter is installed and version is less than 1.12.0
# deactivate clutter before activating cogl to avoid conflict
#
# previous versions included cogl in port clutter
#

pre-activate {
    if { [file exists ${prefix}/lib/pkgconfig/clutter-1.0.pc]
        && ![catch {set vers [lindex [registry_active clutter] 0]}]
        && [vercmp [lindex $vers 1] 1.12.0] < 0} {
        
        registry_deactivate clutter "" "" "" [list ports_nodepcheck 1]
    }
}

variant x11 conflicts quartz {
    depends_lib-append    port:gdk-pixbuf2 \
                          port:xorg-libXcomposite \
                          port:xorg-libXdamage \
                          port:xorg-libXext \
                          port:xorg-libXfixes
    configure.args-append --enable-gdk-pixbuf=yes \
                          --enable-quartz-image=no \
                          --with-x
}

variant quartz conflicts x11 {
    configure.args-append --enable-gdk-pixbuf=no \
                          --enable-quartz-image=yes \
                          --without-x
    configure.ldflags-append    \
                          -framework ApplicationServices \
                          -framework QuartzCore
}

variant debug description {Enable debugging} {
    configure.args-append --enable-debug
}

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

livecheck.type  gnome
