# -*- 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 108278 2013-07-17 20:12:10Z devans@macports.org $

PortSystem      1.0

name            libgda5
set gname       libgda
version         5.1.2
revision        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  36b06a9e07a2e8d81d2d093021712fa2d8b361f0 \
                sha256  59c4416a151297a406091fcfe7af781ea88af3381d10b365ba73b1eb8e23b6c5

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

depends_lib     port:desktop-file-utils \
                port:readline \
                path:bin/dot:graphviz \
                port:gtksourceview2 \
                port:goocanvas \
                port:iso-codes \
                port:libsoup \
                port:libtool \
                port:gobject-introspection

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

default_variants +bdb

# Don't do intltool's INTLTOOL_PERL dance
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  --with-bdb=${prefix} \
                --enable-system-sqlite=no \
                --enable-introspection \
                --disable-silent-rules \
                --without-mysql \
                --without-postgres \
                --without-oracle \
                --without-firebird \
                --without-java \
                --without-jni

#                --without-mdb

use_parallel_build 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   --without-mysql
    configure.args-append   --with-mysql=${prefix}/lib/mysql5
    configure.cppflags-append   "-I${prefix}/include/mysql5/mysql"
}

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

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

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

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

variant bdb description {support for Berkeley DB} {
#
# prefer Berkeley DB 4.7 over 4.6
# and depend on it if 4.6 is not installed
# if both are installed configure will select 4.7
# otherwise look for 4.6
#
    if ([file exists ${prefix}/include/db52/db.h]) {
        depends_lib-append port:db52
    } elseif ([file exists ${prefix}/include/db46/db.h])  {
        depends_lib-append port:db46
    } elseif ([file exists ${prefix}/include/db47/db.h])  {
        depends_lib-append port:db47
    } elseif ([file exists ${prefix}/include/db48/db.h])  {
        depends_lib-append port:db48
    } elseif ([file exists ${prefix}/include/db51/db.h])  {
        depends_lib-append port:db51
    }
}

#
# the following are legacy variants to be removed after a few update cycles

variant with_mysql5 requires mysql5 \
    description {Legacy compatibility variant current MySQL 5.x} {}

variant with_postgresql83 requires postgresql83 \
    description {Legacy compatibility variant PostgreSQL 8.3.x} {}

variant with_postgresql84 requires postgresql84 \
    description {Legacy compatibility variant PostgreSQL 8.4.x} {}

variant with_postgresql90 requires postgresql90 \
    description {Legacy compatibility variant PostgreSQL 9.0.x} {}

variant without_bdb conflicts bdb \
    description {Legacy compatibility variant} {}

if {[variant_isset without_bdb]} {
    default_variants    -bdb
} else {
    default_variants    +bdb
}

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

notes "The with_ and without_ variants are deprecated"

livecheck.type      gnome-with-unstable
livecheck.name      ${gname}
