# -*- 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 91552 2012-04-05 01:30:01Z takeshi@macports.org $

PortSystem                  1.0

name                        gmt4
version                     4.5.8
categories                  science
platforms                   darwin
maintainers                 takeshi
license                     LGPL-3
description                 the generic mapping tools
long_description GMT is an open source collection of ~65 tools  \
    for manipulating geographic and Cartesian data sets and     \
    producing Encapsulated PostScript File (EPS) illustrations  \
    ranging from simple x-y plots via contour maps to           \
    artificially illuminated surfaces and 3-D perspective views.
conflicts                   gmt
homepage                    http://gmt.soest.hawaii.edu/
master_sites                ftp://ftp.soest.hawaii.edu/gmt          \
                            ftp://ibis.grdl.noaa.gov/pub/gmt        \
                            ftp://ftp.iris.washington.edu/pub/gmt   \
                            ftp://ftp.iag.usp.br/pub/gmt            \
                            ftp://ftp.geologi.uio.no/pub/gmt        \
                            ftp://gd.tuwien.ac.at/pub/gmt           \
                            ftp://ftp.scc.u-tokai.ac.jp/pub/gmt     \
                            ftp://mirror.geosci.usyd.edu.au/pub/gmt \
                            ftp://gmt.mirror.ac.za/pub/gmt
use_bzip2                   yes
set gshhsversion            2.2.0
set gmtsrc                  gmt-${version}.tar.bz2
set gshhs                   gshhs-${gshhsversion}.tar.bz2
distfiles                   ${gmtsrc} ${gshhs}
checksums           ${gmtsrc} \
                    md5     8a3fa928bcb8a82ebaed68d62ba8f1ba \
                    sha1    823783c1abc9a7e0493c35661e516d4f607fff17 \
                    rmd160  faa58f8c35a4e00f5a9515066b90e08a940cb0d6 \
                    ${gshhs} \
                    md5     db98bff37adc0d51fdf0ffa3834d45ad \
                    sha1    786d58b9a335d3bacb37f40f21ee3bfbb424cd10 \
                    rmd160  aa744b2fdcdf849cc5c4abce97f1d29f4cdc20a4

worksrcdir                  GMT${version}

depends_lib                 port:netcdf

post-extract {
    # move GSHHS coastlines to worksrcpath
    system "mv ${workpath}/share/coast ${worksrcpath}/share && rmdir ${workpath}/share"
    system "mv ${workpath}/{LICENSE.TXT,README.TXT} ${worksrcpath}/share/coast"
}

configure.pre_args          --prefix=${prefix}/lib/${name}
configure.args              --datarootdir=${prefix}/share/${name} \
                            --docdir=${prefix}/share/doc/${name} \
                            --mandir=${prefix}/share/doc/${name}/man \
                            --includedir=${prefix}/share/${name}/include \
                            --enable-shared \
                            --enable-flock \
                            --disable-xgrid \
                            --disable-mex
configure.optflags-delete   -O2

use_parallel_build          no
universal_variant           no
destroot.target             install-all
configure.ldflags-delete    -L${prefix}/lib

post-destroot {
    ln -s ../doc/${name} ${destroot}${prefix}/share/${name}/doc
    ln -s ../../share/doc/${name}/man ${destroot}${prefix}/lib/${name}/man
    ln -s ../../share/${name}/include ${destroot}${prefix}/lib/${name}/include
    ln -s ../../share/${name} ${destroot}${prefix}/lib/${name}/share
}

variant octave description {compiles Octave interface} {
    depends_lib-append      path:bin/octave:octave
    configure.args-append   --enable-octave
}

variant gdal description {Experimental GDAL import support} {
    depends_lib-append      port:gdal
    configure.args-append   --enable-gdal
}

variant triangle description {use J. Shewchuk's fast, non-GPL triangulation routine} {
    configure.args-append   --enable-triangle
}

livecheck.type              regex
livecheck.url               http://gmt.soest.hawaii.edu/gmt/gmt_home.html
livecheck.regex             {Current version is [^0-9 ]*([0-9]+\.[0-9]+\.[0-9]+)}

