# -*- coding: utf-8; mode: tcl; tab-width: 4; truncate-lines: t; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
# $Id: Portfile 65807 2010-04-01 08:13:19Z jochen@macports.org $

# I (Jochen Küpper) got explicit permission to distribute molden as a
# MacPorts port, given that the source-code is always downloaded from
# the authors webpage and we add a banner asking users to register at
# the following web-page: http://www.cmbi.ru.nl/molden/form.html
#
# Feel free to update checksums whenever a stealth upgrade of molden is out...

PortSystem 1.0
PortGroup xcodeversion 1.0

name                molden
version             4.8-20100325152400
set version_number  [lindex [split ${version} -] 0]
categories          science graphics
maintainers         openmaintainer jochen
homepage            http://www.cmbi.ru.nl/molden/molden.html
distname            molden${version_number}
dist_subdir         ${name}/${version}
master_sites        ftp://ftp.cmbi.ru.nl/pub/molgraph/molden/
checksums           md5     64f3f8aba8b4349ff591a6e68b6d06ea \
                    sha1    b5f8dfb4c48b573c707bd87d82d5c6963d9300b3 \
                    rmd160  c80be8d10784202a89e0eadc512aa5d95b6b5342

description         Molecular graphics visualisation tool
long_description    Molden is a package for displaying Molecular Density from \
                    the Ab Initio packages GAMESS-UK , GAMESS-US and \
                    GAUSSIAN and the Semi-Empirical packages Mopac/Ampac, it \
                    also supports a number of other programs via the Molden Format. \
                    In order to keep up support for Molden, proof that \
                    it is being used outside the CMBI is required. \
                    Please register your copy of molden at: \
                    http://www.cmbi.ru.nl/molden/form.html

platforms           darwin
depends_build       port:gmake
depends_lib         port:xorg-libX11
patchfiles          patch-makefile.diff
post-patch {
    reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/makefile
}

minimum_xcodeversions {9 3.1}
use_parallel_build  yes
use_configure       no
build.target        molden
build.cmd           gmake
pre-build {
    build.args      CC=${configure.cc} \
                    FC=${configure.fc}
}

destroot {
    xinstall -W ${worksrcpath} molden ${destroot}${prefix}/bin
    set docdir ${destroot}${prefix}/share/doc/molden
    xinstall -m 755 -d ${docdir}
    xinstall -W ${worksrcpath} \
        COMMERCIAL_LICENSE \
        CopyRight \
        HISTORY \
        README \
        REGISTER \
        ${docdir}
}

post-install        { ui_msg "**************************************************"
                      ui_msg "In order to keep up support for Molden, proof that"
                      ui_msg "it is being used outside the CMBI is required."
                      ui_msg "Please register your copy of molden at:"
                      ui_msg "***   http://www.cmbi.ru.nl/molden/form.html   ***"
                      ui_msg "**************************************************"
                    }

variant gcc43 conflicts gcc44 description {Build using gcc43} {
    depends_lib-append      port:gcc43
    configure.compiler      macports-gcc-4.3
}

variant gcc44 conflicts gcc43 description {Build using gcc44} {
    depends_lib-append      port:gcc44
    configure.compiler      macports-gcc-4.4
}

if {![variant_isset gcc43] && ![variant_isset gcc44]} {
    default_variants        +gcc43
}

variant opengl description "Install moldenogl OpenGL helper program" {
    depends_lib-append      port:mesa
    build.target-append     moldenogl
    post-destroot {
        xinstall -W ${worksrcpath} moldenogl ${destroot}${prefix}/bin
    }
}

livecheck.type      regex
livecheck.url       http://www.ryandesign.com/macports/version.php/${name}
livecheck.regex     (.*)
