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

name                grace
version             5.1.25
revision            6
categories          x11 math science print
license             GPL-2+
maintainers         nomaintainer
description         WYSIWYG tool to make two-dimensional plots of numerical data
long_description    ${description}

homepage            http://plasma-gate.weizmann.ac.il/Grace/
set sub             grace/src/stable/
master_sites        ftp://ftp.fu-berlin.de/unix/graphics/${sub} \
                    ftp://ftp.u-aizu.ac.jp/pub/SciEng/math/${sub}

checksums           rmd160  3fff22b3ceaaffddd81c8d23d26623f2e8f87c7c \
                    sha256  751ab9917ed0f6232073c193aba74046037e185d73b77bab0f5af3e3ff1da2ac \
                    size    2957689

depends_lib         lib:libXm:openmotif \
                    path:include/turbojpeg.h:libjpeg-turbo \
                    port:libpng \
                    port:pdflib \
                    port:xorg-libXmu \
                    port:xorg-libXp \
                    port:xpm \
                    port:zlib

depends_run         port:openbrowser

patchfiles          implicit.patch \
                    patch-implicit-Xbae.diff \
                    patch-implicit-src.diff

# The default optimization level apparently causes xmgrace to crash for some users.
configure.optflags  -O1
configure.pre_args  --prefix=${prefix}/lib
configure.args      --with-helpviewer="${prefix}/bin/openbrowser ${prefix}/share/doc/${name}/`basename %s`" \
                    --disable-netcdf \
                    --x-include=${prefix}/include --x-lib=${prefix}/lib --with-bundled-t1lib=yes

post-destroot {
    xinstall -m 755 -d ${destroot}${prefix}/share/doc
    file delete ${destroot}${prefix}/bin
    file rename ${destroot}${prefix}/lib/grace/bin ${destroot}${prefix}/bin
    file rename ${destroot}${prefix}/lib/grace/doc ${destroot}${prefix}/share/doc/${name}
    file rename ${destroot}${prefix}/lib/grace/examples ${destroot}${prefix}/share/doc/${name}/examples
    file rename ${destroot}${prefix}/lib/grace/include/grace_np.h ${destroot}${prefix}/include/grace_np.h
    file rename ${destroot}${prefix}/lib/grace/lib/libgrace_np.a ${destroot}${prefix}/lib/libgrace_np.a
    system "cd ${destroot}${prefix}/share/doc/${name} && ln -s . doc"
    system "cd ${destroot}${prefix}/share && mv doc/grace/*.1 man/man1/"
}

variant netcdf description {Support for NetCDF data files} {
    depends_lib-append      port:netcdf
    configure.args-replace  --disable-netcdf --enable-netcdf
}

livecheck.type      regex
livecheck.url       [lindex ${master_sites} 0]
livecheck.regex     ${name}-(\[0-9.\]+)${extract.suffix}
