# $Id: Portfile 90955 2012-03-19 16:34:25Z adfernandes@macports.org $

# Important: keep in sync with the 'gromacs' port!

PortSystem  1.0
PortGroup   muniversal 1.0
name		gromacs-double
version		4.5.4
revision	1
categories	science math
maintainers	adfernandes openmaintainer
description	The World's fastest Molecular Dynamics package (double-precision)
long_description	GROMACS is a versatile package to perform molecular \
	dynamics, i.e. simulate the Newtonian equations of motion for \
	systems with hundreds to millions of particles. It is primarily \
	designed for biochemical molecules like proteins and lipids that \
	have a lot of complicated bonded interactions, but since GROMACS is \
	extremely fast at calculating the nonbonded interactions (that \
	usually dominate simulations) many groups are also using it for \
	research on non-biological systems, e.g. polymers (double-precision).
platforms	darwin

distname        gromacs-${version}
dist_subdir     gromacs
homepage	    http://www.gromacs.org/
master_sites	ftp://ftp.gromacs.org/pub/gromacs \
                http://cluster.earlham.edu/detail/home/charliep/packages

checksums           md5     5013de941017e014b92d41f82c7e86d6 \
                    sha1    c7b3fbd2f3ddf915bc082e7effe76a8276563726 \
                    rmd160  96065d1a173231f75869764a08eb4feccc1ec597

depends_build   port:pkgconfig

depends_lib 	port:fftw-3 port:libxml2 port:openmotif port:gromacs

configure.args  --bindir=${prefix}/lib/${name}/bin --enable-shared --with-x --enable-double

variant no_x11 description {disable the openmotif interface} {
    depends_lib-delete      port:openmotif
    configure.args-delete   --with-x
    configure.args-append   --without-x
}
 
variant gsl description {enable extra analyses via the GNU scientific library} {
    depends_lib-append      port:gsl
    configure.args-append   --with-gsl
}

variant openmpi description {build using openmpi parallelization} {
    depends_lib-append      port:openmpi
    configure.args-append   --enable-mpi
}

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

variant gcc42 conflicts gcc43 gcc44 gcc45 description {build with macports-gcc-4.2} {
    depends_lib-append  port:gcc42
    configure.compiler  macports-gcc-4.2
}

variant gcc43 conflicts gcc42 gcc44 gcc45 description {build with macports-gcc-4.3} {
    depends_lib-append  port:gcc43
    configure.compiler  macports-gcc-4.3
}

variant gcc44 conflicts gcc42 gcc43 gcc45 description {build with macports-gcc-4.4} {
    depends_lib-append  port:gcc44
    configure.compiler  macports-gcc-4.4
}

variant gcc45 conflicts gcc42 gcc43 gcc44 description {build with macports-gcc-4.5} {
    depends_lib-append  port:gcc45
    configure.compiler  macports-gcc-4.5
}

post-destroot {
    # All the required files are provided by the single-precision 'gromacs' port. Delete everything that's not required.
    system "find \"${destroot}${prefix}\" -depth 1 -not -name lib -print0 | xargs -0 rm -rf"
    system "find \"${destroot}${prefix}\" -type f -not -iname '*_d' -a -not -name '*_d.*' -print0 | xargs -0 rm -rf"
    system "mv \"${destroot}${prefix}/lib/gromacs-double\" \"${destroot}${prefix}/lib/gromacs\""
}
