%global proj_somaj 12

# Tests can be of a different version
%global run_tests 0

%global bashcompletiondir %(pkg-config --variable=compatdir bash-completion)

%if 0%{?bootstrap}
%global build_refman 0
%global with_mysql 0
%global mysql --without-mysql
%global with_poppler 0
%global poppler --without-poppler
%global with_spatialite 0
%global spatialite --without-spatialite
%else
# Enable/disable generating refmans
# texlive currently broken deps and FTBFS in rawhide
%global build_refman 1
# https://bugzilla.redhat.com/show_bug.cgi?id=1490492
%global with_mysql 1
%global mysql --with-mysql
# https://bugzilla.redhat.com/show_bug.cgi?id=1490492
%global with_poppler 1
%global poppler --with-poppler
%global with_spatialite 1
%global spatialite "--with-spatialite"
%endif
%global with_python2 0


Name:		gdal
Version:	2.3.1
Release:	1
Summary:	GIS file format library
Group:		System Environment/Libraries
License:	MIT
URL:		http://www.gdal.org

Source0:	https://github.com/OSGeo/gdal/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:	%{name}.pom


# Patch to use system g2clib
# Patch for JNI library location
# Fix bash-completion install dir
Patch0:         %{name}-completion.patch

# Alternatives for Java
Patch1:         %{name}-1.9.0-java.patch
Patch2:         %{name}-2.3.0-zlib.patch

# https://github.com/OSGeo/gdal/pull/876
Patch3:         %{name}-2.3.1-perl-build.patch
Patch4:	        gdal_pdfsdk.patch

BuildRequires:	gcc gcc-c++
BuildRequires:	ant
BuildRequires:	armadillo-devel
BuildRequires:	bash-completion
BuildRequires:	cfitsio-devel
BuildRequires:	chrpath
BuildRequires:	curl-devel
BuildRequires:	doxygen
BuildRequires:	expat-devel
BuildRequires:	fontconfig-devel
BuildRequires:	freexl-devel
BuildRequires:	g2clib-static
BuildRequires:	geos-devel
BuildRequires:	ghostscript
BuildRequires:	hdf-devel
BuildRequires:	hdf-static
BuildRequires:	hdf5-devel
BuildRequires:	java-devel >= 1:1.6.0
BuildRequires:	jasper-devel
BuildRequires:	jpackage-utils
BuildRequires:	javapackages-local
BuildRequires:	json-c-devel
BuildRequires:	libgeotiff-devel
BuildRequires:	libgta-devel

BuildRequires:	libjpeg-devel
BuildRequires:	libpng-devel

%if %{with_spatialite}
BuildRequires:	libspatialite-devel
%endif

BuildRequires:	libtiff-devel
BuildRequires:	libwebp-devel
BuildRequires:	libtool
BuildRequires:	giflib-devel
BuildRequires:	netcdf-devel
BuildRequires:	libdap-devel
%if 0%{?with_mysql}
BuildRequires:	mariadb-connector-c-devel
%endif
BuildRequires:	python3-numpy
BuildRequires:	pcre-devel
BuildRequires:	ogdi-devel
BuildRequires:	perl-devel
BuildRequires:	perl-generators
BuildRequires:	openjpeg2-devel
BuildRequires:	perl(ExtUtils::MakeMaker)
BuildRequires:	%{_bindir}/pkg-config
%if 0%{?with_poppler}
BuildRequires:	poppler-devel
%endif
BuildRequires:	postgresql-devel
BuildRequires:	proj-devel
%if %{?with_python2}
BuildRequires:	python2-devel
%endif
BuildRequires:	python3-devel
BuildRequires:	sqlite-devel
BuildRequires:	swig
%if %{build_refman}
BuildRequires:	texlive-latex
BuildRequires:	texlive-collection-fontsrecommended
BuildRequires:	texlive-collection-latex
BuildRequires:	texlive-epstopdf
BuildRequires:	tex(multirow.sty)
BuildRequires:	tex(sectsty.sty)
BuildRequires:	tex(tabu.sty)
BuildRequires:	tex(tocloft.sty)
BuildRequires:	tex(xtab.sty)
%endif
BuildRequires:	unixODBC-devel
BuildRequires:	xerces-c-devel
BuildRequires:	xz-devel
BuildRequires:	zlib-devel
BuildRequires:	libtirpc-devel
BuildRequires:	texlive-newunicodechar

