# -*- 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$
PortSystem          1.0
name                pymol
version             1.2r2
revision            0
categories          science
maintainers         howarth@bromo.med.uc.edu
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        3866
worksrcdir          pymol

depends_lib         port:glut port:freetype port:libpng port:python26 port:py26-pmw port:py26-numeric
depends_run         port:xorg-apps

patchfiles          pymol-build.patch
use_configure       no

post-patch {
    reinplace  "s|@PREFIX@|${prefix}|g" ${worksrcpath}/contrib/modules/Makefile.pre.in.src
    reinplace  "s|@PREFIX@|${prefix}|g" ${worksrcpath}/setup/Rules.osx-fink
    reinplace  "s|@PREFIX@|${prefix}|g" ${worksrcpath}/setup/pymol.com.osx-fink
    reinplace  "s|-Wno-long-double||g" ${worksrcpath}/setup/Rules.osx-fink
    reinplace  "s|/usr/X11R6|${prefix}|g" ${worksrcpath}/setup/Rules.osx-fink
    reinplace  "s|/usr/X11R6|${prefix}|g" ${worksrcpath}/modules/pymol/__init__.py
}

build {
   system "find ${worksrcpath} -name .svn -print0 | xargs -0 rm -rf"
   system "cd  ${worksrcpath}/setup; cp Rules.osx-fink ../Rules.delsci"
   system "cd  ${worksrcpath}; make -f Makefile.delsci"
}

destroot {
   file mkdir ${destroot}${prefix}/lib/pymol/bin
   copy  ${worksrcpath}/setup/pymol.com.osx-fink ${destroot}${prefix}/lib/pymol/bin/pymol
   system "cd ${worksrcpath}; cp -r data modules examples test scripts ${destroot}${prefix}/lib/pymol"
   file mkdir ${destroot}${prefix}/bin
   ln -s ${prefix}/lib/pymol/bin/pymol ${destroot}${prefix}/bin
}

