# -*- 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 120082 2014-05-15 04:02:07Z devans@macports.org $

PortSystem      1.0

name            gcr
version         3.12.2
license         LGPL-2
set branch      [join [lrange [split ${version} .] 0 1] .]
description     GCR is a library for displaying certificates, and crypto UI, accessing \
                key stores.
long_description \
                ${description} \
                It also provides the viewer for crypto files on the GNOME \
                desktop and a library for accessing PKCS#11 modules like smart cards, in a \
                (G)object oriented way.

maintainers     devans openmaintainer
categories      gnome security
platforms       darwin
homepage        https://wiki.gnome.org/Projects/GnomeKeyring
master_sites    gnome:sources/${name}/${branch}/

use_xz          yes

checksums       rmd160  02b39f14ee5085b404bb789ed2e8793edc363a46 \
                sha256  456e20615ab178aa92eeabdea64dcce535c10d5af189171d9375291a2447d21c

depends_build   port:pkgconfig \
                port:intltool

depends_lib     port:desktop-file-utils \
                path:lib/pkgconfig/glib-2.0.pc:glib2 \
                port:gtk3 \
                port:gobject-introspection \
                port:p11-kit \
                port:libgcrypt \
                port:gnupg \
                port:vala

patchfiles      patch-egg-egg-asn1x.h.diff \
                patch-egg-egg-armor.c.diff \
                patch-ui-gcr.pc.in.diff \
                patch-ui-gcr-ui.pc.in.diff

# update build/m4/intltool.m4 and autoreconf

pre-configure {
    copy -force ${prefix}/share/aclocal/intltool.m4 ${worksrcpath}/build/m4
}

use_autoreconf  yes
autoreconf.args -fvi

configure.args  --enable-introspection=yes \
                --enable-vala=yes \
                --disable-schemas-compile \
                --disable-update-mime \
                --disable-update-icon-cache \
                --disable-silent-rules
            
pre-activate {
    if {![catch {set installed [lindex [registry_active gnome-keyring] 0]}]} {
        set _version [lindex $installed 1]
        if {[vercmp $_version 3.0.0] < 0} {
            registry_deactivate_composite gnome-keyring "" [list ports_nodepcheck 1]
        }
    }
}

post-activate {
    system "${prefix}/bin/glib-compile-schemas ${prefix}/share/glib-2.0/schemas"
    system "${prefix}/bin/update-desktop-database ${prefix}/share/applications"
    system "${prefix}/bin/gtk-update-icon-cache-3.0 -f -t ${prefix}/share/icons/hicolor"
    system "${prefix}/bin/update-mime-database ${prefix}/share/mime"
}

platform darwin 8 {
    # The rules enabled by gobject-introspection require GNU make 3.81+
    depends_build-append    port:gmake
    build.cmd               ${prefix}/bin/gmake
}

livecheck.type  gnome
