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

# See dports/_resources/port1.0/group/kde4-1.1.tcl for more info.
PortGroup           kde4    1.1

name                rkward
version             0.6.5
revision            2

categories          kde kde4 math science
maintainers         hhu.de:meik.michalke kde.org:rkward-devel
license             GPL-2+
platforms           darwin

description         KDE frontend to the R statistics language

long_description    RKWard aims to become an easy to use, transparent frontend to R, a powerful system \
                    for statistical computation and graphics. Besides a convenient GUI for the most important \
                    statistical functions, future versions will also provide seamless integration with an office-suite.

homepage            https://rkward.kde.org
master_sites        kde:Attic/${name}/${version}/src

worksrcdir          ${name}-${version}

depends_lib         port:kdelibs4 \
                    port:kate \
                    port:okular \
                    port:R

checksums           rmd160  086c5f0c402011c16f2eeccd52e823645a73f150 \
                    sha256  3fc5acb48ce717dee8fbbe32973ea4c61f30c335bd18a75471142b19b436a032

post-extract {
        file mkdir ${worksrcpath}/build
}

configure.dir       ${worksrcpath}/build
configure.args-append \
        -DNO_R_XML=1 \
        -DRKVERSION_NUMBER=${version} \
        -DBUNDLE_INSTALL_DIR=${applications_dir} \
        -DR_EXECUTABLE=${frameworks_dir}/R.framework/Resources/R

variant debug description {Add full debugging support} {
        depends_lib-append port:valgrind
}

configure.post_args ..

build.dir           ${worksrcpath}/build


# We force deletion of all residual (previously not properly destrooted) rkward files
# possibly installed on the buildbots, which otherwise fail for the rkward port
# [this should be deleted once the buildbots are clean again]:
pre-activate {
    delete ${frameworks_dir}/R.framework/Resources/library/rkward/
    delete ${frameworks_dir}/R.framework/Resources/library/rkwardtests/
#
#
# TODO: First we want to know the timestamps for further failure analysis,
#       which would have to be determined next time we have a revision bump.
#
    if {[file exists ${frameworks_dir}/R.framework/Resources/library/rkward]} {
        ui_msg "RKWARD_TIMESTAMPS:"
        system "ls -ltR ${frameworks_dir}/R.framework/Resources/library/rkward/"
    }
    if {[file exists ${frameworks_dir}/R.framework/Resources/library/rkwardtests]} {
        ui_msg "RKWARD_TIMESTAMPS:"
        system "ls -ltR ${frameworks_dir}/R.framework/Resources/library/rkwardtests/"
    }
#
# NOTE: rkward isn't binary distributable, which is why [1] doesn't exist!
#
# [1] http://packages.macports.org/rkward
}

livecheck.type      regex
livecheck.regex     ">Download RKWard (\\d+\\.\\d+\\.\\d+)<"

pre-pkg {
        file copy -force -- ${worksrcdir}/macports/postinstall ${package.scripts}/postinstall
        file attributes ${package.scripts}/postinstall -permissions 0755
}
