# -*- 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 78272 2011-05-01 02:18:29Z jmr@macports.org $

PortSystem          1.0
PortGroup           python26 1.0

name                pymol
version             1.4
revision            1
categories          science
maintainers         bromo.med.uc.edu:howarth
description         Molecular graphics system
long_description    PyMOL is a molecular graphics system with an embedded Python interpreter \
                    designed for real-time visualization and rapid generation of high-quality \
                    molecular graphics images and animations.

platforms           darwin

homepage            http://www.pymol.org/

master_sites        sourceforge
fetch.type          svn
svn.url             https://pymol.svn.sourceforge.net/svnroot/pymol/trunk/pymol
svn.revision        3945
worksrcdir          pymol

depends_lib         port:freetype port:libpng port:python26 port:py26-pmw port:py26-numeric port:mesa port:glew port:py26-tkinter
depends_run         port:xdpyinfo

patchfiles          setup_py.diff pymol_shell.diff

post-patch {
    reinplace  "s|@PREFIX@|${prefix}|g" ${worksrcpath}/setup.py
    reinplace  "s|@@PYTHON_PKGDIR@@|${python.pkgd}|g" ${worksrcpath}/setup/pymol_macports
    reinplace  "s|@@PYTHON_BINARY@@|${python.bin}|g" ${worksrcpath}/setup/pymol_macports
}

use_parallel_build  no

variant gcc43 description conflicts gcc44 gcc45 description {build using macports-gcc-4.3} {
    depends_lib-append  port:gcc43
    # the current pymol makefile does not honour CC and CXX environment variables
    build.args-delete   CC="${configure.cc}" CXX="${configure.cxx}"
    build.args-append   CC="${prefix}/bin/gcc-mp-4.3" CXX="${prefix}/bin/g++-mp-4.3"
    configure.compiler  macports-gcc-4.3
}

variant gcc44 description conflicts gcc43 gcc45 description {build using macports-gcc-4.4} {
    depends_lib-append  port:gcc44
    # the current pymol makefile does not honour CC and CXX environment variables
    build.args-delete   CC="${configure.cc}" CXX="${configure.cxx}"
    build.args-append   CC="${prefix}/bin/gcc-mp-4.4" CXX="${prefix}/bin/g++-mp-4.4"
    configure.compiler  macports-gcc-4.4
}

variant gcc45 description conflicts gcc43 gcc44 description {build using macports-gcc-4.5} {
    depends_lib-append  port:gcc45
    # the current pymol makefile does not honour CC and CXX environment variables
    build.args-delete   CC="${configure.cc}" CXX="${configure.cxx}"
    build.args-append   CC="${prefix}/bin/gcc-mp-4.5" CXX="${prefix}/bin/g++-mp-4.5"
    configure.compiler  macports-gcc-4.5
}

post-destroot {
     file copy ${worksrcpath}/setup/pymol_macports ${destroot}${prefix}/bin/pymol
     file attributes ${destroot}${prefix}/bin/pymol -permissions a+x
     foreach d {data modules examples test scripts} {
        copy ${worksrcpath}/${d} ${destroot}${python.pkgd}/pymol
    }
}