# Run time dependency for gpsbabel driver
Requires:	gpsbabel

# proj DL-opened in ogrct.cpp, see also fix in %%prep
%if 0%{?__isa_bits} == 64
Requires:	libproj.so.%{proj_somaj}()(64bit)
%else
Requires:	libproj.so.%{proj_somaj}
%endif

Requires:	%{name}-libs%{?_isa} = %{version}-%{release}

# We have multilib triage
%if "%{_lib}" == "lib"
  %global cpuarch 32
%else
  %global cpuarch 64
%endif

%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}

%description
Geospatial Data Abstraction Library (GDAL/OGR) is a cross platform
C++ translator library for raster and vector geospatial data formats.
As a library, it presents a single abstract data model to the calling
application for all supported formats. It also comes with a variety of
useful commandline utilities for data translation and processing.

It provides the primary data access engine for many applications.
GDAL/OGR is the most widely used geospatial data access library.


%package devel
Summary:        Development files for the GDAL file format library
Group:	        Development/Libraries

Requires:       pkgconfig
Requires:       %{name}-libs%{?_isa} = %{version}-%{release}
Obsoletes:      %{name}-static < 1.9.0-1

%description devel
This package contains development files for GDAL.


%package libs
Summary:        GDAL file format library
Group:	        System Environment/Libraries
# https://trac.osgeo.org/gdal/ticket/3978#comment:5
Obsoletes:      %{name}-ruby < 1.11.0-1

%description libs
This package contains the GDAL file format library.


%package java
Summary:        Java modules for the GDAL file format library
Group:	        Development/Libraries
Requires:       jpackage-utils
Requires:       %{name}-libs%{?_isa} = %{version}-%{release}

%description java
The GDAL Java modules provide support to handle multiple GIS file formats.


%package javadoc
Summary:        Javadocs for %{name}
Group:	        Documentation
Requires:       jpackage-utils
BuildArch:	noarch

%description javadoc
This package contains the API documentation for %{name}.


%package perl
Summary:        Perl modules for the GDAL file format library
Group:	        Development/Libraries
Requires:       %{name}-libs%{?_isa} = %{version}-%{release}
Requires:       perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))

%description perl
The GDAL Perl modules provide support to handle multiple GIS file formats.

%if %{?with_python2}
%package -n python2-gdal
%{?python_provide:%python_provide python2-gdal}
# Remove before F30
Provides:       %{name}-python = %{version}-%{release}
Provides:       %{name}-python%{?_isa} = %{version}-%{release}
Obsoletes:      %{name}-python < %{version}-%{release}
Summary:	Python modules for the GDAL file format library
Group:		Development/Libraries
Requires:	numpy
Requires:	%{name}-libs%{?_isa} = %{version}-%{release}

%description -n python2-gdal
The GDAL Python modules provide support to handle multiple GIS file formats.
The package also includes a couple of useful utilities in Python.
%endif

%package -n python3-gdal
%{?python_provide:%python_provide python3-gdal}
Summary:	Python modules for the GDAL file format library
Group:		Development/Libraries
Requires:	python3-numpy
Requires:	%{name}-libs%{?_isa} = %{version}-%{release}
Obsoletes:	gdal-python3 < 2.3.1
Provides:	gdal-python3

%description -n python3-gdal
The GDAL Python 3 modules provide support to handle multiple GIS file formats.


%package doc
Summary:	Documentation for GDAL
Group:		Documentation
BuildArch:	noarch

%description doc
This package contains HTML and PDF documentation for GDAL.

# We don't want to provide private Python extension libs
%global __provides_exclude_from ^(%{python2_sitearch}|%{python3_sitearch})/.*\.so$

%prep
%setup -q -n %{name}-%{version}

# Delete bundled libraries
rm -rf frmts/zlib
rm -rf frmts/png/libpng
rm -rf frmts/gif/giflib
rm -rf frmts/jpeg/libjpeg \
    frmts/jpeg/libjpeg12
