%global _docdir_fmt %{name}

Name:           bullet
Version:        2.87
Release:        6
Summary:        Real-time collision detection and multi-physics simulation
License:        zlib and MIT and BSD and Boost and LGPLv2+
URL:            http://www.bulletphysics.com
Source0:        https://github.com/bulletphysics/bullet3/archive/%{version}.tar.gz
BuildRequires:  gcc-c++ cmake dos2unix doxygen freeglut-devel libICE-devel tinyxml-devel
Provides:       bullet-extras = %{version}-%{release}
Obsoletes:      bullet-extras < %{version}-%{release}

%description
Real-time collision detection and multi-physics simulation for
VR, games, visual effects, robotics, machine learning etc.

%package        devel
Summary:        Development files for bullet
Requires:       bullet = %{version}-%{release} cmake
Provides:       bullet-extras-devel = %{version}-%{release}
Obsoletes:      bullet-extras-devel < %{version}-%{release}

%description    devel
Headers and libraries for bullet development.

%package        help
Summary:        Documentation for developing programs
License:        zlib and LGPLv2+
Requires:       bullet = %{version}-%{release}
Provides:       bullet-devel-doc = %{version}-%{release}
Obsoletes:      bullet-devel-doc < %{version}-%{release}

%description    help
Documentation for developing programs that will use bullet-devel.

%prep
%autosetup -n bullet3-%{version} -p1
rm -r examples
sed -i 's|-I@CMAKE_INSTALL_PREFIX@/@INCLUDE_INSTALL_DIR@|-I@INCLUDE_INSTALL_DIR@|' bullet.pc.cmake
sed -i 's|BulletRobotics||' Extras/CMakeLists.txt
sed -i 's|obj2sdf||' Extras/CMakeLists.txt
dos2unix README.md
chmod -x src/BulletDynamics/ConstraintSolver/{btSliderConstraint.h,btSliderConstraint.cpp}
%build
mkdir build
cd build
%cmake .. -DCLSOCKET_DEP_ONLY=ON -DBUILD_BULLET2_DEMOS=OFF -DBUILD_EXTRAS=ON -DBUILD_OPENGL_DEMOS=OFF \
          -DBUILD_CPU_DEMOS=OFF -DBUILD_UNIT_TESTS=OFF -DINSTALL_EXTRA_LIBS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo \
          -DINCLUDE_INSTALL_DIR=%{_includedir}/bullet/
%make_build
cd -
doxygen Doxyfile
%install
%make_install -C build
%post
/sbin/ldconfig
%postun
/sbin/ldconfig

%files
%doc LICENSE.txt README.md AUTHORS.txt VERSION
%{_libdir}/*.so.*

%files devel
%{_includedir}/bullet/{*.h,Bullet3Collision,Bullet3Common,Bullet3Dynamics,Bullet3Geometry,Bullet3OpenCL}
%{_includedir}/bullet/{BulletCollision,BulletDynamics,BulletInverseDynamics,BulletSoftBody,InverseDynamics,LinearMath}
%{_includedir}/bullet/{ConvexDecomposition,GIMPACTUtils,HACD,BulletFileLoader,Bullet2FileLoader,BulletWorldImporter,BulletXmlWorldImporter}
%{_libdir}/*.so
%{_libdir}/pkgconfig/bullet.pc
%{_libdir}/cmake/bullet

%files help
%doc docs/Bullet_User_Manual.pdf docs/BulletQuickstart.pdf docs/GPU_rigidbody_using_OpenCL.pdf html

%changelog
* Wed Feb 12 2020 Shuaishuai Song <songshuaishuai2@huawei.com> - 2.87-6
- Package init
