homebrew-core/Formula/gdal.rb

188 lines
5.8 KiB
Ruby

class Gdal < Formula
desc "Geospatial Data Abstraction Library"
homepage "https://www.gdal.org/"
url "http://download.osgeo.org/gdal/3.5.2/gdal-3.5.2.tar.xz"
sha256 "0874dfdeb9ac42e53c37be4184b19350be76f0530e1f4fa8004361635b9030c2"
license "MIT"
livecheck do
url "https://download.osgeo.org/gdal/CURRENT/"
regex(/href=.*?gdal[._-]v?(\d+(?:\.\d+)+)\.t/i)
end
bottle do
sha256 arm64_monterey: "4b31af5bfb44a3a64d6bc04a4cd6650bd4e9e4993997c54f11a49d9094fc5d85"
sha256 arm64_big_sur: "441f7390ab812fcfe17ead6020e08fd6b76e60d8484b5cbfa3fcfac5da7c3a4b"
sha256 monterey: "fa73f2ce395854b62a662453ab783c38e296df47005f0fd2955a522177a3eb30"
sha256 big_sur: "8ff12e2b1438b193410d46d08aaf0aa083162cbc1ade3d46da547d3d8c3f9e2e"
sha256 catalina: "8cf46e405bd9f54823532e5abf58ccab529d430cc64d0e8bcba7b8fc7bed96a4"
sha256 x86_64_linux: "b7df41973128eca2d3f11696ee6909f785f2214114a59134bcf6a69a0f9c6307"
end
head do
url "https://github.com/OSGeo/gdal.git", branch: "master"
depends_on "doxygen" => :build
end
depends_on "pkg-config" => :build
depends_on "cfitsio"
depends_on "epsilon"
depends_on "expat"
depends_on "freexl"
depends_on "geos"
depends_on "giflib"
depends_on "hdf5"
depends_on "jpeg-turbo"
depends_on "json-c"
depends_on "libdap"
depends_on "libgeotiff"
depends_on "libpng"
depends_on "libpq"
depends_on "libspatialite"
depends_on "libtiff"
depends_on "libxml2"
depends_on "netcdf"
depends_on "numpy"
depends_on "openjpeg"
depends_on "pcre2"
depends_on "poppler"
depends_on "proj"
depends_on "python@3.10"
depends_on "sqlite"
depends_on "unixodbc"
depends_on "webp"
depends_on "xerces-c"
depends_on "xz"
depends_on "zstd"
uses_from_macos "curl"
on_linux do
depends_on "util-linux"
end
conflicts_with "avce00", because: "both install a cpl_conv.h header"
conflicts_with "cpl", because: "both install cpl_error.h"
fails_with gcc: "5"
def python3
"python3.10"
end
def install
args = [
# Base configuration
"--prefix=#{prefix}",
"--mandir=#{man}",
"--disable-debug",
"--with-libtool",
"--with-local=#{prefix}",
"--with-threads",
# GDAL native backends
"--with-pam",
"--with-pcidsk=internal",
"--with-pcraster=internal",
# Homebrew backends
"--with-expat=#{Formula["expat"].prefix}",
"--with-freexl=#{Formula["freexl"].opt_prefix}",
"--with-geos=#{Formula["geos"].opt_prefix}/bin/geos-config",
"--with-geotiff=#{Formula["libgeotiff"].opt_prefix}",
"--with-gif=#{Formula["giflib"].opt_prefix}",
"--with-jpeg=#{Formula["jpeg-turbo"].opt_prefix}",
"--with-libjson-c=#{Formula["json-c"].opt_prefix}",
"--with-libtiff=#{Formula["libtiff"].opt_prefix}",
"--with-pg=yes",
"--with-png=#{Formula["libpng"].opt_prefix}",
"--with-spatialite=#{Formula["libspatialite"].opt_prefix}",
"--with-pcre2=yes",
"--with-sqlite3=#{Formula["sqlite"].opt_prefix}",
"--with-proj=#{Formula["proj"].opt_prefix}",
"--with-zstd=#{Formula["zstd"].opt_prefix}",
"--with-liblzma=yes",
"--with-cfitsio=#{Formula["cfitsio"].opt_prefix}",
"--with-hdf5=#{Formula["hdf5"].opt_prefix}",
"--with-netcdf=#{Formula["netcdf"].opt_prefix}",
"--with-openjpeg",
"--with-xerces=#{Formula["xerces-c"].opt_prefix}",
"--with-odbc=#{Formula["unixodbc"].opt_prefix}",
"--with-dods-root=#{Formula["libdap"].opt_prefix}",
"--with-epsilon=#{Formula["epsilon"].opt_prefix}",
"--with-webp=#{Formula["webp"].opt_prefix}",
"--with-poppler=#{Formula["poppler"].opt_prefix}",
# Explicitly disable some features
"--with-armadillo=no",
"--with-qhull=no",
"--without-exr",
"--without-grass",
"--without-jasper",
"--without-jpeg12",
"--without-libgrass",
"--without-mysql",
"--without-perl",
"--without-python",
# Unsupported backends are either proprietary or have no compatible version
# in Homebrew. Podofo is disabled because Poppler provides the same
# functionality and then some.
"--without-ecw",
"--without-fgdb",
"--without-fme",
"--without-gta",
"--without-hdf4",
"--without-idb",
"--without-ingres",
"--without-jp2mrsid",
"--without-kakadu",
"--without-mrsid",
"--without-mrsid_lidar",
"--without-msg",
"--without-oci",
"--without-ogdi",
"--without-podofo",
"--without-rasdaman",
"--without-sde",
"--without-sosi",
]
if OS.mac?
args << "--with-curl=/usr/bin/curl-config"
args << "--with-opencl"
else
args << "--with-curl=#{Formula["curl"].opt_bin}/curl-config"
# The python build needs libgdal.so, which is located in .libs
ENV.append "LDFLAGS", "-L#{buildpath}/.libs"
# The python build needs gnm headers, which are located in the gnm folder
ENV.append "CFLAGS", "-I#{buildpath}/gnm"
end
system "./configure", *args
system "make"
system "make", "install"
# Build Python bindings
cd "swig/python" do
system python3, *Language::Python.setup_install_args(prefix, python3)
end
bin.install buildpath.glob("swig/python/scripts/*.py")
system "make", "man" if build.head?
# Force man installation dir: https://trac.osgeo.org/gdal/ticket/5092
system "make", "install-man", "INST_MAN=#{man}"
# Clean up any stray doxygen files
bin.glob("*.dox").map(&:unlink)
end
test do
# basic tests to see if third-party dylibs are loading OK
system bin/"gdalinfo", "--formats"
system bin/"ogrinfo", "--formats"
# Changed Python package name from "gdal" to "osgeo.gdal" in 3.2.0.
system python3, "-c", "import osgeo.gdal"
end
end