rm -rf frmts/gtiff/libgeotiff \
    frmts/gtiff/libtiff

%patch0 -p1 -b .completion~
%patch1 -p1 -b .java~
%patch2 -p1 -b .zlib~
%patch3 -p1 -b .perl-build~
%patch4 -p1 -b .gdal_pdfsdk~

# Sanitize linebreaks and encoding
set +x
for f in `find . -type f` ; do
  if file $f | grep -q ISO-8859 ; then
    set -x
    iconv -f ISO-8859-1 -t UTF-8 $f > ${f}.tmp && \
      mv -f ${f}.tmp $f
    set +x
  fi
  if file $f | grep -q CRLF ; then
    set -x
    sed -i -e 's|\r||g' $f
    set +x
  fi
done
set -x

for f in gdal/apps; do
pushd $f
  chmod 644 *.cpp
popd
done

# Replace hard-coded library- and include paths
sed -i 's|-L\$with_cfitsio -L\$with_cfitsio/lib -lcfitsio|-lcfitsio|g' gdal/configure
sed -i 's|-I\$with_cfitsio -I\$with_cfitsio/include|-I\$with_cfitsio/include/cfitsio|g' gdal/configure
sed -i 's|-L\$with_netcdf -L\$with_netcdf/lib -lnetcdf|-lnetcdf|g' gdal/configure
sed -i 's|-L\$DODS_LIB -ldap++|-ldap++|g' gdal/configure
sed -i 's|-L\$with_ogdi -L\$with_ogdi/lib -logdi|-logdi|g' gdal/configure
sed -i 's|-L\$with_jpeg -L\$with_jpeg/lib -ljpeg|-ljpeg|g' gdal/configure
sed -i 's|-L\$with_libtiff\/lib -ltiff|-ltiff|g' gdal/configure
sed -i 's|-lgeotiff -L$with_geotiff $LIBS|-lgeotiff $LIBS|g' gdal/configure
sed -i 's|-L\$with_geotiff\/lib -lgeotiff $LIBS|-lgeotiff $LIBS|g' gdal/configure

# libproj is dlopened; upstream sources point to .so, which is usually not present
# http://trac.osgeo.org/gdal/ticket/3602
sed -i 's|libproj.so|libproj.so.%{proj_somaj}|g' gdal/ogr/ogrct.cpp

# Fix Python samples to depend on correct interpreter
mkdir -p gdal/swig/python3/samples
pushd gdal/swig/python/samples
for f in `find . -name '*.py'`; do
  sed 's|^#!.\+python$|#!/usr/bin/python3|' $f > ../../python3/samples/$f
  chmod --reference=$f ../../python3/samples/$f
  sed -i 's|^#!.\+python$|#!/usr/bin/python2|' $f
done
popd

# Adjust check for LibDAP version
# http://trac.osgeo.org/gdal/ticket/4545
%if %cpuarch == 64
  sed -i 's|with_dods_root/lib|with_dods_root/lib64|' gdal/configure
%endif

# Add our custom cflags when trying to find geos
# https://bugzilla.redhat.com/show_bug.cgi?id=1284714
sed -i 's|CFLAGS=\"${GEOS_CFLAGS}\"|CFLAGS=\"${CFLAGS} ${GEOS_CFLAGS}\"|g' gdal/configure

%build
export CFLAGS="$RPM_OPT_FLAGS -fPIC"
export CXXFLAGS="$CFLAGS -I%{_includedir}/libgeotiff -I%{_includedir}/tirpc -I%{_includedir}/cfitsio"
export CPPFLAGS="$CPPFLAGS -I%{_includedir}/libgeotiff -I%{_includedir}/tirpc -I%{_includedir}/cfitsio"

# For future reference:
# epsilon: Stalled review -- https://bugzilla.redhat.com/show_bug.cgi?id=660024
# Building without pgeo driver, because it drags in Java
%global g2clib grib2c

