# GDAL/OGR plugin support for GRASS GIS 8
# This file is Free Software under GNU GPL v>=2.

Summary:	GDAL/OGR support for GRASS
Name:		gdal-grass
Version:	1.0.2
Release:	2%{?dist}
Source0:	https://github.com/OSGeo/gdal-grass/archive/refs/tags/%{name}-%{version}.tar.gz
License:	MIT
URL:		https://gdal.org/

BuildRequires:	gcc-c++
BuildRequires:	gcc
BuildRequires:	make
# BuildRequires:	gdal-devel >= 3.4.3
# for GDAL < 3.4.3 needs patch https://github.com/OSGeo/gdal/pull/5503:
BuildRequires:  gdal-devel
BuildRequires:	gdal-libs
BuildRequires:	geos-devel
BuildRequires:	grass >= 8.0.0
BuildRequires:	grass-devel >= 8.0.0
BuildRequires:	grass-libs >= 8.0.0
BuildRequires:	postgresql-devel
BuildRequires:	proj-devel
BuildRequires:	zlib-devel
Requires:	proj
Requires:	zlib
Requires:	grass >= 8.0.0
Requires:	grass-libs >= 8.0.0

%description
GDAL and OGR support for GRASS GIS created from %{name}-%{version}-%{release}

%global debug_package %{nil}

%prep
%setup -q

# Building GRASS Plugin
AUTOLOAD=%{_libdir}/gdalplugins
mkdir -p ${AUTOLOAD}

# get major version
GRASS_VERSION_MAJOR=`grass --config path | cut -d'/' -f4`

sh configure \
 --prefix=%{_prefix} \
 --with-grass=%{_libdir}/$GRASS_VERSION_MAJOR \
 --with-gdal=%{_prefix}/bin/gdal-config \
 --with-autoload=${AUTOLOAD}


%build
make %{?_smp_mflags}

%install
%make_install install

%files
%{_libdir}/gdalplugins/gdal_GRASS.so
%{_libdir}/gdalplugins/ogr_GRASS.so
## /etc/ld.so.conf.d/gdal-grass.conf

%changelog
* Sat Mar 02 2024 Markus Neteler <neteler@mundialis.de> - 1.0.2-2
- avoid hardcoded GRASS GIS version number

* Sun Jan 29 2023 Markus Neteler <neteler@mundialis.de> - 1.0.2-1
- New upstream version

* Tue May 03 2022 Markus Neteler <neteler@mundialis.de> - 1.0.0-1
- GDAL-GRASS GIS driver release from own repo (https://github.com/OSGeo/gdal-grass/)
- Update to GRASS GIS 8