# -*- 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 101495 2013-01-11 22:02:59Z takeshi@macports.org $

PortSystem          1.0

name                gmt4
version             4.5.9
categories          science
platforms           darwin
maintainers         eprofs.de:florian \
                    takeshi
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 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 nameprefix      gmt
distname            ${nameprefix}-${version}
set dfile_gmt_gpl   ${distname}${extract.suffix}
set dfile_gmt_nogpl ${nameprefix}-${version}-non-gpl${extract.suffix}
distfiles           ${dfile_gmt_gpl} \
                    ${dfile_gmt_nogpl}

checksums           ${dfile_gmt_gpl} \
                    md5     9f241e97774eadd1fe79f4d7022fcaed \
                    sha1    711922fd99dcd47ace522f1e46fcafa5beab8c94 \
                    rmd160  67d36ecf68b9bcd9a38de61e4f1b3e1120c71823 \
                    ${dfile_gmt_nogpl} \
                    md5     d61a34a83dc630b464d472c6f0bdfc3a \
                    sha1    d03651d98a5f010090bceda2bbec09e53a543942 \
                    rmd160  a562f21b1e474d660cc5b9502543c127fb9fb801

worksrcdir          GMT${version}

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

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

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

post-destroot {
    ln -s ../lib/${name}/bin/GMT ${destroot}${prefix}/bin/${name}
    ln -s ../lib/${name}/bin/GMT ${destroot}${prefix}/bin/${nameprefix}
    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
}

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}/gmt/gmt_home.html
livecheck.regex     {Current version[^0-9]*([0-9]+\.[0-9]+\.[0-9]+)}