pushd ./gdal
./autogen.sh
# Fix mandir
sed -i "s|^mandir=.*|mandir='\${prefix}/share/man'|" configure
%configure \
	LIBS="-ltirpc" \
	--with-autoload=%{_libdir}/%{name}plugins \
	--datadir=%{_datadir}/%{name}/ \
	--includedir=%{_includedir}/%{name}/ \
	--prefix=%{_prefix}	\
	--mandir=%{_mandir}     \
	--with-armadillo	\
	--with-curl		\
	--with-cfitsio=%{_prefix}	\
	--with-dods-root=%{_prefix}	\
	--with-expat		\
	--with-freexl		\
	--with-geos		\
	--with-geotiff	        \
	--with-gif		\
	--with-gta		\
	--with-hdf4		\
	--with-hdf5		\
	--with-jasper		\
	--with-java		\
	--with-jpeg		\
	--with-libjson-c	\
	--without-jpeg12	\
	--with-liblzma		\
	--with-libtiff		\
	--with-libz		\
	--without-mdb		\
	%{mysql}		\
	--with-netcdf		\
	--with-odbc		\
	--with-ogdi		\
	--without-msg		\
	--with-openjpeg		\
	--with-pcraster		\
	--with-pg		\
	--with-png		\
	%{poppler}		\
	%{spatialite}		\
	--with-sqlite3		\
	--with-threads		\
	--with-webp		\
	--with-xerces		\
	--enable-shared		\
	--with-libkml


sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
sed -i "s/-Lexternal\/lib/-L\/usr\/lib64/g" GDALmake.opt
sed -i "s/-I\/usr\/include\/poppler//g" configure
sed -i "s/-I\/usr\/include\/poppler//g" configure.ac
sed -i "s/-I\/usr\/include\/poppler//g" GDALmake.opt


POPPLER_OPTS="POPPLER_0_20_OR_LATER=yes POPPLER_0_23_OR_LATER=yes POPPLER_BASE_STREAM_HAS_TWO_ARGS=yes"
POPPLER_OPTS="$POPPLER_OPTS POPPLER_0_58_OR_LATER=yes"

make %{?_smp_mflags} $POPPLER_OPTS
make man
make docs
popd

# Build some utilities, as requested in BZ #1271906
pushd gdal/ogr/ogrsf_frmts/s57/
  make all
popd

pushd gdal/frmts/iso8211/
  make all
popd

# Make Java module and documentation
pushd gdal/swig/java
  make
  ./make_doc.sh
popd

# Make Python modules
pushd gdal/swig/python
  %py3_build
%if 0%{?with_python2}
  %py2_build
%endif
popd

# Make Python modules
pushd gdal/swig/perl
  make generate
  #perl Makefile.PL INSTALLDIRS=%%{perl_vendorarch}
  perl Makefile.PL INSTALLDIRS=vendor
  %make_build
popd

# --------- Documentation ----------

# No useful documentation in swig
%global docdirs gdal/apps gdal/doc gdal/doc/br gdal/doc/ru gdal/ogr gdal/ogr/ogrsf_frmts gdal/frmts/gxf gdal/frmts/iso8211 gdal/frmts/pcidsk gdal/frmts/sdts gdal/frmts/vrt gdal/ogr/ogrsf_frmts/dgn/
for docdir in %{docdirs}; do
  # CreateHTML and PDF documentation, if specified
  pushd $docdir
    if [ ! -f Doxyfile ]; then
      doxygen -g
    else
      doxygen -u
    fi
    sed -i -e 's|^GENERATE_LATEX|GENERATE_LATEX = YES\n#GENERATE_LATEX |' Doxyfile
    sed -i -e 's|^GENERATE_HTML|GENERATE_HTML = YES\n#GENERATE_HTML |' Doxyfile
    sed -i -e 's|^USE_PDFLATEX|USE_PDFLATEX = YES\n#USE_PDFLATEX |' Doxyfile

    if [ $docdir == "doc/ru" ]; then
      sed -i -e 's|^OUTPUT_LANGUAGE|OUTPUT_LANGUAGE = Russian\n#OUTPUT_LANGUAGE |' Doxyfile
    fi
    rm -rf latex html
    doxygen

    %if 0%{build_refman}
      pushd latex
	sed -i -e '/rfoot\[/d' -e '/lfoot\[/d' doxygen.sty
	sed -i -e '/small/d' -e '/large/d' refman.tex
	sed -i -e 's|pdflatex|pdflatex -interaction nonstopmode |g' Makefile
	make refman.pdf || true
      popd
    %endif
  popd
