%define name qhull
%define version 2015.2

# Upstream's versioning is bizarre
%global tarvers 2015-src-7.2.0

Summary: General dimension convex hull programs
Name:    %{name}
Version: %{version}
Release: 1%{?_dist_release}
License: Qhull
Group:   System Environment/Libraries

URL: http://www.qhull.org
Source0: http://www.qhull.org/download/qhull-%{tarvers}.tgz

Patch1: 0001-Link-executables-against-shared-libs.patch
Patch2: 0002-Install-docs-into-subdirs.patch

BuildRoot: %{_tmppath}/%{name}-%{version}-root

BuildRequires: cmake
BuildRequires: chrpath

Vendor: Project Vine
Distribution: Vine Linux


%description
Qhull is a general dimension convex hull program that reads a set
of points from stdin, and outputs the smallest convex set that contains
the points to stdout.  It also generates Delaunay triangulations, Voronoi
diagrams, furthest-site Voronoi diagrams, and halfspace intersections
about a point.

%package -n libqhull
Group:   System Environment/Libraries
Summary: -n libqhull

%description -n libqhull
%{summary}

%package -n libqhull_r
Group:   System Environment/Libraries
Summary: libqhull_r

%description -n libqhull_r
%{summary}

%package -n libqhull_p
Group:   System Environment/Libraries
Summary: libqhull_p

%description -n libqhull_p
%{summary}

%package devel
Summary: Development files for qhull
Group:   Development/Libraries
Requires: lib%{name} = %{version}-%{release}
Requires: lib%{name}_r = %{version}-%{release}
Requires: lib%{name}_p = %{version}-%{release}

%description devel
Qhull is a general dimension convex hull program that reads a set
of points from stdin, and outputs the smallest convex set that contains
the points to stdout.  It also generates Delaunay triangulations, Voronoi
diagrams, furthest-site Voronoi diagrams, and halfspace intersections
about a point.


%prep
%setup -q -n %{name}-%{version}
%patch1 -p1
%patch2 -p1

%build
cd build
%cmake ..
make VERBOSE=1 %{?_smp_mflags}
cd ..

%install
rm -rf ${RPM_BUILD_ROOT}
cd build
%make_install
cd ..

chrpath --delete ${RPM_BUILD_ROOT}%{_libdir}/lib*.so.*

## remove unuse files
rm -rf ${RPM_BUILD_ROOT}%{_libdir}/*.a

## rename doc folder
mv ${RPM_BUILD_ROOT}%{_docdir}/%{name} \
   ${RPM_BUILD_ROOT}%{_docdir}/%{name}-%{version}

%clean
rm -rf $RPM_BUILD_ROOT


%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig

%post -n libqhull -p /sbin/ldconfig
%postun -n libqhull -p /sbin/ldconfig

%post -n libqhull_r -p /sbin/ldconfig
%postun -n libqhull_r -p /sbin/ldconfig

%post -n libqhull_p -p /sbin/ldconfig
%postun -n libqhull_p -p /sbin/ldconfig


%files
%{_bindir}/*
%{_docdir}/%{name}-%{version}/
%{_mandir}/man1/*

%files -n libqhull
%{_libdir}/libqhull.so.*

%files -n libqhull_r
%{_libdir}/libqhull_r.so.*

%files -n libqhull_p
%{_libdir}/libqhull_p.so.*

%files devel
%defattr(-,root,root)
%{_includedir}/libqhull*
%{_libdir}/libqhull.so
%{_libdir}/libqhull_r.so
%{_libdir}/libqhull_p.so


%changelog
* Tue Sep 04 2018 Toshiaki Ara <ara_t@384.jp> 2015.2-1
- update to 2015.2-7.2.0
- add patches from fedora package
- split out libqhull, libqhull_p, libqhull_r packages
- drop Provides: libqhull.so
- drop Provides: libqhull_p.so

* Tue Apr 12 2016 Toshiaki Ara <ara_t@384.jp> 2012.1-2
- add Provides: libqhull.so
- add Provides: libqhull_p.so

* Sun Jan 11 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2012.1-1
- update to 2012.1

* Sat Feb 19 2011 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2003.1-2
- added Patch0 from upstream
- added --disable-static to %%configure

* Sat Sep 20 2008 Shu KONNO <owa@bg.wakwak.com> 2003.1-1vl5
- applied new versioning policy
- removed *.la

*Thu Jan 03 2008 NAKAMURA Kenta <kenta@vinelinux.org> 2003.1-0vl2
- rebuild on VineSeed

*Thu Oct 6 2005 g-staff <g-staff@math.sci.hokudai.ac.jp> 2003.1-0vl1
- taken from FC
- rebuild on Vine Linux 3.2

* Sun Aug 08 2004 Ralf Corsepius <ralf[AT]links2linux.de>	- 2003.1-0.fdr.2
- Use default documentation installation scheme.

* Fri Jul 16 2004 Ralf Corsepius <ralf[AT]links2linux.de>	- 2003.1-0.fdr.1
- Initial Fedora RPM.
