# -*- 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 92412 2012-04-28 04:31:32Z ryandesign@macports.org $

PortSystem          1.0
PortGroup           python26 1.0

name                pymol
version             1.5
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        3996
worksrcdir          pymol

depends_lib         port:freetype port:libpng port:python26 port:py26-pmw port:py26-numpy port:py26-scipy port:mesa port:glew port:py26-tkinter port:freeglut
depends_run         port:xdpyinfo

patchfiles          setup_py.diff pymol_shell.diff pmg_tk_platform.patch apbs-psize.patch

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 yes

variant gcc43 description conflicts gcc44 gcc45 gcc46 gcc47 description {build using macports-gcc-4.3} {
    depends_lib-append  port:gcc43
    python.add_archflags   no
    configure.compiler  macports-gcc-4.3
}

variant gcc44 description conflicts gcc43 gcc45 gcc46 gcc47 description {build using macports-gcc-4.4} {
    depends_lib-append  port:gcc44
    python.add_archflags   no
    configure.compiler  macports-gcc-4.4
}

variant gcc45 description conflicts gcc43 gcc44 gcc46 gcc47 description {build using macports-gcc-4.5} {
    depends_lib-append  port:gcc45
    python.add_archflags   no
    configure.compiler  macports-gcc-4.5
}

variant gcc46 description conflicts gcc43 gcc44 gcc45 gcc47 description {build using macports-gcc-4.6} {
    depends_lib-append  port:gcc46
    python.add_archflags   no
    configure.compiler  macports-gcc-4.6
}

variant gcc47 description conflicts gcc43 gcc44 gcc45 gcc46 description {build using macports-gcc-4.7} {
    depends_lib-append  port:gcc47
    python.add_archflags   no
    configure.compiler  macports-gcc-4.7
}

build {
}

pre-destroot {
	destroot.env CC="${configure.cc}" CXX="${configure.cxx}"
}

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