done


%install
rm -rf %{buildroot}

pushd gdal/swig/python
  %py3_install
%if %{?with_python2}
  %py2_install
%endif
popd

pushd gdal/swig/perl
  %make_install
popd


pushd ./gdal
make	DESTDIR=%{buildroot}	\
	install	\
	install-man
popd

install -pm 755 gdal/ogr/ogrsf_frmts/s57/s57dump %{buildroot}%{_bindir}
install -pm 755 gdal/frmts/iso8211/8211createfromxml %{buildroot}%{_bindir}
install -pm 755 gdal/frmts/iso8211/8211dump %{buildroot}%{_bindir}
install -pm 755 gdal/frmts/iso8211/8211view %{buildroot}%{_bindir}

# Directory for auto-loading plugins
mkdir -p %{buildroot}%{_libdir}/%{name}plugins

find %{buildroot} -name "*.dox" -exec rm -rf '{}' \;
find %{buildroot} -name "perllocal.pod" -exec rm -rf '{}' \;

# Correct permissions
find %{buildroot} -name "*.so" -exec chmod 755 '{}' \;
find %{buildroot} -name "*.pm" -exec chmod 644 '{}' \;

touch -r gdal/NEWS gdal/swig/java/gdal.jar
mkdir -p %{buildroot}%{_javadir}
cp -p gdal/swig/java/gdal.jar  \
    %{buildroot}%{_javadir}/%{name}.jar

# Install Maven pom and update version number
install -dm 755 %{buildroot}%{_mavenpomdir}
install -pm 644 %{SOURCE1} %{buildroot}%{_mavenpomdir}/JPP-%{name}.pom
sed -i 's|<version></version>|<version>%{version}</version>|' %{buildroot}%{_mavenpomdir}/JPP-%{name}.pom

# Create depmap fragment
%add_maven_depmap JPP-%{name}.pom %{name}.jar

