# -*- 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 59965 2009-10-28 03:09:04Z jmr@macports.org $

PortSystem          1.0

name                sparky
version             3.115
categories          science
maintainers         bromo.med.uc.edu:howarth
description         NMR Assignment and Integration Software
long_description    Sparky is a graphical NMR assignment and integration \
                    program for proteins, nucleic acids, and other polymers.

platforms           darwin

homepage            http://www.cgl.ucsf.edu/home/sparky/

master_sites        http://www.cgl.ucsf.edu/home/sparky/distrib-${version}/
distname            ${name}-source-${version}
checksums           md5 cbc10f03e823b38969822353687b8aa0 \
                    sha1 57eb3d6b9b4f406095f6b601c47339f06c73e1e0 \
                    rmd160 59ba7c64c98f86506ae1417e9272ef3d79c8605e
worksrcdir          sparky

depends_lib         port:python26 port:tcl port:tk

patchfiles          sparky-build.diff
use_configure       no

build.env-append    CC=${configure.cc} CXX=${configure.cxx}

post-patch {
    reinplace  "s|@BUILDDIR@|${worksrcpath}|g" ${worksrcpath}/Makefile \
                                               ${worksrcpath}/c++/Makefile
    reinplace  "s|@PREFIX@|${prefix}|g" ${worksrcpath}/Makefile \
                                        ${worksrcpath}/bin/sparky \
                                        ${worksrcpath}/c++/Makefile \
                                        ${worksrcpath}/lib/Makefile \
                                        ${worksrcpath}/manual/Makefile \
                                        ${worksrcpath}/python/Makefile
    reinplace  "s|@DESTDIR@|${destroot}|g" ${worksrcpath}/Makefile \
                                           ${worksrcpath}/bin/sparky \
                                           ${worksrcpath}/c++/Makefile \
                                           ${worksrcpath}/lib/Makefile \
                                           ${worksrcpath}/manual/Makefile \
                                           ${worksrcpath}/python/Makefile
    system "cd ${worksrcpath}; perl -ni -e 'print unless /LIBRARY_PATH/' bin/sparky"
}

post-destroot {
    foreach f {sparky sparky-no-python bruk2ucsf matrix2ucsf peaks2ucsf pipe2ucsf ucsfdata vnmr2ucsf} {
        ln -s ${prefix}/lib/${name}/bin/${f} ${destroot}${prefix}/bin/${f}
    }
}
