# Template file for 'libgdal'
pkgname=libgdal
version=3.5.3
revision=5
build_style=cmake
build_helper=python3
configure_args="-DGDAL_USE_OPENCL=ON
 -DPython_NumPy_INCLUDE_DIR=/${py3_sitelib}/numpy/core/include/numpy"
hostmakedepends="pkg-config bison swig python3-numpy"
makedepends="python3-devel freexl-devel c-blosc-devel geos-devel expat-devel
 jasper-devel giflib-devel json-c-devel libcurl-devel libopenexr-devel
 libjpeg-turbo-devel libpng-devel tiff-devel libqhull-devel libwebp-devel
 libxml2-devel liblzma-devel zlib-devel libzstd-devel libdeflate-devel
 netcdf-devel opencl2-headers pcre2-devel proj-devel sqlite-devel
 ocl-icd-devel libxerces-c-devel libspatialite-devel
 postgresql-libs-devel"
checkdepends="python3-pytest"
short_desc="Geospatial Data Abstraction Library"
maintainer="Orphaned <orphan@voidlinux.org>"
license="MIT"
homepage="https://www.gdal.org"
changelog="https://github.com/OSGeo/gdal/raw/v${version}/NEWS.md"
distfiles="https://download.osgeo.org/gdal/${version}/gdal-${version}.tar.xz"
checksum=d32223ddf145aafbbaec5ccfa5dbc164147fb3348a3413057f9b1600bb5b3890
subpackages="libgdal-devel libgdal-tools libgdal-python3"
python_version=3

if [ -z "$CROSS_BUILD" ]; then
	makedepends+=" hdf5-devel"
	case "$XBPS_TARGET_MACHINE" in
		ppc|ppc-musl) ;;
		*) makedepends+=" armadillo-devel";;
	esac
fi

# "error: static assertion failed: OFF_T should be 64 bits !"
if [ "$XBPS_TARGET_WORDSIZE" = "64" ]; then
	makedepends+=" cfitsio-devel"
fi

post_install() {
	vlicense LICENSE.TXT
}

libgdal-tools_package() {
	depends="${sourcepkg}>=${version}_${revision}"
	short_desc+=" - tools"
	pkg_install() {
		vmove usr/share/man/man1
		vmove usr/share/bash-completion
		vmove usr/bin
	}
}

libgdal-devel_package() {
	depends="${sourcepkg}>=${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/bin/gdal-config
		vmove usr/share/man/man1/gdal-config.1
		vmove usr/include
		vmove usr/lib/pkgconfig
		vmove usr/lib/cmake
		vmove "usr/lib/*.so"
	}
}

libgdal-python3_package() {
	depends="${sourcepkg}>=${version}_${revision}"
	short_desc+=" - python3 bindings"
	pkg_install() {
		vmove ${py3_sitelib}
	}
}
