easyblock = "CMakeMake"

name = "GMT"
version = "5.2.1"

homepage = 'http://gmt.soest.hawaii.edu/'
description = """GMT is an open source collection of about 80 command-line tools for manipulating
 geographic and Cartesian data sets (including filtering, trend fitting, gridding, projecting,
 etc.) and producing PostScript illustrations ranging from simple x-y plots via contour maps
 to artificially illuminated surfaces and 3D perspective views; the GMT supplements add another
 40 more specialized and discipline-specific tools. """

toolchain = {'name': 'foss', 'version': '2015g'}

local_gshhg_ver = '2.3.4'
local_dcw_ver = '1.1.2'
sources = [
    'gmt-%(version)s-src.tar.gz',
    # coastlines, rivers, and political boundaries
    'gshhg-gmt-%s.tar.gz' % local_gshhg_ver,
    # country polygons
    'dcw-gmt-%s.tar.gz' % local_dcw_ver,
]

# 'http://gmt.soest.hawaii.edu/files/download?name=' needs flash enabled browser
source_urls = [
    'http://ftp.soest.hawaii.edu/gmt',
    #    'ftp://ftp.soest.hawaii.edu/gmt/legacy',
    #    'ftp://ftp.soest.hawaii.edu/gshhg',
    #    'ftp://ftp.soest.hawaii.edu/gshhg/legacy',
    #    'ftp://ftp.soest.hawaii.edu/dcw',
    #    'ftp://ftp.soest.hawaii.edu/dcw/legacy',
]

#patches = ['GMT-%(version)s_netCDF.patch']

builddependencies = [('CMake', '3.3.1')]

dependencies = [
    ('PCRE', '8.36'),
    ('GDAL', '1.9.2'),
    ('FFTW', '3.3.4', '', ('gompi', '2015g')),
    ('netCDF', '4.3.2'),
    #    ('Ghostscript', '9.14'),
]

preconfigopts = "export CMAKE_LIBRARY_PATH=$LD_LIBRARY_PATH && "

configopts = '-DCOPY_GSHHG=TRUE -DGSHHG_ROOT=%%(builddir)s/gshhg-gmt-%s ' % local_gshhg_ver
configopts += '-DCOPY_DCW=TRUE -DDCW_ROOT=%%(builddir)s/dcw-gmt-%s ' % local_dcw_ver
configopts += '-DHAVE_NETCDF4=1 '

separate_build_dir = True

sanity_check_paths = {
    'files': ['bin/gmt', 'bin/isogmt'],
    'dirs': []
}

modextrapaths = {'GMTHOME': ''}

moduleclass = 'geo'
