# -*- 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
# $Id: Portfile 102822 2013-02-09 00:51:24Z jmr@macports.org $

PortSystem 1.0

name			    grace
version			    5.1.23
revision        1
categories		    x11 math science print
license             GPL-2+
platforms		    darwin
maintainers		    nomaintainer
description		    WYSIWYG tool to make two-dimensional plots of numerical data
long_description	${description}
use_parallel_build	yes

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  c990d0f0b836eb6d6e3080c47015a86aca074494 \
                    sha256  69527950fd9c056a76b7a6bf4ac37a9b87acc565c12a941ffae3c9c5a822ca10

depends_lib \
	port:xorg-libXmu \
	port:xorg-libXp \
	port:xpm \
	port:libpng \
	lib:libXm:openmotif \
	port:pdflib \
	port:jpeg \
	port:zlib

depends_run         port:openbrowser

patchfiles          patch-configure.diff

configure.pre_args  --prefix=${prefix}/lib
configure.args      --with-helpviewer="${prefix}/bin/openbrowser ${prefix}/share/doc/${name}/`basename %s`" \
                    --x-include=${prefix}/include --x-lib=${prefix}/lib

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-append    --enable-netcdf
}

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