# -*- 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 140960 2015-10-06 20:13:45Z michaelld@macports.org $

PortSystem          1.0

name                soprano
categories          devel
maintainers         pixilla gmail.com:rjvbertin openmaintainer
license             GPL-2+ LGPL-2+

description         The Qt-based RDF framework
long_description    Soprano is a software library that provides \
                    an object-oriented C++/Qt framework for RDF data.

homepage            https://projects.kde.org/projects/kdesupport/soprano

if {${subport} eq "${name}"} {
    PortGroup       kde4 1.1

    version         2.9.4
    # The jump from 4 to 8 is to ensure that version is higher than in MacPorts.
    # Notice that the port differs substantially.
    revision        9
    master_sites    sourceforge:soprano
    use_bzip2       yes
    checksums       rmd160  b5e8db32a77ab9fed5dac74783cb137259d91bb2 \
                    sha256  64066fbd54e71d7ae4c8a4116997448a72808a2813cff3bb5d2c28f0fce9e0e5 \
                    size    1958856

    patchfiles-append \
                    patch-kde4-header-location.diff
    compiler.cxx_standard 1998
    configure.cxxflags-append -std=gnu++98
    configure.args-append \
                    -DQT5_BUILD=OFF \
                    -DINCLUDE_INSTALL_DIR=${kde4.include_dirs}

    post-destroot {
        xinstall -m 755 -d ${destroot}${kde4.include_dirs}
        file rename ${destroot}/${prefix}/include/Soprano ${destroot}${kde4.include_dirs}/Soprano
        # /destroot//opt/local/include/soprano: no such file or directory
        # file rename ${destroot}/${prefix}/include/soprano ${destroot}${kde4.include_dirs}/soprano
    }
}

subport ${name}-qt5 {
    set qt5.prefer_kde 1
    PortGroup       qt5 1.0
    PortGroup       cmake 1.1

    fetch.type      git
    git.url         git://anongit.kde.org/soprano
    git.branch      d7f30f1d2f7a862d687360877c730dc0d6030500
    version         2.9.4.3
    # soprano-qt5 doesn't yet have any dependents, so can be moved 
    # more easily than the Qt4-based port:soprano.
    cmake.install_prefix \
                    ${prefix}/libexec/${subport}
    configure.args-append \
                    -DQT5_BUILD=ON
    worksrcdir      ${name}-5
    distname        ${name}-5
    patchfiles-append \
                    patch-sopranodirs.diff
    post-patch {
        reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/soprano/sopranodirs.cpp
    }
}

depends_lib-append  port:libiodbc \
                    port:strigi

patchfiles          patch-parsers-raptor-raptorparser.h.diff \
                    patch-serializers-raptor-raptorserializer.cpp.diff

configure.args-append \
                    -DSOPRANO_DISABLE_CLUCENE_INDEX=ON \
                    -DSOPRANO_DISABLE_VIRTUOSO_BACKEND=ON \
                    -DSOPRANO_DISABLE_RAPTOR_PARSER=ON \
                    -DSOPRANO_DISABLE_RAPTOR_SERIALIZER=ON \
                    -DSOPRANO_DISABLE_SESAME2_BACKEND=ON \
                    -DSOPRANO_DISABLE_REDLAND_BACKEND=ON

variant clucene description "Add support for Clucene-based full-text indexing" {
    depends_lib-append \
                    port:clucene
    configure.args-delete \
                    -DSOPRANO_DISABLE_CLUCENE_INDEX=ON
}

variant raptor description "Build the Raptor and Redland backends (required for KDELibs4 nepomuk)" {
    depends_lib-append \
                    path:lib/pkgconfig/raptor2.pc:raptor2 \
                    port:redland
    configure.args-replace \
                    -DSOPRANO_DISABLE_RAPTOR_PARSER=ON \
                    -DSOPRANO_DISABLE_RAPTOR_PARSER=OFF \
                    -DSOPRANO_DISABLE_RAPTOR_SERIALIZER=ON \
                    -DSOPRANO_DISABLE_RAPTOR_SERIALIZER=OFF \
                    -DSOPRANO_DISABLE_REDLAND_BACKEND=ON \
                    -DSOPRANO_DISABLE_REDLAND_BACKEND=OFF
}

variant sesame description "Add support for Sesame2 storage back-end" {
    depends_lib-append \
                    port:openjdk8
    configure.env-append \
                    JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk8/Contents/Home
    configure.args-replace \
                    -DSOPRANO_DISABLE_SESAME2_BACKEND=ON \
                    -DSOPRANO_DISABLE_SESAME2_BACKEND=OFF
}

variant virtuoso description "Build the Virtuoso storage back-end" {
    depends_run-append \
                    port:virtuoso
    configure.args-delete \
                    -DSOPRANO_DISABLE_VIRTUOSO_BACKEND=ON
}

default_variants-append +clucene +raptor +virtuoso

livecheck.type      sourceforge
livecheck.url       http://sourceforge.net/projects/soprano/files/Soprano/
livecheck.regex     soprano-(\\d+(\\.\\d+)+)
