summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/gmt/package.py
blob: f60b9660ce18f9c83f3a92562e26d0b1be6c3b2e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from spack import *


class Gmt(Package):
    """GMT (Generic Mapping Tools) 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.
    """

    homepage = "http://gmt.soest.hawaii.edu/"
    url      = "https://github.com/GenericMappingTools/gmt/archive/5.4.4.tar.gz"

    version('5.4.4', sha256='b593dfb101e6507c467619f3d2190a9f78b09d49fe2c27799750b8c4c0cd2da0')
    version('4.5.9', sha256='9b13be96ccf4bbd38c14359c05dfa7eeeb4b5f06d6f4be9c33d6c3ea276afc86',
            url='ftp://ftp.soest.hawaii.edu/gmt/legacy/gmt-4.5.9.tar.bz2')

    variant('pcre', default=False, description='Enable the PCRE interface')
    variant('gdal', default=False, description='Enable the GDAL interface')
    variant('fftw', default=True, description='Fast FFTs')
    variant('lapack', default=True, description='Fast matrix inversion')
    variant('blas', default=True, description='Fast matrix multiplications')

    # http://gmt.soest.hawaii.edu/projects/gmt/wiki/BuildingGMT

    # Required dependencies
    depends_on('ghostscript')
    depends_on('subversion')
    depends_on('cmake@2.8.5:', type='build', when='@5:')
    depends_on('netcdf@4:')
    depends_on('curl', when='@5.4:')

    # Optional dependencies
    depends_on('pcre', when='+pcre')
    depends_on('gdal', when='+gdal')
    depends_on('fftw', when='+fftw')
    depends_on('lapack', when='+lapack')
    depends_on('blas', when='+blas')
    depends_on('graphicsmagick', type='test')

    patch('type.patch', when='@4.5.9')

    @when('@5:')
    def install(self, spec, prefix):
        with working_dir('spack-build', create=True):
            cmake('..', *std_cmake_args)

            make()
            make('install')

    @when('@:4')
    def install(self, spec, prefix):
        args = [
            '--prefix={0}'.format(prefix),
            '--enable-netcdf={0}'.format(spec['netcdf'].prefix),
            '--enable-shared',
            '--without-x'
        ]

        if '+gdal' in spec:
            args.append('--enable-gdal')
        else:
            args.append('--disable-gdal')

        configure(*args)

        # Building in parallel results in dozens of errors like:
        # *** No rule to make target `../libgmtps.so', needed by `pssegyz'.
        make(parallel=False)

        # Installing in parallel results in dozens of errors like:
        # /usr/bin/install: cannot create directory '...': File exists
        make('install', parallel=False)