summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/grass/package.py
blob: 01adc4587bcddd6cc411a24e45e52d2cf0ada614 (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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# Copyright 2013-2024 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.package import *


class Grass(AutotoolsPackage):
    """GRASS GIS (Geographic Resources Analysis Support System), is a free
    and open source Geographic Information System (GIS) software suite
    used for geospatial data management and analysis, image processing,
    graphics and maps production, spatial modeling, and visualization."""

    homepage = "https://grass.osgeo.org"
    url = "https://grass.osgeo.org/grass78/source/grass-7.8.5.tar.gz"
    list_url = "https://grass.osgeo.org/download/software/sources/"
    git = "https://github.com/OSGeo/grass.git"

    maintainers("adamjstewart")

    license("MIT")

    version("master", branch="master")
    version("8.2.0", sha256="621c3304a563be19c0220ae28f931a5e9ba74a53218c5556cd3f7fbfcca33a80")
    version("7.8.5", sha256="a359bb665524ecccb643335d70f5436b1c84ffb6a0e428b78dffebacd983ff37")
    version("7.8.2", sha256="33576f7078f805b39ca20c2fa416ac79c64260c0581072a6dc7d813f53aa9abb")
    version("7.8.1", sha256="6ae578fd67afcce7abec4ba4505dcc55b3d2dfe0ca46b99d966cb148c654abb3")
    version("7.8.0", sha256="4b1192294e959ffd962282344e4ff325c4472f73abe605e246a1da3beda7ccfa")

    variant("cxx", default=True, description="Support C++ functionality")
    variant("tiff", default=False, description="Support TIFF functionality")
    variant("png", default=False, description="Support PNG functionality")
    variant("postgres", default=False, description="Support PostgreSQL functionality")
    variant("mysql", default=False, description="Support MySQL functionality")
    variant("sqlite", default=False, description="Support SQLite functionality")
    variant("opengl", default=False, description="Support OpenGL functionality")
    variant("odbc", default=False, description="Support ODBC functionality")
    variant("fftw", default=False, description="Support FFTW functionality")
    variant("blas", default=False, description="Support BLAS functionality")
    variant("lapack", default=False, description="Support LAPACK functionality")
    variant("cairo", default=False, description="Support Cairo functionality")
    variant("freetype", default=False, description="Support FreeType functionality")
    variant("readline", default=False, description="Support Readline functionality")
    variant("regex", default=False, description="Support regex functionality")
    variant("pthread", default=False, description="Support POSIX threads functionality")
    variant("openmp", default=False, description="Support OpenMP functionality")
    variant("opencl", default=False, description="Support OpenCL functionality")
    variant("bzlib", default=False, description="Support BZIP2 functionality")
    variant("zstd", default=False, description="Support Zstandard functionality")
    variant("gdal", default=True, description="Enable GDAL/OGR support")
    variant("liblas", default=False, description="Enable libLAS support")
    variant("wxwidgets", default=False, description="Enable wxWidgets support")
    variant("netcdf", default=False, description="Enable NetCDF support")
    variant("geos", default=False, description="Enable GEOS support")
    variant("x", default=False, description="Use the X Window System")

    # https://htmlpreview.github.io/?https://github.com/OSGeo/grass/blob/master/REQUIREMENTS.html
    # General requirements
    depends_on("gmake@3.81:", type="build")
    depends_on("iconv")
    depends_on("zlib-api")
    depends_on("flex", type="build")
    depends_on("bison", type="build")
    depends_on("proj")
    # GRASS 7.8.0 was supposed to support PROJ 6, but it still checks for
    # share/proj/epsg, which was removed in PROJ 6
    depends_on("proj@:5", when="@:7.8.0")
    # PROJ6 support released in GRASS 7.8.1
    # https://courses.neteler.org/grass-gis-7-8-1-released-with-proj-6-and-gdal-3-support/
    depends_on("proj@6:", when="@7.8.1:")
    depends_on("python@2.7:", type=("build", "run"))
    depends_on("py-six", when="@7.8:", type=("build", "run"))

    # Optional packages
    depends_on("libtiff", when="+tiff")
    depends_on("libpng", when="+png")
    depends_on("postgresql", when="+postgres")
    depends_on("mariadb", when="+mysql")
    depends_on("sqlite", when="+sqlite")
    depends_on("gl", when="+opengl")
    depends_on("unixodbc", when="+odbc")
    depends_on("fftw", when="+fftw")
    depends_on("blas", when="+blas")
    depends_on("lapack", when="+lapack")
    depends_on("cairo@1.5.8:", when="+cairo")
    depends_on("freetype", when="+freetype")
    depends_on("readline", when="+readline")
    depends_on("opencl", when="+opencl")
    depends_on("bzip2", when="+bzlib")
    depends_on("zstd", when="+zstd")
    depends_on("gdal", when="+gdal")
    conflicts("^gdal@3.3:", when="@7.8")
    depends_on("liblas", when="+liblas")
    depends_on("wxwidgets", when="+wxwidgets")
    depends_on("py-wxpython@2.8.10.1:", when="+wxwidgets", type=("build", "run"))
    depends_on("netcdf-c", when="+netcdf")
    depends_on("geos", when="+geos")
    depends_on("libx11", when="+x")

    def url_for_version(self, version):
        url = "https://grass.osgeo.org/grass{0}/source/grass-{1}.tar.gz"
        return url.format(version.up_to(2).joined, version)

    # https://grasswiki.osgeo.org/wiki/Compile_and_Install
    def configure_args(self):
        spec = self.spec

        args = [
            "--without-nls",
            # TODO: add packages for these optional dependencies
            "--without-opendwg",
            "--without-pdal",
            "--with-proj-share={0}".format(spec["proj"].prefix.share.proj),
        ]

        if "+cxx" in spec:
            args.append("--with-cxx")
        else:
            args.append("--without-cxx")

        if "+tiff" in spec:
            args.append("--with-tiff")
        else:
            args.append("--without-tiff")

        if "+png" in spec:
            args.append("--with-png")
        else:
            args.append("--without-png")

        if "+postgres" in spec:
            args.append("--with-postgres")
        else:
            args.append("--without-postgres")

        if "+mysql" in spec:
            args.append("--with-mysql")
        else:
            args.append("--without-mysql")

        if "+sqlite" in spec:
            args.append("--with-sqlite")
        else:
            args.append("--without-sqlite")

        if "+opengl" in spec:
            args.append("--with-opengl")
        else:
            args.append("--without-opengl")

        if "+odbc" in spec:
            args.append("--with-odbc")
        else:
            args.append("--without-odbc")

        if "+fftw" in spec:
            args.append("--with-fftw")
        else:
            args.append("--without-fftw")

        if "+blas" in spec:
            args.append("--with-blas")
        else:
            args.append("--without-blas")

        if "+lapack" in spec:
            args.append("--with-lapack")
        else:
            args.append("--without-lapack")

        if "+cairo" in spec:
            args.append("--with-cairo")
        else:
            args.append("--without-cairo")

        if "+freetype" in spec:
            args.append("--with-freetype")
        else:
            args.append("--without-freetype")

        if "+readline" in spec:
            args.append("--with-readline")
        else:
            args.append("--without-readline")

        if "+regex" in spec:
            args.append("--with-regex")
        else:
            args.append("--without-regex")

        if "+pthread" in spec:
            args.append("--with-pthread")
        else:
            args.append("--without-pthread")

        if "+openmp" in spec:
            args.append("--with-openmp")
        else:
            args.append("--without-openmp")

        if "+opencl" in spec:
            args.append("--with-opencl")
        else:
            args.append("--without-opencl")

        if "+bzlib" in spec:
            args.append("--with-bzlib")
        else:
            args.append("--without-bzlib")

        if "+zstd" in spec:
            args.append("--with-zstd")
        else:
            args.append("--without-zstd")

        if "+gdal" in spec:
            args.append("--with-gdal={0}/gdal-config".format(spec["gdal"].prefix.bin))
        else:
            args.append("--without-gdal")

        if "+liblas" in spec:
            args.append("--with-liblas={0}/liblas-config".format(spec["liblas"].prefix.bin))
        else:
            args.append("--without-liblas")

        if "+wxwidgets" in spec:
            args.append("--with-wxwidgets={0}/wx-config".format(spec["wxwidgets"].prefix.bin))
        else:
            args.append("--without-wxwidgets")

        if "+netcdf" in spec:
            args.append("--with-netcdf={0}/bin/nc-config".format(spec["netcdf-c"].prefix))
        else:
            args.append("--without-netcdf")

        if "+geos" in spec:
            args.append("--with-geos={0}/bin/geos-config".format(spec["geos"].prefix))
        else:
            args.append("--without-geos")

        if "+x" in spec:
            args.append("--with-x")
        else:
            args.append("--without-x")

        return args

    # see issue: https://github.com/spack/spack/issues/11325
    # 'Platform.make' is created after configure step
    # hence invoke the following function afterwards
    @run_after("configure")
    def fix_iconv_linking(self):
        if self.spec["iconv"].name != "libiconv":
            return

        makefile = FileFilter("include/Make/Platform.make")
        makefile.filter(r"^ICONVLIB\s*=.*", "ICONVLIB = -liconv")