%global commit0 c318d648ff73aa2e32b783709d69740ac3e8c072
%global shortcommit0 %(c=%{commit0}; echo ${c:0:7})

%{!?python3_sitelib: %define python3_sitelib %(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%{!?python3_version: %define python3_version %(python3 -c "import sys; sys.stdout.write(sys.version[:3])")}

Name:           assimp
Version:        3.2.0
Release:        5%{?_dist_release}
Summary:        Library to import various 3D model formats into applications

Group:          Development/Libraries
# Assimp is BSD, the bundled openddlparser is MIT.
License:        BSD and MIT
URL:            http://assimp.sourceforge.net

Vendor:         Project Vine
Distribution:   Vine Linux

#Source0:  https://github.com/assimp/%{name}/archive/%{commit0}.tar.gz#/%{name}-%{shortcommit0}.tar.gz
# Github releases include nonfree models, source tarball must be re-generated
# using assimp_generate_tarball.sh
Source0:        %{name}-%{commit0}-free.tar.bz2
# Strips bundled irrXML out of build files, and allows project to build
# against system versions of the libraries (not yet submitted upstream)
Patch0:         %{name}-3.2.0-unbundle.patch
# Change a doxygen setting so CHM help isn't generated. Fedora-only
Patch1:         %{name}-3.1.1-docfix.patch
# Add /usr/lib64 to library lookup paths for python modules
Patch4:         %{name}-3.2.0-pythonpath.patch
# Fix library and include paths in assimp-config.cmake
# Fixes rhbz#1263698, not submitted upstream
Patch5:         %{name}-3.2.0-cmakefix.patch
# Fix big endian platforms
Patch6:         %{name}-3.2.0-bigendian.patch

BuildRequires:  libboost-devel
BuildRequires:  cmake
BuildRequires:  dos2unix
#BuildRequires:  irrlicht-devel
#BuildRequires:  irrXML-devel
BuildRequires:  zlib-devel
BuildRequires:  doxygen
#BuildRequires:  minizip-devel
#BuildRequires:  poly2tri-devel
#BuildRequires:  polyclipping-devel
BuildRequires:  python-devel
BuildRequires:  python3-devel
BuildRequires:  gtest-devel

Provides: bundled(openddl-parser)

%description
Assimp, the Open Asset Import Library, is a free library to import
various well-known 3D model formats into applications.  Assimp aims
to provide a full asset conversion pipeline for use in game
engines and real-time rendering systems, but is not limited
to these applications.

%package devel
Summary: Header files and libraries for assimp
Group: Development/Libraries
Requires: %{name}%{?_isa} = %{version}-%{release}

%description devel
This package contains the header files and libraries
for assimp. If you would like to develop programs using assimp,
you will need to install assimp-devel.

%package -n python2-%{name}
Summary: Python bindings for assimp
Group: Development/Libraries
BuildArch: noarch
Requires: %{name} = %{version}-%{release}
Requires: python
Provides: %{name}-python = %{version}-%{release}
Obsoletes: %{name}-python < 3.1.1

%description -n python2-%{name}
This package contains the PyAssimp python bindings

%package -n python3-%{name}
Summary: Python 3 bindings for assimp
Group: Development/Libraries
BuildArch: noarch
Requires: %{name} = %{version}-%{release}
Requires: python3
Provides: %{name}-python3 = %{version}-%{release}
Obsoletes: %{name}-python3 < 3.1.1

%description -n python3-%{name}
This package contains the PyAssimp3 python bindings

%prep
%setup -q -n %{name}-%{commit0}
# Get rid of bundled libs so we can't accidently build against them
#rm -f code/fast_atof.h
#rm -rf contrib/cppunit-1.12.1
#rm -rf contrib/irrXML
#rm -rf contrib/zlib
#rm -rf contrib/unzip
#rm -rf contrib/poly2tri
#%patch0 -p1 -b .unbundle
%patch1 -p1 -b .docfix
%patch4 -p1 -b .pythonpath
%patch5 -p0 -b .cmakefix
%patch6 -p1 -b .bigendian

%build
mkdir build
pushd build
%cmake .. \
 -DASSIMP_LIB_INSTALL_DIR=%{_libdir} \
 -DASSIMP_BIN_INSTALL_DIR=%{_bindir} \
 -DASSIMP_INCLUDE_INSTALL_DIR=%{_includedir} \
 -DIRRXML_LIB_PATH=%{_libdir} \
 -DIRRXML_INCLUDE_PATH=%{_includedir}/irrlicht/ \
 -DUSE_EXTERNAL_LIBS=ON  \
 -DASSIMP_ENABLE_BOOST_WORKAROUND=OFF

# -DPOLY2TRI_INCLUDE_PATH=%{_includedir}/poly2tri \
# -DCLIPPER_INCLUDE_PATH=%{_includedir}/clipper \

popd
make %{?_smp_mflags} -C build

# Generate docs, copy assimp logo image and stylesheet into generated docs
pushd doc
doxygen Doxyfile
cp AssimpDoc_Html/dragonsplash.png html/dragonsplash.png
popd

# Fix file encoding
dos2unix README LICENSE CREDITS port/PyAssimp/README.md
iconv -f iso8859-1 -t utf-8 CREDITS > CREDITS.conv && mv -f CREDITS.conv CREDITS

%install
rm -rf %{buildroot}
make -C build install DESTDIR=%{buildroot}
mkdir -p %{buildroot}%{python_sitelib}/pyassimp/
install -m0644 port/PyAssimp/pyassimp/*.py %{buildroot}%{python_sitelib}/pyassimp/
mkdir -p %{buildroot}%{python3_sitelib}/pyassimp/
install -m0644 port/PyAssimp/pyassimp/*.py %{buildroot}%{python3_sitelib}/pyassimp/

%clean
rm -rf %{buildroot}

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig


%files
%license LICENSE
%doc README CREDITS
%{_bindir}/assimp
%{_libdir}/*.so.*

%files devel
%doc doc/html
%{_includedir}/assimp
%{_libdir}/*.so
%{_libdir}/pkgconfig/*.pc
%{_libdir}/cmake/%{name}-3.2

%files -n python2-%{name}
%doc port/PyAssimp/README.md
%{python_sitelib}/pyassimp

%files -n python3-%{name}
%doc port/PyAssimp/README.md
%{python3_sitelib}/pyassimp

%changelog
* Mon Jul 11 2016 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 3.2.0-5
- added tags: Vendor and Distribution.

* Mon Jul 11 2016 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 3.2.0-4
- initial build for Vine Linux.

* Fri Jul 01 2016 Dan Horák <dan[at]danny.cz> - 3.2.0-3
- Fix build on big endian platforms

* Fri Jun 03 2016 Rich Mattes <richmattes@gmail.com> - 3.2.0-2
- Fix pkgconfig and cmake files (rhbz#1340656)

* Mon May 09 2016 Rich Mattes <richmattes@gmail.com> - 3.2.0-1
- Update to release 3.2.0 (rhbz#1332434)

* Wed Feb 03 2016 Fedora Release Engineering <releng@fedoraproject.org> - 3.1.1-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Thu Jan 14 2016 Jonathan Wakely <jwakely@redhat.com> - 3.1.1-8
- Rebuilt for Boost 1.60

* Wed Dec 09 2015 Rich Mattes <richmattes@gmail.com> - 3.1.1-7
- Add patch to fix build on big-endian architectures

* Tue Nov 10 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.1.1-6
- Rebuilt for https://fedoraproject.org/wiki/Changes/python3.5

* Thu Sep 17 2015 Rich Mattes <richmattes@gmail.com> - 3.1.1-5
- Fix assimp-config paths (rhbz#1263698)
- Build against system boost instead of using included workaround

* Thu Aug 27 2015 Jonathan Wakely <jwakely@redhat.com> - 3.1.1-4
- Rebuilt for Boost 1.59

* Wed Jul 29 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.1.1-3
- Rebuilt for https://fedoraproject.org/wiki/Changes/F23Boost159

* Wed Jul 22 2015 David Tardon <dtardon@redhat.com> - 3.1.1-2
- rebuild for Boost 1.58

* Fri Jul 03 2015 Rich Mattes <richmattes@gmail.com> - 3.1.1-1
- Update to release 3.1.1 (rhbz#1206371)
- Remove upstreamed patches
- Correct python package names
- Use license macro

* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.0.1270-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Sat May 02 2015 Kalev Lember <kalevlember@gmail.com> - 3.0.1270-10
- Rebuilt for GCC 5 C++11 ABI change

* Mon Jan 26 2015 Petr Machata <pmachata@redhat.com> - 3.0.1270-9
- Rebuild for boost 1.57.0

* Fri Aug 15 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.0.1270-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild

* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.0.1270-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Wed May 28 2014 Kalev Lember <kalevlember@gmail.com> - 3.0.1270-6
- Rebuilt for https://fedoraproject.org/wiki/Changes/Python_3.4

* Thu May 22 2014 Petr Machata <pmachata@redhat.com> - 3.0.1270-5
- Rebuild for boost 1.55.0

* Sun Mar 02 2014 Scott K Logan <logans@cottsay.net> - 3.0.1270-4
- Changed upstream source to Github
- Un-commented assimp-python, added python-devel to build deps
- Added assimp-python3 subpackage

* Sat Aug 03 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.0.1270-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild

* Tue Jul 30 2013 Petr Machata <pmachata@redhat.com> - 3.0.1270-2
- Rebuild for boost 1.54.0

* Wed May 01 2013 Rich Mattes <richmattes@gmail.com> 3.0.1270-1
- Update to release 3.0.1270

* Wed Feb 13 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.0.863-9.20110824svn
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild

* Thu Oct 25 2012 Rich Mattes <richmattes@gmail.com> - 2.0.863-8.20110824svn
- Install python bindings

* Wed Jul 18 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.0.863-7.20110824svn
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild

* Tue Jul  3 2012 Tom Callaway <spot@fedoraproject.org> - 2.0.863-6.20110824svn
- rebuild against new irrlicht/irrxml

* Wed Apr 11 2012 Rich Mattes <richmattes@gmail.com> - 2.0.863-5.20110824svn
- Changed spec to use buildroot macro

* Sat Dec 17 2011 Rich Mattes <richmattes@gmail.com> - 2.0.863-4.20110824svn
- Fixed pkgconfig paths

* Wed Aug 24 2011 Rich Mattes <richmattes@gmail.com> - 2.0.863-3.20110824svn
- Upgrade to latest svn snapshot
- Port changes to link against system irrXML
- Removed upstreamed zlib/unzip unbundling patches

* Thu Mar 24 2011 Rich Mattes <richmattes@gmail.com> - 2.0.863-2.20110324svn
- Upgrade to latest svn snapshot
- Port changes to link against libIrrXML

* Sat Dec 18 2010 Rich Mattes <richmattes@gmail.com> - 2.0.863-1
- Upgrade to release 2.0

* Mon Sep 20 2010 Rich Mattes <richmattes@gmail.com> - 1.1.700-3
- Remove extra buildrequires
- Generate doxygen docs manually

* Mon Sep 20 2010 Rich Mattes <richmattes@gmail.com> - 1.1.700-2
- Included doxygen-generated docs
- Using original .zip file from project download page

* Sun Sep 19 2010 Rich Mattes <richmattes@gmail.com> - 1.1.700-1
- First build
