# -*- 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 92480 2012-04-29 23:38:12Z ryandesign@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             5.0-20120426080700
set version_number  [lindex [split ${version} -] 0]
categories          science graphics
license             Restrictive Noncommercial
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           rmd160  1eeb49b4b5569f828036fc6acb2b175db9ee3928 \
                    sha256  94dd0fb82b747c115ced3b65484fdad4ca7f45287e03136c6d17075dbc3ff48f

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

notes "
                    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:\
                    \n\nhttp://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}
}

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

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

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

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

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     {^(.+)$}
