Name:           geos
Version:        3.6.1
Release:        12
Summary:        GEOS is a C++ port of the Java Topology Suite
License:        LGPLv2
URL:            http://trac.osgeo.org/geos/
Source0:        http://download.osgeo.org/%{name}/%{name}-%{version}.tar.bz2
#To add stdlib.h
Patch0000:      geos-gcc43.patch

BuildRequires:  gcc gcc-c++ doxygen libtool python2-devel

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

%description
GEOS (Geometry Engine - Open Source) is a C++ port of the JTS Topology Suite (JTS).
It aims to contain the complete functionality of JTS in C++. This includes all the
OpenGIS Simple Features for SQL spatial predicate functions and spatial operators,
as well as specific JTS enhanced functions. GEOS provides spatial functionality to
many other projects and products.

%package devel
Summary:        Development files for GEOS
Requires:       %{name} = %{version}-%{release}

%description devel
GEOS (Geometry Engine - Open Source) is a C++ port of the JTS Topology Suite (JTS).
It aims to contain the complete functionality of JTS in C++. This includes all the
OpenGIS Simple Features for SQL spatial predicate functions and spatial operators,
as well as specific JTS enhanced functions. GEOS provides spatial functionality to
many other projects and products.

This package contains the development files to build applications that
use GEOS.

%package -n python2-geos
%{?python_provide:%python_provide python2-geos}
Provides:      %{name}-python = %{version}-%{release}
Obsoletes:     %{name}-python < %{version}-%{release}
Summary:       Python modules for GEOS
Requires:      %{name} = %{version}-%{release}
BuildRequires: swig

%description -n python2-geos
Python module to build applications using GEOS and python

%prep
%autosetup -p1

%build
sed -i -e 's|\/lib\/python|$libdir\/python|g' configure
sed -i -e 's|.get_python_lib(0|.get_python_lib(1|g' configure
sed -i -e 's|find \$i -name libpython|find \$i\/lib*\/ -name libpython|g' configure
sed -i -e 's|= isnan(|= std::isnan(|g' configure
sed -i -e 's|(isnan(|(std::isnan(|g' include/geos/platform.h.in

for makefile in `find . -type f -name 'Makefile.in'`; do
sed -i 's|@LIBTOOL@|%{_bindir}/libtool|g' $makefile
done

%configure --disable-static --disable-dependency-tracking --enable-python
touch swig/python/geos_wrap.cxx

%make_build
cd doc
make doxygen-html

%install
%make_install

%check
make  check || exit 0

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files
%doc AUTHORS COPYING NEWS README TODO
%{_libdir}/libgeos-%{version}.so
%{_libdir}/libgeos_c.so.1*
%exclude %{_libdir}/*.a

%files devel
%doc doc/doxygen_docs
%{_bindir}/geos-config
%{_includedir}/*
%{_libdir}/libgeos.so
%{_libdir}/libgeos_c.so
%exclude %{_libdir}/*.la
%exclude %{_libdir}/*.a

%files -n python2-geos
%dir %{python2_sitearch}/%{name}
%exclude %{python2_sitearch}/%{name}/_%{name}.a
%exclude %{python2_sitearch}/%{name}/_%{name}.la
%{python2_sitearch}/%{name}.pth
%{python2_sitearch}/%{name}/*.py
%{python2_sitearch}/%{name}/*.py?
%{python2_sitearch}/%{name}/_%{name}.so

%changelog
* Mon Mar 09 2020 yangjian<yangjian79@huawei.com> - 3.6.1-12
- Fix patch problem

* Wed Mar 04 2020 yangjian<yangjian79@huawei.com> - 3.6.1-11
- Package init
