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

name                molmol
version             2k.2.0
revision            13
categories          science chemistry
maintainers         {gmail.com:howarth.at.macports @jwhowarth} openmaintainer
description         Molecular graphics display program
long_description    MOLMOL is a molecular graphics program for displaying, analyzing, \
                    and manipulating the three-dimensional structure of biological \
                    macromolecules, with special emphasis on the study of protein \
                    or DNA structures determined by NMR. The program runs on UNIX \
                    and Windows NT/95/98/2000 and is freely available. It does not work \
                    properly with RNA.
homepage            http://www.mol.biol.ethz.ch/wuthrich/software/molmol/
platforms           darwin
license             Restrictive/Distributable
master_sites        ftp://ftp.mol.biol.ethz.ch/software/MOLMOL/unix-gzip
distfiles           molmol-${version}-src.tar.gz \
                    molmol-${version}-doc.tar.gz
checksums           molmol-2k.2.0-src.tar.gz \
                    rmd160  b1de89953631dd9b11928751d7853cb511bf45f0 \
                    sha256  1104dcb1b2517581c7d6b1695ff2e92f4076ad34afc48dd896eec38e5acf2287 \
                    size    1088805 \
                    molmol-2k.2.0-doc.tar.gz \
                    rmd160  08b3e21ab6eb7c9044e59373334181ff91ca8a53 \
                    sha256  07e1c3fd04ffe7c9e9d91eaefa0bf72e6d0913a981eec3bf0879bfc65537a6be \
                    size    1062297
depends_lib         port:openmotif \
                    port:mesa \
                    port:libGLU \
                    port:glw \
                    port:tiff \
                    path:include/turbojpeg.h:libjpeg-turbo \
                    port:libpng \
                    port:xpm \
                    port:zlib

patchfiles          molmol-build.diff molmol-warnings.diff molmol-png.diff

compilers.choose    cc
compilers.setup

use_configure       no
use_parallel_build  no
build.target-delete all
extract.mkdir       yes
post-patch {
    reinplace  "s|@PREFIX@|${prefix}|g" ${worksrcpath}/makedef \
                                        ${worksrcpath}/molmol
    reinplace  "s|@CC@|${configure.cc}|g" ${worksrcpath}/makedef
    if {${os.major} == 12} {
      reinplace  "s|SYSLIB = |SYSLIB = -isysroot `xcode-select --print-path`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk |g" ${worksrcpath}/makedef
    }
    if {${os.major} >= 20} {
      reinplace  "s|/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib ||g" ${worksrcpath}/makedef
    }
}
destroot {
    # prune installed files
    foreach d {main motif win} {
        system -W ${worksrcpath} "rm -f src/${d}/*.h src/${d}/*.c src/${d}/*.o"
    }
    # Install example files not installed by the Makefile
    file mkdir ${destroot}${prefix}/share/${name}/src
    foreach d {auxil COPYING data help HISTORY macros man molmol README README.UNIX setup tips} {
        copy ${worksrcpath}/${d} ${destroot}${prefix}/share/${name}
    }
    foreach d {main motif win} {
        copy ${worksrcpath}/src/${d} ${destroot}${prefix}/share/${name}/src
    }
    ln -s ${prefix}/share/${name}/${name} ${destroot}${prefix}/bin/${name}
    file mkdir ${destroot}${prefix}/share/doc/${name}
    ln -s ${prefix}/share/${name}/COPYING ${destroot}${prefix}/share/doc/${name}/COPYING
    ln -s ${prefix}/share/${name}/man ${destroot}${prefix}/share/doc/${name}/man
}
