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

name                redland
version             1.0.17
revision            2
description         Redland RDF Library
long_description    Redland is a set of free software libraries that provide \
                    support for the Resource Description Framework (RDF).
maintainers         nomaintainer
license             {LGPL-2.1+ GPL-2+ Apache-2+}
categories          www
platforms           darwin
homepage            http://librdf.org/
master_sites        http://download.librdf.org/source/

checksums           rmd160  86bdf793f36ca01197580fe242c4456b8cbfae39 \
                    sha256  de1847f7b59021c16bdc72abb4d8e2d9187cd6124d69156f3326dd34ee043681

patchfiles          patch-configure.diff
patch.pre_args-replace  -p0 -p1

depends_lib         port:curl \
                    port:libiconv \
                    port:libtool \
                    port:libxml2 \
                    port:libxslt \
                    path:lib/libssl.dylib:openssl \
                    port:raptor2 \
                    port:rasqal \
                    port:zlib

# redland-config uses pkg-config
depends_lib-append  port:pkgconfig

configure.args      --with-bdb=no \
                    --with-iodbc=no \
                    --with-mysql=no \
                    --with-postgresql=no \
                    --with-sqlite=no \
                    --with-threestore=no \
                    --with-unixodbc=no \
                    --with-virtuoso=no

post-configure {
    reinplace -E {s|-arch [a-z0-9_]+||g} \
        ${worksrcpath}/redland-src-config \
        ${worksrcpath}/redland.pc
}

test.run            yes
test.target         check

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

variant db46 conflicts db47 db48 description {Enable Berkeley DB 4.6 backend store} {
    configure.args-delete   --with-bdb=no
    configure.args-append   --with-bdb=${prefix} \
                            --with-bdb-include=${prefix}/include/db46 \
                            --with-bdb-lib=${prefix}/lib/db46
    depends_lib-append      port:db46
}

variant db47 conflicts db46 db48 description {Enable Berkeley DB 4.7 backend store} {
    configure.args-delete   --with-bdb=no
    configure.args-append   --with-bdb=${prefix} \
                            --with-bdb-include=${prefix}/include/db47 \
                            --with-bdb-lib=${prefix}/lib/db47
    depends_lib-append      port:db47
}

variant db48 conflicts db46 db47 description {Enable Berkeley DB 4.8 backend store} {
    configure.args-delete   --with-bdb=no
    configure.args-append   --with-bdb=${prefix} \
                            --with-bdb-include=${prefix}/include/db48 \
                            --with-bdb-lib=${prefix}/lib/db48
    depends_lib-append      port:db48
}

variant mysql57 {
    configure.args-delete --with-mysql=no
    configure.args-append --with-mysql=${prefix}/lib/mysql57/bin/mysql_config
    depends_lib-append port:mysql57
}

variant postgresql11 {
    configure.args-delete --with-postgresql=no
    depends_lib-append port:postgresql11
}

variant sqlite3 {
    configure.args-delete --with-sqlite=no
    depends_lib-append port:sqlite3
}
livecheck.type      regex
livecheck.url       ${master_sites}
livecheck.regex     "${name}-(\\d+(?:\\.\\d+)*)${extract.suffix}"
