# -*- 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 119517 2014-04-28 18:57:12Z devans@macports.org $

PortSystem      1.0

name            gnome-online-accounts

if {${os.platform} eq "darwin" && ${os.major} >= 13} {

set mavericks_or_better yes
version         3.12.1

} else {

set mavericks_or_better no
version         3.8.5
revision        2

}

license         LGPL-2
set branch      [join [lrange [split ${version} .] 0 1] .]
description     Single sign-on framework for GNOME
long_description \
                ${description}
maintainers     devans openmaintainer
categories      gnome
platforms       darwin
homepage        https://wiki.gnome.org/Projects/GnomeOnlineAccounts
master_sites    gnome:sources/${name}/${branch}/

use_xz          yes

if {$mavericks_or_better} {

checksums       rmd160  3166f8140cc1892afd7ff07eb9c2db7bc60e7045 \
                sha256  2b8930e463c84d609a00ed9337db16550de89e7a7b8184ab18f2a63f150e7cef

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

depends_lib     port:gtk3 \
                path:lib/pkgconfig/webkitgtk-3.0.pc:webkit-gtk3 \
                port:libsoup \
                port:json-glib \
                port:rest \
                port:libsecret \
                port:libxml2 \
                port:gobject-introspection \
                port:gcr \
                port:telepathy-glib

# use upstream autogen.sh to update m4/intltool.m4 and telepathy-account-widgets/m4/intltool.m4 and reconfigure

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

configure.cmd   ./autogen.sh

configure.args  --enable-introspection=yes \
                --enable-ubuntu-online-accounts=no \
                --disable-exchange \
                --enable-flickr \
                --enable-google \
                --enable-imap-smtp \
                --enable-owncloud \
                --enable-yahoo \
                --enable-facebook \
                --enable-windows-live \
                --enable-telepathy \
                --enable-pocket \
                --disable-kerberos \
                --disable-maintainer-mode \
                --disable-gtk-doc \
                --disable-silent-rules

} else {

checksums       rmd160  21889d886fa262e536929ecb6905cfcd3f50a462 \
                sha256  34d6fbc33bda4c7bba8aa52343ebe1eb8afe1033097c10a2d9979c0a99593e5d

depends_build   port:pkgconfig \
                port:intltool \
                port:gtk-doc \
                port:gnome-common

depends_lib     port:gtk3 \
                path:lib/pkgconfig/webkitgtk-3.0.pc:webkit-gtk3 \
                port:libsoup \
                port:json-glib \
                port:rest \
                port:libsecret \
                port:libxml2 \
                port:gobject-introspection \
                port:gcr

patchfiles      patch-alarm.diff

# autoreconf with MacPorts intltool.m4

use_autoreconf  yes
autoreconf.args -fvi

configure.cflags-append -Wno-format-nonliteral
configure.args  --enable-introspection=yes \
                --disable-exchange \
                --enable-flickr \
                --enable-google \
                --enable-imap-smtp \
                --enable-owncloud \
                --enable-facebook \
                --enable-windows-live \
                --disable-kerberos \
                --disable-silent-rules

}

# TODO: Check ${configure.cxx_stdlib} directly once MacPorts 2.3 is released
platform darwin {
    set cxxstdlib {}

    if {[info exists configure.cxx_stdlib] &&
        ${configure.cxx_stdlib} ne {} &&
        [string match *clang* ${configure.cxx}]} {
        set cxxstdlib ${configure.cxx_stdlib}
    } elseif {[string match *clang* ${configure.cxx}] &&
              ${os.major} >= 13} {
        set cxxstdlib libc++
    } else {
        set cxxstdlib libstdc++
    }

    if {${cxxstdlib} eq "libstdc++"} {
       depends_lib-delete path:lib/pkgconfig/webkitgtk-3.0.pc:webkit-gtk3
       depends_lib-append path:lib/pkgconfig/webkitgtk-3.0.pc:webkit-gtk3-2.0
    }
}

if {$mavericks_or_better} {

livecheck.type  gnome

} else {

# Version 3.8.5 is the last version that will build on darwin < 13
livecheck.type  none

}
