# $Id: Portfile 92459 2012-04-29 03:22:02Z jeremyhu@macports.org $

PortSystem          1.0

name                swarm
version             2.4.1
categories          science
maintainers         nomaintainer
license             GPL-2
description         Swarm is a platform for agent-based models (ABMs).
long_description    ${description}
homepage            http://www.swarm.org/
platforms           darwin
master_sites        http://ftp.swarm.org/pub/swarm/src/swarm/

checksums           sha1    7869b678a445c430a55b71e3631e5aa511d02d47 \
                    rmd160  f76274f48509ceb4d346c9724f6fd9070e42c6e2 \
                    sha256  04b78811235722c2da199a538ac4465aaf4030f1aaf8554b94785fc1482d2c95

depends_lib         port:blt \
                    port:tcl \
                    port:tk \
                    port:xpm \
                    port:libffi \
                    port:zlib \
                    port:libpng \
                    port:hdf5-18

universal_variant   no

post-patch {
    reinplace {s:-fgnu-runtime:-DH5_USE_16_API -fnested-functions -fgnu-runtime:g} \
        ${worksrcpath}/configure \
        ${worksrcpath}/libobjc/configure
}

configure.args      --with-x \
                    --x-include=${prefix}/include \
                    --x-lib=${prefix}/lib \
                    --with-tcl=${prefix}/lib \
                    --with-tk=${prefix}/lib

pre-configure {
    configure.args-append --with-ffidir=[glob ${prefix}/lib/libffi-*]

    if {[file exists /System/Library/Frameworks/JavaVM.framework]} {
        configure.args-append --with-jdkdir=/System/Library/Frameworks/JavaVM.framework
    }
}

post-destroot {
    # http://trac.macports.org/ticket/34232
    file delete -force ${destroot}${prefix}/include
}
