# -*- 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

PortSystem          1.0
PortGroup           makefile 1.0

name                SurfaceEvolver
version             2.70
revision            0
categories          science

# This software does not indicate a license, other than mentioning that "it is
# available free of charge". However, it contains GPL-2+ licensed source files,
# which cause the entire package to be GPL as well.
license             GPL-2+

maintainers         nomaintainer
description         Software for the modeling of the evolution of liquid surfaces.
long_description    Surface Evolver is an interactive program for the modelling \
                    of liquid surfaces shaped by various forces and constraints.

homepage            http://facstaff.susqu.edu/brakke/evolver/evolver.html
master_sites        http://facstaff.susqu.edu/brakke/evolver/downloads/
distname            evolver-${version}

extract.mkdir       yes

platforms           darwin

checksums           rmd160  f6c7058523207d1ae336a173a07f97485be84f93 \
                    sha256  be7d60d9eb690f1fb124e2ecc12237a7a35be1935bfa5e92be3fe912207a3b6b \
                    size    3157309

patchfiles          patch-manpage-fix.diff

# This is performance-oriented software.
configure.cflags-replace \
                    -Os -O2

# The following is based on the "Mac OSX" section of Makefile:

configure.cflags-append \
                    -DLINUX -DPTHREADS -DOOGL -DMAC_OS_X -I${configure.sdkroot}/System/Library/Frameworks/GLUT.framework/Headers

build.args-append   CFLAGS="${configure.cflags}" \
                    GRAPH=glutgraph.o \
                    GRAPHLIB="-framework GLUT -framework OpenGL"

build.dir           ${worksrcpath}/src

# The default 'all' target is not present in this makefile.
build.target

destroot {
    # Install documentation

    set docdir ${prefix}/share/doc/${name}
    xinstall -d ${destroot}${docdir}

    xinstall -W ${worksrcpath} -m 0644 {*}[glob ${worksrcpath}/*.html] ${destroot}${docdir}
    xinstall -W ${worksrcpath} -m 0644 {*}[glob ${worksrcpath}/*.pdf] ${destroot}${docdir}
    xinstall -d ${destroot}${docdir}/doc
    xinstall -W ${worksrcpath} -m 0644 {*}[glob ${worksrcpath}/doc/*] ${destroot}${docdir}/doc

    # Install examples
    
    set exdir ${prefix}/share/${name}
    xinstall -d ${destroot}${exdir}

    xinstall -W ${worksrcpath} -m 0644 {*}[glob ${worksrcpath}/fe/*] ${destroot}${exdir}

    # Install man page

    xinstall -m 0644 ${worksrcpath}/evolver.1 ${destroot}${prefix}/share/man/man1

    # Install executable

    xinstall -W ${worksrcpath}/src evolver ${destroot}${prefix}/bin/evolver
}

notes               "Documentation is installed into ${prefix}/share/doc/${name}.\
                    Examples are in ${prefix}/share/${name}.
                    \nTo enable interactive help, set the EVOLVERPATH environment variable to\
                    ${prefix}/share/${name}:${prefix}/share/doc/${name}/doc"

livecheck.url       ${homepage}
livecheck.type      regex
livecheck.regex     {evolver-(\d+\.\d+)\.tar\.gz}
