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

name            gtksourceview2
set my_name     gtksourceview
version         2.10.5
revision        10
license         LGPL-2.1+
# respository indicates they were in process of shift
# from LGPL-2+ to LGPL-2.1+
set branch      [join [lrange [split ${version} .] 0 1] .]
maintainers     mit.edu:wdc openmaintainer
categories      gnome
platforms       darwin
description     GtkSourceView is a text widget

long_description \
    GtkSourceView is a text widget that extends the standard \
    gtk+ 2.x text widget GtkTextView. It improves GtkTextView \
    by implementing syntax highlighting and other features \
    typical of a source editor. This port contains version 2 of the \
    GtkSourceView widget. Port GtkSourceView contains version 1 of the \
    widget.

homepage        https://wiki.gnome.org/Projects/GtkSourceView
master_sites    gnome:sources/${my_name}/${branch}/
distname        ${my_name}-${version}
use_bzip2       yes

checksums       md5     1219ad1694df136f126507466aeb41aa \
                sha1    5081dc7a081954d0af73852c22e874a746bda30e \
                rmd160  081679debc8ca021749136e952329bb3ea0aa4f2 \
                sha256  c585773743b1df8a04b1be7f7d90eecdf22681490d6810be54c81a7ae152191e \
                size    1253321

set port_ver_major [lindex [split ${version} .] 0]

depends_build   port:intltool \
                port:pkgconfig \
                port:gettext \
                port:gnome-common \
                port:gtk-doc \
                port:autoconf \
                port:automake \
                port:libtool

depends_lib \
    path:lib/pkgconfig/glib-2.0.pc:glib2 \
    port:gettext-runtime \
    path:lib/pkgconfig/gtk+-2.0.pc:gtk2 \
    port:libxml2

patchfiles      patch-configure.ac.diff \
                patch-gtkosxapplication.diff

# reconfigure using upstream autogen.sh for intltool 0.51 compatibility

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

configure.cmd   ./autogen.sh

configure.args  --enable-compile-warnings=minimum

test.run        yes
test.target     check

post-destroot {
    set docdir ${prefix}/share/doc/${name}
    xinstall -d ${destroot}${docdir}
    xinstall -m 644 -W ${worksrcpath} AUTHORS COPYING COPYING.lib MAINTAINERS \
        NEWS README ${destroot}${docdir}

# glade-3 expects catalog modules and libraries to have a .so suffix

    if {[variant_isset glade]} {
        set libdir ${prefix}/lib
        ln -s ${libdir}/libgtksourceview-2.0.dylib ${destroot}${libdir}/libgtksourceview-2.0.so
    }
}

# although this port correctly senses the installed variant of gtk2 and configures accordingly,
# gtk-osx-application-gtk2 only builds with gtk2 +quartz and will fail to build if gtk2 +x11
# is active. Since this can break the x11 build of this port, only depend on it if +quartz
# is set. It's not used when building with gtk2 +x11 anyway.
 
variant quartz {
    depends_lib-append  port:gtk-osx-application-gtk2
}

# make sure the right variant of gtk2 is installed for the intended build

if {[variant_isset quartz]} {
    require_active_variants gtk2 quartz
} else {
    require_active_variants gtk2 x11
}

variant glade description {Build glade catalog} {
    depends_lib-append port:glade3
    configure.args-append   --enable-glade-catalog
}

livecheck.type  regex
livecheck.url   http://ftp.gnome.org/pub/gnome/sources/${my_name}/${branch}/
livecheck.regex "LATEST-IS-(${port_ver_major}\\.\\d*\[02468\](?:\\.\\d+)*)"
