# -*- 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           python 1.0
PortGroup           wxWidgets 1.0

name                relax
version             4.0.3
categories          science python chemistry
license             GPL-3
maintainers         {gmail.com:howarth.at.macports @jwhowarth}
description         Protein dynamics by NMR relax. data analysis
long_description    The program relax is designed for the study of the \
                    dynamics of proteins or other macromolecules though the \
                    analysis of NMR relaxation data.
homepage            http://www.nmr-relax.com/
platforms           darwin
master_sites        http://download.gna.org/relax/
distfiles           ${name}-${version}.src.tar.bz2
dist_subdir         ${name}

checksums           rmd160  2a91388482c21ae885a5201cebcf970b1b923d29 \
                    sha256  6791520ce38c949de214b8b0260f1cccdad11de61598934c57869f86d4463316

use_bzip2           yes

python.default_version 27

depends_build-append \
                    port:scons
depends_lib-append  port:pymol \
                    port:py${python.version}-scipy \
                    port:py${python.version}-numpy \
                    port:py${python.version}-wxpython-3.0
patchfiles          relax.patch
post-patch {
    reinplace  "s|'i386', 'ppc', 'x86_64'|'${build_arch}'|g" ${worksrcpath}/sconstruct
    reinplace  "s|cflags = '-I'|cflags = '-O3 -ffast-math -funroll-loops -I'|g" ${worksrcpath}/sconstruct
    reinplace  "s|@DEST_ROOT@|${destroot}|g" ${worksrcpath}/sconstruct
    reinplace  "s|@PYTHON_BIN@|${python.bin}|g" ${worksrcpath}/relax
    reinplace  "s|@PYTHON_INCL@|${python.include}|g" ${worksrcpath}/sconstruct
    reinplace  "s|@PREFIX@|${prefix}|g" ${worksrcpath}/sconstruct
}
build.cmd           ${prefix}/bin/scons
build.target
test.run            yes
test.cmd            ./relax
test.target         --test-suite
destroot.cmd        ${build.cmd}
destroot.destdir    DESTDIR=${destroot}
post-destroot {
    reinplace  "s|${destroot}${prefix}|${prefix}|g" ${destroot}${prefix}/lib/relax/sconstruct
    ln -sf ${prefix}/lib/relax/relax ${destroot}${prefix}/bin/relax
    file delete -force ${destroot}${prefix}/lib/relax/version.pyc
    file delete -force {*}[glob -directory ${destroot}${prefix}/lib/relax/scons/ *.pyc]
    system "${python.bin} -O ${python.libdir}/compileall.py -d ${prefix}/lib/relax ${destroot}${prefix}/lib/relax"
}

universal_variant   no