mkdir -p %{buildroot}%{_jnidir}/%{name}
cp -pl gdal/swig/java/.libs/*.so*  \
    %{buildroot}%{_jnidir}/%{name}/
chrpath --delete %{buildroot}%{_jnidir}/%{name}/*jni.so*

# Install Java API documentation in the designated place
mkdir -p %{buildroot}%{_javadocdir}/%{name}
cp -pr gdal/swig/java/java/org %{buildroot}%{_javadocdir}/%{name}

# Install refmans
for docdir in %{docdirs}; do
  pushd $docdir
    path=%{_builddir}/%{name}-%{version}/refman
    mkdir -p $path/html/$docdir
    cp -r html $path/html/$docdir

    # Install all Refmans
    %if %{build_refman}
	if [ -f latex/refman.pdf ]; then
		mkdir -p $path/pdf/$docdir
		cp latex/refman.pdf $path/pdf/$docdir
	fi
    %endif
  popd
done

# Install formats documentation
for dir in gdal/gdal_frmts gdal/ogrsf_frmts; do
  mkdir -p $dir
  find gdal/frmts -name "*.html" -exec install -p -m 644 '{}' $dir \;
done

install -p -D -m 644 gdal/port/cpl_config.h %{buildroot}%{_includedir}/%{name}/cpl_config-%{cpuarch}.h

#>>>>>>>>>>>>>
cat > %{buildroot}%{_includedir}/%{name}/cpl_config.h <<EOF
#include <bits/wordsize.h>

#if __WORDSIZE == 32
#include "gdal/cpl_config-32.h"
#else
#if __WORDSIZE == 64
#include "gdal/cpl_config-64.h"
#else
#error "Unknown word size"
#endif
#endif
EOF
#<<<<<<<<<<<<<
touch -r gdal/NEWS gdal/port/cpl_config.h

# Create and install pkgconfig file
# http://trac.osgeo.org/gdal/ticket/3470
#>>>>>>>>>>>>>
cat > %{name}.pc <<EOF
prefix=%{_prefix}
exec_prefix=%{_prefix}
libdir=%{_libdir}
includedir=%{_includedir}

Name: GDAL
Description: GIS file format library
Version: %{version}
Libs: -L\${libdir} -lgdal
Cflags: -I\${includedir}/%{name}
EOF
#<<<<<<<<<<<<<
mkdir -p %{buildroot}%{_libdir}/pkgconfig/
install -m 644 %{name}.pc %{buildroot}%{_libdir}/pkgconfig/
touch -r gdal/NEWS %{buildroot}%{_libdir}/pkgconfig/%{name}.pc

# Multilib gdal-config
# Rename the original script to gdal-config-$arch (stores arch-specific information)
# and create a script to call one or the other -- depending on detected architecture
mv %{buildroot}%{_bindir}/%{name}-config %{buildroot}%{_bindir}/%{name}-config-%{cpuarch}
#>>>>>>>>>>>>>
cat > %{buildroot}%{_bindir}/%{name}-config <<EOF
#!/bin/bash

ARCH=\$(uname -m)
case \$ARCH in
x86_64 | ppc64 | ppc64le | ia64 | s390x | sparc64 | alpha | alphaev6 | aarch64 )
%{name}-config-64 \${*}
;;
*)
%{name}-config-32 \${*}
;;
esac
EOF
#<<<<<<<<<<<<<
touch -r gdal/NEWS %{buildroot}%{_bindir}/%{name}-config
chmod 755 %{buildroot}%{_bindir}/%{name}-config

# Clean up junk
rm -f %{buildroot}%{_bindir}/*.dox

#jni-libs and libgdal are also built static (*.a)
#.exists and .packlist stem from Perl
for junk in {*.a,*.la,*.bs,.exists,.packlist} ; do
  find %{buildroot} -name "$junk" -exec rm -rf '{}' \;
done

# Don't duplicate license files
rm -f %{buildroot}%{_datadir}/%{name}/LICENSE.TXT

# Throw away random API man mages plus artefact seemingly caused by Doxygen 1.8.1 or 1.8.1.1
for f in 'GDAL*' BandProperty ColorAssociation CutlineTransformer DatasetProperty EnhanceCBInfo ListFieldDesc NamedColor OGRSplitListFieldLayer VRTBuilder; do
  rm -rf %{buildroot}%{_mandir}/man1/$f.1*
done

rm -f %{buildroot}%{_mandir}/man1/*_%{name}-%{version}_apps_*
rm -f %{buildroot}%{_mandir}/man1/_home_rouault_dist_wrk_gdal_apps_.1*

%check
%if %{run_tests}
for i in -I/usr/lib/jvm/java/include{,/linux}; do
    java_inc="$java_inc $i"
done


pushd ./autotest
  # Export test enviroment
  export PYTHONPATH=$PYTHONPATH:%{buildroot}%{python_sitearch}
  export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:%{buildroot}%{_libdir}

  export GDAL_DATA=%{buildroot}%{_datadir}/%{name}/


  # Remove some test cases that would require special preparation
  rm -rf ogr/ogr_pg.py        # No database available
  rm -rf ogr/ogr_mysql.py     # No database available
  rm -rf osr/osr_esri.py      # ESRI datum absent
  rm -rf osr/osr_erm.py       # File from ECW absent

  # Run tests but force normal exit in the end
  ./run_all.py || true
popd
%endif


%post libs -p /sbin/ldconfig

%postun libs -p /sbin/ldconfig


%files
%{bashcompletiondir}/*
%{_bindir}/gdallocationinfo
%{_bindir}/gdal_contour
%{_bindir}/gdal_rasterize
%{_bindir}/gdal_translate
%{_bindir}/gdaladdo
%{_bindir}/gdalinfo
%{_bindir}/gdaldem
%{_bindir}/gdalbuildvrt
%{_bindir}/gdaltindex
%{_bindir}/gdalwarp
%{_bindir}/gdal_grid
%{_bindir}/gdalenhance
%{_bindir}/gdalmanage
%{_bindir}/gdalserver
%{_bindir}/gdalsrsinfo
%{_bindir}/gdaltransform
%{_bindir}/nearblack
%{_bindir}/ogr*
%{_bindir}/8211*
%{_bindir}/s57*
%{_bindir}/testepsg
%{_bindir}/gnmanalyse
%{_bindir}/gnmmanage
%{_mandir}/man1/gdal*.1*
%exclude %{_mandir}/man1/gdal-config.1*
%exclude %{_mandir}/man1/gdal2tiles.1*
%exclude %{_mandir}/man1/gdal_fillnodata.1*
%exclude %{_mandir}/man1/gdal_merge.1*
%exclude %{_mandir}/man1/gdal_retile.1*
%exclude %{_mandir}/man1/gdal_sieve.1*
%{_mandir}/man1/nearblack.1*
%{_mandir}/man1/ogr*.1*
%{_mandir}/man1/gnm*.1.*


%files libs
%doc gdal/LICENSE.TXT gdal/NEWS gdal/PROVENANCE.TXT gdal/COMMITTERS
%{_libdir}/libgdal.so.20
%{_libdir}/libgdal.so.20.*
%{_datadir}/%{name}
%dir %{_libdir}/%{name}plugins

%files devel
%{_bindir}/%{name}-config
%{_bindir}/%{name}-config-%{cpuarch}
%{_mandir}/man1/gdal-config.1*
%dir %{_includedir}/%{name}
%{_includedir}/%{name}/*.h
%{_libdir}/*.so
%{_libdir}/pkgconfig/%{name}.pc

%files java -f .mfiles
%doc gdal/swig/java/apps
%{_jnidir}/%{name}/

%files javadoc
%{_javadocdir}/%{name}

%files perl
%doc gdal/swig/perl/README
%{perl_vendorarch}/*
%{_mandir}/man3/*.3pm*

%if %{?with_python2}
%files -n python2-gdal
%doc gdal/swig/python/README.txt
%doc gdal/swig/python/samples
%{_bindir}/*.py
%{_mandir}/man1/pct2rgb.1*
%{_mandir}/man1/rgb2pct.1*
%{_mandir}/man1/gdal2tiles.1*
%{_mandir}/man1/gdal_fillnodata.1*
%{_mandir}/man1/gdal_merge.1*
%{_mandir}/man1/gdal_retile.1*
%{_mandir}/man1/gdal_sieve.1*
%{python2_sitearch}/osgeo
%{python2_sitearch}/GDAL-%{version}-py*.egg-info
%{python2_sitearch}/osr.py*
%{python2_sitearch}/ogr.py*
%{python2_sitearch}/gdal*.py*
%{python2_sitearch}/gnm.py*
%else
%exclude %{python2_sitearch}
%endif

%files -n python3-gdal
%doc gdal/swig/python/README.txt
%doc gdal/swig/python3/samples
%{_bindir}/*.py
%{_mandir}/man1/pct2rgb.1*
%{_mandir}/man1/rgb2pct.1*
%{_mandir}/man1/gdal2tiles.1*
%{_mandir}/man1/gdal_fillnodata.1*
%{_mandir}/man1/gdal_merge.1*
%{_mandir}/man1/gdal_retile.1*
%{_mandir}/man1/gdal_sieve.1*
%{python3_sitearch}/osgeo
%{python3_sitearch}/GDAL-%{version}-py*.egg-info
%{python3_sitearch}/osr.py
%{python3_sitearch}/__pycache__/osr.*.py*
%{python3_sitearch}/ogr.py
%{python3_sitearch}/__pycache__/ogr.*.py*
%{python3_sitearch}/gdal*.py
%{python3_sitearch}/__pycache__/gdal*.*.py*
%{python3_sitearch}/gnm.py*
%{python3_sitearch}/__pycache__/gnm.*.py*

%files doc
%doc gdal/gdal_frmts gdal/ogrsf_frmts
%if %{build_refman}
%doc refman
%endif

%changelog
* Fri Oct 8 2021 zhaoshuang <zhaoshuang@uniontech.com> - 2.3.1-1
- Init package
