# -*- 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 92837 2012-05-09 00:51:48Z ryandesign@macports.org $

PortSystem                  1.0

name                        gmt5
version                     5.0.0b
revision                    2
categories                  science
platforms                   darwin
maintainers                 eprofs.de:florian 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://www.soest.hawaii.edu/gmt5
master_sites                ftp://ftp.soest.hawaii.edu/gmt5          \
                            ftp://ibis.grdl.noaa.gov/pub/gmt5        \
                            ftp://ftp.iris.washington.edu/pub/gmt5   \
                            ftp://ftp.iag.usp.br/pub/gmt5            \
                            ftp://ftp.geologi.uio.no/pub/gmt5        \
                            ftp://gd.tuwien.ac.at/pub/gmt5           \
                            ftp://ftp.scc.u-tokai.ac.jp/pub/gmt5     \
                            ftp://mirror.geosci.usyd.edu.au/pub/gmt5 \
                            ftp://gmt.mirror.ac.za/pub/gmt5
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     c5b78de5edab4c42a8a08e7fcfa976b4 \
                    sha1    73b16b25e59fa1cd74bfc01bdeb8170924cbda0c \
                    rmd160  175a752b6a4027454a1163f638f2deb0abf62082 \
                    ${gshhs} \
                    md5     db98bff37adc0d51fdf0ffa3834d45ad \
                    sha1    786d58b9a335d3bacb37f40f21ee3bfbb424cd10 \
                    rmd160  aa744b2fdcdf849cc5c4abce97f1d29f4cdc20a4

worksrcdir                  GMT${version}

depends_lib                 port:netcdf \
                            port:pcre
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://www.soest.hawaii.edu/gmt5/gmt/gmt_home.html
livecheck.regex             {Current version is [^0-9 ]*([0-9]+\.[0-9]+\.[0-9a-z]+)}

