# -*- 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
# $Id: Portfile 117762 2014-03-11 07:25:09Z devans@macports.org $

PortSystem      1.0

name            libgda5
set gname       libgda
version         5.2.2
license         {GPL-2 LGPL}
set branch      [join [lrange [split ${version} .] 0 1] .]
description     GDA provides uniform access to different kinds of data sources.
long_description \
                GNU Data Access (GDA) is an attempt to provide \
                uniform access to different kinds of data sources \
                (databases, information servers, mail spools, etc).
maintainers     jwa devans openmaintainer
categories      databases gnome
platforms       darwin
homepage        http://www.gnome-db.org/
distname        libgda-${version}
master_sites    gnome:sources/${gname}/${branch}/

use_xz          yes

checksums       rmd160  d391a7ea74d08ae4f5f5fe7ba6c49f2f254be5f9 \
                sha256  c9b8b1c32f1011e47b73c5dcf36649aaef2f1edaa5f5d75be20d9caadc2bc3e4

depends_build   port:pkgconfig \
                port:intltool \
                port:itstool \
                port:yelp-tools \
                port:gtk-doc

depends_lib     port:desktop-file-utils \
                port:readline \
                port:gtk3 \
                port:gtksourceview3 \
                port:goocanvas2 \
                port:iso-codes \
                port:libsecret \
                port:libsoup \
                port:libgcrypt \
                port:libxml2 \
                port:libxslt \
                port:gobject-introspection

depends_run     port:gnome-settings-daemon \
                port:yelp

patchfiles      patch-bdb.diff

# update m4/intltool.m4 and autoreconf

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

use_autoreconf  yes
autoreconf.args -fvi

#
# use embedded libsqlite3 rather than the system version
# to avoid dlopen 'Can't find file libsqlite3.so' errors
#

configure.args  --enable-system-sqlite=no \
                --enable-introspection=yes \
                --enable-gda-gi=yes \
                --enable-gdaui-gi=yes \
                --disable-silent-rules \
                --without-graphviz \
                --with-ldap=no \
                --with-bdb=no \
                --with-mdb=no \
                --with-mysql=no \
                --with-postgres=no \
                --with-oracle=no \
                --with-firebird=no \
                --with-java=no \
                --with-jni=no

variant mysql5 \
    description {support for current MySQL 5.x} {
    depends_lib-append  path:bin/mysql_config5:mysql5
    configure.env-append    \
        MYSQL_CONFIG=${prefix}/lib/mysql5/bin/mysql_config
    configure.args-delete   --with-mysql=no
    configure.args-append   --with-mysql=${prefix}/lib/mysql5
    configure.cppflags-append   "-I${prefix}/include/mysql5/mysql"
}

variant postgresql84 conflicts postgresql90 postgresql91 postgresql92 postgresql93 \
    description {support for PostgreSQL 8.4.x} {
    configure.cppflags-append   "-I${prefix}/include/postgresql84"
    depends_lib-append  port:postgresql84
    configure.args-delete   --with-postgres=no
    configure.args-append   --with-postgres=${prefix}/lib/postgresql84
}

variant postgresql90 conflicts postgresql84 postgresql91 postgresql92 postgresql93 \
    description {support for PostgreSQL 9.0.x} {
    configure.cppflags-append   "-I${prefix}/include/postgresql90"
    depends_lib-append  port:postgresql90
    configure.args-delete   --with-postgres=no
    configure.args-append   --with-postgres=${prefix}/lib/postgresql90
}

variant postgresql91 conflicts postgresql84 postgresql90 postgresql92 postgresql93 \
    description {support for PostgreSQL 9.1.x} {
    configure.cppflags-append   "-I${prefix}/include/postgresql91"
    depends_lib-append  port:postgresql91
    configure.args-delete   --with-postgres=no
    configure.args-append   --with-postgres=${prefix}/lib/postgresql91
}

variant postgresql92 conflicts postgresql84 postgresql90 postgresql91 postgresql93 \
    description {support for PostgreSQL 9.2.x} {
    configure.cppflags-append   "-I${prefix}/include/postgresql92"
    depends_lib-append  port:postgresql92
    configure.args-delete   --with-postgres=no
    configure.args-append   --with-postgres=${prefix}/lib/postgresql92
}

variant postgresql93 conflicts postgresql84 postgresql90 postgresql91 postgresql92 \
    description {support for PostgreSQL 9.3.x} {
    configure.cppflags-append   "-I${prefix}/include/postgresql93"
    depends_lib-append  port:postgresql93
    configure.args-delete   --with-postgres=no
    configure.args-append   --with-postgres=${prefix}/lib/postgresql93
}

variant db47 conflicts db48 db51  \
    description {support for Berkeley DB 4.7.x} {
    set db_version 47
    depends_lib-append  port:db${db_version}
    configure.cppflags-append "-I${prefix}/include/db${db_version}"
    configure.args-delete   --with-bdb=no
    configure.args-append   --with-bdb=${prefix} \
                            --with-bdb-libdir-name=lib/db${db_version}
}

variant db48 conflicts db47 db51 \
    description {support for Berkeley DB 4.8.x} {
    set db_version 48
    depends_lib-append  port:db${db_version}
    configure.cppflags-append "-I${prefix}/include/db${db_version}"
    configure.args-delete   --with-bdb=no
    configure.args-append   --with-bdb=${prefix} \
                            --with-bdb-libdir-name=lib/db${db_version}
}

variant db51 conflicts db47 db48 \
    description {support for Berkeley DB 5.1.x} {
    set db_version 51
    depends_lib-append  port:db${db_version}
    configure.cppflags-append "-I${prefix}/include/db${db_version}"
    configure.args-delete   --with-bdb=no
    configure.args-append   --with-bdb=${prefix} \
                            --with-bdb-libdir-name=lib/db${db_version}
}

if {![variant_isset db47] && ![variant_isset db48]} {
    default_variants +db51
}

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

livecheck.type      gnome
livecheck.name      ${gname}
