1{ lib, stdenv, fetchFromGitHub, fetchpatch, unzip, libjpeg, libtiff, zlib, postgresql
2, libmysqlclient, libgeotiff, pythonPackages, proj, geos, openssl, libpng
3, sqlite, libspatialite, poppler, hdf4, qhull, giflib, expat, libiconv, libxml2
4, autoreconfHook, netcdfSupport ? true, netcdf, hdf5, curl, pkg-config }:
5
6with lib;
7
8stdenv.mkDerivation rec {
9 pname = "gdal";
10 version = "3.3.2";
11
12 src = fetchFromGitHub {
13 owner = "OSGeo";
14 repo = "gdal";
15 rev = "v${version}";
16 sha256 = "sha256-fla3EMDmuW0+vmmU0sgtLsGfO7dDApLQ2EoKJeR/1IM=";
17 };
18
19 sourceRoot = "source/gdal";
20
21 nativeBuildInputs = [ autoreconfHook pkg-config unzip ];
22
23 buildInputs = [
24 libjpeg
25 libtiff
26 libpng
27 proj
28 openssl
29 sqlite
30 libspatialite
31 libgeotiff
32 poppler
33 hdf4
34 qhull
35 giflib
36 expat
37 libxml2
38 postgresql
39 ] ++ (with pythonPackages; [ python numpy wrapPython ])
40 ++ lib.optional stdenv.isDarwin libiconv
41 ++ lib.optionals netcdfSupport [ netcdf hdf5 curl ];
42
43 configureFlags = [
44 "--with-expat=${expat.dev}"
45 "--with-jpeg=${libjpeg.dev}"
46 "--with-libtiff=${libtiff.dev}" # optional (without largetiff support)
47 "--with-png=${libpng.dev}" # optional
48 "--with-poppler=${poppler.dev}" # optional
49 "--with-libz=${zlib.dev}" # optional
50 "--with-pg=yes" # since gdal 3.0 doesn't use ${postgresql}/bin/pg_config
51 "--with-mysql=${getDev libmysqlclient}/bin/mysql_config"
52 "--with-geotiff=${libgeotiff}"
53 "--with-sqlite3=${sqlite.dev}"
54 "--with-spatialite=${libspatialite.dev}"
55 "--with-python" # optional
56 "--with-proj=${proj.dev}" # optional
57 "--with-geos=${geos}/bin/geos-config" # optional
58 "--with-hdf4=${hdf4.dev}" # optional
59 "--with-xml2=yes" # optional
60 (if netcdfSupport then "--with-netcdf=${netcdf}" else "")
61 ];
62
63 hardeningDisable = [ "format" ];
64
65 CXXFLAGS = "-fpermissive";
66
67 # - Unset CC and CXX as they confuse libtool.
68 # - teach gdal that libdf is the legacy name for libhdf
69 preConfigure = ''
70 substituteInPlace configure \
71 --replace "-lmfhdf -ldf" "-lmfhdf -lhdf"
72 '';
73
74 preBuild = ''
75 substituteInPlace swig/python/GNUmakefile \
76 --replace "ifeq (\$(STD_UNIX_LAYOUT),\"TRUE\")" "ifeq (1,1)"
77 '';
78
79 postInstall = ''
80 wrapPythonPrograms
81 '';
82
83 enableParallelBuilding = true;
84
85 meta = {
86 description = "Translator library for raster geospatial data formats";
87 homepage = "https://www.gdal.org/";
88 license = lib.licenses.mit;
89 maintainers = [ lib.maintainers.marcweber ];
90 platforms = with lib.platforms; linux ++ darwin;
91 };
92}