# -*- 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
PortGroup           active_variants 1.1

name                rNMR
version             1.1.7
revision            1
categories          science chemistry
platforms           {darwin any}
maintainers         {gmail.com:howarth.at.macports @jwhowarth}
supported_archs     noarch
license             GPL-3

description         Open Source Software for NMR Data Analysis

long_description    rNMR is an open source software package for visualizing \
                    and interpreting one and two dimensional NMR data. In \
                    contrast to most existing 2D NMR software, rNMR is \
                    specifically designed for high-throughput assignment and \
                    quantification of small molecules. As a result, rNMR \
                    supports extensive batch manipulation of plotting \
                    parameters and has numerous tools for expediting \
                    repetitive resonance assignment and quantification tasks.

homepage            http://rnmr.nmrfam.wisc.edu/
master_sites        ${homepage}pages/download/files/Binaries/Mac%20and%20Linux/current/ \
                    ${homepage}pages/download/files/Binaries/Mac%20and%20Linux/${version}/

distname            ${name}_${version}

checksums           rmd160  daaa56141cb1fdd5febd33601147f6ef401ed837 \
                    sha256  fb9082bb098af1678c5e9b566e6f3411ee46256d47488f5dd2f1f367b3513c1f

depends_lib         port:R

require_active_variants R tcltk

use_configure       no

build {
    file mkdir ${worksrcpath}/pkg
    system -W ${worksrcpath} "${prefix}/bin/R CMD INSTALL -l pkg --byte-compile --build ${distpath}/[lindex ${distfiles} 0]"
}

destroot {
    xinstall -d ${destroot}${frameworks_dir}/R.framework/Resources/library/${name}/macosx/
    system "tar -C ${destroot}${frameworks_dir}/R.framework/Resources/library -zxf ${worksrcpath}/${distname}.tgz"
    xinstall -W ${destroot}${frameworks_dir}/R.framework/Resources/library/${name}/linux \
        loadrNMR.R rNMR.gif xdg-open \
        ${destroot}${frameworks_dir}/R.framework/Resources/library/${name}/macosx/
    reinplace "s|~/rNMR/linux/|./|g" ${destroot}${frameworks_dir}/R.framework/Resources/library/${name}/macosx/loadrNMR.R
    xinstall -m 755 ${filespath}/${name}.sh ${destroot}${frameworks_dir}/R.framework/Resources/library/${name}/macosx
    reinplace "s|@PREFIX@|${prefix}|g" ${destroot}${frameworks_dir}/R.framework/Resources/library/${name}/macosx/rNMR.sh
    reinplace "s|@FRAMEWORKS_DIR@|${frameworks_dir}|g" ${destroot}${frameworks_dir}/R.framework/Resources/library/${name}/macosx/rNMR.sh
    ln -s ${frameworks_dir}/R.framework/Resources/library/${name}/macosx/${name}.sh ${destroot}${prefix}/bin/${name}
}

livecheck.type      regex
livecheck.url       [lindex ${master_sites} 0]
livecheck.regex     ${name}_(\[0-9.\]+)${extract.suffix}