# $Id: Portfile 62254 2010-01-02 04:54:14Z adfernandes@macports.org $

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

PortSystem  1.0
PortGroup   muniversal 1.0
name		gromacs-double
version		4.0.7
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       sha1 8519bef2fa989fb487d54612b0a2d0228f228b30

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 {
    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-append     +gcc44
}

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

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

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

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\""
}
