# -*- 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                gmt4
version             4.5.18
revision            6
categories          science
platforms           darwin
maintainers         {takeshi @tenomoto}
license             GPL-2
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 PostScript illustrations ranging from simple x-y  \
    plots via contour maps to artificially illuminated surfaces \
    and 3D perspective views.
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://gmt.mirror.ac.za/pub/gmt
use_bzip2           yes
distname            gmt-${version}
set dfile_gmt_gpl   ${distname}-src${extract.suffix}
set dfile_gmt_nogpl ${distname}-non-gpl-src${extract.suffix}
distfiles           ${dfile_gmt_gpl} \
                    ${dfile_gmt_nogpl}

checksums           ${dfile_gmt_gpl} \
                    rmd160  ae01001398eb754650629ce646c91b6d04c8c63c \
                    sha256  27c30b516c317fed8e44efa84a0262f866521d80cfe76a61bf12952efb522b63 \
                    size    39791396 \
                    ${dfile_gmt_nogpl} \
                    rmd160  0b783b62f887281c3f6c5b712734a6757a691941 \
                    sha256  460f7578d372b9b6c074488831255b2ae435a40ab2d8949c16966a786e1c3d9c \
                    size    103378

depends_lib         port:ghostscript \
                    port:gshhg-gmt \
                    port:netcdf

destroot.target     install-all
use_parallel_build  no
universal_variant   no
default_variants    +gdal +triangle

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 \
                            --with-gshhg-dir=${prefix}/share/gmt/gshhg \
                            --with-nc-config=${prefix}/bin/nc-config \
                            --enable-shared \
                            --enable-flock \
                            --disable-xgrid \
                            --disable-mex
configure.ldflags-delete    -L${prefix}/lib

post-destroot {
    ln -s ../lib/${name}/bin/GMT ${destroot}${prefix}/bin/${name}
    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} {
    license-delete          GPL-2
    license-append          Restrictive
    configure.args-append   --enable-triangle
}

variant xgrid description {enable xGridEdit} {
    depends_lib-append      lib:libXaw:xorg-libXaw
    configure.args-delete   --disable-xgrid
    configure.args-append   --enable-xgrid
}

livecheck.type      regex
livecheck.url       ${homepage}
livecheck.regex     {(?i)gmt-(4\.[0-9]+\.[0-9]+)<\/a>}